text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: ulysseB/telamon path: /src/ir/size.rs use serde::{Deserialize, Serialize}; use std; use std::fmt; use std::sync::Arc; use utils::*; use crate::ir; /// A fully specified size. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Size { factor: u32, params: Vec<Arc<...
code_fim
hard
{ "lang": "rust", "repo": "ulysseB/telamon", "path": "/src/ir/size.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.static_factor != 1 { write!(fmt, "{}", self.static_factor)?; if !self.param_factors.is_empty() || !self.dim_factors.is_empty() { write!(fmt, "*")?; } } write!( fmt, "{}", self.param_fac...
code_fim
hard
{ "lang": "rust", "repo": "ulysseB/telamon", "path": "/src/ir/size.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>extern crate librespot_protocol as protocol; #[macro_use]pub mod util; mod audio_decrypt; mod audio_file; mod audio_key; mod authentication; mod connection; mod diffie_hellman; pub mod discovery; pub mod mercury; pub mod metadata; pub mod player; pub mod session; pub mod spirc; pub mod link; mod stream; ...
code_fim
hard
{ "lang": "rust", "repo": "xuio/librespot", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xuio/librespot path: /src/lib.rs #![crate_name = "librespot"] #![feature(plugin,zero_one,iter_arith)] #![plugin(protobuf_macros)] #![plugin(json_macros)] #[macro_use] extern crate lazy_static; <|fim_suffix|>#[macro_use]pub mod util; mod audio_decrypt; mod audio_file; mod audio_key; mod authen...
code_fim
hard
{ "lang": "rust", "repo": "xuio/librespot", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/rand/src/rngs/adapter/mod.rs / / Copyright 2018 Developers of the Rand project . / / / / Licensed under the Apache License Version 2 . 0 < LICENSE - APACHE or / / https : / / <|fim_suffix|>d read ; mod reseeding ; # [ allow ( deprecated ) ] pub...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/rand/src/rngs/adapter/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>d read ; mod reseeding ; # [ allow ( deprecated ) ] pub use self : : read : : { ReadError ReadRng } ; pub use self : : reseeding : : ReseedingRng ;<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/rand/src/rngs/adapter/mod.rs / / Copyright 2018 Developers of the Rand project . / ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/rand/src/rngs/adapter/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>r / / option . This file may not be copied modified or distributed / / except according to those terms . / / ! Wrappers / adapters forming RNGs mod read ; mod reseeding ; # [ allow ( deprecated ) ] pub use self : : read : : { ReadError ReadRng } ; pub use self : : reseeding : : ReseedingRng ;<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/rand/src/rngs/adapter/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn get_user_by_id( db: web::Data<Pool>, user_id: web::Path<i32>, ) -> Result<HttpResponse, Error> { Ok( web::block(move || db_get_user_by_id(db, user_id.into_inner())) .await .map(|user| HttpResponse::Ok().json(user)) .map_err(|_| HttpRespo...
code_fim
hard
{ "lang": "rust", "repo": "donmilorad87/blazingsun-rust-api", "path": "/src/handlers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: donmilorad87/blazingsun-rust-api path: /src/handlers.rs use super::models::{NewUser, User, Item, NewProduct, Product, Items}; use super::schema::users::dsl::*; use super::schema::products::dsl::*; use super::Pool; use crate::diesel::QueryDsl; use crate::diesel::RunQueryDsl; use actix_web::{web, ...
code_fim
hard
{ "lang": "rust", "repo": "donmilorad87/blazingsun-rust-api", "path": "/src/handlers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let _: usize = stdout.write(b"planning time = ")?; planning.show(); let _: usize = stdout.write(b"\n")?; let _: usize = stdout.write(b"coding time = ")?; coding.show(); let _: usize = stdout.write(b"\n")?; let _: usize = stdout.write(b"fixing time = ")?; fixing.show(); ...
code_fim
hard
{ "lang": "rust", "repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust", "path": "/Chapter 11/usetime1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust path: /Chapter 11/usetime1.rs // usetime1.rs -- using the second draft of the Time struct // compile usetime1.rs and mytime1.rs together #[macro_use] mod mytime1; use mytime1::*; use std::io; use std::io::prelude::*; use std::ops::Add; ...
code_fim
hard
{ "lang": "rust", "repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust", "path": "/Chapter 11/usetime1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> total = coding + fixing; let _: usize = stdout.write(b"coding + fixing = ")?; total.show(); let _: usize = stdout.write(b"\n")?; let morefixing: Time = Time_new!(3, 28); let _: usize = stdout.write(b"more fixing = ")?; morefixing.show(); let _: usize = stdout.write(b"\n")?...
code_fim
hard
{ "lang": "rust", "repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust", "path": "/Chapter 11/usetime1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theunkn0wn1/rustpad path: /rustpad/build.rs use rustpad_generator::generator::DeviceDescriptor; use std::path::PathBuf; <|fim_suffix|> println!("cargo:rerun-if-changed=warthog_throttle.toml"); println!("cargo:rerun-if-changed=build.rs"); let out_dir = std::env::var("OUT_DIR").unwra...
code_fim
medium
{ "lang": "rust", "repo": "theunkn0wn1/rustpad", "path": "/rustpad/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = PathBuf::from("warthog_throttle.toml"); let data: DeviceDescriptor = DeviceDescriptor::from_toml(input); let output = PathBuf::from(format!("{}/thrustmaster.rs", out_dir)); // let output = PathBuf::from("src/thrustmaster.rs"); data.generate_module(output); }<|fim_prefix|>//...
code_fim
medium
{ "lang": "rust", "repo": "theunkn0wn1/rustpad", "path": "/rustpad/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( neighbour_seats(&map, (0, 0)), vec![F, F, F, F, S(false), F, S(true), S(false)] ); assert_eq!( neighbour_seats(&map, (2, 2)), vec![ S(false), S(false), S(true), ...
code_fim
hard
{ "lang": "rust", "repo": "charypar/advent-of-code-2020", "path": "/seating-system/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charypar/advent-of-code-2020 path: /seating-system/src/main.rs use std::io::BufRead; #[derive(Debug, PartialEq, Copy, Clone)] enum Square { Floor, Seat(bool), } fn main() { let mut map = std::io::stdin() .lock() .lines() .map(|line| { line.unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "charypar/advent-of-code-2020", "path": "/seating-system/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kroisse/urashima path: /urashima-ast/src/expr/call.rs use urashima_util::Symbol; use super::{ExprArena, ExprIndex}; use crate::{ print::{self, Print}, find::Find, span::{Position, Span, Spanned}, }; #[cfg(feature = "deserialize")] use serde_derive_state::DeserializeState; #[cfg(fe...
code_fim
hard
{ "lang": "rust", "repo": "Kroisse/urashima", "path": "/urashima-ast/src/expr/call.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl InvokeExpression { pub(super) fn new( receiver: ExprIndex, method: Spanned<Symbol>, arguments: Spanned<Vec<ExprIndex>>, ) -> Self { InvokeExpression { receiver, method, arguments, __opaque: (), } } } ...
code_fim
hard
{ "lang": "rust", "repo": "Kroisse/urashima", "path": "/urashima-ast/src/expr/call.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn print_yellow(str: &str) { println!("{}", Yellow.paint(str)); } print_yellow("Bonjour! ಠ_ರೃ "); print_yellow("Je suis Lumière, your personal projector."); print_yellow("Press enter to start.\n"); for i in 0..slides.len() { let ref slide = slides[i]; prin...
code_fim
hard
{ "lang": "rust", "repo": "lenage/lumiere", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..slides.len() { let ref slide = slides[i]; println!(">>> {} [{}/{}]", Green.paint(&slide.title), i + 1, slides.len()); enter_to_go(); for point in &slide.bullet_points { println!("> {}", point); enter_to_go(); } } prin...
code_fim
hard
{ "lang": "rust", "repo": "lenage/lumiere", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lenage/lumiere path: /src/main.rs extern crate rustc_serialize; extern crate term_painter; use std::env; use std::io::prelude::*; use std::fs::File; use std::fmt; use rustc_serialize::json; use term_painter::ToStyle; use term_painter::Color::*; #[derive(RustcDecodable, RustcEncodable)] pub st...
code_fim
medium
{ "lang": "rust", "repo": "lenage/lumiere", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: provotum/node-rs path: /src/chain/mod.rs /// A block of the blockchain. pub mod block; /// The data structure of the blockchain. pub mod chain; <|fim_suffix|>/// `ChainWalker`s walk the blockchain in a specific, implementation-defined order. /// Each such walker is provided with a `ChainVisito...
code_fim
medium
{ "lang": "rust", "repo": "provotum/node-rs", "path": "/src/chain/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>/// `ChainWalker`s walk the blockchain in a specific, implementation-defined order. /// Each such walker is provided with a `ChainVisitor` which in turn is invoked by the walker /// at crucial steps during the traversal of the chain. When and if a visitor is invoked /// is specific to an implementation of...
code_fim
medium
{ "lang": "rust", "repo": "provotum/node-rs", "path": "/src/chain/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mtvu/influxdb_iox path: /parquet_catalog/src/internals/proto_io.rs use bytes::Bytes; use futures::TryStreamExt; use generated_types::influxdata::iox::preserved_catalog::v1 as proto; use iox_object_store::{IoxObjectStore, TransactionFilePath}; use object_store::{ObjectStore, ObjectStoreApi}; use ...
code_fim
hard
{ "lang": "rust", "repo": "mtvu/influxdb_iox", "path": "/parquet_catalog/src/internals/proto_io.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } /// Load and deserialize protobuf-encoded transaction from store. pub async fn load_transaction_proto( iox_object_store: &IoxObjectStore, path: &TransactionFilePath, ) -> Result<proto::Transaction> { let data = iox_object_store .get_catalog_transaction_file(path) ...
code_fim
hard
{ "lang": "rust", "repo": "mtvu/influxdb_iox", "path": "/parquet_catalog/src/internals/proto_io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> iox_object_store .put_catalog_transaction_file(path, data) .await .context(Write {})?; Ok(()) } /// Load and deserialize protobuf-encoded transaction from store. pub async fn load_transaction_proto( iox_object_store: &IoxObjectStore, path: &TransactionFilePath, ) ...
code_fim
hard
{ "lang": "rust", "repo": "mtvu/influxdb_iox", "path": "/parquet_catalog/src/internals/proto_io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tom-leys/godot-rust path: /gdnative-core/src/object/ownership.rs //! Typestates to express ownership and thread safety of Godot types. /// Marker that indicates that a value currently only has a /// single unique reference. /// /// Using this marker causes the type to be `!Sync`. #[derive(Copy,...
code_fim
hard
{ "lang": "rust", "repo": "tom-leys/godot-rust", "path": "/gdnative-core/src/object/ownership.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Ownership for Unique {} impl LocalThreadOwnership for Unique {} impl private::Sealed for Unique {} impl Ownership for Shared {} impl NonUniqueOwnership for Shared {} impl private::Sealed for Shared {} impl Ownership for ThreadLocal {} impl LocalThreadOwnership for ThreadLocal {} impl NonUniqueOwner...
code_fim
medium
{ "lang": "rust", "repo": "tom-leys/godot-rust", "path": "/gdnative-core/src/object/ownership.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> url.query_pairs_mut() .append_pair("blocklisttype", self.to_str()); } }<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /sdk/storage_blobs/src/blob/block_list_type.rs use azure_core::AppendToUrlQuery; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BlockListType { ...
code_fim
medium
{ "lang": "rust", "repo": "Azure/azure-sdk-for-rust", "path": "/sdk/storage_blobs/src/blob/block_list_type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /sdk/storage_blobs/src/blob/block_list_type.rs use azure_core::AppendToUrlQuery; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BlockListType { Committed, Uncommitted, All, } <|fim_suffix|> url.query_pairs_mut() .append_pair(...
code_fim
hard
{ "lang": "rust", "repo": "Azure/azure-sdk-for-rust", "path": "/sdk/storage_blobs/src/blob/block_list_type.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ftilde/rust-x86asm path: /src/test/instruction_tests/instr_lgs.rs use instruction_def::*; use test::run_test; use Operand::*; use Reg::*; use RegScale::*; use RegType::*; use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; #[test] fn lgs_1() { run...
code_fim
hard
{ "lang": "rust", "repo": "ftilde/rust-x86asm", "path": "/src/test/instruction_tests/instr_lgs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test( &Instruction { mnemonic: Mnemonic::LGS, operand1: Some(Direct(EBP)), operand2: Some(IndirectScaledDisplaced( RDX, Eight, 1416678466, Some(OperandSize::Far32), None, ...
code_fim
hard
{ "lang": "rust", "repo": "ftilde/rust-x86asm", "path": "/src/test/instruction_tests/instr_lgs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { loop { let mut input = String::new(); io::stdin().read_line(&mut input); let split: Vec<&str> = input.split(" ").collect(); if split.len() < 3 { break } let n: i32 = split[0].trim().parse().unwrap(); let k: i32 = split[1...
code_fim
hard
{ "lang": "rust", "repo": "richwandell/rust-algorithms", "path": "/src/bin/spoj_discrete_roots.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: richwandell/rust-algorithms path: /src/bin/spoj_discrete_roots.rs use std::io::{self}; use std::process; fn powmod(mut a: i32, mut b: i32, p: i32) -> i32 { let mut res = 1; while b > 0 { if b & 1 { res = res * a % p; } a = a * a % p; ...
code_fim
hard
{ "lang": "rust", "repo": "richwandell/rust-algorithms", "path": "/src/bin/spoj_discrete_roots.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { let mut input = String::new(); io::stdin().read_line(&mut input); let split: Vec<&str> = input.split(" ").collect(); if split.len() < 3 { break } let n: i32 = split[0].trim().parse().unwrap(); let k: i32 = split[1].trim().par...
code_fim
hard
{ "lang": "rust", "repo": "richwandell/rust-algorithms", "path": "/src/bin/spoj_discrete_roots.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { steps: self.steps.into_iter() .chain(rhs.steps.into_iter()) .collect(), nr_inv: self.nr_inv } } } pub struct ReverseStepIterator<'a, G: Graph, W: GraphWalker<'a, G>> { current: Option<&'a Step<'a, G, W>> } imp...
code_fim
hard
{ "lang": "rust", "repo": "kalou/whe.re", "path": "/backend/graph/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kalou/whe.re path: /backend/graph/src/lib.rs use std::cmp::Ordering; use std::collections::{BinaryHeap, HashMap, HashSet}; use std::time::{Duration, Instant}; use std::fmt::Debug; use std::hash::Hash; use std::hash::Hasher; use std::vec::Vec; use std::rc::Rc; use std::fmt; #[macro_use] extern c...
code_fim
hard
{ "lang": "rust", "repo": "kalou/whe.re", "path": "/backend/graph/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn bitand(self, rhs: Self) -> Self::Output { let nodes = self .steps .iter() .map(|step| step.to) .collect::<HashSet<&G::Node>>(); let other = rhs .steps .iter() .map(|step| step.to) .collec...
code_fim
hard
{ "lang": "rust", "repo": "kalou/whe.re", "path": "/backend/graph/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Menacing-Rust/capital_state_client path: /src/main.rs // #![windows_subsystem = "windows"] use amethyst::{ core::{frame_limiter::FrameRateLimitStrategy, transform::TransformBundle}, input::{InputBundle, StringBindings}, prelude::*, renderer::{ plugins::{RenderFlat2D, RenderToWindow}, ty...
code_fim
hard
{ "lang": "rust", "repo": "Menacing-Rust/capital_state_client", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let root = application_root_dir()?; let display = root.join("config").join("display.ron"); let assets = root.join("assets"); let input = root.join("config").join("input.ron"); let input_bundle = InputBundle::<StringBindings>::new().with_bindings_from_file(input)?; let render_bundle = RenderingBundl...
code_fim
medium
{ "lang": "rust", "repo": "Menacing-Rust/capital_state_client", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let game_data = GameDataBuilder::default() .with_bundle(TransformBundle::new())? .with_bundle(UiBundle::<StringBindings>::new())? .with_bundle(input_bundle)? .with_bundle(render_bundle)?; let mut game = Application::build(assets, Menu::default())? .with_frame_limit( FrameRateLimitStrategy::...
code_fim
hard
{ "lang": "rust", "repo": "Menacing-Rust/capital_state_client", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize)] pub struct Upgrade { name: String, race: String, #[serde(rename = "effectArray")] effect_array: Vec<EffectArrayEntry>, } type UpgradeData = HashMap<String, Upgrade>; pub struct Game { pub races: Vec<String>, pub unit_data: UnitData, pub weapon_data: Wea...
code_fim
hard
{ "lang": "rust", "repo": "mephi42/sc2-kill-calculator", "path": "/src/game_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Game { pub races: Vec<String>, pub unit_data: UnitData, pub weapon_data: WeaponData, pub upgrade_data: UpgradeData, } fn load_json<T>(path: &Path) -> Result<T, Error> where for<'de> T: serde::Deserialize<'de> { let f = File::open(path)?; let weapon_data = serde_json::fr...
code_fim
hard
{ "lang": "rust", "repo": "mephi42/sc2-kill-calculator", "path": "/src/game_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mephi42/sc2-kill-calculator path: /src/game_data.rs extern crate serde; extern crate serde_json; use error::Error; use std::collections::HashMap; use std::collections::HashSet; use std::fs::File; use std::iter::FromIterator; use std::path::Path; #[derive(Deserialize)] pub struct WeaponEffectIm...
code_fim
hard
{ "lang": "rust", "repo": "mephi42/sc2-kill-calculator", "path": "/src/game_data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn insert(title_str: &str, owner_str: &str) { let native: NaiveDateTime = Local::now().naive_utc(); let new_post = NewItem { title: title_str, owner: owner_str, due_date: Some(native), borrower: None }; let _ = database_connection::connection(|connecti...
code_fim
medium
{ "lang": "rust", "repo": "nakakura/study", "path": "/rust/database/src/models/items_query.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nakakura/study path: /rust/database/src/models/items_query.rs use diesel; use diesel::prelude::*; use schema::items; use schema::items::dsl::*; use chrono::prelude::*; use database_connection; use models::items::*; pub fn insert(title_str: &str, owner_str: &str) { let native: NaiveDateTime...
code_fim
hard
{ "lang": "rust", "repo": "nakakura/study", "path": "/rust/database/src/models/items_query.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let new_post = NewItem { title: title_str, owner: owner_str, due_date: Some(native), borrower: None }; let _ = database_connection::connection(|connection| { diesel::insert(&new_post).into(items::table) .execute(connection) }); } pub f...
code_fim
medium
{ "lang": "rust", "repo": "nakakura/study", "path": "/rust/database/src/models/items_query.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(map) } fn modify_map( map: SassMap, keys: impl Iterator<Item = Value>, modify: impl Fn(Value) -> Value, // default=true add_nesting: bool, span: Span, ) -> Value { let mut keys = keys.peekable(); fn modify_nested_map( mut mutable_map: SassMap, mut ke...
code_fim
hard
{ "lang": "rust", "repo": "connorskees/grass", "path": "/crates/compiler/src/builtin/modules/map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: connorskees/grass path: /crates/compiler/src/builtin/modules/map.rs use std::iter::Peekable; use crate::builtin::builtin_imports::*; use crate::builtin::{ map::{map_get, map_has_key, map_keys, map_merge, map_remove, map_set, map_values}, modules::Module, }; fn deep_merge_impl(map1: Sa...
code_fim
hard
{ "lang": "rust", "repo": "connorskees/grass", "path": "/crates/compiler/src/builtin/modules/map.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tempbottle/scaproust path: /examples/reqer.rs #[macro_use] extern crate log; extern crate env_logger; extern crate scaproust; use std::io; use scaproust::{Session, SocketType, Socket}; fn handle_comand(cmd: &str, socket: &mut Socket) { println!("User command: {:?}", cmd); match socket.se...
code_fim
hard
{ "lang": "rust", "repo": "tempbottle/scaproust", "path": "/examples/reqer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let session = Session::new().unwrap(); let mut socket = session.create_socket(SocketType::Req).unwrap(); socket.connect("tcp://127.0.0.1:5458").unwrap(); let mut input = String::new(); loop { match io::stdin().read_line(&mut input) { Ok(0) => return, Ok(_) => handle_com...
code_fim
medium
{ "lang": "rust", "repo": "tempbottle/scaproust", "path": "/examples/reqer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jasonwhite/reverie path: /tests/convert.rs /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ // FIXME: This test does some ve...
code_fim
hard
{ "lang": "rust", "repo": "jasonwhite/reverie", "path": "/tests/convert.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(target_arch = "x86_64")] #[allow(unused_mut)] unsafe fn open_syscall_sanity_check() -> i32 { let path = b"/dev/null\0".as_ptr() as usize; let flags: usize = 0x8000; // O_LARGEFILE let mode: usize = 0o644; let mut ret: usize; // // The following a...
code_fim
hard
{ "lang": "rust", "repo": "jasonwhite/reverie", "path": "/tests/convert.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn scans_alone_wrong_number_correctly() { let _ = try_init(); let text = "01F2c"; let mut scanner = Scanner::new(text); assert_eq!( scanner.next(), Some(Err(ScannerError { kind: ScannerErrorKind::NotInRadix('F', 8), pos: SymbolPosition { ...
code_fim
hard
{ "lang": "rust", "repo": "NotIntMan/n-lang", "path": "/tests/lexeme_scanner.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NotIntMan/n-lang path: /tests/lexeme_scanner.rs extern crate n_lang; extern crate env_logger; use n_lang::lexeme_scanner::{ Scanner, ScannerError, ScannerErrorKind, Token, TokenKind, SymbolPosition, }; #[allow(unused_imports)] use env_logger::try_init; #[test] fn scans...
code_fim
hard
{ "lang": "rust", "repo": "NotIntMan/n-lang", "path": "/tests/lexeme_scanner.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>@file main.rs @brief Main executable for picointerpreter */ //a Imports use std::fs::File; extern crate clap; use clap::{App, Arg}; extern crate picointerp; use picointerp::{PicoProgram}; // use picointerp::{PicoInterpIsize, PicoProgramIsize, PicoProgram}; //a Global constants for debug // const ...
code_fim
hard
{ "lang": "rust", "repo": "atthecodeface/picointerp", "path": "/picointerp/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>//a Imports use std::fs::File; extern crate clap; use clap::{App, Arg}; extern crate picointerp; use picointerp::{PicoProgram}; // use picointerp::{PicoInterpIsize, PicoProgramIsize, PicoProgram}; //a Global constants for debug // const DEBUG_MAIN : bool = 1 == 0; //a Main //fp main /// Run the ap...
code_fim
hard
{ "lang": "rust", "repo": "atthecodeface/picointerp", "path": "/picointerp/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atthecodeface/picointerp path: /picointerp/src/main.rs /*a Copyright 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 req...
code_fim
medium
{ "lang": "rust", "repo": "atthecodeface/picointerp", "path": "/picointerp/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NiklasEi/game-off-2020 path: /server/src/session.rs use log::{debug, info}; use actix::fut; use actix::prelude::*; use actix_broker::BrokerIssue; use actix_web_actors::ws; use serde_json::json; use crate::message::{CreateGame, GameMessage, GameState, JoinGame, LeaveGame, Message, StartGame}; ...
code_fim
hard
{ "lang": "rust", "repo": "NiklasEi/game-off-2020", "path": "/server/src/session.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn send_game_state(&self, payload: serde_json::Value, secret: String) { match &self.game_name { Some(game_name) => { let msg = GameState { sender_id: self.id.clone(), game_name: game_name.to_owned(), pa...
code_fim
hard
{ "lang": "rust", "repo": "NiklasEi/game-off-2020", "path": "/server/src/session.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs trait Foo {} impl Foo for dyn Send {} <|fim_suffix|>impl Foo for dyn Send + Sync + Send {} //~^ ERROR conflicting implementations //~| hard error fn main() {}<|fim_middle|>impl Foo for dyn Send + Sen...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Foo for dyn Sync + Send {} //~^ ERROR conflicting implementations //~| hard error impl Foo for dyn Send + Sync + Send {} //~^ ERROR conflicting implementations //~| hard error fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/lint/lint-incoherent-auto-trait-obje...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/lint/lint-incoherent-auto-trait-objects.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ime sqlx::migrate!() .run(&pg_pool) .await .expect("Failed to migrate"); gql_sql_test::run(Some(8000), pg_pool).await; }<|fim_prefix|>// repo: audunhalland/gql-sql-test path: /src/main.rs use gql_sql_test::config::Config; #[tokio::main] async fn main() { let config =...
code_fim
hard
{ "lang": "rust", "repo": "audunhalland/gql-sql-test", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: audunhalland/gql-sql-test path: /src/main.rs use gql_sql_test::config::Config; #[tokio::main] async fn main() { let config = Config { db_url: std::env::var("DATABASE_URL").expect("DATA<|fim_suffix|>ime sqlx::migrate!() .run(&pg_pool) .await .expect("Faile...
code_fim
hard
{ "lang": "rust", "repo": "audunhalland/gql-sql-test", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>bitflags! { /// IOMMU permission flags. pub struct IommuPerms: u32 { #[allow(clippy::identity_op)] /// Read Permission. const PERM_READ = 1 << 0; /// Write Permission. const PERM_WRITE = 1 << 1; /// Execute Permission. ...
code_fim
hard
{ "lang": "rust", "repo": "rcore-os/zCore", "path": "/zircon-object/src/dev/iommu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcore-os/zCore path: /zircon-object/src/dev/iommu.rs use {crate::object::*, crate::vm::*, alloc::sync::Arc, bitflags::bitflags}; /// Iommu refers to DummyIommu in zircon. /// /// A dummy implementation, do not take it serious. pub struct Iommu { base: KObjectBase, } impl_kobject!(Iommu); ...
code_fim
hard
{ "lang": "rust", "repo": "rcore-os/zCore", "path": "/zircon-object/src/dev/iommu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avr-rust/rust-legacy-fork path: /src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs // compile-pass // edition:2018 macro_rules! define_iso { () => { extern crate std as iso; }} <|fim_suffix|>fn main() { let s = S; }<|fim_middle|>::iso::thread_local! { static S: u...
code_fim
medium
{ "lang": "rust", "repo": "avr-rust/rust-legacy-fork", "path": "/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs", "mode": "psm", "license": "LicenseRef-scancode-other-permissive", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let s = S; }<|fim_prefix|>// repo: avr-rust/rust-legacy-fork path: /src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs // compile-pass // edition:2018 macro_rules! define_iso { () => { extern crate std as iso; }} ::iso::thread_local! { static S: u8 = 0; } <|fi...
code_fim
easy
{ "lang": "rust", "repo": "avr-rust/rust-legacy-fork", "path": "/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs", "mode": "spm", "license": "LicenseRef-scancode-other-permissive", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krdln/mlpretty path: /src/main.rs extern crate regex; extern crate colored; mod charpeek; use charpeek::Charpeek; use regex::Regex; use colored::Colorize; use std::collections::BTreeMap; use std::fs; use std::io::prelude::*; use std::io; use std::iter::{once,repeat}; use std::env; use std::p...
code_fim
hard
{ "lang": "rust", "repo": "krdln/mlpretty", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let file = files.entry(filename.to_owned()) .or_insert_with(|| fs::File::open(&filename) .map(|file| io::BufReader::new(file) .lines() .map(|...
code_fim
hard
{ "lang": "rust", "repo": "krdln/mlpretty", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn remove_group() { let package_hash_key: ContractPackageHash = runtime::get_key(PACKAGE_HASH_KEY) .and_then(Key::into_hash) .unwrap_or_revert() .into(); let group_name: String = runtime::get_named_arg(GROUP_NAME_ARG); storage::remove_contrac...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/smart_contracts/contracts/test/manage-groups/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let entry_point_name = REMOVE_GROUP_UREFS.to_string(); let remove_group_urefs = EntryPoint::new( entry_point_name, vec![ Parameter::new(GROUP_NAME_ARG, CLType::String), Parameter::new(UREFS_ARG, CLType::List(Box::new(CLType::URef))), ], CLTyp...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/smart_contracts/contracts/test/manage-groups/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /smart_contracts/contracts/test/manage-groups/src/main.rs #![no_std] #![no_main] #[macro_use] extern crate alloc; use alloc::{ boxed::Box, collections::BTreeSet, string::{String, ToString}, vec::Vec, }; use core::{convert::TryInto, iter...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/smart_contracts/contracts/test/manage-groups/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub enum CultureFeature { Warrior, Seafaring, } #[iron_data] pub struct Culture { pub id: usize, pub name: String, pub religion: ReligionId, pub language: LanguageId, pub features: Vec<CultureFeature>, } impl Culture { pub fn generate_character(&self, sex: Sex, age: isize...
code_fim
hard
{ "lang": "rust", "repo": "ristew/iron-game", "path": "/src/pops.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ristew/iron-game path: /src/pops.rs use inflector::cases::titlecase::to_title_case; use rand::{Rng, distributions::Slice, prelude::IteratorRandom, random, thread_rng}; use rand_distr::Uniform; use crate::*; use std::{cell::RefCell, collections::{HashMap, HashSet}, fmt::Debug, hash::Hash, rc::Rc...
code_fim
hard
{ "lang": "rust", "repo": "ristew/iron-game", "path": "/src/pops.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Input { pub fn new() -> Self { Self { was_pressed: false } } } impl<'a> specs::System<'a> for Input { type SystemData = ( Entities<'a>, Read<'a, Cursor, PanicHandler>, Write<'a, CollisionWorld, PanicHandler>, WriteStorage<'a, Collider>, ); ...
code_fim
medium
{ "lang": "rust", "repo": "Ralith/rustlike", "path": "/src/sim.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ralith/rustlike path: /src/sim.rs use ncollide2d::{ shape, world::{CollisionGroups, CollisionObjectHandle, GeometricQueryType}, }; use specs::shred::PanicHandler; use specs::{Component, Entities, Entity, Read, VecStorage, Write, WriteStorage}; use specs_derive::Component; <|fim_suffix|>...
code_fim
hard
{ "lang": "rust", "repo": "Ralith/rustlike", "path": "/src/sim.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Component)] #[storage(VecStorage)] pub struct Collider(pub CollisionObjectHandle); pub fn setup(world: &mut specs::World) { let collision = CollisionWorld::new(0.01); world.add_resource(collision); world.register::<Collider>(); } pub struct Input { was_pressed: bool, } impl Inp...
code_fim
medium
{ "lang": "rust", "repo": "Ralith/rustlike", "path": "/src/sim.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mryingster/ProjectEuler path: /problem_053.rs // -*- compile-command: "rustc -o problem_053_rs problem_053.rs" -*- // Copyright (c) 2016 Michael Caldwell fn qualifies(n:usize, r:usize) -> bool { let mut n = n; let limit = 1000000; let mut nr = n-r; let mut answer = 1; <|fim_suf...
code_fim
hard
{ "lang": "rust", "repo": "mryingster/ProjectEuler", "path": "/problem_053.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for n in 23..101 { for r in 1..n { if qualifies(n, r) == true { total += 1; } } } println!("{}", total); }<|fim_prefix|>// repo: mryingster/ProjectEuler path: /problem_053.rs // -*- compile-command: "rustc -o problem_053_rs problem_053....
code_fim
hard
{ "lang": "rust", "repo": "mryingster/ProjectEuler", "path": "/problem_053.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut total = 0; for n in 23..101 { for r in 1..n { if qualifies(n, r) == true { total += 1; } } } println!("{}", total); }<|fim_prefix|>// repo: mryingster/ProjectEuler path: /problem_053.rs // -*- compile-command: "rustc -o pro...
code_fim
medium
{ "lang": "rust", "repo": "mryingster/ProjectEuler", "path": "/problem_053.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn perlin(x: f64, y: f64) -> f64 { let xi = (x.floor() as usize) % 255; let yi = (y.floor() as usize) % 255; let xf = x - xi as f64; let yf = y - yi as f64; let u = fade(xf); let v = fade(yf); let aa = P[P[xi] + yi] % 4; let ab = P[P[xi] + yi + 1] % 4; l...
code_fim
hard
{ "lang": "rust", "repo": "petosegan/voronoi_mapgen", "path": "/src/perlin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let xf = x - xi as f64; let yf = y - yi as f64; let u = fade(xf); let v = fade(yf); let aa = P[P[xi] + yi] % 4; let ab = P[P[xi] + yi + 1] % 4; let ba = P[P[xi+1] + yi] % 4; let bb = P[P[xi+1] + yi + 1] % 4; let g1 = grad(aa, xf, yf); let g2 = grad(ab, xf, yf...
code_fim
hard
{ "lang": "rust", "repo": "petosegan/voronoi_mapgen", "path": "/src/perlin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: petosegan/voronoi_mapgen path: /src/perlin.rs const P: [usize; 512] = [183, 248, 164, 81, 145, 214, 152, 67, 104, 21, 240, 165, 110, 23, 33, 79, 108, 209, 228, 129, 101, 222, 238, 29, 195, 141, 113, 189, 200, 19, 184, 130, 36, 112, 168, 4, 30, 44, 215, 65, 211, 199, 251, 175, 13...
code_fim
hard
{ "lang": "rust", "repo": "petosegan/voronoi_mapgen", "path": "/src/perlin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rukai/canon_collision path: /canon_collision/src/cli.rs use getopts::Options; use std::env; use std::net::IpAddr; fn print_usage(program: &str, opts: Options) { let brief = format!("Usage: {} [options] [package_dir]\nIf no arguments are given the GUI menu is used instead. (excluding -g)", p...
code_fim
hard
{ "lang": "rust", "repo": "rukai/canon_collision", "path": "/canon_collision/src/cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(address) = matches.opt_str("a") { if let Ok(address) = address.parse() { results.address = Some(address); results.continue_from = ContinueFrom::Netplay; } else { print_usage(program, opts); results.continue_from = Cont...
code_fim
hard
{ "lang": "rust", "repo": "rukai/canon_collision", "path": "/canon_collision/src/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: obsoke/rustris path: /src/states/menu_state/spawner.rs use crate::states::play_state::tetromino::{u8_to_piece_type, Piece, PieceType}; use crate::states::Assets; use crate::util::DurationExt; use ggez::graphics::Point2; use ggez::{graphics, Context}; use rand; use std::time::Duration; const SPE...
code_fim
hard
{ "lang": "rust", "repo": "obsoke/rustris", "path": "/src/states/menu_state/spawner.rs", "mode": "psm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_suffix|> let piece_type = { let piece_type_no = rand::thread_rng().gen_range(0, 7); u8_to_piece_type(piece_type_no).unwrap() }; // spawn at a random x position way above viewable screen so pieces just // dont 'pop' in but kinda just float into view l...
code_fim
hard
{ "lang": "rust", "repo": "obsoke/rustris", "path": "/src/states/menu_state/spawner.rs", "mode": "spm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_suffix|>const TIME_BETWEEN_SPAWNS: f64 = 0.5; const MAX_ROTATION: f64 = 50.0; pub struct Spawner { active_pieces: Vec<SpawnedPiece>, time_until_next_spawn: f64, } impl Spawner { pub fn new() -> Self { Self { active_pieces: vec![], time_until_next_spawn: 0.0, }...
code_fim
hard
{ "lang": "rust", "repo": "obsoke/rustris", "path": "/src/states/menu_state/spawner.rs", "mode": "spm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gs-akhan/learning-rust path: /src/operators.rs fn main() { println!("Hello Operators"); <|fim_suffix|> array.push(8); array.iter() .map(|x| x * 2) .filter(|x| *x > 4) .for_each(|x| println!("{}", x)); }<|fim_middle|> let mut array:Vec<i32> = vec![1,2,3,4...
code_fim
easy
{ "lang": "rust", "repo": "gs-akhan/learning-rust", "path": "/src/operators.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> array.push(8); array.iter() .map(|x| x * 2) .filter(|x| *x > 4) .for_each(|x| println!("{}", x)); }<|fim_prefix|>// repo: gs-akhan/learning-rust path: /src/operators.rs fn main() { println!("Hello Operators"); <|fim_middle|> let mut array:Vec<i32> = vec![1,2,3,4...
code_fim
easy
{ "lang": "rust", "repo": "gs-akhan/learning-rust", "path": "/src/operators.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Amount: {}", amount_str); println!("Volumes of CO2: {}", co2_volumes); println!("Temperature: {}", temperature); println!("CO2 in Beer: {:.2} volumes", co2_beer); println!("Priming Sugar Options:"); for sugar in sugars.iter() { println...
code_fim
hard
{ "lang": "rust", "repo": "flauntingspade4/rustybeer", "path": "/rustybeer-cli/src/commands/priming.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flauntingspade4/rustybeer path: /rustybeer-cli/src/commands/priming.rs use clap::{value_t, App, Arg, ArgMatches}; use rustybeer::calculators::priming::{calculate_co2, calculate_sugars}; use rustybeer_util::conversions::{TemperatureBuilder, VolumeBuilder}; pub fn add_subcommand<'a, 'b>() -> App<...
code_fim
hard
{ "lang": "rust", "repo": "flauntingspade4/rustybeer", "path": "/rustybeer-cli/src/commands/priming.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: petertodd/rust-obstack path: /benches/bench.rs #[macro_use] extern crate bencher; extern crate obstack; use std::mem; use std::rc::Rc; use bencher::Bencher; use obstack::{Obstack, Ref}; const CONS_ITERS: usize = 10000; const CONS_SUM: usize = 49995000; fn cons_list_with_box(bench: &mut Ben...
code_fim
hard
{ "lang": "rust", "repo": "petertodd/rust-obstack", "path": "/benches/bench.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn str_cons_list_stack(bench: &mut Bencher) { enum RefCons<'a, T: 'a> { Nil, Cell(T, Ref<'a, RefCons<'a, T>>), } bench.iter(|| { let stack = Obstack::new(); let mut tip = RefCons::Nil; for i in 0 .. CONS_ITERS { let s = i.to_string(); ...
code_fim
hard
{ "lang": "rust", "repo": "petertodd/rust-obstack", "path": "/benches/bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bench.iter(|| { let stack = Obstack::new(); let mut tip = RefCons::Nil; for i in 0 .. CONS_ITERS { let old_tip = mem::replace(&mut tip, RefCons::Nil); tip = RefCons::Cell(i, stack.push(old_tip)); } let mut cur_tip = &tip; let mu...
code_fim
hard
{ "lang": "rust", "repo": "petertodd/rust-obstack", "path": "/benches/bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf5340-pac path: /nrf5340-app-pac/src/comp_ns/shorts.rs c = "Register `SHORTS` writer"] pub struct W(crate::W<SHORTS_SPEC>); impl core::ops::Deref for W { type Target = crate::W<SHORTS_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl co...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf5340-pac", "path": "/nrf5340-app-pac/src/comp_ns/shorts.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Field `CROSS_STOP` reader - Shortcut between event CROSS and task STOP"] pub struct CROSS_STOP_R(crate::FieldReader<bool, CROSS_STOP_A>); impl CROSS_STOP_R { pub(crate) fn new(bits: bool) -> Self { CROSS_STOP_R(crate::FieldReader::new(bits)) } ...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf5340-pac", "path": "/nrf5340-app-pac/src/comp_ns/shorts.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf5340-pac path: /nrf5340-app-pac/src/comp_ns/shorts.rs ::R<SHORTS_SPEC>> for R { fn from(reader: crate::R<SHORTS_SPEC>) -> Self { R(reader) } } #[doc = "Register `SHORTS` writer"] pub struct W(crate::W<SHORTS_SPEC>); impl core::ops::Deref for W { type Target = crate:...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf5340-pac", "path": "/nrf5340-app-pac/src/comp_ns/shorts.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> pub fn named_dynamic(name: &str) -> Axis { let name_ptr = name.as_ptr(); let name_len = name.len(); Axis { payload: unsafe { cpp!([name_ptr as "char*", name_len as "size_t"] -> AxisInner as "Axis" { string name(name_ptr, name_ptr ...
code_fim
hard
{ "lang": "rust", "repo": "usamec/cntk-rs", "path": "/src/axis.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }