text stringlengths 8 4.13M |
|---|
use itertools::Itertools;
fn main() {
let input = include_str!("../../../input/12.txt")
.split('\n')
.collect_vec();
let mut ship = Ship::new(&input);
let part_one_result = ship.journey();
println!("Manhattan distance: {}", part_one_result)
}
enum Direction {
North,
East,
S... |
use core::sync::atomic;
use core::{ptr};
use super::super::linux_def::IoVec;
use super::super::common::*;
use super::register::execute;
use super::register::Probe;
use super::squeue::SubmissionQueue;
use super::sys;
use super::util::{cast_ptr, unsync_load, Fd};
use super::porting::*;
#[cfg(feature = "unstable")]
use ... |
use types::MalVal;
use types::MalVal::{Nil,Bool,Int,Str,Sym,List,Vector,Hash,Func,MalFunc,Atom};
fn escape_str(s: &str) -> String {
s.chars().map(|c| {
match c {
'"' => "\\\"".to_string(),
'\n' => "\\n".to_string(),
'\\' => "\\\\".to_string(),
_ => c.to_string(),
}
}).col... |
//! this module manages reading and translating
//! the arguments passed on launch of the application.
pub mod clap_args;
mod app_launch_args;
mod install_launch_args;
pub use {
app_launch_args::*,
install_launch_args::*,
};
use {
crate::{
app::{App, AppContext},
conf::Conf,
displ... |
use input_i_scanner::InputIScanner;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.scan::<$t>() as $t
};
(($($t: ty),... |
//! An API wrapper for startuppong.com
//!
//! The wrapper is implemented as a few module level functions for accessing the endpoints. All of
//! the JSON responses are represented with structs. The rustc_serialize crate is heavily relied on
//! to handle decoding of JSON responses.
//!
//! Sign up for an account at [s... |
use std::collections::HashMap;
use std::collections::HashSet;
use instruction::*;
use error::*;
use std::fmt;
const ROM_START_ADDR: usize = 0x200;
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, PartialOrd, Ord)]
struct Pc(usize);
impl Pc {
fn advance(self, n: usize) -> Pc {
Pc(self.0 + n * 2)
}
}
... |
#[doc = "Reader of register UR10"]
pub type R = crate::R<u32, super::UR10>;
#[doc = "Reader of field `PA_END_2`"]
pub type PA_END_2_R = crate::R<u16, u16>;
#[doc = "Reader of field `SA_BEG_2`"]
pub type SA_BEG_2_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:11 - Protected area end address for bank 2"]
#[inli... |
use bevy::prelude::*;
use crate::construction::ConstructionSite;
#[derive(Debug, Clone)]
pub enum ResourceType {
Wasmium,
}
#[derive(Debug, Clone)]
pub struct Mine {
resource_type: ResourceType,
/// The total amount of this resource that exists in the "resource deposit" underlying this mine
deposit_q... |
//! ```elixir
//! @doc """
//! Returns `true` if the `function/arity` is exported from `module`.
//! """
//! @spec function_exported(module :: atom(), function :: atom(), arity :: 0..255)
//! ```
use std::convert::TryInto;
use anyhow::*;
use liblumen_alloc::erts::apply::find_symbol;
use liblumen_alloc::erts::excepti... |
#[inline(always)]
fn compare_elements(x: char, y: char) -> bool {
// My version
// x != y && x.to_ascii_lowercase() == y.to_ascii_lowercase()
// Optimization taken from Reddit:
// https://www.reddit.com/r/adventofcode/comments/a3912m/2018_day_5_solutions/eb4ilyz/
x as u8 ^ 32 == y as u8
}
pub fn pa... |
use crate::cluster_api;
use crate::cluster_management;
use crate::deployment_management;
use crate::runtime_plugin_manager;
use clap::{App, Arg};
use common::config::*;
use daemonize::Daemonize;
// use std::sync::mpsc::{Receiver, Sender};
use std::env;
use std::path::Path;
use std::sync::mpsc;
use std::thread;
use chr... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ICompositionCapabilitiesInteropFactory(pub ::w... |
use super::*;
use ffi_support::{FfiStr, ExternError};
#[no_mangle]
pub extern fn indy_res_context_create(pool_handle: Handle,
submitter_did: FfiStr<'_>,
submitter_did_private_key: &ByteArray,
context_json:... |
use winapi::um::winuser::{WS_OVERLAPPEDWINDOW, WS_VISIBLE, WS_DISABLED, WS_MAXIMIZE, WS_MINIMIZE, WS_CAPTION,
WS_MINIMIZEBOX, WS_MAXIMIZEBOX, WS_SYSMENU, WS_THICKFRAME, WS_CLIPCHILDREN, WS_CLIPSIBLINGS };
use crate::win32::base_helper::check_hwnd;
use crate::win32::window_helper as wh;
use crate::{NwgError, Icon};
use... |
mod draw;
use cogs_gamedev::controls::InputHandler;
use crate::{
assets::Assets,
boilerplates::{FrameInfo, Gamemode, GamemodeDrawer, Transition},
controls::{Control, InputSubscriber},
modes::ModeEnding,
simulator::{
board::Board,
floodfill::{FloodFillError, FloodFiller},... |
fn main() {
loop {
//emulator.updateCpu()
//emulator.updatePpu()
}
}
|
#[doc = "Reader of register CLIDR"]
pub type R = crate::R<u32, super::CLIDR>;
#[doc = "Reader of field `CL1`"]
pub type CL1_R = crate::R<u8, u8>;
#[doc = "Reader of field `CL2`"]
pub type CL2_R = crate::R<u8, u8>;
#[doc = "Reader of field `CL3`"]
pub type CL3_R = crate::R<u8, u8>;
#[doc = "Reader of field `CL4`"]
pub t... |
use std::mem;
use Error;
/// Encode a natural number according to section 7.2.1
/// of the Simplicity tech report
pub fn encode(n: usize) -> Vec<bool> {
assert_ne!(n, 0); // Cannot encode zero
let len = 8 * mem::size_of::<usize>() - n.leading_zeros() as usize - 1;
if len == 0 {
vec![false]
}... |
extern crate alloc;
use alloc::collections::BTreeMap;
use std::{mem, slice};
use uefi::guid::Guid;
use uefi::status::{Error, Result};
unsafe fn smm_cmd(cmd: u8, subcmd: u8, arg: u32) -> u32 {
let res;
asm!(
"out 0xB2, $0"
: "={eax}"(res)
: "{eax}"(((subcmd as u32) << 8) | (cmd as u32))... |
use smithay::{
delegate_presentation, delegate_xdg_decoration, delegate_xdg_shell,
desktop::{PopupKind, Space, Window},
input::{
pointer::{Focus, GrabStartData as PointerGrabStartData},
Seat,
},
reexports::{
wayland_protocols::xdg::shell::server::xdg_toplevel::{self},
... |
use crate::{DocBase, VarType};
pub fn gen_doc() -> Vec<DocBase> {
vec![DocBase {
var_type: VarType::Variable,
name: "open",
signatures: vec![],
description: "Current open price.",
example: "",
returns: "",
arguments: "",
remarks: "Previous values may ... |
use crate::r#macro;
use super::{parser, semantics, LispErr, Pos};
use alloc::{
boxed::Box,
collections::{btree_map::BTreeMap, linked_list::LinkedList, vec_deque::VecDeque},
format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::{
cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd},
... |
mod asset_manager; pub use asset_manager::*;
mod asset_path; pub use asset_path::*;
|
#[doc = "Reader of register CC"]
pub type R = crate::R<u32, super::CC>;
#[doc = "Writer for register CC"]
pub type W = crate::W<u32, super::CC>;
#[doc = "Register CC `reset()`'s with value 0"]
impl crate::ResetValue for super::CC {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
use anyhow::{anyhow, Result};
use std::{collections::BTreeMap, fmt};
use tokio::process::Command;
const CMD: &str = "/usr/bin/ansible-playbook";
pub const INSTALL_HOST_PLAYBOOK: &str = "playbooks/roles/setup_host/playbook.yml";
#[derive(Debug)]
pub struct AnsibleCommand<'a> {
playbook: &'a str,
user: &'a str,... |
// See LICENSE file for copyright and license details.
use glfw;
use cgmath::{Vector2};
use visualizer::mgl;
use visualizer::types::{Time, ScreenPos};
use visualizer::gui::{ButtonManager, Button, ButtonId};
use visualizer::context::Context;
use visualizer::state_visualizer::{
StateVisualizer,
StateChangeComman... |
extern crate secp256k1;
#[macro_use]
extern crate lazy_static;
extern crate generic_array;
extern crate digest;
extern crate sha2;
extern crate ripemd160;
extern crate base58;
extern crate rand;
extern crate pbkdf2;
extern crate hmac;
#[macro_use]
extern crate hex_literal;
extern crate byteorder;
use std::marker::Phan... |
#![recursion_limit = "1024"]
extern crate chrono;
#[macro_use]
extern crate error_chain;
extern crate lalrpop_util;
#[macro_use]
extern crate lazy_static;
extern crate petgraph;
extern crate postgres;
extern crate regex;
extern crate rust_decimal;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate ... |
// Copyright 2017 Dasein Phaos aka. Luxko
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except a... |
use num_bigint::BigUint;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
use stark_curve::FieldElement;
use stark_hash::{stark_hash, Felt};
/// Computes the Pedersen hash.
///
/// Inputs are expected to be big-endian 32 byte slices.
#[pyfunction]
fn pedersen_hash_func(a: &[u8], b: &[u8]) -> PyResult<Vec<u8>... |
// Copyright (c) 2018-2022 Ministerio de Fomento
// Instituto de Ciencias de la Construcción Eduardo Torroja (IETcc-CSIC)
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the ... |
use std::any::Any;
use crate::{DefaultMutator, Mutator};
/*
These mutators try to achieve multiple things:
* avoid repetitions, such that if the value “7” was already produced, then it will not appear again
* cover most of the search space as quickly as possible. For example, for 8-bit unsigned integers,
... |
pub use self::as_any::AsAny;
pub use self::dyn_iter::DynIter;
pub use self::from_bytes::FromBytes;
pub use self::id::Id;
pub use self::inner_thread::InnerThread;
pub use self::map_access::MapAccess;
pub use self::network_abuser::NetworkAbuser;
pub use self::time::{Tick, Time};
pub mod view_lock;
mod as_any;
mod dyn_i... |
use std::fmt;
#[derive(Debug, Clone)]
pub struct Registers {
pub pc: u16, // Program Counter
pub sp: u16, // Stack Pointer
pub a: u8, // Accumulator
pub f: u8, // Flag Register
// General Purpose Flags
pub b: u8,
pub c: u8,
pub d: u8,
pub e: u8,
pub h: u8, // High
pub l:... |
// Box
// adalah tipe pointer u/ mengalokasi heap(tumpukan)
// menyediakan bentuk yang paling sederhana dari pengalokasikan heap di rust.
// Box menyediakan ownership untuk alokasi ini, dan drop isinya
// saat mereka keluar dari scope(lingkup)
//
use std::boxed::Box;
fn main() {
let slot = Box::new(3);
... |
pub mod init;
mod low_level;
mod command;
use dma;
use embed_stm::sdmmc::Sdmmc;
/// SD handle
// represents SD_HandleTypeDef
pub struct SdHandle {
registers: &'static mut Sdmmc,
lock_type: LockType,
rx_dma_transfer: dma::DmaTransfer,
tx_dma_transfer: dma::DmaTransfer,
context: Context,
state: ... |
const X: i32 = 10;
pub fn print() {
println!("lib::print {}", X)
}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
pub const DFS_ADD_VOLUME: u32 = 1u32;
pub const DFS_FORCE_REMOVE: u32 = 2147483648u32;
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct DFS_GET_PKT_ENTRY_... |
// This file is part of Webb.
// Copyright (C) 2021 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... |
use semver::Version;
use semver::VersionReq;
use semver::ReqParseError;
fn fix_exact_version_for_range(range: Option<String>) -> Result<VersionReq, ReqParseError> {
range.map(|r| {
Version::parse(r.as_str())
.map(|v| VersionReq::exact(&v))
.or_else(|_| VersionReq::parse(r.... |
//! Modfile interface
use std::ffi::OsStr;
use std::path::Path;
use mime::APPLICATION_OCTET_STREAM;
use tokio_io::AsyncRead;
use url::form_urlencoded;
use crate::multipart::{FileSource, FileStream};
use crate::prelude::*;
pub use crate::types::mods::{Download, File, FileHash};
/// Interface for the modfiles the aut... |
use yew::prelude::*;
use yew_router::components::RouterAnchor;
use crate::app::AppRoute;
pub struct DbCreate {
// link: ComponentLink<Self>
}
pub enum Msg {}
impl Component for DbCreate {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
... |
use structopt::StructOpt;
use super::{CliCommand, GlobalFlags};
pub const AFTER_HELP: &str = r#"EXAMPLES:
To fetch updates for all repositories:
$ deck update
To fetch updates for a specific repository:
$ deck update --repo stable
"#;
#[derive(Debug, StructOpt)]
pub struct Update {
/// Specific ... |
//! Config for socket addresses.
use std::{net::ToSocketAddrs, ops::Deref};
/// Parsable socket address.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SocketAddr(std::net::SocketAddr);
impl Deref for SocketAddr {
type Target = std::net::SocketAddr;
fn deref(&self) -> &Self::Target {
&self.0... |
// extern crate typed_arena;
// #[derive(PartialOrd, PartialEq)]
// struct Tree<'a, T: 'a + Ord> {
// l: Option<&'a mut Tree<'a, T>>,
// r: Option<&'a mut Tree<'a, T>>,
// data: T,
// }
// impl<'a, T: 'a + Ord> Tree<'a, T> {
// fn new(t: T) -> Tree<'a, T> {
// Tree {
// l: None,
//... |
//! A custom kubelet backend that can run [waSCC](https://wascc.dev/) based workloads
//!
//! The crate provides the [`WasccProvider`] type which can be used
//! as a provider with [`kubelet`].
//!
//! # Example
//! ```rust,no_run
//! use kubelet::{Kubelet, config::Config};
//! use kubelet::store::oci::FileStore;
//! u... |
//! Process-associated operations.
#[cfg(not(target_os = "wasi"))]
mod chdir;
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
mod chroot;
mod exit;
#[cfg(not(target_os = "wasi"))] // WASI doesn't have get[gpu]id.
mod id;
#[cfg(not(target_os = "espidf"))]
mod ioctl;
#[cfg(not(any(target_os = "espidf", targe... |
#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::Term;
use crate::erlang::spawn_apply_1;
#[native_implemented::function(erlang:spawn/1)]
pub fn result(process: &Process, function: Term) -... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless ... |
//! Base widgets
//! ============
//!
//! *Note*: this list is not exhaustive as backend crates may also define custom widgets.
//!
//! Combining widgets
//! -----------------
//!
//! The set of widgets have been designed to do as little as necessary. This means that you have
//! different widgets to specify background... |
//! A late-initialized static reference.
use std::{
marker::PhantomData,
ptr::{self, NonNull},
sync::atomic::{AtomicPtr, Ordering},
};
use crate::{
external_types::RMutex,
pointer_trait::{GetPointerKind, ImmutableRef, PK_Reference},
prefix_type::{PrefixRef, PrefixRefTrait},
};
/// A late-init... |
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
use std::collections::HashSet;
use regex::Regex;
use petgraph::graphmap::DiGraphMap;
use petgraph::Incoming;
//use petgraph::dot::{Dot, Config};
fn part1(g : &DiGraphMap<&str, i64>) -> i64 {
let mut count : i64 = 0;
let mut to_visit : Vec<&str> = ... |
#[macro_use]
extern crate serde_derive;
extern crate bincode;
pub mod model;
pub mod protocol;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let x = super::protocol::Packet::Join{nickname: "hi"};
let encoded: Vec<u8> = super::protocol::serialize(&x).unwrap();
let decoded: super::proto... |
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::{
capability::*,
model::{addable_directory::AddableDirectory, *},
},
directory_broker,
fidl::endpoints::{Clien... |
pub mod any_all;
pub mod by_ref;
pub mod chain;
pub mod consumer;
pub mod cycle;
pub mod filter_map_flat_map;
pub mod find;
pub mod fold;
pub mod iterator;
pub mod iterator_ii;
pub mod map_filter;
pub mod nth_last;
pub mod peekable;
pub mod position;
pub mod scan;
pub mod skip_take;
pub mod zip;
|
#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;
use std::convert::TryInto;
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::Term;
use crate::erlang::unique_integer::{unique_integer, Options};
#[native_implemented::function(erlang:uniq... |
use crate::game;
pub struct Engine {
pub game: game::Game,
}
impl Engine {
pub fn init(&mut self) {
}
pub fn start(&mut self) {
self.game.welcome();
loop {
self.game.play();
if !self.game.playing() {
break
}
}
self.ga... |
use crate::flat;
use crate::flat::PrimitiveSubtype::*;
use crate::raw::Spanned;
use serde::{Deserialize, Serialize};
use std::cmp;
use std::convert::TryFrom;
pub fn typeshape(ty: &Type, wire_format: WireFormat) -> TypeShape {
let unalined_size = unaligned_size(ty, wire_format);
let alignment = alignment(ty, fa... |
use std::fmt;
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct TextRange {
start: u32,
end: u32,
}
impl fmt::Debug for TextRange {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[{}; {})", self.start(), self.end())
}
}
impl TextRange {
pub fn from_to(start: u32, end: u3... |
// #[derive(Debug)]
// struct Country {
// pop: usize,
// capital: String,
// leader_name: String,
// }
// fn main() {
// let pop = 500;
// let capital = "Dora".to_string();
// let leader_name = "Caleb".to_string();
// let ella = Country {
// pop,
// captial,
// lea... |
// Implement repeating-key XOR
// Here is the opening stanza of an important work of the English language:
// Burning 'em, if you ain't quick and nimble
// I go crazy when I hear a cymbal
// Encrypt it, under the key "ICE", using repeating-key XOR.
// In repeating-key XOR, you'll sequentially apply each byte of the k... |
//! CBOR Value object representation
//!
//! While it is handy to be able to construct into the intermediate value
//! type it is also not recommended to use it as an intermediate type
//! before deserialising concrete type:
//!
//! - it is slow and bloated;
//! - it takes a lot dynamic memory and may not be compatible... |
use super::RECURSIVE_INDICATOR;
use crate::{
abi_stability::stable_abi_trait::get_type_layout, sabi_types::Constructor, std_types::RSlice,
test_utils::AlwaysDisplay, type_layout::TypeLayout, StableAbi,
};
mod display {
use super::*;
#[repr(C)]
#[derive(StableAbi)]
#[sabi(phantom_const_param =... |
#[macro_use(lazy_static)]
extern crate lazy_static;
extern crate serde;
#[macro_use]
extern crate specs_derive;
use std::fmt::Display;
use rltk::console;
use specs::prelude::*;
use specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
use specs::WorldExt;
pub use components::*;
pub use context::*;
pub use game_log... |
use actix_web::{error, http::StatusCode, HttpRequest, HttpResponse};
use thiserror::Error;
use crate::models::ErrorResponse;
#[derive(Error, Debug)]
pub enum CustomError {
#[error("A validation error has occurred.")]
ValidationError,
#[error("The specified resource cannot be found.")]
NotFound,
#[... |
fn main(){
println!("Hello the world!");
}
|
pub struct IntBST {
root: Option<Box<TreeNode>>,
size: isize,
}
impl IntBST {
pub fn new() -> IntBST {
IntBST {
root: None,
size: 0,
}
}
pub fn addR(&mut self, x:isize) {
self.addH(x, &self.root);
self.size += 1;
}
fn addH(&mut self... |
use crate::TimeTracker;
use std::fs::OpenOptions;
impl<'a> TimeTracker<'a> {
pub fn clear(&self) {
OpenOptions::new()
.write(true)
.truncate(true)
.create(true)
.open(&self.config.raw_data_path)
.unwrap();
OpenOptions::new()
.w... |
use crate::Region;
use game_lib::{
bevy::{math::Vec2, reflect::Reflect},
derive_more::{Add, AddAssign, Display, From, Into, Sub, SubAssign},
serde::{Deserialize, Serialize},
};
use std::{
convert::{TryFrom, TryInto},
num::TryFromIntError,
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg... |
#[doc = "Reader of register MACHWF2R"]
pub type R = crate::R<u32, super::MACHWF2R>;
#[doc = "Reader of field `RXQCNT`"]
pub type RXQCNT_R = crate::R<u8, u8>;
#[doc = "Reader of field `TXQCNT`"]
pub type TXQCNT_R = crate::R<u8, u8>;
#[doc = "Reader of field `RXCHCNT`"]
pub type RXCHCNT_R = crate::R<u8, u8>;
#[doc = "Rea... |
#[doc = "Reader of register CCSIDR"]
pub type R = crate::R<u32, super::CCSIDR>;
#[doc = "Reader of field `LineSize`"]
pub type LINESIZE_R = crate::R<u8, u8>;
#[doc = "Reader of field `Associativity`"]
pub type ASSOCIATIVITY_R = crate::R<u16, u16>;
#[doc = "Reader of field `NumSets`"]
pub type NUMSETS_R = crate::R<u16, ... |
use std::{
cmp::Reverse,
collections::{BinaryHeap, HashSet},
};
use proconio::input;
fn main() {
input! {
n: usize,
mut k: usize,
a: [u64; n],
};
let mut heap = BinaryHeap::new();
let mut seen = HashSet::new();
for &x in &a {
if seen.contains(&x) {
... |
use std::env;
use std::io;
#[derive(Debug, Clone)]
enum LexItem {
LParen,
RParen,
Op(char),
Num(u64),
}
fn lex(line: &str) -> Result<Vec<LexItem>, String> {
let mut result = vec![];
let mut number = String::new();
for c in line.chars() {
match c {
'0'..='9' => number.pu... |
#[doc = "Reader of register IER"]
pub type R = crate::R<u32, super::IER>;
#[doc = "Writer for register IER"]
pub type W = crate::W<u32, super::IER>;
#[doc = "Register IER `reset()`'s with value 0"]
impl crate::ResetValue for super::IER {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
//! Variable mapping and metadata.
use rustc_hash::FxHashSet as HashSet;
use partial_ref::{partial, PartialRef};
use varisat_formula::{Lit, Var};
use varisat_internal_proof::ProofStep;
use crate::{
context::{parts::*, set_var_count, Context},
decision, proof,
};
pub mod data;
pub mod var_map;
use data::{S... |
use crate::protocol::parts::type_id::TypeId;
use std::sync::Arc;
use vec_map::VecMap;
// The structure is a bit weird; reason is that we want to retain the transfer format
// which seeks to avoid String duplication
/// Metadata of a field in a `ResultSet`.
#[derive(Clone, Debug)]
pub struct FieldMetadata {
inner:... |
use openexr_sys as sys;
use crate::core::error::Error;
type Result<T, E = Error> = std::result::Result<T, E>;
/// A KeyCode object uniquely identifies a motion picture film frame.
/// The following fields specifiy film manufacturer, film type, film
/// roll and the frame's position within the roll.
///
/// # Fields
... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct BluetoothLEAdvertisement(pub ::windows::core::... |
extern crate piston;
extern crate graphics;
extern crate glutin_window;
extern crate opengl_graphics;
extern crate rand;
use std::collections::LinkedList;
use piston::window::WindowSettings;
use piston::event_loop::*;
use piston::input::*;
use glutin_window::GlutinWindow as Window;
use opengl_graphics::{ GlGraphics... |
use gitter::{self, Gitter};
use gtk;
use gtk::{ContainerExt, EntryExt, LabelExt, WidgetExt};
use relm::Update;
use relm::{Relm, Widget};
use std::time::Duration;
use std::env;
use core::msg::{AppState, Msg};
use core::model::Model;
use futures_glib;
pub struct Win {
model: Model,
window: gtk::ApplicationWind... |
use proc_macro;
use proc_macro::TokenStream;
use std::str::FromStr;
#[cfg(feature = "enabled")]
#[proc_macro_attribute]
pub fn const_if_feature_enabled(_: TokenStream, item: TokenStream) -> TokenStream {
let string = item.to_string();
let fn_index = string.find("fn").unwrap();
let res = format!("{}{} {}", ... |
pub trait Solution {
fn check_it(x: i32) -> i32;
}
pub struct Solution1;
pub struct Solution2;
impl Solution for Solution1 {
fn check_it(x: i32) -> i32 {
x
}
}
impl Solution for Solution2 {
fn check_it(x: i32) -> i32 {
x + 1
}
} |
//! # msfs-rs
//!
//! These bindings include:
//!
//! - MSFS Gauge API
//! - SimConnect API
//! - NanoVG API
//!
//! ## Building
//!
//! Tools such as `cargo-wasi` may not work. When in doubt, try invoking
//! `cargo build --target wasm32-wasi` directly.
//!
//! If your MSFS SDK is not installed to `C:\MSFS SDK` you wi... |
pub(crate) mod calculator;
|
//! Unix domain sockets for Windows
#[cfg(windows)]
extern crate winapi;
#[cfg(windows)]
extern crate tempfile;
#[cfg(windows)]
mod stdnet;
#[cfg(windows)]
pub use crate::stdnet::{
from_path, AcceptAddrs, AcceptAddrsBuf, SocketAddr, UnixListener, UnixListenerExt, UnixStream,
UnixStreamExt,
};
|
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! # Implementation of `ucal.h`.
//!
//! As a general piece of advice, since a lot of documentation is currently elided,
//! see the unit tests for exampl... |
/*
An experiment to use a greedy optimizer for landing a spaceship on the Moon from the Earth.
Hopefully, without crashing. :)
This is example is currently working, but is far from realistic.
TODO:
- [x] Add rigid body physics
- [ ] Add gravity
- [ ] Add force control of spaceship (instead of acceleration)
- [ ] Ad... |
use midi_message::MidiMessage;
use color::Color;
use color_strip::ColorStrip;
use effects::effect::Effect;
use rainbow::get_rainbow_color;
pub struct Flash {
color_strip: ColorStrip
}
impl Flash {
pub fn new(led_count: usize) -> Flash {
Flash {
color_strip: ColorStrip::new(led_count)
... |
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Format {
Unknown,
R32UNorm,
R16UNorm,
R8Unorm,
RGBA8UNorm,
RGBA8Srgb,
BGR8UNorm,
BGRA8UNorm,
DXT1,
DXT1Alpha,
DXT3,
DXT5,
R16Float,
R32Float,
RG32Float,
RG16Float,
RGB32Float,
RGBA32Float,
RG16UNorm,
RG8UNorm,
R32UInt... |
//! Private module for selective re-export.
use crate::util::DenseNatMap;
use crate::Rewrite;
use std::fmt;
use std::iter::FromIterator;
use std::ops::Index;
/// A `RewritePlan<R>` is derived from a data structure instance and indicates how values of type
/// `R` (short for "rewritten") should be rewritten. When that... |
pub mod camera;
pub mod homogeneous;
pub mod interpolation;
pub mod projection;
pub mod semi_dense;
pub mod transform;
pub mod triangulation;
pub mod warp;
|
#![deny(missing_docs)]
//! A crate implementing cancellable synchronous network I/O.
//!
//! This crate exposes structs [TcpStream](struct.TcpStream.html),
//! [TcpListener](struct.TcpListener.html) and [UdpSocket](struct.UdpSocket.html)
//! that are similar to their std::net variants, except that I/O operations
//! c... |
use buffer::VkBufferSlice;
use texture::VkTextureView;
use crate::pipeline::VkShader;
use crate::rt::VkAccelerationStructure;
use crate::swapchain::VkBinarySemaphore;
use crate::sync::VkTimelineSemaphore;
use crate::texture::VkSampler;
use crate::{
VkDevice,
*,
};
#[derive(Copy, Clone, Debug, Eq, Hash, Partia... |
pub mod file_io {
pub fn some_function() {
println!("# some_function called");
}
pub fn some_function2() {
println!("# some_function2 called");
}
use std::{fs::File, io, io::BufRead, path::Path};
pub fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
... |
#[derive(Debug)]
pub struct Todo {
id: usize,
title: String,
is_done: bool,
}
impl Todo {
pub fn new(title: String) -> Todo {
Todo {
id: 0,
title,
is_done: false,
}
}
}
|
use std::{borrow::Cow, convert::Infallible, future::Future, str::FromStr};
use async_graphql::{
futures_util::task::{Context, Poll},
http::{WebSocketProtocols, WsMessage, ALL_WEBSOCKET_PROTOCOLS},
Data, Executor, Result,
};
use axum::{
body::{boxed, BoxBody, HttpBody},
extract::{
ws::{Close... |
extern crate rand;
extern crate ansi_term;
use ansi_term::{Style};
const PASSCODE_LEN: usize = 8;
fn main() {
let style = Style::new().bold();
for i in (0..1000000) {
let mut password = gen_string(PASSCODE_LEN);
password.insert(PASSCODE_LEN/2, '-');
println!("{}", style.paint( passw... |
pub struct PackageEntry {
/// File name of this entry
pub file_name: String,
/// The name of the directory this file is in.
/// '/' is always used as a directory separator in Valve's implementation.
/// Directory names are also always lower cased in Valve's implementation.
pub directory_name: String,
//... |
use std::ffi::OsStr;
use std::io::{self, Error, ErrorKind, Result};
use std::iter::once;
use std::os::windows::ffi::OsStrExt;
use std::sync::mpsc::TryRecvError;
use crate::config::{Program, PtyConfig};
use crate::event::{OnResize, WindowSize};
use crate::tty::windows::child::ChildExitWatcher;
use crate::tty::{ChildEve... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.