text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> pub fn bind_solid(&'a mut self, bfc_certified: bool) -> &'a ShadedProgram<T> { if let Some(e) = &self.bound { match (e, bfc_certified) { (ProgramKind::Solid(p), true) => return p, (ProgramKind::SolidFlat(p), false) => return p, (_, _)...
code_fim
hard
{ "lang": "rust", "repo": "forkeith/ldraw.rs", "path": "/renderer/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkeith/ldraw.rs path: /renderer/src/state.rs use crate::shader::{Bindable, EdgeProgram, ProgramKind, ProgramManager, ShadedProgram}; use crate::GL; pub struct State<'a, T: GL> { program_manager: ProgramManager<T>, bound: Option<ProgramKind<'a, T>>, } <|fim_suffix|> pub fn bind_sol...
code_fim
hard
{ "lang": "rust", "repo": "forkeith/ldraw.rs", "path": "/renderer/src/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn bind_edge(&'a mut self) -> &'a EdgeProgram<T> { if let Some(e) = &self.bound { if let ProgramKind::Edge(p) = e { return p; } else { e.unbind(); } } self.bound = Some(ProgramKind::Edge(&self.program_mana...
code_fim
hard
{ "lang": "rust", "repo": "forkeith/ldraw.rs", "path": "/renderer/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Circle { pub x: f64, pub y: f64, pub radius: f64, } pub trait HasArea { fn area(&self) -> f64; } impl HasArea for Rectangle { fn area(&self) -> f64 { &self.length * &self.width } } impl HasArea for Circle { fn area(&self) -> f64 { std::f64::consts::...
code_fim
medium
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/three_days_of_rust/three_days_of_rust.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TianTianForever/Rust-Tutorial path: /three_days_of_rust/three_days_of_rust.rs // three_days_of_rust.rs // This crate is library. // Generic type 'Point'. pub struct Point<T>(pub T, pub T); // implement of Point for a generic type 'T'. impl <T> Point<T> { pub fn take_x(&self) -> &T { ...
code_fim
medium
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/three_days_of_rust/three_days_of_rust.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Define a generic function 'print_area'. pub fn print_area<T: HasArea> (shape: T) { println!("This shape has an area of {}", shape.area()); }<|fim_prefix|>// repo: TianTianForever/Rust-Tutorial path: /three_days_of_rust/three_days_of_rust.rs // three_days_of_rust.rs // This crate is library. // Ge...
code_fim
hard
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/three_days_of_rust/three_days_of_rust.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns `Some` with the command line string if this is a `Cmd` ATAG. /// Otherwise returns `None`. pub fn cmd(self) -> Option<&'static str> { unimplemented!() } } // FIXME: Implement `From<&raw::Atag> for `Atag`. impl From<&'static raw::Atag> for Atag { fn from(atag: &'sta...
code_fim
hard
{ "lang": "rust", "repo": "yihozhang/cs3210rustos", "path": "/lib/pi/src/atags/atag.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yihozhang/cs3210rustos path: /lib/pi/src/atags/atag.rs use crate::atags::raw; pub use crate::atags::raw::{Core, Mem}; /// An ATAG. #[derive(Debug, Copy, Clone, PartialEq)] pub enum Atag { Core(raw::Core), Mem(raw::Mem), Cmd(&'static str), Unknown(u32), None, } impl Atag { ...
code_fim
hard
{ "lang": "rust", "repo": "yihozhang/cs3210rustos", "path": "/lib/pi/src/atags/atag.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn world_constructor_hook(world: *mut target::gfc__World) { if PRETENDING.load(Ordering::SeqCst) { (*world).mInEditor = true; } }<|fim_prefix|>// repo: whatisaphone/war-is-here path: /crates/aether/src/commands/editor_mode.rs use darksiders1_sys::target; use std::sync::atomic::...
code_fim
hard
{ "lang": "rust", "repo": "whatisaphone/war-is-here", "path": "/crates/aether/src/commands/editor_mode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whatisaphone/war-is-here path: /crates/aether/src/commands/editor_mode.rs use darksiders1_sys::target; use std::sync::atomic::{AtomicBool, Ordering}; static PRETENDING: AtomicBool = AtomicBool::new(false); <|fim_suffix|>pub unsafe fn world_constructor_hook(world: *mut target::gfc__World) { ...
code_fim
hard
{ "lang": "rust", "repo": "whatisaphone/war-is-here", "path": "/crates/aether/src/commands/editor_mode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl LolCatalogItemChoiceDetails { pub fn new() -> LolCatalogItemChoiceDetails { LolCatalogItemChoiceDetails { background_image: None, contents: None, discount: None, display_type: None, full_price: None, item: None, ...
code_fim
hard
{ "lang": "rust", "repo": "Potato-Gaming/crystal", "path": "/league-client/src/models/lol_catalog_item_choice_details.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Potato-Gaming/crystal path: /league-client/src/models/lol_catalog_item_choice_details.rs /* * * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 * * Generated by: https://openapi-g...
code_fim
hard
{ "lang": "rust", "repo": "Potato-Gaming/crystal", "path": "/league-client/src/models/lol_catalog_item_choice_details.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Questionable-Research-Labs/EsquaredG_PicoscopeMonitering path: /src/app/mod.rs pub mod state; use actix_web::{get, web::Data, HttpResponse}; use parking_lot::Mutex; use std::time::Instant; use crate::pico::clear_and_get_memory; use super::state::AppState; use serde_json; // / #[get("/")] p...
code_fim
hard
{ "lang": "rust", "repo": "Questionable-Research-Labs/EsquaredG_PicoscopeMonitering", "path": "/src/app/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Mounts to /api/device-info #[get("/device-info")] pub fn device_info(state: Data<Mutex<AppState>>) -> HttpResponse { let locked_state = state.lock(); let device_info = locked_state.device_info.clone(); drop(locked_state); return HttpResponse::Ok() .content_type("application/jso...
code_fim
medium
{ "lang": "rust", "repo": "Questionable-Research-Labs/EsquaredG_PicoscopeMonitering", "path": "/src/app/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gevorgyana/rust-problem-solving path: /minimum-in-rotated-sorted-array/src/medium/binary/libs/mod.rs use superslice::*; use std::cmp; fn rotation_index(vec: &Vec<i32>) -> i32 { let reversed_vec = vec .iter() .rev(); let cooked = reversed_vec .zip(...
code_fim
medium
{ "lang": "rust", "repo": "gevorgyana/rust-problem-solving", "path": "/minimum-in-rotated-sorted-array/src/medium/binary/libs/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // not moved at all assert_eq!(rotation_index(&vec![1, 2, 3, 4]), 0); assert_eq!(minimum_in_rotated_array(0, &vec![1, 2, 3, 4]), 1); // moved around the first hole assert_eq!(rotation_index(&vec![2, 3, 4, 1]), 1); assert_eq!(minimum_in_rotated_array(1, &vec![2, 3, 4, 1]), 1); /...
code_fim
medium
{ "lang": "rust", "repo": "gevorgyana/rust-problem-solving", "path": "/minimum-in-rotated-sorted-array/src/medium/binary/libs/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> mod seccomp; pub mod signal; pub mod syscall; pub mod tty; pub mod utils;<|fim_prefix|>// repo: anyawal/youki path: /src/lib.rs pub mod apparmor; pub mod capabilities; pub mod commands; pub mod contain<|fim_middle|>er; pub mod dbus; pub mod hooks; pub mod logger; pub mod namespaces; pub mod notify_socke...
code_fim
medium
{ "lang": "rust", "repo": "anyawal/youki", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anyawal/youki path: /src/lib.rs pub mod apparmor; pub mod capabilities; pub mod commands; pub mod contain<|fim_suffix|> mod seccomp; pub mod signal; pub mod syscall; pub mod tty; pub mod utils;<|fim_middle|>er; pub mod dbus; pub mod hooks; pub mod logger; pub mod namespaces; pub mod notify_socke...
code_fim
medium
{ "lang": "rust", "repo": "anyawal/youki", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let color = Rgb::new(50, 155, 255); for x in 50..250 { for y in 50..150 { fb.put_pixel(x, y, color.clone()); } } } #[panic_handler] fn panic(_info: &core::panic::PanicInfo) -> ! { loop { unsafe { asm!("hlt") } } }<|fim_prefix|>// repo: rabe1028/tac...
code_fim
hard
{ "lang": "rust", "repo": "rabe1028/tachibana", "path": "/tachibana-kernel/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rabe1028/tachibana path: /tachibana-kernel/src/main.rs #![no_std] #![no_main] #![feature(asm)] #![feature(lang_items)] use tachibana_common::frame_buffer::{Bgr, ColorSpace, FrameBuffer, FrameBufferPayload, Rgb}; #[no_mangle] pub extern "sysv64" fn kernel_main(fb: &mut FrameBuffer) { match ...
code_fim
hard
{ "lang": "rust", "repo": "rabe1028/tachibana", "path": "/tachibana-kernel/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let op = Or::new(0x8281); let cpu = Cpu { pc: 4, ..Cpu::new().set_register(2, 0x04).set_register(8, 0xFF) }; assert_eq!( Cpu { pc: 6, ..Cpu::new().set_register(2, 0xFF).set_register(8, 0xFF) },...
code_fim
hard
{ "lang": "rust", "repo": "marosluuce/rchip8", "path": "/src/ops/or.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marosluuce/rchip8 path: /src/ops/or.rs use cpu::Cpu; use ops::op::{Matcher, Op}; use std::fmt; pub struct Or { register1: usize, register2: usize, } impl Op for Or { fn execute(&self, cpu: Cpu) -> Cpu { cpu.update_register(self.register1, |x| x | cpu.registers[self.register...
code_fim
hard
{ "lang": "rust", "repo": "marosluuce/rchip8", "path": "/src/ops/or.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vlmonk/advent2019 path: /day01/src/main.rs use std::error::Error; use std::fs; fn calc(input: i64) -> i64 { input / 3 - 2 } fn calc2(input: i64) -> i64 { let mut total = calc(input); let mut current = total; loop { let step = calc(current); if step <= 0 { ...
code_fim
medium
{ "lang": "rust", "repo": "vlmonk/advent2019", "path": "/day01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_calc() { assert_eq!(2, calc(12)); assert_eq!(33583, calc(100756)); } #[test] fn test_calc2() { assert_eq!(2, calc2(12)); assert_eq!(966, calc2(1969)); assert_eq!(50346, calc2(100756)); } }<|fim_prefix|>// repo: vlmonk/advent2...
code_fim
medium
{ "lang": "rust", "repo": "vlmonk/advent2019", "path": "/day01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryym/exercism path: /rust/isbn-verifier/src/lib.rs /// Determines whether the supplied string is a valid ISBN number pub fn is_valid_isbn(isbn: &str) -> bool { let mut<|fim_suffix|>10, _ => return false, }; sum += n * i; i -= 1; } i == 0 && sum % ...
code_fim
hard
{ "lang": "rust", "repo": "ryym/exercism", "path": "/rust/isbn-verifier/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>alse; } let n = match c.to_digit(10) { Some(n) => n, _ if i == 1 && c == 'X' => 10, _ => return false, }; sum += n * i; i -= 1; } i == 0 && sum % 11 == 0 }<|fim_prefix|>// repo: ryym/exercism path: /rust/isbn-verifier/sr...
code_fim
medium
{ "lang": "rust", "repo": "ryym/exercism", "path": "/rust/isbn-verifier/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!( "{:?}", Solution::subdomain_visits(vec![ String::from("900 google.mail.com"), String::from("50 yahoo.com"), String::from("1 intel.mail.com"), String::from("5 wiki.org") ]) ); ...
code_fim
hard
{ "lang": "rust", "repo": "qinxiaoguang/rs-lc", "path": "/src/solution/l811.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qinxiaoguang/rs-lc path: /src/solution/l811.rs pub struct Solution {} /* * @lc app=leetcode.cn id=811 lang=rust * * [811] 子域名访问计数 * * https://leetcode-cn.com/problems/subdomain-visit-count/description/ * * algorithms * Easy (68.28%) * Likes: 74 * Dislikes: 0 * Total Accepted: 10...
code_fim
hard
{ "lang": "rust", "repo": "qinxiaoguang/rs-lc", "path": "/src/solution/l811.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // introduce new data for round in 0..10 { if worker.index() == 0 { input.send(round); } input.advance_to(round + 1); } }).unwrap(); }<|fim_prefix|>// repo: danalex97/rust-examples path: /timely_tutorial/src/examples/core/tim...
code_fim
hard
{ "lang": "rust", "repo": "danalex97/rust-examples", "path": "/timely_tutorial/src/examples/core/timestamps.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danalex97/rust-examples path: /timely_tutorial/src/examples/core/timestamps.rs #![allow(unused_variables)] extern crate timely; use timely::dataflow::InputHandle; use timely::dataflow::operators::{Input, Exchange, Inspect, Probe}; <|fim_suffix|> // introduce new data for round i...
code_fim
hard
{ "lang": "rust", "repo": "danalex97/rust-examples", "path": "/timely_tutorial/src/examples/core/timestamps.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tuanir/fantoch path: /fantoch_plot/src/fmt.rs use fantoch::planet::Region; use fantoch_exp::Protocol; pub struct PlotFmt; impl PlotFmt { pub fn region_name(region: Region) -> &'static str { match region.name().as_str() { "ap-southeast-1" => "Singapore", "ca-...
code_fim
hard
{ "lang": "rust", "repo": "tuanir/fantoch", "path": "/fantoch_plot/src/fmt.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Possible values: {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} pub fn hatch(protocol: Protocol, f: usize) -> String { match (protocol, f) { (Protocol::FPaxos, 1) => "/", // 1 (Protocol::FPaxos, 2) => "\\", (Protocol::EPaxosLocked, _) => "//", // ...
code_fim
hard
{ "lang": "rust", "repo": "tuanir/fantoch", "path": "/fantoch_plot/src/fmt.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Possible values: {'-', '--', '-.', ':', ''} pub fn linestyle(protocol: Protocol, f: usize) -> String { match (protocol, f) { (Protocol::AtlasLocked, _) => "--", (Protocol::EPaxosLocked, _) => ":", (Protocol::CaesarLocked, _) => ":", (Prot...
code_fim
hard
{ "lang": "rust", "repo": "tuanir/fantoch", "path": "/fantoch_plot/src/fmt.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: visioncortex/polypartition path: /visioncortex/src/path/reduce.rs //! Path simplification algorithms adapted from https://github.com/mourner/simplify-js use std::ops::*; use crate::Point2; type Float = f64; /// square distance between 2 points fn get_sq_dist<T>(p1: Point2<T>, p2: Point2<T>) -...
code_fim
hard
{ "lang": "rust", "repo": "visioncortex/polypartition", "path": "/visioncortex/src/path/reduce.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn simplify_i32() { let points = vec![ PointI32 { x: 22455, y: 25015 }, PointI32 { x: 22691, y: 24419 }, PointI32 { x: 23331, y: 24145 }, PointI32 {x: 23498, y: 23606 }, PointI32 { x: 24421, y: 23276 }, PointI32 { x: 26259, y: 21531 }, PointI32 { x: 26776, ...
code_fim
hard
{ "lang": "rust", "repo": "visioncortex/polypartition", "path": "/visioncortex/src/path/reduce.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vtec234/lists-rs path: /src/epoch_skiplist.rs .finish() } } impl<K, V, S> EpochSkiplistMap<K, V, S> where K: Eq + Hash, S: BuildHasher { /// Creates an empty map which will use the given hasher factory to hash keys. pub fn with_hash_factory(f: S) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "Vtec234/lists-rs", "path": "/src/epoch_skiplist.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vtec234/lists-rs path: /src/epoch_skiplist.rs > = pred_next; // Loop until we encounter Node::Tail while curr.deref().is_data() { let mut curr_next: Shared<Node<K, V>> = curr.deref().nexts()[lvl].load(Ordering::SeqCst, g); ...
code_fim
hard
{ "lang": "rust", "repo": "Vtec234/lists-rs", "path": "/src/epoch_skiplist.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !curr.deref().is_data() { break; } if (curr.deref().hash() == hash && curr.deref().key().borrow() == key) || curr.deref().hash() > hash { // The next node falls after the Pos...
code_fim
hard
{ "lang": "rust", "repo": "Vtec234/lists-rs", "path": "/src/epoch_skiplist.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>gram() -> (String, crate::pubkey::Pubkey) { ("solana_move_loader_program".to_string(), id()) }<|fim_prefix|>// repo: VIP21/solana path: /sdk/src/move_loader.rs crate::declare_id!("MoveLdr111111111111111111111<|fim_middle|>111111111111111"); pub fn solana_move_loader_pro
code_fim
easy
{ "lang": "rust", "repo": "VIP21/solana", "path": "/sdk/src/move_loader.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>"solana_move_loader_program".to_string(), id()) }<|fim_prefix|>// repo: VIP21/solana path: /sdk/src/move_loader.rs crate::declare_id!("MoveLdr111111111111111111111<|fim_middle|>111111111111111"); pub fn solana_move_loader_program() -> (String, crate::pubkey::Pubkey) { (
code_fim
medium
{ "lang": "rust", "repo": "VIP21/solana", "path": "/sdk/src/move_loader.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VIP21/solana path: /sdk/src/move_loader.rs crate::declare_id!("MoveLdr111111111111111111111<|fim_suffix|>gram() -> (String, crate::pubkey::Pubkey) { ("solana_move_loader_program".to_string(), id()) }<|fim_middle|>111111111111111"); pub fn solana_move_loader_pro
code_fim
easy
{ "lang": "rust", "repo": "VIP21/solana", "path": "/sdk/src/move_loader.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustAudio/cpal path: /src/platform/mod.rs iterator associated with the platform's dynamically /// dispatched [`Host`] type. pub struct SupportedOutputConfigs(SupportedOutputConfigsInner); /// Unique identifier for available hosts on the platform. #[derive(Copy, C...
code_fim
hard
{ "lang": "rust", "repo": "RustAudio/cpal", "path": "/src/platform/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self.0 { $( $(#[cfg($feat)])? SupportedInputConfigsInner::$HostVariant(ref d) => d.size_hint(), )* } } } impl Iterator for SupportedOutputConfigs { ...
code_fim
hard
{ "lang": "rust", "repo": "RustAudio/cpal", "path": "/src/platform/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'cfg> Resolver<'cfg> { pub(crate) fn new<'i, I>(config: &'cfg Config, deps: I) -> Result<Self, Error> where I: IntoIterator<Item = &'i Dep>, { let pkgs = deps .into_iter() .filter_map(|d| { d.pkg_id() .with_contex...
code_fim
medium
{ "lang": "rust", "repo": "avast/cargo-depdiff", "path": "/src/sources.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avast/cargo-depdiff path: /src/sources.rs use std::collections::HashSet; use anyhow::{Context, Error}; use cargo::core::package::{Package, PackageSet}; use cargo::core::package_id::PackageId; use cargo::core::source::SourceMap; use cargo::core::SourceId; use cargo::sources::config::SourceConfig...
code_fim
medium
{ "lang": "rust", "repo": "avast/cargo-depdiff", "path": "/src/sources.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Calling method on a 7 might look strange, but if you think about it, there // is nothing preventing the compiler from treating it as other struct type. 7.method(); "test".to_string().print(7); trait_constraints(); println!("Summary for 7: {}", 7.summarize()); }<|fim_prefix|>// r...
code_fim
hard
{ "lang": "rust", "repo": "bieganski/distributed", "path": "/dslab05/examples/advanced_traits.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bieganski/distributed path: /dslab05/examples/advanced_traits.rs use std::fmt::Display; trait TestTrait { fn method(&self); } // No type is special, trait implementation looks always the same. impl TestTrait for i32 { fn method(&self) { println!("Method in trait called: {}", *s...
code_fim
hard
{ "lang": "rust", "repo": "bieganski/distributed", "path": "/dslab05/examples/advanced_traits.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn trait_constraints() { let mut num: u32 = 0; num.add_two(); println!( "Method derived from trait constraints. Add two to 0 is: {}", num ); } // The definition of Add is copied from the standard library. trait Add<RHS = Self> { type Output; fn add(self, rhs: RHS)...
code_fim
hard
{ "lang": "rust", "repo": "bieganski/distributed", "path": "/dslab05/examples/advanced_traits.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arsing/azure-iot-mqtt path: /src/io.rs //! This module contains the I/O types used by the clients. use futures::Future; /// A [`mqtt::IoSource`] implementation used by the clients. pub struct IoSource { iothub_hostname: std::sync::Arc<str>, iothub_host: std::net::SocketAddr, authentication:...
code_fim
hard
{ "lang": "rust", "repo": "arsing/azure-iot-mqtt", "path": "/src/io.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn flush(&mut self) -> std::io::Result<()> { use tokio_io::AsyncWrite; match self.poll_flush()? { futures::Async::Ready(()) => Ok(()), futures::Async::NotReady => Err(std::io::ErrorKind::WouldBlock.into()), } } } impl<S> tokio_io::AsyncWrite for Io<S> where S: std::io::Read + tokio_io::Asy...
code_fim
hard
{ "lang": "rust", "repo": "arsing/azure-iot-mqtt", "path": "/src/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>async fn move_user_to_channel( ctx: &Context, guild: &Guild, user: &User, channel_id: ChannelId, ) -> serenity::Result<()> { guild.move_member(&ctx.http, user.id, channel_id).await } async fn assign_banishment( ctx: &Context, guild: &Guild, user: &User, member: &mut Me...
code_fim
hard
{ "lang": "rust", "repo": "SuperiorJT/mr-cd-projekt-red", "path": "/src/commands/admin/shadow_realm.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SuperiorJT/mr-cd-projekt-red path: /src/commands/admin/shadow_realm.rs use std::thread; use std::time::Duration; use serenity::framework::standard::{macros::command, Args, CommandResult}; use serenity::model::guild::Guild; use serenity::model::prelude::{ChannelId, Member, Message, RoleId, User}...
code_fim
hard
{ "lang": "rust", "repo": "SuperiorJT/mr-cd-projekt-red", "path": "/src/commands/admin/shadow_realm.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> send_msg(ctx, msg, punish_msg).await; // They must stay banished for a period of time thread::sleep(Duration::from_millis(5000)); for (user, member, channel_id) in members.iter_mut() { if user.id == msg.author.id { move_...
code_fim
hard
{ "lang": "rust", "repo": "SuperiorJT/mr-cd-projekt-red", "path": "/src/commands/admin/shadow_realm.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> startpt: Point2<f32>, ctrlpt: Point2<f32>, endpt: Point2<f32>, samples: i32, ) -> Vec<(f32, Point2<f32>)> { let mut points = Vec::new(); for i in 0..samples { let t = (i as f32) / (samples - 1) as f32; let precisept = Point2 { x: (1.0 - t).powf(2.0) * st...
code_fim
hard
{ "lang": "rust", "repo": "canselcik/libremarkable", "path": "/src/framebuffer/graphics.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: canselcik/libremarkable path: /src/framebuffer/graphics.rs use crate::framebuffer::cgmath::*; use crate::framebuffer::common::*; macro_rules! min { ($x: expr) => ($x); ($x: expr, $($z: expr),+) => (::std::cmp::min($x, min!($($z),*))); } macro_rules! max { ($x: expr) => ...
code_fim
hard
{ "lang": "rust", "repo": "canselcik/libremarkable", "path": "/src/framebuffer/graphics.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: camerondubas/exercism-rust path: /sublist/src/lib.rs #[derive(Debug, PartialEq)] pub enum Comparison { Equal, Sublist, Superlist, Unequal, } <|fim_suffix|> let first_is_longer = _first_list.len() > _second_list.len(); let long_list; let short_list; if first_is_lo...
code_fim
hard
{ "lang": "rust", "repo": "camerondubas/exercism-rust", "path": "/sublist/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if first_is_longer { long_list = _first_list; short_list = _second_list; } else { long_list = _second_list; short_list = _first_list; } if long_list.windows(short_list.len()).any(|window| window == short_list) { if first_is_longer { return Compa...
code_fim
medium
{ "lang": "rust", "repo": "camerondubas/exercism-rust", "path": "/sublist/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rng = rand::thread_rng(); let request = tonic::Request::new(NewDogRequest{ breed:rng.gen_range(0..3)}, ); let response = client.send(request).await?.into_inner(); println!("Response = {:?}", response); Ok(()) }<|fim_prefix|>// repo: akirwski/rust_demo path: /client.rs use dog...
code_fim
hard
{ "lang": "rust", "repo": "akirwski/rust_demo", "path": "/client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let response = client.send(request).await?.into_inner(); println!("Response = {:?}", response); Ok(()) }<|fim_prefix|>// repo: akirwski/rust_demo path: /client.rs use dog::dog_client::DogClient; use dog::NewDogRequest; use rand::Rng; mod dog; <|fim_middle|>#[tokio::main] async fn main() -> R...
code_fim
hard
{ "lang": "rust", "repo": "akirwski/rust_demo", "path": "/client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akirwski/rust_demo path: /client.rs use dog::dog_client::DogClient; use dog::NewDogRequest; use rand::Rng; mod dog; <|fim_suffix|> let response = client.send(request).await?.into_inner(); println!("Response = {:?}", response); Ok(()) }<|fim_middle|>#[tokio::main] async fn main() -> R...
code_fim
hard
{ "lang": "rust", "repo": "akirwski/rust_demo", "path": "/client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Win32/System/Com/Marshal/mod.rs { #[link(name = "windows")] extern "system" { fn BSTR_UserUnmarshal64(param0: *const u32, param1: *const u8, param2: *mut ::core::mem::ManuallyDrop<super::super::super::Foundation::BSTR>)...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/Com/Marshal/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } ::core::mem::transmute(HGLOBAL_UserSize64(::core::mem::transmute(param0), ::core::mem::transmute(param1), ::core::mem::transmute(param2))) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn HGLOBAL_UserUnmarshal(param0: *const u32, param...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/Com/Marshal/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } ::core::mem::transmute(CLIPFORMAT_UserMarshal64(::core::mem::transmute(param0), ::core::mem::transmute(param1), ::core::mem::transmute(param2))) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn CLIPFORMAT_UserSize(param0: *const u32, p...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/Com/Marshal/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: standardgalactic/diplomat path: /tool/src/c/structs.rs use std::fmt::Write; use std::{collections::HashMap, fmt}; use diplomat_core::ast; use indenter::indented; use super::types::c_type_for_prim; use super::types::gen_type; pub fn gen_struct<W: fmt::Write>( custom_type: &ast::CustomType,...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/diplomat", "path": "/tool/src/c/structs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> test_file! { #[diplomat::bridge] mod ffi { #[diplomat::opaque] struct MyStruct(UnknownType); impl MyStruct { pub fn new_str(v: &str) -> Box<MyStruct> { unimplemented!() ...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/diplomat", "path": "/tool/src/c/structs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_simple_opaque_struct() { test_file! { #[diplomat::bridge] mod ffi { #[diplomat::opaque] struct MyStruct(UnknownType); impl MyStruct { pub fn new(a: u8, b: u8) -> Box<MyStruct> { ...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/diplomat", "path": "/tool/src/c/structs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maurer/mycroft path: /tests/aggregate.rs use mycroft_macros::mycroft_program; type Vu16 = Vec<u16>; fn u8_plus(xs: &[u8]) -> u8 { let mut out = 0; for x in xs { out += *x; } out } fn vu16_append(xs: &[&Vu16]) -> Vu16 { let mut out = Vec::new(); for x in xs { ...
code_fim
hard
{ "lang": "rust", "repo": "maurer/mycroft", "path": "/tests/aggregate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use crate::mycroft_program::{Bar, Database, GetBarResult}; let mut db = Database::new(); assert_eq!(db.query_get_bar(), vec![]); db.insert_bar(Bar { arg0: vec![1, 3, 5], }); db.insert_bar(Bar { arg0: vec![2, 4, 8], }); assert_eq!( db.query_get_bar(),...
code_fim
medium
{ "lang": "rust", "repo": "maurer/mycroft", "path": "/tests/aggregate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use crate::mycroft_program::{Database, Foo, GetFooResult}; let mut db = Database::new(); assert_eq!(db.query_get_foo(), vec![]); db.insert_foo(Foo { arg0: 3 }); db.insert_foo(Foo { arg0: 42 }); assert_eq!(db.query_get_foo(), vec![GetFooResult { out: 45 }]); } #[test] fn insert_agg...
code_fim
medium
{ "lang": "rust", "repo": "maurer/mycroft", "path": "/tests/aggregate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LukeMinnich/quick-fea path: /src/lib.rs extern crate nalgebra as na; extern crate quick_fea_types as types; extern crate serde; extern crate wasm_bindgen; #[macro_use] extern crate approx; #[macro_use] extern crate lazy_static; pub mod analysis; pub mod elements; pub mod models; pub mod utils; ...
code_fim
hard
{ "lang": "rust", "repo": "LukeMinnich/quick-fea", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ElementData { frames: HashMap::<String, FrameElement>::new(), nodes: HashMap::<String, Node>::new(), } } } pub fn add_node(node: Node) { ELEMENT_DATA .write() .unwrap() .nodes .insert(node.id.clone(), node); } // TODO is the...
code_fim
hard
{ "lang": "rust", "repo": "LukeMinnich/quick-fea", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> mut self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>, ) -> std::task::Poll<Self::Output> { match std::mem::replace(&mut *self, WsConnect::Invalid) { WsConnect::Handshake(mut handshake) => { handshake.get_mut().get_mut().set_cx(cx); ...
code_fim
hard
{ "lang": "rust", "repo": "Azure/iotedge", "path": "/edge-modules/api-proxy-module/rust-sdk/azure-iot-mqtt/src/io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>enum WsConnect<S> where S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin, { Handshake(tungstenite::handshake::MidHandshake<tungstenite::ClientHandshake<TokioToStd<S>>>), Invalid, } impl<S> std::fmt::Debug for WsConnect<S> where S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpi...
code_fim
hard
{ "lang": "rust", "repo": "Azure/iotedge", "path": "/edge-modules/api-proxy-module/rust-sdk/azure-iot-mqtt/src/io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Azure/iotedge path: /edge-modules/api-proxy-module/rust-sdk/azure-iot-mqtt/src/io.rs ne(); let authentication = match &self.authentication { crate::Authentication::SasKey { device_id, key, max_token_valid_duration, ...
code_fim
hard
{ "lang": "rust", "repo": "Azure/iotedge", "path": "/edge-modules/api-proxy-module/rust-sdk/azure-iot-mqtt/src/io.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>xpect("Error setting Ctrl-C handler"); }<|fim_prefix|>// repo: stepht/devrc path: /src/interrupt.rs pub fn setup_interrupt_handler() { ctrlc::set_handler(move || { pri<|fim_middle|>ntln!("CTRL-C received"); }) .e
code_fim
easy
{ "lang": "rust", "repo": "stepht/devrc", "path": "/src/interrupt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stepht/devrc path: /src/interrupt.rs pub fn setup_interrupt_handler() { ctrlc::set_handler(move || { pri<|fim_suffix|>xpect("Error setting Ctrl-C handler"); }<|fim_middle|>ntln!("CTRL-C received"); }) .e
code_fim
easy
{ "lang": "rust", "repo": "stepht/devrc", "path": "/src/interrupt.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koalp/rust-atelier path: /atelier-lib/src/action.rs /*! This module provides functions that wrap common actions into single entry points. The two entry points ensure that standard lint and validation actions are always easily accessible to the user. */ <|fim_suffix|>// -------------------------...
code_fim
hard
{ "lang": "rust", "repo": "koalp/rust-atelier", "path": "/atelier-lib/src/action.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/sprite_loading/src/sprite_loader.rs use std::path::Path; use amethyst::{ assets::{AssetStorage, Loader, ProgressCounter}, renderer::{sprite::SpriteSheetHandle, SpriteSheet, Texture}, Error, }; use sprite_model::config::SpritesDefinition; <|fim_suf...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/sprite_loading/src/sprite_loader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl SpriteLoader { /// Loads sprite sheet layout and texture data and returns their handles. /// /// The sprites base directory is expected to contain: /// /// * `sprites.yaml`: Configuration file that defines what sprites to load. /// * Sprite sheets: The images that contain the ...
code_fim
medium
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/sprite_loading/src/sprite_loader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crispamares/helio path: /src/scale/linear_scale.rs use crate::scale::interpolate; #[derive(Debug, Builder, Default, PartialEq)] #[builder(setter(into))] pub struct LinearScale { #[builder(default = "[0.0, 1.0]")] pub domain:[f64; 2], #[builder(default = "[0.0, 1.0]")] pub range...
code_fim
hard
{ "lang": "rust", "repo": "crispamares/helio", "path": "/src/scale/linear_scale.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( scale.call(&[1.0, 2.0, 3.0, 4.0, 5.0]), [0.0, 100.0, 200.0, 300.0, 400.0] ); } #[test] fn invert_works() { let scale: LinearScale = LinearScaleBuilder::default() .domain([1.0, 2.0]) .range([10.0, 20.0]) .build().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "crispamares/helio", "path": "/src/scale/linear_scale.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>generate_exported!();<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/auxiliary/dollar-crate-nested-encoding.rs pub type S = u8; <|fim_middle|>macro_rules! generate_exported { () => { #[macro_export] macro_rules! exported { () => ($crate::S) } }}
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/macros/auxiliary/dollar-crate-nested-encoding.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/auxiliary/dollar-crate-nested-encoding.rs pub type S = u8; <|fim_suffix|>generate_exported!();<|fim_middle|>macro_rules! generate_exported { () => { #[macro_export] macro_rules! exported { () => ($crate::S) } }}
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/macros/auxiliary/dollar-crate-nested-encoding.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: porky11/ncollide path: /ncollide_transformation/to_trimesh/reflection_to_trimesh.rs use geometry::shape::Reflection; use procedural::TriMesh; use super::ToTriMesh; use math::Point; impl<'a, P: Point, G: ToTriMesh<P, I>, I> ToTriMesh<P, I> for Reflection<'a, G> { fn to_trimesh(&self, paramet...
code_fim
easy
{ "lang": "rust", "repo": "porky11/ncollide", "path": "/ncollide_transformation/to_trimesh/reflection_to_trimesh.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for c in res.coords.iter_mut() { *c = -*c; } res } }<|fim_prefix|>// repo: porky11/ncollide path: /ncollide_transformation/to_trimesh/reflection_to_trimesh.rs use geometry::shape::Reflection; use procedural::TriMesh; use super::ToTriMesh; use math::Point; <|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "porky11/ncollide", "path": "/ncollide_transformation/to_trimesh/reflection_to_trimesh.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>ring) { description("malformed file") display("malformed file: {}", message) } } }<|fim_prefix|>// repo: dylanmckay/javabc path: /src/errors.rs error_chain! { foreign_links { Io(::std::io::Er<|fim_middle|>ror); } errors { MalformedFile(mess...
code_fim
easy
{ "lang": "rust", "repo": "dylanmckay/javabc", "path": "/src/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dylanmckay/javabc path: /src/errors.rs error_chain! { foreign_links { Io(::std::io::Er<|fim_suffix|>ring) { description("malformed file") display("malformed file: {}", message) } } }<|fim_middle|>ror); } errors { MalformedFile(mess...
code_fim
easy
{ "lang": "rust", "repo": "dylanmckay/javabc", "path": "/src/errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> display("malformed file: {}", message) } } }<|fim_prefix|>// repo: dylanmckay/javabc path: /src/errors.rs error_chain! { foreign_links { Io(::std::io::Error); } errors { MalformedFile(message: St<|fim_middle|>ring) { description("malformed file") ...
code_fim
easy
{ "lang": "rust", "repo": "dylanmckay/javabc", "path": "/src/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 3for/tk-http path: /src/client/client.rs use futures::sink::Sink; use futures::future::FutureResult; use futures::{Async, AsyncSink, Future, IntoFuture}; use client::{Error, Encoder, EncoderDone, Head, RecvMode}; use client::errors::ErrorEnum; use client::buffered; #[derive(Debug, Copy, Clone...
code_fim
hard
{ "lang": "rust", "repo": "3for/tk-http", "path": "/src/client/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> (**self).headers_received(headers) } fn data_received(&mut self, data: &[u8], end: bool) -> Result<Async<usize>, Error> { (**self).data_received(data, end) } } /// A marker trait that applies to a Sink that is essentially a HTTP client /// /// It may apply to a sin...
code_fim
hard
{ "lang": "rust", "repo": "3for/tk-http", "path": "/src/client/client.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// A marker trait that applies to a Sink that is essentially a HTTP client /// /// It may apply to a single connection or a connection pool. For a single /// connection the `client::Proto` implements this interface. /// /// We expect a boxed codec here because we assume that different kinds of /// reques...
code_fim
hard
{ "lang": "rust", "repo": "3for/tk-http", "path": "/src/client/client.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luizdepra/exercism path: /rust/space-age/src/lib.rs #[derive(Debug)] pub struct Duration { seconds: f64, } impl Duration { fn seconds(&self) -> f64 { self.seconds } } impl From<u64> for Duration { fn from(s: u64) -> Self { Duration{ seconds: s as f64 } } } ...
code_fim
hard
{ "lang": "rust", "repo": "luizdepra/exercism", "path": "/rust/space-age/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Planet for Venus { const YEAR_IN_SECONDS: f64 = 19_414_149.052176; } impl Planet for Earth { const YEAR_IN_SECONDS: f64 = 31_557_600.0; } impl Planet for Mars { const YEAR_IN_SECONDS: f64 = 59_354_032.690079994; } impl Planet for Jupiter { const YEAR_IN_SECONDS: f64 = 374_355_659.1...
code_fim
medium
{ "lang": "rust", "repo": "luizdepra/exercism", "path": "/rust/space-age/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jacobmischka/adventofcode-2020 path: /src/bin/23.rs use std::{ collections::BTreeMap, io::{self, Read}, marker::PhantomPinned, pin::Pin, ptr, }; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let input_vals: Vec<usize...
code_fim
hard
{ "lang": "rust", "repo": "jacobmischka/adventofcode-2020", "path": "/src/bin/23.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for val in iter { max_val = max_val.max(val); let mut cup = Box::pin(Cup { val, next: ptr::null_mut(), _pin: PhantomPinned, }); if let Some(prev) = cups .last_mut() .map(|prev| prev.as_mut().get_unchecked_mut...
code_fim
hard
{ "lang": "rust", "repo": "jacobmischka/adventofcode-2020", "path": "/src/bin/23.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..10_000_000 { current = play_round(&mut cups, current, NUM_CUPS); } let next = (*cups.get_mut(&1).unwrap().as_ref().get_ref()).next; let part_2: u128 = (*next).val as u128 * (*(*next).next).val as u128; println!("Part 2: {}", part_2); } }...
code_fim
hard
{ "lang": "rust", "repo": "jacobmischka/adventofcode-2020", "path": "/src/bin/23.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ko1N/frame_counter path: /examples/limiter.rs use frame_counter::FrameCounter; pub fn dummy_workload() { std::thread::sleep(std::time::Duration::from_millis(1)); } <|fim_suffix|> println!("fps stats - {}", frame_counter); } }<|fim_middle|>pub fn main() { let mut frame_counte...
code_fim
hard
{ "lang": "rust", "repo": "ko1N/frame_counter", "path": "/examples/limiter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dummy_workload(); // hot loop, do not trigger scheduler frame_counter.sleep_until_framerate(60f64); println!("fps stats - {}", frame_counter); } }<|fim_prefix|>// repo: ko1N/frame_counter path: /examples/limiter.rs use frame_counter::FrameCounter; pub fn dummy_workl...
code_fim
easy
{ "lang": "rust", "repo": "ko1N/frame_counter", "path": "/examples/limiter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-plan/src/logical_plan/mod.rs use std::fmt::Debug; use std::path::PathBuf; use std::sync::{Arc, Mutex}; #[cfg(feature = "parquet")] use polars_core::cloud::CloudOptions; use polars_core::prelude::*; use crate::logical_plan::LogicalPlan::DataFrameScan; use cra...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-plan/src/logical_plan/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ErrorStateSync { fn take(&self) -> PolarsError { let mut curr_err = self.0.lock().unwrap(); match &*curr_err { ErrorState::NotYetEncountered { err: polars_err } => { // Need to finish using `polars_err` here so that NLL considers `err` dropped ...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-plan/src/logical_plan/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }