text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> #[test] fn sanity_check() { assert_eq!(roundf(-1.0), -1.0); assert_eq!(roundf(2.8), 3.0); assert_eq!(roundf(-0.5), -1.0); assert_eq!(roundf(0.5), 1.0); assert_eq!(roundf(-1.5), -2.0); assert_eq!(roundf(1.5), 2.0); } }<|fim_prefix|>// repo: rust-l...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/libm", "path": "/src/math/roundf.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/libm path: /src/math/roundf.rs use super::copysignf; use super::truncf; use core::f32; #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn roundf(x: f32) -> f32 { truncf(x + copysignf(0.5 - 0.25 * f32::EPSILON, x)) } // PowerPC tests are failing on LLVM 13: https:/...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/libm", "path": "/src/math/roundf.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn token(&self) -> &Token { self.expression.token() } } impl Display for ExpressionStatement { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { self.expression.fmt(f) } }<|fim_prefix|>// repo: robotlovesyou/ronky path: /src/ast/expression_statement.rs use crate::...
code_fim
hard
{ "lang": "rust", "repo": "robotlovesyou/ronky", "path": "/src/ast/expression_statement.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ExpressionStatement { pub fn new_expression_statement(expression: Expression) -> Statement { Statement::new(StatementKind::Expression(ExpressionStatement { expression, })) } pub fn expression(&self) -> &Expression { &self.expression } pub fn t...
code_fim
medium
{ "lang": "rust", "repo": "robotlovesyou/ronky", "path": "/src/ast/expression_statement.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robotlovesyou/ronky path: /src/ast/expression_statement.rs use crate::ast::{Expression, Statement, StatementKind}; use crate::token::Token; use std::fmt::{self, Display, Formatter}; <|fim_suffix|> pub fn token(&self) -> &Token { self.expression.token() } } impl Display for Expre...
code_fim
hard
{ "lang": "rust", "repo": "robotlovesyou/ronky", "path": "/src/ast/expression_statement.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shmew/wasmtime path: /cranelift/peepmatic/src/linear_passes.rs hs, a, b)); debug_assert!(is_sorted_by_generality(opts)); } /// Sort the linear optimizations lexicographically. /// /// This sort order is required for automata construction. pub fn sort_lexicographically<TOperator>(opts: &mut ...
code_fim
hard
{ "lang": "rust", "repo": "Shmew/wasmtime", "path": "/cranelift/peepmatic/src/linear_passes.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shmew/wasmtime path: /cranelift/peepmatic/src/linear_passes.rs ted result. /// /// For example, consider these two patterns that don't have any shared prefix: /// /// ```lisp /// (=> (iadd $x $y) ...) /// (=> $C ...) /// ``` /// /// These produce the following linear match operations and expecte...
code_fim
hard
{ "lang": "rust", "repo": "Shmew/wasmtime", "path": "/cranelift/peepmatic/src/linear_passes.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(expected, actual); } }; } macro_rules! match_in_same_order { ($test_name:ident, $source:expr, $make_expected:expr) => { #[test] #[allow(unused_variables)] fn $test_name() { let buf = wast::p...
code_fim
hard
{ "lang": "rust", "repo": "Shmew/wasmtime", "path": "/cranelift/peepmatic/src/linear_passes.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> let flow_rate = parts.nth(2).expect("expected flow rate on input"); let flow_rate: u32 = flow_rate .get(5..(flow_rate.len() - 1)) .expect("flow rate has unexpected size") .parse() .expect("flow rate is not an integer")...
code_fim
hard
{ "lang": "rust", "repo": "diogotcorreia/advent-of-code", "path": "/2022/src/day16.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diogotcorreia/advent-of-code path: /2022/src/day16.rs use std::{ cmp::Reverse, collections::{HashMap, VecDeque}, }; use crate::AocDay; type Edges = Vec<String>; type AllEdges = HashMap<String, Edges>; type ValveDistances = HashMap<String, u32>; type AllValveDistances = HashMap<String, ...
code_fim
hard
{ "lang": "rust", "repo": "diogotcorreia/advent-of-code", "path": "/2022/src/day16.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn dfs_greater_pressure( day: &AocDay16, current_valves: (&String, &String), current_minute: (i32, i32), already_visited: Vec<String>, current_pressure: u32, mut max_pressure: u32, ) -> u32 { let (distances_me, distances_elephant) = ( day.valves_distances .g...
code_fim
hard
{ "lang": "rust", "repo": "diogotcorreia/advent-of-code", "path": "/2022/src/day16.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Indicates support for automatically keeping the /// Flags field of the advertising data updated. Users of this flag /// will decrease the `max_adv_data_len` by 3 and need to keep /// that in mind. The Flags field will be added in front of the /// advertising data provided by the us...
code_fim
hard
{ "lang": "rust", "repo": "laptou/bluez-rs", "path": "/src/management/client/advertising.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laptou/bluez-rs path: /src/management/client/advertising.rs use super::*; use crate::util::BufExt; use enumflags2::{bitflags, BitFlags}; /// This command is used to read the advertising features supported /// by the controller and stack. The `max_adv_data_len` and `max_scan_rsp_len` provides ex...
code_fim
hard
{ "lang": "rust", "repo": "laptou/bluez-rs", "path": "/src/management/client/advertising.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let path = Path::new(&env::var("OUT_DIR").unwrap()).join("params.rs"); let mut file = File::create(&path).unwrap(); writeln!(&mut file, "pub const PITS: usize = {};", pits) .unwrap(); writeln!(&mut file, "pub const FPITS: usize = {};", fpits) .unwrap(); writeln!(&mut f...
code_fim
hard
{ "lang": "rust", "repo": "Lapin0t/awari", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> writeln!(&mut file, "pub const PITS: usize = {};", pits) .unwrap(); writeln!(&mut file, "pub const FPITS: usize = {};", fpits) .unwrap(); writeln!(&mut file, "pub const START_SEEDS: usize = {};", seeds / fpits) .unwrap(); writeln!(&mut file, "pub const SEEDS: usize ...
code_fim
hard
{ "lang": "rust", "repo": "Lapin0t/awari", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lapin0t/awari path: /build.rs //extern crate libc; use std::env; use std::fs::File; use std::path::Path; use std::io::Write; fn binom(k: usize, n: usize) -> usize { if n < k { return 0; } let mut p = 1; for i in 0..k { p *= n - i; p /= i + 1; } ...
code_fim
hard
{ "lang": "rust", "repo": "Lapin0t/awari", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rv32m1-rust/rv32m1_ri5cy-hal path: /examples/serial-hello-world.rs #![no_std] #![no_main] extern crate panic_halt; use rv32m1_ri5cy_hal::{pac, prelude::*, scg::{Clocks, Source}, serial::{Serial, Config}}; <|fim_suffix|> let cp = pac::Peripherals::take().unwrap(); let mut pcc0 = cp.PCC0....
code_fim
medium
{ "lang": "rust", "repo": "rv32m1-rust/rv32m1_ri5cy-hal", "path": "/examples/serial-hello-world.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let cp = pac::Peripherals::take().unwrap(); let mut pcc0 = cp.PCC0.constrain(); let clocks = Clocks {}; // todo! let portb = cp.PORTB.split(&mut pcc0.portb).unwrap(); let ptb26 = portb.ptb26.into_af3(); let ptb25 = portb.ptb25.into_af3(); let mut serial = Serial::lpuart0( ...
code_fim
medium
{ "lang": "rust", "repo": "rv32m1-rust/rv32m1_ri5cy-hal", "path": "/examples/serial-hello-world.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mic92/wireguard-p2p path: /src/search.rs use futures::prelude::*; use tokio_core::reactor::Handle; use sodiumoxide::crypto::hash::sha256; use base64; use errors::Result; use bulletinboard::BulletinBoard; #[async] pub fn search(handle: Handle, peer_name: String) -> Result<()> { println!("...
code_fim
medium
{ "lang": "rust", "repo": "Mic92/wireguard-p2p", "path": "/src/search.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{} public key(s) found:", values.len()); for (i, v) in values.iter().enumerate() { println!(" {}) {}", i + 1, base64::encode(v)); } Ok(()) }<|fim_prefix|>// repo: Mic92/wireguard-p2p path: /src/search.rs use futures::prelude::*; use tokio_core::reactor::Handle; use so...
code_fim
hard
{ "lang": "rust", "repo": "Mic92/wireguard-p2p", "path": "/src/search.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PegasisForever/rust_todo path: /src/webpage.rs use actix_web::HttpResponse; use actix_web::http::StatusCode; #[get("/")<|fim_suffix|>=utf-8") .body(include_str!("../frontend/inlined/index.html"))) }<|fim_middle|>] pub async fn webpage() -> actix_web::Result<HttpResponse> { Ok(HttpRe...
code_fim
medium
{ "lang": "rust", "repo": "PegasisForever/rust_todo", "path": "/src/webpage.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Response::build(StatusCode::OK) .content_type("text/html; charset=utf-8") .body(include_str!("../frontend/inlined/index.html"))) }<|fim_prefix|>// repo: PegasisForever/rust_todo path: /src/webpage.rs use actix_web::HttpResponse; use actix_web::http::StatusCode; #[get("/")<|fim_middle|>] ...
code_fim
medium
{ "lang": "rust", "repo": "PegasisForever/rust_todo", "path": "/src/webpage.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/* ./target/release/day15 3,29s user 0,05s system 99% cpu 3,351 total ./target/release/day15 3,25s user 0,07s system 99% cpu 3,323 total ./target/release/day15 3,30s user 0,04s system 99% cpu 3,346 total ./target/release/day15 3,32s user 0,05s system 99% cpu 3,372 total ./target/release/day15 3,60s u...
code_fim
hard
{ "lang": "rust", "repo": "Kortekaasy/aoc2020", "path": "/day15/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("==================== Part {} ======================", part); for l in output.lines() { println!("| {:^46} |", l); } println!("=================================================="); } /* ./target/release/day15 3,29s user 0,05s system 99% cpu 3,351 total ./target/release/d...
code_fim
hard
{ "lang": "rust", "repo": "Kortekaasy/aoc2020", "path": "/day15/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kortekaasy/aoc2020 path: /day15/src/main.rs use std::collections::HashMap; // ========================= Challenge Logic ============================ pub fn find_number_of_turn(input_numbers: &Vec<usize>, target: usize) -> usize { let mut mem: HashMap<usize, usize> = HashMap::new(); for...
code_fim
hard
{ "lang": "rust", "repo": "Kortekaasy/aoc2020", "path": "/day15/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: viirya/vektor path: /src/x86_64/rdrand.rs // Autogenerated by `scrape.py`. // See https://github.com/AdamNiederer/vektor-gen #![allow(unused_imports)] use crate::myarch::*; use crate::simd::*; <|fim_suffix|>/// Read a 64-bit NIST SP800-90B and SP800-90C compliant random value and store /// in ...
code_fim
hard
{ "lang": "rust", "repo": "viirya/vektor", "path": "/src/x86_64/rdrand.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Read a 64-bit NIST SP800-90B and SP800-90C compliant random value and store /// in val. Return 1 if a random value was generated, and 0 otherwise. #[inline] #[target_feature(enable = "rdseed")] #[cfg_attr(test, assert_instr(rdseed))] pub unsafe fn _rdseed64_step(val: &mut u64) -> i32 { crate::mem:...
code_fim
hard
{ "lang": "rust", "repo": "viirya/vektor", "path": "/src/x86_64/rdrand.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gilescope/wasm-tools path: /fuzz/fuzz_targets/validate-valid-module.rs #![no_main] use libfuzzer_sys::fuzz_target; // Define a fuzz target that accepts arbitrary // `Module`s as input. fuzz_target!(|m: &[u8]| { let (bytes, config) = match wasm_tools_fuzz::generate_valid_module(m, |_, _|<|f...
code_fim
hard
{ "lang": "rust", "repo": "gilescope/wasm-tools", "path": "/fuzz/fuzz_targets/validate-valid-module.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>parser::WasmFeatures { multi_value: true, multi_memory: config.max_memories > 1, bulk_memory: true, reference_types: true, module_linking: config.module_linking_enabled, simd: config.simd_enabled, memory64: config.memory64_enabled, ..wasmpars...
code_fim
hard
{ "lang": "rust", "repo": "gilescope/wasm-tools", "path": "/fuzz/fuzz_targets/validate-valid-module.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Send work into the thread pool... for path in matches.values_of("paths").unwrap() { for entry in WalkDir::new(path) .sort_by(|a, b| a.cmp(b)) .into_iter() .filter_map(|e| e.ok()) .filter(|e| e.file_type().is_file()) { i...
code_fim
hard
{ "lang": "rust", "repo": "bruceadams/wdscli", "path": "/src/add.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bruceadams/wdscli path: /src/add.rs use clap; use crossbeam::sync::MsQueue; use hyper::status::StatusCode; use info::discovery_service_info; use select::{select_collection, writable_environment}; use serde_json::to_string; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use ...
code_fim
hard
{ "lang": "rust", "repo": "bruceadams/wdscli", "path": "/src/add.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut unexplained_error_count = 0; let doc_id = format!("{:011x}", context.doc_id.fetch_add(1, Ordering::Relaxed)); loop { match document::create( &context.creds, &context.env_id, &context.col_id, None, Some(&doc_id)...
code_fim
hard
{ "lang": "rust", "repo": "bruceadams/wdscli", "path": "/src/add.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = std::panic::catch_unwind(|| level2::trmv('l', 't', 'n', 6, &vec![0.0], 6, &mut vec![], 0)); assert!(result.is_err()); let result = std::panic::catch_unwind(|| level2::trmv('l', 't', 'n', 6, &vec![0.0], 5, &mut vec![], 1)); assert!(result.is_err()); } #[test] ...
code_fim
hard
{ "lang": "rust", "repo": "elaraproject/libblas", "path": "/tests/level2_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let result = std::panic::catch_unwind(|| { level2::syr2('l', 10, 1.0, &vec![], 1, &vec![], 1, &mut vec![], 6) }); assert!(result.is_err()); } #[test] fn tbmv() { let a = fixtures::M6X6UB(); let mut x = vec![ -0.08252376201716412, 0.6060734308621007, 0.0...
code_fim
hard
{ "lang": "rust", "repo": "elaraproject/libblas", "path": "/tests/level2_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elaraproject/libblas path: /tests/level2_test.rs 627, -2.2486927197608679, 1.1758816997533543, -1.5951304169961045, 0.86201992449819898, -1.7624980634300442, 0.50015198022593665, 0.15566204820567009, ...
code_fim
hard
{ "lang": "rust", "repo": "elaraproject/libblas", "path": "/tests/level2_test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Win32/System/AssessmentTool/mod.rs ::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IProvideWinSATVisuals_abi( pub unsafe extern "system" fn(this: ::windows::...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/AssessmentTool/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Win32/System/AssessmentTool/mod.rs Param::Borrowed(unsafe { ::core::mem::transmute(self) }) } } #[repr(C)] #[doc(hidden)] pub struct IProvideWinSATAssessmentInfo_abi( pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windo...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/AssessmentTool/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> value.0 } } impl ::core::convert::From<&IWinSATInitiateEvents> for ::windows::core::IUnknown { fn from(value: &IWinSATInitiateEvents) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IWinSATInitiateEvents { fn into_param(s...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/AssessmentTool/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oScape/finthnif path: /frontend/src/driver_selector.rs use std::fmt::{Display, Formatter, Result}; use yew::prelude::*; use yew_components::Select; #[derive(Clone, Debug, Properties, PartialEq)] pub struct Props { pub on_change: Callback<Driver>, } #[derive(PartialEq, Clone, Debug)] pub st...
code_fim
hard
{ "lang": "rust", "repo": "oScape/finthnif", "path": "/frontend/src/driver_selector.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn create(props: Self::Properties, _link: ComponentLink<Self>) -> Self { Self { props, _link } } fn update(&mut self, _msg: Self::Message) -> ShouldRender { false } fn change(&mut self, _props: Self::Properties) -> ShouldRender { false } fn view(&self...
code_fim
hard
{ "lang": "rust", "repo": "oScape/finthnif", "path": "/frontend/src/driver_selector.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for Driver { fn fmt(&self, f: &mut Formatter<'_>) -> Result { write!(f, "{}", self.firstname) } } pub struct DriverSelector { props: Props, _link: ComponentLink<Self>, } impl Component for DriverSelector { type Message = (); type Properties = Props; fn c...
code_fim
hard
{ "lang": "rust", "repo": "oScape/finthnif", "path": "/frontend/src/driver_selector.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> interface.write( " You find yourself upon the summit of a mountain towering over the landscape. The summit is thin strip of smooth obsidian several hundred yards long and a few feet tall.", ); match interface.choose(vec![Summit::Gaze, Summit::Descend]) { Summit::Gaze => { ...
code_fim
hard
{ "lang": "rust", "repo": "Mattachoo/text-adventurers", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> interface.write("Goodbye! Thanks for playing."); ExitMarker } fn main() { let mut interface = StandardIoInterface {}; let mut world = World::empty(); world .player .stats .mut_stat(stat::StatKind::Strength) .advance(1000); interface.write(world.play...
code_fim
hard
{ "lang": "rust", "repo": "Mattachoo/text-adventurers", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mattachoo/text-adventurers path: /src/main.rs mod accessible; mod character; mod choice; mod inventory; mod io; mod stat; mod story_graph; mod table; mod template; mod unit; mod world; use character::Character; use choice::ConstantChoice; use io::{Interface, StandardIoInterface}; use world::Wor...
code_fim
hard
{ "lang": "rust", "repo": "Mattachoo/text-adventurers", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> = parse(&rules, text); match data { Ok(data) => { assert_eq!(data.len(), 1); if let &MetaData::String(_, ref hello) = &data[0].1 { println!("{}", hello); } } Err((range, err)) => { // Report the error to standard ...
code_fim
medium
{ "lang": "rust", "repo": "emberian/meta", "path": "/examples/hello_world.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emberian/meta path: /examples/hello_world.rs extern crate piston_meta; use piston_meta::*; fn main() { let text = r#"say "Hello world!""#; let rules = r#"1 "rule" ["say" w! t?"foo"]"#; // Parse rules with meta language and conv<|fim_suffix|>", hello); } } ...
code_fim
hard
{ "lang": "rust", "repo": "emberian/meta", "path": "/examples/hello_world.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hgfkeep/rust-tutorial path: /network/parse_str/src/main.rs #[macro_use] extern crate nom; use std::str; use nom::{IResult}; use nom::error::ErrorKind; /// Http 方法类型 #[derive(Debug)] enum Method{ GET, POST } /// /// 抽象表示 HTTP 协议请求, /// 待解析的 HTTP 协议,例如:GET /home/ HTTP/1.1 #[derive(Debug)...
code_fim
hard
{ "lang": "rust", "repo": "hgfkeep/rust-tutorial", "path": "/network/parse_str/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match parse_request(input.as_bytes()){ IResult::Ok(ok) => println!("value: {:?}", ok ), IResult::Err(err) => eprintln!("{:?}", err), } } fn main(){ let get = "GET /home/ HTTP/1.1\r\n"; run_parser(get); let post = "POST /update/ HTTP/1.1\r\n"; run_parser(post); ...
code_fim
hard
{ "lang": "rust", "repo": "hgfkeep/rust-tutorial", "path": "/network/parse_str/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evik42/codingame path: /training/medium/there-is-no-spoon-episode-1.rs use std::io; use std::collections::HashMap; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } #[derive(Copy,Clone)] struct Node { coords: (i32, i32), right: (i32, i32), } ...
code_fim
hard
{ "lang": "rust", "repo": "evik42/codingame", "path": "/training/medium/there-is-no-spoon-episode-1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (cx, cy) = n.coords; let (rx, ry) = n.right; let (bx, by) = bot; // Three coordinates: a node, its right neighbor, its bottom neighbor println!("{} {} {} {} {} {}", cx, cy, rx, ry, bx, by); } }<|fim_prefix|>// repo: evik42/codingame path: /training/medium/t...
code_fim
hard
{ "lang": "rust", "repo": "evik42/codingame", "path": "/training/medium/there-is-no-spoon-episode-1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Trait> Verifier for Module<T> { // verify a message fn verify(app_id: AppID, message: Message) -> DispatchResult { Self::schedule_approval(app_id, message)?; Ok(()) } }<|fim_prefix|>// repo: rohanabraham/polkadot-ethereum path: /parachain/pallets/dummy-verifier/src/lib.rs #![allow(unus...
code_fim
hard
{ "lang": "rust", "repo": "rohanabraham/polkadot-ethereum", "path": "/parachain/pallets/dummy-verifier/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> } } impl<T: Trait> Module<T> { // No-op verifier that sends verified message back to broker. fn schedule_approval(app_id: AppID, message: Message) -> DispatchResult { //let delay: <T as system::Trait>::BlockNumber = 1.into(); let delay: u32 = 1; if T::Scheduler::schedule( <system::Module...
code_fim
hard
{ "lang": "rust", "repo": "rohanabraham/polkadot-ethereum", "path": "/parachain/pallets/dummy-verifier/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rohanabraham/polkadot-ethereum path: /parachain/pallets/dummy-verifier/src/lib.rs #![allow(unused_variables)] #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{decl_module, decl_storage, decl_event, decl_error, dispatch::{DispatchResult, Dispatchable}}; use frame_support::{Paramet...
code_fim
hard
{ "lang": "rust", "repo": "rohanabraham/polkadot-ethereum", "path": "/parachain/pallets/dummy-verifier/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let args: Vec<String> = env::args().collect(); let config_file = &args[1]; let mut cats = build_from_json(config_file); cats.sort_by(|a, b| b.name.cmp(&a.name)); for cat in cats { println!("TRACER {:?}", cat); } println!("TRACER Ready."); }<|fim_prefix|>// repo: code...
code_fim
hard
{ "lang": "rust", "repo": "codetojoy/talk_peidevs_rust", "path": "/src/rust/cats_2_json/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut cats = build_from_json(config_file); cats.sort_by(|a, b| b.name.cmp(&a.name)); for cat in cats { println!("TRACER {:?}", cat); } println!("TRACER Ready."); }<|fim_prefix|>// repo: codetojoy/talk_peidevs_rust path: /src/rust/cats_2_json/src/main.rs use serde_json; us...
code_fim
hard
{ "lang": "rust", "repo": "codetojoy/talk_peidevs_rust", "path": "/src/rust/cats_2_json/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: codetojoy/talk_peidevs_rust path: /src/rust/cats_2_json/src/main.rs use serde_json; use serde::{Deserialize, Serialize}; use std::fs; use std::env; use std::vec::Vec; #[derive(Debug, Serialize, Deserialize)] pub struct Cat { pub name: String, pub age: u8, } pub fn build_from_json(con...
code_fim
medium
{ "lang": "rust", "repo": "codetojoy/talk_peidevs_rust", "path": "/src/rust/cats_2_json/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Benchmark { pub fn new() -> Self { let world = World::default(); world.run( |mut entities: EntitiesViewMut, mut transforms: ViewMut<Transform>, mut positions: ViewMut<Position>, mut rotations: ViewMut<Rotation>, mut ...
code_fim
hard
{ "lang": "rust", "repo": "cart/ecs_bench_suite", "path": "/src/shipyard/simple_iter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cart/ecs_bench_suite path: /src/shipyard/simple_iter.rs use cgmath::*; use shipyard::*; #[derive(Copy, Clone)] struct Transform(Matrix4<f32>); #[derive(Copy, Clone)] struct Position(Vector3<f32>); #[derive(Copy, Clone)] struct Rotation(Vector3<f32>); #[derive(Copy, Clone)] struct Velocity(Ve...
code_fim
hard
{ "lang": "rust", "repo": "cart/ecs_bench_suite", "path": "/src/shipyard/simple_iter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run(&mut self) { self.0.run( |velocities: View<Velocity>, mut positions: ViewMut<Position>| { (&velocities, &mut positions) .iter() .for_each(|(velocity, position)| { position.0 += velocity.0; ...
code_fim
hard
{ "lang": "rust", "repo": "cart/ecs_bench_suite", "path": "/src/shipyard/simple_iter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: but0n/riscv-rust path: /src/clint.rs pub struct Clint { clock: u64, msip: u32, mtimecmp: u64, mtime: u64 } impl Clint { pub fn new() -> Self { Clint { clock: 0, msip: 0, mtimecmp: 0, mtime: 0 } } pub fn tick(&mut self) { self.clock = self.clock.wrapping_add(1); if se...
code_fim
hard
{ "lang": "rust", "repo": "but0n/riscv-rust", "path": "/src/clint.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>s 0x0200bff8 => { self.mtime = (self.mtime & !0xff) | (value as u64); }, 0x0200bff9 => { self.mtime = (self.mtime & !(0xff << 8)) | ((value as u64) << 8); }, 0x0200bffa => { self.mtime = (self.mtime & !(0xff << 16)) | ((value as u64) << 16); }, 0x0200bffb => { self.mti...
code_fim
hard
{ "lang": "rust", "repo": "but0n/riscv-rust", "path": "/src/clint.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lehnart/rust-games path: /asteroids/src/graphics.rs use sdl2::pixels::Color; use sdl2::rect::{Point}; use sdl2::render::WindowCanvas; use sdl2::ttf::Sdl2TtfContext; use engine::geometry::AsRect; use engine::graphics::{RectSprite, Sprite, Window}; use crate::logic; use crate::logic::Logic; use ...
code_fim
hard
{ "lang": "rust", "repo": "Lehnart/rust-games", "path": "/asteroids/src/graphics.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Update the dynamic elements accordingly to the state of the game. pub fn update(&mut self, logic: &Logic, window: &Window, _ttf_context: &Sdl2TtfContext) { let w = window.width(); let h = window.height(); self.spaceship.update(&logic.spaceship, w, h); let ids =...
code_fim
hard
{ "lang": "rust", "repo": "Lehnart/rust-games", "path": "/asteroids/src/graphics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> : ? } " ) ; assert_eq ! ( thought_to_be_continue xid_continue_fst . contains ( ( ch as u32 ) . to_be_bytes ( ) ) " { ch : ? } " ) ; / / roaring assert_eq ! ( thought_to_be_start xid_start_roaring . contains ( ch as u32 ) " { ch : ? } " ) ; assert_eq ! ( thought_to_be_continue xid_continue_roaring . conta...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/unicode-ident/tests/compare.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/unicode-ident/tests/compare.rs mod fst ; mod roaring ; mod trie ; # [ test ] fn compare_all_implementations ( ) { let xid_start_fst = fst : : xid_start_fst ( ) ; let xid_continue_fst = fst : : xid_continue_fst ( ) ; let xid_start_roaring = roar...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/unicode-ident/tests/compare.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>( ch ) " { ch : ? } " ) ; / / ucd - trie assert_eq ! ( thought_to_be_start trie : : XID_START . contains_char ( ch ) " { ch : ? } " ) ; assert_eq ! ( thought_to_be_continue trie : : XID_CONTINUE . contains_char ( ch ) " { ch : ? } " ) ; / / fst assert_eq ! ( thought_to_be_start xid_start_fst . contains ( ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/unicode-ident/tests/compare.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LightAndLight/spiddy path: /pretty/src/lib.rs use ast::de_bruijn; use ast::syntax; pub fn pretty_syntax<'src, 'expr>(expr: syntax::ExprRef<'src, 'expr>) -> String { match expr { syntax::Expr::Ident(ident) => String::from(*ident), syntax::Expr::App(l, r) => { let ...
code_fim
hard
{ "lang": "rust", "repo": "LightAndLight/spiddy", "path": "/pretty/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn pretty_de_bruijn<'expr>(expr: de_bruijn::ExprRef<'expr>) -> String { match expr { de_bruijn::Expr::Var(ix) => format!("#{}", ix), de_bruijn::Expr::U64(n) => format!("{}", n), de_bruijn::Expr::App(l, r) => { let parens_l = match &*l { de_bruijn...
code_fim
hard
{ "lang": "rust", "repo": "LightAndLight/spiddy", "path": "/pretty/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> string += " + "; if parens_r { string.push('('); } string += &pretty_de_bruijn(*r); if parens_r { string.push(')'); } string } de_bruijn::Expr::Lam(body) => { l...
code_fim
hard
{ "lang": "rust", "repo": "LightAndLight/spiddy", "path": "/pretty/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } (Some(names), None) => Err(Error::TypeExpectedGenerics { location, r#type: self.identifier.to_owned(), expected: names.len(), }), (None, Some(_types)) => Err(Error::TypeUnexpectedGeneri...
code_fim
hard
{ "lang": "rust", "repo": "prz23/zinc", "path": "/zinc-compiler/src/semantic/element/type/structure/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prz23/zinc path: /zinc-compiler/src/semantic/element/type/structure/mod.rs //! //! The semantic analyzer structure type element. //! #[cfg(test)] mod tests; use std::cell::RefCell; use std::collections::HashMap; use std::fmt; use std::rc::Rc; use zinc_lexical::Location; use crate::semantic::...
code_fim
hard
{ "lang": "rust", "repo": "prz23/zinc", "path": "/zinc-compiler/src/semantic/element/type/structure/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrigocfd/winsafe path: /src/gui/dlg_base.rs use crate::co; use crate::decl::*; use crate::gui::{events::*, privs::*}; use crate::msg::*; use crate::prelude::*; /// Base to all dialog windows. /// /// Owns the window procedure for all dialog windows. pub(in crate::gui) struct DlgBase ...
code_fim
hard
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/gui/dlg_base.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(in crate::gui) fn spawn_new_thread<F>(&self, func: F) where F: FnOnce() -> AnyResult<()> + Send + 'static, { self.base.spawn_new_thread(func); } pub(in crate::gui) fn run_ui_thread<F>(&self, func: F) where F: FnOnce() -> AnyResult<()> + Send + 'static { self.base.run_ui_thread(f...
code_fim
hard
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/gui/dlg_base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(in crate::gui) fn on(&self) -> &WindowEventsAll { self.base.on() } pub(in crate::gui) fn privileged_on(&self) -> &WindowEventsAll { self.base.privileged_on() } pub(in crate::gui) fn parent(&self) -> Option<&Base> { self.base.parent() } pub(in crate::gui) fn create_dialog_pa...
code_fim
hard
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/gui/dlg_base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl AppConfig { pub fn load_file(file: PathBuf) -> Result<Self> { let f = std::fs::File::open(file)?; Ok(serde_yaml::from_reader(f)?) } pub fn get_actions(&self, actions: &[String]) -> Result<Vec<Action>> { let mut res = vec![]; for action in actions.iter() { ...
code_fim
hard
{ "lang": "rust", "repo": "proctorlabs/ecli", "path": "/src/config/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: proctorlabs/ecli path: /src/config/mod.rs mod actions; mod menus; mod misc; mod styles; use crate::*; pub use actions::*; pub use menus::*; pub use misc::*; use serde::{Deserialize, Serialize}; use serde_yaml; use std::{collections::BTreeMap, fmt, path::PathBuf}; pub use styles::*; pub use term...
code_fim
hard
{ "lang": "rust", "repo": "proctorlabs/ecli", "path": "/src/config/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut menus = BTreeMap::new(); menus.insert( "main".into(), Menu::Choice(ChoiceMenu { title: "Default Menu".into(), entries: vec![Entry { text: "Exit".into(), actions: OneOrMany::One("exit".in...
code_fim
hard
{ "lang": "rust", "repo": "proctorlabs/ecli", "path": "/src/config/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Here, we need to configure Songbird to decode all incoming voice packets. // If you want, you can do this on a per-call basis---here, we need it to // read the audio data that other people are sending us! let songbird_config = Config::default() .decode_mode(DecodeMode::Decode); ...
code_fim
hard
{ "lang": "rust", "repo": "peppizza/songbird-yt-dlp", "path": "/examples/serenity/voice_receive/src/main.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> handler.add_global_event( CoreEvent::VoicePacket.into(), Receiver::new(), ); handler.add_global_event( CoreEvent::RtcpPacket.into(), Receiver::new(), ); handler.add_global_event( CoreEvent::ClientConnect....
code_fim
hard
{ "lang": "rust", "repo": "peppizza/songbird-yt-dlp", "path": "/examples/serenity/voice_receive/src/main.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peppizza/songbird-yt-dlp path: /examples/serenity/voice_receive/src/main.rs //! Requires the "client", "standard_framework", and "voice" features be enabled //! in your Cargo.toml, like so: //! //! ```toml //! [dependencies.serenity] //! git = "https://github.com/serenity-rs/serenity.git" //! fe...
code_fim
hard
{ "lang": "rust", "repo": "peppizza/songbird-yt-dlp", "path": "/examples/serenity/voice_receive/src/main.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ronanM/makair-control-ui path: /src/config/environment.rs // MakAir // // Copyright: 2020, Makers For Life // License: Public Domain License pub const RUNTIME_VERSION: &str = env!("CARGO_PKG_VERSION"); pub const WINDOW_ICON_WIDTH: u32 = 512; pub const WINDOW_ICON_HEIGHT: u32 = 512; pub const ...
code_fim
hard
{ "lang": "rust", "repo": "ronanM/makair-control-ui", "path": "/src/config/environment.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>pub const EXP_RATIO_SETTINGS_MODAL_WIDTH: f64 = 600.0; pub const EXP_RATIO_SETTINGS_MODAL_HEIGTH: f64 = 150.0; pub const MODAL_VALIDATE_BUTTON_HEIGHT: f64 = 30.0; pub const LAYOUT_HEADER_SIZE_FULL_HEIGHT: f64 = DISPLAY_WINDOW_SIZE_HEIGHT as f64 - LAYOUT_FOOTER_SIZE_HEIGHT; // So the alarms can overf...
code_fim
hard
{ "lang": "rust", "repo": "ronanM/makair-control-ui", "path": "/src/config/environment.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> AtomicScatteringFactor { energy: 0.232_147_f64, f1: Some(5.899_f64), f2: Some(1.682_1_f64) }, AtomicScatteringFactor { energy: 0.235_902_f64, f1: Some(5.719_85_f64), f2: Some(1.662_24_f64) }, AtomicScatteringFactor { energy: 0.239_717_f64, f1: Some(5.519_65_f64...
code_fim
hard
{ "lang": "rust", "repo": "DomiDre/periodictable", "path": "/src/elements/K.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>cScatteringFactor { energy: 0.088_648_7_f64, f1: Some(7.263_85_f64), f2: Some(1.990_38_f64) }, AtomicScatteringFactor { energy: 0.090_082_5_f64, f1: Some(7.288_35_f64), f2: Some(2.028_87_f64) }, AtomicScatteringFactor { energy: 0.091_539_5_f64, f1: Some(7.326_47_f64), f2: S...
code_fim
hard
{ "lang": "rust", "repo": "DomiDre/periodictable", "path": "/src/elements/K.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DomiDre/periodictable path: /src/elements/K.rs f2: Some(11.454_9_f64) }, AtomicScatteringFactor { energy: 0.455_435_f64, f1: Some(14.645_f64), f2: Some(11.271_7_f64) }, AtomicScatteringFactor { energy: 0.462_802_f64, f1: Some(14.921_1_f64), f2: Some(11.047_9_f64)...
code_fim
hard
{ "lang": "rust", "repo": "DomiDre/periodictable", "path": "/src/elements/K.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let query = Select::from_table((schema_name, table_name)).value(count(asterisk())); let result_set = conn.query(query.into()).await?; let rows_count = result_set .first() .ok_or_else(|| { SqlError::Generic(anyhow::anyhow!( "No row was returned when c...
code_fim
hard
{ "lang": "rust", "repo": "IanMitchell/prisma-engines", "path": "/migration-engine/connectors/sql-migration-connector/src/sql_destructive_change_checker/destructive_check_plan.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IanMitchell/prisma-engines path: /migration-engine/connectors/sql-migration-connector/src/sql_destructive_change_checker/destructive_check_plan.rs use super::{ check::Check, database_inspection_results::DatabaseInspectionResults, unexecutable_step_check::UnexecutableStepCheck, warning_ch...
code_fim
hard
{ "lang": "rust", "repo": "IanMitchell/prisma-engines", "path": "/migration-engine/connectors/sql-migration-connector/src/sql_destructive_change_checker/destructive_check_plan.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steamroller-airmash/serde-deserialize-over path: /serde-deserialize-over/examples/basic.rs use serde_deserialize_over::DeserializeOver; #[derive(Default, DeserializeOver, Debug)] struct ExampleStruct { pub a: String, pub b: i32, } const JSON: &str = r#"{ "a": "test" }"#; fn main() { <|fim...
code_fim
medium
{ "lang": "rust", "repo": "steamroller-airmash/serde-deserialize-over", "path": "/serde-deserialize-over/examples/basic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> instance .deserialize_over(&mut de) .expect("Failed to deserialize"); println!("{:#?}", instance); }<|fim_prefix|>// repo: steamroller-airmash/serde-deserialize-over path: /serde-deserialize-over/examples/basic.rs use serde_deserialize_over::DeserializeOver; #[derive(Default, DeserializeOve...
code_fim
medium
{ "lang": "rust", "repo": "steamroller-airmash/serde-deserialize-over", "path": "/serde-deserialize-over/examples/basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut instance = ExampleStruct { a: "a string".to_owned(), b: 64, }; let mut de = serde_json::Deserializer::new(serde_json::de::StrRead::new(JSON)); instance .deserialize_over(&mut de) .expect("Failed to deserialize"); println!("{:#?}", instance); }<|fim_prefix|>// repo: stea...
code_fim
easy
{ "lang": "rust", "repo": "steamroller-airmash/serde-deserialize-over", "path": "/serde-deserialize-over/examples/basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return result; } fn main() { let result = dec_to_roman(1001); println!("Hello, world!, {}", result); } #[test] fn known_roman_numerals() { let decimals: Vec<u32> = vec![39, 246, 789, 2421, 160, 207, 1009, 1066, 1954, 2014, 900]; let expected = vec![ "XXXIX", "CCXLVI",...
code_fim
hard
{ "lang": "rust", "repo": "icyJoseph/code-wars", "path": "/roman-numerals-encoder/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: icyJoseph/code-wars path: /roman-numerals-encoder/src/main.rs use std::convert::TryFrom; fn dec_to_roman(num: u32) -> String { if num >= 4000 { panic!("Roman Numerals higher than 3999 are not covered here"); } let bases = vec![1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5,...
code_fim
hard
{ "lang": "rust", "repo": "icyJoseph/code-wars", "path": "/roman-numerals-encoder/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn known_roman_numerals() { let decimals: Vec<u32> = vec![39, 246, 789, 2421, 160, 207, 1009, 1066, 1954, 2014, 900]; let expected = vec![ "XXXIX", "CCXLVI", "DCCLXXXIX", "MMCDXXI", "CLX", "CCVII", "MIX", "MLXVI", "MCM...
code_fim
hard
{ "lang": "rust", "repo": "icyJoseph/code-wars", "path": "/roman-numerals-encoder/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Triple (self, self, self) } } fn main() { // doesn't work as I'd thought // raises error // error[E0107]: this associated function takes 0 type arguments but 1 type argument was supplied let single = 5.into::<Single>(); println!("single is {}", single); }<|fim_prefix|>// ...
code_fim
medium
{ "lang": "rust", "repo": "mfonism/__rust-by-example__", "path": "/05-Conversion/ff-turbofish.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mfonism/__rust-by-example__ path: /05-Conversion/ff-turbofish.rs use std::convert::Into; #[derive(Debug)] struct Single (isize); #[derive(Debug)] struct Double (isize, isize); #[derive(Debug)] struct Triple (isize, isize, isize); impl Into<Single> for isize { fn into(self) -> Single { ...
code_fim
medium
{ "lang": "rust", "repo": "mfonism/__rust-by-example__", "path": "/05-Conversion/ff-turbofish.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>::subscription_tiers::subscription_tiers; pub use self::users::users;<|fim_prefix|>// repo: redirectdog/dalmatian path: /src/routes/mod.rs mod logins; mod redirects; mod settings; mod subscription_tiers; mod <|fim_middle|>users; pub use self::logins::logins; pub use self::redirects::redirects_path as re...
code_fim
medium
{ "lang": "rust", "repo": "redirectdog/dalmatian", "path": "/src/routes/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redirectdog/dalmatian path: /src/routes/mod.rs mod logins; mod redirects; mod settings; mod subscription_tiers; mod users; pub use self::logins::logins; pub use self::redirects::redire<|fim_suffix|>::subscription_tiers::subscription_tiers; pub use self::users::users;<|fim_middle|>cts_path as re...
code_fim
medium
{ "lang": "rust", "repo": "redirectdog/dalmatian", "path": "/src/routes/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn additional_fuel(mass: f64) -> f64 { let mut fuel = mass; let mut inc = fuel; while inc > 0.0 { inc = fuel_required(inc); fuel += inc; } return fuel; }<|fim_prefix|>// repo: therocode/oxidised path: /hexagon/task1/src/main.rs use std::{ fs::File, io::{prelude...
code_fim
hard
{ "lang": "rust", "repo": "therocode/oxidised", "path": "/hexagon/task1/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: therocode/oxidised path: /hexagon/task1/src/main.rs use std::{ fs::File, io::{prelude::*, BufReader}, error }; fn main() -> Result<(), Box<dyn error::Error>> { let file = File::open("modules.txt")?; let reader = BufReader::new(file); let (fuel, total_fuel) = { l...
code_fim
medium
{ "lang": "rust", "repo": "therocode/oxidised", "path": "/hexagon/task1/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zoosky/rust-trending path: /src/lib.rs extern crate failure; #[macro_use] extern crate serde_derive; extern crate chrono; #[macro_use] extern crate futures; extern crate hyper; extern crate hyper_tls; extern crate oauth_client; extern crate serde_json; extern crate tokio; extern crate twitter_ap...
code_fim
hard
{ "lang": "rust", "repo": "zoosky/rust-trending", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }