text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: xujihui1985/learningrust path: /sqlite_demo/src/model.rs use bcrypt::BcryptError; use sqlite::Error as SqlErr; #[derive(Debug)] pub struct User { uname: String, pass_hash: String, } #[derive(Debug)] pub enum UBaseErr { DbErr(SqlErr), HashError(BcryptError), } impl From<SqlErr>...
code_fim
hard
{ "lang": "rust", "repo": "xujihui1985/learningrust", "path": "/sqlite_demo/src/model.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn verify(&self, pwd: &str) -> bool { bcrypt::verify(pwd, &self.pass_hash).unwrap_or(false) } } #[cfg(test)] mod tests { use super::*; #[test] fn add_user_test() { let fname = "test_data/users.db"; let ub = UserBase { fname: fname.to_string(), ...
code_fim
hard
{ "lang": "rust", "repo": "xujihui1985/learningrust", "path": "/sqlite_demo/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn add_user_test() { let fname = "test_data/users.db"; let ub = UserBase { fname: fname.to_string(), }; ub.add_user("sean", "hello").unwrap(); assert_eq!(ub.validate_user("sean", "hello").unwrap...
code_fim
hard
{ "lang": "rust", "repo": "xujihui1985/learningrust", "path": "/sqlite_demo/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheNeikos/textwidth-rs path: /src/lib.rs use std::ffi::CString; use std::mem::MaybeUninit; use std::ptr; use thiserror::Error; use x11::xlib; /// XError holds the X11 error message #[derive(Debug, Error)] pub enum XError { /// No X11 display found #[error("X Error: Could not open Displa...
code_fim
hard
{ "lang": "rust", "repo": "TheNeikos/textwidth-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // SAFE because XCreateFontSet always sets both ptrs to NULL or a valid value unsafe { if !missing_ptr.assume_init().is_null() { xlib::XFreeStringList(missing_ptr.assume_init()); } } if !fontset.is_null() { Ok(Context { ...
code_fim
hard
{ "lang": "rust", "repo": "TheNeikos/textwidth-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut t = Tokenizer::new(String::new()); let mut tokens = Vec::new(); tokens.push(Token::new( TokenType::Eof, String::new(), false, String::new(), )); assert_eq!(t.tokens(), tokens); }<|fim_prefix|>// repo: hobo0xcc/liumos path: /app/browser-rs/tests...
code_fim
hard
{ "lang": "rust", "repo": "hobo0xcc/liumos", "path": "/app/browser-rs/tests/tokenizer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hobo0xcc/liumos path: /app/browser-rs/tests/tokenizer.rs #![no_std] #![no_main] #![feature(custom_test_frameworks)] #![test_runner(crate::test_runner)] #![reexport_test_harness_main = "test_main"] extern crate alloc; <|fim_suffix|>#[cfg(test)] entry_point!(main); #[cfg(test)] fn main() { t...
code_fim
hard
{ "lang": "rust", "repo": "hobo0xcc/liumos", "path": "/app/browser-rs/tests/tokenizer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] pub fn test_runner(tests: &[&dyn Testable]) { println!("Running {} tests", tests.len()); for test in tests { test.run(); } } #[cfg(test)] entry_point!(main); #[cfg(test)] fn main() { test_main(); } #[test_case] fn no_input() { let mut t = Tokenizer::new(String::n...
code_fim
medium
{ "lang": "rust", "repo": "hobo0xcc/liumos", "path": "/app/browser-rs/tests/tokenizer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (2..=v.len() / 2).all(|n| { set.iter().copied().combinations(n).all(|p| { let p_sum = p.iter().sum::<usize>(); (&set - &p.iter().copied().collect::<BTreeSet<_>>()) .into_iter() .combinations(n) .all(|q| p_sum != q.iter()....
code_fim
hard
{ "lang": "rust", "repo": "TAKEDA-Takashi/rust-project-euler", "path": "/project-euler/src/bin/problem-105.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TAKEDA-Takashi/rust-project-euler path: /project-euler/src/bin/problem-105.rs //! http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%20105 //! //! 大きさ n の集合 A の要素の和を S(A) で表す. 空でなく共通要素を持たないいかなる 2 つの部分集合 B と C に対しても以下の性質が真であれば, A を特殊和集合と呼ぼう. //! //! i. S(B)≠S(C); つまり, 部分集合の和が等しく...
code_fim
hard
{ "lang": "rust", "repo": "TAKEDA-Takashi/rust-project-euler", "path": "/project-euler/src/bin/problem-105.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self.states } } impl<P: Prop + Clone + 'static> Component for FnComponent<P> { type Props = (Box<dyn ComponentFn<P>>, P); fn render(&self, props: &Self::Props, ctx: Ctx<Self>) -> Vec<Element> { let mut ro = Vec::new(); props.0.call( &props.1, ...
code_fim
hard
{ "lang": "rust", "repo": "TheRawMeatball/hookless", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheRawMeatball/hookless path: /src/lib.rs -> Vec<Element> { props.print_type(); self.render( props.as_any().downcast_ref::<T::Props>().unwrap(), Ctx::new(tx.clone(), id), ) } fn post_mount(&mut self, track: &mut bool, tx: &Tx, id: Component...
code_fim
hard
{ "lang": "rust", "repo": "TheRawMeatball/hookless", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheRawMeatball/hookless path: /src/lib.rs Self { tx: self.tx.clone(), id: self.id, _m: PhantomData, } } } impl<T: 'static> Ctx<T> { pub fn mutate_state<F: FnOnce(&mut T) + Send + 'static>(&self, f: F) { let id = self.id; ...
code_fim
hard
{ "lang": "rust", "repo": "TheRawMeatball/hookless", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>PiHoleInit() { cd ~/.pi-hole if [ -z $(docker compose ps | ag running | ag pihole) ]; then echo 'You have to run docker'; return; fi docker compose exec -it pihole pihole logging off sudo sh -c "echo 'PRIVACYLEVEL=3' >> ./etc-pihole/pihole-FTL.conf" sudo sh -c "echo 'DBINTERVAL=60.0' >> ./etc-pi...
code_fim
hard
{ "lang": "rust", "repo": "igncp/environment", "path": "/src/common_provision/general/pi_hole.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Clients: // Chrome: // Flush DNS cache: `chrome://net-internals/#dns` // Arch Linux: // Update `netctl` profile config to include the IP address // DNS=('192.168.1.X') // If inside a VM with a network using the bridge adapter // Update: `/etc/...
code_fim
hard
{ "lang": "rust", "repo": "igncp/environment", "path": "/src/common_provision/general/pi_hole.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: igncp/environment path: /src/common_provision/general/pi_hole.rs use crate::base::{config::Config, Context}; pub fn setup_pi_hole(context: &mut Context) { if !Config::has_config_file(&context.system, ".config/pi-hole") { return; }; // https://docs.pi-hole.net/guides/dns/unb...
code_fim
hard
{ "lang": "rust", "repo": "igncp/environment", "path": "/src/common_provision/general/pi_hole.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sin-us/sdhk-rs path: /src/game_state.rs extern crate glfw; extern crate cgmath; use gfx::render_target::RenderTarget; use gfx::camera::{Camera, CameraDirection}; use gfx::game_window::Game; use glfw::{Key, Action, WindowEvent}; pub struct GameState<'a> { pub camera: Camera, pub meshes...
code_fim
hard
{ "lang": "rust", "repo": "sin-us/sdhk-rs", "path": "/src/game_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match key { Key::W => self.camera.move_camera(CameraDirection::Forward), Key::S => self.camera.move_camera(CameraDirection::Back), Key::A => { self.camera.move_camera(CameraDirection::Left); }, Key::D => self...
code_fim
hard
{ "lang": "rust", "repo": "sin-us/sdhk-rs", "path": "/src/game_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", event); match event { WindowEvent::Key(key, _, Action::Press, _) | WindowEvent::Key(key, _, Action::Repeat, _) => { for rt in self.meshes.iter_mut() { rt.process_key_pressed(key); }; match ke...
code_fim
hard
{ "lang": "rust", "repo": "sin-us/sdhk-rs", "path": "/src/game_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>== '}' || bracket == ']') && (stack.is_empty() || !stack.ends_with(&[opposite(bracket)])) => { return false; } _ => {} } } stack.is_empty() }<|fim_prefix|>// repo: tarikeshaq/exercism-rust path: /matching-brackets/src...
code_fim
hard
{ "lang": "rust", "repo": "tarikeshaq/exercism-rust", "path": "/matching-brackets/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> && !stack.is_empty() && stack.ends_with(&[opposite(bracket)]) => { stack.pop(); } bracket if (bracket == ')' || bracket == '}' || bracket == ']') && (stack.is_empty() || !stack.e...
code_fim
hard
{ "lang": "rust", "repo": "tarikeshaq/exercism-rust", "path": "/matching-brackets/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarikeshaq/exercism-rust path: /matching-brackets/src/lib.rs fn opposite(bracket: char) -> char { match bracket { '}' => '{', ')' => '(', ']' => '[', _ => panic!("Invalid bracket!"), } } pub fn brackets_are_balanced(string: &str) -> bool { let <|fim_s...
code_fim
hard
{ "lang": "rust", "repo": "tarikeshaq/exercism-rust", "path": "/matching-brackets/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nezdolik/raft-grpc path: /raft/src/lib.rs #![feature(proc_macro, conservative_impl_trait, generators)] #![deny(missing_docs)] //! crate docs #[macro_use] extern crate log; extern crate futures_await as futures; use futures::prelude::*; #[async] fn foo() -> Result<i32> { Ok(1 + await!(...
code_fim
hard
{ "lang": "rust", "repo": "nezdolik/raft-grpc", "path": "/raft/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Server { /// Constructs a ... pub fn new(id: usize) -> Server { Server { id: id, role: Role::Unknown, current_term: None, voted_for: None, log: LinkedList::new(), is_running: false, handle: None ...
code_fim
hard
{ "lang": "rust", "repo": "nezdolik/raft-grpc", "path": "/raft/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Constructs a ... pub fn start() -> () { for n in 0..N_SERVERS { print!("***called for {}", n); let future = start_server(n); } } #[async] fn start_server(id: usize) -> Result<u32>{ print!("called for {}", id); let server = Server::new(id); server.run(); Ok(2) ...
code_fim
hard
{ "lang": "rust", "repo": "nezdolik/raft-grpc", "path": "/raft/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 223kazuki/rust-exercise path: /rust-book/4/workspace/src/main.rs fn main() { { let s = "hello"; } let mut s = String::from("Hello"); s.push_str(", world!"); println!("{}", s); let x = 5; let y = x; println!("{}", x); let mut x = 10; let mut y ...
code_fim
hard
{ "lang": "rust", "repo": "223kazuki/rust-exercise", "path": "/rust-book/4/workspace/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> a_string } fn calculate_length(s: String) -> (String, usize) { let length = s.len(); (s, length) } fn calculate_length2(s: &String) -> usize { s.len() } fn change(some_string: &mut String) { some_string.push_str("AAA"); } fn not_dungle(s1: &String) -> &String { let s2 = String...
code_fim
hard
{ "lang": "rust", "repo": "223kazuki/rust-exercise", "path": "/rust-book/4/workspace/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yvt/query_interface path: /src/lib.rs let mut u = $crate::TraitObject { data: data as *const (), vtable: vtable }; Ok(Box::from_raw(*::std::mem::transmute::<_, &mut *mut U>(&mut u))) } } else { Err(self) ...
code_fim
hard
{ "lang": "rust", "repo": "yvt/query_interface", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yvt/query_interface path: /src/lib.rs { unsafe { let data = Box::into_raw(self); let mut u = $crate::TraitObject { data: data as *const (), vtable: vtable }; Ok(Box::from_raw(*::std::mem::transmute::<_, ...
code_fim
hard
{ "lang": "rust", "repo": "yvt/query_interface", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(o) = other.query_ref::<Self>() { Some(self.cmp(o)) } else { None } } } /// This is an object-safe version of `Hash`, which is automatically /// implemented for all `Hash + Object` types. This is a support trait used to /// allow `Object` tra...
code_fim
hard
{ "lang": "rust", "repo": "yvt/query_interface", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaini/eink-clock path: /timekeeper/src/rawhw/nvic.rs pub const CT16B0: i32 = 13; pub const RTC: i32 = 30; <|fim_suffix|> scr 0xE000ED10 => { 4, sevonpend, bool; 2, sleepdeep, bool; 1, sleeponexit, bool; } }<|fim_middle|>register_block! { iser 0xE000E1...
code_fim
medium
{ "lang": "rust", "repo": "kaini/eink-clock", "path": "/timekeeper/src/rawhw/nvic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> scr 0xE000ED10 => { 4, sevonpend, bool; 2, sleepdeep, bool; 1, sleeponexit, bool; } }<|fim_prefix|>// repo: kaini/eink-clock path: /timekeeper/src/rawhw/nvic.rs pub const CT16B0: i32 = 13; pub const RTC: i32 = 30; <|fim_middle|>register_block! { iser 0xE000E1...
code_fim
medium
{ "lang": "rust", "repo": "kaini/eink-clock", "path": "/timekeeper/src/rawhw/nvic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fraang/userutils path: /src/bin/groupadd.rs #![deny(warnings)] extern crate arg_parser; extern crate extra; extern crate redox_users; use extra::option::OptionalExt; use std::{io, env}; use std::io::Write; use std::process::exit; use arg_parser::ArgParser; use redox_users::{add_group, get_un...
code_fim
hard
{ "lang": "rust", "repo": "fraang/userutils", "path": "/src/bin/groupadd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let gid = match get_unique_group_id() { Some(gid) => gid, None => { eprintln!("groupadd: no available gid"); exit(1); } }; match add_group(groupname, gid, &[""]) { Ok(_) => {}, Err(ref err) if err.kind() == io::ErrorKind::Alr...
code_fim
hard
{ "lang": "rust", "repo": "fraang/userutils", "path": "/src/bin/groupadd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run(&mut self) { for &entity in self.1.iter() { let a = self.0.get_component_mut::<A>(entity).unwrap(); criterion::black_box(a); } } }<|fim_prefix|>// repo: BoxyUwU/ecs_bench_suite path: /src/ellecs/get.rs use ellecs::entities::Entity; use ellecs::sp...
code_fim
medium
{ "lang": "rust", "repo": "BoxyUwU/ecs_bench_suite", "path": "/src/ellecs/get.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BoxyUwU/ecs_bench_suite path: /src/ellecs/get.rs use ellecs::entities::Entity; use ellecs::spawn; use ellecs::world::World; pub struct A(f32); pub struct Benchmark(World, Box<[Entity]>); impl Benchmark { pub fn new() -> Self { let mut world = World::new(); let mut entities...
code_fim
medium
{ "lang": "rust", "repo": "BoxyUwU/ecs_bench_suite", "path": "/src/ellecs/get.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yhakbar/ya path: /tests/multi-step.rs #[cfg(test)] mod multi_step { use anyhow::Result; use assert_cmd::Command; fn ya() -> Command { Command::cargo_bin(env!("CARGO_PKG_NAME")).expect("Error invoking ya") } <|fim_suffix|> ya().args(["-c", "examples/multi-step/.con...
code_fim
medium
{ "lang": "rust", "repo": "yhakbar/ya", "path": "/tests/multi-step.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ya().args(["-c", "examples/multi-step/.config/ya.yml", "multi_step"]) .assert() .success() .stdout("These are the pre-commands. They will run before the main command.\nMain command\nThese are the post-commands. They will run after the main command.\n"); ...
code_fim
medium
{ "lang": "rust", "repo": "yhakbar/ya", "path": "/tests/multi-step.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: probe-rs/probe-rs path: /probe-rs/src/bin/probe-rs/cmd/dump.rs use std::time::Instant; use probe_rs::MemoryInterface; use crate::util::{common_options::ProbeOptions, parse_u32, parse_u64}; use crate::CoreOptions; #[derive(clap::Parser)] pub struct Cmd { #[clap(flatten)] shared: CoreOp...
code_fim
hard
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/probe-rs/src/bin/probe-rs/cmd/dump.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Cmd { pub fn run(self) -> anyhow::Result<()> { let (mut session, _probe_options) = self.common.simple_attach()?; let mut data = vec![0_u32; self.words as usize]; // Start timer. let instant = Instant::now(); // let loc = 220 * 1024; let mut core...
code_fim
hard
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/probe-rs/src/bin/probe-rs/cmd/dump.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let hm: Vec<&str> = time.split(' ').collect(); let hm: Vec<&str> = hm[1].split(':').collect(); (hm[0].parse::<u32>().unwrap(), hm[1].parse::<u32>().unwrap()) } fn set_asleep(mut guards: HashMap<String, Vec<u32>>, id: &str, begin: u32, end: u32) -> HashMap<String, Vec<u32>> { let guard = g...
code_fim
hard
{ "lang": "rust", "repo": "tony612/adventofcode", "path": "/src/day4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tony612/adventofcode path: /src/day4.rs use std::fs; use regex::Regex; use std::collections::HashMap; pub fn run() { let body = fs::read_to_string("./input/day4.txt").expect("couldn't read the input file"); let line_re = Regex::new(r"\[(.+)\] (.+)").unwrap(); let mut lines: Vec<(&st...
code_fim
hard
{ "lang": "rust", "repo": "tony612/adventofcode", "path": "/src/day4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sn99/pokemon-text-game path: /src/main.rs } else { game_play(); } } else if choice == 2 { println!("\nCharacters Available\n========================"); for i in 0..total_pokemons { println!( "{}.{}", i + 1, ...
code_fim
hard
{ "lang": "rust", "repo": "sn99/pokemon-text-game", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if player2_pokemon.health_check() { println!( "\n========================\nPlayer 1 wins with pokemon {}", player1_pokemon.name ); pri...
code_fim
hard
{ "lang": "rust", "repo": "sn99/pokemon-text-game", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sn99/pokemon-text-game path: /src/main.rs i + 1, &json["pokemons"][i]["name"].as_str().unwrap() ); } println!("Enter Character to edit : "); let choice = i64_input(); if choice as usize > total_pokemons { println!("\n====...
code_fim
hard
{ "lang": "rust", "repo": "sn99/pokemon-text-game", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: angered-ghandi/OpenAOE path: /crates/resource/src/game_dir.rs // OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentatio...
code_fim
hard
{ "lang": "rust", "repo": "angered-ghandi/OpenAOE", "path": "/crates/resource/src/game_dir.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let game_dir = GameDir { dir: dir.to_path_buf() }; for file_name in &["language.dll", "data/border.drs", "data/empires.dat", "data/graphics.drs", "data/interfac.drs", ...
code_fim
hard
{ "lang": "rust", "repo": "angered-ghandi/OpenAOE", "path": "/crates/resource/src/game_dir.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let parsed_map: LooseMap = *s.downcast::<LooseMap>().unwrap(); Ok(Self { filename: filename.to_string(), parsed_map, idx: 0, }) } pub fn filename(self) -> String { return self.filename; ...
code_fim
hard
{ "lang": "rust", "repo": "erikh/steam-shortcut-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn read_next_string(handle: &mut Bytes<File>) -> String { String::from_utf8( handle .take_while(|c| match *c { Ok(c) => c != TERMINATOR_STRING, _ => false, }) .map(|c| c.unwrap()) ...
code_fim
hard
{ "lang": "rust", "repo": "erikh/steam-shortcut-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erikh/steam-shortcut-rs path: /src/lib.rs use std::{collections::HashMap, time::SystemTime}; #[derive(Debug, Clone)] pub struct Shortcut { id: u32, app_name: String, exe: String, start_dir: String, is_hidden: bool, icon: String, launch_options: String, allow_desk...
code_fim
hard
{ "lang": "rust", "repo": "erikh/steam-shortcut-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ccc = c2 / 3; println!("{}", can + cca + ccc); } } fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).expect("failed to read"); buf.trim().parse().unwrap() } fn read_vec<T>() -> Vec<...
code_fim
medium
{ "lang": "rust", "repo": "ducktail/aoj", "path": "/vol02/rust/q0281.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ducktail/aoj path: /vol02/rust/q0281.rs use std::cmp; fn main(){ let q: usize = read(); for _ in 0 .. q { let vcan: Vec<u32> = read_vec(); let c = vcan[0]; let a = vcan[1]; let n = vcan[2]; <|fim_suffix|> let cca = cmp::min(c1 / 2, a1); let c2 = c1 - 2 * cca; l...
code_fim
medium
{ "lang": "rust", "repo": "ducktail/aoj", "path": "/vol02/rust/q0281.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: albinekb/rust-oled path: /src/main.rs use std::error::Error; use std::{thread, time}; // use std::time::Duration; use embedded_graphics::{ fonts::{Font6x12, Font6x8, Text}, image::{Image, ImageRaw}, pixelcolor::BinaryColor, prelude::*, style::TextStyleBuilder, }; use displ...
code_fim
hard
{ "lang": "rust", "repo": "albinekb/rust-oled", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> disp: &mut GraphicsMode< display_interface_spi::SPIInterface<rppal::spi::Spi, OutputPin, OutputPin>, >, ) { let text_style = TextStyleBuilder::new(Font6x8) .text_color(BinaryColor::On) .build(); Text::new("Eyes Everywhere - Tochal", Point::zero()) .into_sty...
code_fim
hard
{ "lang": "rust", "repo": "albinekb/rust-oled", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut sponge = Keccak::new_keccak256(); sponge.update(&data); sponge.finalize(&mut result); result.to_vec() } #[cfg(test)] mod tests { use rustc_serialize::hex::FromHex; use spec::ParamType; use super::signature; #[test] fn test_signature() { assert_eq!("cdcd77c0".from_hex().unwrap(), signa...
code_fim
hard
{ "lang": "rust", "repo": "gancherj/ethabi", "path": "/src/signature.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gancherj/ethabi path: /src/signature.rs use tiny_keccak::Keccak; use spec::ParamType; use spec::param_type::Writer; pub fn signature(name: &str, params: &[ParamType]) -> Vec<u8> { let types = params.iter() .map(Writer::write) .collect::<Vec<String>>() .join(","); let data: Vec<u8> = Fr...
code_fim
medium
{ "lang": "rust", "repo": "gancherj/ethabi", "path": "/src/signature.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let data: Vec<u8> = From::from(format!("{}({})", name, types).as_ref() as &str); let mut result = [0u8; 4]; let mut sponge = Keccak::new_keccak256(); sponge.update(&data); sponge.finalize(&mut result); result.to_vec() } #[cfg(test)] mod tests { use rustc_serialize::hex::FromHex; use spec::ParamT...
code_fim
medium
{ "lang": "rust", "repo": "gancherj/ethabi", "path": "/src/signature.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, device: &wgpu::Device, delta: f32, spawner: &LocalSpawner, ) -> Vec<wgpu::CommandBuffer> { let focus_point = self.cam.intersect_height(level::HEIGHT_SCALE as f32 * 0.3); if let Some(ref mut jump) = self.jump { let power = delta * ...
code_fim
hard
{ "lang": "rust", "repo": "lolmaus/vange-rs", "path": "/bin/road/game.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lolmaus/vange-rs path: /bin/road/game.rs ( format!("Other-{}", i), &db.cars[car_id], color, (x, y), rng.gen(), &level, gpu.as_mut().map(|Gpu { ref mut store, .. }| store), ...
code_fim
hard
{ "lang": "rust", "repo": "lolmaus/vange-rs", "path": "/bin/road/game.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lolmaus/vange-rs path: /bin/road/game.rs size>, last_control: Control, }, } enum SimulationStep<'a> { Intermediate, Final { focus_point: &'a cgmath::Point3<f32>, line_buffer: Option<&'a mut LineBuffer>, }, } pub struct Agent { _name: String, spir...
code_fim
hard
{ "lang": "rust", "repo": "lolmaus/vange-rs", "path": "/bin/road/game.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 11Takanori/linkerd2-proxy path: /linkerd/fallback/src/lib.rs #![deny(warnings, rust_2018_idioms)] use futures::{try_ready, Future, Poll}; use linkerd2_error::Error; use tracing::trace; /// A fallback layer composing two service builders. /// /// If the future returned by the primary builder's ...
code_fim
hard
{ "lang": "rust", "repo": "11Takanori/linkerd2-proxy", "path": "/linkerd/fallback/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<A, B, P, T> Future for MakeFuture<A, B, P, T> where A: Future, A::Error: Into<Error>, B: tower::Service<T>, B::Response: Into<A::Item>, B::Error: Into<Error>, P: Fn(&Error) -> bool, { type Item = A::Item; type Error = Error; fn poll(&mut self) -> Poll<Self::Item, ...
code_fim
hard
{ "lang": "rust", "repo": "11Takanori/linkerd2-proxy", "path": "/linkerd/fallback/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AzureCloudMonk/antisamples path: /tests/compile-fail/expressions_match_exhaustive.rs // error-pattern: non-exhaustive patterns enum Suit { Books, Bugs, Fromps, Zurfs } enum Rank { Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace } <|fim_suffix|> use ...
code_fim
medium
{ "lang": "rust", "repo": "AzureCloudMonk/antisamples", "path": "/tests/compile-fail/expressions_match_exhaustive.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { use self::Suit::*; use self::Rank::*; let card = Card { rank: Three, suit: Fromps }; let score = match card.rank { Jack => 10, Queen => 10, Ace => 11 }; // error: nonexhaustive patterns println!("{}", score); }<|fim_prefix|>// repo: AzureCloudM...
code_fim
medium
{ "lang": "rust", "repo": "AzureCloudMonk/antisamples", "path": "/tests/compile-fail/expressions_match_exhaustive.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let score = match card.rank { Jack => 10, Queen => 10, Ace => 11 }; // error: nonexhaustive patterns println!("{}", score); }<|fim_prefix|>// repo: AzureCloudMonk/antisamples path: /tests/compile-fail/expressions_match_exhaustive.rs // error-pattern: non-exhaustive pa...
code_fim
medium
{ "lang": "rust", "repo": "AzureCloudMonk/antisamples", "path": "/tests/compile-fail/expressions_match_exhaustive.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryantate13/wc path: /rust/wc.rs use std::io; use std::io::Read; fn isspace(c: char) -> bool { <|fim_suffix|> let mut word_count: u32 = 0; let mut in_space: bool = true; for c in io::stdin().lock().bytes() { if isspace(c.unwrap().into()) { in_space = true; ...
code_fim
medium
{ "lang": "rust", "repo": "ryantate13/wc", "path": "/rust/wc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut word_count: u32 = 0; let mut in_space: bool = true; for c in io::stdin().lock().bytes() { if isspace(c.unwrap().into()) { in_space = true; } else { if in_space { word_count += 1; } in_space = false; ...
code_fim
medium
{ "lang": "rust", "repo": "ryantate13/wc", "path": "/rust/wc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut word_count: u32 = 0; let mut in_space: bool = true; for c in io::stdin().lock().bytes() { if isspace(c.unwrap().into()) { in_space = true; } else { if in_space { word_count += 1; } in_space = fa...
code_fim
medium
{ "lang": "rust", "repo": "ryantate13/wc", "path": "/rust/wc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OpenFlowLabs/ports path: /specfile/src/macros.rs use pest::Parser; use crate::errors::Result; use std::collections::HashMap; use failure::Fail; #[derive(Debug, Fail)] pub enum MacroParserError { #[fail(display = "macro does not exist: {}", macro_name)] DoesNotExist { macro_name:...
code_fim
hard
{ "lang": "rust", "repo": "OpenFlowLabs/ports", "path": "/specfile/src/macros.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if i == 0 { return_string += &replaced_line; } else { return_string += "\n"; return_string += &replaced_line; } } Ok(return_string) } fn get_variable(&self, macro_name: &str) -> Result<&str> { ...
code_fim
hard
{ "lang": "rust", "repo": "OpenFlowLabs/ports", "path": "/specfile/src/macros.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return Some(( method.clone(), serde_json::Value::from_str(raw_output.as_str()).expect("Somethng Wend wronfs"), )); } else { dbg!("External command failed:"); let err = String::from_utf8(output.stderr).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "talbergs/vim_son_rpc", "path": "/src/core/eventhandler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: talbergs/vim_son_rpc path: /src/core/eventhandler.rs use neovim_lib::neovim_api::{Buffer, Tabpage}; use neovim_lib::{Neovim, NeovimApi, Session, Utf8String, Value}; use std::convert::TryInto; use std::num::ParseIntError; use std::str::FromStr; use std::time::Duration; use super::client::Client...
code_fim
hard
{ "lang": "rust", "repo": "talbergs/vim_son_rpc", "path": "/src/core/eventhandler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !self.client.is_authorized() { self.client.login(); self.nvim .set_var("son_state", State::son_state(&self)) .unwrap(); } let buf_params = Buffer::new(bufs.get(0).unwrap().clone()); let buf_resp = Buffer::new(bufs....
code_fim
hard
{ "lang": "rust", "repo": "talbergs/vim_son_rpc", "path": "/src/core/eventhandler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuval-k/connect path: /src/animations/mod.rs use std; use palette; use bit_set; use std::ops::Rem; pub mod idle; pub mod touch; use super::NUM_POLES; const LED_ANIM_DURATION: u64 = 10; fn to_float(t: std::time::Duration) -> f32 { t.as_secs() as f32 + t.subsec_nanos() as f32 / 1_000_000...
code_fim
hard
{ "lang": "rust", "repo": "yuval-k/connect", "path": "/src/animations/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cur_pole = &mut poles[i]; let new_state = { if !is_self_touching && current_touches.is_empty() { super::PoleState::NotTouched } else if is_self_touching && current_touches.is_empty() { ...
code_fim
hard
{ "lang": "rust", "repo": "yuval-k/connect", "path": "/src/animations/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl convert::From<io::Error> for WalletError { fn from(err: io::Error) -> WalletError { WalletError::IO(err) } } impl convert::From<bip32::Error> for WalletError { fn from(err: bip32::Error) -> WalletError { WalletError::KeyDerivation(err) } } impl convert::From<symmetri...
code_fim
hard
{ "lang": "rust", "repo": "LightningPeach/rust-wallet", "path": "/wallet/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LightningPeach/rust-wallet path: /wallet/src/error.rs // // Copyright 2018 rust-wallet developers // // 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....
code_fim
hard
{ "lang": "rust", "repo": "LightningPeach/rust-wallet", "path": "/wallet/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nutty7t/playground path: /rust/book/variables/src/main.rs fn main() { let mut x = 5; println!("The value of x is: {}", x); x = 6; println!("The value of x is: {}<|fim_suffix|>t the values of constant variables may only be constant expressions -- // expressions whose values ca...
code_fim
medium
{ "lang": "rust", "repo": "nutty7t/playground", "path": "/rust/book/variables/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>t the values of constant variables may only be constant expressions -- // expressions whose values can only be computed at compile-time. const MAX_POINTS: u32 = 100_000; println!("The value of MAX_POINTS is: {}", MAX_POINTS); }<|fim_prefix|>// repo: nutty7t/playground path: /rust/book/variabl...
code_fim
medium
{ "lang": "rust", "repo": "nutty7t/playground", "path": "/rust/book/variables/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_big_box_space_sample() { let box_space = Space::BOX { shape: vec![3, 2, 2], high: vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.], low: vec![-1., -2., -3., -4., -5., -6., -7., -8., -9., -10., -11., -12.] }; for _ in 0..NUM_SAMPLES { let sample = box_space.sample(); a...
code_fim
hard
{ "lang": "rust", "repo": "NivenT/gym-http-api", "path": "/binding-rust/tests/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NivenT/gym-http-api path: /binding-rust/tests/lib.rs extern crate gym; use gym::*; const NUM_SAMPLES: usize = 25; #[test] fn test_discrete_space_sample() { let discrete_space = Space::DISCRETE{n: 15}; for _ in 0..NUM_SAMPLES { let sample = discrete_space.sample(); assert!(sample.len() =...
code_fim
hard
{ "lang": "rust", "repo": "NivenT/gym-http-api", "path": "/binding-rust/tests/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let discrete_space = Space::DISCRETE{n: 15}; let box_space = Space::BOX { shape: vec![5], high: vec![1., 2., 3., 4., 5.], low: vec![-1., -2., -3., -4., -5.] }; let tuple_space = Space::TUPLE { spaces: vec![ Box::new(discrete_space), Box::new(box_space) ] }; for _ in 0..NUM_SAMPLE...
code_fim
hard
{ "lang": "rust", "repo": "NivenT/gym-http-api", "path": "/binding-rust/tests/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kluzynskn6/main-server path: /backend/src/departments/requests.rs use diesel; use diesel::mysql::Mysql; use diesel::mysql::MysqlConnection; use diesel::query_builder::AsQuery; use diesel::query_builder::BoxedSelectStatement; use diesel::ExpressionMethods; use diesel::QueryDsl; use diesel::RunQue...
code_fim
hard
{ "lang": "rust", "repo": "kluzynskn6/main-server", "path": "/backend/src/departments/requests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut inserted_user_departments = user_departments_schema::table .filter(diesel::dsl::sql("id = LAST_INSERT_ID()")) .load::<UserDepartment>(database_connection)?; if let Some(inserted_user_departments) = inserted_user_departments.pop() { trace!("Successfully created user...
code_fim
hard
{ "lang": "rust", "repo": "kluzynskn6/main-server", "path": "/backend/src/departments/requests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jean553/array-merge path: /array-merge/src/lib.rs pub mod am { /// Takes one source array, divides it into two arrays using `start`, `middle` and `end` /// delimiters. Overwrites the destination array. #[allow(dead_code)] pub fn merge( source: &mut [u8], destinat...
code_fim
medium
{ "lang": "rust", "repo": "jean553/array-merge", "path": "/array-merge/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for index in start..end { if (j >= end || source[i] <= source[j]) && i < middle { destination[index] = source[i]; i += 1; } else { destination[index] = source[j]; j += 1; } ...
code_fim
medium
{ "lang": "rust", "repo": "jean553/array-merge", "path": "/array-merge/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chemouna/AlgorithmsRust path: /algorithms/src/explore_quickcheck.rs #[cfg(test)] #[macro_use] extern crate quickcheck; #[cfg(test)] mod tests { use quickcheck::TestResult; <|fim_suffix|> quickcheck! { fn prop_one_element_vector_same(xs: Vec<isize>) -> TestResult { i...
code_fim
medium
{ "lang": "rust", "repo": "chemouna/AlgorithmsRust", "path": "/algorithms/src/explore_quickcheck.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if xs.len() != 1 { return TestResult::discard() } TestResult::from_bool(xs == reverse(&*xs)) } } }<|fim_prefix|>// repo: chemouna/AlgorithmsRust path: /algorithms/src/explore_quickcheck.rs #[cfg(test)] #[macro_use] extern crate quickcheck;...
code_fim
medium
{ "lang": "rust", "repo": "chemouna/AlgorithmsRust", "path": "/algorithms/src/explore_quickcheck.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> quickcheck! { fn prop_one_element_vector_same(xs: Vec<isize>) -> TestResult { if xs.len() != 1 { return TestResult::discard() } TestResult::from_bool(xs == reverse(&*xs)) } } }<|fim_prefix|>// repo: chemouna/AlgorithmsRust path:...
code_fim
medium
{ "lang": "rust", "repo": "chemouna/AlgorithmsRust", "path": "/algorithms/src/explore_quickcheck.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> NibVec::new() } } impl slice::private::Sealed for NibVec { #[inline(always)] fn has_left_hi(&self) -> bool { true } #[inline(always)] fn has_right_lo(&self) -> bool { self.as_slice().has_right_lo() } #[inline(always)] fn iter(&self) -> stdslice::Iter<u4x2> { self.inner....
code_fim
hard
{ "lang": "rust", "repo": "joelburget/nibble", "path": "/src/vec.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joelburget/nibble path: /src/vec.rs //! Types for arrays of nibbles. use std::{slice as stdslice, mem}; use base::{u4lo, u4}; use pair::u4x2; use slice::{self, NibSliceAligned, NibSliceAlignedMut, NibSliceFull, NibSliceNoR}; use common::{get_nib, set_nib, shift_left, shift_right}; use quickcheck...
code_fim
hard
{ "lang": "rust", "repo": "joelburget/nibble", "path": "/src/vec.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..vec1.len() { okay = okay && get_nib::<u4lo>(vec1_copy_slice, i) == get_nib::<u4lo>(vec1_slice, i); } for i in 0..vec2.len() { okay = okay && get_nib::<u4lo>(vec...
code_fim
hard
{ "lang": "rust", "repo": "joelburget/nibble", "path": "/src/vec.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NlsDKps/pervau path: /src/lib.rs # ![feature(proc_macro_hygiene, decl_macro)]<|fim_suffix|> pub mod model; pub mod schema; pub mod view;<|fim_middle|> #[macro_use]extern crate diesel; #[macro_use] extern crate rocket; pub mod controller;
code_fim
medium
{ "lang": "rust", "repo": "NlsDKps/pervau", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub mod model; pub mod schema; pub mod view;<|fim_prefix|>// repo: NlsDKps/pervau path: /src/lib.rs # ![feature(proc_macro_hygiene, decl_macro)]<|fim_middle|> #[macro_use]extern crate diesel; #[macro_use] extern crate rocket; pub mod controller;
code_fim
medium
{ "lang": "rust", "repo": "NlsDKps/pervau", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NlsDKps/pervau path: /src/lib.rs # ![feature(proc_macro_hygiene, decl_macro)] #[macro_use]extern crate diesel; #[macro_us<|fim_suffix|> pub mod model; pub mod schema; pub mod view;<|fim_middle|>e] extern crate rocket; pub mod controller;
code_fim
easy
{ "lang": "rust", "repo": "NlsDKps/pervau", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run_intcode(intcode: &[i64], inputs: &[i64]) -> Computer { let mut computer = Computer::new(intcode, inputs); computer.run().unwrap(); computer } pub fn load_intcode(path: &str) -> Vec<i64> { fs::read_to_string(path) .unwrap() .trim() .split(',') .ma...
code_fim
hard
{ "lang": "rust", "repo": "BobuSumisu/aoc19", "path": "/intcode/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn last_output(&self) -> Option<i64> { self.outputs.last().cloned() } pub fn patch(&mut self, patch: (i64, i64)) { self.memory[1] = patch.0; self.memory[2] = patch.1; } pub fn get_patch(&self) -> (i64, i64) { (self.memory[1], self.memory[2]) } ...
code_fim
hard
{ "lang": "rust", "repo": "BobuSumisu/aoc19", "path": "/intcode/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BobuSumisu/aoc19 path: /intcode/src/lib.rs use std::convert::{TryFrom, TryInto}; use std::fs; enum Op { Add, Multiply, Read, Write, JumpIfTrue, JumpIfFalse, LessThan, Equals, AdjustBase, Halt, } impl TryFrom<i64> for Op { type Error = String; fn...
code_fim
hard
{ "lang": "rust", "repo": "BobuSumisu/aoc19", "path": "/intcode/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> / ("NEXT" / "next" ) { nodes("next", vec![]) } / ("COLOR" / "color") _ e:expression() { nodes("color", vec![e]) } / ("FLIP" / "flip") { nodes("flip", vec![]) } / ("MODE" / "mode") _ i:integer() { nodes("mode", vec![i]) } / ("RETURN" / "return")...
code_fim
hard
{ "lang": "rust", "repo": "fazibear/fazic", "path": "/fazic_mono/src/fazic/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fazibear/fazic path: /fazic_mono/src/fazic/parser.rs peg::parser!( pub grammar parser() for str { use fazic::enums::*; use fazic::nodes::*; pub rule parse_all() -> Entry = i:integer() _ a:(all() ++ ":") { entry_node(&Some(i), a) } / a:(all() ...
code_fim
hard
{ "lang": "rust", "repo": "fazibear/fazic", "path": "/fazic_mono/src/fazic/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }