text
stringlengths
8
4.13M
use super::player::Player; use super::wizard::Wizard; use super::minion::Minion; use super::projectile::Projectile; use super::bonus::Bonus; use super::building::Building; use super::tree::Tree; #[derive(Clone, Debug, PartialEq)] pub struct World { pub tick_index: i32, pub tick_count: i32, pub width: f64, ...
use std::{cell::RefCell, collections::HashMap, net::SocketAddr, rc::Rc}; use naia_shared::StateMask; use crate::actors::actor_key::actor_key::ActorKey; use indexmap::IndexMap; #[derive(Debug)] pub struct MutHandler { actor_state_mask_list_map: HashMap<ActorKey, IndexMap<SocketAddr, Rc<RefCell<StateMask>>>>, } ...
#[doc = "Reader of register IOPENR"] pub type R = crate::R<u32, super::IOPENR>; #[doc = "Writer for register IOPENR"] pub type W = crate::W<u32, super::IOPENR>; #[doc = "Register IOPENR `reset()`'s with value 0"] impl crate::ResetValue for super::IOPENR { type Type = u32; #[inline(always)] fn reset_value() ...
extern crate byteorder; extern crate libc; #[macro_use] extern crate plugkit; use std::io::{BufReader, Error, ErrorKind, Read, Result}; use std::fs::File; use std::path::Path; use byteorder::{BigEndian, LittleEndian, ReadBytesExt}; use plugkit::file::{Importer, RawFrame}; use plugkit::context::Context; pub struct Pca...
fn main() { enum SpreadsheetCell { Int(i32), Float(f64), Text(String), } let row = vec![ SpreadsheetCell::Int(3), SpreadsheetCell::Text(String::from("blue")), SpreadsheetCell::Float(10.12), ]; } // rust needs to know what types will be in the vector //...
/// Creates an [`NSString`](foundation/struct.NSString.html) from a static /// string. /// /// # Feature Flag /// /// This macro is defined in [`foundation`](foundation/index.html), /// which requires the **`foundation`** /// [feature flag](index.html#feature-flags). /// /// # Examples /// /// This macro takes a either...
use prelude::*; #[derive(Copy, Clone, Serialize, Deserialize)] pub struct Tile { pub terrain: Terrain, pub mob_id: Option<MobId>, } #[derive(PartialEq, Eq, Debug, Copy, Clone, Serialize, Deserialize)] pub enum Terrain { Wall, Floor, ShortGrass, TallGrass, Brownberry, Exit, Entrance...
use std::env; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> where P: AsRef<Path>, { let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()) } fn valid_password_part1(line: &String) -> bool { ...
//! Matrixrices with dimensions known at compile-time. #![allow(missing_docs)] // we allow missing to avoid having to document the mij components. use std::fmt; use std::ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign, Index, IndexMut}; use std::mem; use std::slice::{Iter, IterMut}; use rand::{Ra...
use map_macros::{map, btree_map, set, btree_set}; fn main() { let mut mm = map!{}; println!("{:?}", mm); mm.insert("hello", "world"); let mm = btree_map!{"hello"=>"world", "yes"=>"ok"}; println!("{:?}", mm); let mm = set!{"hello", "yes"}; println!("{:?}", mm); let mm = bt...
//! Trace exporters use crate::{api, sdk}; use std::sync::Arc; use std::time::SystemTime; /// Describes the result of an export. #[derive(Debug)] pub enum ExportResult { /// Batch is successfully exported. Success, /// Batch export failed. Caller must not retry. FailedNotRetryable, /// Batch export...
use crate::cache::ResponseCache; use crate::error::Result; use crate::proto::{Proto, Request}; use serde::{Deserialize, Serialize}; use serde_json::{json, Map, Value}; use std::rc::Rc; pub trait Emeter { fn get_emeter_realtime(&mut self) -> Result<RealtimeStats>; fn get_emeter_month_stats(&mut self, year: u32...
use crow_ecs::{Entities, Entity, Joinable, Storage}; use crate::{ data::{Collider, ColliderType, Collision, Collisions, Grounded, Position, Velocity}, physics, time::Time, }; #[derive(Debug, Default)] pub struct PhysicsSystem { collisions: Collisions, } impl PhysicsSystem { pub fn new() -> Self {...
// This file is part of linux-epoll. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-epoll/master/COPYRIGHT. No part of linux-epoll, including this file, may be copied, modified, propagated, or distri...
pub mod evaluator; pub mod fan; pub mod fan_console; pub mod fan_hwmon_pwm; pub use fan::fan::Fan; pub use fan::fan_console::ConsoleFan; pub use fan::fan_hwmon_pwm::HwmonPwmFan;
mod get_blocks_proof; mod get_transactions_proof;
fn main() { yew::start_app::<npm_and_rest_web_sys::Model>(); }
use crate::{DocBase, VarType}; pub fn gen_doc() -> Vec<DocBase> { let fn_doc = DocBase { var_type: VarType::Variable, name: "accdist", signatures: vec![], description: "Accumulation/distribution index.", example: "", returns: "", arguments: "", remarks...
// Copyright 2018 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. pub struct Size { pub width: u32, pub height: u32, } pub fn get_window_size() -> Result<Size, failure::Error> { Err(failure::err_msg( ...
use std::sync::Arc; use crate::{graphics::{SampleCount, Format, Backend}, Matrix4}; pub trait Surface { } #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum SwapchainError { ZeroExtents, SurfaceLost, Other } pub trait WSIFence : Sized {} pub struct PreparedBackBuffer<'a, B: Backend> { pub prepare_fence...
use std::{fmt::Debug, sync::Arc}; use parking_lot::{Mutex, MutexGuard}; use crate::buffer_tree::partition::PartitionData; pub(crate) trait PostWriteObserver: Send + Sync + Debug { fn observe(&self, partition: Arc<Mutex<PartitionData>>, guard: MutexGuard<'_, PartitionData>); }
use std::{ cell::UnsafeCell, clone::Clone, mem::MaybeUninit, ops::Deref, ptr, sync::{Arc, Once}, }; /// Helps you create C-compatible string literals, like `c_string!("Hello!")` -> `b"Hello!\0"`. macro_rules! c_string { ($s:expr) => { concat!($s, "\0").as_bytes() }; } /// Macro to ...
use std::sync::{Arc, atomic::{AtomicU64, Ordering}, Mutex, Condvar}; use sourcerenderer_core::graphics::{Format, SampleCount, Surface, Swapchain, Texture, TextureInfo, TextureViewInfo, TextureUsage, TextureDimension}; use wasm_bindgen::JsCast; use web_sys::{Document, HtmlCanvasElement, WebGl2RenderingContext}; use cr...
#[macro_use] extern crate conrod; mod gui; mod config; mod gui_result; mod reasonable_main; pub use gui::{run, run_config}; pub use config::Config; pub use gui_result::GuiResult; pub use reasonable_main::{reasonable_main, Command}; pub use conrod::color;
use crate::codegen::segment::*; use crate::parser::Segment; use crate::parser::Source; use anyhow::Result; pub fn gen_push(vm_name: &str, seg: Segment, index: i64, _source: Source) -> Result<String> { let asm = vec![format!("// push {:?} {}", seg, index), gen_segment_read(vm_name, seg, index), gen_stack_push()?]....
#[macro_use] extern crate error_chain; extern crate url; mod errors; mod url_example; pub fn run() { //let run = url_example::run_parse; //let run = url_example::run_base_url; //let run = url_example::run_join; //let run = url_example::run_exposes; //let run = url_example::run_origin; let run ...
use std::env; use std::error::Error; use std::fs; use bioinformatics_algorithms::revc; fn main() -> Result<(), Box<dyn Error>> { let input: String = env::args() .nth(1) .unwrap_or("data/rosalind_ba1c.txt".into()); let data = fs::read_to_string(input)?; let mut lines = data.lines(); le...
/* * Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. * * Note: * The length of both num1 and num2 is < 5100. * Both num1 and num2 contains only digits 0-9. * Both num1 and num2 does not contain any leading zero. * You must not use any built-in BigInteger libr...
use core::{ptr, slice}; /// An iterator that removes the items from a `SmallVec` and yields them by value. /// /// Returned from [`SmallVec::drain`][1]. /// /// [1]: struct.SmallVec.html#method.drain pub struct Drain<'a, T: 'a> { pub(crate) iter: slice::IterMut<'a, T>, } impl<'a, T: 'a> Iterator for Drain<'a, T> ...
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CFG { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W...
mod schema; use diesel::prelude::*; use model::*; use std::collections::HashMap; use std::str::FromStr; use thiserror::Error; #[macro_use] extern crate diesel; pub struct SqliteClient { scorelog_db_url: String, song_db_url: String, score_db_url: String, } impl SqliteClient { fn new(scorelog_db_url: ...
extern crate peg; fn main() { peg::cargo_build("src/grammar/smtp.rustpeg"); }
use crate::error::HandleError::*; use serde::Serialize; use std::convert::Infallible; use std::num::ParseIntError; use thiserror::Error; use warp::{http::StatusCode, Rejection, Reply}; #[derive(Debug, Error)] pub enum HandleError { #[error("AuthorizationCodeIsNotFound")] AuthorizationCodeIsNotFound, #[err...
mod builder; use self::builder::*; use firefly_diagnostics::CodeMap; use firefly_mlir::{self as mlir, Context, OwnedContext}; use firefly_pass::Pass; use firefly_session::Options; use firefly_syntax_ssa as syntax_ssa; use log::debug; pub struct SsaToMlir<'a> { context: Context, codemap: &'a CodeMap, opti...
// 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::registry::base::{Command, Registry, State}; use crate::switchboard::base::{ SettingAction, SettingActionData, SettingEvent, SettingRequest, ...
use std::ffi::OsString; use std::fs::read_dir; use std::path::Path; use std::sync::Arc; use std::time::Duration; use arrow_util::assert_batches_sorted_eq; use assert_matches::assert_matches; use data_types::{PartitionKey, TableId, Timestamp}; use ingester_query_grpc::influxdata::iox::ingester::v1::IngesterQueryRequest...
#[macro_use] extern crate rocket; extern crate hex; use core::str; use hex::FromHex; use url::form_urlencoded::{parse}; use regex::Regex; fn ascii_to_hex<'a>(text: String) -> String { let hex_text: String = hex::encode(text); format!("{}", hex_text) } fn hex_to_ascii<'a>(hex: String) -> String { le...
use std::cmp::Ordering; use std::collections::HashSet; use std::collections::VecDeque; use std::io; type Deck = VecDeque<u32>; /// Read cards. Terminates on blank line or EOF. fn read_player() -> Deck { let mut line = String::new(); io::stdin().read_line(&mut line).expect("error!"); let mut cards = VecDe...
#[derive(Debug, Clone)] pub struct AppState { pub templates: minijinja::Environment<'static>, pub database: sea_orm::DatabaseConnection, }
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] pub const CLSID_IITCmdInt: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4662daa2_d393_11d0_9a56_00c04fb68bf7); pub const CLSID_IITDatabase: ::windows::core::GUID = ::windows::co...
//! CLI config for the router using the RPC write path use crate::{ gossip::GossipConfig, ingester_address::IngesterAddress, single_tenant::{ CONFIG_AUTHZ_ENV_NAME, CONFIG_AUTHZ_FLAG, CONFIG_CST_ENV_NAME, CONFIG_CST_FLAG, }, }; use std::{ num::{NonZeroUsize, ParseIntError}, time::Durati...
#![allow(unused_imports)] #![allow(dead_code)] use std::collections::HashMap; use std::str; use rand::rngs::OsRng; use rsa::pkcs1::{ToRsaPrivateKey, ToRsaPublicKey}; use rsa::{RsaPrivateKey}; use super::digest::*; use super::system::*; // #[ derive( Debug, Clone, Serialize, Deserialize, PartialEq ) ] pub struct W...
// Copyright 2022 Datafuse Labs. // // 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 required by applicable law or agre...
mod managed_program; pub use managed_program::*; mod program_asset_schema; pub use program_asset_schema::*;
//! Convenient utility methods, mostly for printing `syntect` data structures //! prettily to the terminal. use highlighting::Style; use std::fmt::Write; #[cfg(feature = "parsing")] use parsing::ScopeStackOp; /// Formats the styled fragments using 24-bit colour /// terminal escape codes. Meant for debugging and testin...
use druid::kurbo::{BezPath}; use druid::piet::{FontFamily, FontStyle, ImageFormat, InterpolationMode}; use druid::kurbo; use druid::widget::prelude::*; use druid::{ Affine, AppLauncher, ArcStr, Color, Data, FontDescriptor, LocalizedString, MouseEvent, Point as DruidPoint, TextLayout, WindowDesc, }; use klein...
pub mod lexer; pub mod parser; pub mod resolver; pub mod types;
use crate::spec::{RelroLevel, TargetOptions}; pub fn opts() -> TargetOptions { TargetOptions { os: "linux".into(), dynamic_linking: true, families: vec!["unix".into()], has_rpath: true, position_independent_executables: true, relro_level: RelroLevel::Full, ha...
use std::convert::Infallible; use warp::Rejection; use warp::{hyper::StatusCode, reply::json, Filter, Reply}; use crate::{with_context, AppContext}; fn get_actor_id( context: AppContext, ) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { warp::path!("actor" / u32) .and(warp::get()) ...
mod day_1; mod day_2; mod day_3; mod day_4; mod day_5; mod day_8; mod day_9; use day_1::{find_three_items_that_sum_2020, find_two_items_that_sum_2020}; use day_2::{number_of_valid_passwords, PolicyStrategy}; use day_3::{count_trees, tree_product}; use day_4::{count_valid_passports, CountType}; use day_9::{all_numbers_...
mod utils; fn main() { let data = utils::load_input("./data/day_3.txt").unwrap(); let lines: Vec<&str> = data.split("\n").collect(); let configs = [[1, 1], [3, 1], [5, 1], [7, 1], [1, 2]]; let mut answer: u32 = 1; for config in configs.iter() { answer *= slop(&lines, config[0], config[1]...
//! Stream protocol implementation use std::{ io, marker::Unpin, pin::Pin, task::{Context, Poll}, }; use bytes::{Buf, BufMut, BytesMut}; use futures::ready; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use crate::crypto::v1::{Cipher, CipherKind}; // use super::BUFFER_SIZE; /// Reader wrapper tha...
//! stat implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstat.h.html #![no_std] extern crate platform; use platform::types::*; pub const S_IFMT: c_int = 00170000; pub const S_IFBLK: c_int = 0060000; pub const S_IFCHR: c_int = 0020000; pub const S_IFIFO: c_int = 0010000; pub c...
#[macro_use] extern crate fawkes_crypto; #[macro_use] extern crate fawkes_crypto_derive; #[macro_use] extern crate serde; pub mod circuit; pub mod native; pub mod constants; use crate::native::gen_test_data::gen_test_data; use crate::{ circuit::{CWithdrawPub, CWithdrawSec, c_withdraw}, native::{WithdrawPub...
// Copyright 2021 Datafuse Labs. // // 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 required by applicable law or agreed to ...
fn main() { let a = "a".parse::<i32>(); match a { Ok(val) => println!("{:?}", val), Err(e) => println!("{:#?}", e), } //println!("{:?}", a); }
use super::schema::NewsSourceType; use super::schema::news; #[derive(Queryable, Debug, Clone)] pub struct SourceAtom { pub id: i32, pub url: Option<String>, pub display_name: Option<String>, pub color: Option<String>, } #[derive(Queryable, Debug, Clone)] pub struct SourceRss { pub id: i32, p...
use std::io; use std::path; use std::fs; pub fn create_cache_dir(cache_config: &super::CacheDirConfig) -> io::Result<path::PathBuf> { use std::error::Error; let default_config = !cache_config.app_cache && !cache_config.user_cache && !cache_config.sys_cache ...
#![cfg_attr(not(feature = "std"), no_std)] use ink_env::Environment; use ink_lang as ink; use ink_prelude::vec::Vec; pub use contract_types::*; pub type Quantity = u64; pub type ClassId = u32; pub type TokenId = u64; pub type Metadata = Vec<u8>; pub type Chars = Vec<u8>; pub type Balance = <ink_env::DefaultEnvironmen...
// 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 ...
// auto generated, do not modify. // created: Wed Jan 20 00:44:03 2016 // src-file: /QtNetwork/qsslcipher.h // dst-file: /src/network/qsslcipher.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begi...
// Copyright 2022 Datafuse Labs. // // 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 required by applicable law or agreed to ...
use wasm_bindgen_test::*; use js_sys::*; #[wasm_bindgen_test] fn validate() { assert!(!WebAssembly::validate(&ArrayBuffer::new(42).into()).unwrap()); assert!(WebAssembly::validate(&2.into()).is_err()); }
#![no_std] #![no_main] #![feature(global_asm)] mod arch; mod panic; // The virt arch global_asm!(include_str!("arch/aarch64/qemu_virt/start.s")); pub use arch::aarch64::qemu_virt::QEMU_UART0_VIRT; mod kdriver; // Kernel public functions pub use kdriver::serial::{serial_log, serialc}; use kdriver::{kfs, uri_sys}; m...
extern crate image; extern crate nalgebra as na; use std::mem::swap; use shape; //use tf; use tf::Pose; #[derive(Debug)] pub struct GraphicsContext { pub tf_root: na::Matrix4<f32>, pub projection: na::Perspective3<f32>, pub img_width: u32, pub img_height: u32, pub imgbuf: image::RgbImage, } i...
extern crate parse_obj; use parse_obj::*; static TRIANGLE_OBJ: &'static str = r#" v -1.0 -1.0 0.0 v 1.0 -1.0 0.0 v 0.0 1.0 0.0 f 1// 2// 3// "#; static TRIANGLE_WITH_NORM: &'static str = r#" v -1.0 -1.0 0.0 v 1.0 -1.0 0.0 v 0.0 1.0 0.0 vt 1.0 1.0 1.0 vn 1.0 0.0 0.0 f 1/1/1 2/1/1 3/1/1 "#; #[test] fn test_iterat...
#![feature(asm)] #![feature(naked_functions)] #![feature(termination_trait_lib)] #![feature(thread_local)] #![feature(alloc_layout_extra)] #[cfg(not(unix))] compile_error!("lumen_rt_minimal is only supported on unix targets!"); #[macro_use] mod macros; mod config; mod logging; mod scheduler; mod sys; mod distribution...
use std::fs; fn main() { let data = fs::read_to_string("input").expect("Error"); let mut numbers: Vec<u32> = data.lines().map(|x| x.parse::<u32>().unwrap()).collect(); numbers.sort_unstable(); numbers = numbers .iter() .enumerate() .map(|(idx, x)| x - previous(idx, &numbers)) ...
//Tutorial developed by Philipp Oppermann - https://os.phil-opp.com/freestanding-rust-binary/ //Disabling std library from build. #![no_std] //Overwriting Entry Point #![no_main] use core::panic::PanicInfo; //Using our own Rust module for handling printing mod vga_buffer; //Function to be called when panic. #[panic_...
use std::collections::HashMap; use color_eyre::eyre::{eyre, Result, WrapErr}; use execute::shell; use serde::Deserialize; use crate::git::branch_name_from_issue; use crate::semver::get_version; use crate::State; /// Describes a value that you can replace an arbitrary string with when running a command. #[derive(Debu...
use std::collections::HashMap; use std::collections::HashSet; pub fn run(path: &str) { let input = std::fs::read_to_string(path).expect("Couldn't read data file"); let (steps, _) = parser::parse_steps(&input).expect("Couldn't parse input steps"); let mut step_deps = build_step_deps(&steps); let step...
fn main() { // This is so sad ;-( // https://github.com/rust-lang/cargo/issues/2599 println!("cargo:rerun-if-changed=client/public/channel.html"); println!("cargo:rerun-if-changed=client/public/favicon.ico"); println!("cargo:rerun-if-changed=client/public/login.html"); println!("cargo:rerun-if...
use gtk::*; pub fn open_file_dialog(window: ApplicationWindow) -> Option<String> { let open_dialog = FileChooserDialog::with_buttons( "Load image", Some(&window), FileChooserAction::Open, &[ ("_Cancel", ResponseType::Cancel), ("_Open", ResponseType::Accept) ] );...
use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::{Duration, Instant}; use std::{env, net}; use actix_web::{web, App, HttpRequest, HttpServer, Responder}; use tokio::time; static DEFAULT_ADDR: &str = "127.0.0.1:8080"; static COUNTER: AtomicUsize = AtomicUsize::new(0usize); async fn index(_req: HttpReque...
use std::{io, error, iter}; use std::collections::HashSet; use xml; fn find_attr<'a>(a: &'a Vec<xml::attribute::OwnedAttribute>, n: &str) -> Result<&'a str, Box<dyn error::Error>> { a.into_iter() .find(|q| q.name.prefix.is_none() && q.name.local_name == n) .map(|f| &*f.value) .ok_or_else(|...
#![cfg(target_family = "unix")] /// TODO: Would be better to use linux low level tty /// [Reference of low level api](https://linux.die.net/man/4/tty)
#[cfg(any(unix, macos))] use rscam; use crate::camera::CameraProvider; use std::vec::*; use std::fs; use std::io::Write; use std::sync::Arc; use bytes::buf::BufMut; pub struct PiCamera { width: usize, height: usize, frame_rate: usize, device : rscam::Camera, first_frame: Arc<Vec<u8>> }...
use crate::{ time::{TimePoint, TimePointSec}, NumBytes, Read, Write, }; /// This class is used in the block headers to represent the block time /// It is a parameterised class that takes an Epoch in milliseconds and /// and an interval in milliseconds and computes the number of slots. #[derive( Read, W...
fn main() { let mut v1 = vec![1,2,3]; let mut v2:Vec<i32> = vec![]; let x1 = v1.pop(); let x2 = v2.pop(); println!("x1={:?}, x2={:?}", x1, x2); }
#![cfg_attr(feature = "lints", allow(unstable_features))] #![cfg_attr(feature = "lints", feature(plugin))] #![cfg_attr(feature = "lints", plugin(clippy))] extern crate chrono; extern crate term; // TODO consolidate term, ansi_term and terminal_size extern crate open; extern crate icalendar; #[cfg(feature="shell")] ex...
pub mod pe_001; pub mod pe_002; pub mod pe_003; pub mod pe_004; pub mod pe_005; pub mod pe_006; pub mod pe_007; pub mod pe_008; pub mod aoc_001; pub mod aoc_002; pub mod aoc_003;
extern crate byteorder; use std::{io, fs}; use std::io::BufRead; use byteorder::{LittleEndian, ReadBytesExt}; extern crate yahtzeevalue; use yahtzeevalue::*; use yahtzeevalue::constants::*; fn read_state_value() -> io::Result<Vec<f64>> { let file = fs::File::open("state_value.bin")?; let size = file.metadata...
extern crate rand; extern crate piston; extern crate graphics; extern crate glutin_window; extern crate opengl_graphics; mod pong; mod game_object; fn main() { pong::play(); }
pub mod connection { mod codec { use byteorder::{BigEndian, ByteOrder, WriteBytesExt}; use shannon::Shannon; use std::io; use tokio_core::io::{Codec, EasyBuf}; const HEADER_SIZE: usize = 3; const MAC_SIZE: usize = 4; #[derive(Debug)] enum DecodeState {...
{{#with NewObjs~}} if {{list}}.iter().any(|&c| c {{~#if ../is_triangular}} >= {{else}} == {{/if~}} {{~#if set.var~}} ({{>set.id_getter def=set.def.arg item=set.var}}, {{>set.id_getter set item=../var~}}) {{~else~}} {{>set.id_getter set item=../var~}} {{/if~}}) { conti...
use input_i_scanner::{scan_with, InputIScanner}; use mod_int::ModInt998244353; use std::collections::HashMap; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); let (n, m) = scan_with!(_i_i, (usize, usize)); let k = scan_with!(_i_i, i32); let a = scan_with!...
#[macro_use] extern crate dotenv_codegen; #[macro_use] extern crate duct; fn main() { println!("Hello, world!"); let msg = cmd!("sh", "-c", "cd /home/fish/m/gitr && ls").stderr_to_stdout().read().unwrap(); println!("{}", msg); getvar("test".to_string()); } fn getvar(var: String) { // environment ...
use super::{Column, DataStore, PinModeRequirement}; use crate::error::Error; use crate::repo::{PinKind, PinMode, PinStore, References}; use async_trait::async_trait; use cid::{self, Cid}; use futures::stream::{StreamExt, TryStreamExt}; use once_cell::sync::OnceCell; use sled::{ self, transaction::{ Conf...
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
use super::chan; use futures::{Poll, Sink, StartSend, Stream}; use std::fmt; /// Send values to the associated `Receiver`. /// /// Instances are created by the [`channel`](fn.channel.html) function. pub struct Sender<T> { chan: chan::Tx<T, Semaphore>, } impl<T> Clone for Sender<T> { fn clone(&self) -> Self ...
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
use futures_util::stream::{self, Stream}; use http::{Request, StatusCode}; use platform::Body; use serde::{de::DeserializeOwned, Deserialize}; use snafu::ResultExt; use url::Url; macro_rules! api_url { ($resource:ident) => { url::Url::parse(concat!( "https://www.speedrun.com/api/v1/", ...
/*! Operation implementations This module contains implementations for operations ([crate::ops]) on OSCAR Schema specifications. !*/ mod oscar_doc; mod oscar_txt; pub(crate) use oscar_doc::OscarDoc; pub(crate) use oscar_txt::OscarTxt;
// Copyright 2020 - 2021 Alex Dukhno // // 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 required by applicable law or agreed...
use rule::Rule; #[test] fn between() { let code = "zzz"; let z = Rule::new(|_, _| Ok(34)); z.literal("z"); let test1: Rule<i32> = Rule::default(); test1.between(1, 3, &z); if let Ok(branches) = test1.scan(&code) { assert_eq!(branches[0], 34); assert_eq!(branch...
// raii.rs fn create_box() { // Выделить память для целого число в куче let _box1 = Box::new(3i32); // `_box1` здесь уничтожается, а память освобождается } fn main() { // Выделить память для целого число в куче let _box2 = Box::new(5i32); // Вложенная область видимости: { // Выдел...
use super::Graph; use std::collections::BinaryHeap; impl Graph { pub fn dijkstra(&self, s: usize) -> Vec<Option<i64>> { let mut v = vec![None; self.node_size]; let mut pq = BinaryHeap::new(); pq.push(Node{node:s, cost:0}); while let Some(tp) = pq.pop() { if v[tp.node] != None { continue; } ...
//! Error types use num_derive::FromPrimitive; use solana_program::program_error::ProgramError; use num_traits::FromPrimitive; use thiserror::Error; /// Errors that may be returned by the program. #[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] pub enum Error { /// Owner mismatch #[error("Owner ...
///! This module defines a trait which represents the idea of equality without ///! the possibility of coercion. Its usage in Firefly is to extend the behavior ///! of `Eq` for terms to respect the semantics of the `=:=` and `=/=` operators. /// This trait extends the notion of equality provided by `Eq` to cover the d...
/* Copyright 2020 Timo Saarinen 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 required by applicable law or agreed to in writing, software d...