text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: pluxtore/maze-server path: /maze_gameserver/src/gamelogic/packets.rs d::convert::TryInto; use super::score::Score; /* ######## packet types ######## */ #[derive(Clone)] pub struct PosUpdate { uid : [u8;4], timestamp : u32, pos_x : i32, pos_y : i32, pos_z : i32, euler_x ...
code_fim
hard
{ "lang": "rust", "repo": "pluxtore/maze-server", "path": "/maze_gameserver/src/gamelogic/packets.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Foo { fn new(baz: String, qux: Vec<i32>) -> Self { Self { baz, qux } }<|> } ", ); // Check that it reuses existing impls check_assist( add_new, "struct Foo {<|>} impl Foo {} ", "struct Foo {} impl Foo { fn new() -> Self { Self { } }<|> } ", ); ...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/crates/ra_assists/src/handlers/add_new.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/rust-analyzer path: /crates/ra_assists/src/handlers/add_new.rs use hir::Adt; use ra_syntax::{ ast::{ self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, }, TextUnit, T, }; use stdx::{format_to, SepBy}; use crate::{Assist, A...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/crates/ra_assists/src/handlers/add_new.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akofke/adventofcode path: /aoc/src/y2020/day07.rs use nom::{IResult, Parser}; use nom::sequence::{terminated, separated_pair}; use nom::bytes::complete::{take_until, tag}; use nom::combinator::{opt, all_consuming}; use nom::character::complete::digit1; use nom::branch::alt; use nom::multi::separ...
code_fim
hard
{ "lang": "rust", "repo": "akofke/adventofcode", "path": "/aoc/src/y2020/day07.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn bag_spec(input: &str) -> (&str, Option<Vec<(u32, &str)>>) { let (_rest, (bag, bag_spec)) = all_consuming(terminated( separated_pair(bag, tag(" contain "), bag_list), tag("."), ))(input).ok().unwrap(); (bag, bag_spec) }<|fim_prefix|>// repo: akofke/adventofcode path: /aoc/sr...
code_fim
hard
{ "lang": "rust", "repo": "akofke/adventofcode", "path": "/aoc/src/y2020/day07.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut m: HashMap<String, DeployPlan> = HashMap::new(); let config = self.config.clone().unwrap(); for n in &config.plan_files { let path = PathBuf::from(&config.config_dir).join(n); let dp = DeployPlan::from_file(path.to_str().unwrap(), Some(config.clone()...
code_fim
hard
{ "lang": "rust", "repo": "kid143/queenbee", "path": "/src/executor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kid143/queenbee path: /src/executor.rs //! MIT License //! Copyright (c) [year] [fullname] //! Permission is hereby granted, free of charge, to any person obtaining a copy //! of this software and associated documentation files (the "Software"), to deal //! in the Software without restriction,...
code_fim
hard
{ "lang": "rust", "repo": "kid143/queenbee", "path": "/src/executor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Solution { pub fn next_greatest_letter(letters: Vec<char>, target: char) -> char { let min_greatest: Option<&char> = letters.iter().filter(|x| *x > &target).min(); return if min_greatest.is_some() { *min_greatest.unwrap() } else { *letters.iter().mi...
code_fim
hard
{ "lang": "rust", "repo": "monkeylyf/interviewjam", "path": "/str/leetcode_find_smallest_letter_greater_than_target.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: monkeylyf/interviewjam path: /str/leetcode_find_smallest_letter_greater_than_target.rs /** * Given a list of sorted characters letters containing only lowercase letters, * and given a target letter target, find the smallest element in the list that * is larger than the given target. * * Let...
code_fim
hard
{ "lang": "rust", "repo": "monkeylyf/interviewjam", "path": "/str/leetcode_find_smallest_letter_greater_than_target.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> atomic_int x = 0; atomic_int y = 0; {{{ x.store(1,mo_relaxed); ||| { r1=x.load(mo_relaxed).readsvalue(1); fence(mo_seq_cst); r2=y.load(mo_relaxed); } ||| { y.store(1,mo_relaxed); fence(mo_seq_cst); r3=x.load(m...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/fail/should-pass/cpp20_rwc_syncs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/miri path: /tests/fail/should-pass/cpp20_rwc_syncs.rs //@compile-flags: -Zmiri-ignore-leaks // https://plv.mpi-sws.org/scfix/paper.pdf // 2.2 Second Problem: SC Fences are Too Weak // This test should pass under the C++20 model Rust is using. // Unfortunately, Miri's weak memory emula...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/fail/should-pass/cpp20_rwc_syncs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stepa2/webrtc-rs-turn path: /src/server/mod.rs #[cfg(test)] mod server_test; pub mod config; pub mod request; use crate::allocation::allocation_manager::*; use crate::auth::AuthHandler; use crate::proto::lifetime::DEFAULT_LIFETIME; use config::*; use request::*; use std::collections::HashMap;...
code_fim
hard
{ "lang": "rust", "repo": "stepa2/webrtc-rs-turn", "path": "/src/server/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> tokio::spawn(async move { let allocation_manager = Arc::new(Manager::new(ManagerConfig { relay_addr_generator: p.relay_addr_generator, })); let _ = Server::read_loop( p.conn, allocation...
code_fim
hard
{ "lang": "rust", "repo": "stepa2/webrtc-rs-turn", "path": "/src/server/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> file_path.exists() } fn log(&self, text: &str) { let _g = self.output_lock.lock().unwrap(); println!("{}", text); } fn log_error(&self, text: &str) { let _g = self.output_lock.lock().unwrap(); eprintln!("{}", text); } }<|fim_prefix|>// repo: zs...
code_fim
medium
{ "lang": "rust", "repo": "zscaiosi/dprint", "path": "/crates/dprint/src/environment/real_environment.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zscaiosi/dprint path: /crates/dprint/src/environment/real_environment.rs use std::path::PathBuf; use std::fs; use super::Environment; use std::sync::{Arc, Mutex}; pub struct RealEnvironment { output_lock: Arc<Mutex<u8>>, } impl RealEnvironment { pub fn new() -> RealEnvironment { ...
code_fim
medium
{ "lang": "rust", "repo": "zscaiosi/dprint", "path": "/crates/dprint/src/environment/real_environment.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut storage = Storage { path: path.as_ref().to_path_buf(), ..Default::default() }; if let Some(uri) = obj.get("uri").and_then(|it| it.as_str()) { storage = storage.uri(&uri)?; } if let Some(key_prefix) = obj.get("key_prefix"...
code_fim
hard
{ "lang": "rust", "repo": "dmexe/tc-cache", "path": "/src/storage/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmexe/tc-cache path: /src/storage/mod.rs use std::fs::{File, OpenOptions}; use std::path::{Path, PathBuf}; use serde_json::{self, json, Value}; use url::Url; use crate::errors::ResultExt; use crate::{Config, Error, Stats}; mod backend; mod futures_ext; #[derive(Debug, Default)] pub struct St...
code_fim
hard
{ "lang": "rust", "repo": "dmexe/tc-cache", "path": "/src/storage/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(key_prefix) = obj.get("key_prefix").and_then(|it| it.as_str()) { storage = storage.key_prefix(&key_prefix); } if let Some(uploadable) = obj.get("uploadable").and_then(|it| it.as_bool()) { storage = storage.uploadable(uploadable); } ...
code_fim
hard
{ "lang": "rust", "repo": "dmexe/tc-cache", "path": "/src/storage/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_enable_cape_button_monitoring(&mut self, val: bool) { self.settings.enableCapeButtonMonitoring = match val { true => 1, false => 0 }; } pub fn high_performance_mode(&self) -> bool { match self.settings.highPerformanceMode { ...
code_fim
hard
{ "lang": "rust", "repo": "Arkrait/bela-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Sets the direction of a digital pin for the current frame and all subsequent frames pub fn pin_mode(&mut self, frame: usize, channel: usize, mode: DigitalDirection) { let digital = self.digital(); for i in frame..digital.len() { match mode { DigitalDi...
code_fim
hard
{ "lang": "rust", "repo": "Arkrait/bela-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Arkrait/bela-rs path: /src/lib.rs one we are attempting to access with each function. /// /// TODO: Bela needs to also wrap the various setup, render, and cleanup /// functions and keep them in the same struct. /// /// Called when audio is initialized. /// /// ```rust /// pub type SetupFn = F...
code_fim
hard
{ "lang": "rust", "repo": "Arkrait/bela-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32l0/peripherals/exti.rs IMR { /// Interrupt Mask on line 0 pub mod IM0 { /// Offset (0 bits) pub const offset: u32 = 0; /// Mask (1 bit: 1 << 0) pub const mask: u32 = 1 << offset; /// Read-only values (empty) ...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32l0/peripherals/exti.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32l0/peripherals/exti.rs line 21 pub mod FT21 { /// Offset (21 bits) pub const offset: u32 = 21; /// Mask (1 bit: 1 << 21) pub const mask: u32 = 1 << offset; /// Read-only values (empty) pub mod R {} ///...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32l0/peripherals/exti.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Software Interrupt on line 4 pub mod SWI4 { /// Offset (4 bits) pub const offset: u32 = 4; /// Mask (1 bit: 1 << 4) pub const mask: u32 = 1 << offset; /// Read-only values (empty) pub mod R {} pub use super::SWI0::W; /// Read-writ...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32l0/peripherals/exti.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielSanchezQ/jormungandr path: /testing/jormungandr-integration-tests/src/networking/cross_version/fragment_propagation.rs use super::{ALICE, BOB, CLARICE, DAVID}; use super::{LEADER, PASSIVE}; use function_name::named; use hersir::builder::wallet::template::builder::WalletTemplateBuilder; use...
code_fim
hard
{ "lang": "rust", "repo": "danielSanchezQ/jormungandr", "path": "/testing/jormungandr-integration-tests/src/networking/cross_version/fragment_propagation.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let passive = controller .spawn(SpawnParams::new(PASSIVE).in_memory()) .unwrap(); send_all_fragment_types(&mut controller, &passive, None); } fn get_legacy_data(title: &str, context: &mut Context) -> (PathBuf, Version) { let releases = download_last_n_releases(1); let las...
code_fim
hard
{ "lang": "rust", "repo": "danielSanchezQ/jormungandr", "path": "/testing/jormungandr-integration-tests/src/networking/cross_version/fragment_propagation.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use crate::expressions::CastFunction; pub use crate::function::IFunction; pub use crate::function_alias::AliasFunction; pub use crate::function_column::ColumnFunction; pub use crate::function_factory::FactoryFuncRef; pub use crate::function_factory::FunctionFactory; pub use crate::function_literal::Li...
code_fim
hard
{ "lang": "rust", "repo": "rostamn739/datafuse", "path": "/common/functions/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rostamn739/datafuse path: /common/functions/src/lib.rs // Copyright 2020-2021 The Datafuse Authors. // // SPDX-License-Identifier: Apache-2.0. #[cfg(test)] mod function_column_test; <|fim_suffix|>pub use crate::expressions::CastFunction; pub use crate::function::IFunction; pub use crate::funct...
code_fim
hard
{ "lang": "rust", "repo": "rostamn739/datafuse", "path": "/common/functions/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod aggregators; mod arithmetics; mod comparisons; mod expressions; mod function; mod function_alias; mod function_column; mod function_factory; mod function_literal; mod logics; mod strings; mod udfs; pub use crate::expressions::CastFunction; pub use crate::function::IFunction; pub use crate::function_a...
code_fim
medium
{ "lang": "rust", "repo": "rostamn739/datafuse", "path": "/common/functions/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KirillSleta/actix-mqtt path: /examples/mqtt-ws-server.rs //! Mqtt over WebSockets use std::io; use ntex::http::{body, h1, HttpService, Request, Response, ResponseError}; use ntex::io::{Filter, Io}; use ntex::service::{pipeline_factory, ServiceFactory}; use ntex::util::{variant, Ready}; use ntex...
code_fim
hard
{ "lang": "rust", "repo": "KirillSleta/actix-mqtt", "path": "/examples/mqtt-ws-server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // enable websocket streamimng, ws transport // converts incoming stream of ws frames into bytes stream io.add_filter(ws::WsTransportFactory::new( ...
code_fim
hard
{ "lang": "rust", "repo": "KirillSleta/actix-mqtt", "path": "/examples/mqtt-ws-server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ntex::server::Server::build() .bind("mqtt", "127.0.0.1:8883", move |_| { // first switch to ssl stream pipeline_factory(Acceptor::new(acceptor.clone())) .map_err(|_err| MqttError::Service(ServerError {})) // we need to read first 4 bytes ...
code_fim
hard
{ "lang": "rust", "repo": "KirillSleta/actix-mqtt", "path": "/examples/mqtt-ws-server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for value in input { counts.clear(); for ch in value.chars() { counts.entry(ch) .and_modify(|x| *x += 1) .or_insert(1); } if counts.values().any(|v| *v == 2) { twos += 1; } if counts.values().any(...
code_fim
medium
{ "lang": "rust", "repo": "garrettpauls/AdventOfCode2018", "path": "/day2/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: garrettpauls/AdventOfCode2018 path: /day2/src/main.rs extern crate aoc_common; use aoc_common::advent; fn main() { advent(&parse_input, &part_one, &part_two); } // Note: this could probably be rewritten to return &str instead of String // need to learn more about lifetimes. fn parse_input...
code_fim
hard
{ "lang": "rust", "repo": "garrettpauls/AdventOfCode2018", "path": "/day2/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ngtkana/query_test path: /examples/helper.rs pub mod helpers { use query_test::{help_material, HelpMaterial}; use std::marker::PhantomData; #[help_material(usize)] pub struct Len(); #[help_material(T)] pub struct Value<T>(PhantomData<T>); #[help_material(T)] pu...
code_fim
hard
{ "lang": "rust", "repo": "ngtkana/query_test", "path": "/examples/helper.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod gen_example { use super::helpers; use query_test::impl_help; use rand::Rng; pub struct G {} impl_help! { helpers::Len, |rng| rng.gen_range(1, 20); helpers::Value<u32>, |rng| rng.gen_range(0, 20); } }<|fim_prefix|>// repo: ngtkana/query_test path: /examples...
code_fim
hard
{ "lang": "rust", "repo": "ngtkana/query_test", "path": "/examples/helper.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgkf/advent-of-code path: /2015/09/rust/src/main.rs use std::io::BufRead; use std::collections::BTreeMap; use itertools::Itertools; use regex::Regex; fn parse_dists() -> BTreeMap<Vec<String>, i32> { std::io::stdin() .lock() .lines() .filter_map(|l| l.ok()) .m...
code_fim
hard
{ "lang": "rust", "repo": "dgkf/advent-of-code", "path": "/2015/09/rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let dist = String::from(&cap["d"]).parse::<i32>().unwrap(); (towns, dist) } fn unique_towns(x: &BTreeMap<Vec<String>, i32>) -> Vec<String> { let mut towns: Vec<String> = Vec::new(); for k in x.keys().cloned().collect_vec() { towns.extend(k); } towns.iter().cloned().unique...
code_fim
medium
{ "lang": "rust", "repo": "dgkf/advent-of-code", "path": "/2015/09/rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let font_handle = asset_server .load_sync(&mut assets, "resources/fonts/FiraSans-Bold.ttf") .unwrap(); log.make(&mut commands, font_handle, 4) .add_message("Welcome to Labyrinth".to_string()) .add_message("This is a demo at this point".to_string()) .add_mes...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/labyrinth-game", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/labyrinth-game path: /src/main.rs use bevy::prelude::*; mod state; use lab_core::*; use lab_entities::prelude::*; use lab_input::*; use lab_sprites::*; use lab_world::{TextChangeEvent, TileInteraction}; pub mod layers { // z indexes of sprites pub const TOP: f32 = 999.; pu...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/labyrinth-game", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(base64_encode("\0".as_bytes()), "AA=="); assert_eq!(base64_encode("abcdef".as_bytes()), "YWJjZGVm"); assert_eq!(base64_encode("abcdefgh".as_bytes()), "YWJjZGVmZ2g="); } #[test] fn test_hex_to_base64() { let x = "49276d206b696c6c696e6720796f7572206272...
code_fim
hard
{ "lang": "rust", "repo": "nadirs/cryptopals", "path": "/src/set01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_base64_encode() { assert_eq!(base64_encode("\0".as_bytes()), "AA=="); assert_eq!(base64_encode("abcdef".as_bytes()), "YWJjZGVm"); assert_eq!(base64_encode("abcdefgh".as_bytes()), "YWJjZGVmZ2g="); } #[test] fn test_hex_to_base64() { let x...
code_fim
hard
{ "lang": "rust", "repo": "nadirs/cryptopals", "path": "/src/set01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nadirs/cryptopals path: /src/set01.rs use std::iter::*; use std::cmp::min; static BASE64_MAP: &'static[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; pub fn base64_encode(x: &[u8]) -> String { let mut result = Vec::with_capacity((x.len() / 3) * 4); let c...
code_fim
hard
{ "lang": "rust", "repo": "nadirs/cryptopals", "path": "/src/set01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Noskilo/mario-rs path: /src/main.rs use engine::game::SuperMario; use ggez::{ conf::{WindowMode, WindowSetup}, event, ContextBuilder, }; use std::{env, path}; <|fim_suffix|> let (mut ctx, mut event_loop) = ContextBuilder::new("super_mario", "Michael Iskandarani") .window_setu...
code_fim
hard
{ "lang": "rust", "repo": "Noskilo/mario-rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let resource_dir = if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") { let mut path = path::PathBuf::from(manifest_dir); path.push("resources"); path } else { path::PathBuf::from("./resources") }; let (mut ctx, mut event_loop) = ContextBuilder::new("...
code_fim
medium
{ "lang": "rust", "repo": "Noskilo/mario-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut a = gen_ubig(2); let prev_cap = capacity(&a); a.clone_from(&num); // The buffer should now be reallocated, it's too small. assert_ne!(capacity(&a), prev_cap); assert_eq!(capacity(&a), capacity(&num)); let mut a = gen_ubig(100); let p...
code_fim
hard
{ "lang": "rust", "repo": "nabeix51/ibig-rs", "path": "/src/ubig.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nabeix51/ibig-rs path: /src/ubig.rs //! Unsigned big integer. use self::Repr::*; use crate::{ arch::{ntt, word::Word}, buffer::Buffer, math, primitive::WORD_BITS_USIZE, }; use core::slice; /// Internal representation of UBig. #[derive(Debug, Eq, Hash, PartialEq)] pub(crate) enu...
code_fim
hard
{ "lang": "rust", "repo": "nabeix51/ibig-rs", "path": "/src/ubig.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(users.limit(limit as i64).load::<User>(conn)?) }<|fim_prefix|>// repo: pfcoder/uranus path: /user/src/user/service/list.rs use crate::database::PooledConnection; use crate::errors::ServiceResult; use crate::graphql::model::Context; use crate::user::model::User; use diesel::prelude::*; <|fim_middle|...
code_fim
medium
{ "lang": "rust", "repo": "pfcoder/uranus", "path": "/user/src/user/service/list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pfcoder/uranus path: /user/src/user/service/list.rs use crate::database::PooledConnection; use crate::errors::ServiceResult; use crate::graphql::model::Context; use crate::user::model::User; use diesel::prelude::*; <|fim_suffix|> Ok(users.limit(limit as i64).load::<User>(conn)?) }<|fim_middle|...
code_fim
medium
{ "lang": "rust", "repo": "pfcoder/uranus", "path": "/user/src/user/service/list.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: houweifeng/mprovision path: /src/bin/main.rs extern crate mprovision; extern crate docopt; #[macro_use(version)] extern crate version; use std::io::{self, Write}; use std::process; use docopt::Docopt; const USAGE: &'static str = " mprovision A tool that helps iOS developers to manage mobilepr...
code_fim
hard
{ "lang": "rust", "repo": "houweifeng/mprovision", "path": "/src/bin/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if args.get_bool("search") { Some(Command::Search) } else if args.get_bool("remove") { Some(Command::Remove) } else { None } } } fn search(args: &::docopt::ArgvMap) -> Result<(), String> { let text = args.get_str("<text>"); i...
code_fim
hard
{ "lang": "rust", "repo": "houweifeng/mprovision", "path": "/src/bin/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Command { fn from_args(args: &::docopt::ArgvMap) -> Option<Command> { if args.get_bool("search") { Some(Command::Search) } else if args.get_bool("remove") { Some(Command::Remove) } else { None } } } fn search(args: &::docopt...
code_fim
hard
{ "lang": "rust", "repo": "houweifeng/mprovision", "path": "/src/bin/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tgaref/arithmitikon path: /src/factor/pollard.rs extern crate rand; use ramp::Int; use ramp::RandomInt; use std::vec::Vec; use super::common; use crate::primes; fn g(x: &Int, n: &Int) -> Int { (x * x + 1) % n } fn split(n: &Int) -> (Int, Int) { let mut rng = rand::thread_rng(); let...
code_fim
hard
{ "lang": "rust", "repo": "tgaref/arithmitikon", "path": "/src/factor/pollard.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn factor(n: &Int) -> Vec<(Int,usize)> { if *n < 0 { let m = -n; return factor(&m) } if *n == 0 || *n == 1 { return vec![] } let mut m = n.clone(); let mut ps1 = common::remove_primes(&mut m, &Int::from(100)); let mut ps2 = compute_pairs(pr_fact...
code_fim
hard
{ "lang": "rust", "repo": "tgaref/arithmitikon", "path": "/src/factor/pollard.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timothybrink/oak path: /src/common.rs use super::expressions::*; use std::cell::RefCell; use std::collections::HashMap; use std::fmt; use std::fmt::Debug; use std::fmt::Display; use std::ops::{Add, Mul}; use std::rc::Rc; #[derive(Debug, Clone)] pub struct Function { pub parameters: Vec<Stri...
code_fim
hard
{ "lang": "rust", "repo": "timothybrink/oak", "path": "/src/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Iterator for StringIterator<'a> { type Item = char; fn next(&mut self) -> Option<char> { let val = self.next_value; self.next_value = self.iter.next(); val } } impl<'a> StringIterator<'a> { pub fn new(string: &str) -> StringIterator { let mut iter...
code_fim
hard
{ "lang": "rust", "repo": "timothybrink/oak", "path": "/src/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0503.rs //! @ Here we use the fact that |"<"|, |"="|, and |">"| are consecutive ASCII //! codes. //! @^ASCII code@> // // @<Test relation between integers or dimensions@>= pub(crate) macro Test_relation_between_integers_or_dimensions($globals:e...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0503.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> $globals.cur_val; } // ">": b:=(n>cur_val); else if r == b'>' { $b = n > $globals.cur_val; } // end; else { unreachable!(); } // end use crate::pascal::integer; use crate::section_0073::print_err; use crate::section_0079::help1; use crate::s...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0503.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rainliu/rsplit path: /src/main.rs extern crate rsplit; use std::env; use std::process; use rsplit::yuv::Yuv; use rsplit::ivf::Ivf; use rsplit::webm::Webm; use rsplit::psnr::Psnr; use rsplit::bin::Bin; fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 2 { ...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/rsplit", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Err(err) = webm.run() { println!("{}", err); } } else { println!("unsupported split {} mode", args[1]); println!("Usage: rsplit bin|ivf|psnr|webm|yuv ..."); } } }<|fim_prefix|>// repo: rainliu/rsplit path: /src/mai...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/rsplit", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Err(err) = bin.run() { println!("{}", err); } } else if args[1] == "webm" { let webm = Webm::new(&args).unwrap_or_else(|err| { println!("Problem parsing arguments: {}", err); Webm::helper(); ...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/rsplit", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match a { Action::N(x) => { self.location.1 = self.location.1 - x; } Action::E(x) => { self.location.0 = self.location.0 + x; } Action::W(x) => { self.location.0 = self.location.0 - x; ...
code_fim
hard
{ "lang": "rust", "repo": "squidboylan/advent-of-code-2020", "path": "/day12/src/part1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: squidboylan/advent-of-code-2020 path: /day12/src/part1.rs use super::*; #[derive(Debug, Clone)] struct Ship { direction: Direction, // (x, y) location: (i64, i64), } impl Ship { fn new() -> Self { Ship { direction: Direction::E, location: (0, 0),...
code_fim
hard
{ "lang": "rust", "repo": "squidboylan/advent-of-code-2020", "path": "/day12/src/part1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn apply_action(&mut self, a: Action) { match a { Action::N(x) => { self.location.1 = self.location.1 - x; } Action::E(x) => { self.location.0 = self.location.0 + x; } Action::W(x) => { ...
code_fim
hard
{ "lang": "rust", "repo": "squidboylan/advent-of-code-2020", "path": "/day12/src/part1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HyperDeFiProtocol/surge path: /src/subscribe.rs use std::fs; fn req_get(url: &str) -> Result<String, Box<dyn std::error::Error>> { let txt = reqwest::blocking::get(url)?.text()?; Ok(txt) } fn read_subscribe_urls() -> Vec<String> { println!("Read `./subscribe.list`.....
code_fim
hard
{ "lang": "rust", "repo": "HyperDeFiProtocol/surge", "path": "/src/subscribe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match req_get(&url) { Err(_err) => { println!("Failed!"); }, Ok(text) => { println!("Succeess!"); for line in text.lines() { if line.len() > 0 { lines.push(Stri...
code_fim
hard
{ "lang": "rust", "repo": "HyperDeFiProtocol/surge", "path": "/src/subscribe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ert_eq!(count_tts!(------------), 12); const_assert_eq!(count_tts!(-------------), 13); const_assert_eq!(count_tts!(--------------), 14); const_assert_eq!(count_tts!(---------------), 15);<|fim_prefix|>// repo: camsteffen/count-tts path: /tests/test.rs use count_tts::count_tts; use static_assertions::con...
code_fim
hard
{ "lang": "rust", "repo": "camsteffen/count-tts", "path": "/tests/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: camsteffen/count-tts path: /tests/test.rs use count_tts::count_tts; use static_assertions::const_assert_eq; const_assert_eq!(count_tts!(), 0); const_assert_eq!(count_tts!(-), 1); const_assert_eq!(count_tts!(--), 2); const_assert_<|fim_suffix|>ert_eq!(count_tts!(------------), 12); const_assert_...
code_fim
hard
{ "lang": "rust", "repo": "camsteffen/count-tts", "path": "/tests/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn bind_listen_serve<A, P, F, Fut>( addrs: A, directory_url: impl AsRef<str>, domains: Vec<String>, cache_dir: Option<P>, f: F, ) -> io::Result<()> where A: ToSocketAddrs, P: AsRef<Path>, F: 'static + Sync + Send + Fn(TlsStream) -> Fut, Fut: Future<Output = ()...
code_fim
medium
{ "lang": "rust", "repo": "agora-org/rustls-acme", "path": "/src/simple.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agora-org/rustls-acme path: /src/simple.rs use crate::{ResolvesServerCertUsingAcme, TlsAcceptor}; use async_rustls::rustls::{NoClientAuth, ServerConfig}; use async_std::io; use async_std::net::{TcpListener, TcpStream, ToSocketAddrs}; use async_std::path::Path; use async_std::sync::Arc; use async...
code_fim
medium
{ "lang": "rust", "repo": "agora-org/rustls-acme", "path": "/src/simple.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> arq.update(3, 7, &0); let first_neg_zeros = static_arq::first_negative(&mut arq); assert_eq!(first_neg, Some(3)); assert_eq!(first_neg_zeros, None); } #[test] fn test_dynamic_binary_search_rmq() { let vec = vec![2, 1, 0, -1, -2, -3, -4, -5]; le...
code_fim
hard
{ "lang": "rust", "repo": "EbTech/rust-algorithms", "path": "/src/range_query/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EbTech/rust-algorithms path: /src/range_query/mod.rs pub mod dynamic_arq; pub mod specs; pub mod sqrt_decomp; pub mod static_arq; pub use dynamic_arq::{ArqView, DynamicArq}; pub use specs::ArqSpec; pub use static_arq::StaticArq; #[cfg(test)] mod test { use super::specs::*; use super::*;...
code_fim
hard
{ "lang": "rust", "repo": "EbTech/rust-algorithms", "path": "/src/range_query/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(arq.query(view, 0, 9), 23); assert_eq!(arq.query(view, 10, 4), 0); } #[test] fn test_supply_demand() { let mut arq = StaticArq::<SupplyDemand>::new(&[(0, 0, 0); 10]); arq.update(1, 1, &(25, 100)); arq.update(3, 3, &(100, 30)); arq.up...
code_fim
hard
{ "lang": "rust", "repo": "EbTech/rust-algorithms", "path": "/src/range_query/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marius851000/cp_mod_tool path: /src/mod_file_writer.rs use std::fs::File; use std::io; use std::io::{ErrorKind, Read, Seek, Write}; use std::path::PathBuf; use crate::style::StepProgress; use crate::ModConfiguration; use walkdir::WalkDir; use zip::{ write::{FileOptions, ZipWriter}, Com...
code_fim
hard
{ "lang": "rust", "repo": "marius851000/cp_mod_tool", "path": "/src/mod_file_writer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let zip_options = FileOptions::default().compression_method(CompressionMethod::Deflated); let mut embedded_content = Vec::new(); for entry in walkdir { let entry = entry?; let content_abs_path = entry.path(); let content_rel_path = ...
code_fim
hard
{ "lang": "rust", "repo": "marius851000/cp_mod_tool", "path": "/src/mod_file_writer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ixre/jsa path: /src/main.rs #![feature(proc_macro_hygiene, decl_macro)] #![allow(unused)] extern crate openssl; #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_contrib; <|fim_suffix|>use clap::{App, Arg}; use rocket::config::Environment; use rocket::http::ContentType; use roc...
code_fim
medium
{ "lang": "rust", "repo": "ixre/jsa", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let args = [ Arg::with_name("data-dir") .short("d") .takes_value(true) .default_value("./data"), Arg::with_name("port") .short("p") .takes_value(true) .default_value("8302"), Arg::with_name("print").takes_v...
code_fim
hard
{ "lang": "rust", "repo": "ixre/jsa", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl TransferMsg { pub fn new(recipient: HumanAddr, amount: Uint128) -> Self { let padding = Some(" ".repeat(40 - amount.to_string().chars().count())); Self { recipient, amount, padding, } } /// serializes the message pub fn into_...
code_fim
hard
{ "lang": "rust", "repo": "cankisagun/SCRT-sealed-bid-auction", "path": "/src/msg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cankisagun/SCRT-sealed-bid-auction path: /src/msg.rs use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::state::ContractInfo; use cosmwasm_std::{to_binary, Binary, CosmosMsg, HumanAddr, StdResult, Uint128, WasmMsg}; // Instantiating an auction requires: // sell_contra...
code_fim
hard
{ "lang": "rust", "repo": "cankisagun/SCRT-sealed-bid-auction", "path": "/src/msg.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let queue = queues.next().unwrap(); let (mut swapchain, images) = { let caps = surface.capabilities(physical).unwrap(); let usage = caps.supported_usage_flags; let alpha = caps.supported_composite_alpha.iter().next().unwrap(); let format = caps.supported_formats[0]...
code_fim
hard
{ "lang": "rust", "repo": "Aganthor/vulkano-tutorial", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aganthor/vulkano-tutorial path: /src/main.rs )] struct AmbientLight { color: [f32; 3], intensity: f32 } #[derive(Default, Debug, Clone)] struct DirectionalLight { position: [f32; 4], color: [f32; 3] } mod deferred_vert { vulkano_shaders::shader!{ ty: "vertex", ...
code_fim
hard
{ "lang": "rust", "repo": "Aganthor/vulkano-tutorial", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Main loop! event_loop.run(move |event, _, control_flow| { match event { Event::WindowEvent {window_id, event } => { match event { WindowEvent::CloseRequested => { *control_flow = ControlFlow::Exit ...
code_fim
hard
{ "lang": "rust", "repo": "Aganthor/vulkano-tutorial", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let reader = mem.reader(); for x in reader { let r: (i32, f32) = x.ok().unwrap(); } } #[test] pub fn test_write_projected() { let schema = &[I32, F32, I32]; let session = Session; let mut gen = RandomTable::new(&session, schema, 5); let mut mem = MemTable::new(&session, &[F32, I32], &[...
code_fim
hard
{ "lang": "rust", "repo": "hyunsik/tokamak", "path": "/src/common/tests/memtable_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] pub fn test_write_projected() { let schema = &[I32, F32, I32]; let session = Session; let mut gen = RandomTable::new(&session, schema, 5); let mut mem = MemTable::new(&session, &[F32, I32], &["x", "y"]); let page = gen.next().unwrap(); let projected = page.project(&[1,2]); a...
code_fim
hard
{ "lang": "rust", "repo": "hyunsik/tokamak", "path": "/src/common/tests/memtable_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hyunsik/tokamak path: /src/common/tests/memtable_tests.rs #[macro_use] extern crate common; use common::session::Session; use common::types::{I32, F32, Ty}; use common::page::{c_api, Page, ROWBATCH_SIZE}; use common::input::InputSource; use common::storage::{MemTable, RandomTable}; macro_rules...
code_fim
hard
{ "lang": "rust", "repo": "hyunsik/tokamak", "path": "/src/common/tests/memtable_tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kcc-community/safe-client-gateway path: /src/monitoring/tests/path_patterns.rs use crate::monitoring::performance::extract_chain_id; #[test] fn chain_dependent_endpoint() { let uri = uri!("/v1/chains/1/safes/0x1230B3d59858296A31053C1b8562Ecf89A2f888b"); let actual = extract_chain_id(&ur...
code_fim
medium
{ "lang": "rust", "repo": "kcc-community/safe-client-gateway", "path": "/src/monitoring/tests/path_patterns.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn chain_independent_endpoint() { let uri = uri!("/about/redis/"); let actual = extract_chain_id(&uri.path()); assert_eq!("-1", actual); }<|fim_prefix|>// repo: kcc-community/safe-client-gateway path: /src/monitoring/tests/path_patterns.rs use crate::monitoring::performance::extract_...
code_fim
hard
{ "lang": "rust", "repo": "kcc-community/safe-client-gateway", "path": "/src/monitoring/tests/path_patterns.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: transparencies/speedrun-api path: /src/api/publishers.rs //! # Publishers //! //! Endpoints available for publishers. use std::{borrow::Cow, fmt::Display}; use http::Method; use serde::{Deserialize, Serialize}; use super::{endpoint::Endpoint, Direction, Pageable}; /// Sorting options for publ...
code_fim
hard
{ "lang": "rust", "repo": "transparencies/speedrun-api", "path": "/src/api/publishers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(serde_urlencoded::to_string(self)?.into()) } } impl Endpoint for Publisher<'_> { fn method(&self) -> Method { Method::GET } fn endpoint(&self) -> Cow<'static, str> { format!("/publishers/{}", self.id).into() } } impl Pageable for Publishers {}<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "transparencies/speedrun-api", "path": "/src/api/publishers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nervosnetwork/ckb path: /test/src/specs/tx_pool/descendant.rs use ckb_jsonrpc_types::Status; use crate::specs::tx_pool::utils::prepare_tx_family; use crate::utils::{blank, commit, propose}; use crate::{Node, Spec}; use std::collections::HashSet; // Convention: // * `tx_family` is a set of re...
code_fim
hard
{ "lang": "rust", "repo": "nervosnetwork/ckb", "path": "/test/src/specs/tx_pool/descendant.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let node = &nodes[0]; let window = node.consensus().tx_proposal_window(); node.mine(window.farthest() + 2); // 1. Propose `tx_family.a` into proposed-pool. let family = prepare_tx_family(node); let tx_a = family.a(); node.submit_transaction(tx_a); ...
code_fim
hard
{ "lang": "rust", "repo": "nervosnetwork/ckb", "path": "/test/src/specs/tx_pool/descendant.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn distance(&self, source: &str, destination: &str) -> Option<usize> { let mut distances: HashMap<&str, usize> = HashMap::new(); let mut queue = BinaryHeap::new(); queue.push((0, source)); while let Some((distance, object)) = queue.pop() { if destination == ...
code_fim
hard
{ "lang": "rust", "repo": "ssiegler/aoc-2019", "path": "/src/bin/day6.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ssiegler/aoc-2019 path: /src/bin/day6.rs use std::collections::{BinaryHeap, HashMap}; use std::convert::TryFrom; use std::io::{stdin, BufRead}; use std::iter::FromIterator; fn main() { let orbits = read_orbits(); println!("Checksum: {}", orbits.checksum()); let source = orbits.cente...
code_fim
hard
{ "lang": "rust", "repo": "ssiegler/aoc-2019", "path": "/src/bin/day6.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn read_lines(lines: &str) -> OrbitMap { lines .lines() .map(|line| line.to_string()) .map(Orbit::try_from) .collect::<Result<OrbitMap, _>>() .unwrap() } #[test] fn calculates_checksum() { let orbits = read_lines(...
code_fim
hard
{ "lang": "rust", "repo": "ssiegler/aoc-2019", "path": "/src/bin/day6.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn serialize_some<T>(self, _value: &T) -> EncodeResult<Self::Ok> where T: ?Sized + Serialize, { Err(EncoderError::KeyMustBeAString) } fn serialize_seq(self, _len: Option<usize>) -> EncodeResult<Self::SerializeSeq> { Err(EncoderError::KeyMustBeAString) } ...
code_fim
hard
{ "lang": "rust", "repo": "gentoo90/winreg-rs", "path": "/src/encoder/serialization_serde.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gentoo90/winreg-rs path: /src/encoder/serialization_serde.rs // Copyright 2017, Igor Shaula // Licensed under the MIT License <LICENSE or // http://opensource.org/licenses/MIT>. This file // may not be copied, modified, or distributed // except according to those terms. use super::EncoderState::...
code_fim
hard
{ "lang": "rust", "repo": "gentoo90/winreg-rs", "path": "/src/encoder/serialization_serde.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>3; pub const ACARS_MU_CMU: u8 = 0o304; pub const WBS: u8 = 0o305; pub const TCAS: u8 = 0o306; pub const SDU_1: u8 = 0o307; pub const GPWS: u8 = 0o310; pub const GNLU_1: u8 = 0o311; pub const GNLU_2: u8 = 0o312; pub const GNLU_3: u8 = 0o313; pub const GNU_1: u8 = 0o314; pub const GNU_2: u8 = 0o315; pub con...
code_fim
hard
{ "lang": "rust", "repo": "samcrow/arinc_429.rs", "path": "/src/constants/sal.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samcrow/arinc_429.rs path: /src/constants/sal.rs //! //! Subsystem address label (SAL) values //! pub const B777_CABIN_INTERPHONE: u8 = 0o152; pub const CVR_2: u8 = 0o156; pub const CVR: u8 = 0o157; pub const B747_DFHR_A330_A340_SSFDR: u8 = 0o163; pub const DFDAU: u8 = 0o170; pub const SDU_2: u...
code_fim
hard
{ "lang": "rust", "repo": "samcrow/arinc_429.rs", "path": "/src/constants/sal.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jfredett/os path: /src/interrupt/keyboard.rs use super::*; use x86_64::instructions::port::Port; use pc_keyboard::{ layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1 }; use spin::Mutex; <|fim_suffix|>pub extern "x86-interrupt" fn handler(_stack_frame: &mut Interrup...
code_fim
hard
{ "lang": "rust", "repo": "jfredett/os", "path": "/src/interrupt/keyboard.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut keyboard = KEYBOARD.lock(); let mut port = Port::new(PS2_IO_PORT); let scancode: u8 = unsafe { port.read() }; if let Ok(Some(key_event)) = keyboard.add_byte(scancode) { if let Some(key) = keyboard.process_keyevent(key_event) { match key { Decod...
code_fim
medium
{ "lang": "rust", "repo": "jfredett/os", "path": "/src/interrupt/keyboard.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }