text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: memoryruins/rendy-pbr path: /src/main.rs #![cfg_attr( not(any(feature = "dx12", feature = "metal", feature = "vulkan")), allow(unused) )] use rendy::{ command::{Supports, Graphics}, factory::{Config, Factory}, graph::{present::PresentNode, render::*, GraphBuilder}, memor...
code_fim
hard
{ "lang": "rust", "repo": "memoryruins/rendy-pbr", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn current_offset(&self) -> usize { self.iter.byte_offset() } } impl<'de, I: Deserialize<'de>> Iterator for LogPartitionIter<'de, I> { type Item = I; fn next(&mut self) -> Option<Self::Item> { self.iter.next().map(|item| item.unwrap()) } } // struct LogPartitionR...
code_fim
hard
{ "lang": "rust", "repo": "Wietse/kvs-rs", "path": "/src/log.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wietse/kvs-rs path: /src/log.rs // #![allow(dead_code)] // #![allow(unused_variables)] // #![allow(unused_imports)] use std::{ self, mem, io::{Read, Write, Seek, SeekFrom, ErrorKind}, fs::{self, File, OpenOptions}, collections::{HashMap, VecDeque}, path::{Path, PathBuf},...
code_fim
hard
{ "lang": "rust", "repo": "Wietse/kvs-rs", "path": "/src/log.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let acl_tx = self.acl.tx.clone(); ctx.spawn(async move { acl_tx.send(AclPacket::parse(&data.take_payload()).unwrap()).await.unwrap(); sink.success(Empty::default()).await.unwrap(); }); } fn send_sco(&mut self, _ctx: RpcContext<'_>, _sco: Data, _sink...
code_fim
hard
{ "lang": "rust", "repo": "LineageOS/android_system_bt", "path": "/gd/rust/hal/src/facade.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LineageOS/android_system_bt path: /gd/rust/hal/src/facade.rs //! BT HCI HAL facade use crate::{AclHal, ControlHal, IsoHal}; use bt_common::GrpcFacade; use bt_facade_helpers::RxAdapter; use bt_facade_proto::common::Data; use bt_facade_proto::empty::Empty; use bt_facade_proto::hal_facade_grpc::{c...
code_fim
hard
{ "lang": "rust", "repo": "LineageOS/android_system_bt", "path": "/gd/rust/hal/src/facade.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Emulate the behavior of [reallocf](https://linux.die.net/man/3/reallocf). pub fn rcutils_reallocf( pointer: *mut c_void, size: usize, allocator: *mut rcutils_allocator_t, ) -> *mut c_void; }<|fim_prefix|>// repo: koukemo/rclrust path: /rcl-sys/src/rcutils/allocator...
code_fim
hard
{ "lang": "rust", "repo": "koukemo/rclrust", "path": "/rcl-sys/src/rcutils/allocator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koukemo/rclrust path: /rcl-sys/src/rcutils/allocator.rs //! API in rcutils/allocator.h use std::os::raw::c_void; /// Encapsulation of an allocator. #[repr(C)] #[derive(Debug)] pub struct rcutils_allocator_t { /// Allocate memory, given a size and the `state` pointer. pub allocate: Opti...
code_fim
hard
{ "lang": "rust", "repo": "koukemo/rclrust", "path": "/rcl-sys/src/rcutils/allocator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Return a properly initialized rcutils_allocator_t with default values. pub fn rcutils_get_default_allocator() -> rcutils_allocator_t; /// Return true if the given allocator has non-null function pointers. pub fn rcutils_allocator_is_valid(allocator: *const rcutils_allocator_t) -> bool...
code_fim
medium
{ "lang": "rust", "repo": "koukemo/rclrust", "path": "/rcl-sys/src/rcutils/allocator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod notify { use super::*; pub fn notify_subcommand() -> App<'static, 'static> { SubCommand::with_name("notify") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) .about("notification api") .long_about("This command mani...
code_fim
hard
{ "lang": "rust", "repo": "Hosshii/qui", "path": "/src/cli/clap_app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hosshii/qui path: /src/cli/clap_app.rs use clap::{App, Arg, SubCommand}; const BANNER: &str = " _ ___ ___ __(_) / _ `/ // / / \\_, /\\_,_/_/ /_/ "; pub fn clap_app() -> App<'static, 'static> { let clap_app = App::new(env!("CARGO_PKG_NAME")) .version(env!...
code_fim
hard
{ "lang": "rust", "repo": "Hosshii/qui", "path": "/src/cli/clap_app.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/resol-vbus.rs path: /src/live_data_recording_writer.rs use std::io::{Result, Write}; use chrono::{DateTime, UTC}; use recording_encoder::{bytes_from_timestamp, bytes_from_record}; /// A `RecordingWriter` for type 0x88 live data recordings. #[derive(Debug)] pub struct LiveDataRecordi...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/resol-vbus.rs", "path": "/src/live_data_recording_writer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { let mut ldrw = LiveDataRecordingWriter::new(&mut bytes); let start_timestamp = UTC.timestamp(1486857602, 94000000); let end_timestamp = UTC.timestamp(1486857602, 95000000); let data = &[170, 16, 0, 17, 126, 16, 0, 1, 27, 52, 56, 34, 56, 34, 5, 70,...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/resol-vbus.rs", "path": "/src/live_data_recording_writer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let container = Container::new(&self.docker, &self.id); container.kill(None); } fn detect_crash(&mut self, rt: &mut Runtime) -> bool { let container = Container::new(&self.docker, &self.id); match rt.block_on(container.inspect()) { Ok(details) => { ...
code_fim
hard
{ "lang": "rust", "repo": "adeboyed/Parliament", "path": "/MemberOfParliament/src/executor/docker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adeboyed/Parliament path: /MemberOfParliament/src/executor/docker.rs /* Parliament - A distributed general-purpose cluster-computing framework for OCaml Copyright (c) 2018-2019 [Name REDACTED] [Email REDACTED] */ use std::sync::{Arc, RwLock, Mutex}; use std::collections::HashMap; use c...
code_fim
hard
{ "lang": "rust", "repo": "adeboyed/Parliament", "path": "/MemberOfParliament/src/executor/docker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = recursive_circus::find_root(&node_map); println!("{:?}", result); }<|fim_prefix|>// repo: onelson/advent-of-code-2017 path: /src/bin/day07a.rs extern crate aoc; use std::env; use aoc::recursive_circus; fn main() { let args = env::args().collect::<Vec<String>>(); let fp = ...
code_fim
medium
{ "lang": "rust", "repo": "onelson/advent-of-code-2017", "path": "/src/bin/day07a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: onelson/advent-of-code-2017 path: /src/bin/day07a.rs extern crate aoc; use std::env; use aoc::recursive_circus; <|fim_suffix|> let args = env::args().collect::<Vec<String>>(); let fp = &args[1]; let data = aoc::read_file(fp); let node_map = recursive_circus::build_node_map(&...
code_fim
easy
{ "lang": "rust", "repo": "onelson/advent-of-code-2017", "path": "/src/bin/day07a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let node_map = recursive_circus::build_node_map(&data); let result = recursive_circus::find_root(&node_map); println!("{:?}", result); }<|fim_prefix|>// repo: onelson/advent-of-code-2017 path: /src/bin/day07a.rs extern crate aoc; use std::env; use aoc::recursive_circus; <|fim_middle|> fn ...
code_fim
medium
{ "lang": "rust", "repo": "onelson/advent-of-code-2017", "path": "/src/bin/day07a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hackagotchi/tile path: /hexa/src/camera.rs #[derive(Debug, Clone)] pub struct Camera { pub eye: nalgebra::Point3<f32>, pub target: nalgebra::Point3<f32>, up: nalgebra::Vector3<f32>, aspect: f32, pub fovy: f32, znear: f32, zfar: f32, } impl Default for Camera { fn ...
code_fim
hard
{ "lang": "rust", "repo": "hackagotchi/tile", "path": "/hexa/src/camera.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_angle(&mut self, angle: f32, distance: f32) { let (sin, cos) = angle.sin_cos(); self.eye.x = cos * distance; self.eye.y = sin * distance; } pub fn view(&self) -> nalgebra::Matrix4<f32> { nalgebra::Matrix4::look_at_rh( &(self.eye.coords + ...
code_fim
hard
{ "lang": "rust", "repo": "hackagotchi/tile", "path": "/hexa/src/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn can_hold(&self, other: &Rectangle) -> bool { other.width <= self.width && other.length <= self.length } // Associated function fn square(size: u32) -> Rectangle { Rectangle { width: size, length: size } } }<|fim_prefix|>// repo: victorazzam/rust path: /rectangl...
code_fim
hard
{ "lang": "rust", "repo": "victorazzam/rust", "path": "/rectangles/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: victorazzam/rust path: /rectangles/src/main.rs fn main() { let (width, length) = (30, 50); let a = area1(width, length); let b = area2((width, length)); let rect = Rectangle { width: 30, length: 50 }; let c = area3(&rect); let d = rect.area(); println!("Area = width *...
code_fim
hard
{ "lang": "rust", "repo": "victorazzam/rust", "path": "/rectangles/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// `NativeContext` - Native function context. /// /// This is the API, the "privileges", a native function is given. /// Normally a native function will only need the `CostTable`. /// The set of native functions and their linkage is entirely inside the MoveVM /// runtime. pub trait NativeContext { //...
code_fim
hard
{ "lang": "rust", "repo": "jolestar/libra", "path": "/language/move-vm/types/src/natives/function.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jolestar/libra path: /language/move-vm/types/src/natives/function.rs // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Native Function Support //! //! All move native functions have the following signature: //! //! `pub fn native_function( //! context: ...
code_fim
hard
{ "lang": "rust", "repo": "jolestar/libra", "path": "/language/move-vm/types/src/natives/function.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let immutable_book = Book { author: "Douglas Hofstadter", title: "Gödel, Escher, Bach", year: 1979 }; // Create a mutable copy of `immutable_book` and call it `mutable_book` let mut mutable_book = immutable_book; // borrow an immutable object as i...
code_fim
hard
{ "lang": "rust", "repo": "hyone/rust_by_example", "path": "/chapter13/13_3_1_mutability.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hyone/rust_by_example path: /chapter13/13_3_1_mutability.rs #[allow(dead_code)] #[derive(Clone, Copy)] struct Book { // `&'static str` is a reference to a string allocated in read only memory author: &'static str, title: &'static str, year: u32, } fn borrow_book(book: &Book) { ...
code_fim
hard
{ "lang": "rust", "repo": "hyone/rust_by_example", "path": "/chapter13/13_3_1_mutability.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_empty_grid() { let _ = simple_logger::init(); let mut grid = Grid::<Node>::empty(); assert_eq!(grid.width, 0); assert_eq!(grid.height, 0); grid.set(&xy(-1, 2), Some(Node{a: 10})); grid.set(&xy(2, 2), Some(Node{a: 11})); grid...
code_fim
hard
{ "lang": "rust", "repo": "mcbridejc/aoc2019", "path": "/src/grid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mcbridejc/aoc2019 path: /src/grid.rs use std::cmp::{max}; use log::*; use std::slice::Iter; #[derive(PartialEq, Eq, Hash, Debug, Copy, Clone)] pub struct Location { pub x: i32, pub y: i32, } #[derive(Debug, Copy, Clone)] pub enum Direction { North, South, East, West } ...
code_fim
hard
{ "lang": "rust", "repo": "mcbridejc/aoc2019", "path": "/src/grid.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let _ = simple_logger::init(); let mut grid = Grid::<Node>::empty(); assert_eq!(grid.width, 0); assert_eq!(grid.height, 0); grid.set(&xy(-1, 2), Some(Node{a: 10})); grid.set(&xy(2, 2), Some(Node{a: 11})); grid.set(&xy(4, -4), Some(Node{a: 12})); ...
code_fim
hard
{ "lang": "rust", "repo": "mcbridejc/aoc2019", "path": "/src/grid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>common::problem!("28684", solve); #[cfg(test)] mod tests { #[test] fn three() { let map: &[fn(u32) -> u32] = &[super::triangle, super::square, super::pentagonal]; let cycle = super::find_cycle(&mut super::create_map(map)) .iter() .map(|vs| super::cycle_to_n...
code_fim
hard
{ "lang": "rust", "repo": "gifnksm/ProjectEulerRust", "path": "/src/bin/p061.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let map: &[fn(u32) -> u32] = &[super::triangle, super::square, super::pentagonal]; let cycle = super::find_cycle(&mut super::create_map(map)) .iter() .map(|vs| super::cycle_to_nums(vs)) .map(|mut vs| { vs.sort(); vs ...
code_fim
hard
{ "lang": "rust", "repo": "gifnksm/ProjectEulerRust", "path": "/src/bin/p061.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gifnksm/ProjectEulerRust path: /src/bin/p061.rs //! [Problem 61](https://projecteuler.net/problem=61) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use iter::Permutations; fn triangle(n: u32) ->...
code_fim
hard
{ "lang": "rust", "repo": "gifnksm/ProjectEulerRust", "path": "/src/bin/p061.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn help_message(zero: &str) { println!("Usage {} <flags> file", zero); println!("-h | --help : Show this help message"); println!("-d | --debug : Print debug info to stdout"); println!("-df <file> | --debug-file <file> : Write debug info to specified file"); process::exit(1); }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "kcomas/kscript", "path": "/src/lang/kargs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kcomas/kscript path: /src/lang/kargs.rs use std::{env, process}; #[derive(Debug)] pub struct ArgContainer { args: Vec<String>, } impl ArgContainer { pub fn new() -> ArgContainer { let mut args: Vec<String> = env::args().collect(); args.reverse(); ArgContainer { ...
code_fim
hard
{ "lang": "rust", "repo": "kcomas/kscript", "path": "/src/lang/kargs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> sub: "1 - 2" => "-1" sub_nested_left: "1 - 2 - a" => "-1 - a" mult: "2 * 3" => "6" mult_nested_left: "2 * 3 * a" => "a * 6" div: "6 / 2" => "3"...
code_fim
hard
{ "lang": "rust", "repo": "ayazhafiz/slide", "path": "/libslide/src/partial_evaluator.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> div: "6 / 2" => "3" div_nested_left: "6 / 2 / a" => "3 / a" div_associated: "6 / 2 / 3" => "1" modulo: "6 % 4" => "2" modulo_nested_left: "6 % 4 % a" => "2 % a" ...
code_fim
hard
{ "lang": "rust", "repo": "ayazhafiz/slide", "path": "/libslide/src/partial_evaluator.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ayazhafiz/slide path: /libslide/src/partial_evaluator.rs //! libslide's heavy-lifting optimizer, applying simplification rules on the libslide IR. #[macro_use] mod errors; mod compare; pub mod flatten; mod validate; mod variable_expand; pub use errors::PartialEvaluatorErrors; use flatten::flat...
code_fim
hard
{ "lang": "rust", "repo": "ayazhafiz/slide", "path": "/libslide/src/partial_evaluator.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> do window.render_loop |w| { for o in w.objects_mut().mut_iter() { o.append_rotation_wrt_center(&Vec3::new(0.0f32, 0.014, 0.0)); } }; }; }<|fim_prefix|>// repo: ekt7be/kiss3d path: /examples/primitives_scale.rs extern mod kiss3d; extern mod nalge...
code_fim
hard
{ "lang": "rust", "repo": "ekt7be/kiss3d", "path": "/examples/primitives_scale.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ekt7be/kiss3d path: /examples/primitives_scale.rs extern mod kiss3d; extern mod nalgebra; use std::rand::random; use nalgebra::na::{Vec3, Translation, RotationWithTranslation}; use kiss3d::window::{Window, StickToCamera}; #[start] fn start(argc: int, argv: **u8) -> int { <|fim_suffix|> do W...
code_fim
medium
{ "lang": "rust", "repo": "ekt7be/kiss3d", "path": "/examples/primitives_scale.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> do Window::spawn("Kiss3d: scaled primitives") |window| { // NOTE: scaling is not possible. for i in range(0u, 11) { let dim: f32 = random::<f32>() / 2.0; let dim2 = dim / 2.0; let offset = i as f32 * 1.0 - 5.0; let mut cu = window.add_c...
code_fim
medium
{ "lang": "rust", "repo": "ekt7be/kiss3d", "path": "/examples/primitives_scale.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_arguments() -> ArgMatches<'static> { App::new(env!("CARGO_PKG_DESCRIPTION")) .version(env!("CARGO_PKG_VERSION")) .arg( Arg::with_name(PATH) .required(true) .short("p") .long("path") .takes_value(true) ...
code_fim
hard
{ "lang": "rust", "repo": "gierlachg/log-cruncher", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> App::new(env!("CARGO_PKG_DESCRIPTION")) .version(env!("CARGO_PKG_VERSION")) .arg( Arg::with_name(PATH) .required(true) .short("p") .long("path") .takes_value(true) .help("Path to the file"), ...
code_fim
hard
{ "lang": "rust", "repo": "gierlachg/log-cruncher", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gierlachg/log-cruncher path: /src/main.rs use clap::{App, Arg, ArgMatches}; const PATH: &str = "PATH"; fn main() { <|fim_suffix|> App::new(env!("CARGO_PKG_DESCRIPTION")) .version(env!("CARGO_PKG_VERSION")) .arg( Arg::with_name(PATH) .required(true...
code_fim
hard
{ "lang": "rust", "repo": "gierlachg/log-cruncher", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>b use new_issue::NewIssue; pub use new_project::NewProject; pub use project_name::ProjectName;<|fim_prefix|>// repo: chanhuhu/actix-web-condo-plan-reporter-api path: /src/domain/mod.rs mod new_file; mod new_issue; mod new_project; m<|fim_middle|>od project_name; pub use new_file::NewFile; pu
code_fim
easy
{ "lang": "rust", "repo": "chanhuhu/actix-web-condo-plan-reporter-api", "path": "/src/domain/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>:NewProject; pub use project_name::ProjectName;<|fim_prefix|>// repo: chanhuhu/actix-web-condo-plan-reporter-api path: /src/domain/mod.rs mod new_file; mod new_issue; mod new_project; mod project_name; pub use new_file::NewFile; pu<|fim_middle|>b use new_issue::NewIssue; pub use new_project:
code_fim
easy
{ "lang": "rust", "repo": "chanhuhu/actix-web-condo-plan-reporter-api", "path": "/src/domain/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chanhuhu/actix-web-condo-plan-reporter-api path: /src/domain/mod.rs mod new_file; mod new_issue; mod new_project; m<|fim_suffix|>:NewProject; pub use project_name::ProjectName;<|fim_middle|>od project_name; pub use new_file::NewFile; pub use new_issue::NewIssue; pub use new_project:
code_fim
medium
{ "lang": "rust", "repo": "chanhuhu/actix-web-condo-plan-reporter-api", "path": "/src/domain/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn solve_part2(ids: &[String]) -> Option<String> { for comb in ids.iter().combinations(2) { let it = comb[0].chars().zip(comb[1].chars()); if it.clone().filter(|(a, b)| a != b).count() == 1 { return Some(it.filter(|(a, b)| a == b).map(|(a, _)| a).collect()); } }...
code_fim
hard
{ "lang": "rust", "repo": "tacgomes/advent-of-code-2018", "path": "/02/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tacgomes/advent-of-code-2018 path: /02/main.rs use std::collections::HashMap; use std::env; use std::fs; use std::path::Path; use std::process; use itertools::Itertools; fn parse_input(file_name: impl AsRef<Path>) -> Vec<String> { fs::read_to_string(file_name) .unwrap() .li...
code_fim
hard
{ "lang": "rust", "repo": "tacgomes/advent-of-code-2018", "path": "/02/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ids = parse_input(env::args().nth(1).unwrap()); let part1 = solve_part1(&ids); let part2 = solve_part2(&ids); println!("Part 1: {}", part1); println!("Part 2: {:?}", part2); } #[cfg(test)] mod tests { use super::*; #[test] fn test_puzzle_input() { let ids = pa...
code_fim
hard
{ "lang": "rust", "repo": "tacgomes/advent-of-code-2018", "path": "/02/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ctx = Context::new(files.as_slice(), root)?; let generators: Vec<Box<dyn Generator>> = vec![ Box::new(RefNodeTrait), Box::new(MutNodeTrait), Box::new(RefNodeImpl), Box::new(MutNodeImpl), Box::new(RefVisitorTrait), Box::new(MutVisitorTrait), ...
code_fim
hard
{ "lang": "rust", "repo": "ecreeth/hhvm", "path": "/hphp/hack/src/hh_codegen/gen_visitor/run.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ecreeth/hhvm path: /hphp/hack/src/hh_codegen/gen_visitor/run.rs // Copyright (c) 2019, Facebook, Inc. // All rights reserved. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use super::{ context::Context, gene...
code_fim
hard
{ "lang": "rust", "repo": "ecreeth/hhvm", "path": "/hphp/hack/src/hh_codegen/gen_visitor/run.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let generators: Vec<Box<dyn Generator>> = vec![ Box::new(RefNodeTrait), Box::new(MutNodeTrait), Box::new(RefNodeImpl), Box::new(MutNodeImpl), Box::new(RefVisitorTrait), Box::new(MutVisitorTrait), ]; Ok(generators .into_iter() .ma...
code_fim
hard
{ "lang": "rust", "repo": "ecreeth/hhvm", "path": "/hphp/hack/src/hh_codegen/gen_visitor/run.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rifqideveloper/game-of-life path: /src/main.rs extern crate rand; use rand::Rng; fn main(){ // alive = true // dead = false let mut tile = [false,false,false,false,false,false, false,false,false,false,false,false, false,false,false,false,false,...
code_fim
hard
{ "lang": "rust", "repo": "rifqideveloper/game-of-life", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>{ //genereted location rand_location(sample,list,z); //choose random location *random = sample[rand::thread_rng().gen_range(0,sample.len()-1)]; //remove all element for _i in 0..sample.len()-1{ sample.remove(0); } } fn rand_location(sample:&mut Vec<usize>,list:&mut Vec<...
code_fim
hard
{ "lang": "rust", "repo": "rifqideveloper/game-of-life", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>{ if list[x] == 0{ for i in vec![1,6,7]{ if !z[list[x]+i] {sample.push(list[x]+i)} } } else if list[x] == 30 { if !z[list[x]+1] {sample.push(list[x]+1)} for i in vec![5,6]{ if !z[list[x]-i] {sample.push(list[x]-i)} } } els...
code_fim
hard
{ "lang": "rust", "repo": "rifqideveloper/game-of-life", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elauffenburger/sixty-five-oh-too path: /src/cpu/instr/compare/cmp.rs use super::InstrResult; use super::AddrResult; use super::addr; use super::Cpu; pub fn imm(cpu: &mut Cpu) -> Box<InstrResult> { let addr_result = addr::imm(cpu); cmp(cpu, addr_result, 2, 2) } pub fn zero_p...
code_fim
medium
{ "lang": "rust", "repo": "elauffenburger/sixty-five-oh-too", "path": "/src/cpu/instr/compare/cmp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> cmp(cpu, addr_result, 3, 4) } pub fn abs_y(cpu: &mut Cpu) -> Box<InstrResult> { let addr_result = addr::abs_y(cpu); cmp(cpu, addr_result, 3, 4) } pub fn ind_x(cpu: &mut Cpu) -> Box<InstrResult> { let addr_result = addr::ind_x(cpu); cmp(cpu, addr_result, 2, 6) } pub ...
code_fim
hard
{ "lang": "rust", "repo": "elauffenburger/sixty-five-oh-too", "path": "/src/cpu/instr/compare/cmp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct Searcher { node_link: Vec<Node>, cursor: usize, open: BTreeSet<Node>, closed: HashSet<Position>, obstacles: HashSet<Position>, childs: [Node; ROTATION_MATRIX.len()], } impl Searcher { pub fn new() -> Self { Self { node_link: Vec:...
code_fim
hard
{ "lang": "rust", "repo": "Crypec/bake", "path": "/src/search.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Crypec/bake path: /src/search.rs use crate::game::*; use crate::game::{WINDOW_SIZE_X, WINDOW_SIZE_Y}; use crate::snake::*; use hashbrown::HashSet; use std::cmp::Ordering; use std::collections::{BTreeSet, VecDeque}; use std::hash::{Hash, Hasher}; const NODE_LEN_X: usize = WINDOW_SIZE_X / NODE_SI...
code_fim
hard
{ "lang": "rust", "repo": "Crypec/bake", "path": "/src/search.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mlr/grpc_rust path: /src/main.rs use std::error::Error; use std::str::FromStr; use std::convert::TryInto; use stargate_grpc::*; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { let mut client = StargateClient::builder() .uri("https://e2ba1542-362d-41bb-b920-96640808b4a6-us...
code_fim
hard
{ "lang": "rust", "repo": "mlr/grpc_rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for row in result_set.rows { let (firstname, lastname): (String, String) = row.try_into()?; println!("{} {}", firstname, lastname); } Ok(()) }<|fim_prefix|>// repo: mlr/grpc_rust path: /src/main.rs use std::error::Error; use std::str::FromStr; use std::convert::TryInto; use s...
code_fim
medium
{ "lang": "rust", "repo": "mlr/grpc_rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[lang = "panic_fmt"] #[cold] extern fn rust_panic_fmt(msg: fmt::Arguments, file: &'static str, line: u32) -> ! { sys::print_str(&"internal error: "); sys::print_str(&file); sys::print_str(&":"); sys::print_u32(line); sys::print_str(&": "); let _ = fmt::write(&mut SimpleWriter, msg...
code_fim
medium
{ "lang": "rust", "repo": "artisdom/pcboot", "path": "/src/stage1/panic.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: artisdom/pcboot path: /src/stage1/panic.rs use sys; use core::fmt; pub struct SimpleWriter; impl fmt::Write for SimpleWriter { #[inline] fn write_str(&mut self, x: &str) -> fmt::Result { <|fim_suffix|>#[lang = "panic_fmt"] #[cold] extern fn rust_panic_fmt(msg: fmt::Arguments, file: &'st...
code_fim
medium
{ "lang": "rust", "repo": "artisdom/pcboot", "path": "/src/stage1/panic.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|>impl Texture for ConstantTexture { fn value(&self, _: f32, _: f32, _: Vec3) -> Vec3 { self.color } }<|fim_prefix|>// repo: skyzh/raytracer.rs path: /raytracer/src/tracer/textures/constant_texture.rs use super::{Texture, Vec3}; #[derive(Clone)] pub struct ConstantTexture { pub color: ...
code_fim
medium
{ "lang": "rust", "repo": "skyzh/raytracer.rs", "path": "/raytracer/src/tracer/textures/constant_texture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: skyzh/raytracer.rs path: /raytracer/src/tracer/textures/constant_texture.rs use super::{Texture, Vec3}; #[derive(Clone)] pub struct ConstantTexture { pub color: Vec3, } <|fim_suffix|>impl Texture for ConstantTexture { fn value(&self, _: f32, _: f32, _: Vec3) -> Vec3 { self.colo...
code_fim
medium
{ "lang": "rust", "repo": "skyzh/raytracer.rs", "path": "/raytracer/src/tracer/textures/constant_texture.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: happyborg/gitoxide path: /git-transport/src/client/git.rs use crate::{ client::{self, capabilities, SetServiceResponse}, Protocol, Service, }; use bstr::BString; use git_packetline::PacketLine; use std::{ io, io::Write, net::{TcpStream, ToSocketAddrs}, }; pub(crate) mod mess...
code_fim
hard
{ "lang": "rust", "repo": "happyborg/gitoxide", "path": "/git-transport/src/client/git.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn desired_protocol_version(&self) -> Protocol { self.desired_version } fn is_stateful(&self) -> bool { true } } impl<R, W> Connection<R, W> where R: io::Read, W: io::Write, { pub fn new( read: R, write: W, desired_version: Protocol, ...
code_fim
hard
{ "lang": "rust", "repo": "happyborg/gitoxide", "path": "/git-transport/src/client/git.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erglabs/arti path: /crates/tor-dirclient/src/err.rs //! Declare dirclient-specific errors. use thiserror::Error; use tor_rtcompat::TimeoutError; /// An error originating from the tor-dirclient crate. #[derive(Error, Debug)] #[non_exhaustive] pub enum Error { /// We received an object with ...
code_fim
medium
{ "lang": "rust", "repo": "erglabs/arti", "path": "/crates/tor-dirclient/src/err.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Io error while reading on connection #[error("IO error: {0}")] IoError(#[from] std::io::Error), /// Error when parsing http #[error("Couldn't parse HTTP headers")] HttparseError(#[from] httparse::Error), /// Error while creating http request #[error("Couldn't create H...
code_fim
hard
{ "lang": "rust", "repo": "erglabs/arti", "path": "/crates/tor-dirclient/src/err.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: batuwa/fuzzysearch path: /src/search.rs extern crate fuzzymatch; use std::fs::File; use std::io::{BufReader,BufRead}; use std::vec::Vec; use self::fuzzymatch::algo::fuzzy_match; #[derive(Clone,Debug,Serialize,Deserialize)] pub struct Match { pub score: i32, pub movie: String, } <|fim...
code_fim
hard
{ "lang": "rust", "repo": "batuwa/fuzzysearch", "path": "/src/search.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn highlight_matched_indices(text: &str, matched_indices: Vec<usize>) -> String { let mut formatted_str = Vec::new(); let mut last_idx = 0; for idx in matched_indices { // Take piece between last match and this match. formatted_str.push(text.chars().skip(last_idx).take(idx - l...
code_fim
hard
{ "lang": "rust", "repo": "batuwa/fuzzysearch", "path": "/src/search.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nhatquangsin/battle-state path: /src/state_list/mod.rs pub mod buff_state_list; pub mod card_state_list; pub mod fighter_state_lis<|fim_suffix|>ist; pub use card_state_list::CardStateList; pub use fighter_state_list::FighterStateList; pub use i32_list::I32List; pub use bool_list::BoolStateList;<...
code_fim
medium
{ "lang": "rust", "repo": "nhatquangsin/battle-state", "path": "/src/state_list/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ghterStateList; pub use i32_list::I32List; pub use bool_list::BoolStateList;<|fim_prefix|>// repo: nhatquangsin/battle-state path: /src/state_list/mod.rs pub mod buff_state_list; pub mod card_state_list; pub mod fighter_state_list; pub mod i32_list; pub mod bool_list; pub use buff_state_list::BuffStateL...
code_fim
medium
{ "lang": "rust", "repo": "nhatquangsin/battle-state", "path": "/src/state_list/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ist; pub use card_state_list::CardStateList; pub use fighter_state_list::FighterStateList; pub use i32_list::I32List; pub use bool_list::BoolStateList;<|fim_prefix|>// repo: nhatquangsin/battle-state path: /src/state_list/mod.rs pub mod buff_state_list; pub mod card_state_list; pub mod fighter_state_lis<...
code_fim
medium
{ "lang": "rust", "repo": "nhatquangsin/battle-state", "path": "/src/state_list/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn cmtie(&mut self) -> CMTIE_W<5> { CMTIE_W::new(self) } #[doc = "Bit 6 - Trigger interrupt enable"] #[inline(always)] #[must_use] pub fn trgie(&mut self) -> TRGIE_W<6> { TRGIE_W::new(self) } #[doc = "Bit 7 - Break interrupt enable"] #[inline(always)...
code_fim
hard
{ "lang": "rust", "repo": "riscv-rust/gd32vf103-pac", "path": "/src/timer0/dmainten.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: riscv-rust/gd32vf103-pac path: /src/timer0/dmainten.rs #[doc = "Register `DMAINTEN` reader"] pub struct R(crate::R<DMAINTEN_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DMAINTEN_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl F...
code_fim
hard
{ "lang": "rust", "repo": "riscv-rust/gd32vf103-pac", "path": "/src/timer0/dmainten.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aleshaleksey/asbestos-test path: /src/spectrum.rs , d| { if y >= d.y { acc } else { false } }) { let prominence = self.data[(i - w)..(i + w + 1)].iter()...
code_fim
hard
{ "lang": "rust", "repo": "aleshaleksey/asbestos-test", "path": "/src/spectrum.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aleshaleksey/asbestos-test path: /src/spectrum.rs mindex..(maxdex + 1) { // NB, with f64, this is more precise than multiple addition. let ans = y_min + dy * (i - mindex) as f64; //println!("point[i].y = {}", ans); self.data[i].y = ans; } ...
code_fim
hard
{ "lang": "rust", "repo": "aleshaleksey/asbestos-test", "path": "/src/spectrum.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> output } /// A function that tells you whether peaks are similar or not. /// This will only work when comparing samples with a single asbestos. pub fn compare_peaks_pure( &self, other: &Spectrum, no_peaks: usize, spectral_noise: f64, ) -> bool {...
code_fim
hard
{ "lang": "rust", "repo": "aleshaleksey/asbestos-test", "path": "/src/spectrum.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn bg_color_arg<'a, 'b>() -> Arg<'a, 'b> { Arg::with_name("bg_color") .short("c") .long("bg-color") .help("The background color to highlight the focused file. Blue by default") .takes_value(true) .possible_values(colors()) } fn fg_color_arg<'a, 'b>() -> Arg<'a,...
code_fim
hard
{ "lang": "rust", "repo": "sashaweiss/itree", "path": "/src/args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sashaweiss/itree path: /src/args.rs use itree::{color, options}; use clap::{App, Arg}; pub enum RenderMethod { JustSummary, NoInteractive, FullInteractive, } pub fn parse_args( version: &str, ) -> ( options::FsOptions<String>, options::RenderOptions, RenderMethod, ...
code_fim
hard
{ "lang": "rust", "repo": "sashaweiss/itree", "path": "/src/args.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn only_dirs_arg<'a, 'b>() -> Arg<'a, 'b> { Arg::with_name("only_dirs") .long("only-dirs") .help("List directories only") } fn level_arg<'a, 'b>() -> Arg<'a, 'b> { Arg::with_name("max_level") .short("L") .long("max-level") .help("Max recursion level") ...
code_fim
hard
{ "lang": "rust", "repo": "sashaweiss/itree", "path": "/src/args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FinnStokes/democracy-sausage path: /src/scene.rs use piston_window::{context::Context}; use crate::entity::{G, Entity, Selection, Loaf, SausageTray, PattyTray, Hotplate, Table, Bottle, Condiment, ChoppingBoard, Queue}; use std::cell::RefCell; use std::rc::Rc; pub struct Scene(Vec<Rc<RefCell<d...
code_fim
hard
{ "lang": "rust", "repo": "FinnStokes/democracy-sausage", "path": "/src/scene.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn dropped(&mut self, entity: &Rc<RefCell<dyn Entity>>) { for e in self.0.iter().filter(|e| !Rc::ptr_eq(e, entity)) { e.borrow_mut().other_dropped(entity); } if !entity.borrow().topping().is_none() { for e in self.0.iter().rev().filter(|e| !Rc::ptr_e...
code_fim
hard
{ "lang": "rust", "repo": "FinnStokes/democracy-sausage", "path": "/src/scene.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(order) = entity.borrow().order() { let mut mood = None; for e in self.0.iter().rev().filter(|e| !Rc::ptr_eq(e, entity) && e.borrow().bounds().intersect_rect(&entity.borrow().bounds())) { mood = e.borrow_mut().deliver_order(order); ...
code_fim
hard
{ "lang": "rust", "repo": "FinnStokes/democracy-sausage", "path": "/src/scene.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_inject_dep() { let mut container = DIContainer::new(); // add obj to DI create_dep!(DIAwareStruct::new(), container); // inject DI container to aware objects let container_arc = container.init().unwrap(); let container_ptr = contain...
code_fim
hard
{ "lang": "rust", "repo": "innobead/simpledi-rs", "path": "/src/macrorule.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: innobead/simpledi-rs path: /src/macrorule.rs #[macro_export] macro_rules! create_dep { ($obj:expr, $container:expr) => {{ $container.add($obj).unwrap() }}; ($obj:expr, $container:expr, $($t:tt)+) => {{ $container.add($obj).unwrap()$($t)+ }}; } #[macro_export] ma...
code_fim
hard
{ "lang": "rust", "repo": "innobead/simpledi-rs", "path": "/src/macrorule.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(obj_ptr, injected_obj as *const DIStruct); } #[test] fn test_inject_dep() { let mut container = DIContainer::new(); // add obj to DI create_dep!(DIAwareStruct::new(), container); // inject DI container to aware objects let container...
code_fim
hard
{ "lang": "rust", "repo": "innobead/simpledi-rs", "path": "/src/macrorule.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ByteNacked/tetris-stm32 path: /src/pld.rs #![allow(dead_code)] use crate::pac::DWT; use crate::rtt_print; use nb::Error::{Other, WouldBlock}; use nb::{Error as NbError, Result as NbResult}; use volatile_register::{RO, RW, WO}; register_u16_rw! {PldPWMValve, 0x60380000} // ШИММ для кла...
code_fim
hard
{ "lang": "rust", "repo": "ByteNacked/tetris-stm32", "path": "/src/pld.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> rg = rg << 1; } match map_bus == 0 { true => rtt_print!("Fsmc test OK"), false => panic!("Fsmc test FAILED"), } } // FIFO Test // Проверка работоспособности FIFO в PLL { let mut fifo_test_buf = [0u16; 0x100]; PldA...
code_fim
hard
{ "lang": "rust", "repo": "ByteNacked/tetris-stm32", "path": "/src/pld.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> test_reg.write(rg); map_bus |= test_reg.read() ^ rg; rg = rg << 1; } match map_bus == 0 { true => rtt_print!("Fsmc test OK"), false => panic!("Fsmc test FAILED"), } } // FIFO Test // Проверка работоспособност...
code_fim
hard
{ "lang": "rust", "repo": "ByteNacked/tetris-stm32", "path": "/src/pld.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "online")] impl From<reqwest::Error> for YubicoError { fn from(err: reqwest::Error) -> YubicoError { YubicoError::Network(err) } } #[cfg(feature = "online")] impl From<reqwest::StatusCode> for YubicoError { fn from(err: reqwest::StatusCode) -> YubicoError { Yub...
code_fim
hard
{ "lang": "rust", "repo": "drahnr/yubico-rs", "path": "/src/yubicoerror.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match *self { #[cfg(feature = "online")] YubicoError::Network(ref err) => err.description(), #[cfg(feature = "online")] YubicoError::HTTPStatusCode(_) => "200 not received", YubicoError::IOError(ref err) => err.description(), ...
code_fim
hard
{ "lang": "rust", "repo": "drahnr/yubico-rs", "path": "/src/yubicoerror.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drahnr/yubico-rs path: /src/yubicoerror.rs #[cfg(feature = "online")] extern crate reqwest; use std::error; use std::fmt; #[cfg(feature = "usb")] use libusb::Error as usbError; use std::io::Error as ioError; use std::sync::mpsc::RecvError as channelError; use base64::DecodeError as base64Error...
code_fim
hard
{ "lang": "rust", "repo": "drahnr/yubico-rs", "path": "/src/yubicoerror.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_p120() { assert_eq!( 11, minimum_total(vec![vec![2], vec![3, 4], vec![6, 5, 7], vec![4, 1, 8, 3]]) ); assert_eq!( -1, minimum_total(vec![vec![-1], vec![2, 3], vec![1, -1, -3]]) ); } }<|fim_prefix|>...
code_fim
medium
{ "lang": "rust", "repo": "xcaptain/rust-algorithms", "path": "/leetcode/src/p120.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xcaptain/rust-algorithms path: /leetcode/src/p120.rs // https://leetcode-cn.com/problems/triangle/ use std::cmp::min; pub fn minimum_total(triangle: Vec<Vec<i32>>) -> i32 { let n = triangle.len(); let mut triangle = triangle; for i in (0..n - 1).rev() { for j in 0..triangle...
code_fim
medium
{ "lang": "rust", "repo": "xcaptain/rust-algorithms", "path": "/leetcode/src/p120.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn test_user_register() { let request = UserRegisterRequest::new("test_register_id", "test_password").into_request(); let service = get_mock_service(); assert!(service.user_register(request).is_ok()); } pub fn test_user_login() { let service = get_mock_serv...
code_fim
hard
{ "lang": "rust", "repo": "z1queue/incubator-teaclave", "path": "/services/authentication/enclave/src/api_service.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub fn test_user_login() { let service = get_mock_service(); let request = UserRegisterRequest::new("test_login_id", "test_password").into_request(); assert!(service.user_register(request).is_ok()); let request = UserLoginRequest::new("test_login_id", "test_password").i...
code_fim
hard
{ "lang": "rust", "repo": "z1queue/incubator-teaclave", "path": "/services/authentication/enclave/src/api_service.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: z1queue/incubator-teaclave path: /services/authentication/enclave/src/api_service.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright owner...
code_fim
hard
{ "lang": "rust", "repo": "z1queue/incubator-teaclave", "path": "/services/authentication/enclave/src/api_service.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Geal/generic-http-server path: /src/body.rs use crate::accumulator::AccReader; use std::fmt::Debug; use std::io::{self, BufRead, Read, Write}; #[derive(Debug)] pub struct Body<Stream: Read + Write + Debug> { pub(crate) stream: AccReader<Stream>, pub(crate) length: Length, pub(crate)...
code_fim
hard
{ "lang": "rust", "repo": "Geal/generic-http-server", "path": "/src/body.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if bound > self.stream.buffer().len() { //println!("refilling (bound = {}, buffer len: {}, internal buffer len = {})", //bound, buf.len(), //self.stream.buffer().len()); if self.at_eof { ...
code_fim
hard
{ "lang": "rust", "repo": "Geal/generic-http-server", "path": "/src/body.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }