text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> if targets.is_empty() { return internal_error!(MissingAssignmentTarget, self); } let single_target = targets.len() == 1; if let Some(rhs) = self.parse_expressions(&mut ExpressionContext::permissive(), !single_target)? { let node ...
code_fim
hard
{ "lang": "rust", "repo": "llogiq/koto", "path": "/src/parser/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: llogiq/koto path: /src/parser/src/parser.rs rst().unwrap(), op: assign_op, expression: rhs, } } else { Node::MultiAssign { targets, expression: rhs, } ...
code_fim
hard
{ "lang": "rust", "repo": "llogiq/koto", "path": "/src/parser/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: osaware/rCore-N path: /os/src/trap/mod.rs mod context; mod usertrap; use crate::config::{TRAMPOLINE, TRAP_CONTEXT}; use crate::plic; use crate::sbi::set_timer; use crate::syscall::syscall; use crate::task::{ current_task, current_trap_cx, current_user_token, exit_current_and_run_next, s...
code_fim
hard
{ "lang": "rust", "repo": "osaware/rCore-N", "path": "/os/src/trap/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } stvec::write(kernelvec as usize, TrapMode::Direct); } } fn set_user_trap_entry() { unsafe { stvec::write(TRAMPOLINE as usize, TrapMode::Direct); } } #[no_mangle] pub fn trap_handler() -> ! { set_kernel_trap_entry(); let scause = scause::read(); let stval...
code_fim
hard
{ "lang": "rust", "repo": "osaware/rCore-N", "path": "/os/src/trap/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn trap_from_kernel() { unsafe { ebreak(); } let scause = scause::read(); let stval = stval::read(); let _sepc = sepc::read(); let _sstatus = sstatus::read(); match scause.cause() { Trap::Interrupt(Interrupt::SupervisorTimer) => { ...
code_fim
hard
{ "lang": "rust", "repo": "osaware/rCore-N", "path": "/os/src/trap/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.rs //@aux-build:../../ui/auxiliary/proc_macros.rs //@aux-build:helper.rs //@revisions: allow_crates disallow_crates //@[allow_crates] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/absolute_paths/allow_crates //@[disallo...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub struct B; } pub struct A; } fn main() { f32::max(1.0, 2.0); std::f32::MAX; core::f32::MAX; ::core::f32::MAX; crate::a::b::c::C; crate::a::b::c::d::e::f::F; crate::a::A; crate::a::b::B; crate::a::b::c::C::ZERO; helper::b::c::d::e::f(); ::hel...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_should_raise_error_if_overflow() { let mut phrase = Phrase::new("test"); assert_eq!(true, phrase.decrement(&Phrase::new("tettt")).is_err()); } #[test] fn it_has_is_exhausted() { let mut phrase = Phrase::new("test"); assert_eq!(false, phrase.is_exhausted()); phr...
code_fim
hard
{ "lang": "rust", "repo": "matitalatina/anagram-generator", "path": "/algorithm/src/anagram.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matitalatina/anagram-generator path: /algorithm/src/anagram.rs use std::collections::HashMap; use std::collections::HashSet; use std::hash::{Hash, Hasher}; use std::iter::FromIterator; #[derive(Debug)] pub enum PhraseError { NotPhrase, } #[derive(PartialEq, Debug, Clone, Eq)] pub struct Phra...
code_fim
hard
{ "lang": "rust", "repo": "matitalatina/anagram-generator", "path": "/algorithm/src/anagram.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulhowardarm/parsec path: /src/utils/service_builder.rs .core_settings .buffer_size_limit .unwrap_or(DEFAULT_BUFFER_SIZE_LIMIT), ) .with_allow_deprecated(config.core_settings.allow_deprecated.unwrap_or(false)) ...
code_fim
hard
{ "lang": "rust", "repo": "paulhowardarm/parsec", "path": "/src/utils/service_builder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulhowardarm/parsec path: /src/utils/service_builder.rs arsec service configuration into a fully formed service. /// Each component is independently created after which its ownership can be passed to the previous /// component in the ownership chain. The service's ownership is then passed in th...
code_fim
hard
{ "lang": "rust", "repo": "paulhowardarm/parsec", "path": "/src/utils/service_builder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut core_provider_builder = CoreProviderBuilder::new() .with_wire_protocol_version(WIRE_PROTOCOL_VERSION_MINOR, WIRE_PROTOCOL_VERSION_MAJOR); for (_auth_type, authenticator) in authenticators { let authenticator_info = authenticator .describe() .map_err...
code_fim
hard
{ "lang": "rust", "repo": "paulhowardarm/parsec", "path": "/src/utils/service_builder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hikobae/seterrorlevel path: /src/main.rs fn main() { let errorlevel = match std::env::args().nth(1) { <|fim_suffix|>, Err(_) => 0, }; std::process::exit(errorlevel); }<|fim_middle|> Some(n) => n, None => "0".to_string(), }; let errorlevel = match errorl...
code_fim
medium
{ "lang": "rust", "repo": "hikobae/seterrorlevel", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>, Err(_) => 0, }; std::process::exit(errorlevel); }<|fim_prefix|>// repo: hikobae/seterrorlevel path: /src/main.rs fn main() { let errorlevel = match std::env::args().nth(1) { Some(n) => n, None => "0".to_string(), }; le<|fim_middle|>t errorlevel = match errorl...
code_fim
medium
{ "lang": "rust", "repo": "hikobae/seterrorlevel", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> AngleBracketedGenericArguments { colon2_token: None, lt_token: generics.lt_token.unwrap_or_else(|| Token![<](generics.span())), args, gt_token: generics.gt_token.unwrap_or_else(|| Token![>](generics.span())) } }<|fim_prefix|>// repo: kitlith/robusta path: /robusta-...
code_fim
hard
{ "lang": "rust", "repo": "kitlith/robusta", "path": "/robusta-codegen/src/derive/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kitlith/robusta path: /robusta-codegen/src/derive/utils.rs use syn::{AngleBracketedGenericArguments, ConstParam, GenericArgument, GenericParam, Generics, TypeParam}; use syn::parse_quote; use syn::punctuated::Punctuated; use syn::Token; use syn::spanned::Spanned; <|fim_suffix|> AngleBrackete...
code_fim
hard
{ "lang": "rust", "repo": "kitlith/robusta", "path": "/robusta-codegen/src/derive/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut s = vec!['H', 'a', 'n', 'n', 'a', 'h']; Solution::reverse_string(&mut s); dbg!(s); }<|fim_prefix|>// repo: lovesegfault/leetcode path: /reverse-string/src/main.rs struct Solution; impl Solution { pub fn reverse_string(s: &mut Vec<char>) { // s.reverse(); let l = s...
code_fim
easy
{ "lang": "rust", "repo": "lovesegfault/leetcode", "path": "/reverse-string/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lovesegfault/leetcode path: /reverse-string/src/main.rs struct Solution; impl Solution { pub fn reverse_string(s: &mut Vec<char>) { // s.reverse(); let l = s.len(); for i in 0..(l / 2) { s.swap(i, l - i - 1); } } } <|fim_suffix|> let mut s...
code_fim
easy
{ "lang": "rust", "repo": "lovesegfault/leetcode", "path": "/reverse-string/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jk563/aoc2020 path: /04/src/main.rs use std::collections::HashMap; use regex::Regex; const INPUT_FILE_NAME: &str = "input.txt"; fn main() { let input = std::fs::read_to_string(INPUT_FILE_NAME).expect("Opening file failed") .parse::<String>(...
code_fim
hard
{ "lang": "rust", "repo": "jk563/aoc2020", "path": "/04/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Passport { fn from(info: &str) -> Passport { let mut passport_info = HashMap::new(); for kv in info.split_whitespace() { let kv = kv.split(":").collect::<Vec<&str>>(); passport_info.insert(kv[0], kv[1]); } Passport { byr: passpor...
code_fim
hard
{ "lang": "rust", "repo": "jk563/aoc2020", "path": "/04/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let re_hcl = Regex::new(r"^#[0-9a-f]{6}$").unwrap(); let re_ecl = Regex::new(r"^(amb|blu|brn|gry|grn|hzl|oth)$").unwrap(); let re_pid = Regex::new(r"^\d{9}$").unwrap(); self.basic_valid() && ((1920 <= self.byr.as_ref().unwrap().parse::<usize>().unwrap()) && ((&self...
code_fim
hard
{ "lang": "rust", "repo": "jk563/aoc2020", "path": "/04/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pc.cycle += 1; } } struct InstructionAddx { value: i32, } impl Instruction for InstructionAddx { fn run(&self, pc: &mut Pc) { pc.cycle += 2; pc.x += self.value; } } fn parse_input(input: &str) -> Vec<Box<dyn Instruction>> { let mut instructions: Vec<Box<dyn In...
code_fim
hard
{ "lang": "rust", "repo": "pavel1269/advent-of-code", "path": "/2022/src/day10/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>trait Instruction { fn run(&self, pc: &mut Pc); } struct InstructionNoop {} impl Instruction for InstructionNoop { fn run(&self, pc: &mut Pc) { pc.cycle += 1; } } struct InstructionAddx { value: i32, } impl Instruction for InstructionAddx { fn run(&self, pc: &mut Pc) { ...
code_fim
hard
{ "lang": "rust", "repo": "pavel1269/advent-of-code", "path": "/2022/src/day10/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pavel1269/advent-of-code path: /2022/src/day10/mod.rs use std::collections::HashMap; pub fn get_solution_part1() -> String { let input = get_input(); let result = sum_signal_strengths(input); return result.to_string(); } pub fn get_solution_part2() -> String { let input = get_i...
code_fim
hard
{ "lang": "rust", "repo": "pavel1269/advent-of-code", "path": "/2022/src/day10/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* println!( "calling update_status, lyc = {}, ly = {}", *self.lyc.borrow(), *ly ); */ self.update_status( sys...
code_fim
hard
{ "lang": "rust", "repo": "codyd51/axle", "path": "/rust_programs/gb_emu/src/ppu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // We have tile data to push out let px = tile_row[cursor_within_tile_pixels]; let px_offset = row_base + (rendered_pixel_count * 4); frame[px_offset + 0] = px.0; frame[px_offset + 1] = px.1; frame[px_offset + 2] = px.2; f...
code_fim
hard
{ "lang": "rust", "repo": "codyd51/axle", "path": "/rust_programs/gb_emu/src/ppu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: codyd51/axle path: /rust_programs/gb_emu/src/ppu.rs } */ if (screen_y as usize) < sprite_screen_coordinates.1 || (screen_y as usize) >= sprite_screen_coordinates.1 + sprite_height { // Skip this sprite as the current scan...
code_fim
hard
{ "lang": "rust", "repo": "codyd51/axle", "path": "/rust_programs/gb_emu/src/ppu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erszcz/learning path: /rust-sexp/old/parser.rs #![feature(phase, globs)] #[phase(syntax, link)] extern crate log; // S Expression Parser // // This parser should correspond to the following grammar: // // sexp :: ATOM // | list // list :: LPAREN members RPAREN // | LPAREN RPAREN // ...
code_fim
hard
{ "lang": "rust", "repo": "erszcz/learning", "path": "/rust-sexp/old/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn unwrap(parse_result: ParseResult) -> SExp { match parse_result { Ok (sexp) => sexp, Error (reason) => fail!(reason.to_owned()) } } fn tokeparse(s: &str) -> SExp { unwrap( parse_sexp( lexer::tokenize(s) ) ) } #[test] fn test_parse_1() { assert_eq!(Atom (~"asd"), tokeparse("asd")); } #...
code_fim
hard
{ "lang": "rust", "repo": "erszcz/learning", "path": "/rust-sexp/old/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_parse_1() { assert_eq!(Atom (~"asd"), tokeparse("asd")); } #[test] fn test_parse_2() { assert_eq!(List (~[Atom (~"asd"), Atom (~"qwe")]), tokeparse("(asd qwe)")); } #[test] fn test_parse_3() { assert_eq!(List (~[List (~[Atom (~"asd")]), Atom (~"qwe")]), to...
code_fim
hard
{ "lang": "rust", "repo": "erszcz/learning", "path": "/rust-sexp/old/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: casey/colour-lovers-rs path: /src/opt.rs use common::*; #[derive(StructOpt, Debug)] #[structop<|fim_suffix|>ctopt(name = "palette")] Palette { id: u64, } }<|fim_middle|>t(name = "colour-lovers")] pub enum Opt { #[structopt(name = "color")] Color { hex: Rgb, }, #[stru
code_fim
medium
{ "lang": "rust", "repo": "casey/colour-lovers-rs", "path": "/src/opt.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>(name = "color")] Color { hex: Rgb, }, #[structopt(name = "palette")] Palette { id: u64, } }<|fim_prefix|>// repo: casey/colour-lovers-rs path: /src/opt.rs use common::*; #[derive(StructOpt, Debug)] #[structop<|fim_middle|>t(name = "colour-lovers")] pub enum Opt { #[structopt
code_fim
easy
{ "lang": "rust", "repo": "casey/colour-lovers-rs", "path": "/src/opt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ctopt(name = "palette")] Palette { id: u64, } }<|fim_prefix|>// repo: casey/colour-lovers-rs path: /src/opt.rs use common::*; #[derive(StructOpt, Debug)] #[structop<|fim_middle|>t(name = "colour-lovers")] pub enum Opt { #[structopt(name = "color")] Color { hex: Rgb, }, #[stru
code_fim
medium
{ "lang": "rust", "repo": "casey/colour-lovers-rs", "path": "/src/opt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Model { canvas: None, gl: None, camera: None, mesh: HashMap::new(), materials: HashMap::new(), images: HashMap::new(), renderer: None, link, node_ref: NodeRef::default(), render_...
code_fim
hard
{ "lang": "rust", "repo": "opal-ai/web-geo-viewer", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: opal-ai/web-geo-viewer path: /src/lib.rs #![recursion_limit = "256"] use io::Material; use std::collections::HashMap; use three_d::{Camera, DeferredPipeline, Gl}; use web_sys::HtmlCanvasElement; use yew::prelude::*; use yew::services::reader::{File, FileData, ReaderService, ReaderTask}; use yew...
code_fim
hard
{ "lang": "rust", "repo": "opal-ai/web-geo-viewer", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self { Model { canvas: None, gl: None, camera: None, mesh: HashMap::new(), materials: HashMap::new(), images: HashMap::new(), renderer: None, ...
code_fim
hard
{ "lang": "rust", "repo": "opal-ai/web-geo-viewer", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hacspec/hacspecs-rust path: /src/aesgcm.rs // Import hacspec and all needed definitions. use hacspec::prelude::*; // Import aes and gcm use crate::aes; use crate::aes::{aes128_ctr_keyblock, aes128_decrypt, aes128_encrypt, Block}; use crate::gf128::{gmac, Tag, Key}; fn pad_aad_msg(aad: ByteSeq...
code_fim
hard
{ "lang": "rust", "repo": "hacspec/hacspecs-rust", "path": "/src/aesgcm.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mac_key = aes128_ctr_keyblock(key, iv0, U32(0)); let tag_mix = aes128_ctr_keyblock(key, iv, U32(1)); let padded_msg = pad_aad_msg(aad, cipher_text.clone()); let my_tag = gmac(padded_msg, Key::copy(mac_key)); let my_tag = aes::xor_block(Block::copy(my_tag), tag_mix); if my_tag...
code_fim
medium
{ "lang": "rust", "repo": "hacspec/hacspecs-rust", "path": "/src/aesgcm.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ResponseError for Error { fn error_response(&self) -> HttpResponse { let mut response = match self { Error::UpstreamFailure => HttpResponse::ServiceUnavailable(), Error::AuthenticationFailure => HttpResponse::InternalServerError(), Error::Inconsistency ...
code_fim
hard
{ "lang": "rust", "repo": "Wassasin/ical-filter", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl core::convert::From<serde_qs::Error> for Error { fn from(e: serde_qs::Error) -> Self { Error::BadRequest(format!("{}", e)) } } pub type Result<T> = core::result::Result<T, Error>; impl core::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Res...
code_fim
hard
{ "lang": "rust", "repo": "Wassasin/ical-filter", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wassasin/ical-filter path: /src/error.rs use actix_web::{client::SendRequestError, HttpResponse, ResponseError}; use awc::error::PayloadError; use serde::Serialize; #[derive(Debug, Serialize)] pub enum Error { UpstreamFailure, AuthenticationFailure, Inconsistency, BadRequest(Str...
code_fim
medium
{ "lang": "rust", "repo": "Wassasin/ical-filter", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_part1() { assert_eq!(13180, part1().unwrap()); } #[bench] fn bench_part1(b: &mut Bencher) { b.iter(|| { part1().unwrap(); }) } }<|fim_prefix|>// repo: Max-Leopold/LeetCode path: /src/main/other/advent_of_code_2022/src/day10/part...
code_fim
hard
{ "lang": "rust", "repo": "Max-Leopold/LeetCode", "path": "/src/main/other/advent_of_code_2022/src/day10/part1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Max-Leopold/LeetCode path: /src/main/other/advent_of_code_2022/src/day10/part1.rs extern crate test; use std::fs::File; use std::io::{BufRead, BufReader}; pub fn part1() -> Result<isize, Box<dyn std::error::Error>> { let file = File::open("input/day10/input.txt")?; let reader = BufRead...
code_fim
medium
{ "lang": "rust", "repo": "Max-Leopold/LeetCode", "path": "/src/main/other/advent_of_code_2022/src/day10/part1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ashishnegi/learn-rust path: /src/maybe.rs // #[derive(Debug)] // enum Maybe<T> { // Nothing, // Just(T), // } // fn plus_one(there: Maybe<u32>) -> Maybe<u32> { // match there { // Nothing => Nothing, // Just(v) => Just(v+1), // } // } fn plus_one(there: Option<...
code_fim
medium
{ "lang": "rust", "repo": "ashishnegi/learn-rust", "path": "/src/maybe.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn call_nothing() { let v = Some(1); if let Some(inc_val) = plus_one(v) { assert_eq!(inc_val, 2); } else { assert_eq!(None, v); } } }<|fim_prefix|>// repo: ashishnegi/learn-rust path: /src/maybe.rs // #[derive(Debug)] // enum May...
code_fim
medium
{ "lang": "rust", "repo": "ashishnegi/learn-rust", "path": "/src/maybe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mneumann/izhikevich-neurons path: /src/model/neuron_activity.rs /// Describes the activity of a neuron after one step of simulation. /// A neuron either fires an act<|fim_suffix|>impl NeuronActivity { pub fn fires(&self) -> bool { *self == NeuronActivity::Fires } }<|fim_middle|>i...
code_fim
hard
{ "lang": "rust", "repo": "mneumann/izhikevich-neurons", "path": "/src/model/neuron_activity.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl NeuronActivity { pub fn fires(&self) -> bool { *self == NeuronActivity::Fires } }<|fim_prefix|>// repo: mneumann/izhikevich-neurons path: /src/model/neuron_activity.rs /// Describes the activity of a neuron after one step of simulation. /// A neuron either fires an action potential o...
code_fim
medium
{ "lang": "rust", "repo": "mneumann/izhikevich-neurons", "path": "/src/model/neuron_activity.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn unused_when_decrease_input_same_direction() { vec![(1., false), (-1., true)] .into_iter() .for_each(|(x_input, mirrored)| { let input = ControllerInput::new(x_input, 0., false, false, false, false); assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/workspace_tests/src/character_play/run_counter_updater.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/workspace_tests/src/character_play/run_counter_updater.rs #[cfg(test)] mod tests { use character_model::{config::CharacterSequenceName, play::RunCounter}; use game_input_model::play::ControllerInput; use mirrored_model::play::Mirrored; use objec...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/workspace_tests/src/character_play/run_counter_updater.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andyyu2004/l-lang path: /src/lc-resolve/src/scope.rs use lc_ast::Ident; use rustc_hash::FxHashMap; use std::ops::{Deref, DerefMut}; #[derive(Debug)] pub struct Scopes<T> { scopes: Vec<Scope<T>>, } impl<T> Default for Scopes<T> { fn default() -> Self { // start with one top-leve...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/l-lang", "path": "/src/lc-resolve/src/scope.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { bindings: Default::default(), paramc: Default::default() } } } #[derive(Debug)] pub struct Scope<T> { bindings: FxHashMap<Ident, T>, paramc: usize, } impl<T> Scope<T> { fn def(&mut self, ident: Ident, value: T) -> Option<T> { self.bindings.insert(ident, value) ...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/l-lang", "path": "/src/lc-resolve/src/scope.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tynopex/revisa path: /minidump/src/mem_analysis.rs #![allow(non_snake_case)] use parse::{self, ParseData}; use types::{MemoryInfo, Module, StreamType}; #[derive(Serialize)] pub struct ProtectionRegion { pub BaseAddress: u64, pub RegionSize: u64, pub State: u32, pub Protect: u32...
code_fim
hard
{ "lang": "rust", "repo": "tynopex/revisa", "path": "/minidump/src/mem_analysis.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut current = regions.last_mut().unwrap(); assert!(info.AllocationBase == current.AllocationBase); assert!(info.AllocationProtect == current.AllocationProtect); assert!(info.BaseAddress == current.AllocationBase + current.AllocationSize); as...
code_fim
hard
{ "lang": "rust", "repo": "tynopex/revisa", "path": "/minidump/src/mem_analysis.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Annotate module name region.ModuleName = parse::parse_string(data, module.ModuleNameRva) .map(|(n, _)| n) .ok(); assert!(region.ModuleName.is_some()); } } // Rebuilds minidump data into a more useful format pub fn memory_analysis(data: ParseData) -> ...
code_fim
hard
{ "lang": "rust", "repo": "tynopex/revisa", "path": "/minidump/src/mem_analysis.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uamhforever/rs_illume path: /src/core/geometry/vector3.rs use std::ops::*; use std::fmt; use num; use super::super::pbrt::Float; use super::Point3; pub type Vector3f = Vector3<Float>; pub type Vector3i = Vector3<i32>; /// Representation of a 3D Vector. #[derive(Debug, Default, Copy, Clone, Par...
code_fim
hard
{ "lang": "rust", "repo": "uamhforever/rs_illume", "path": "/src/core/geometry/vector3.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Add<T> for Vector3<T> where T: Copy + Add<T, Output = T> { type Output = Self; #[inline] fn add(self, rhs: T) -> Self { Vector3::<T>{ x: self.x + rhs, y: self.y + rhs, z: self.z + rhs } } } impl<T> AddAssign<T> for Vector3<T> where T: Cop...
code_fim
hard
{ "lang": "rust", "repo": "uamhforever/rs_illume", "path": "/src/core/geometry/vector3.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rsk0315/rust-library path: /src/algebra/structures.rs pub trait Magma { type Set: Copy; fn op(lhs: Self::Set, rhs: Self::Set) -> Self::Set; fn op_assign(lhs: &mut Self::Set, rhs: Self::Set); } pub trait Semigroup: Magma { // Operation should be associative. } pub trait Monoid: Se...
code_fim
medium
{ "lang": "rust", "repo": "rsk0315/rust-library", "path": "/src/algebra/structures.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub trait AbelianMonoid: Monoid { // Operation should be commutative. } pub trait AbelianGroup: Group { // Operation should be commutative. }<|fim_prefix|>// repo: rsk0315/rust-library path: /src/algebra/structures.rs pub trait Magma { type Set: Copy; fn op(lhs: Self::Set, rhs: Self::Se...
code_fim
hard
{ "lang": "rust", "repo": "rsk0315/rust-library", "path": "/src/algebra/structures.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn is_completed(&self) -> bool { self.indexes_atom_boundary.len() == 0 } fn value(&self, atom_invariant_values: &Vec<core::graph::VertexFixedHashValue>) -> core::graph::VertexExtendableHashValue { let mut values: Vec<usize> = self.bonds.iter() .map(|b| b.fixed_has...
code_fim
hard
{ "lang": "rust", "repo": "chiral-data/rust-canonical-numbering", "path": "/src/ext/molecule/extendable_hash.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chiral-data/rust-canonical-numbering path: /src/ext/molecule/extendable_hash.rs // Copyright 2021 Chiral Ltd. // Licensed under the Apache-2.0 license (https://opensource.org/licenses/Apache-2.0) // This file may not be copied, modified, or distributed // except according to those terms. //! Ex...
code_fim
hard
{ "lang": "rust", "repo": "chiral-data/rust-canonical-numbering", "path": "/src/ext/molecule/extendable_hash.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_atom_repr() { let mol = molecule::Molecule::from_smiles("c1ccccc1CN"); let aivs: Vec<core::graph::VertexFixedHashValue> = mol.atoms.iter() .map(|a| a.fixed_hash_value()) .collect(); let mut ar = AtomExtendable::init(5); assert...
code_fim
hard
{ "lang": "rust", "repo": "chiral-data/rust-canonical-numbering", "path": "/src/ext/molecule/extendable_hash.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/picorv32-rt path: /src/lib.rs //! Minimal startup / runtime for PicoRV32 RISC-V CPU //! //! # Minimum Supported Rust Version (MSRV) //! //! This crate is guaranteed to compile on stable Rust 1.32 and up. It *might* //! compile with older versions but that may change in any new patch rele...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/picorv32-rt", "path": "/src/lib.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> } unsafe { // dispatch trap to handler trap_handler( NonNull::new_unchecked(regs as *mut PicoRV32StoredRegisters).as_ref(), irqs, ); } } /// Default Trap Handler #[no_mangle] pub fn default_trap_handler(_irqs: u32) {} #[doc(hidden)] #[no_mangl...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/picorv32-rt", "path": "/src/lib.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jpopesculian/rise-wasm path: /src/funcs/resolver.rs use crate::memory::{AllocatorRef, MemoryWrapper, TableStorage}; use core::fmt; use wasmi::{RuntimeArgs, RuntimeValue, Signature, Trap}; pub trait ResolverTarget { fn memory(self: &Self) -> MemoryWrapper; fn table(self: &Self) -> TableS...
code_fim
medium
{ "lang": "rust", "repo": "jpopesculian/rise-wasm", "path": "/src/funcs/resolver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn gas(self: &Self) -> u64; } impl<T> fmt::Debug for FuncResolver<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FuncResolver") } }<|fim_prefix|>// repo: jpopesculian/rise-wasm path: /src/funcs/resolver.rs use crate::memory::{AllocatorRef, MemoryWrapper, Table...
code_fim
hard
{ "lang": "rust", "repo": "jpopesculian/rise-wasm", "path": "/src/funcs/resolver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub const PF_X: Elf64Word = 0x1; pub const PF_W: Elf64Word = 0x2; pub const PF_R: Elf64Word = 0x4; pub const SHT_NULL: Elf64Word = 0; pub const SHT_PROGBITS: Elf64Word = 1; pub const SHT_SYMTAB: Elf64Word = 2; pub const SHT_STRTAB: Elf64Word = 3; pub const SHT_RELA: Elf64Word = 4; pub const SHT_HASH: Elf...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/rbpf", "path": "/src/elf_parser/consts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub const DT_NULL: Elf64Xword = 0; pub const DT_NEEDED: Elf64Xword = 1; pub const DT_PLTRELSZ: Elf64Xword = 2; pub const DT_PLTGOT: Elf64Xword = 3; pub const DT_HASH: Elf64Xword = 4; pub const DT_STRTAB: Elf64Xword = 5; pub const DT_SYMTAB: Elf64Xword = 6; pub const DT_RELA: Elf64Xword = 7; pub const DT_R...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/rbpf", "path": "/src/elf_parser/consts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solana-labs/rbpf path: /src/elf_parser/consts.rs #![allow(dead_code, missing_docs)] use super::types::*; pub const ELFMAG: [u8; 4] = [0x7F, 0x45, 0x4C, 0x46]; pub const ELFCLASSNONE: u8 = 0; pub const ELFCLASS32: u8 = 1; pub const ELFCLASS64: u8 = 2; pub const ELFDATANONE: u8 = 0; pub const ...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/rbpf", "path": "/src/elf_parser/consts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quodlibetor/cargo-readme path: /tests/alternate-input.rs extern crate assert_cli; use assert_cli::Assert; #[test] fn empty_docs() { let args = [ "readme", "--project-root", "tests/test-project", "--no-template", "--input", "src/no_docs.rs", ...
code_fim
hard
{ "lang": "rust", "repo": "quodlibetor/cargo-readme", "path": "/tests/alternate-input.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Assert::main_binary() .with_args(&args) .succeeds() .prints_exactly(expected) .unwrap(); } #[test] fn a_little_bit_longer() { let args = [ "readme", "--project-root", "tests/test-project", "--no-template", "--input", ...
code_fim
hard
{ "lang": "rust", "repo": "quodlibetor/cargo-readme", "path": "/tests/alternate-input.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lqc/rover path: /crates/rover-client/build.rs use std::fs::{self, read, write}; use camino::Utf8PathBuf as PathBuf; use reqwest::blocking::Client; use uuid::Uuid; /// This script downloads the schema if it's not in the file system /// or if we can detect the user is internet connected. /// ///...
code_fim
hard
{ "lang": "rust", "repo": "lqc/rover", "path": "/crates/rover-client/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let client = Client::new(); let etag_path = PathBuf::from(".schema/etag.id"); let should_update_schema = !(etag_path.exists()) || online::sync::check(None).is_ok(); if should_update_schema { if !(etag_path.exists()) { eprintln!(".schema/etag.id doesn't exist"); ...
code_fim
hard
{ "lang": "rust", "repo": "lqc/rover", "path": "/crates/rover-client/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn update_schema(client: &Client, url: &str) -> std::io::Result<()> { eprintln!("Updating schema."); let response = client .get(url) .send() .expect("Failed to get GraphQL schema from Apollo's schema download url."); let etag = response .headers() .get(...
code_fim
hard
{ "lang": "rust", "repo": "lqc/rover", "path": "/crates/rover-client/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub struct TransactionResponse { pub tx_hash: Hash, } #[derive(Debug, Clone, Copy)] struct CounterApi; impl CounterApi { fn increment( state: &api::ServiceApiState, transaction: Signed<RawTransaction>, ) -> api::Result<TransactionRespo...
code_fim
hard
{ "lang": "rust", "repo": "KateNegrienko/exonum", "path": "/testkit/tests/counter/counter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let tx_hash = transaction.hash(); state.sender().broadcast_transaction(transaction)?; Ok(TransactionResponse { tx_hash }) } fn wire(builder: &mut api::ServiceApiBuilder) { builder .private_scope() .endpoint("count", Self::count) ...
code_fim
hard
{ "lang": "rust", "repo": "KateNegrienko/exonum", "path": "/testkit/tests/counter/counter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KateNegrienko/exonum path: /testkit/tests/counter/counter.rs // Copyright 2018 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.a...
code_fim
hard
{ "lang": "rust", "repo": "KateNegrienko/exonum", "path": "/testkit/tests/counter/counter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crisptrutski/aws-sdk-rust path: /sdk/wafv2/src/client.rs nner .build() .map_err(|err| smithy_http::result::SdkError::ConstructionFailure(err.into()))?; let op = input .make_operation(&self.handle.conf) .map_err(|err| smi...
code_fim
hard
{ "lang": "rust", "repo": "crisptrutski/aws-sdk-rust", "path": "/sdk/wafv2/src/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luke-titley/imgui-docking-rs path: /imgui-sys/src/lib.rs #[cfg(feature = "wasm")] mod wasm_bindings; #[cfg(feature = "wasm")] pub use crate::wasm_bindings::*; #[cfg(not(feature = "wasm"))] mod bindings; #[cfg(not(feature = "wasm"))] pub use crate::bindings::*; impl ImVec2 { #[inline] ...
code_fim
hard
{ "lang": "rust", "repo": "luke-titley/imgui-docking-rs", "path": "/imgui-sys/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ImVec4::new(x, y, z, w) } } impl Into<[f32; 4]> for ImVec4 { #[inline] fn into(self) -> [f32; 4] { [self.x, self.y, self.z, self.w] } } impl Into<(f32, f32, f32, f32)> for ImVec4 { #[inline] fn into(self) -> (f32, f32, f32, f32) { (self.x, self.y, self.z, ...
code_fim
hard
{ "lang": "rust", "repo": "luke-titley/imgui-docking-rs", "path": "/imgui-sys/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_data_structures/owning_ref/mod.rs ice the array without losing ownership or changing type. let arr: BoxRef<[i32]> = arr.map(|arr| &arr[1..3]); assert_eq!(&*arr, &[2, 3]); // Also works for Arc, Rc, String and Vec! } ``` ## Caching...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_data_structures/owning_ref/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Helper trait for erasing the concrete type of what an owner dereferences to, /// for example `Box<T> -> Box<Erased>`. This would be unneeded with /// higher kinded types support in the language. #[allow(unused_lifetimes)] pub unsafe trait IntoErased<'a> { /// Owner with the dereference type substi...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_data_structures/owning_ref/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<O, T: ?Sized> PartialEq for OwningRefMut<O, T> where T: PartialEq { fn eq(&self, other: &Self) -> bool { (&*self as &T).eq(&*other as &T) } } impl<O, T: ?Sized> Eq for OwningRefMut<O, T> where T: Eq {} impl<O, T: ?Sized> PartialOrd for OwningRefMut<O, T> where T: PartialOrd { f...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_data_structures/owning_ref/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oberien/refunct-tas path: /server/src/main.rs use std::collections::HashMap; use std::sync::Arc; use axum::extract::WebSocketUpgrade; use axum::extract::ws::{Message, WebSocket}; use axum::response::{Html, IntoResponse}; use axum::Router; use axum::routing::get; use futures::{SinkExt, StreamExt}...
code_fim
hard
{ "lang": "rust", "repo": "oberien/refunct-tas", "path": "/server/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let request = match serde_json::from_str(&msg) { Ok(request) => request, Err(e) => { log::warn!("Got invalid JSON from player {player_id:?} ({e:?}), disconnecting..."); disconnect().await; return } }; ...
code_fim
hard
{ "lang": "rust", "repo": "oberien/refunct-tas", "path": "/server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samlet/onepiece path: /examples/procs_crossbeam_deque.rs extern crate crossbeam_deque as deque; extern crate crossbeam_utils as utils; extern crate rand; use std::sync::atomic::Ordering::SeqCst; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::sync::{Arc, Mutex}; use deque::Steal::{E...
code_fim
hard
{ "lang": "rust", "repo": "samlet/onepiece", "path": "/examples/procs_crossbeam_deque.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> w.push(3); w.push(4); w.push(5); assert_eq!(s.steal(), Success(3)); assert_eq!(s.steal(), Success(4)); assert_eq!(s.steal(), Success(5)); assert_eq!(s.steal(), Empty); w.push(6); w.push(7); w.push(8); w.push(9); assert_eq!(w.pop(), Some(9)); assert_eq!(...
code_fim
hard
{ "lang": "rust", "repo": "samlet/onepiece", "path": "/examples/procs_crossbeam_deque.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> scope(|scope| { scope.spawn(|_| { for i in 0..STEPS { loop { if let Success(v) = s.steal() { assert_eq!(i, v); break; } } } assert_eq!(s....
code_fim
hard
{ "lang": "rust", "repo": "samlet/onepiece", "path": "/examples/procs_crossbeam_deque.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gfx-rs/naga path: /src/front/interpolator.rs /*! Interpolation defaults. */ impl crate::Binding { /// Apply the usual default interpolation for `ty` to `binding`. /// /// This function is a utility front ends may use to satisfy the Naga IR's /// requirement, meant to ensure that...
code_fim
hard
{ "lang": "rust", "repo": "gfx-rs/naga", "path": "/src/front/interpolator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> location: _, interpolation: ref mut interpolation @ None, ref mut sampling, second_blend_source: _, } = *self { match ty.scalar_kind() { Some(crate::ScalarKind::Float) => { *interpolation = Som...
code_fim
hard
{ "lang": "rust", "repo": "gfx-rs/naga", "path": "/src/front/interpolator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! get_list { ( $t: ty ) => { { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let list: Vec<$t> = line .split_whitespace() .map(|s| s.parse::<$t>().unwrap()) .collect...
code_fim
medium
{ "lang": "rust", "repo": "xCrypt0r/Baekjoon", "path": "/src/11/11908.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xCrypt0r/Baekjoon path: /src/11/11908.rs /** * 11908. 카드 * * 작성자: xCrypt0r * 언어: Rust 2018 * 사용 메모리: 13,028 KB * 소요 시간: 4 ms * 해결 날짜: 2020년 10월 3일 */ <|fim_suffix|> std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ...
code_fim
medium
{ "lang": "rust", "repo": "xCrypt0r/Baekjoon", "path": "/src/11/11908.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leesongun/bitboard_xo path: /examples/console_play_2.rs use bitboard_xo::*; use std::error::Error; use std::io::{stdin, stdout, Write}; /// try read a u8 from console fn read_u8() -> Result<u32, Box<dyn Error>> { let mut user_input = String::new(); stdin().read_line(&mut user_input)?; ...
code_fim
hard
{ "lang": "rust", "repo": "leesongun/bitboard_xo", "path": "/examples/console_play_2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // prompt user and read col from console print!("Input col : "); stdout().flush()?; let col = read_u8()?; // parse row, col into XOPos Ok(XOPos::row_col(row, col)?) }; loop { match try_get_xo_pos() { Ok(xo_pos) => break xo_pos, ...
code_fim
medium
{ "lang": "rust", "repo": "leesongun/bitboard_xo", "path": "/examples/console_play_2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // parse row, col into XOPos Ok(XOPos::row_col(row, col)?) }; loop { match try_get_xo_pos() { Ok(xo_pos) => break xo_pos, Err(err) => println!("{}", err), } } } fn main() -> Result<(), XOError> { // create new XO game let mut ga...
code_fim
hard
{ "lang": "rust", "repo": "leesongun/bitboard_xo", "path": "/examples/console_play_2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} fn part2(lines: &Vec<Vec<char>>) { for jpos in 0..lines.len() { for kpos in (jpos+1)..lines.len() { let mut diff = 0; let mut common: Vec<char> = Vec::new(); for cpos in 0..lines[jpos].len() { if lines[jpos][cpos] == lines[kpos][cpos] { ...
code_fim
hard
{ "lang": "rust", "repo": "gonzus/AdventOfCode", "path": "/attic/rust/c02/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gonzus/AdventOfCode path: /attic/rust/c02/src/main.rs use std::io::{self, BufRead}; fn main() { let mut raw = Vec::new(); let mut sorted = Vec::new(); let stdin = io::stdin(); for line in stdin.lock().lines() { let mut chars: Vec<char> = line.unwrap().chars().collect();...
code_fim
hard
{ "lang": "rust", "repo": "gonzus/AdventOfCode", "path": "/attic/rust/c02/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn part2(lines: &Vec<Vec<char>>) { for jpos in 0..lines.len() { for kpos in (jpos+1)..lines.len() { let mut diff = 0; let mut common: Vec<char> = Vec::new(); for cpos in 0..lines[jpos].len() { if lines[jpos][cpos] == lines[kpos][cpos] { ...
code_fim
hard
{ "lang": "rust", "repo": "gonzus/AdventOfCode", "path": "/attic/rust/c02/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ahupp/exercise path: /aoc2020/day6/src/main.rs use std::io::{self, BufRead}; use std::collections::HashMap; fn all_yes(group: &Vec<String>) -> usize { let mut yes = HashMap::new(); for g in group { for letter in g.chars() { let value = yes.entry(letter).or_insert(0);...
code_fim
medium
{ "lang": "rust", "repo": "ahupp/exercise", "path": "/aoc2020/day6/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let total : usize = groups.iter().map(all_yes).sum(); println!("{}", total); }<|fim_prefix|>// repo: ahupp/exercise path: /aoc2020/day6/src/main.rs use std::io::{self, BufRead}; use std::collections::HashMap; fn all_yes(group: &Vec<String>) -> usize { let mut yes = HashMap::new(); for g ...
code_fim
hard
{ "lang": "rust", "repo": "ahupp/exercise", "path": "/aoc2020/day6/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_overclaimed() { let claims = vec![ "#1 @ 1,3: 4x4".parse().unwrap(), "#2 @ 3,1: 4x4".parse().unwrap(), "#3 @ 5,5: 2x2".parse().unwrap(), ]; assert_eq!(4, overclaimed(&claims, 8, 8)); } pub fn find_unclaimed(claims: &[Claim], width: i32, height: i32) -> i32 { let mut fabric = Fab...
code_fim
hard
{ "lang": "rust", "repo": "CasualX/adventofcode2018", "path": "/src/bin/day3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }