text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>h one element println!("t1=({})", t1.0) // (5) }<|fim_prefix|>// repo: hoppfull/Learning-Rust path: /basics/ex06_tuples/src/main.rs fn main() { let t0 = (1, "hello"); // a tuple w<|fim_middle|>ith two elements println!("t0=({},{})", t0.0, t0.1); // (1, hello) let t1 = (5,); // a tuple wit
code_fim
medium
{ "lang": "rust", "repo": "hoppfull/Learning-Rust", "path": "/basics/ex06_tuples/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hoppfull/Learning-Rust path: /basics/ex06_tuples/src/main.rs fn main() { let t0 = (1, "hello"); // a tuple w<|fim_suffix|>.1); // (1, hello) let t1 = (5,); // a tuple with one element println!("t1=({})", t1.0) // (5) }<|fim_middle|>ith two elements println!("t0=({},{})", t0.0, t0
code_fim
easy
{ "lang": "rust", "repo": "hoppfull/Learning-Rust", "path": "/basics/ex06_tuples/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0066_plus_one/clever.rs pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // <|fim_suffix|> Self::plus_one(digits) } } #[cfg(test)] mod tests { #[test] ...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0066_plus_one/clever.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return digits; } } digits[0] = 1; digits.push(0); digits } } // ------------------------------------------------------ snip ------------------------------------------------------ // impl super::Solution for Solution { fn plus_one(digi...
code_fim
medium
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0066_plus_one/clever.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flame4/leetcode path: /src/medium/maximum_product_subarray_152.rs use crate::Solution; impl Solution { /// https://leetcode.com/problems/maximum-product-subarray/ /// 最大连续子序列的乘积. 有正数有负数. /// 注意要求是至少含有一个元素. 所以假设全是负数, 就应该返回最大的负数. /// 这类问题和house robber一样, 递归表达式里面一定有一项自己. /// ...
code_fim
hard
{ "lang": "rust", "repo": "flame4/leetcode", "path": "/src/medium/maximum_product_subarray_152.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use crate::Solution; #[test] pub fn sliding_window_maximum_test() { assert_eq!(Solution::max_product(vec![1, 3, -1, -3, 5, 3, 6, 7]), 5670); assert_eq!(Solution::max_product(vec![-1]), -1); assert_eq!(Solution::max_product(vec![-1, 0]), 0); ...
code_fim
hard
{ "lang": "rust", "repo": "flame4/leetcode", "path": "/src/medium/maximum_product_subarray_152.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for Record { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{}] {}", self.datetime, self.record_type) } } impl FromStr for Record { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { if !s.starts_with('[') { ...
code_fim
hard
{ "lang": "rust", "repo": "thvdburgt/advent-of-code-2018", "path": "/day-4-repose-record/src/record.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !s.starts_with('[') { return Err(()); } let s = &s[1..]; let mut iter = s.split(']'); let datetime = iter.next().ok_or(())?.parse().map_err(|_| ())?; let record_type = iter.next().ok_or(())?.trim().parse().map_err(|_| ())?; Ok(Self {...
code_fim
hard
{ "lang": "rust", "repo": "thvdburgt/advent-of-code-2018", "path": "/day-4-repose-record/src/record.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thvdburgt/advent-of-code-2018 path: /day-4-repose-record/src/record.rs use std::fmt; use std::str::FromStr; use crate::datetime::*; #[derive(PartialEq, Eq, PartialOrd, Ord)] pub enum RecordType { ShiftStart(u32), FallsAsleep, WakesUp, } impl fmt::Display for RecordType { fn fm...
code_fim
hard
{ "lang": "rust", "repo": "thvdburgt/advent-of-code-2018", "path": "/day-4-repose-record/src/record.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YorozuyaDev/compiler path: /core/utils.rs use std::env; pub fn get_sflyn_path() -> String { match env::var("SFLYN_PATH") { Ok(sflyn_path) => sflyn_path, Err(_) => String::new() } } <|fim_suffix|> while message.len() < size { message.push_str(character); } message }<|fim_m...
code_fim
hard
{ "lang": "rust", "repo": "YorozuyaDev/compiler", "path": "/core/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while message.len() < size { message.push_str(character); } message }<|fim_prefix|>// repo: YorozuyaDev/compiler path: /core/utils.rs use std::env; pub fn get_sflyn_path() -> String { match env::var("SFLYN_PATH") { Ok(sflyn_path) => sflyn_path, Err(_) => String::new() } } <|fim_m...
code_fim
hard
{ "lang": "rust", "repo": "YorozuyaDev/compiler", "path": "/core/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samwho/hmm path: /src/error.rs use std::{error, fmt, io}; pub fn from_str(s: &str) -> Error { s.to_owned().into() } #[derive(Debug)] pub enum Error { Io(io::Error), Csv(csv::Error), QuickCsv(quick_csv::error::Error), ChronoParse(chrono::format::ParseError), SerdeJson(se...
code_fim
hard
{ "lang": "rust", "repo": "samwho/hmm", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Error::Csv(err) } } impl From<quick_csv::error::Error> for Error { fn from(err: quick_csv::error::Error) -> Error { Error::QuickCsv(err) } } impl From<serde_json::error::Error> for Error { fn from(err: serde_json::error::Error) -> Error { Error::SerdeJson(err) ...
code_fim
hard
{ "lang": "rust", "repo": "samwho/hmm", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<quick_csv::error::Error> for Error { fn from(err: quick_csv::error::Error) -> Error { Error::QuickCsv(err) } } impl From<serde_json::error::Error> for Error { fn from(err: serde_json::error::Error) -> Error { Error::SerdeJson(err) } } impl From<chrono::format::P...
code_fim
hard
{ "lang": "rust", "repo": "samwho/hmm", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: huangjie0515/rust-learn path: /learn12-option/src/main.rs //1.option是标准定义的一个枚举,形式: //enum Option<T{ //Some(T), //None, // } //2.使用方式 fn main() { <|fim_suffix|> let sum = x + temp; //无法使用,不是同一个类型 println!("Hello, world!"); }<|fim_middle|> let some_number = Some(5); let some_string...
code_fim
hard
{ "lang": "rust", "repo": "huangjie0515/rust-learn", "path": "/learn12-option/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let some_number = Some(5); let some_string = Some(String::from("hello world")); let absent_number: Option<i32> = None; let x: i32 = 5; let y: Option<i32> = Some(5); let mut temp = 0; match y { Some(i) => { temp = i; } None => { p...
code_fim
medium
{ "lang": "rust", "repo": "huangjie0515/rust-learn", "path": "/learn12-option/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let sum = x + temp; //无法使用,不是同一个类型 println!("Hello, world!"); }<|fim_prefix|>// repo: huangjie0515/rust-learn path: /learn12-option/src/main.rs //1.option是标准定义的一个枚举,形式: //enum Option<T{ //Some(T), //None, // } //2.使用方式 fn main() { let some_number = Some(5); let some_string = Some(String...
code_fim
hard
{ "lang": "rust", "repo": "huangjie0515/rust-learn", "path": "/learn12-option/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(bump.try_alloc([0; 2048]).is_err()); bump.set_allocation_limit(Some(16384)); assert!(bump.try_alloc([0; 2048]).is_ok()); assert!(bump.allocation_limit().unwrap() >= bump.allocated_bytes()); } #[test] fn remove_allocation_limit_with_live_allocations() { let bump = Bump::new()...
code_fim
hard
{ "lang": "rust", "repo": "fitzgen/bumpalo", "path": "/tests/all/allocation_limit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fitzgen/bumpalo path: /tests/all/allocation_limit.rs use bumpalo::Bump; #[test] fn allocation_limit_trivial() { let bump = Bump::with_capacity(0); bump.set_allocation_limit(Some(0)); assert!(bump.try_alloc(5).is_err()); assert!(bump.allocation_limit().unwrap() >= bump.allocated...
code_fim
hard
{ "lang": "rust", "repo": "fitzgen/bumpalo", "path": "/tests/all/allocation_limit.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(any(feature = "v1_12", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] #[doc(alias = "devices")] pub fn connect_devices_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_devices_trampoline<F: Fn(&Checkpoi...
code_fim
hard
{ "lang": "rust", "repo": "balena-io-modules/libnm-rs", "path": "/src/checkpoint.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: balena-io-modules/libnm-rs path: /src/checkpoint.rs // This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files // DO NOT EDIT use crate::{Device, Object}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box a...
code_fim
hard
{ "lang": "rust", "repo": "balena-io-modules/libnm-rs", "path": "/src/checkpoint.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let x : u8 = 255; let y = x; let expected : u16 = 255*255; let under_test = Square{ x:x, y:y }; let actual = under_test.area(); assert_eq!(expected, actual); } }<|fim_prefix|>// repo: dfschwabe/hellorust path: /src/shapes.rs #[cfg(test)] extern crate ...
code_fim
hard
{ "lang": "rust", "repo": "dfschwabe/hellorust", "path": "/src/shapes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dfschwabe/hellorust path: /src/shapes.rs #[cfg(test)] extern crate mockall; use std::collections::HashMap; #[cfg_attr(test, mockall::automock)] pub trait Shape { fn spec(&self) -> HashMap<String, u8>; fn area(&self) -> u16; } pub struct Square { pub x: u8, pub y: u8, } impl Shape for ...
code_fim
hard
{ "lang": "rust", "repo": "dfschwabe/hellorust", "path": "/src/shapes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: besok/json-generator path: /src/generator/generators.rs use crate::generator::{GeneratorFunc, Generator, Func, new_func}; use rand::distributions::Alphanumeric; use rand::prelude::ThreadRng; use uuid::Uuid; use rand::Rng; use chrono::Utc; use rand::seq::SliceRandom; use std::fs::File; use std::i...
code_fim
hard
{ "lang": "rust", "repo": "besok/json-generator", "path": "/src/generator/generators.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn null_test() { if_let!(gen(Null{}).next() => Value::Null => ()) } #[test] fn random_uuid_test() { if_let!(gen(UUID {}).next() => Value::String(el) => assert_eq!(el.len(), 36)); } #[test] fn sequence_test() { let g1 = gen(Sequence { val: 1...
code_fim
hard
{ "lang": "rust", "repo": "besok/json-generator", "path": "/src/generator/generators.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// The structure generating random integer. pub struct RandomInt { /// The start inclusively. start: i32, /// The end exclusively. end: i32, /// the generated random. rng: ThreadRng, } impl RandomInt { pub fn new(start: i32, end: i32) -> Self { RandomInt { start, end,...
code_fim
hard
{ "lang": "rust", "repo": "besok/json-generator", "path": "/src/generator/generators.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MindFlavor/azure-sdk-for-rust path: /services/mgmt/web/src/package_2018_11_only/models.rs #![doc = "generated by AutoRust 0.1.0"] #![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct C...
code_fim
hard
{ "lang": "rust", "repo": "MindFlavor/azure-sdk-for-rust", "path": "/services/mgmt/web/src/package_2018_11_only/models.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>wn, } } } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct DefaultErrorResponse { #[serde(default, skip_serializing_if = "Option::is_none")] pub error: Option<default_error_response::Error>, } pub mod default_error_response { use super::*; #[derive(Clone, D...
code_fim
hard
{ "lang": "rust", "repo": "MindFlavor/azure-sdk-for-rust", "path": "/services/mgmt/web/src/package_2018_11_only/models.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matchai/starship path: /src/modules/username.rs use ansi_term::{Color, Style}; use std::env; use std::process::Command; use super::{Context, Module}; /// Creates a module with the current user's username /// /// Will display the username if any of the following criteria are met: /// - The ...
code_fim
hard
{ "lang": "rust", "repo": "matchai/starship", "path": "/src/modules/username.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> match Command::new("id").arg("-u").output() { Ok(output) => String::from_utf8(output.stdout) .map(|uid| uid.trim().parse::<u32>().ok()) .ok()?, Err(_) => None, } } fn get_mod_style(user_uid: Option<u32>, module: &Module) -> Style { match user_uid { ...
code_fim
hard
{ "lang": "rust", "repo": "matchai/starship", "path": "/src/modules/username.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wvandyk/adventofcode_rust path: /src/advent6/mod.rs use regex::Regex; use std; use general; fn turn_on(lights: &mut Vec<bool>, lx: u32, ly: u32, rx: u32, ry: u32) { for y in ly..(ry + 1) { for x in lx..(rx + 1) { let index = x + y * 1000; lights[index as usize] = true; } ...
code_fim
hard
{ "lang": "rust", "repo": "wvandyk/adventofcode_rust", "path": "/src/advent6/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for y in ly..(ry + 1) { for x in lx..(rx + 1) { let index = x + y * 1000; if lights[index as usize] == 0 {} else { lights[index as usize] -= 1 } } } } fn toggle_p2(lights: &mut Vec<u32>, lx: u32, ly: u32, rx: u32, ry: u32) { for y in ly..(ry + 1) { for x in lx..(rx + 1) { ...
code_fim
hard
{ "lang": "rust", "repo": "wvandyk/adventofcode_rust", "path": "/src/advent6/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for line in input.split('\n') { let caps = re.captures(line).unwrap(); let instruction = caps.at(1).unwrap(); let lx:u32 = caps.at(2).unwrap().parse().unwrap(); let ly:u32 = caps.at(3).unwrap().parse().unwrap(); let rx:u32 = caps.at(4).unwrap().parse().unwrap(); let ry:u32 = caps...
code_fim
hard
{ "lang": "rust", "repo": "wvandyk/adventofcode_rust", "path": "/src/advent6/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> apply_horizontal_tunnel(&mut level.buffer, p_x, r_x, p_y); apply_vertical_tunnel(&mut level.buffer, p_y, r_y, r_x); } level } fn apply_horizontal_tunnel(map: &mut TileBuffer, x1: i32, x2: i32, y: i32) { for x in min(x1, x2)..=max(x1, x2) { let idx = map.xy_idx(x, y); ...
code_fim
hard
{ "lang": "rust", "repo": "djmittens/tetra", "path": "/src/components/map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: djmittens/tetra path: /src/components/map.rs use crate::util::Rect; use specs::prelude::*; use std::cmp::{max, min}; pub struct TetraMap { pub buffer: TileBuffer, pub rooms: Vec<Room>, pub nav_buffer: Buffer2D<bool>, pub entities: Buffer2D<Vec<Entity>>, } impl TetraMap { pu...
code_fim
hard
{ "lang": "rust", "repo": "djmittens/tetra", "path": "/src/components/map.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Camera{ pub fn new(theta: f64, phi: f64, location: Point3<GLfloat>) -> Camera { Camera{ theta: theta, phi: phi, direction: calculate_dir(theta, phi), location: location } } pub fn set_orientation(&mut self, theta: f64, phi: f64){ self.theta = theta; self...
code_fim
hard
{ "lang": "rust", "repo": "peerhenry/rust_hello_quad", "path": "/src/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_orientation(&mut self, theta: f64, phi: f64){ self.theta = theta; self.phi = phi; self.direction = calculate_dir(theta, phi); } pub fn set_location(&mut self, location: Point3<GLfloat>){ self.location = location; } }<|fim_prefix|>// repo: peerhenry/rust_hello_quad path...
code_fim
hard
{ "lang": "rust", "repo": "peerhenry/rust_hello_quad", "path": "/src/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peerhenry/rust_hello_quad path: /src/camera.rs extern crate gl; use gl::types::GLfloat; extern crate cgmath; use cgmath::{Vector3, Point3}; <|fim_suffix|>impl Camera{ pub fn new(theta: f64, phi: f64, location: Point3<GLfloat>) -> Camera { Camera{ theta: theta, phi: phi, ...
code_fim
hard
{ "lang": "rust", "repo": "peerhenry/rust_hello_quad", "path": "/src/camera.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let dir = tempfile::tempdir()?; let actual = ModuleRenderer::new("terraform").path(dir.path()).collect(); let expected = None; assert_eq!(expected, actual); dir.close() } #[test] fn folder_with_tf_file() -> io::Result<()> { let dir = tempfile:...
code_fim
hard
{ "lang": "rust", "repo": "starship/starship", "path": "/src/modules/terraform.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: starship/starship path: /src/modules/terraform.rs use super::{Context, Module, ModuleConfig}; use crate::configs::terraform::TerraformConfig; use crate::formatter::StringFormatter; use crate::utils; use crate::formatter::VersionFormatter; use std::io; use std::path::PathBuf; /// Creates a mod...
code_fim
hard
{ "lang": "rust", "repo": "starship/starship", "path": "/src/modules/terraform.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn sqrtps_3() { run_test(&Instruction { mnemonic: Mnemonic::SQRTPS, operand1: Some(Direct(XMM4)), operand2: Some(Direct(XMM1)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 81, 225], OperandSize::Qword) } ...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_sqrtps.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_sqrtps.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; <|f...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_sqrtps.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn sqrtps_4() { run_test(&Instruction { mnemonic: Mnemonic::SQRTPS, operand1: Some(Direct(XMM5)), operand2: Some(IndirectScaledIndexed(RDX, RCX, Four, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None,...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_sqrtps.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rayylee/libvnc-rs path: /vncserver/src/rfb/mod.rs #![allow(dead_code)] #![allow(improper_ctypes)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] use std; use core::slice; include!(concat!(std::env!("OUT_DIR"), "/rfb.rs")); pub fn rfb_get_screen(wi...
code_fim
hard
{ "lang": "rust", "repo": "rayylee/libvnc-rs", "path": "/vncserver/src/rfb/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn rfb_process_events(ptr: rfbScreenInfoPtr, usec: i64) -> rfbBool { unsafe { rfbProcessEvents(ptr, usec as ::std::os::raw::c_long) } } pub fn rfb_kbd_add_event(ptr: rfbScreenInfoPtr, cb: rfbKbdAddEventProcPtr) { unsafe { (*ptr).kbdAddEvent = cb; } } pub fn rfb_mark_r...
code_fim
hard
{ "lang": "rust", "repo": "rayylee/libvnc-rs", "path": "/vncserver/src/rfb/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod query_string; pub mod mimes; mod urlencoded; mod nickel_error; mod default_error_handler; pub mod extensions; pub mod template_cache; pub mod status { pub use hyper::StatusCode; }<|fim_prefix|>// repo: nickel-org/nickel.rs path: /src/lib.rs #![doc(test(attr(deny(warnings))))] pub use hyper; #[...
code_fim
hard
{ "lang": "rust", "repo": "nickel-org/nickel.rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickel-org/nickel.rs path: /src/lib.rs #![doc(test(attr(deny(warnings))))] pub use hyper; #[macro_use] extern crate log; #[macro_use] extern crate lazy_static; pub use crate::nickel::{Nickel, Options}; pub use crate::request::Request; pub use crate::response::Response; pub use crate::middlewa...
code_fim
medium
{ "lang": "rust", "repo": "nickel-org/nickel.rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AstroPlant/astroplant-api path: /astroplant-api/src/bin/astroplant-admin.rs use clap::Parser; use astroplant_api::admin::{ self, insert_astroplant_definitions::ExistingPeripheralDefinitionStrategy, migrate, }; /// AstroPlant backend administration tools. #[derive(Parser, Debug)] #[command(...
code_fim
hard
{ "lang": "rust", "repo": "AstroPlant/astroplant-api", "path": "/astroplant-api/src/bin/astroplant-admin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match command { Command::Migrate => { migrate::run(&mut conn)?; } Command::InsertAstroplantDefinitions(opts) => { let existing_peripheral_definition_strategy = if opts.update_existing_peripheral_definitions { ExistingP...
code_fim
hard
{ "lang": "rust", "repo": "AstroPlant/astroplant-api", "path": "/astroplant-api/src/bin/astroplant-admin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TannerRogalsky/haex-rs path: /src/state/main.rs mod ui; use crate::{ state::{DrawableMap, NavigableMap, State, StateContext}, ProgressionType, }; use solstice_2d::{Color, Draw}; use ui::UIState; pub struct Main { pub map: NavigableMap, pub player: crate::player::Player, pub...
code_fim
hard
{ "lang": "rust", "repo": "TannerRogalsky/haex-rs", "path": "/src/state/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> g.set_shader(Some(ctx.resources.shaders.menu.clone())); g.image( crate::UVRect { positions: full_screen, uvs: ctx.resources.sprites_metadata.boss_contrast.uvs, }, &ctx.resources.sprites, ); g.set_shader(Non...
code_fim
hard
{ "lang": "rust", "repo": "TannerRogalsky/haex-rs", "path": "/src/state/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const BLACK: Color = Color::new(0., 0., 0., 1.); ctx.g.clear(BLACK); { ctx.g.set_canvas(Some(ctx.canvas.clone())); ctx.g.clear(BLACK); self.map.render(&self.player, ctx); for enemy in self.enemies.iter_mut() { let ...
code_fim
hard
{ "lang": "rust", "repo": "TannerRogalsky/haex-rs", "path": "/src/state/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krsmanian1972/ferries path: /src/models/programs.rs /** * A coach can offer mutilple Programs. We define the structure of * the program. */ use chrono::NaiveDateTime; use crate::commons::chassis::ValidationError; use crate::commons::util; use crate::models::coaches::Coach; use crate::schema:...
code_fim
hard
{ "lang": "rust", "repo": "krsmanian1972/ferries", "path": "/src/models/programs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.coach_id.trim().is_empty() { errors.push(ValidationError::new("coach_id", "coach id is a must")); } if self.description.trim().is_empty() { errors.push(ValidationError::new("description", "description of the program is a must.")); } ...
code_fim
hard
{ "lang": "rust", "repo": "krsmanian1972/ferries", "path": "/src/models/programs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fhiroki/atcoder path: /ABC/abc193/src/bin/c.rs use proconio::{fastout, input}; use std::collections::HashSet; <|fim_suffix|> input! { n: usize } let mut set = HashSet::new(); for a in 2..=((n as f64).sqrt().ceil() as usize) { let mut p = a * a; while p <= ...
code_fim
easy
{ "lang": "rust", "repo": "fhiroki/atcoder", "path": "/ABC/abc193/src/bin/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input! { n: usize } let mut set = HashSet::new(); for a in 2..=((n as f64).sqrt().ceil() as usize) { let mut p = a * a; while p <= n { set.insert(p); p *= a; } } println!("{}", n - set.len()); }<|fim_prefix|>// repo: fhiroki/a...
code_fim
easy
{ "lang": "rust", "repo": "fhiroki/atcoder", "path": "/ABC/abc193/src/bin/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TianTianForever/Rust-Tutorial path: /fifty-six_days_of_rust/src/main.rs use std::net::TcpListener; use std::io::prelude::*; use std::net::TcpStream; // Create 'handle_connection' method and read data from the stream. fn handle_connection(mut stream: TcpStream) { <|fim_suffix|> // Listen for ...
code_fim
hard
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/fifty-six_days_of_rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Listen for TCP connections. let listener = TcpListener::bind("127.0.0.1:8080").unwrap(); for stream in listener.incoming() { let stream = stream.unwrap(); println!("Connection established."); handle_connection(stream); } }<|fim_prefix|>// repo: TianTianForever/Ru...
code_fim
hard
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/fifty-six_days_of_rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let url = env::args().nth(1).unwrap(); println!("Retrieving: {:?}", url); let client = Client::with_connector(HttpsConnector::new(hyper_rustls::TlsClient::new())); match client.get(&url).send() { Ok(response) => println!("{:?}", response), Err(error) => println!("{:?}", er...
code_fim
easy
{ "lang": "rust", "repo": "cesare/rust-http-experiments", "path": "/src/http-get.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let client = Client::with_connector(HttpsConnector::new(hyper_rustls::TlsClient::new())); match client.get(&url).send() { Ok(response) => println!("{:?}", response), Err(error) => println!("{:?}", error), } }<|fim_prefix|>// repo: cesare/rust-http-experiments path: /src/http-g...
code_fim
medium
{ "lang": "rust", "repo": "cesare/rust-http-experiments", "path": "/src/http-get.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cesare/rust-http-experiments path: /src/http-get.rs use std::env; extern crate hyper; extern crate hyper_rustls; use hyper::client::Client; use hyper::net::HttpsConnector; fn main() { <|fim_suffix|> let client = Client::with_connector(HttpsConnector::new(hyper_rustls::TlsClient::new())); ...
code_fim
medium
{ "lang": "rust", "repo": "cesare/rust-http-experiments", "path": "/src/http-get.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct CombinatorDescription { creator: AggregateFunctionCombinatorCreator, // TODO(Winter): function document, this is very interesting. // TODO(Winter): We can support the SHOW FUNCTION DOCUMENT `function_name` or MAN FUNCTION `function_name` query syntax. } impl CombinatorDescription {...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/common/functions/src/aggregates/aggregate_function_factory.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Err(ErrorCode::UnknownAggregateFunction(format!( "Unsupported AggregateFunction: {}", origin ))) } pub fn check(&self, name: impl AsRef<str>) -> bool { let origin = name.as_ref(); let lowercase_name = origin.to_lowercase(); if self....
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/common/functions/src/aggregates/aggregate_function_factory.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: r-asou/databend path: /common/functions/src/aggregates/aggregate_function_factory.rs // Copyright 2020 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License ...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/common/functions/src/aggregates/aggregate_function_factory.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut data = vec![0; length as usize]; reader.read_exact(&mut data).await?; bincode::deserialize(&data).map_err(|err| Error::new(ErrorKind::InvalidData, err)) } pub async fn write_message<W>(mut writer: W, message: &Message) -> Result<(), Error> where W: AsyncWrite + Unpin, { let d...
code_fim
hard
{ "lang": "rust", "repo": "jbg/rkvm", "path": "/net/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn write_message<W>(mut writer: W, message: &Message) -> Result<(), Error> where W: AsyncWrite + Unpin, { let data = bincode::serialize(&message).map_err(|err| Error::new(ErrorKind::InvalidInput, err))?; let length: u8 = data .len() .try_into() .map_er...
code_fim
hard
{ "lang": "rust", "repo": "jbg/rkvm", "path": "/net/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbg/rkvm path: /net/src/lib.rs use input::Event; use serde::{Deserialize, Serialize}; use std::convert::TryInto; use std::io::{Error, ErrorKind}; use std::time::Duration; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; // Is it bold to assume there won't be more than 65536 ...
code_fim
hard
{ "lang": "rust", "repo": "jbg/rkvm", "path": "/net/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebookresearch/Private-ID path: /protocol/src/fileio.rs // Copyright (c) Facebook, Inc. and its affiliates. // SPDX-License-Identifier: Apache-2.0 use std::collections::HashMap; use std::path::Path; use std::sync::Arc; use std::sync::RwLock; use common::files; use common::timer; use crat...
code_fim
hard
{ "lang": "rust", "repo": "facebookresearch/Private-ID", "path": "/protocol/src/fileio.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(v, vec![String::from("pid"), String::from("")]); } #[test] fn test_keyedcsv_get_empty_record_with_key() { let t = KeyedCSV { headers: vec![String::from("ID"), String::from("NAME")], records: HashMap::from([ ( ...
code_fim
hard
{ "lang": "rust", "repo": "facebookresearch/Private-ID", "path": "/protocol/src/fileio.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>//TODO: KILL THIS impl From<*const ff::AVCodecParameters> for CodecParams { fn from(ptr: *const ff::AVCodecParameters) -> Self { let mut codec_params = CodecParams::alloc(); unsafe { match ff::avcodec_parameters_copy(&mut *codec_params, ptr) { e if 0 > e => ...
code_fim
hard
{ "lang": "rust", "repo": "attackgoat/libffmpeg", "path": "/src/codec_params.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: attackgoat/libffmpeg path: /src/codec_params.rs use std::ops::{Deref, DerefMut}; use ::{CodecContext, ff, FFmpegError}; pub struct CodecParams(*mut ff::AVCodecParameters); impl CodecParams { pub fn alloc() -> Self { unsafe { match ff::avcodec_parameters_alloc() { ...
code_fim
hard
{ "lang": "rust", "repo": "attackgoat/libffmpeg", "path": "/src/codec_params.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let create_info = RenderPassCreateInfo { flags: RenderPassCreateFlags::empty(), attachments: vec![ shading_attachment_description, blur_attachment_description, ], subpasses: vec![subpass], ...
code_fim
hard
{ "lang": "rust", "repo": "SiegeEngine/siege-render", "path": "/src/renderer/passes/blur/blurh.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SiegeEngine/siege-render path: /src/renderer/passes/blur/blurh.rs use dacite::core::{Device, RenderPass, Framebuffer, Extent2D, ImageView, CommandBuffer}; use crate::error::Error; use crate::renderer::image_wrap::ImageWrap; pub struct BlurHPass { pub framebuffer: Framebu...
code_fim
hard
{ "lang": "rust", "repo": "SiegeEngine/siege-render", "path": "/src/renderer/passes/blur/blurh.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { kernel::int_table.map(|mut t| { t.enable_maskable(keyboard::IRQ, keyboard::isr_addr()); }); } }<|fim_prefix|>// repo: charlesconnell/rustboot path: /arch/x86/drivers/mod.rs use core::option::Option; use core::option::Option::{Some, None}; use kernel; pub mod...
code_fim
medium
{ "lang": "rust", "repo": "charlesconnell/rustboot", "path": "/arch/x86/drivers/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charlesconnell/rustboot path: /arch/x86/drivers/mod.rs use core::option::Option; use core::option::Option::{Some, None}; <|fim_suffix|>pub static mut keydown: Option<fn(u8)> = None; pub fn init() { vga::clear_screen(vga::Color::LightRed); vga::cursor_at(0); unsafe { kernel...
code_fim
easy
{ "lang": "rust", "repo": "charlesconnell/rustboot", "path": "/arch/x86/drivers/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init() { vga::clear_screen(vga::Color::LightRed); vga::cursor_at(0); unsafe { kernel::int_table.map(|mut t| { t.enable_maskable(keyboard::IRQ, keyboard::isr_addr()); }); } }<|fim_prefix|>// repo: charlesconnell/rustboot path: /arch/x86/drivers/mod.rs us...
code_fim
easy
{ "lang": "rust", "repo": "charlesconnell/rustboot", "path": "/arch/x86/drivers/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alpheonix/rustStarfighter path: /starFighter/src/spaceship.rs pub struct Spaceship { pub _id: String<|fim_suffix|> pub adventage: bool, pub miss : i64 }<|fim_middle|>, pub name: String, pub speed: i64, pub hp: i64, pub damage: i64,
code_fim
medium
{ "lang": "rust", "repo": "alpheonix/rustStarfighter", "path": "/starFighter/src/spaceship.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>, pub hp: i64, pub damage: i64, pub adventage: bool, pub miss : i64 }<|fim_prefix|>// repo: alpheonix/rustStarfighter path: /starFighter/src/spaceship.rs pub struct Spaceship { pub _id: String<|fim_middle|>, pub name: String, pub speed: i64
code_fim
easy
{ "lang": "rust", "repo": "alpheonix/rustStarfighter", "path": "/starFighter/src/spaceship.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PkmX/rust path: /src/librustc/traits/trans/mod.rs // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // htt...
code_fim
hard
{ "lang": "rust", "repo": "PkmX/rust", "path": "/src/librustc/traits/trans/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { tcx, param_env } } fn fold<T: TypeFoldable<'gcx>>(&mut self, value: &T) -> T { if !value.has_projections() { value.clone() } else { value.fold_with(self) } } } impl<'a, 'gcx> TypeFolder<'gcx, 'gcx> for AssociatedTypeNormalizerEnv...
code_fim
hard
{ "lang": "rust", "repo": "PkmX/rust", "path": "/src/librustc/traits/trans/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn fold_ty(&mut self, ty: Ty<'gcx>) -> Ty<'gcx> { if !ty.has_projections() { ty } else { debug!("AssociatedTypeNormalizerEnv: ty={:?}", ty); self.tcx.normalize_associated_type_in_env(&ty, self.param_env) } } } // Implement DepTrackingMap...
code_fim
hard
{ "lang": "rust", "repo": "PkmX/rust", "path": "/src/librustc/traits/trans/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blakehawkins/aoc-2020 path: /src/main.rs b) .collect::<HashSet<_>>(); (goal, variants.contains(&goal)) }) .find(|(_, succ)| !succ) .unwrap() .0 } pub fn day9_part2(input: &str, goal: usize) -> usize { ...
code_fim
hard
{ "lang": "rust", "repo": "blakehawkins/aoc-2020", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blakehawkins/aoc-2020 path: /src/main.rs .finish() .ok() .filter(|(i, _)| i.is_empty()) .map(|(_, out)| out) }) .is_some() } } struct Ecl<'a>(Option<&'a str>); ...
code_fim
hard
{ "lang": "rust", "repo": "blakehawkins/aoc-2020", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn part2(input: &str) -> usize { let initial_actives = get_actives(input); let mut actives = initial_actives .into_iter() .map(|(x, y)| (x, y, 0isize, 0isize)) .collect::<HashSet<_>>(); let mut next_actives = actives.clone(); l...
code_fim
hard
{ "lang": "rust", "repo": "blakehawkins/aoc-2020", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let to_test = vec![3, 8, -10, 23, 19, -4, -14, 27]; let res = Solution::minimum_abs_difference(to_test); assert_eq!(res, vec![vec![-14, -10], vec![19, 23], vec![23, 27]]); }<|fim_prefix|>// repo: kiraclf/leetCodePractice path: /rust_practice/src/minimum_absolute_difference_1200.rs #[allow(unu...
code_fim
medium
{ "lang": "rust", "repo": "kiraclf/leetCodePractice", "path": "/rust_practice/src/minimum_absolute_difference_1200.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kiraclf/leetCodePractice path: /rust_practice/src/minimum_absolute_difference_1200.rs #[allow(unused)] struct Solution {} impl Solution { #[allow(unused)] pub fn minimum_abs_difference(arr: Vec<i32>) -> Vec<Vec<i32>> { let mut sorted_arr = arr.clone(); sorted_arr.sort();...
code_fim
medium
{ "lang": "rust", "repo": "kiraclf/leetCodePractice", "path": "/rust_practice/src/minimum_absolute_difference_1200.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match Regex::new(r"(\d{4})\-(\d{2})-(\d{2})") { Ok(pattern) => { match pattern.captures("2019-02-01") { Some(matches) => { assert_eq!(&matches[0], "2019-02-01"); assert_eq!(&matches[1], "2019"); ...
code_fim
hard
{ "lang": "rust", "repo": "0x-ff/learning-artifacts", "path": "/rust/example/src/types/regex.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0x-ff/learning-artifacts path: /rust/example/src/types/regex.rs pub mod regex { use regex::Regex; #[test] fn test_is_match() { match Regex::new(r"(\d{4})\-(\d{2})-(\d{2})") { Ok(pattern) => { assert!(pattern.is_match("2019-01-01")); ...
code_fim
hard
{ "lang": "rust", "repo": "0x-ff/learning-artifacts", "path": "/rust/example/src/types/regex.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut is = File::open(&Path::new(bin)).unwrap(); let fds = parse_from_reader::<FileDescriptorSet>(&mut is as &mut Reader).unwrap(); let file_names: Vec<String> = fds.get_file().iter() .map(|f| f.get_name().to_string()) .collect(); let results = gen(fds.get_file(), file_n...
code_fim
medium
{ "lang": "rust", "repo": "cristicbz/rust-protobuf", "path": "/src/protobuf-bin-gen-rust.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cristicbz/rust-protobuf path: /src/protobuf-bin-gen-rust.rs #![crate_type = "bin"] #![feature(globs)] extern crate protobuf; extern crate getopts; use std::io::fs::*; use std::io::Reader; use std::io::Writer; use std::path::Path; use std::os; use protobuf::parse_from_reader; use protobuf::des...
code_fim
hard
{ "lang": "rust", "repo": "cristicbz/rust-protobuf", "path": "/src/protobuf-bin-gen-rust.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let counter = Rc::new(Cell::new(0)); let mut x = SomeGoableThing { counter: counter.clone() }; go(&x, 10); assert_eq!(counter.get(), 10); go_mut(&mut x, 100); assert_eq!(counter.get(), 110); go_once(x, 1_000); assert_eq!(counter.get(), 1_110); let x = SomeGoOnceable...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/traits/traits-conditional-model-fn.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>struct SomeGoOnceableThing { counter: Rc<Cell<isize>> } impl GoOnce for SomeGoOnceableThing { fn go_once(self, arg: isize) { self.counter.set(self.counter.get() + arg); } } fn main() { let counter = Rc::new(Cell::new(0)); let mut x = SomeGoableThing { counter: counter.clone()...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/traits/traits-conditional-model-fn.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/traits/traits-conditional-model-fn.rs // run-pass #![allow(unused_imports)] // A model for how the `Fn` traits could work. You can implement at // most one of `Go`, `GoMut`, or `GoOnce`, and then the others follow // automatically. // aux-build...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/traits/traits-conditional-model-fn.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> messages.enqueue(Box::new(MessageXPTO::Progress { label_ptr: Rc::downgrade(&label_1), progress_ptr: Rc::downgrade(&progressbar_1), num_ptr: Rc::downgrade(&counter), inc: 5.2, event: None, })); messages.enqueue(Box::new(MessageXPTO::Progress { la...
code_fim
hard
{ "lang": "rust", "repo": "hyber-gp/hyber_raqote", "path": "/src/bin/progress_bar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hyber-gp/hyber_raqote path: /src/bin/progress_bar.rs use hyber::display::Display; use hyber::event::Event; use hyber::renderer::{AbsoluteWidgetCollection, Message, RenderInstructionCollection, Renderer}; use hyber::util::{Color, IDMachine, Vector2D}; use hyber::widget::grid_view::GridViewWidget;...
code_fim
hard
{ "lang": "rust", "repo": "hyber-gp/hyber_raqote", "path": "/src/bin/progress_bar.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>]: The Value of the Transmit Bits"] pub mod spi_tbr; #[doc = "spi_rbr (rw) register accessor: an alias for `Reg<SPI_RBR_SPEC>`"] pub type SPI_RBR = crate::Reg<spi_rbr::SPI_RBR_SPEC>; #[doc = "SPI RX Bit Register\n\nVRB \\[31:0\\]: The Value of the Receive Bits"] pub mod spi_rbr; #[doc = "spi_ndma_mode_ctl...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/spi0.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /d1-pac/src/spi0.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { _reserved0: [u8; 0x04], #[doc = "0x04 - SPI Global Control Register"] pub spi_gcr: SPI_GCR, #[doc = "0x08 - SPI Transfer Control Register"] pub spi_tcr: SPI_TCR, ...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/spi0.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, GamePlayEndTransitionDelaySystemData { game_play_ec, mut game_play_end_transition_delay_clock, }: Self::SystemData, ) { game_play_end_transition_delay_clock.tick(); let game_play_event_rid = self .game_play_event_r...
code_fim
medium
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/game_play/src/system/game_play_end_transition_delay_system.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/game_play/src/system/game_play_end_transition_delay_system.rs use amethyst::{ ecs::{Read, System, World, Write}, shred::{ResourceId, SystemData}, shrev::{EventChannel, ReaderId}, }; use derivative::Derivative; use derive_new::new; use game_play_mode...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/game_play/src/system/game_play_end_transition_delay_system.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Immortalin/puddle path: /puddle-core/src/process/manager.rs use std::ops::{Deref, DerefMut, Drop}; use std::sync::{Arc, Mutex}; use crate::grid::{DropletInfo, Grid}; use crate::process::{Process, ProcessId, PuddleError, PuddleResult}; use crate::system::System; use indexmap::IndexMap; pub str...
code_fim
hard
{ "lang": "rust", "repo": "Immortalin/puddle", "path": "/puddle-core/src/process/manager.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }