text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> StepMessage::Start => { if let Step::Run {join_handle, sender_channel, ..} = self { if join_handle.is_none() { let (handle, sx) = crate::ui::controller::start_follow(); *join_handle = Some(handle); ...
code_fim
hard
{ "lang": "rust", "repo": "VaranTavers/parrot_hat_follow", "path": "/src/ui/step.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: philippeitis/isbn-rs path: /build.rs use std::env; use std::fs::File; use std::io::{Read, Write}; use std::path::Path; use codegen::{Block, Function, Scope}; use roxmltree::{Document, Node}; const ALLOW_LINTS: &str = r###" #[allow(clippy::unreadable_literal)] #[allow(clippy::match_same_arms)] ...
code_fim
hard
{ "lang": "rust", "repo": "philippeitis/isbn-rs", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut f = File::open("./isbn-ranges/RangeMessage.xml").unwrap(); let mut text = String::new(); f.read_to_string(&mut text).unwrap(); let mut options = roxmltree::ParsingOptions::default(); options.allow_dtd = true; let range_message = Document::parse_with_options(&tex...
code_fim
hard
{ "lang": "rust", "repo": "philippeitis/isbn-rs", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ine(always)] pub fn txc(&self) -> TXC_R { TXC_R::new(((self.bits >> 2) & 0x01) != 0) } #[doc = "Bit 3 - Overrun Error Interrupt Enable"] #[inline(always)] pub fn error(&self) -> ERROR_R { ERROR_R::new(((self.bits >> 3) & 0x01) != 0) } #[doc = "Bit 8 - Chip Selec...
code_fim
hard
{ "lang": "rust", "repo": "wgwoods/atsamd", "path": "/pac/atsamd51j20a/src/qspi/intenset.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsamd51j20a/src/qspi/intenset.rs #[doc = "Reader of register INTENSET"] pub type R = crate::R<u32, super::INTENSET>; #[doc = "Writer for register INTENSET"] pub type W = crate::W<u32, super::INTENSET>; #[doc = "Register INTENSET `reset()`'s with value 0"] impl crate::R...
code_fim
hard
{ "lang": "rust", "repo": "wgwoods/atsamd", "path": "/pac/atsamd51j20a/src/qspi/intenset.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let start = self.keys.bisect_right(&key_hash); let port = if start == self.keys.len() { self.nodes.get(&self.keys.get(0).unwrap()).unwrap() } else { self.nodes.get(&self.keys.get(start).unwrap()).unwrap() }; redis::Client::open(format!("red...
code_fim
hard
{ "lang": "rust", "repo": "GnaneshKunal/consistent-hash-sample", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let port = if start == self.keys.len() { self.nodes.get(&self.keys.get(0).unwrap()).unwrap() } else { self.nodes.get(&self.keys.get(start).unwrap()).unwrap() }; redis::Client::open(format!("redis://127.0.0.1:{}/", port)) } }<|fim_prefix|>// repo...
code_fim
hard
{ "lang": "rust", "repo": "GnaneshKunal/consistent-hash-sample", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GnaneshKunal/consistent-hash-sample path: /src/lib.rs use std::collections::{hash_map::DefaultHasher, HashMap}; use std::hash::{Hash, Hasher}; pub const RING_DIVIDER: f64 = 27782217.355555557; pub type Port = u16; pub const REPLICA_SIZE: u8 = 3; mod bisect; use bisect::Bisect; pub fn calcu...
code_fim
hard
{ "lang": "rust", "repo": "GnaneshKunal/consistent-hash-sample", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: icefoxen/orbweaver path: /src/binding_generator.rs use std::collections::HashMap; use syn; use quote; use webidl; use webidl::ast; /// A member in an interface definition. /// Translates to a Rust function definition. #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Mem...
code_fim
hard
{ "lang": "rust", "repo": "icefoxen/orbweaver", "path": "/src/binding_generator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl BindingGenerator { pub fn to_rust_module(&self) -> quote::Tokens { let mut output = quote::Tokens::new(); let header_tokens = quote! { use wasm_bindgen::prelude::*; }; output.append_all(header_tokens); output.append_all( ...
code_fim
hard
{ "lang": "rust", "repo": "icefoxen/orbweaver", "path": "/src/binding_generator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: surt91/AFractalADay path: /src/fractal/iterated_function_system/ode/sampler.rs use crate::color::RGB; use crate::numbers::Real; use rand::Rng; use super::{Perturbable, Samplable, OdeSystem}; pub struct OdeFractalSampler<T> where T: Rng { pub rng: T, pub ode: Box<dyn OdeSystem>, ...
code_fim
medium
{ "lang": "rust", "repo": "surt91/AFractalADay", "path": "/src/fractal/iterated_function_system/ode/sampler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut state = self.ode.get_state().clone(); for x in state.iter_mut() { *x += self.rng.gen_range(-0.01, 0.01); } self.ode.set_state(state); } } impl<T> Samplable for OdeFractalSampler<T> where T: Rng {}<|fim_prefix|>// repo: surt91/AFractalADay path:...
code_fim
hard
{ "lang": "rust", "repo": "surt91/AFractalADay", "path": "/src/fractal/iterated_function_system/ode/sampler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Perturbable for OdeFractalSampler<T> where T: Rng { fn perturb(&mut self) { let mut state = self.ode.get_state().clone(); for x in state.iter_mut() { *x += self.rng.gen_range(-0.01, 0.01); } self.ode.set_state(state); } } impl<T> Samplable f...
code_fim
medium
{ "lang": "rust", "repo": "surt91/AFractalADay", "path": "/src/fractal/iterated_function_system/ode/sampler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e::<i32>() { Ok(fig) => fig, Err(e) => { panic!("error: {}", e); } }, }; println!("i: {}", i); }<|fim_prefix|>// repo: rarewin/PublicSlides path: /DebianMeeting/2019-03/examples/option_result/src/main.rs use std::env; fn main() { l...
code_fim
medium
{ "lang": "rust", "repo": "rarewin/PublicSlides", "path": "/DebianMeeting/2019-03/examples/option_result/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>anic!("error: {}", e); } }, }; println!("i: {}", i); }<|fim_prefix|>// repo: rarewin/PublicSlides path: /DebianMeeting/2019-03/examples/option_result/src/main.rs use std::env; fn main() { let i = match env::args().nth(1) { None => <|fim_middle|>{ pani...
code_fim
medium
{ "lang": "rust", "repo": "rarewin/PublicSlides", "path": "/DebianMeeting/2019-03/examples/option_result/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rarewin/PublicSlides path: /DebianMeeting/2019-03/examples/option_result/src/main.rs use std::env; fn main() { let i = match env::args().nth(1) { None => <|fim_suffix|>e::<i32>() { Ok(fig) => fig, Err(e) => { panic!("error: {}", e); ...
code_fim
medium
{ "lang": "rust", "repo": "rarewin/PublicSlides", "path": "/DebianMeeting/2019-03/examples/option_result/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let DataType::Null = dt { None } else { Some(SqliteTypeInfo(dt)) } } pub fn int(&self) -> i32 { unsafe { sqlite3_value_int(self.handle.0.as_ptr()) } } pub fn int64(&self) -> i64 { unsafe { sqlite3_value_int64(self.handle....
code_fim
hard
{ "lang": "rust", "repo": "rbatis/rbatis", "path": "/rbdc-sqlite/src/value.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rbatis/rbatis path: /rbdc-sqlite/src/value.rs use std::ptr::NonNull; use std::slice::from_raw_parts; use std::str::from_utf8; use std::sync::Arc; use libsqlite3_sys::{ sqlite3_value, sqlite3_value_blob, sqlite3_value_bytes, sqlite3_value_double, sqlite3_value_dup, sqlite3_value_free, sq...
code_fim
hard
{ "lang": "rust", "repo": "rbatis/rbatis", "path": "/rbdc-sqlite/src/value.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn type_info(&self) -> Cow<'_, SqliteTypeInfo> { self.type_info_opt() .map(Cow::Owned) .unwrap_or(Cow::Borrowed(&self.type_info)) } pub fn is_null(&self) -> bool { unsafe { sqlite3_value_type(self.handle.0.as_ptr()) == SQLITE_NULL } } } impl Dr...
code_fim
hard
{ "lang": "rust", "repo": "rbatis/rbatis", "path": "/rbdc-sqlite/src/value.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut c = vec![0; n as usize + 1]; for l in 0..=n as usize { c[l] = comb(n, l as u64); } let mut dp = vec![vec![0; m as usize + 1]; s + 1]; dp[s - 1][0] = 1; dp[s - 1][1 << (s - 1)] = 0; for i in (0..(s - 1)).rev() { for j in 0..=m as usize { let ...
code_fim
hard
{ "lang": "rust", "repo": "n4o847/procon-rust", "path": "/accepted/arc116_d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n4o847/procon-rust path: /accepted/arc116_d.rs use proconio::{fastout, input}; fn pow(mut x: u64, mut y: u64, z: u64) -> u64 { let mut r = 1; while y > 0 { if y & 1 == 1 { r = r * x % z; } x = x * x % z; y >>= 1; } r } fn inv(x: u64, ...
code_fim
hard
{ "lang": "rust", "repo": "n4o847/procon-rust", "path": "/accepted/arc116_d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mklein994/nimbus-alt path: /src/config/darksky_config.rs use super::ArgEnum; use super::GenericWeatherUnit; use serde_derive::{Deserialize, Serialize}; <|fim_suffix|> match unit { GenericWeatherUnit::Metric => DarkSkyUnit::Si, GenericWeatherUnit::Imperial => DarkS...
code_fim
hard
{ "lang": "rust", "repo": "mklein994/nimbus-alt", "path": "/src/config/darksky_config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive( Display, Debug, PartialEq, Eq, Copy, Clone, EnumString, EnumIter, Deserialize, Serialize, )] #[serde(rename_all = "lowercase")] #[strum(serialize_all = "kebab_case")] pub enum DarkSkyUnit { Auto, Ca, Si, Uk2, Us, } impl ArgEnum for DarkSkyUnit { const VARIANTS: &'sta...
code_fim
medium
{ "lang": "rust", "repo": "mklein994/nimbus-alt", "path": "/src/config/darksky_config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match unit { GenericWeatherUnit::Metric => DarkSkyUnit::Si, GenericWeatherUnit::Imperial => DarkSkyUnit::Us, } } }<|fim_prefix|>// repo: mklein994/nimbus-alt path: /src/config/darksky_config.rs use super::ArgEnum; use super::GenericWeatherUnit; use serde_derive...
code_fim
hard
{ "lang": "rust", "repo": "mklein994/nimbus-alt", "path": "/src/config/darksky_config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agatan/dotfm path: /src/config.rs use std::path::{Path, PathBuf}; #[derive(Debug)] pub struct Config<'a> { root_path: &'a Path, home_dir: PathBuf, } <|fim_suffix|> pub fn root_path(&self) -> &'a Path { self.root_path } pub fn home_dir(&'a self) -> &'a Path { ...
code_fim
medium
{ "lang": "rust", "repo": "agatan/dotfm", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn root_path(&self) -> &'a Path { self.root_path } pub fn home_dir(&'a self) -> &'a Path { self.home_dir.as_ref() } }<|fim_prefix|>// repo: agatan/dotfm path: /src/config.rs use std::path::{Path, PathBuf}; #[derive(Debug)] pub struct Config<'a> { root_path: &'a P...
code_fim
medium
{ "lang": "rust", "repo": "agatan/dotfm", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benbrittain/xdr-rpc path: /src/lib.rs #![cfg_attr(test, feature(custom_attribute, custom_derive, plugin))] <|fim_suffix|>pub mod xdr_rpc; pub mod xdr_codec;<|fim_middle|>#[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_xdr; extern crate serde; extern crate tokio_core;
code_fim
medium
{ "lang": "rust", "repo": "benbrittain/xdr-rpc", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod xdr_rpc; pub mod xdr_codec;<|fim_prefix|>// repo: benbrittain/xdr-rpc path: /src/lib.rs #![cfg_attr(test, feature(custom_attribute, custom_derive, plugin))] #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_xdr; <|fim_middle|>extern crate serde; extern crate tokio_core;
code_fim
easy
{ "lang": "rust", "repo": "benbrittain/xdr-rpc", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn end_tabs(&mut self, cx: &mut Cx) { self.tab_fill.color = Theme::color_bg_normal().get(cx); self.tab_fill.draw_quad(cx, Walk::wh(Width::Fill, Height::Fill)); self.tabs.sweep(cx, | _, _ | ()); if let Some((fe, id)) = &self._dragging_tab { if let Ok(()) ...
code_fim
hard
{ "lang": "rust", "repo": "teohhanhui/makepad", "path": "/widget/src/tabcontrol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: teohhanhui/makepad path: /widget/src/tabcontrol.rs use makepad_render::*; use crate::scrollbar::*; use crate::scrollview::*; use crate::tab::*; use crate::widgetstyle::*; #[derive(Clone)] pub struct TabControl { pub tabs_view: ScrollView, pub tabs: Elements<usize, Tab, Tab>, pub dr...
code_fim
hard
{ "lang": "rust", "repo": "teohhanhui/makepad", "path": "/widget/src/tabcontrol.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.drag_tab.abs_origin = Some(Vec2 {x: fe.abs.x - fe.rel_start.x, y: fe.abs.y - fe.rel_start.y}); let origin_tab = self.tabs.get_draw(cx, *id, | _cx, tmpl | tmpl.clone()); self.drag_tab.label = origin_tab.label.clone(); self.drag_tab.is_clo...
code_fim
hard
{ "lang": "rust", "repo": "teohhanhui/makepad", "path": "/widget/src/tabcontrol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greendwin/rust_ray path: /src/utils/parser.rs use linked_hash_map::LinkedHashMap; use serde::de::DeserializeOwned; use serde_yaml::Value; use std::collections::HashMap; use std::error::Error; pub trait ParserPlugin<'a>: 'a { fn init(&'a self, parser: &mut Parser<'a>); } #[derive(Debug)] pu...
code_fim
hard
{ "lang": "rust", "repo": "greendwin/rust_ray", "path": "/src/utils/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn add_cmd<Cfg, Cmd, Cb>(&mut self, cmd: Cmd, f: Cb) where Cfg: DeserializeOwned, Cmd: Into<String>, Cb: Fn(Cfg) -> ParserResult + 'a, { self.cmds.insert( cmd.into(), Box::new(move |val| { let cfg: Cfg = serde_yaml::fr...
code_fim
hard
{ "lang": "rust", "repo": "greendwin/rust_ray", "path": "/src/utils/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sciter-sdk/rust-sciter path: /examples/dom.rs #![allow(unused_variables)] #![allow(unused_must_use)] extern crate sciter; use sciter::{Value, Element, HELEMENT}; use sciter::dom::event::*; #[derive(Default)] struct DocumentHandler; impl sciter::EventHandler for DocumentHandler { fn attac...
code_fim
hard
{ "lang": "rust", "repo": "sciter-sdk/rust-sciter", "path": "/examples/dom.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> if let Ok(Some(mut body)) = root.find_first("html > body") { let mut div = Element::with_parent("div", &mut body).unwrap(); div.set_attribute("id", "requests"); div.set_style_attribute("outline", "1px solid orange"); div.set_style_attribute("margin", "10dip 0"); div.set_style_attribute("p...
code_fim
hard
{ "lang": "rust", "repo": "sciter-sdk/rust-sciter", "path": "/examples/dom.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let root = Element::from(root); println!("detaching from {}", root); } fn on_event(&mut self, root: HELEMENT, source: HELEMENT, target: HELEMENT, code: BEHAVIOR_EVENTS, phase: PHASE_MASK, reason: EventReason) -> bool { if phase != PHASE_MASK::BUBBLING { return false; } match code { BEH...
code_fim
hard
{ "lang": "rust", "repo": "sciter-sdk/rust-sciter", "path": "/examples/dom.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saturday06/extreme-blend path: /reflex/src/protocol/wayland/wl_registry.rs // Copyright © 2008-2011 Kristian Høgsberg // Copyright © 2010-2011 Intel Corporation // Copyright © 2012-2013 Collabora, Ltd. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this ...
code_fim
hard
{ "lang": "rust", "repo": "saturday06/extreme-blend", "path": "/reflex/src/protocol/wayland/wl_registry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> NativeEndian::write_u32(&mut dst[0..], context.sender_object_id); NativeEndian::write_u32(&mut dst[4..], (total_len << 16) as u32 | u32::from(opcode)); #[allow(unused_mut)] let mut encode_offset = 8; NativeEndian::write_u32(&mut dst[encode_offset..], name); ...
code_fim
hard
{ "lang": "rust", "repo": "saturday06/extreme-blend", "path": "/reflex/src/protocol/wayland/wl_registry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match name { crate::protocol::wayland::wl_registry::GLOBAL_SINGLETON_NAME => { context .resources .insert(id, context.wl_registry.clone().into()); return context.ok(); } crate::protocol::way...
code_fim
hard
{ "lang": "rust", "repo": "saturday06/extreme-blend", "path": "/reflex/src/protocol/wayland/wl_registry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize)] pub struct Summative { pub Name: String, pub Score: f64, pub Weight: f64, }<|fim_prefix|>// repo: brianjiang2200/grade_tracker path: /src/jsondata.rs #![allow(non_snake_case)] #![allow(dead_code)] use std::fs; use serde::{Serialize, Deserialize}; use serde_json::Val...
code_fim
medium
{ "lang": "rust", "repo": "brianjiang2200/grade_tracker", "path": "/src/jsondata.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brianjiang2200/grade_tracker path: /src/jsondata.rs #![allow(non_snake_case)] #![allow(dead_code)] use std::fs; use serde::{Serialize, Deserialize}; use serde_json::Value; <|fim_suffix|> course["courseName"].to_string() } #[derive(Serialize, Deserialize)] pub struct Course { pub cou...
code_fim
hard
{ "lang": "rust", "repo": "brianjiang2200/grade_tracker", "path": "/src/jsondata.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> course["courseName"].to_string() } #[derive(Serialize, Deserialize)] pub struct Course { pub courseName: String, pub Average: f64, pub Lazy: f64, pub Summatives: Vec<Summative>, } #[derive(Serialize, Deserialize)] pub struct Summative { pub Name: String, pub Score: f64, pub Weight: f6...
code_fim
hard
{ "lang": "rust", "repo": "brianjiang2200/grade_tracker", "path": "/src/jsondata.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let notation = match self { | types::Face::U => "U", | types::Face::D => "D", | types::Face::L => "L", | types::Face::R => "R", | types::Face::F => "F", | types::Face::B => "B", }; write!(fmt, "{}", notation) } } impl std::fmt::D...
code_fim
hard
{ "lang": "rust", "repo": "nwtnni/rubik", "path": "/src/display.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nwtnni/rubik path: /src/display.rs use termion::color; use crate::state; use crate::types; const W: color::Fg<&'static dyn color::Color> = color::Fg(&color::White); const R: color::Fg<&'static dyn color::Color> = color::Fg(&color::Red); const B: color::Fg<&'static dyn color::Color> = color::Fg...
code_fim
medium
{ "lang": "rust", "repo": "nwtnni/rubik", "path": "/src/display.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let color = match *self { | types::Color::W => W, | types::Color::R => R, | types::Color::B => B, | types::Color::Y => Y, | types::Color::G => G, | types::Color::O => O, }; write!(fmt, "{}██", color) } } impl std::fmt::Display fo...
code_fim
hard
{ "lang": "rust", "repo": "nwtnni/rubik", "path": "/src/display.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// A memory area we can pass to ioctls in order to get/set plane information /// with the multi-planar API. type PlaneData = [bindings::v4l2_plane; bindings::VIDEO_MAX_PLANES as usize]; fn is_multi_planar(queue: QueueType) -> bool { match queue { QueueType::VideoCaptureMplane | QueueType::Vi...
code_fim
hard
{ "lang": "rust", "repo": "keiichiw/v4l2_rust", "path": "/src/ioctl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: keiichiw/v4l2_rust path: /src/ioctl.rs //! Provides safer versions of the V4L2 ioctls through simple functions working //! on a `RawFd` and Rust variants of the V4L2 structures. This module can be //! used directly if that's the level of abstraction you are aiming for, but //! the `device` modul...
code_fim
hard
{ "lang": "rust", "repo": "keiichiw/v4l2_rust", "path": "/src/ioctl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Modify the TrapFrame *self.tf = TrapFrame::new_user_thread(entry_addr, ustack_top); info!("exec:END: path: {:?}", path); Ok(0) } pub fn sys_yield(&mut self) -> SysResult { thread::yield_now(); Ok(0) } /// Kill the process pub fn sys...
code_fim
hard
{ "lang": "rust", "repo": "wlex-club/rCore", "path": "/kernel/src/syscall/proc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> thread_manager().exit(tid, exit_code as usize); thread::yield_now(); unreachable!(); } /// Exit the current thread group (i.e. process) pub fn sys_exit_group(&mut self, exit_code: usize) -> ! { let mut proc = self.process(); info!("exit_group: {}, code:...
code_fim
hard
{ "lang": "rust", "repo": "wlex-club/rCore", "path": "/kernel/src/syscall/proc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wlex-club/rCore path: /kernel/src/syscall/proc.rs //! Syscalls for process use super::*; impl Syscall<'_> { /// Fork the current process. Return the child's PID. pub fn sys_fork(&mut self) -> SysResult { let new_thread = self.thread.fork(self.tf); let pid = new_thread.p...
code_fim
hard
{ "lang": "rust", "repo": "wlex-club/rCore", "path": "/kernel/src/syscall/proc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: balena-io-experimental/crosser path: /src/logger.rs use std::io::{stdout, Write}; use std::path::Path; use anyhow::{Context, Result}; use log::{LevelFilter, Log, Metadata, Record}; use crossterm::{ execute, style::{Color, Print, ResetColor, SetForegroundColor}, }; static LOGGER: Logg...
code_fim
hard
{ "lang": "rust", "repo": "balena-io-experimental/crosser", "path": "/src/logger.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(r) = s.get_mut(0..1) { r.make_ascii_uppercase(); } } pub fn init() -> Result<()> { log::set_logger(&LOGGER).context("Logging initialization failed")?; log::set_max_level(LevelFilter::Info); Ok(()) }<|fim_prefix|>// repo: balena-io-experimental/crosser path: /src/l...
code_fim
hard
{ "lang": "rust", "repo": "balena-io-experimental/crosser", "path": "/src/logger.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kurotakazuki/wav_ast path: /src/chunk/fmt.rs use crate::chunk::ChunkHeader; #[derive(Clone, Copy, Debug)] pub enum FormatTag { UncompressedPCM, IEEEFloatingPoint, WaveFormatExtensible, Other(u16), } impl Default for FormatTag { fn default() -> Self { FormatTag::Othe...
code_fim
hard
{ "lang": "rust", "repo": "kurotakazuki/wav_ast", "path": "/src/chunk/fmt.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl FmtChunk { pub fn new( size: u32, format_tag: FormatTag, channels: u16, samples_per_sec: u32, avg_bytes_per_sec: u32, block_align: u16, bits_per_sample: u16, cb_size: Option<u16>, wave_format_extensible: Option<WaveFormatExte...
code_fim
hard
{ "lang": "rust", "repo": "kurotakazuki/wav_ast", "path": "/src/chunk/fmt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vxio/aldor path: /src/loan.rs use std::ops::{Add, Div, Mul}; use std::str::FromStr; use bigdecimal::{BigDecimal, Zero}; use chrono::Datelike; use chrono::format::Numeric::Month; use diesel::{ deserialize::{self, FromSql}, PgConnection, prelude::*, serialize, serialize::{Output, ToSql}, sq...
code_fim
hard
{ "lang": "rust", "repo": "vxio/aldor", "path": "/src/loan.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn decrement(&self, id: &Id, amount: &BigDecimal) -> db::Result<Loan> { let conn = &self.db.get()?; diesel::update(loans::table) .filter(loans::id.eq(id)) .set(( loans::balance.eq(loans::balance + loans::accrued_interest - amount), loans::accrued_interest.eq(BigDecimal::zero()), ...
code_fim
hard
{ "lang": "rust", "repo": "vxio/aldor", "path": "/src/loan.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>= 0)) .fold(0, |acc, c| acc+c) }<|fim_prefix|>// repo: mboersma/exercism-rust path: /sum-of-multiples/src/lib.rs pub fn sum_of_multiples(limit: u32, fac<|fim_middle|>tors: &[u32]) -> u32 { (1..limit).filter(|c| factors.iter().any(|f| c % f =
code_fim
medium
{ "lang": "rust", "repo": "mboersma/exercism-rust", "path": "/sum-of-multiples/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mboersma/exercism-rust path: /sum-of-multiples/src/lib.rs pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 { (1..limit).fi<|fim_suffix|>= 0)) .fold(0, |acc, c| acc+c) }<|fim_middle|>lter(|c| factors.iter().any(|f| c % f =
code_fim
easy
{ "lang": "rust", "repo": "mboersma/exercism-rust", "path": "/sum-of-multiples/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let to_encode = to_encode & !U64_HIGH_BIT_MASK; for offset_byte_shift in 0..U64_BYTE_WIDTH { let offset_bit_shift = offset_byte_shift * BYTE_BIT_WIDTH; let to_encode_offset = to_encode >> offset_bit_shift; // cast should truncate, but just in case ...
code_fim
hard
{ "lang": "rust", "repo": "AlterionX/benxu-dev", "path": "/crypto/src/token/paseto.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlterionX/benxu-dev path: /crypto/src/token/paseto.rs //! An implementation of the [PASETO token standard](https://paseto.io). //! //! Here is an example usage of the v2 local PASETO protocol: //! ```rust //! use bundled_crypto::token::paseto::{self, Protocol}; //! use bundled_crypto::algo::{Alg...
code_fim
hard
{ "lang": "rust", "repo": "AlterionX/benxu-dev", "path": "/crypto/src/token/paseto.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kineolyan/project-tz-io path: /rs-parser/generator/src/java/constants.rs // from https://docs.oracle.com/javase/specs/jvms/se10/html/jvms-4.html#jvms-4.6 /// Enum class referencing the various possible flag accesses for a class #[derive(Debug, PartialEq)] #[allow(dead_code)] pub enum ClassAcces...
code_fim
hard
{ "lang": "rust", "repo": "Kineolyan/project-tz-io", "path": "/rs-parser/generator/src/java/constants.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Primitive types for an array #[derive(Debug, PartialEq, Clone)] #[allow(dead_code)] pub enum ArrayType { BOOLEAN = 4, CHAR = 5, FLOAT = 6, DOUBLE = 7, BYTE = 8, SHORT = 9, INT = 10, LONG = 11 } #[derive(Debug, PartialEq, Clone)] #[allow(dead_code)] pub enum PoolCode { Class = 7, F...
code_fim
hard
{ "lang": "rust", "repo": "Kineolyan/project-tz-io", "path": "/rs-parser/generator/src/java/constants.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn with<F>(&self, index: ModuleGraphIndex<M>, func: F) where F: FnOnce(&M) -> (), { let module = self.get(index); func(module); } } impl<M: Debug, D: Reference> std::default::Default for ModuleGraph<M, D> { fn default() -> Self { ModuleGraph { ...
code_fim
hard
{ "lang": "rust", "repo": "aweary/unnamed-web-lang", "path": "/data_structures/src/module_graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aweary/unnamed-web-lang path: /data_structures/src/module_graph.rs use petgraph::graph::{EdgeIndex, Graph, NodeIndex}; use crate::arena::{Arena, Id}; use crate::scope_map::Reference; use std::clone::Clone; use std::cmp::Eq; use std::fmt::Debug; use std::hash::{Hash, Hasher}; // A module in th...
code_fim
hard
{ "lang": "rust", "repo": "aweary/unnamed-web-lang", "path": "/data_structures/src/module_graph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let expected = r" script { use 0x0000000000000000000000000000000000000000000000000000000000000001::Event; use 0x0000000000000000000000000000000000000000000000000000000000000001::Math; use 0x000000000000000000000000000000000000000000000000...
code_fim
hard
{ "lang": "rust", "repo": "Krishnacore/move-tools", "path": "/lang/src/compiler/preprocessor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Krishnacore/move-tools path: /lang/src/compiler/preprocessor.rs use move_lang::errors::{Errors, FilesSourceText}; use move_lang::preprocessor::SourceProcessor; use crate::compiler::dialects::{Dialect, line_endings}; use crate::compiler::mut_string::{MutString, NewValue}; use crate::compiler::so...
code_fim
hard
{ "lang": "rust", "repo": "Krishnacore/move-tools", "path": "/lang/src/compiler/preprocessor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use crate::compiler::mut_string::MutString; use crate::compiler::preprocessor::replace_sender_placeholder; use crate::compiler::source_map::FileOffsetMap; #[test] pub fn test_replace_sender_placeholder() { let source = r" script { use {{sender}}::Ev...
code_fim
hard
{ "lang": "rust", "repo": "Krishnacore/move-tools", "path": "/lang/src/compiler/preprocessor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // fn transform(&self, transform: &Transform) -> Box<Prim+Send+Sync>; fn mut_transform(&mut self, transform: &Transform); } impl<'a> PartialBoundingBox for Box<dyn Prim+Send+Sync> { fn partial_bounding_box(&self) -> Option<BBox> { (**self).partial_bounding_box() } }<|fim_pref...
code_fim
medium
{ "lang": "rust", "repo": "ericsink/rust-raytracer", "path": "/src/geometry/prim.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ericsink/rust-raytracer path: /src/geometry/prim.rs use crate::prelude::*; use crate::geometry::{BBox, PartialBoundingBox}; use crate::raytracer::{Ray, Intersection}; use crate::mat4::Transform; <|fim_suffix|> // fn transform(&self, transform: &Transform) -> Box<Prim+Send+Sync>; fn ...
code_fim
medium
{ "lang": "rust", "repo": "ericsink/rust-raytracer", "path": "/src/geometry/prim.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greglearns/okra path: /src/okta/models/log_authentication_provider.rs #[derive(Debug, Serialize, Deserialize, PartialEq)] pub enum r#LogAuthenticationProvider { #[serde(rename = "OKTA_AUTHENTICATION_PROVIDER")] <|fim_suffix|>serde(rename = "FEDERATION")] r#Federation, #[serde(rename...
code_fim
medium
{ "lang": "rust", "repo": "greglearns/okra", "path": "/src/okta/models/log_authentication_provider.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>rProvider, } impl Default for r#LogAuthenticationProvider { fn default() -> Self { r#LogAuthenticationProvider::OktaAuthenticationProvider } }<|fim_prefix|>// repo: greglearns/okra path: /src/okta/models/log_authentication_provider.rs #[derive(Debug, Serialize, Deserialize, PartialEq)] pub enum r#Lo...
code_fim
medium
{ "lang": "rust", "repo": "greglearns/okra", "path": "/src/okta/models/log_authentication_provider.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>serde(rename = "FEDERATION")] r#Federation, #[serde(rename = "SOCIAL")] r#Social, #[serde(rename = "FACTOR_PROVIDER")] r#FactorProvider, } impl Default for r#LogAuthenticationProvider { fn default() -> Self { r#LogAuthenticationProvider::OktaAuthenticationProvider } }<|fim_prefix|...
code_fim
medium
{ "lang": "rust", "repo": "greglearns/okra", "path": "/src/okta/models/log_authentication_provider.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TeXitoi/keyberon path: /keyberon-macros/tests/mod.rs extern crate keyberon_macros; use keyberon::action::{k, l, m, Action, Action::*, HoldTapConfig, HoldTapAction}; use keyberon::key_code::KeyCode::*; use keyberon::layout::*; use keyberon_macros::layout; #[test] fn test_layout_equality() { ...
code_fim
hard
{ "lang": "rust", "repo": "TeXitoi/keyberon", "path": "/keyberon-macros/tests/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> static A: Layers<2, 1, 1> = layout! { { ['\\' '\''] } }; static B: Layers<2, 1, 1> = [[[k(Bslash), k(Quote)]]]; assert_eq!(A, B); } #[test] fn test_keycode_group_comma() { static A: Layers<3, 1, 1> = layout! { { [ C [D E] F ] } ...
code_fim
hard
{ "lang": "rust", "repo": "TeXitoi/keyberon", "path": "/keyberon-macros/tests/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: starcoinorg/starcoin path: /network-p2p/src/lib.rs // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 extern crate prometheus; #[macro_use] extern crate starcoin_metrics; pub use crate::protocol::event::{DhtEvent, Event}; pub use crate::protocol::generic_pro...
code_fim
medium
{ "lang": "rust", "repo": "starcoinorg/starcoin", "path": "/network-p2p/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>trait DiscoveryNetBehaviour { /// Notify the protocol that we have learned about the existence of nodes. /// /// Can (or most likely will) be called multiple times with the same `PeerId`s. /// /// Also note that there is no notification for expired nodes. The implementer must add a TTL...
code_fim
medium
{ "lang": "rust", "repo": "starcoinorg/starcoin", "path": "/network-p2p/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: q2p/software_rendering_experiments path: /src/rust_casted/game_core/src/profile.rs const RCL_PROFILE:bool = false; pub struct Profiler { calls:u32 } impl Profiler { pub fn call(&mut self) { if RCL_PROFILE { self.calls.overflowing_add(1); } } } macro_rules! profile { ( $( $p:ident )...
code_fim
medium
{ "lang": "rust", "repo": "q2p/software_rendering_experiments", "path": "/src/rust_casted/game_core/src/profile.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// function call counters for profiling profile![ RCL_sqrtInt, RCL_clamp, RCL_cosInt, RCL_angleToDirection, RCL_dist, RCL_len, RCL_pointIsLeftOfRay, RCL_castRayMultiHit, RCL_castRay, RCL_absVal, RCL_normalize, RCL_vectorsAngleCos, RCL_perspectiveScale, RCL_wrap, RCL_divRoundDown ];<|fim_pre...
code_fim
medium
{ "lang": "rust", "repo": "q2p/software_rendering_experiments", "path": "/src/rust_casted/game_core/src/profile.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakmeier/paddlers-browser-game path: /paddlers-db-interface/src/graphql/gql_err.rs use juniper::IntoFieldError; use juniper::*; #[derive(Debug)] pub enum ReadableInterfaceError { NotAllowed, RequiresAuthentication, } <|fim_suffix|>impl std::fmt::Display for ReadableInterfaceError { ...
code_fim
hard
{ "lang": "rust", "repo": "jakmeier/paddlers-browser-game", "path": "/paddlers-db-interface/src/graphql/gql_err.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl std::fmt::Display for ReadableInterfaceError { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } }<|fim_prefix|>// repo: jakmeier/paddlers-browser-game path: /paddlers-db-interface/src/graphql/gql_err.rs use juniper::IntoFieldError; use junipe...
code_fim
hard
{ "lang": "rust", "repo": "jakmeier/paddlers-browser-game", "path": "/paddlers-db-interface/src/graphql/gql_err.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self.cxx_value_serializer } } impl<'a, 's> ValueSerializerHelper for ValueSerializer<'a, 's> { fn get_cxx_value_serializer(&mut self) -> &mut CxxValueSerializer { &mut self.value_serializer_heap.cxx_value_serializer } } pub struct ValueSerializer<'a, 's> { value_serializer_heap: Pin...
code_fim
hard
{ "lang": "rust", "repo": "denoland/rusty_v8", "path": "/src/value_serializer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> this: *mut CxxValueSerializer, value: u32, ); fn v8__ValueSerializer__WriteUint64( this: *mut CxxValueSerializer, value: u64, ); fn v8__ValueSerializer__WriteDouble( this: *mut CxxValueSerializer, value: f64, ); fn v8__ValueSerializer__WriteRawBytes( this: *mut CxxV...
code_fim
hard
{ "lang": "rust", "repo": "denoland/rusty_v8", "path": "/src/value_serializer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: denoland/rusty_v8 path: /src/value_serializer.rs use crate::ArrayBuffer; use crate::Context; use crate::Exception; use crate::HandleScope; use crate::Isolate; use crate::Local; use crate::Object; use crate::SharedArrayBuffer; use crate::String; use crate::Value; use crate::WasmModuleObject; use...
code_fim
hard
{ "lang": "rust", "repo": "denoland/rusty_v8", "path": "/src/value_serializer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>.com/RustCrypto/meta/blob/master/HAZMAT.md #![no_std] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg" )] #![warn(missing_docs, rust_2018_idioms)] mod ctr128; mod ct...
code_fim
hard
{ "lang": "rust", "repo": "mondaylord/phala-blockchain", "path": "/diem/vendor/ctr/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mondaylord/phala-blockchain path: /diem/vendor/ctr/src/lib.rs //! Generic implementations of CTR mode for block ciphers. //! //! Mode functionality is accessed using traits from re-exported //! [`cipher`](https://docs.rs/cipher) crate. //! //! # ⚠️ Security Warning: [Hazmat!] //! //! This crate ...
code_fim
hard
{ "lang": "rust", "repo": "mondaylord/phala-blockchain", "path": "/diem/vendor/ctr/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Error for LoxError {} // TODO: Get better error display impl Display for LoxError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "There was a problem lexing") } }<|fim_prefix|>// repo: sria91-rlox/rlox-47 path: /src/errors.rs use std::{error::Error,...
code_fim
medium
{ "lang": "rust", "repo": "sria91-rlox/rlox-47", "path": "/src/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sria91-rlox/rlox-47 path: /src/errors.rs use std::{error::Error, fmt::Display}; <|fim_suffix|> write!(f, "There was a problem lexing") } }<|fim_middle|>#[derive(Debug, Clone, Copy)] pub enum LoxError { UnexpectedCharacter(usize, char), UnterminatedString } impl Error for Lox...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/rlox-47", "path": "/src/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sria91-rlox/rlox-47 path: /src/errors.rs use std::{error::Error, fmt::Display}; #[derive(Debug, Clone, Copy)] pub enum LoxError { UnexpectedCharacter(usize, char), UnterminatedString } <|fim_suffix|>// TODO: Get better error display impl Display for LoxError { fn fmt(&self, f: &mut...
code_fim
easy
{ "lang": "rust", "repo": "sria91-rlox/rlox-47", "path": "/src/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LongJohnCoder/gandalv path: /rust/method_fail_2.rs // @expect error struct Car; impl Car { fn num_wheels(&self) -> isize { <|fim_suffix|> let c = Car; assert!(c.num_wheels() == 4); assert!(c.num_headlights() != 2); assert!(c.milage_left(250000) == 50000); }<|fim_middle|> ...
code_fim
medium
{ "lang": "rust", "repo": "LongJohnCoder/gandalv", "path": "/rust/method_fail_2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let c = Car; assert!(c.num_wheels() == 4); assert!(c.num_headlights() != 2); assert!(c.milage_left(250000) == 50000); }<|fim_prefix|>// repo: LongJohnCoder/gandalv path: /rust/method_fail_2.rs // @expect error struct Car; impl Car { fn num_wheels(&self) -> isize { 4 } ...
code_fim
easy
{ "lang": "rust", "repo": "LongJohnCoder/gandalv", "path": "/rust/method_fail_2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if i >= k - 1 && h == hash_value { ridx = i + 1; } } let idx = n - ridx; s[idx..idx + k].to_string() } }<|fim_prefix|>// repo: wisest30/AlgoStudy path: /source/leetcode/2156/hyo.rs impl Solution { pub fn sub_str_hash(s: String, powe...
code_fim
hard
{ "lang": "rust", "repo": "wisest30/AlgoStudy", "path": "/source/leetcode/2156/hyo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wisest30/AlgoStudy path: /source/leetcode/2156/hyo.rs impl Solution { pub fn sub_str_hash(s: String, power: i32, modulo: i32, k: i32, hash_value: i32) -> String { let power = power as u64; let modulo = modulo as u64; let k = k as usize; let hash_value = hash_v...
code_fim
hard
{ "lang": "rust", "repo": "wisest30/AlgoStudy", "path": "/source/leetcode/2156/hyo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bcamp1/neat-rs path: /src/neat.rs use crate::network::*; use rand::Rng; // Helper Functions pub fn random() -> f32 { let f: f32 = rand::thread_rng().gen(); return f; } pub fn weighted_bool(true_chance: f32) -> bool { if random() < true_chance { return true; } false ...
code_fim
hard
{ "lang": "rust", "repo": "bcamp1/neat-rs", "path": "/src/neat.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Evaluate all networks for i in 0..self.pop.len() { self.pop[i].fitness = evaluate_xor(self.pop[i].clone()); } // Sort by Fitness self.pop.sort_by(|a, b| a.partial_cmp(b).unwrap()); // ----- Speciate ----- self.species_list = Vec::ne...
code_fim
hard
{ "lang": "rust", "repo": "bcamp1/neat-rs", "path": "/src/neat.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ssolaric/cses.fi path: /2. Sorting and Searching/12-traffic-lights.rs // Rust doesn't have a Multiset struct, so we need to use a BTreeMap (frequency counter) as a replacement. use std::collections::BTreeMap; use std::collections::BTreeSet; use std::io; use std::str; fn neighbors(tree: &BTreeSe...
code_fim
hard
{ "lang": "rust", "repo": "ssolaric/cses.fi", "path": "/2. Sorting and Searching/12-traffic-lights.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<R: io::BufRead> Scanner<R> { pub fn new(reader: R) -> Self { Self { reader, buffer: vec![], } } pub fn token<T: str::FromStr>(&mut self) -> T { loop { if let Some(token) = self.buffer.pop() { return token.parse()...
code_fim
hard
{ "lang": "rust", "repo": "ssolaric/cses.fi", "path": "/2. Sorting and Searching/12-traffic-lights.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// The class (severity) of the error. A class of less than 10 indicates an /// informational message. pub fn class(&self) -> u8 { self.class } /// The error message returned from the server. pub fn message(&self) -> &str { &self.message } /// The server n...
code_fim
hard
{ "lang": "rust", "repo": "Jolg42/tiberius", "path": "/src/tds/codec/token/token_error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// The line number in the SQL batch or stored procedure that caused the /// error. Line numbers begin at 1. If the line number is not applicable to /// the message, the value is 0. pub fn line(&self) -> u32 { self.line } } impl fmt::Display for TokenError { fn fmt(&self, ...
code_fim
hard
{ "lang": "rust", "repo": "Jolg42/tiberius", "path": "/src/tds/codec/token/token_error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jolg42/tiberius path: /src/tds/codec/token/token_error.rs use crate::{tds::codec::FeatureLevel, SqlReadBytes}; use std::fmt; #[derive(Clone, Debug, thiserror::Error)] /// An error token returned from the server. pub struct TokenError { /// ErrorCode pub(crate) code: u32, /// ErrorSt...
code_fim
hard
{ "lang": "rust", "repo": "Jolg42/tiberius", "path": "/src/tds/codec/token/token_error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Devolutions/sardine-rs path: /sardine/src/messages/srd_offer.rs use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use messages::{expand_start, srd_msg_id, Message, SrdHeader, SrdMessage}; use std::io::{Read, Write}; use Result; #[derive(Debug, PartialEq, Eq, Clone)] pub struct SrdOffe...
code_fim
hard
{ "lang": "rust", "repo": "Devolutions/sardine-rs", "path": "/sardine/src/messages/srd_offer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }