text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>#[inline(always)] pub fn breakpoint() { BREAKpin.write(1); }<|fim_prefix|>// repo: zdimension/parm_extended path: /code_rs/test/src/parm/control.rs use crate::parm::mmio::{BREAKpin, RESETpin}; use core::hint::unreachable_unchecked; <|fim_middle|>#[inline(always)] pub fn reset() -> ! { RESETpin.w...
code_fim
medium
{ "lang": "rust", "repo": "zdimension/parm_extended", "path": "/code_rs/test/src/parm/control.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(parse_helper("2 ** 3"), Ok(Value::unitless(8.0)),); assert_eq!( parse_helper("($2) ** 3"), Ok(Value::new(8.0, units!("$" to 3))), ); assert_eq!( parse_helper("($1 + $1) ** (1 + 4 - 2)"), Ok(Value::new(8.0, units!("...
code_fim
hard
{ "lang": "rust", "repo": "gabipurcaru/dedo-rust", "path": "/lang/src/test_parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( parse_helper("123 usd - 12 usd"), Ok(Value::simple(111.0, "usd")), ); assert_eq!( parse_helper("-123 usd - 12 usd * 14"), Ok(Value::simple(-291.0, "usd")), ); assert_eq!(parse_helper("2 * 3 + 4"), Ok(Valu...
code_fim
medium
{ "lang": "rust", "repo": "gabipurcaru/dedo-rust", "path": "/lang/src/test_parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gabipurcaru/dedo-rust path: /lang/src/test_parser.rs #[cfg(test)] mod tests { use super::super::defaults::ENVIRONMENT; use super::super::parser::{parse, parse_single}; use super::super::types::{Unit, UnitSet, Value}; use pretty_assertions::assert_eq; use wasm_bindgen_test::*;...
code_fim
hard
{ "lang": "rust", "repo": "gabipurcaru/dedo-rust", "path": "/lang/src/test_parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: schungx/rhai path: /src/bin/rhai-dbg.rs Pretty-print source line. fn print_source(lines: &[String], pos: Position, offset: usize, window: (usize, usize)) { if pos.is_none() { // No position println!(); return; } let line = pos.line().unwrap() - 1; let st...
code_fim
hard
{ "lang": "rust", "repo": "schungx/rhai", "path": "/src/bin/rhai-dbg.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if range.contains(&n) { let bp = rhai::debugger::BreakPoint::AtPosition { source: source.map(|s| s.into()), pos: Position::new(n as u16, 0), enabled: true, ...
code_fim
hard
{ "lang": "rust", "repo": "schungx/rhai", "path": "/src/bin/rhai-dbg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> input.clear(); match stdin().read_line(&mut input) { Ok(0) => break Ok(DebuggerCommand::Continue), Ok(_) => match input.split_whitespace().collect::<Vec<_>>().as_slice() { ["help" | "h"] => print_debug_help(), ["exit" | "quit" | "q" ...
code_fim
hard
{ "lang": "rust", "repo": "schungx/rhai", "path": "/src/bin/rhai-dbg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AustinHaugerud/oxidsys path: /src/language/operations/scene_resources/prop_instance_add_particle_system.rs use language::operations::{make_param_doc, Operation, ParamInfo}; pub struct PropInstanceAddParticleSystemOp; const DOC : &str = "Version 1.153+. Adds a new particle system to the scene p...
code_fim
hard
{ "lang": "rust", "repo": "AustinHaugerud/oxidsys", "path": "/src/language/operations/scene_resources/prop_instance_add_particle_system.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: furuhama/atcoder path: /abc171/src/bin/d.rs #[allow(unused_imports)] use proconio::{ fastout, input, marker::{Bytes, Chars, Isize1, Usize1}, }; #[allow(unused_macros)] macro_rules! echo { ($($e:expr),+) => ( { $(println!("{}", $e))+ } ); } fn main() { input! { n: usize,...
code_fim
medium
{ "lang": "rust", "repo": "furuhama/atcoder", "path": "/abc171/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut kv = std::collections::HashMap::new(); let mut sum = 0; for e in a { *kv.entry(e).or_insert(0) += 1; } for (&k, &v) in kv.iter() { sum += k * v; // initialized sum } for (b, c) in bc { if let Some(count) = kv.remove(&b) { *kv.entry...
code_fim
medium
{ "lang": "rust", "repo": "furuhama/atcoder", "path": "/abc171/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (b, c) in bc { if let Some(count) = kv.remove(&b) { *kv.entry(c).or_insert(0) += count; if c >= b { sum += (c - b) * count; } else { sum -= (b - c) * count; } } echo!(sum); } }<|fim_prefix|...
code_fim
medium
{ "lang": "rust", "repo": "furuhama/atcoder", "path": "/abc171/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let config = LogConfig::builder() .appender(Appender::builder().build("requests", Box::new(requests))) .logger(Logger::builder().build("app::backend::db", LevelFilter::Info)) .logger( Logger::builder() .appender("requests") .additive(...
code_fim
hard
{ "lang": "rust", "repo": "atareao/wbcli", "path": "/src/logger.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atareao/wbcli path: /src/logger.rs use log::{error, info, warn, LevelFilter}; use log4rs::append::console::ConsoleAppender; use log4rs::append::file::FileAppender; use log4rs::config::{Appender, Config as LogConfig, Logger, Root}; use log4rs::encode::pattern::PatternEncoder; use log4rs::Handle; ...
code_fim
hard
{ "lang": "rust", "repo": "atareao/wbcli", "path": "/src/logger.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let toplevels = match parse::parse(tokens.into_iter()) { Ok(toplevels) => toplevels, Err(()) => { process::exit(1); }, }; if args.dump_syntax_tree { for toplevel in &toplevels { println!("{:?}", toplevel); } } }<|fim_prefix|>/...
code_fim
hard
{ "lang": "rust", "repo": "czipperz/shirk", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: czipperz/shirk path: /src/main.rs mod arguments; mod diagnostics; mod file_position; mod lex; mod parse; use std::env; use std::process; use std::fs; use std::path::Path; use std::io::Read; use std::rc::Rc; <|fim_suffix|> let toplevels = match parse::parse(tokens.into_iter()) { Ok(t...
code_fim
hard
{ "lang": "rust", "repo": "czipperz/shirk", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (tokens, success) = lex::lex(lex::FileIterator { bytes: file.bytes(), fpos: file_position::FilePosition { filename: Rc::new(args.filename), line: 1, column: 0, }, }); if args.dump_tokens { ...
code_fim
hard
{ "lang": "rust", "repo": "czipperz/shirk", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phodina/rustify path: /src/core.rs #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] extern crate clap; use std::ffi::CString; use std::io::Error; use std::os::raw::c_char; mod lib { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); } fn hello () ...
code_fim
hard
{ "lang": "rust", "repo": "phodina/rustify", "path": "/src/core.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; #[test] fn multiply_compute () { let m; unsafe { m = multiply(2,3); } assert_eq!(6, m); } }<|fim_prefix|>// repo: phodina/rustify path: /src/core.rs #![allow(non_upper_case_globals)] #![allow(non_cam...
code_fim
hard
{ "lang": "rust", "repo": "phodina/rustify", "path": "/src/core.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Scanner { stdin: io::stdin(), buf: Vec::with_capacity(256), } } fn parse<T: FromStr>(&mut self) -> T where <T as FromStr>::Err: Debug { self.buf.clear(); let mut it = self.stdin.lock().bytes(); let mut c = it.next().unwra...
code_fim
hard
{ "lang": "rust", "repo": "kenkoooo/programming-contest-solutions", "path": "/rust/src/bin/arc080_b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kenkoooo/programming-contest-solutions path: /rust/src/bin/arc080_b.rs use std::io; use std::io::{Read, Stdin}; use std::str; use std::str::FromStr; use std::usize; use std::fmt::Debug; fn main() { let mut sc = Scanner::new(); let h = sc.parse::<usize>(); let w = sc.parse::<usize>()...
code_fim
hard
{ "lang": "rust", "repo": "kenkoooo/programming-contest-solutions", "path": "/rust/src/bin/arc080_b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>acters: Vec<char>) -> Self { SubstitutionTable { characters: characters } } }<|fim_prefix|>// repo: atsushi130/EnigmaMachine path: /src/enigma_machine/substitution_table.rs pub struct SubstitutionTable { pub characters: Ve<|fim_middle|>c<char> } impl SubstitutionTabl...
code_fim
easy
{ "lang": "rust", "repo": "atsushi130/EnigmaMachine", "path": "/src/enigma_machine/substitution_table.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atsushi130/EnigmaMachine path: /src/enigma_machine/substitution_table.rs pub struct SubstitutionTable { pub characters: Vec<char> } impl SubstitutionTable { pub fn new(char<|fim_suffix|> { characters: characters } } }<|fim_middle|>acters: Vec<char>) -> Self { ...
code_fim
easy
{ "lang": "rust", "repo": "atsushi130/EnigmaMachine", "path": "/src/enigma_machine/substitution_table.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> core.run(runner).expect("Error on core"); } /// Asks the user a question and reads from stdin, returning the resultant /// String buffer. /// /// # Examples /// /// Ask the user "What colour is the sky?" and print the result: /// /// ```rust,no_run /// println!("{}", ask("what colour is the sky?")); ...
code_fim
hard
{ "lang": "rust", "repo": "whats-this/owo.rs", "path": "/examples/01_hyper/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whats-this/owo.rs path: /examples/01_hyper/src/main.rs //! A sample application asking the user for an input URL to shorten. //! //! This makes use of a tokio reactor Core. Typically you would maintain a //! single core for multiple concurrent events, but due to the oneshot nature of //! this ex...
code_fim
hard
{ "lang": "rust", "repo": "whats-this/owo.rs", "path": "/examples/01_hyper/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spencerdento/micro-message-r-drafts path: /src/check_mail.rs use std::{fs, net::TcpStream}; use anyhow::Error; use imap::Session; use native_tls::{TlsConnector, TlsStream}; pub fn email_login(domain: &str, username: &str, password: &str) -> anyhow::Result<Session<TlsStream<TcpStream>>> { le...
code_fim
medium
{ "lang": "rust", "repo": "spencerdento/micro-message-r-drafts", "path": "/src/check_mail.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for mail in my_fetch.iter() { match mail.body() { Some(body) => { fs::write("email.txt", body)?; }, None => { return Err(Error::msg("Message was unreadable.")); } }; } Ok("email.txt") }<|fi...
code_fim
medium
{ "lang": "rust", "repo": "spencerdento/micro-message-r-drafts", "path": "/src/check_mail.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaitai-io/kaitai_struct_tests path: /spec/rust/tests/test_expr_1.rs // Autogenerated from KST: please remove this line if doing any edits by hand! <|fim_suffix|> if let Ok(r) = Expr1::from_file("src/str_encodings.bin") { assert_eq!(r.len_of_1, 10); assert_eq!(r.len_of_1_mod, ...
code_fim
medium
{ "lang": "rust", "repo": "kaitai-io/kaitai_struct_tests", "path": "/spec/rust/tests/test_expr_1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_expr_1() { if let Ok(r) = Expr1::from_file("src/str_encodings.bin") { assert_eq!(r.len_of_1, 10); assert_eq!(r.len_of_1_mod, 8); assert_eq!(r.str1, "Some ASC"); assert_eq!(r.str1_len, 8); } }<|fim_prefix|>// repo: kaitai-io/kaitai_struct_tests path:...
code_fim
medium
{ "lang": "rust", "repo": "kaitai-io/kaitai_struct_tests", "path": "/spec/rust/tests/test_expr_1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pe SubCommandType = (NameType, AboutType, &'static [OptionType], &'static [AppSettings]);<|fim_prefix|>// repo: Tiamat-Tech/wagyu path: /wagyu/cli/parameters/types.rs use clap::AppSettings; pub type NameType = &'static str; pub type AboutType = &'static <|fim_middle|>str; pub type FlagType = &'static st...
code_fim
medium
{ "lang": "rust", "repo": "Tiamat-Tech/wagyu", "path": "/wagyu/cli/parameters/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tiamat-Tech/wagyu path: /wagyu/cli/parameters/types.rs use clap::AppSettings; pub type NameType = &'static str; pub type AboutType = &'static <|fim_suffix|>atic [&'static str], &'static [&'static str], &'static [&'static str], ); pub type SubCommandType = (NameType, AboutType, &'static ...
code_fim
medium
{ "lang": "rust", "repo": "Tiamat-Tech/wagyu", "path": "/wagyu/cli/parameters/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(MallocSizeOf, Default)] struct Trivia { hm: std::collections::HashMap<u64, Vec<u8>>, #[ignore_malloc_size_of = "I don't like vectors"] v: Vec<u8>, } let mut t = Trivia::default(); t.hm.insert(1, vec![0u8; 2048]); t.v = vec![0u8; 1024]; assert!(t.malloc_size_of() < 3000); } #[test]...
code_fim
hard
{ "lang": "rust", "repo": "KomodoPlatform/parity-common", "path": "/parity-util-mem/tests/derive.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KomodoPlatform/parity-common path: /parity-util-mem/tests/derive.rs // Copyright 2020 Parity Technologies // // 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/MI...
code_fim
hard
{ "lang": "rust", "repo": "KomodoPlatform/parity-common", "path": "/parity-util-mem/tests/derive.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> t.hm.insert(1, vec![0u8; 2048]); assert!(t.malloc_size_of() > 2000); } #[test] fn derive_ignore() { #[derive(MallocSizeOf, Default)] struct Trivia { hm: std::collections::HashMap<u64, Vec<u8>>, #[ignore_malloc_size_of = "I don't like vectors"] v: Vec<u8>, } let mut t = Trivia::default(); ...
code_fim
hard
{ "lang": "rust", "repo": "KomodoPlatform/parity-common", "path": "/parity-util-mem/tests/derive.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut space = vec![MaybeUninit::new(0); 1]; let once_alloc = OnceAlloc { space: Cell::new(&mut space[..]) }; let boxed = Box::new_in([42u8; 1], &once_alloc); let _val = *boxed; let with_dyn: Box<dyn TheTrait, &OnceAlloc> = boxed; assert_eq!(42, with_dyn.hello()); let with_dy...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/pass/box-custom-alloc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let boxed = Box::new_in([42u8; 1], &once_alloc); let _val = *boxed; let with_dyn: Box<dyn TheTrait, &OnceAlloc> = boxed; assert_eq!(42, with_dyn.hello()); let with_dyn: Box<dyn MyTrait, &OnceAlloc> = with_dyn; // upcast assert_eq!(42, with_dyn.hello()); } // Make the allocator its...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/pass/box-custom-alloc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/box-custom-alloc.rs //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![allow(incomplete_features)] // for trait upcasting #![feature(allocator_api, trait_upcasting)] use std::alloc::Layout; use std::alloc::{AllocError, Allocator}; use std::c...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/pass/box-custom-alloc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JanMH/euler path: /euler3/src/main.rs fn is_prime(number: i64) -> bool { <|fim_suffix|> let to_test = 600851475143; let result = (2..sqrt_i(to_test)).filter(|i| to_test % i == 0).filter(|i| is_prime(*i)); for i in result { println!("{}", i); } }<|fim_middle|> (2..sqrt_i...
code_fim
medium
{ "lang": "rust", "repo": "JanMH/euler", "path": "/euler3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let to_test = 600851475143; let result = (2..sqrt_i(to_test)).filter(|i| to_test % i == 0).filter(|i| is_prime(*i)); for i in result { println!("{}", i); } }<|fim_prefix|>// repo: JanMH/euler path: /euler3/src/main.rs fn is_prime(number: i64) -> bool { (2..sqrt_i(n...
code_fim
medium
{ "lang": "rust", "repo": "JanMH/euler", "path": "/euler3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JanMH/euler path: /euler3/src/main.rs fn is_prime(number: i64) -> bool { <|fim_suffix|>fn sqrt_i(i:i64) -> i64 { (i as f64).sqrt() as i64 + 1 } fn main() { let to_test = 600851475143; let result = (2..sqrt_i(to_test)).filter(|i| to_test % i == 0).filter(|i| is_prime(*i)); for i ...
code_fim
easy
{ "lang": "rust", "repo": "JanMH/euler", "path": "/euler3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub static SQL_INS_TRIP : &str = "select a from funcs.ins_trip($1, $2) a " ; pub static SQL_UPD_TRIP : &str = "select a from funcs.upd_trip($1, $2) a " ; pub static SQL_GET_USER : &str = "select a from funcs.get_usr($1, $2) a " ; pub static SQL_GET_OTHER_USER : &str = "select a from funcs.get_o...
code_fim
hard
{ "lang": "rust", "repo": "whl36512/ride4", "path": "/server/src/constants.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whl36512/ride4 path: /server/src/constants.rs //pub static LOG_FILE : &str ="/tmp/server.log" ; pub static EMPTY_STRING : &str ="" ; pub static EMPTY_JSON_STRING : &str ="{}" ; pub static SECRET : &str ="an ultra secretstr" ; pub static ERROR_ROW_NOT_FOUND: &str = r##"{"error":"row not found"}...
code_fim
hard
{ "lang": "rust", "repo": "whl36512/ride4", "path": "/server/src/constants.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atayozcan/photo-to-mc-skin path: /src/main.rs use tensorflow::{Graph, ImportGraphDefOptions, Session, SessionOptions, SessionRunArgs, Tensor}; use image::{imageops::{crop, thumbnail}, open, GenericImageView}; use imageproc::drawing::Canvas; use std::error::Error; #[derive(Copy, Clone, Debug)] p...
code_fim
hard
{ "lang": "rust", "repo": "atayozcan/photo-to-mc-skin", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input_image = thumbnail(&input_image, 8, 8); let mut template = open("minecraft-skin-template.png").unwrap(); let mut x = 7; let mut y = 7; for pixel in &mut input_image.pixels() { x += 1; if x % 8 == 0 { y += 1; x -= 8 } C...
code_fim
hard
{ "lang": "rust", "repo": "atayozcan/photo-to-mc-skin", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let bboxes: Vec<_> = bbox_res .chunks_exact(4) .zip(prob_res.iter()) .map(|(bbox, &prob)| BBox { y1: bbox[0], x1: bbox[1], y2: bbox[2], x2: bbox[3], prob, }) .collect(); let bbox = bboxes.get(0).un...
code_fim
hard
{ "lang": "rust", "repo": "atayozcan/photo-to-mc-skin", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( Color::new(1.0, 1.0, 1.0).to_pixel_color(), Color::new(255.0, 255.0, 255.0) ); assert_eq!( Color::new(1.6, 1.3, 1.1).to_pixel_color(), Color::new(255.0, 255.0, 255.0) ); assert_eq!( Color::new(0.5, 1.0, 0.0).to_pixel_color(), ...
code_fim
hard
{ "lang": "rust", "repo": "pepone42/raytracer.rs", "path": "/src/color.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pepone42/raytracer.rs path: /src/color.rs use std::f64; use std::ops::{Mul, Add, Sub}; #[derive(Debug, Clone, PartialEq, Copy)] pub struct Color { pub r: f64, pub g: f64, pub b: f64, } impl Color { pub fn new(r: f64, g: f64, b: f64) -> Self { Color { r, g, b } } ...
code_fim
hard
{ "lang": "rust", "repo": "pepone42/raytracer.rs", "path": "/src/color.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: loop-revolution/data-block path: /mod.rs use block_tools::{ blocks::{BlockType, Context, TypeInfo}, display_api::{ component::{atomic::icon::Icon, layout::card::CardComponent, DisplayComponent}, CreationObject, DisplayObject, }, models::Block, LoopError, }; mod display; mod methods; p...
code_fim
hard
{ "lang": "rust", "repo": "loop-revolution/data-block", "path": "/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> context: &Context, name: String, block_id: i64, args: String, ) -> Result<Block, LoopError> { Self::handle_method_delegate(context, name, block_id, args) } fn block_name(_block: &Block, _context: &Context) -> Result<String, LoopError> { Ok("Data Block".into()) } }<|fim_prefix|>// repo: lo...
code_fim
medium
{ "lang": "rust", "repo": "loop-revolution/data-block", "path": "/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl super::Solution for Solution { fn path_sum(root: Option<Rc<RefCell<TreeNode>>>, sum: i32) -> i32 { Self::path_sum(root, sum) } } #[cfg(test)] mod tests { #[test] fn test_solution() { super::super::tests::run::<super::Solution>(); } }<|fim_prefix|>// repo: EFanZh/L...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0437_path_sum_iii/recursive.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0437_path_sum_iii/recursive.rs use crate::data_structures::TreeNode; pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // use std::cell::RefCell; use std::collections::h...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0437_path_sum_iii/recursive.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Returns a 16-bit signed 16kHz PCM buffer. pub fn generate( &mut self, source: &[u8], ) -> Result<Vec<i16>, Error> { let mut remaining = source; while remaining.len() > 0 { let n_put = self.engine.put_text(remaining)?; remaining = &rema...
code_fim
hard
{ "lang": "rust", "repo": "BoniLindsley/ssip-server", "path": "/src/ttspico.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BoniLindsley/ssip-server path: /src/ttspico.rs pub struct Error { description: String, } impl From<ttspico::PicoError> for Error { fn from(source: ttspico::PicoError) -> Error { let description = source.descr; Error { description } } } impl std::error::Error for Error...
code_fim
hard
{ "lang": "rust", "repo": "BoniLindsley/ssip-server", "path": "/src/ttspico.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, formatter: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { write!(formatter, "TTS Pico error: {}", self.description) } } pub struct Synthesiser { engine: ttspico::Engine, } impl Synthesiser { pub fn new() -> Result<Synthesiser, Error> { let mem...
code_fim
hard
{ "lang": "rust", "repo": "BoniLindsley/ssip-server", "path": "/src/ttspico.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: williballenthin/zydis-wasm path: /src/lib.rs use std::io::Write; use wasm_bindgen::prelude::*; use zydis::*; #[wasm_bindgen] pub fn disassemble(buf: Vec<u8>) -> String { let formatter = Formatter::new(FormatterStyle::INTEL).unwrap(); let decoder = Decoder::new(MachineMode::LONG_64, Ad...
code_fim
medium
{ "lang": "rust", "repo": "williballenthin/zydis-wasm", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut w = Vec::new(); let addr = 0x007FFFFFFF400000; for (instruction, ip) in decoder.instruction_iterator(&buf, addr) { formatter.format_instruction(&instruction, &mut buffer, Some(ip), None).unwrap(); writeln!(&mut w, "0x{:016X} {}", ip, buffer).unwrap(); } return...
code_fim
medium
{ "lang": "rust", "repo": "williballenthin/zydis-wasm", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let addr = 0x007FFFFFFF400000; for (instruction, ip) in decoder.instruction_iterator(&buf, addr) { formatter.format_instruction(&instruction, &mut buffer, Some(ip), None).unwrap(); writeln!(&mut w, "0x{:016X} {}", ip, buffer).unwrap(); } return String::from_utf8(w).unwrap(...
code_fim
medium
{ "lang": "rust", "repo": "williballenthin/zydis-wasm", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self.0 } } impl From<crate::W<THS_ALARM_CTRL_SPEC>> for W { #[inline(always)] fn from(writer: crate::W<THS_ALARM_CTRL_SPEC>) -> Self { W(writer) } } #[doc = "Field `ALARM_T_HOT` reader - Thermal sensor alarm threshold for hot temperature"] pub type ALARM_T_HOT_R = crat...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/r528-pac/src/ths/ths_alarm_ctrl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /r528-pac/src/ths/ths_alarm_ctrl.rs #[doc = "Register `THS_ALARM_CTRL` reader"] pub struct R(crate::R<THS_ALARM_CTRL_SPEC>); impl core::ops::Deref for R { type Target = crate::R<THS_ALARM_CTRL_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { ...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/r528-pac/src/ths/ths_alarm_ctrl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: onecodex/taxonomy-rs path: /src/taxonomy.rs //! The Taxonomy trait defines a large suite of methods that can be used //! by implementing a limited subset of required methods. use std::collections::VecDeque; use std::fmt::{Debug, Display}; use std::iter::Sum; use crate::rank::TaxRank; use crate:...
code_fim
hard
{ "lang": "rust", "repo": "onecodex/taxonomy-rs", "path": "/src/taxonomy.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(match tax_id { 1 => vec![131567], 131567 => vec![2], 2 => vec![1224], 1224 => vec![1236], 1236 => vec![135622, 135613], // Gammaproteobacteria 135622 => vec![22], 22 => vec![62322...
code_fim
hard
{ "lang": "rust", "repo": "onecodex/taxonomy-rs", "path": "/src/taxonomy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where Self: Sized, { Ok(TaxonomyIterator::new(self, node)) } /// Returns the number of nodes in the taxonomy /// /// A default implementation is specified, but you almost always want /// to provide your own for speed reasons. fn len(&'t self) -> usize w...
code_fim
hard
{ "lang": "rust", "repo": "onecodex/taxonomy-rs", "path": "/src/taxonomy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Resets the state so the same waker can be reused. /// /// This function is not impl #[allow(dead_code, clippy::clippy::unnecessary_wraps)] pub(crate) fn reset(&self) -> std::io::Result<()> { Ok(()) } }<|fim_prefix|>// repo: crossterm-rs/crossterm path: /src/event/sys/u...
code_fim
hard
{ "lang": "rust", "repo": "crossterm-rs/crossterm", "path": "/src/event/sys/unix/waker/mio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crossterm-rs/crossterm path: /src/event/sys/unix/waker/mio.rs use std::sync::{Arc, Mutex}; use ::mio::{Registry, Token}; /// Allows to wake up the `mio::Poll::poll()` method. /// This type wraps `mio::Waker`, for more information see its documentation. #[derive(Clone, Debug)] pub(crate) struct...
code_fim
hard
{ "lang": "rust", "repo": "crossterm-rs/crossterm", "path": "/src/event/sys/unix/waker/mio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn lexer_single_line_rules_incorrect() -> Result<(), ESError> { let lines: Vec<String> = vec![ format!("+ A B C => E"), format!("A + + B C => E"), format!("A(B) C => E"), format!("A + (B +) + C => E"), format!("A + (B + D) + C + => E"), format!("...
code_fim
hard
{ "lang": "rust", "repo": "guilhemSmith/expert-system", "path": "/src/lexer_parser/tests/checker.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guilhemSmith/expert-system path: /src/lexer_parser/tests/checker.rs use crate::lexer_parser::{ESLine, ESLineType}; use crate::utils::error::ESError; #[test] fn lexer_single_line_empty() -> Result<(), ESError> { let line = format!(""); let tmp: ESLine = ESLine::new(&line)?; tmp.check...
code_fim
hard
{ "lang": "rust", "repo": "guilhemSmith/expert-system", "path": "/src/lexer_parser/tests/checker.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Stratus51/rust_scalable_space_engine path: /src/space_tree.rs derive(Debug, Clone, PartialEq)] pub enum SpaceTree { Parent(SpaceTreeParent), Matter(MatterTree), } #[derive(Debug, Clone, PartialEq)] pub struct SpaceTreeParent { pub scale: u32, pub sub_trees: [Option<Box<SpaceTree...
code_fim
hard
{ "lang": "rust", "repo": "Stratus51/rust_scalable_space_engine", "path": "/src/space_tree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Stratus51/rust_scalable_space_engine path: /src/space_tree.rs } else { SpaceTree::Parent(SpaceTreeParent { scale: self.scale - 1, sub_trees: [SpaceTree::NONE_SPACE_CELL; NB_QUADRANTS], }) }) } } #[derive(Debug, Clone, PartialE...
code_fim
hard
{ "lang": "rust", "repo": "Stratus51/rust_scalable_space_engine", "path": "/src/space_tree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run_movements(&mut self) { self.tree.run_movements(); } pub fn refresh(&mut self) { let mut outsiders = self.tree.refresh(); // Check in which directions the ousiders are let mut expansion_dirs = [0; NB_DIRECTIONS as usize]; let mut nb_expansion...
code_fim
hard
{ "lang": "rust", "repo": "Stratus51/rust_scalable_space_engine", "path": "/src/space_tree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn tokenize_deals_with_parentheses() { let string = "2*(4-3)"; let result: Vec<Token> = tokenize(string); let expected_result: Vec<Token> = [ Token::Literal(Literal::from(String::from("2"))), Token::Operator(Operator::Times), Tok...
code_fim
hard
{ "lang": "rust", "repo": "Pamplemousse/mathematical_expression_evaluation", "path": "/src/tokenizer/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pamplemousse/mathematical_expression_evaluation path: /src/tokenizer/mod.rs pub mod token; use self::token::*; use self::token::literal::Literal; use self::token::literal::digit::Digit; pub fn tokenize(expression: &str) -> Vec<Token> { fn pop_literal_buffer_to_tokens(buffer: &mut Vec<Digit>...
code_fim
hard
{ "lang": "rust", "repo": "Pamplemousse/mathematical_expression_evaluation", "path": "/src/tokenizer/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use super::token::literal::Literal; use super::token::operator::Operator; #[test] fn tokenize_creates_tokens_from_a_string() { let string = "2*3"; let result: Vec<Token> = tokenize(string); let expected_result: Vec<Token>...
code_fim
hard
{ "lang": "rust", "repo": "Pamplemousse/mathematical_expression_evaluation", "path": "/src/tokenizer/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn comisd_2() { run_test(&Instruction { mnemonic: Mnemonic::COMISD, operand1: Some(Direct(XMM0)), operand2: Some(IndirectScaledDisplaced(ESI, Four, 1266860078, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, ...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/comisd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::COMISD, operand1: Some(Direct(XMM5)), operand2: Some(Indirect(RAX, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 47, 40], OperandSiz...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/comisd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/comisd.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; <|fim_suffix|> run_test(&Ins...
code_fim
medium
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/comisd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simongibbons/efficient_route_planning path: /src/shortest_path.rs use crate::road_network::{Cost, RoadNetwork, Node, NodeIndex}; use std::collections::{BinaryHeap, HashMap, HashSet}; use std::cmp::Ordering; #[derive(Debug, Default, Eq, PartialEq)] struct HeapEl { cost: Cost, potential...
code_fim
hard
{ "lang": "rust", "repo": "simongibbons/efficient_route_planning", "path": "/src/shortest_path.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_route_to_same_node() { let network = get_test_network(); let node = network.get_node(1).unwrap(); let result = dijkstra_shortest_path(&network, &node, &node).unwrap(); assert_eq!(0, result.cost); assert_eq!(vec![1], result.path); } ...
code_fim
hard
{ "lang": "rust", "repo": "simongibbons/efficient_route_planning", "path": "/src/shortest_path.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: freebsd/freebsd-ports path: /lang/rust/files/riscv64/patch-vendor_rustc__ap__rustc__target_src_spec_riscv64gc__unknown__freebsd.rs --- vendor/rustc-ap-rustc_target/src/spec/riscv64gc_unknown_freebsd.rs.orig 2021-11-04 11:22:10 UTC +++ vendor/rustc-ap-rustc_target/src/spec/riscv64gc_unknown_freeb...
code_fim
hard
{ "lang": "rust", "repo": "freebsd/freebsd-ports", "path": "/lang/rust/files/riscv64/patch-vendor_rustc__ap__rustc__target_src_spec_riscv64gc__unknown__freebsd.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>i64:64-i128:128-n64-S128".to_string(), + arch: "riscv64".to_string(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".to_string(), + features: "+m,+a,+f,+d,+c".to_string(), + llvm_abiname: "lp64d".to_string()...
code_fim
hard
{ "lang": "rust", "repo": "freebsd/freebsd-ports", "path": "/lang/rust/files/riscv64/patch-vendor_rustc__ap__rustc__target_src_spec_riscv64gc__unknown__freebsd.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Eissen/fuchsia path: /src/sys/time/httpsdate_time_source/src/diagnostics/cobalt.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use crate::datatypes::{HttpsSample, Phase}; use ...
code_fim
hard
{ "lang": "rust", "repo": "Eissen/fuchsia", "path": "/src/sys/time/httpsdate_time_source/src/diagnostics/cobalt.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[fasync::run_until_stalled(test)] async fn test_success_after_phase_update() { let (cobalt, mut event_recv) = diagnostics_for_test(); cobalt.success(&HttpsSample { utc: *TEST_TIME, monotonic: *TEST_TIME, standard_deviation: TEST_STANDARD_DEVIATI...
code_fim
hard
{ "lang": "rust", "repo": "Eissen/fuchsia", "path": "/src/sys/time/httpsdate_time_source/src/diagnostics/cobalt.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Reset, and get time elapsed (in seconds) since last reset. pub fn tick(&mut self) -> f64 { #[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] { let now = now(); let delta = now - self.start; self.start = now; delta ...
code_fim
hard
{ "lang": "rust", "repo": "kuviman/commons", "path": "/timer/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kuviman/commons path: /timer/src/lib.rs //! Timer. #![deny(warnings)] extern crate prelude; #[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] #[macro_use] extern crate stdweb; /// Timer can be used to track time since some instant. pub struct Timer { #[cfg(any(target_arch = "asmj...
code_fim
medium
{ "lang": "rust", "repo": "kuviman/commons", "path": "/timer/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Drop for FileStruct { fn drop(&mut self) { for file in &self.files { if let Some(f) = file { f.release().ok(); } } } } impl Debug for FileStruct { fn fmt(&self, f: &mut Formatter) -> Result { f.debug_map() .entri...
code_fim
hard
{ "lang": "rust", "repo": "DeathWish5/aCore", "path": "/kernel/src/fs/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DeathWish5/aCore path: /kernel/src/fs/mod.rs mod file; mod stdio; use alloc::{sync::Arc, vec::Vec}; use core::fmt::{Debug, Formatter, Result}; use crate::error::{AcoreError, AcoreResult}; use crate::utils::IdAllocator; use stdio::{Stdin, Stdout}; pub use file::{File, RAM_DISK}; pub trait Gen...
code_fim
hard
{ "lang": "rust", "repo": "DeathWish5/aCore", "path": "/kernel/src/fs/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_file(&self, fd: usize) -> AcoreResult<Arc<dyn GenericFile>> { if fd >= self.files.len() { return Err(AcoreError::BadFileDescriptor); } match &self.files[fd] { Some(f) => Ok(f.clone()), None => Err(AcoreError::BadFileDescriptor), ...
code_fim
hard
{ "lang": "rust", "repo": "DeathWish5/aCore", "path": "/kernel/src/fs/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/* Utility to read contents fo the file and returning error codes,if any */ fn safe_read<P: AsRef<Path>>(file: P) -> Result<String, std::io::Error> { let mut _data = fs::read_to_string(file)?; Ok(_data) } /* Utility function to print lines in files which have the required input */ pub...
code_fim
hard
{ "lang": "rust", "repo": "dattatreya97/minigrepCmdTool", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dattatreya97/minigrepCmdTool path: /src/lib.rs //CRATES extern crate term; use std::path::Path; use std::error::Error; use std::fs; use std::env; use walkdir::WalkDir; //ENUM pub enum SearchType{ File, Directory, } //STRUCT pub struct Config { pub query: String, pub filena...
code_fim
hard
{ "lang": "rust", "repo": "dattatreya97/minigrepCmdTool", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xatabch/technopark_highload path: /src/http/request.rs extern crate percent_encoding; use self::percent_encoding::percent_decode; #[derive(Debug)] pub struct HTTPRequest { pub method: String, pub path: String, pub isAutoIndex: bool, } impl HTTPRequest { pub fn new() -> HTTP...
code_fim
hard
{ "lang": "rust", "repo": "Xatabch/technopark_highload", "path": "/src/http/request.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if firstLine.len() == 0 { return Err(()); } let requestVec: Vec<&str> = firstLine.split(" ").collect(); if requestVec.len() < 3 { return Err(()); } let (parsedPath, isAutoIndex) = match parsePath(requestVec[1]) { Ok((p,...
code_fim
hard
{ "lang": "rust", "repo": "Xatabch/technopark_highload", "path": "/src/http/request.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> test_map.insert(25, 30, &'c'); assert_eq!(test_map.get(&10), &'b'); assert_eq!(test_map.get(&20), &'a'); assert_eq!(test_map.get(&26), &'c'); assert_eq!(test_map.get(&30), &'a'); } #[test] fn overlapping() { let mut test_map: IntervalMap<i32, ch...
code_fim
hard
{ "lang": "rust", "repo": "BramGrooteman/IntervalMap", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BramGrooteman/IntervalMap path: /src/lib.rs use std::collections::BTreeMap; use std::hash::Hash; pub trait Min { fn minimum() -> Self; } impl Min for i32 { fn minimum() -> i32 { std::i32::MIN } } /* Implements a mapping that encapsulates an interval meaning that we can ins...
code_fim
hard
{ "lang": "rust", "repo": "BramGrooteman/IntervalMap", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: huin/accountmerge path: /src/mutcell.rs #![allow(dead_code)] use std::fmt::Debug; use std::hash::{Hash, Hasher}; /// Contains a value that can be updated via move. /// See `MutCell::map_value` in particular. pub struct MutCell<T>(State<T>); enum State<T> { Poisoned, Value(T), } impl<...
code_fim
hard
{ "lang": "rust", "repo": "huin/accountmerge", "path": "/src/mutcell.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Eq for MutCell<T> where T: Eq {} impl<T> Hash for MutCell<T> where T: Hash, { fn hash<H>(&self, h: &mut H) where H: Hasher, { self.as_ref().hash(h) } } impl<T> PartialEq for MutCell<T> where T: PartialEq, { fn eq(&self, rhs: &Self) -> bool { se...
code_fim
hard
{ "lang": "rust", "repo": "huin/accountmerge", "path": "/src/mutcell.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use TestEnum::*; match self { One(ref mut v) => *v += 1, Two(ref mut v) => *v += 1, } } } #[test] fn mut_cell() { use TestEnum::*; let mut cell = MutCell::new(One(5)); assert_eq!(cell.as_ref()...
code_fim
hard
{ "lang": "rust", "repo": "huin/accountmerge", "path": "/src/mutcell.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } impl EDGE_R { #[doc = "Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> EDGE_A { match self.bits { false => EDGE_A::LEFT_FALLING, true => EDGE_A::LEFT_RISING, } } #[doc = "Checks if the...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf-pacs", "path": "/pacs/nrf52832-pac/src/pdm/mode.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf-pacs path: /pacs/nrf52832-pac/src/pdm/mode.rs #[doc = "Register `MODE` reader"] pub struct R(crate::R<MODE_SPEC>); impl core::ops::Deref for R { type Target = crate::R<MODE_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate:...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf-pacs", "path": "/pacs/nrf52832-pac/src/pdm/mode.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> RegisterMode { tokens: quote!{ pub struct #title { value: #repr } impl #title { #(#field_accessors)* #(#fast_enum_accessors)* } }, main_impl_fn: quote!{ #[inline] ...
code_fim
hard
{ "lang": "rust", "repo": "russellmcc/rust-gba", "path": "/gba-register-generator/src/generate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[doc = "Updates only certain fields of the register,"] #[doc = "keeping other fields unchanged."] #[inline] pub fn update<F: FnOnce(#title) -> #title>(&mut self, f: F) -> &mut #rtitle { let t = self.value.get(); self.value.se...
code_fim
hard
{ "lang": "rust", "repo": "russellmcc/rust-gba", "path": "/gba-register-generator/src/generate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: russellmcc/rust-gba path: /gba-register-generator/src/generate.rs use ::register::*; use std::rc::Rc; use quote::Tokens; use syn::Ident; fn generate_docs(doc: &str) -> Tokens { let docs: Vec<Tokens> = doc.lines().map(|line| { quote! { #[doc=#line] } }).collec...
code_fim
hard
{ "lang": "rust", "repo": "russellmcc/rust-gba", "path": "/gba-register-generator/src/generate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zgrannan/tendermint-prusti path: /light-client/src/types.rs //! Defines or just re-exports the main datatypes used by the light client. use std::fmt; pub use tendermint::{block::Height, hash::Hash}; extern crate prusti_contracts; use prusti_contracts::*; use tendermint::block::signed_header::...
code_fim
hard
{ "lang": "rust", "repo": "zgrannan/tendermint-prusti", "path": "/light-client/src/types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }