text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: evq/atsaml11xxx path: /src/oscctrl/xoscctrl/mod.rs #[doc = r" Value read from the register"] pub struct R { bits: u16, } #[doc = r" Value to write to the register"] pub struct W { bits: u16, } impl super::XOSCCTRL { #[doc = r" Modifies the contents of the register"] #[inline] ...
code_fim
hard
{ "lang": "rust", "repo": "evq/atsaml11xxx", "path": "/src/oscctrl/xoscctrl/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>k Failure Detector Enable"] #[inline] pub fn cfden(&self) -> CFDENR { let bits = { const MASK: bool = true; const OFFSET: u8 = 3; ((self.bits >> OFFSET) & MASK as u16) != 0 }; CFDENR { bits } } #[doc = "Bit 4 - Xosc Clock Switch E...
code_fim
hard
{ "lang": "rust", "repo": "evq/atsaml11xxx", "path": "/src/oscctrl/xoscctrl/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ool = true; const OFFSET: u8 = 4; self.w.bits &= !((MASK as u16) << OFFSET); self.w.bits |= ((value & MASK) as u16) << OFFSET; self.w } } #[doc = r" Proxy"] pub struct _RUNSTDBYW<'a> { w: &'a mut W, } impl<'a> _RUNSTDBYW<'a> { #[doc = r" Sets the field bit"] ...
code_fim
hard
{ "lang": "rust", "repo": "evq/atsaml11xxx", "path": "/src/oscctrl/xoscctrl/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apache/tvm path: /rust/tvm/src/ir/arith.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 ownership. The ASF licenses this file * to...
code_fim
hard
{ "lang": "rust", "repo": "apache/tvm", "path": "/rust/tvm/src/ir/arith.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use tvm_macros::Object; macro_rules! define_node { ($name:ident, $ref:expr, $typekey:expr; $node:ident { $($id:ident : $t:ty),*}) => { #[repr(C)] #[derive(Object, Debug)] #[ref_name = $ref] #[type_key = $typekey] pub struct $node { base: Object, ...
code_fim
medium
{ "lang": "rust", "repo": "apache/tvm", "path": "/rust/tvm/src/ir/arith.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fastlyos/proxyengine path: /tests/timeout.rs extern crate ctrlc; extern crate e2d2; extern crate tcp_proxy; extern crate time; #[macro_use] extern crate log; extern crate env_logger; extern crate ipnet; extern crate netfcts; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use...
code_fim
hard
{ "lang": "rust", "repo": "fastlyos/proxyengine", "path": "/tests/timeout.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (mtx, reply_mrx) = run_time.get_main_channel().expect("cannot get main channel"); mtx.send(MessageFrom::StartEngine).unwrap(); thread::sleep(Duration::from_millis(2000 as u64)); // emulate clients let queries = configuration.test_size.unwrap(); let timeout = Duration::from_mi...
code_fim
hard
{ "lang": "rust", "repo": "fastlyos/proxyengine", "path": "/tests/timeout.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let l234data: Vec<L234Data> = configuration .targets .iter() .enumerate() .map(|(i, srv_cfg)| L234Data { mac: srv_cfg .mac .unwrap_or_else(|| get_mac_from_ifname(srv_cfg.linux_if.as_ref().unwrap()).unwrap()), ip: u...
code_fim
hard
{ "lang": "rust", "repo": "fastlyos/proxyengine", "path": "/tests/timeout.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use rustc_serialize::hex::FromHex; let ciphertext = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736"; assert_eq!( String::from_utf8(xor_by_max( ciphertext.from_hex().unwrap(), read_freqsmap("./examples/english.txt").ok().unwrap() ...
code_fim
hard
{ "lang": "rust", "repo": "quininer/rustcode", "path": "/cryptopals/3-single-byte-xor-cipher/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quininer/rustcode path: /cryptopals/3-single-byte-xor-cipher/src/lib.rs extern crate rustc_serialize; extern crate fixed_xor; use std::fs::File; use std::path::Path; use std::num::ParseFloatError; use std::cmp::Ordering::Equal; use std::collections::HashMap; use std::io::{ Read, Error as IoErro...
code_fim
hard
{ "lang": "rust", "repo": "quininer/rustcode", "path": "/cryptopals/3-single-byte-xor-cipher/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// for botton clicked in gui fn force_to(self : Arc<Self>, on : bool) -> (Arc<dyn State>, Option<bool>); } impl State for On { fn get_state(&self) -> bool {true} fn update(self : Arc<Self>, n : usize) -> Result<(Arc<dyn State>, Option<bool>), &'static str> { if let Some(b) = self.mapping.get(n)...
code_fim
hard
{ "lang": "rust", "repo": "GiacomoZheng/cell_automaton", "path": "/src/_history/version2-channel/states/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GiacomoZheng/cell_automaton path: /src/_history/version2-channel/states/mod.rs use std::sync::{Arc, Weak}; use std::fmt; struct On { rule : Weak<Rule>, mapping : Vec<bool> } struct Off { rule : Weak<Rule>, mapping : Vec<bool> } impl fmt::Debug for On { fn fmt(&self, f: &mut fmt::Formatter...
code_fim
hard
{ "lang": "rust", "repo": "GiacomoZheng/cell_automaton", "path": "/src/_history/version2-channel/states/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Output:"); for output in machine.output_buffer.drain(..) { println!("{}", output); } }<|fim_prefix|>// repo: KallDrexx/AdventOfCode2019 path: /src/puzzle_05.rs use crate::intcode::Machine; <|fim_middle|>pub fn run() { let mut machine = Machine::new_from_file("src/inputs...
code_fim
medium
{ "lang": "rust", "repo": "KallDrexx/AdventOfCode2019", "path": "/src/puzzle_05.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KallDrexx/AdventOfCode2019 path: /src/puzzle_05.rs use crate::intcode::Machine; <|fim_suffix|> println!("Output:"); for output in machine.output_buffer.drain(..) { println!("{}", output); } }<|fim_middle|>pub fn run() { let mut machine = Machine::new_from_file("src/inputs...
code_fim
medium
{ "lang": "rust", "repo": "KallDrexx/AdventOfCode2019", "path": "/src/puzzle_05.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kodsnack/advent_of_code_2019 path: /johan-oelrich-rust/day08/src/a.rs pub fn run() -> String { let data = loader::load_as("./day/08/input.csv", |l| l).collect::<Vec<String>>()[0].clone(); let image = Image::from_string(25, 6, data); write_image(&image); "whee!".to_owned() } fn write_ima...
code_fim
hard
{ "lang": "rust", "repo": "kodsnack/advent_of_code_2019", "path": "/johan-oelrich-rust/day08/src/a.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let image = Image::from_string(2, 2, "0222112222120000".to_owned()); assert_eq!(image.layer(3).unwrap().pixels(), vec![2, 2, 1, 2]); } #[test] fn mini_image_8() { let image = Image::from_string(2, 2, "0222112222120000".to_owned()); assert_eq!(image.layer(4).unwrap().pixels(), vec![0,...
code_fim
hard
{ "lang": "rust", "repo": "kodsnack/advent_of_code_2019", "path": "/johan-oelrich-rust/day08/src/a.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 23prime/linear-algebra-rust path: /src/vector.rs //! Define Vector calculations. pub fn print_vec(v: &Vec<f64>) { print!("[{}", v[0]); for i in 1..v.len() { print!(",{}", v[i]); } println!("]"); } <|fim_suffix|>pub fn inner_prod(v0: &Vec<f64>, v1: &Vec<f64>) -> f64 { ...
code_fim
hard
{ "lang": "rust", "repo": "23prime/linear-algebra-rust", "path": "/src/vector.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn inner_prod(v0: &Vec<f64>, v1: &Vec<f64>) -> f64 { let len0 = v0.len(); let len1 = v1.len(); if len0 != len1 { panic!("Size mismatched."); } let mut s = 0.0; for i in 0..len0 { s += v0[i] * v1[i]; } return s; }<|fim_prefix|>// repo: 23prime/linear-alge...
code_fim
hard
{ "lang": "rust", "repo": "23prime/linear-algebra-rust", "path": "/src/vector.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhiruchen/rust-code path: /generics/src/main.rs #[derive(Debug)] struct Point<T> { // Point<T> struct is generic over some type T x: T, y: T } #[derive(Debug)] struct Point1<T, U> { x: T, y: U, } fn main() { let number_list = vec![34, 50, 35, 60, 100]; let result = lar...
code_fim
hard
{ "lang": "rust", "repo": "zhiruchen/rust-code", "path": "/generics/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn generic_largest<T: PartialOrd + Copy>(list: &[T]) -> T { let mut largest = list[0]; for &item in list.iter() { if item > largest { largest = item; } } largest }<|fim_prefix|>// repo: zhiruchen/rust-code path: /generics/src/main.rs #[derive(Debug)] struct Poi...
code_fim
medium
{ "lang": "rust", "repo": "zhiruchen/rust-code", "path": "/generics/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> options: TargetOptions { // ARMv8-M baseline doesn't support unaligned loads/stores so we disable them // with +strict-align. features: "+strict-align".to_string(), max_atomic_width: Some(32), .. super::thumb_base::opts() }, }...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_target/spec/thumbv8m_base_none_eabi.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_target/spec/thumbv8m_base_none_eabi.rs // Targets the Cortex-M23 processor (Baseline ARMv8-M) use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult}; <|fim_suffix|> options: TargetOptions { // ARMv8...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_target/spec/thumbv8m_base_none_eabi.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let wind = context.wind.clone(); for i in 0..context.sprites.len() { let mut sprite = &mut context.sprites[i]; sprite.position.x += delta_seconds * (wind.x + 0.1) * sprite.width; if sprite.position.x > width + 100.0 { sprite.position.x -= width + 200.0; ...
code_fim
hard
{ "lang": "rust", "repo": "shutkin/kosygin", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shutkin/kosygin path: /src/lib.rs use std::cell::RefMut; use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::{JsFuture, spawn_local}; use web_sys::{console, Crypto, Response, Blob, ImageBitmap, HtmlCanvasElement, MouseEvent, TouchEvent, CanvasRenderingContext2d}; u...
code_fim
hard
{ "lang": "rust", "repo": "shutkin/kosygin", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let app = match ui.application_mut("") { Some(app) => app, None => return, }; let mut dirty = false; if let Some((_, (player, health, weapon, events))) = world .query::<(&Player, &Health, &Weapon, &Events<HaVolumeOverlapEvent>)>() .iter() .next() ...
code_fim
hard
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/templates/game/src/systems/sync_game_state_info.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PsichiX/Oxygengine path: /templates/game/src/systems/sync_game_state_info.rs use crate::{ components::{health::*, player::*, weapon::*}, resources::game_state_info::*, }; use oxygengine::prelude::*; pub type SyncGameStateInfoSystemResources<'a> = ( WorldRef, &'a mut UserInterfac...
code_fim
hard
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/templates/game/src/systems/sync_game_state_info.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>s { pub fn new() -> Self { Self { buffer_arena: Arena::with_capacity(32), } } }<|fim_prefix|>// repo: jmd/first_voxel_engine path: /src/rendering/gpu_resources.rs use generational_arena::*; pub struct GpuResources { <|fim_middle|>pub buffer_arena: Arena<wgpu::Buffe...
code_fim
easy
{ "lang": "rust", "repo": "jmd/first_voxel_engine", "path": "/src/rendering/gpu_resources.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jmd/first_voxel_engine path: /src/rendering/gpu_resources.rs use generational_arena::*; pub struct GpuResources { pub buffer_arena: Arena<wgpu::Buffer>, } impl GpuResource<|fim_suffix|> buffer_arena: Arena::with_capacity(32), } } }<|fim_middle|>s { pub fn new() -> Self { ...
code_fim
easy
{ "lang": "rust", "repo": "jmd/first_voxel_engine", "path": "/src/rendering/gpu_resources.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>GES + 1]; for y in 1..grid.len() { for x in 1..grid.len() { grid[y][x] = grid[y][x - 1] + grid[y - 1][x]; } } grid[EDGES][EDGES] }<|fim_prefix|>// repo: sile/euler.rs path: /euler_00/src/problem015.rs //! [15] Lattice paths //! ------------------ //! pub fn solve...
code_fim
medium
{ "lang": "rust", "repo": "sile/euler.rs", "path": "/euler_00/src/problem015.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sile/euler.rs path: /euler_00/src/problem015.rs //! [15] Lattice paths //! ------------------ //! pub fn solve() -> u64 { const ED<|fim_suffix|>GES + 1]; for y in 1..grid.len() { for x in 1..grid.len() { grid[y][x] = grid[y][x - 1] + grid[y - 1][x]; } } ...
code_fim
medium
{ "lang": "rust", "repo": "sile/euler.rs", "path": "/euler_00/src/problem015.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod arcer_variant; mod configuration_variant; mod construction_error_variant; mod coordinate_variant; pub mod good_variant; mod make_dict; mod terrain_meta_variant; mod terrain_type_variant; mod terrain_yields_variant; mod territory_id_variant; mod tile_name_variant;<|fim_prefix|>// repo: chjdev/ultreia-r...
code_fim
hard
{ "lang": "rust", "repo": "chjdev/ultreia-rs", "path": "/src/godot/variant.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chjdev/ultreia-rs path: /src/godot/variant.rs macro_rules! enum_variant { ($enum:ty) => { impl ToVariant for $enum { fn to_variant(&self) -> Variant { Variant::from_str(self.as_ref()) } } impl FromVariant for $enum { ...
code_fim
hard
{ "lang": "rust", "repo": "chjdev/ultreia-rs", "path": "/src/godot/variant.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl FromVariant for $enum { fn from_variant(variant: &Variant) -> Result<Self, FromVariantError> { variant .try_to_string() .ok_or(FromVariantError::InvalidVariantType { variant_type: variant.get_type(), ...
code_fim
hard
{ "lang": "rust", "repo": "chjdev/ultreia-rs", "path": "/src/godot/variant.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gabrielesvelto/api-daemon path: /third-party/tokio-sync/src/lib.rs #![doc(html_root_url = "https://docs.rs/tokio-sync/0.1.8")] #![deny(missing_debug_implementations, missing_docs, unreachable_pub)] //! Asynchronous synchronization primitives. //! //! > **Note:** This crate is **deprecated in to...
code_fim
medium
{ "lang": "rust", "repo": "gabrielesvelto/api-daemon", "path": "/third-party/tokio-sync/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod lock; mod loom; pub mod mpsc; pub mod oneshot; pub mod semaphore; pub mod task; pub mod watch;<|fim_prefix|>// repo: gabrielesvelto/api-daemon path: /third-party/tokio-sync/src/lib.rs #![doc(html_root_url = "https://docs.rs/tokio-sync/0.1.8")] #![deny(missing_debug_implementations, missing_docs, ...
code_fim
medium
{ "lang": "rust", "repo": "gabrielesvelto/api-daemon", "path": "/third-party/tokio-sync/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>where S: Source, B: Backend, { let parallelism = builder_type.parallelism(); let time = builder_type.time(); let manager_constructor = SourceConstructor::new(String::from("source_manager"), builder_type, time); let mut ctx = Context::default(); let typed_source_factory:...
code_fim
hard
{ "lang": "rust", "repo": "cda-group/arcon", "path": "/arcon/src/dataflow/source/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cda-group/arcon path: /arcon/src/dataflow/source/mod.rs use super::builder::SourceBuilderType; use super::stream::Stream; use crate::stream::source::Source; use crate::{data::ArconType, dataflow::conf::DefaultBackend}; use crate::{ dataflow::{ builder::SourceBuilder, conf::So...
code_fim
hard
{ "lang": "rust", "repo": "cda-group/arcon", "path": "/arcon/src/dataflow/source/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<A> ToStreamExt<A> for LocalFileSource where A: ArconType + std::str::FromStr + std::fmt::Display, <A as std::str::FromStr>::Err: std::fmt::Display, { fn to_stream<F: FnOnce(&mut SourceConf<A>)>(self, f: F) -> Stream<A> { let mut conf = SourceConf::default(); f(&mut conf); ...
code_fim
hard
{ "lang": "rust", "repo": "cda-group/arcon", "path": "/arcon/src/dataflow/source/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amritanshu-pandey/projects-ctl path: /src/config.rs extern crate shellexpand; use crate::cli::get_config_home; use crate::util; use log; extern crate path_absolutize; use path_abs::PathAbs; use std::fs; use std::path::Path; pub fn canonicalise_path(path: &str) -> String { let expanded_dir: ...
code_fim
hard
{ "lang": "rust", "repo": "amritanshu-pandey/projects-ctl", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let config_file = match config_file_path.to_str() { Some(filename) => filename, None => panic!("Unable to get project config file path!"), }; let content = util::read_file(config_file.to_string()); content } pub fn write_config_file(filename: &str, content: &str) { le...
code_fim
hard
{ "lang": "rust", "repo": "amritanshu-pandey/projects-ctl", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn write_config_file(filename: &str, content: &str) { let config_file_home = get_config_home(); let config_file_pathbuf = Path::new(&config_file_home); let config_file_path = config_file_pathbuf.join(filename); let config_file = match config_file_path.to_str() { Some(filename)...
code_fim
hard
{ "lang": "rust", "repo": "amritanshu-pandey/projects-ctl", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } // kill the inferior, assume that the inferior is still alive pub fn kill(&mut self) { self.child.kill().unwrap(); self.wait(None).unwrap(); println!("Killing running inferior (pid {})", self.pid()) } // // get the current value of %rip in this inferior proc...
code_fim
hard
{ "lang": "rust", "repo": "PKUFlyingPig/CS110L", "path": "/proj-1/deet/src/inferior.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PKUFlyingPig/CS110L path: /proj-1/deet/src/inferior.rs use nix::sys::ptrace; use nix::sys::signal; use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus}; use nix::unistd::Pid; use std::process::Child; use std::process::Command; use std::os::unix::process::CommandExt; use crate::dwarf_data::Dwar...
code_fim
hard
{ "lang": "rust", "repo": "PKUFlyingPig/CS110L", "path": "/proj-1/deet/src/inferior.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // kill the inferior, assume that the inferior is still alive pub fn kill(&mut self) { self.child.kill().unwrap(); self.wait(None).unwrap(); println!("Killing running inferior (pid {})", self.pid()) } // // get the current value of %rip in this inferior process ...
code_fim
hard
{ "lang": "rust", "repo": "PKUFlyingPig/CS110L", "path": "/proj-1/deet/src/inferior.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: webbrandon/mc path: /src/model/configs.rs use std::fmt; #[derive(Default)] pub struct Configs { repository: String, params: String, template: String, render: String, global_env: Vec<(String, String, String, String, Vec<String>)>, pre_script: String, pre_env: Vec<(Str...
code_fim
hard
{ "lang": "rust", "repo": "webbrandon/mc", "path": "/src/model/configs.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>script.len() { n if n > 0 => true, _ => false, } } pub fn has_no_pre(&self) -> bool { self.no_pre } pub fn has_build_script(&self) -> bool { match self.build_script.len() { n if n > 0 => true, _ => false, } ...
code_fim
hard
{ "lang": "rust", "repo": "webbrandon/mc", "path": "/src/model/configs.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>fn render(&self) -> &String { &self.render } pub fn pre_script(&self) -> &String { &self.pre_script } pub fn pre_env(&self) -> &Vec<(String, String, String, String, Vec<String>)> { &self.pre_env } pub fn unit_test(&self) -> &String { &self.unit_test ...
code_fim
hard
{ "lang": "rust", "repo": "webbrandon/mc", "path": "/src/model/configs.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: impuls71/grammers path: /lib/grammers-mtproto/src/transports/mod.rs // Copyright 2020 - developers of the `grammers` project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://open...
code_fim
medium
{ "lang": "rust", "repo": "impuls71/grammers", "path": "/lib/grammers-mtproto/src/transports/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Write the protocol's magic into `output`. /// /// On success, return how many bytes were written. /// /// On failure, return how many bytes long the output buffer should have been. fn write_magic(&mut self, output: &mut [u8]) -> Result<usize, usize>; /// Write the packet ...
code_fim
medium
{ "lang": "rust", "repo": "impuls71/grammers", "path": "/lib/grammers-mtproto/src/transports/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mayelespino/code path: /LEARN/rust/tutorial_12_things_about_rust/lesson07/src/main.rs #![allow(unused_variables)] fn main() { println!("Lesson 07 - Tuples"); // tuples can have different typ<|fim_suffix|> println!("tup {:?} tup2 {:?}", tup, tup2); let (w, x, y, z) = tup; print...
code_fim
medium
{ "lang": "rust", "repo": "mayelespino/code", "path": "/LEARN/rust/tutorial_12_things_about_rust/lesson07/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>, x, y, z); let a = tup.0; let b = tup2.1; let c = tup.3; println!("a:{} b:{} c:{}",a ,b , c); }<|fim_prefix|>// repo: mayelespino/code path: /LEARN/rust/tutorial_12_things_about_rust/lesson07/src/main.rs #![allow(unused_variables)] fn main() { println!("Lesson 07 - Tuples"); // t...
code_fim
medium
{ "lang": "rust", "repo": "mayelespino/code", "path": "/LEARN/rust/tutorial_12_things_about_rust/lesson07/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonnydubowsky/backtalk path: /src/server.rs use {JsonValue, JsonObject, Reply, Request, Handler, Method, Error, ErrorKind}; use futures::future::{ok, err}; use futures::{BoxFuture, Future}; use std::collections::HashMap; use hyper; use hyper::mime; use hyper::header::{Accept,q}; use hyper::serve...
code_fim
hard
{ "lang": "rust", "repo": "jonnydubowsky/backtalk", "path": "/src/server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn call(&self, http_req: http::Request) -> Self::Future { let (method, uri, _, headers, body) = http_req.deconstruct(); let server = self.server.clone(); let body_prom = body.fold(Vec::new(), |mut a, b| -> FutureResult<Vec<u8>, hyper::Error> { a.extend_from_slice(&b[..]); ok(a) }); bod...
code_fim
hard
{ "lang": "rust", "repo": "jonnydubowsky/backtalk", "path": "/src/server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> client.submit_sys_stat(tonic::Request::new(new_stat)).await?; interval.tick().await; } } #[cfg(target_os = "linux")] async fn get_used_memory() -> Result<i32, Box<dyn Error>> { use heim::memory::os::linux::MemoryExt; let memory = memory::memory().await?; Ok(memory.used()....
code_fim
hard
{ "lang": "rust", "repo": "tunnelshade/fuzzy", "path": "/src/worker/dispatcher.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // We repeatedly iterate over here because we want to keep connecting back with server if we have // disconnections in the middle loop { tokio::select! { result = send_sys_stats(worker_id) => { if let Err(e) = result { error!("System stat...
code_fim
hard
{ "lang": "rust", "repo": "tunnelshade/fuzzy", "path": "/src/worker/dispatcher.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tunnelshade/fuzzy path: /src/worker/dispatcher.rs use std::error::Error; use std::io::{self, ErrorKind}; use heim::{cpu, memory, units::information}; use tracing::{error, trace, warn}; use tokio::sync::mpsc::Receiver; use crate::trace::TraceEvent; use crate::common::intervals::WORKER_HEARTBEAT...
code_fim
hard
{ "lang": "rust", "repo": "tunnelshade/fuzzy", "path": "/src/worker/dispatcher.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Logical shift right /// /// mnemonic: `)` /// /// ```text /// *SP = *SP >> 1 trunc W /// PC = PC + 1 mod L /// NZ = true if the result is nonzero, else false /// ``` Shr = op_codes::SHR as isize, /// Bitwise NOT /// /// mnemonic: `~` /// ///...
code_fim
hard
{ "lang": "rust", "repo": "Kerollmops/reustmann", "path": "/src/instruction/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Skip five instructions /// /// mnemonic: `5` /// /// ```text /// PC = PC + 6 mod L /// SP = no change /// NZ = no change /// ``` Skip5 = op_codes::SKIP5 as isize, /// Skip five instructions /// /// mnemonic: `6` /// /// ```text /// PC = ...
code_fim
hard
{ "lang": "rust", "repo": "Kerollmops/reustmann", "path": "/src/instruction/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kerollmops/reustmann path: /src/instruction/mod.rs ``text /// SP = SP + 1 mod L /// PC = PC + 1 mod L /// NZ = true if the item popped is nonzero, else false /// ``` Pop = op_codes::POP as isize, /// Duplicate the last stacked value /// /// mnemonic: `D` /// ...
code_fim
hard
{ "lang": "rust", "repo": "Kerollmops/reustmann", "path": "/src/instruction/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let bgm_volume_slider = Slider::new(&mut self.bgm_volume_state, 0.0..=100.0, self.bgm_volume_value, Message::BGMVolumeChange); Column::new() .push(tick_text) .push( Row::new() .push(one_minute_button) .push(te...
code_fim
hard
{ "lang": "rust", "repo": "toshimana/work_timer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toshimana/work_timer path: /src/main.rs #![windows_subsystem = "windows"] use iced::Slider; use std::time::Duration; use std::time::Instant; use iced::{button, executor, futures, slider, Align, Application, Button, Column, Command, Clipboard, Element, Font, HorizontalAlignment, Length, Row, Set...
code_fim
hard
{ "lang": "rust", "repo": "toshimana/work_timer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ten_minute_button = Button::new( &mut self.ten_minute_button_state, Text::new("10m.") .horizontal_alignment(HorizontalAlignment::Center) .font(FONT) ) .min_width(40) .on_press(Message::TenMinute); let ...
code_fim
hard
{ "lang": "rust", "repo": "toshimana/work_timer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: psychoss/rust-example path: /search_a_list/src/main.rs fn main(){ let haystack=vec!["B","A","B","E","<|fim_suffix|>on(|s| *s=="A").unwrap()); println!("{}",haystack.iter().rposition(|s| *s=="A").unwrap()); }<|fim_middle|>F","A"]; println!("{}",haystack.iter().positi
code_fim
easy
{ "lang": "rust", "repo": "psychoss/rust-example", "path": "/search_a_list/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ack.iter().rposition(|s| *s=="A").unwrap()); }<|fim_prefix|>// repo: psychoss/rust-example path: /search_a_list/src/main.rs fn main(){ let haystack=vec!["B","A","B","E","F","A"]; println!("{}",haystack.iter().positi<|fim_middle|>on(|s| *s=="A").unwrap()); println!("{}",hayst
code_fim
easy
{ "lang": "rust", "repo": "psychoss/rust-example", "path": "/search_a_list/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32g0/src/stm32g071/syscfg_vrefbuf/itline12.rs #[doc = "Register `ITLINE12` reader"] pub type R = crate::R<ITLINE12_SPEC>; #[doc = "Field `ADC` reader - ADC"] pub type ADC_R = crate::BitReader; #[doc = "Field `COMP1` reader - COMP1"] pub type COMP1_R = crate:...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32g0/src/stm32g071/syscfg_vrefbuf/itline12.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>] pub fn comp2(&self) -> COMP2_R { COMP2_R::new(((self.bits >> 2) & 1) != 0) } } #[doc = "interrupt line 12 status register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`itline12::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."] pub struct I...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32g0/src/stm32g071/syscfg_vrefbuf/itline12.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ffwff/iro path: /src/ssa/visitor.rs .ins .push(Ins::new(retvar, InsType::Copy(last_retvar), location)); } else { block .ins .push(Ins::new(retvar, InsType::Move(last_retvar)...
code_fim
hard
{ "lang": "rust", "repo": "ffwff/iro", "path": "/src/ssa/visitor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let func_context = Context::with_args(defstmt.id.clone(), arg_types); let mut visitor = self.derive_with_context(func_context); visitor.visit_defstmt(defstmt, boxed)?; let context = visitor.into_context(); ...
code_fim
hard
{ "lang": "rust", "repo": "ffwff/iro", "path": "/src/ssa/visitor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ffwff/iro path: /src/ssa/visitor.rs block .ins .push(Ins::new(var, InsType::Copy(right), location)); }); } else { self.with_block_mut(|block| { ...
code_fim
hard
{ "lang": "rust", "repo": "ffwff/iro", "path": "/src/ssa/visitor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Reset() } } } }); remote_type!( /// Obtained by calling `Experiment::data()`. object SpaceCenter.ScienceData { properties: { { DataAmount { /// Returns the data mount. /// /// **Game Scenes**: ...
code_fim
hard
{ "lang": "rust", "repo": "storance/krpc-bindings-rs", "path": "/src/spacecenter/parts/experiment.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: storance/krpc-bindings-rs path: /src/spacecenter/parts/experiment.rs use super::Part; use crate::codec::{Decode, Encode}; use crate::{remote_type, RemoteObject}; remote_type!( /// An experiment. Obtained by calling `Part::experiment().` object SpaceCenter.Experiment { properties: { ...
code_fim
hard
{ "lang": "rust", "repo": "storance/krpc-bindings-rs", "path": "/src/spacecenter/parts/experiment.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Dump() } } { /// Reset the experiment. /// /// **Game Scenes**: All fn reset() { Reset() } } } }); remote_type!( /// Obtained by calling `Experiment::data()`. object SpaceCe...
code_fim
hard
{ "lang": "rust", "repo": "storance/krpc-bindings-rs", "path": "/src/spacecenter/parts/experiment.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sugyan/leetcode path: /others/july-leetcoding-challenge/week-1/3379/lib.rs pub struct Solution {} impl Solution { pub fn prison_after_n_days(cells: Vec<i32>, n: i32) -> Vec<i32> { let mut cells: Vec<i32> = cells; for _ in 0..=(n - 1) % 14 { cells = (0..cells.len(...
code_fim
hard
{ "lang": "rust", "repo": "sugyan/leetcode", "path": "/others/july-leetcoding-challenge/week-1/3379/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn example_1() { assert_eq!( vec![0, 0, 1, 1, 0, 0, 0, 0], Solution::prison_after_n_days(vec![0, 1, 0, 1, 1, 0, 0, 1], 7) ); } #[test] fn example_2() { assert_eq!( vec![0, 0, 1, 1, 1, 1, 1, 0], Solution::p...
code_fim
hard
{ "lang": "rust", "repo": "sugyan/leetcode", "path": "/others/july-leetcoding-challenge/week-1/3379/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn example_2() { assert_eq!( vec![0, 0, 1, 1, 1, 1, 1, 0], Solution::prison_after_n_days(vec![1, 0, 0, 1, 0, 0, 1, 0], 1_000_000_000) ); } }<|fim_prefix|>// repo: sugyan/leetcode path: /others/july-leetcoding-challenge/week-1/3379/lib.rs pub str...
code_fim
hard
{ "lang": "rust", "repo": "sugyan/leetcode", "path": "/others/july-leetcoding-challenge/week-1/3379/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn stdout() -> *mut FILE { extern { static mut stdout: *mut FILE; } unsafe { stdout } } pub fn stderr() -> *mut FILE { extern { static mut stderr: *mut FILE; } unsafe { stderr } }<|fim_prefix|>// repo: lummax/posix.rs path: /src/stdio/linux/x86.rs #[repr(C)] #[deriving(Copy)] pub str...
code_fim
medium
{ "lang": "rust", "repo": "lummax/posix.rs", "path": "/src/stdio/linux/x86.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lummax/posix.rs path: /src/stdio/linux/x86.rs #[repr(C)] #[deriving(Copy)] pub struct FILE { _flags: [u32, ..1], _IO_read_ptr: [u32, ..1], _IO_read_end: [u32, ..1], _IO_read_base: [u32, ..1], _IO_write_base: [u32, ..1], _IO_write_ptr: [u32, ..1], _IO_write_end: [u32, ...
code_fim
medium
{ "lang": "rust", "repo": "lummax/posix.rs", "path": "/src/stdio/linux/x86.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ibaryshnikov/fosdem-talk-2020 path: /pure-rustc/lib.rs use std::mem::ManuallyDrop; #[no_mangle] extern "C" fn alloc_array(len: i32) -> i32 { let array = ManuallyDrop::new(vec![0; len as usize]); array.as_ptr() as i32 } #[no_ma<|fim_suffix|> std::slice::from_raw_parts(ptr, len a...
code_fim
medium
{ "lang": "rust", "repo": "ibaryshnikov/fosdem-talk-2020", "path": "/pure-rustc/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> std::slice::from_raw_parts(ptr, len as usize) }; array.iter().sum::<i32>() }<|fim_prefix|>// repo: ibaryshnikov/fosdem-talk-2020 path: /pure-rustc/lib.rs use std::mem::ManuallyDrop; #[no_mangle] extern "C" fn alloc_array(len: i32) -> i32 { <|fim_middle|> let array = ManuallyDrop::new...
code_fim
medium
{ "lang": "rust", "repo": "ibaryshnikov/fosdem-talk-2020", "path": "/pure-rustc/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ngle] extern "C" fn sum_array(ptr: *const i32, len: i32) -> i32 { let array = unsafe { std::slice::from_raw_parts(ptr, len as usize) }; array.iter().sum::<i32>() }<|fim_prefix|>// repo: ibaryshnikov/fosdem-talk-2020 path: /pure-rustc/lib.rs use std::mem::ManuallyDrop; #[no_mangle] e...
code_fim
medium
{ "lang": "rust", "repo": "ibaryshnikov/fosdem-talk-2020", "path": "/pure-rustc/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn logand_op<T: Allocator>(a: &mut Number, b: &Number) { a.bitand_assign(b); } pub fn op_logand<T: Allocator>(a: &mut T, input: T::Ptr, max_cost: Cost) -> Response<T::Ptr> { let v: Number = (-1).into(); binop_reduction("logand", a, v, input, max_cost, logand_op::<T>) } fn logior_op<T: Alloca...
code_fim
hard
{ "lang": "rust", "repo": "Achi-Coin/alvm_rs", "path": "/src/more_ops.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Achi-Coin/alvm_rs path: /src/more_ops.rs vec![0xff, 0xff, 0]; assert!(!test_op_unknown(&buf, &mut a, null).is_ok()); let buf = vec![0xff, 0xff, 0xcc, 0xcc, 0xfe, 0xed, 0xce]; assert!(!test_op_unknown(&buf, &mut a, null).is_ok()); // an empty atom is not a valid opcode let ...
code_fim
hard
{ "lang": "rust", "repo": "Achi-Coin/alvm_rs", "path": "/src/more_ops.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Achi-Coin/alvm_rs path: /src/more_ops.rs st PUBKEY_COST_PER_BYTE: Cost = 38; fn limbs_for_int(v: &Number) -> usize { ((v.bits() + 7) / 8) as usize } fn new_atom_and_cost<T: Allocator>(a: &mut T, cost: Cost, buf: &[u8]) -> Response<T::Ptr> { let c = buf.len() as Cost * MALLOC_COST_PER_B...
code_fim
hard
{ "lang": "rust", "repo": "Achi-Coin/alvm_rs", "path": "/src/more_ops.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamwaffles/ssd1306 path: /src/size.rs //! Display size. use super::command::Command; use display_interface::{DisplayError, WriteOnlyDataCommand}; /// Workaround trait, since `Default` is only implemented to arrays up to 32 of size pub trait NewZeroed { /// Creates a new value with its memo...
code_fim
hard
{ "lang": "rust", "repo": "jamwaffles/ssd1306", "path": "/src/size.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Size information for the common 64x48 variants #[derive(Debug, Copy, Clone)] pub struct DisplaySize64x48; impl DisplaySize for DisplaySize64x48 { const WIDTH: u8 = 64; const HEIGHT: u8 = 48; const OFFSETX: u8 = 32; const OFFSETY: u8 = 0; type Buffer = [u8; Self::WIDTH as usize * Se...
code_fim
hard
{ "lang": "rust", "repo": "jamwaffles/ssd1306", "path": "/src/size.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>extern "C" { pub fn strcasecmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; pub fn strncasecmp(s1: *const ::c_char, s2: *const ::c_char, n: ::size_t) -> ::c_int; pub fn wmemchr(cx: *const ::wchar_t, c: ::wchar_t, n: ::size_t) -> *mut ::wchar_t; } cfg_if! { if #[cfg(lib...
code_fim
medium
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/libc/src/windows/gnu/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/libc/src/windows/gnu/mod.rs pub const L_tmpnam: ::c_uint = 14; pub const TMP_MAX: ::c_uint = 0x7fff; pub const STDIN_FILENO: ::c_int = 0; pub const STDOUT_FILENO: ::c_int = 1; pub const STDERR_FILENO: ::c_int = 2; <|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/libc/src/windows/gnu/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // a set of two attributes let mut _attributes: Vec<String> = Vec::new(); _attributes.push(String::from("3")); _attributes.push(String::from("4")); let _result1 = calc_pruned_str( &_attributes, &String::from(r#"{"OR": [{"AND": [{"ATT": "1"},...
code_fim
hard
{ "lang": "rust", "repo": "Sp0Q1/rabe", "path": "/src/utils/secretsharing/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sp0Q1/rabe path: /src/utils/secretsharing/mod.rs extern crate rand; #[allow(dead_code)] extern crate serde; extern crate serde_json; use bn::*; use utils::tools::{contains, string_to_json, usize_to_fr}; use rand::Rng; // Policy variables const POLICY_OR: &'static str = "OR"; const POLICY_AND: &...
code_fim
hard
{ "lang": "rust", "repo": "Sp0Q1/rabe", "path": "/src/utils/secretsharing/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: securityin/aquasphere-contracts path: /entropy/lib.rs let mut hash_output = <<Blake2x256 as HashOutput>::Type as Default>::default(); <Blake2x256 as CryptoHash>::hash(&encoded, &mut hash_output); let copy_len = core::cmp::min(hash_output.len(), len_result...
code_fim
hard
{ "lang": "rust", "repo": "securityin/aquasphere-contracts", "path": "/entropy/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Constructor works. let mut entropy = Entropy::new(100); // Transfer event triggered during initial construction. let accounts = ink_env::test::default_accounts::<ink_env::DefaultEnvironment>() .expect("Cannot get accoun...
code_fim
hard
{ "lang": "rust", "repo": "securityin/aquasphere-contracts", "path": "/entropy/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Constructor works let entropy = Entropy::new(100); // Transfer event triggered during initial construction let emitted_events = ink_env::test::recorded_events().collect::<Vec<_>>(); assert_transfer_event( &emitted_events[0], ...
code_fim
hard
{ "lang": "rust", "repo": "securityin/aquasphere-contracts", "path": "/entropy/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: beevans/integrated-manager-for-lustre path: /iml-gui/crate/src/components/popover.rs // Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::{ components::{arrow, Placement}, gener...
code_fim
medium
{ "lang": "rust", "repo": "beevans/integrated-manager-for-lustre", "path": "/iml-gui/crate/src/components/popover.rs", "mode": "psm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|> let popover_right_styles = style! { St::Transform => "translateY(50%)", St::Left => percent(100), St::Bottom => percent(50), St::MarginLeft => px(5), }; let popover_bottom_styles = style! { St::Transform => "translateX(50%)", St::Top => percent(...
code_fim
hard
{ "lang": "rust", "repo": "beevans/integrated-manager-for-lustre", "path": "/iml-gui/crate/src/components/popover.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sugyan/atcoder path: /abc151/src/bin/e.rs use proconio::{fastout, input}; const MOD: i64 = 1_000_000_007; #[fastout] fn main() { input! { n: usize, k: usize, mut a: [i64; n], } a.sort(); let mut fact = vec![1; n + 1]; for i in 0..n { fact[i + 1] = fa...
code_fim
medium
{ "lang": "rust", "repo": "sugyan/atcoder", "path": "/abc151/src/bin/e.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut ret = 1; while b > 0 { if b & 1 > 0 { ret = ret * a % MOD } a = a * a % MOD; b >>= 1; } ret }<|fim_prefix|>// repo: sugyan/atcoder path: /abc151/src/bin/e.rs use proconio::{fastout, input}; const MOD: i64 = 1_000_000_007; #[fastout] fn...
code_fim
medium
{ "lang": "rust", "repo": "sugyan/atcoder", "path": "/abc151/src/bin/e.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let parent = arena[self].parent(); let previous_sibling = arena[self].previous_sibling(); if let Some(previous_sibling) = previous_sibling { arena[previous_sibling].next_sibling = Some(node_idx); arena[node_idx].previous_sibling = Some(previous_sibling); ...
code_fim
hard
{ "lang": "rust", "repo": "Zach41/rust-algorithm-club", "path": "/src/idtree/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zach41/rust-algorithm-club path: /src/idtree/mod.rs use std::ops::{Index, IndexMut}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct NodeId { index: usize, } #[derive(Clone)] pub struct Node<T> { parent: Option<NodeId>, next_sibling: Option<NodeId>, previous_sibling: Op...
code_fim
hard
{ "lang": "rust", "repo": "Zach41/rust-algorithm-club", "path": "/src/idtree/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> CssMediaRule { inner } } } impl AsRef<web_sys::CssMediaRule> for CssMediaRule { fn as_ref(&self) -> &web_sys::CssMediaRule { &self.inner } } impl_css_rule_traits!(CssMediaRule, CssMediaRule);<|fim_prefix|>// repo: RSSchermer/ARWA path: /arwa/src/cssom/css_media_rule.rs use c...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/ARWA", "path": "/arwa/src/cssom/css_media_rule.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RSSchermer/ARWA path: /arwa/src/cssom/css_media_rule.rs use crate::cssom::{ css_condition_rule_seal, css_grouping_rule_seal, impl_css_rule_traits, CssConditionRule, CssGroupingRule, }; #[derive(Clone)] pub struct CssMediaRule { inner: web_sys::CssMediaRule, } impl CssMediaRule { ...
code_fim
medium
{ "lang": "rust", "repo": "RSSchermer/ARWA", "path": "/arwa/src/cssom/css_media_rule.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }