text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fn into_iter(self) -> Self::IntoIter { self.data.into_iter() } } #[cfg(test)] mod tests { use super::*; /// Generate a test vector for test cases fn test_vector() -> Vec<u32> { (0..100).collect() } #[test] fn test_negative_indices() { let vec = te...
code_fim
hard
{ "lang": "rust", "repo": "afnanenayet/diffsitter", "path": "/src/neg_idx_vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheHellBox/Recyclers path: /server/src/base/player.rs use crate::base::components::PhysicsBody; use crate::base::systems::physics::Physics; use nphysics3d::object::{Body, BodyStatus, RigidBody}; use shared::components::*; use ncollide3d::shape::{Ball, Cuboid, ShapeHandle}; use nphysics3d::mater...
code_fim
hard
{ "lang": "rust", "repo": "TheHellBox/Recyclers", "path": "/server/src/base/player.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn spawn( world: &mut hecs::World, physics: &mut Physics, name: String, entity_id: shared::EntityId, ) -> hecs::Entity { let mut player = hecs::EntityBuilder::new(); player.add(Transform { isometry: na::Isometry3::from_parts( na::Translation3::new(0.0, 0.0, ...
code_fim
hard
{ "lang": "rust", "repo": "TheHellBox/Recyclers", "path": "/server/src/base/player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let player_body = physics.add_body( RigidBodyDesc::new() //.collider(&ColliderDesc::new()) .mass(40.0) .translation(na::Vector3::new( 996609.65806255, -747775.7217986964, 414785.79067247955, )) ...
code_fim
hard
{ "lang": "rust", "repo": "TheHellBox/Recyclers", "path": "/server/src/base/player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_block_on_stream() { let observable = Mutable::new(1); let signal_from_stream = observable.signal(); let broadcaster = Broadcaster::new(signal_from_stream); let mut blocking_stream = block_on_stream(broadcaster.signal().to_stream()); assert_eq!(blocking_stream.next(),...
code_fim
hard
{ "lang": "rust", "repo": "Pauan/rust-signals", "path": "/tests/broadcaster.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pauan/rust-signals path: /tests/broadcaster.rs use futures_signals::map_ref; use futures_signals::signal::{SignalExt, Mutable, Broadcaster, always, from_stream}; use futures_executor::block_on_stream; use std::task::Poll; mod util; #[test] fn test_broadcaster() { let mutable = Mutable::ne...
code_fim
hard
{ "lang": "rust", "repo": "Pauan/rust-signals", "path": "/tests/broadcaster.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(blocking_stream.next(), Some(2)); } #[test] fn test_block_on_stream_wrapper() { let observable = Mutable::new(1); let signal_from_stream = from_stream(observable.signal().to_stream()); let broadcaster = Broadcaster::new(signal_from_stream); let mut blocking_stream = block_...
code_fim
hard
{ "lang": "rust", "repo": "Pauan/rust-signals", "path": "/tests/broadcaster.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kpcyrd/sloppy-rfc4880 path: /examples/split.rs use sloppy_rfc4880::errors::*; use std::fs; use std::env; use std::io::{self, Read}; use std::path::PathBuf; fn find_free_num(prefix: &str, ctr: &mut usize) -> PathBuf { <|fim_suffix|> let range = old..new; info!("Dumping {:?} into {...
code_fim
hard
{ "lang": "rust", "repo": "kpcyrd/sloppy-rfc4880", "path": "/examples/split.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let remaining = parser.inner().len(); let new = total - remaining; let range = old..new; info!("Dumping {:?} into {:?}, remaining={:?}", range, path, remaining); fs::write(path, &buf[range]) .context("Failed to write")?; old = new; } ...
code_fim
hard
{ "lang": "rust", "repo": "kpcyrd/sloppy-rfc4880", "path": "/examples/split.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> env_logger::init(); let prefix = env::args().nth(1) .context("Missing prefix")?; let mut buf = Vec::new(); io::stdin().read_to_end(&mut buf) .context("read_to_end")?; let total = buf.len(); let mut ctr = 0; let mut parser = sloppy_rfc4880::Parser::new(buf.as_...
code_fim
medium
{ "lang": "rust", "repo": "kpcyrd/sloppy-rfc4880", "path": "/examples/split.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut students = StudentsBase::new(); students.addStudent( 5, "tom"); students.addStudent( 2, "kat"); students.addStudent( 3, "mary"); students.addStudent( 1, "john"); students.addStudent( 2, "winston"); students.addStudent( 3, "philip"); students.addStudent( 1, "meghan")...
code_fim
medium
{ "lang": "rust", "repo": "franka911/Exercism", "path": "/grade_school/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: franka911/Exercism path: /grade_school/src/lib.rs use std::collections::HashMap; pub struct StudentsBase{ Students: HashMap<i32, Vec<String>> } impl StudentsBase { pub fn new () -> StudentsBase{ StudentsBase{ Students: HashMap::new() } } /*method t...
code_fim
hard
{ "lang": "rust", "repo": "franka911/Exercism", "path": "/grade_school/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oeb25/super-tiny-service-example path: /auth/src/main.rs extern crate rouille; fn main() { <|fim_suffix|> use rouille::Request; use rouille::Response; rouille::start_server("0.0.0.0:80", move |request| { Response::text("Hello, world! Rust is slow some times, but is fine :'("...
code_fim
easy
{ "lang": "rust", "repo": "oeb25/super-tiny-service-example", "path": "/auth/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> rouille::start_server("0.0.0.0:80", move |request| { Response::text("Hello, world! Rust is slow some times, but is fine :'(") }); }<|fim_prefix|>// repo: oeb25/super-tiny-service-example path: /auth/src/main.rs extern crate rouille; fn main() { <|fim_middle|> println!("Hello, world!")...
code_fim
medium
{ "lang": "rust", "repo": "oeb25/super-tiny-service-example", "path": "/auth/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use rouille::Request; use rouille::Response; rouille::start_server("0.0.0.0:80", move |request| { Response::text("Hello, world! Rust is slow some times, but is fine :'(") }); }<|fim_prefix|>// repo: oeb25/super-tiny-service-example path: /auth/src/main.rs extern crate rouille; f...
code_fim
easy
{ "lang": "rust", "repo": "oeb25/super-tiny-service-example", "path": "/auth/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pietroalbini/areweawaityet path: /archive/src/reddit.rs static SUBREDDIT: &str = "https://www.reddit.com/r/rust"; use crate::{is_await, Context, Item, Source}; use chrono::DateTime; use failure::Error; use std::io::BufReader; pub(crate) struct Reddit; impl Reddit { fn parse_feed(&self, ct...
code_fim
hard
{ "lang": "rust", "repo": "pietroalbini/areweawaityet", "path": "/archive/src/reddit.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let response = ctx.get(&format!("{}{}", SUBREDDIT, feed))?; Ok( atom_syndication::Feed::read_from(&mut BufReader::new(response))? .entries() .iter() .filter(|entry| { [ Some(entry.title(...
code_fim
hard
{ "lang": "rust", "repo": "pietroalbini/areweawaityet", "path": "/archive/src/reddit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abassibe/Gomoku path: /src/algorithm/mod.rs use super::{bitboard::BitBoard, goban::Goban, node::Node}; #[cfg(test)] mod tests; mod minimax; mod transposition_table; mod negamax; #[derive(Default)] pub struct Algorithm { initial: Node, patterns: NewPattern, } impl Algorithm { /// I...
code_fim
hard
{ "lang": "rust", "repo": "abassibe/Gomoku", "path": "/src/algorithm/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> result |= extract_threatening_moves_from_opponent( current_player, opponent, GET_MOVES_PATTERNS[2].0, GET_MOVES_PATTERNS[2].1, GET_MOVES_PATTERNS[2].2 ); result |= extract_missing_bit( current_player, ...
code_fim
hard
{ "lang": "rust", "repo": "abassibe/Gomoku", "path": "/src/algorithm/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if result.is_empty() { extract_winning_move_capture(player, opponent, player_captures, &self.patterns) } else { result } } fn is_game_over(&self, current: &Node) -> bool { let goban = current.get_item(); let (player, opponent, player...
code_fim
hard
{ "lang": "rust", "repo": "abassibe/Gomoku", "path": "/src/algorithm/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: balena-io-modules/libnm-rs path: /src/setting_olpc_mesh.rs // This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files // DO NOT EDIT use crate::Setting; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as ...
code_fim
hard
{ "lang": "rust", "repo": "balena-io-modules/libnm-rs", "path": "/src/setting_olpc_mesh.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[doc(alias = "channel")] pub fn connect_channel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_channel_trampoline<F: Fn(&SettingOlpcMesh) + 'static>( this: *mut ffi::NMSettingOlpcMesh, _param_spec: glib::ffi::gpointer, ...
code_fim
hard
{ "lang": "rust", "repo": "balena-io-modules/libnm-rs", "path": "/src/setting_olpc_mesh.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ftmazzone/pim447-trackball path: /examples/read_inputs.rs use flume; use pim447_trackball::pim447::{Command, Input, Trackball}; use simple_signal::{self, Signal}; use std::{ error::Error, sync::atomic::{AtomicBool, Ordering}, sync::Arc, time::Duration, }; use tokio::time::timeout...
code_fim
hard
{ "lang": "rust", "repo": "ftmazzone/pim447-trackball", "path": "/examples/read_inputs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while !trackball_turn_off_command && !rx.is_disconnected() { let input = trackball.read_input()?; if input.state_update { tx.send(input)?; } let result = timeout(Duration::from_millis(100), rx.recv_async()).await; match result { Ok(Ok(Com...
code_fim
hard
{ "lang": "rust", "repo": "ftmazzone/pim447-trackball", "path": "/examples/read_inputs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elpnt/rust-snippets path: /todo-app/actix-juniper-gql/src/main.rs mod context; mod gql_schema; mod model; mod routes; use crate::gql_schema::schema; use crate::routes::*; use actix_cors::Cors; use actix_web::{http::header, middleware, web, App, HttpServer}; <|fim_suffix|> HttpServer::new(m...
code_fim
hard
{ "lang": "rust", "repo": "elpnt/rust-snippets", "path": "/todo-app/actix-juniper-gql/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> HttpServer::new(move || { App::new() .data(schema()) .wrap(middleware::Logger::default()) .wrap( Cors::default() .allowed_origin("http://127.0.0.1:8080") .allowed_methods(vec!["GET", "POST"]) ...
code_fim
hard
{ "lang": "rust", "repo": "elpnt/rust-snippets", "path": "/todo-app/actix-juniper-gql/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut p = Tokenizer::new("(123)", true); assert_eq!(Ok(Sexp::from((123usize,))), parse_sexp(&mut p)); assert_eq!(true, at_end(&mut p)); let mut p = Tokenizer::new("(test 123) ", true); assert_eq!(Ok(Sexp::from(("test", 123usize))), parse_sexp(&mut p)); assert_eq!(true, at_end(...
code_fim
hard
{ "lang": "rust", "repo": "mneumann/asexp-rs", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mneumann/asexp-rs path: /src/parser.rs use super::token::Token; use super::Atom; use super::Sexp; #[cfg(test)] use super::token::Tokenizer; #[derive(Debug, PartialEq)] pub enum ParseError<'a> { UnexpectedToken(Token<'a>), UnexpectedEnd, } // Returns either the successfully parsed expr...
code_fim
hard
{ "lang": "rust", "repo": "mneumann/asexp-rs", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut p = Tokenizer::new("(abc } ", true); assert_eq!( Err(ParseError::UnexpectedToken(Token::CloseCurly)), parse_sexp(&mut p) ); let mut p = Tokenizer::new("[1 2 3]", true); assert_eq!( Ok(Sexp::Array(vec![ Sexp::from(1usize), Sexp:...
code_fim
hard
{ "lang": "rust", "repo": "mneumann/asexp-rs", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heyrict/rofi-script path: /examples/simple.rs use rofi_script::{RofiContext, RofiMessage, RowOption}; use std::process; <|fim_suffix|> let rofi_message = match context.input.as_str() { "quit" => process::exit(0), _ => { let row = vec![RowOption::new("reload"), Row...
code_fim
easy
{ "lang": "rust", "repo": "heyrict/rofi-script", "path": "/examples/simple.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let rofi_message = match context.input.as_str() { "quit" => process::exit(0), _ => { let row = vec![RowOption::new("reload"), RowOption::new("quit")]; RofiMessage { opt: Default::default(), row, } } }; ...
code_fim
easy
{ "lang": "rust", "repo": "heyrict/rofi-script", "path": "/examples/simple.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (p1_wins, p2_wins) = universe_roll(state); p1_wins.max(p2_wins) } #[cfg(test)] mod tests { use super::*; const SAMPLE_INPUT: &str = "Player 1 starting position: 4\nPlayer 2 starting position: 8"; #[test] fn sample_parse() { assert_eq!(parse(SAMPLE_INPUT), (4, 8)); ...
code_fim
hard
{ "lang": "rust", "repo": "mblonyox/adventofcode", "path": "/2021/src/day21.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[aoc(day21, part1)] pub fn part1(input: &(i32, i32)) -> i32 { let mut state = GameState::new(input); let mut dice = (1..=100).cycle(); while !state.is_ended(1000) { let rolls = dice.next().unwrap() + dice.next().unwrap() + dice.next().unwrap(); state.moves(rolls); } st...
code_fim
hard
{ "lang": "rust", "repo": "mblonyox/adventofcode", "path": "/2021/src/day21.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mblonyox/adventofcode path: /2021/src/day21.rs use regex::Regex; #[derive(Debug, Clone, Copy)] struct GameState { p1_pos: i32, p2_pos: i32, p1_score: i32, p2_score: i32, turn: i32, } impl GameState { fn new(pos: &(i32, i32)) -> Self { GameState { p1_...
code_fim
hard
{ "lang": "rust", "repo": "mblonyox/adventofcode", "path": "/2021/src/day21.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let res: Vec<_> = rx.iter().collect(); println!("{:?}", res); }<|fim_prefix|>// repo: max-block/test__rust-multithreading path: /src/bin/t3.rs use std::{sync::mpsc::channel, thread, time}; fn job(data: String) -> (String, usize) { thread::sleep(time::Duration::from_secs(1)); let size = d...
code_fim
medium
{ "lang": "rust", "repo": "max-block/test__rust-multithreading", "path": "/src/bin/t3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: max-block/test__rust-multithreading path: /src/bin/t3.rs use std::{sync::mpsc::channel, thread, time}; fn job(data: String) -> (String, usize) { <|fim_suffix|> let data_list = vec!["a".to_string(), "bla bla".to_string(), "cc".to_string()]; let (tx, rx) = channel(); for data in data...
code_fim
medium
{ "lang": "rust", "repo": "max-block/test__rust-multithreading", "path": "/src/bin/t3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lachlanwillis/rust-tutorials path: /variable-bindings/scope-and-shadowing.rs // variable bindings have a scope and are constrained to live inside a block // a block is a collection of statements enclosed by braces {} fn main() { // this binding lives in the main fn let long_lived_binding = 1...
code_fim
hard
{ "lang": "rust", "repo": "lachlanwillis/rust-tutorials", "path": "/variable-bindings/scope-and-shadowing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // this binding *shadows* the outer one let shadowed_binding = "abc"; println!("shadowed in inner block: {}", shadowed_binding); } println!("outside inner block: {}", shadowed_binding); // this binding *shadows* the previous binding let shadowed_binding = 2; println!("shadowed in ...
code_fim
medium
{ "lang": "rust", "repo": "lachlanwillis/rust-tutorials", "path": "/variable-bindings/scope-and-shadowing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> > ( ast None ) Err ( ( ast err ) ) = > ( ast Some ( err ) ) } ; # [ cfg ( feature = " json " ) ] { let target_json = serde_json : : to_string_pretty ( & ast ) . unwrap ( ) ; println ! ( " { } " target_json ) ; } # [ cfg ( not ( feature = " json " ) ) ] { use std : : fmt : : Write ; let mut result = Strin...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/fluent-syntax/src/bin/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mut result = String : : new ( ) ; write ! ( result " { : # ? } " ast ) . unwrap ( ) ; println ! ( " { } " result ) ; } if let Some ( errors ) = errors { println ! ( " \ n = = = = = = = = Errors = = = = = = = = = = \ n " ) ; for err in errors { println ! ( " Err : { : # ? } " err ) ; } } }<|fim_prefix|>// ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/fluent-syntax/src/bin/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/fluent-syntax/src/bin/parser.rs use fluent_syntax : : parser : : parse ; use std : : env ; use std : : fs : : File ; use std : : io ; use std : : io : : Read ; fn read_file ( path : & str ) - > Result < String io : : Error > { let mut f = File ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/fluent-syntax/src/bin/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hakuyume/rust-cuda path: /cudnn/src/convolution/mode.rs use cudnn_sys; #[repr(u32)] #[derive(Clone, Copy, Debug)] pub enum Mode { Convolution <|fim_suffix|>lation = cudnn_sys::CUDNN_CROSS_CORRELATION, }<|fim_middle|>= cudnn_sys::CUDNN_CONVOLUTION, CrossCorre
code_fim
easy
{ "lang": "rust", "repo": "Hakuyume/rust-cuda", "path": "/cudnn/src/convolution/mode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lation = cudnn_sys::CUDNN_CROSS_CORRELATION, }<|fim_prefix|>// repo: Hakuyume/rust-cuda path: /cudnn/src/convolution/mode.rs use cudnn_sys; #[repr(u32)] #[derive(Clone, Copy, Debug)] pub enum Mode { Convolution <|fim_middle|>= cudnn_sys::CUDNN_CONVOLUTION, CrossCorre
code_fim
easy
{ "lang": "rust", "repo": "Hakuyume/rust-cuda", "path": "/cudnn/src/convolution/mode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (output, count * 10 + d as usize) } else { output.push_str(&x.to_string().repeat(cmp::max(count, 1))); (output, 0) } }) .0 }<|fim_prefix|>// repo: pedantic79/Exercism path: /rust/run-length-encoding/src/lib.rs extern crate iterto...
code_fim
hard
{ "lang": "rust", "repo": "pedantic79/Exercism", "path": "/rust/run-length-encoding/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pedantic79/Exercism path: /rust/run-length-encoding/src/lib.rs extern crate itertools; use itertools::Itertools; use std::cmp; pub fn encode(source: &str) -> String { source .chars() .group_by(|&x| x) .into_iter() .map(|(key<|fim_suffix|> (output, count *...
code_fim
hard
{ "lang": "rust", "repo": "pedantic79/Exercism", "path": "/rust/run-length-encoding/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(response.data) }); } pub fn sign_message_recoverable( &self, message: &[u8], display_hex: bool, ) -> Result<RecoverableSignature, LedgerKeyStoreError> { let get_ledger_with_id = LedgerKeyStore::wallet_id_filter(&self.ledger_id); r...
code_fim
hard
{ "lang": "rust", "repo": "obsidiansystems/ckb-plugin-ledger", "path": "/src/keystore.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: obsidiansystems/ckb-plugin-ledger path: /src/keystore.rs <H160, LedgerKeyStoreError> { let get_ledger_with_id = LedgerKeyStore::wallet_id_filter(&account_id); let res = with_ledger_matching(get_ledger_with_id, &mut |ledger_app| { let bip_account_index = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "obsidiansystems/ckb-plugin-ledger", "path": "/src/keystore.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Serialize, Deserialize)] struct LedgerAccountJson { ledger_id: H256, lock_arg: H160, extended_public_key_root: LedgerAccountExtendedPubKeyJson, // TODO: `path` missing because it's not configurable } #[derive(Debug, Clone, Serialize, Deserialize)] struct LedgerAccou...
code_fim
hard
{ "lang": "rust", "repo": "obsidiansystems/ckb-plugin-ledger", "path": "/src/keystore.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nuta/archives path: /noa-lsp/src/proxy/protocol.rs use std::path::PathBuf; use lsp_types::{CompletionItem, Diagnostic, HoverContents, TextEdit}; use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, PartialEq, Eq, Debug, Deserialize, Serialize, Hash)] pub struct RequestId(usize); impl Fr...
code_fim
hard
{ "lang": "rust", "repo": "nuta/archives", "path": "/noa-lsp/src/proxy/protocol.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)] pub enum Response { Ok { body: serde_json::Value }, Err { reason: String }, } #[derive(Deserialize, Serialize, PartialEq, Debug, Clone)] pub struct FileLocation { pub path: PathBuf, pub position: lsp_types::Position, } #[derive(S...
code_fim
hard
{ "lang": "rust", "repo": "nuta/archives", "path": "/noa-lsp/src/proxy/protocol.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samueltangz/rust-etcd path: /examples/lease.rs extern crate futures; extern crate tokio; use std::ops::Add; use std::time::{Duration, Instant}; use etcd_rs::prelude::*; use etcd_rs::Client; use futures::{Future, Stream}; fn main() { let client = Client::builder().add_endpoint("127.0.0.1:...
code_fim
hard
{ "lang": "rust", "repo": "samueltangz/rust-etcd", "path": "/examples/lease.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // revoke lease after 30 seconds let revoke_lease = tokio::timer::Delay::new(Instant::now().add(Duration::from_secs(30))) .map_err(|_| ()) .and_then(move |_| { client .lease(...
code_fim
hard
{ "lang": "rust", "repo": "samueltangz/rust-etcd", "path": "/examples/lease.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: endlmk/nand2tetris path: /06/assembler/src/parser.rs use std::fs; use std::io::{self, BufRead}; pub struct Parser<R: io::Read> { fs : io::BufReader<R>, cur_line : String, command_type : Option<CommandType>, symbol : String, dest : String, comp : String, jump : String...
code_fim
hard
{ "lang": "rust", "repo": "endlmk/nand2tetris", "path": "/06/assembler/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(p.hasMoreComments(), true); assert_eq!(p.cur_line, "D = D-A"); p.advance(); assert_eq!(p.commandType().unwrap(), CommandType::C_Command); assert_eq!(p.dest, "D"); assert_eq!(p.comp, "D-A"); assert_eq!(p.jump, ""); } #[tes...
code_fim
hard
{ "lang": "rust", "repo": "endlmk/nand2tetris", "path": "/06/assembler/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn advance_4() { let s = io::Cursor::new("D = D-A"); let mut p = Parser::new(s); assert_eq!(p.hasMoreComments(), true); assert_eq!(p.cur_line, "D = D-A"); p.advance(); assert_eq!(p.commandType().unwrap(), CommandType::C_Command); ...
code_fim
hard
{ "lang": "rust", "repo": "endlmk/nand2tetris", "path": "/06/assembler/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = self.as_mut().get_mut(); let this = s.this.as_mut(); let res = this.poll_read_write(cx, s.buffer)?; all_poll(res, cx, &mut self.buffer).map_err(|_| AllError::UnexpectedEof) } }<|fim_prefix|>// repo: AerialX/no-io.rs path: /src/async_traits/read_write_all.rs use...
code_fim
hard
{ "lang": "rust", "repo": "AerialX/no-io.rs", "path": "/src/async_traits/read_write_all.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { let s = self.as_mut().get_mut(); let this = s.this.as_mut(); let res = this.poll_read_write(cx, s.buffer)?; all_poll(res, cx, &mut self.buffer).map_err(|_| AllError::UnexpectedEof) } }<|fim_...
code_fim
medium
{ "lang": "rust", "repo": "AerialX/no-io.rs", "path": "/src/async_traits/read_write_all.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AerialX/no-io.rs path: /src/async_traits/read_write_all.rs use core::future::Future; use core::task::{Context, Poll}; use core::pin::Pin; use crate::AllError; use super::all_poll; pub struct AsyncReadWriteAll<'a, 'b, T: ?Sized> { pub(crate) this: Pin<&'a mut T>, pub(crate) buffer: &'b m...
code_fim
medium
{ "lang": "rust", "repo": "AerialX/no-io.rs", "path": "/src/async_traits/read_write_all.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mariiillo/btree path: /src/binary_tree/tree.rs use binary_tree::node::Node; #[derive(Debug, Default)] pub struct Tree { root: Option<Node>, } <|fim_suffix|> pub fn read(self) { self.root.unwrap().read(); } }<|fim_middle|>impl Tree { pub fn add_node(&mut self, value: i32)...
code_fim
hard
{ "lang": "rust", "repo": "mariiillo/btree", "path": "/src/binary_tree/tree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read(self) { self.root.unwrap().read(); } }<|fim_prefix|>// repo: mariiillo/btree path: /src/binary_tree/tree.rs use binary_tree::node::Node; #[derive(Debug, Default)] pub struct Tree { root: Option<Node>, } <|fim_middle|>impl Tree { pub fn add_node(&mut self, value: i32)...
code_fim
hard
{ "lang": "rust", "repo": "mariiillo/btree", "path": "/src/binary_tree/tree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn parse_program_tokens(tokens: Vec<Token>) -> Result<Program, String> { let mut token_iterator = tokens.into_iter().peekable(); let main_function: Statement = match parse_statement(&mut token_iterator) { Ok(main_statement) => match &main_statement { Statement::Function(val...
code_fim
hard
{ "lang": "rust", "repo": "khayliang/fe2o3-cc", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: khayliang/fe2o3-cc path: /src/parser.rs use crate::syntax::*; use crate::tokenizer::Token; /* pub struct TokenIteratorContainer<'a> { iterator: &'a std::iter::Peekable<std::slice::Iter<'a, Token<'a>>>, } impl<'a> TokenIteratorContainer<'a> { pub fn new(token: &'a Vec<Token>) -> TokenIt...
code_fim
hard
{ "lang": "rust", "repo": "khayliang/fe2o3-cc", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let tokens: Vec<Token> = vec![ Token::Keyword("int"), Token::Identifier("main"), Token::OpenBracket, Token::CloseBracket, Token::OpenBrace, Token::Keyword("return"), Token::Integer("2"), Token::Semicolo...
code_fim
hard
{ "lang": "rust", "repo": "khayliang/fe2o3-cc", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: remexre/tmst path: /src/cmds.rs use crate::{ models::{NewTime, Time}, schema, schema::times::dsl::*, utils::{ current_id, current_project, current_time, day_bounds, expand_time_format, from_timestamp, }, }; use chrono::{Local, NaiveDate, Utc}; use diesel::prelude::*; ...
code_fim
hard
{ "lang": "rust", "repo": "remexre/tmst", "path": "/src/cmds.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> dates .into_iter() .map(|date| { let range = day_bounds(date); let mut out = BTreeMap::new(); times .filter(start.ge(range.start.timestamp())) .filter(start.lt(range.end.timestamp())) .filter(end.is_not...
code_fim
hard
{ "lang": "rust", "repo": "remexre/tmst", "path": "/src/cmds.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ptomato/mozjs path: /third_party/rust/serde_with_macros/src/lib.rs #![deny( missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unused_extern_crates, unused_import_braces, unused_qualifications, variant_size_differenc...
code_fim
hard
{ "lang": "rust", "repo": "ptomato/mozjs", "path": "/third_party/rust/serde_with_macros/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Add the skip_serializing_if annotation to each field of the struct fn skip_serializing_none_add_attr_to_field<'a>( fields: impl IntoIterator<Item = &'a mut Field>, ) -> Result<(), String> { fields.into_iter().map(|field| ->Result<(), String> { if let Type::Path(path) = &field.ty.clone(...
code_fim
hard
{ "lang": "rust", "repo": "ptomato/mozjs", "path": "/third_party/rust/serde_with_macros/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "404", "The page you're looking for does not seem to exist." )) }<|fim_prefix|>// repo: bernep/Telescope path: /src/web/services/p404.rs use crate::web::RequestContext; use actix_web::HttpResponse; use crate::templates::jumbotron::Jumbotron; <|fim_middle|>/// 40...
code_fim
hard
{ "lang": "rust", "repo": "bernep/Telescope", "path": "/src/web/services/p404.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bernep/Telescope path: /src/web/services/p404.rs use crate::web::RequestContext; use actix_web::HttpResponse; use crate::templates::jumbotron::Jumbotron; /// 404 Page pub async fn not_found(ctx: RequestContext) -> HttpResponse { HttpResponse::NotFound() <|fim_suffix|> "404", ...
code_fim
medium
{ "lang": "rust", "repo": "bernep/Telescope", "path": "/src/web/services/p404.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 47leonel-wabo/rust-hands-on path: /concurrency/src/main.rs use std::sync::mpsc::channel; use std::thread::{sleep, spawn}; use std::time::Duration; fn main() { /* Thread - spawn the spawn function take a closure as parameter this closure represents the code that will ...
code_fim
hard
{ "lang": "rust", "repo": "47leonel-wabo/rust-hands-on", "path": "/concurrency/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // let received_data = receiver.try_recv().unwrap(); // Doesn't block and wait data let received_data = receiver.recv().unwrap(); // Block and wait data println!("Data received is: {}", received_data); }<|fim_prefix|>// repo: 47leonel-wabo/rust-hands-on path: /concurrency/src/main.rs use std:...
code_fim
medium
{ "lang": "rust", "repo": "47leonel-wabo/rust-hands-on", "path": "/concurrency/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !transaction::verify(&signed_tx.tx, &signed_tx.signature, &signed_tx.public_key){ println!("tx didn't pass signature check!"); return false; } let owner_address = address::address_from_public_key_vec_ref(&signed_tx.public_key); let ...
code_fim
hard
{ "lang": "rust", "repo": "VinithKrishnan/Prism_Voting_Chains", "path": "/src/utxo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VinithKrishnan/Prism_Voting_Chains path: /src/utxo.rs use crate::transaction::{self, UtxoInput, UtxoOutput, SignedTransaction}; use crate::crypto::hash::{H256, Hashable}; use crate::crypto::address::{self, H160}; use ring::signature::{self,Ed25519KeyPair, Signature, KeyPair}; use std::coll...
code_fim
hard
{ "lang": "rust", "repo": "VinithKrishnan/Prism_Voting_Chains", "path": "/src/utxo.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //Should it be a "function" rather than "method" of UtxoState?? //1. Signature check //2. Owner match //3. Double Spend //4. Input/Output total match pub fn is_tx_valid(&self, signed_tx: &SignedTransaction) -> bool { // println!("current signed_tx {:?}", signed_tx); ...
code_fim
hard
{ "lang": "rust", "repo": "VinithKrishnan/Prism_Voting_Chains", "path": "/src/utxo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Blue-Pix/null path: /src/config/mod.rs use std::env; use std::fs; use std::io::ErrorKind; use std::str; use anyhow::{anyhow, Result}; #[derive(Debug, PartialEq)] pub struct Config { pub screen_name: String, pub token: String, pub api_key: String, pub api_secret: String, pub access_to...
code_fim
hard
{ "lang": "rust", "repo": "Blue-Pix/null", "path": "/src/config/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn initialize_config_with_file() { setup(); let expected = Config { screen_name: String::from("a"), token: String::from("b"), api_key: String::from("z"), api_secret: String::from("z"), access_token: String::from("z"), access_secret: String::from("z")...
code_fim
hard
{ "lang": "rust", "repo": "Blue-Pix/null", "path": "/src/config/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> setup(); let expected = Config { screen_name: String::from("a"), token: String::from("b"), api_key: String::from("z"), api_secret: String::from("z"), access_token: String::from("z"), access_secret: String::from("z"), }; let actual = Config::new(Some(".en...
code_fim
hard
{ "lang": "rust", "repo": "Blue-Pix/null", "path": "/src/config/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// use std::cell::RefCell; use std::mem::transmute; use ordered_float::OrderedFloat; // use res::ResMgr; use stdweb::unstable::TryInto; use stdweb::Object; use webgl_rendering_context::WebGLRenderingContext; use flex_layout::{Dimension}; #[cfg(feature = "debug")] #[derive(Serialize, Debug)] pub struct ...
code_fim
hard
{ "lang": "rust", "repo": "GaiaWorld/pi_show", "path": "/gui_web/src/main1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaiaWorld/pi_show path: /gui_web/src/main1.rs #![feature(nll)] #![feature(proc_macro_hygiene)] #![feature(rustc_const_unstable)] #![feature(core_intrinsics)] #![feature(custom_attribute)] #![feature(type_ascription)] #![feature(link_args)] #![feature(vec_remove_item)] #![allow(unused_attribute...
code_fim
hard
{ "lang": "rust", "repo": "GaiaWorld/pi_show", "path": "/gui_web/src/main1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn get_selected_vertices(tree: &RTree<Point2<f64>>, point: Point2<f64>, lookup_mode: LookupMode) -> Vec<Point2<f64>> { const LOOKUP_RADIUS2: f64 = 0.2 * 0.2; const N: usize = 10; let mut points = Vec::new(); match lookup_mode { LookupMode::Nearest => {...
code_fim
hard
{ "lang": "rust", "repo": "adeschamps/spade", "path": "/examples/interactivedemo/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut delaunay = DelaunayTriangulation::with_tree_locate(); let mut rtree = RTree::new(); let mut render_data = RenderData::new(&display); let mut last_point = Point2::new(0., 0.); let mut lookup_mode = LookupMode::Nearest; let mut draw_tree_nodes = false; println!("Intera...
code_fim
hard
{ "lang": "rust", "repo": "adeschamps/spade", "path": "/examples/interactivedemo/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adeschamps/spade path: /examples/interactivedemo/src/main.rs // Copyright 2017 The Spade Developers. // // 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>, a...
code_fim
hard
{ "lang": "rust", "repo": "adeschamps/spade", "path": "/examples/interactivedemo/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_current_instr_idx(&mut self, idx: usize) -> Result<(), String> { if idx > self.instructions.len() { Err("Out of bounds".to_string()) } else { self.current_instr = Some(idx); Ok(()) } } pub fn next_instr(&mut self) { ...
code_fim
hard
{ "lang": "rust", "repo": "libfud/XBTVEd", "path": "/src/program.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libfud/XBTVEd path: /src/program.rs use std::fmt; use super::tags::Tags; #[derive(Clone, PartialEq, Debug)] pub enum Source { Pathname(String), URL(String) } impl<'a> Source { pub fn is_path(&self) -> bool { match self { &Source::Pathname(_) => true, ...
code_fim
hard
{ "lang": "rust", "repo": "libfud/XBTVEd", "path": "/src/program.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rivy/crossterm path: /src/cursor/cursor.rs //! With this module you can perform actions that are cursor related. //! Like changing and display the position of the cursor in terminal. //! //! Note that positions of the cursor are 0 -based witch means that the coordinates (cells) starts counting f...
code_fim
hard
{ "lang": "rust", "repo": "rivy/crossterm", "path": "/src/cursor/cursor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Save cursor position for recall later. /// /// Note that this position is stored program based not per instance of the `Cursor` struct. /// /// #Example /// /// ```rust /// /// extern crate crossterm; /// use self::crossterm::Context; /// use self::crossterm...
code_fim
hard
{ "lang": "rust", "repo": "rivy/crossterm", "path": "/src/cursor/cursor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Enable or disable blinking of the terminal. /// /// Not all terminals are supporting this functionality. Windows versions lower than windows 10 also are not supporting this version. /// /// #Example /// /// ```rust /// /// extern crate crossterm; /// use self::c...
code_fim
hard
{ "lang": "rust", "repo": "rivy/crossterm", "path": "/src/cursor/cursor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scannells/ac_rhack path: /src/util/math.rs use std::ops::Sub; use crate::{game_base, InternalMemory}; /// represents a point a 3D environment #[derive(Debug, Copy, Clone, PartialEq)] #[repr(C)] pub struct Vec3 { pub x: f32, pub y: f32, pub z: f32 } impl Vec3 { /// Creates a 3D...
code_fim
hard
{ "lang": "rust", "repo": "scannells/ac_rhack", "path": "/src/util/math.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if screen_w < 0.1 { return (false, 0.0, 0.0); } let mut ndc = Vec3::from([screen_x, screen_y, screen_z]); ndc.x = screen_x / screen_w; ndc.y = screen_y / screen_w; ndc.z = screen_z / screen_w; let x = (width as f32 / 2.0 * ndc.x) + (ndc...
code_fim
hard
{ "lang": "rust", "repo": "scannells/ac_rhack", "path": "/src/util/math.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SierraSoftworks/git-tool path: /src/macros.rs #[cfg(not(debug_assertions))] #[macro_export] macro_rules! version { () => { env!("CA<|fim_suffix|>VERSION")) }; } #[cfg(debug_assertions)] #[macro_export] macro_rules! version { () => { "0.0.0-dev" }; ($prefix:ex...
code_fim
medium
{ "lang": "rust", "repo": "SierraSoftworks/git-tool", "path": "/src/macros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>VERSION")) }; } #[cfg(debug_assertions)] #[macro_export] macro_rules! version { () => { "0.0.0-dev" }; ($prefix:expr) => { format!("{}0.0.0-dev", $prefix) }; }<|fim_prefix|>// repo: SierraSoftworks/git-tool path: /src/macros.rs #[cfg(not(debug_assertions))] #[macro_ex...
code_fim
medium
{ "lang": "rust", "repo": "SierraSoftworks/git-tool", "path": "/src/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DerekStrickland/k8s-controller path: /src/main.rs #[macro_use] extern crate serde_derive; use kube::{ api::{Informer, Object, RawApi, Void, WatchEvent}, client::APIClient, config, }; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Book { pub title: String, pub au...
code_fim
medium
{ "lang": "rust", "repo": "DerekStrickland/k8s-controller", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn handle(event: WatchEvent<KubeBook>) { match event { WatchEvent::Added(book) => println!( "Added a book {} with title '{}'", book.metadata.name, book.spec.title ), WatchEvent::Deleted(book) => println!("Deleted a book {}", book.metadata.name), ...
code_fim
hard
{ "lang": "rust", "repo": "DerekStrickland/k8s-controller", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wotsushi/competitive-programming path: /abc/137/e.rs macro_rules! get { (Vec<$t:ty>) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwra...
code_fim
medium
{ "lang": "rust", "repo": "wotsushi/competitive-programming", "path": "/abc/137/e.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // ベルマンフォード法により解を求める let INF = 1000000000000; let mut dp = vec!(INF; N + 1); dp[1] = 0; for k in 0..2*N { for i in 0..M { let (a, b, c) = ABC[i]; let w = P - c; if dp[a] < INF && dp[b] > dp[a] + w { dp[b] = dp[a] + w; ...
code_fim
medium
{ "lang": "rust", "repo": "wotsushi/competitive-programming", "path": "/abc/137/e.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ression; pub mod variable_definition; pub mod stack; pub mod stack_visitor; pub mod expression;<|fim_prefix|>// repo: Rosefield/carousels path: /rust/src/visitor/mod.rs pub mod file; pub mod program; pub mod function<|fim_middle|>_definition; pub mod type_node; pub mod name_exp
code_fim
easy
{ "lang": "rust", "repo": "Rosefield/carousels", "path": "/rust/src/visitor/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Rosefield/carousels path: /rust/src/visitor/mod.rs pub mod file; pub mod program; pub mod function_definition; pub mod type_node; pub mod name_exp<|fim_suffix|>tack; pub mod stack_visitor; pub mod expression;<|fim_middle|>ression; pub mod variable_definition; pub mod s
code_fim
easy
{ "lang": "rust", "repo": "Rosefield/carousels", "path": "/rust/src/visitor/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryanleh/muse path: /rust/protocols/src/cds.rs elems_per_label: usize, ) -> (usize, usize) { let rands = 2 * (num_layers + 2 * total_size + total_size * modulus_bits + 2 * (modulus_bits * total_size * elems_per_label)...
code_fim
hard
{ "lang": "rust", "repo": "ryanleh/muse", "path": "/rust/protocols/src/cds.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryanleh/muse path: /rust/protocols/src/cds.rs ls.as_slice(), rng)?; let one_labels = mpc.private_inputs(reader, writer, one_labels.as_slice(), rng)?; timer_end!(share_time); // Receive client shares let recv_time = timer_start!(|| "Server receiving inputs"); ...
code_fim
hard
{ "lang": "rust", "repo": "ryanleh/muse", "path": "/rust/protocols/src/cds.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn client_cds<R: Read + Send + Unpin, W: Write + Send + Unpin, RNG: CryptoRng + RngCore>( reader: &mut IMuxAsync<R>, writer: &mut IMuxAsync<W>, cfhe: &ClientFHE, layer_sizes: &[usize], out_mac_shares: &[P::Field], out_shares: &[P::Field], inp...
code_fim
hard
{ "lang": "rust", "repo": "ryanleh/muse", "path": "/rust/protocols/src/cds.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }