text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: lovasoa/sugar-rs path: /src/collections_macros.rs pub use maplit::*; pub use vec_box::*; <|fim_suffix|> let v = vec![1, 2, 3]; let map = hashmap!( 1 => "1".to_owned(), 2 => "2".to_owned(), 3 => "3".to_owned(), ); assert_eq!(map...
code_fim
easy
{ "lang": "rust", "repo": "lovasoa/sugar-rs", "path": "/src/collections_macros.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lovasoa/sugar-rs path: /src/collections_macros.rs pub use maplit::*; pub use vec_box::*; #[cfg(test)] mod tests { #[test] fn it_works() { <|fim_suffix|> assert_eq!(map, m!{i => i.to_string(), for i in v}) } }<|fim_middle|> let v = vec![1, 2, 3]; let map = hashm...
code_fim
medium
{ "lang": "rust", "repo": "lovasoa/sugar-rs", "path": "/src/collections_macros.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(map, m!{i => i.to_string(), for i in v}) } }<|fim_prefix|>// repo: lovasoa/sugar-rs path: /src/collections_macros.rs pub use maplit::*; pub use vec_box::*; #[cfg(test)] mod tests { #[test] fn it_works() { <|fim_middle|> let v = vec![1, 2, 3]; let map = hashm...
code_fim
medium
{ "lang": "rust", "repo": "lovasoa/sugar-rs", "path": "/src/collections_macros.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe{GetWindowRect(self.wHndl, &mut console_rect)}; unsafe{MoveWindow(self.wHndl, console_rect.left, console_rect.top, width, height, 0)}; } pub fn write_buffer(&mut self, buff: &OsString){ let rect = Box::new(SMALL_RECT{Top:0, Left:0, Right:self.width as i16, Bottom:sel...
code_fim
hard
{ "lang": "rust", "repo": "MyGoodSir/ANSI_Rusterizer", "path": "/src/terminal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MyGoodSir/ANSI_Rusterizer path: /src/terminal.rs use winapi::shared::windef::{HWND, RECT}; use winapi::um::winuser::{MoveWindow, GetWindowRect}; use winapi::um::handleapi::INVALID_HANDLE_VALUE; use winapi::um::processenv::GetStdHandle; use winapi::um::winbase::STD_OUTPUT_HANDLE; use winapi::um...
code_fim
hard
{ "lang": "rust", "repo": "MyGoodSir/ANSI_Rusterizer", "path": "/src/terminal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn setup_font(&mut self, size: i16){ unsafe{ let fn_staging: [u16;32] = ['C' as u16,'o' as u16,'n' as u16,'s' as u16,'o' as u16,'l' as u16,'a' as u16,'s' as u16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,] ; let cfi: *mut CONSOLE_FONT_INFOEX; let m...
code_fim
hard
{ "lang": "rust", "repo": "MyGoodSir/ANSI_Rusterizer", "path": "/src/terminal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub unsafe fn call_term_write(addr: u64, buffer: &[u8]) -> () { let term_write: fn(*const u8, usize) -> () = core::mem::transmute(addr); term_write(buffer.as_ptr(), buffer.len()) } pub fn term_write(&self, buffer: &[u8]) -> () { unsafe { Self::call_term_write(self.term...
code_fim
hard
{ "lang": "rust", "repo": "robbie01/stivale2", "path": "/src/structure/tag/terminal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn cols_and_rows(&self) -> Option<(u16, u16)> { self.cols_and_rows_provided().then(|| (self.cols, self.rows)) } pub unsafe fn call_term_write(addr: u64, buffer: &[u8]) -> () { let term_write: fn(*const u8, usize) -> () = core::mem::transmute(addr); term_write(buffe...
code_fim
hard
{ "lang": "rust", "repo": "robbie01/stivale2", "path": "/src/structure/tag/terminal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robbie01/stivale2 path: /src/structure/tag/terminal.rs use crate::new_tag; use bitflags::bitflags; bitflags! { struct TerminalFlags: u32 { const COLS_AND_ROWS_PROVIDED = 0b1; } } <|fim_suffix|> pub fn cols_and_rows(&self) -> Option<(u16, u16)> { self.cols_and_rows_pr...
code_fim
hard
{ "lang": "rust", "repo": "robbie01/stivale2", "path": "/src/structure/tag/terminal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn hande_input(&mut self, keycode: &HashSet<KeyCode>) { // println!("{:?}", keycode); if keycode.contains(&KeyCode::Right) { self.changingdir = self.dir.can_change_dir(MovingDir::EAST) } else if keycode.contains(&KeyCode::Up) { self.changingdir = self.dir.can_change_dir(MovingDir::NO...
code_fim
hard
{ "lang": "rust", "repo": "MetalElitist/rust-snake", "path": "/src/snake.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn grow(&mut self) { self.growing = true; } pub fn update(&mut self) { let mut last_p_pos = *self.parts.last().unwrap(); if self.update_count % ((self.parts.len() as f32/80.0) + 17.0) as u32 == 0 { self.dir = self.changingdir; let dir = self.dir.to_vel(); let newhead = Poin...
code_fim
hard
{ "lang": "rust", "repo": "MetalElitist/rust-snake", "path": "/src/snake.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MetalElitist/rust-snake path: /src/snake.rs use ggez; use ggez::nalgebra as na; use ggez::mint::{Point2}; use ggez::{Context}; use ggez::event::{KeyCode}; use std::collections::HashSet; use ggez::graphics; use crate::cellsize; use na::RealField; use crate::create_mesh; use rand::Rn...
code_fim
hard
{ "lang": "rust", "repo": "MetalElitist/rust-snake", "path": "/src/snake.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gardrek/stvm path: /src/bin/main.rs extern crate stvm; use stvm::{Lang, STVM}; use std::env; fn wait_for_input() -> () { use std::io::{self, Read}; let mut buffer = [0u8; 1]; let mut stdin = io::stdin(); stdin.lock(); match stdin.read(&mut buffer) { Err(e) => panic...
code_fim
hard
{ "lang": "rust", "repo": "gardrek/stvm", "path": "/src/bin/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match e { Err(e) => match e { _ => eprintln!("{:?}", e), } _ => if debug_mode{ println!("OK")}, } if debug_mode { println!("{:?}", main_vm); } //println!("{:?} {...
code_fim
hard
{ "lang": "rust", "repo": "gardrek/stvm", "path": "/src/bin/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Validate the resource is the given kind or it is the root resource. pub fn validate(&self, kind: ResourceKind) -> ZxResult { if self.kind == kind || self.kind == ResourceKind::ROOT { Ok(()) } else { Err(ZxError::WRONG_TYPE) } } /// Valid...
code_fim
hard
{ "lang": "rust", "repo": "rcore-os/zCore", "path": "/zircon-object/src/dev/resource.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcore-os/zCore path: /zircon-object/src/dev/resource.rs use {crate::object::*, alloc::sync::Arc, bitflags::bitflags, numeric_enum_macro::numeric_enum}; numeric_enum! { #[repr(u32)] /// ResourceKind definition from fuchsia/zircon/system/public/zircon/syscalls/resource.h #[allow(missi...
code_fim
hard
{ "lang": "rust", "repo": "rcore-os/zCore", "path": "/zircon-object/src/dev/resource.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // reverse from 1 to 4 for number in (1..4).rev() { println!("{}", number); } println!("LIFTOFF!"); }<|fim_prefix|>// repo: raimonlpz/rust-katas path: /loopsex.rs fn main() { let mut counter = 0; let result = loop { counter += 1; if counter == 10 { ...
code_fim
medium
{ "lang": "rust", "repo": "raimonlpz/rust-katas", "path": "/loopsex.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raimonlpz/rust-katas path: /loopsex.rs fn main() { let mut counter = 0; let result = loop { counter += 1; if counter == 10 { break counter * 2; } }; <|fim_suffix|> // reverse from 1 to 4 for number in (1..4).rev() { println!("{}",...
code_fim
hard
{ "lang": "rust", "repo": "raimonlpz/rust-katas", "path": "/loopsex.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while index < arr.len() { println!("{}", arr[index]); index += 1; } // more safety for elem in arr.iter() { println!("{}", elem); } // reverse from 1 to 4 for number in (1..4).rev() { println!("{}", number); } println!("LIFTOFF!"); }<|f...
code_fim
hard
{ "lang": "rust", "repo": "raimonlpz/rust-katas", "path": "/loopsex.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn commit_operation(idx: usize) -> Operation { assert!( idx < COMMIT_OPERATIONS.len(), format!("Index {} is out of bounds for commit operations", idx) ); COMMIT_OPERATIONS[idx].clone() } pub fn verify_operation(idx: usize) -> Operation { assert!( idx < VERIFY_...
code_fim
hard
{ "lang": "rust", "repo": "intech-id/collexi-rollup", "path": "/core/server/src/eth_sender/tests/test_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: intech-id/collexi-rollup path: /core/server/src/eth_sender/tests/test_data.rs //! Data to be used in tests as the input for `ETHSender`. // External uses use lazy_static::lazy_static; // Workspace uses use models::node::{block::Block, Fr}; use models::{Action, Operation}; /// Creates a dummy o...
code_fim
medium
{ "lang": "rust", "repo": "intech-id/collexi-rollup", "path": "/core/server/src/eth_sender/tests/test_data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn verify_operation(idx: usize) -> Operation { assert!( idx < VERIFY_OPERATIONS.len(), format!("Index {} is out of bounds for verify operations", idx) ); VERIFY_OPERATIONS[idx].clone() }<|fim_prefix|>// repo: intech-id/collexi-rollup path: /core/server/src/eth_sender/test...
code_fim
hard
{ "lang": "rust", "repo": "intech-id/collexi-rollup", "path": "/core/server/src/eth_sender/tests/test_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 5HT-ST0LE-THIS-PROJECT/n2o-1 path: /src/io/mod.rs pub mod poll; pub mod event; pub mod ready<|fim_suffix|>adiness; pub mod registration; pub mod unix; pub mod tcp; pub mod stdio; pub mod notify;<|fim_middle|>; pub mod options; pub mod token; pub mod re
code_fim
easy
{ "lang": "rust", "repo": "5HT-ST0LE-THIS-PROJECT/n2o-1", "path": "/src/io/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>adiness; pub mod registration; pub mod unix; pub mod tcp; pub mod stdio; pub mod notify;<|fim_prefix|>// repo: 5HT-ST0LE-THIS-PROJECT/n2o-1 path: /src/io/mod.rs pub mod poll; pub mod event; pub mod ready<|fim_middle|>; pub mod options; pub mod token; pub mod re
code_fim
easy
{ "lang": "rust", "repo": "5HT-ST0LE-THIS-PROJECT/n2o-1", "path": "/src/io/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn u8_lookup_fk(kv: u32) -> u32 { kv >> 8 } #[inline] fn u8_lookup_fv(kv: u32) -> u8 { (kv & 0xff) as u8 } #[inline] fn bool_lookup_fk(kv: u32) -> u32 { kv } #[inline] fn bool_lookup_fv(_kv: u32) -> bool { true } #[inline] fn pair_lookup_fk<T>(kv: (u32, T)) -> u32 { ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/unicode-normalization/src/lookups.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> kv >> 8 } #[inline] fn u8_lookup_fv(kv: u32) -> u8 { (kv & 0xff) as u8 } #[inline] fn bool_lookup_fk(kv: u32) -> u32 { kv } #[inline] fn bool_lookup_fv(_kv: u32) -> bool { true } #[inline] fn pair_lookup_fk<T>(kv: (u32, T)) -> u32 { kv.0 } #[inline] fn pair_lookup_fv_opt<T>(k...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/unicode-normalization/src/lookups.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/unicode-normalization/src/lookups.rs use crate::perfect_hash::mph_lookup; use crate::tables::*; pub fn canonical_combining_class(c: char) -> u8 { mph_lookup( c.into(), CANONICAL_COMBINING_CLASS_SALT, ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/unicode-normalization/src/lookups.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: astro/rust-lpc43xx path: /src/cgu/mod.rs #[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { _reserved0: [u8; 20usize], #[doc = "0x14 - Frequency monitor register"] pub freq_mon: FREQ_MON, #[doc = "0x18 - Crystal oscillator control register"] pub xtal_osc_ctrl: ...
code_fim
hard
{ "lang": "rust", "repo": "astro/rust-lpc43xx", "path": "/src/cgu/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> = "PLL1 status register"] pub struct PLL1_STAT { register: ::vcell::VolatileCell<u32>, } #[doc = "PLL1 status register"] pub mod pll1_stat; #[doc = "PLL1 control register"] pub struct PLL1_CTRL { register: ::vcell::VolatileCell<u32>, } #[doc = "PLL1 control register"] pub mod pll1_ctrl; #[doc = "...
code_fim
hard
{ "lang": "rust", "repo": "astro/rust-lpc43xx", "path": "/src/cgu/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> test_bin.kill().unwrap(); assert_eq!(expected_response, response); }<|fim_prefix|>// repo: henryboisdequin/http-server-rust path: /tests/test_default_path.rs use assert_cmd::prelude::*; use reqwest::blocking::get; use std::fs; use std::process::Command; <|fim_middle|>// 'cargo test' #[test] fn t...
code_fim
hard
{ "lang": "rust", "repo": "henryboisdequin/http-server-rust", "path": "/tests/test_default_path.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: henryboisdequin/http-server-rust path: /tests/test_default_path.rs use assert_cmd::prelude::*; use reqwest::blocking::get; use std::fs; use std::process::Command; <|fim_suffix|> test_bin.kill().unwrap(); assert_eq!(expected_response, response); }<|fim_middle|>// 'cargo test' #[test] fn t...
code_fim
hard
{ "lang": "rust", "repo": "henryboisdequin/http-server-rust", "path": "/tests/test_default_path.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let expected_response = fs::read_to_string(format!("{}/public/index.html", env!("CARGO_MANIFEST_DIR"))).unwrap(); let mut test_bin = Command::cargo_bin("server").unwrap().spawn().unwrap(); let response = get("http://127.0.0.1:8080/").unwrap().text().unwrap(); test_bin.kill().unwra...
code_fim
medium
{ "lang": "rust", "repo": "henryboisdequin/http-server-rust", "path": "/tests/test_default_path.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajmwagar/spotr path: /src/config.rs use serde::{Serialize, Deserialize}; const CRATE_NAME: &str = "spotr"; #[derive(Serialize, Deserialize, Default, Debug, Clone)] pub struct Config { pub auth: AuthTokens, pub defaults: Defaults } <|fim_suffix|>pub fn load_config() -> Result<Config, c...
code_fim
hard
{ "lang": "rust", "repo": "ajmwagar/spotr", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn save_config(config: Config) -> Result<(), confy::ConfyError> { confy::store(CRATE_NAME, config)?; Ok(()) }<|fim_prefix|>// repo: ajmwagar/spotr path: /src/config.rs use serde::{Serialize, Deserialize}; const CRATE_NAME: &str = "spotr"; #[derive(Serialize, Deserialize, Default, Debug, Cl...
code_fim
medium
{ "lang": "rust", "repo": "ajmwagar/spotr", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: todun/libra path: /config/src/config/safety_rules_config.rs // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|>#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(tag = "type")] pub enum SafetyRulesBackend { InMemoryStorage, ...
code_fim
hard
{ "lang": "rust", "repo": "todun/libra", "path": "/config/src/config/safety_rules_config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for SafetyRulesConfig { fn default() -> Self { Self { backend: SafetyRulesBackend::InMemoryStorage, } } } #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(tag = "type")] pub enum SafetyRulesBackend { InMemoryStorage, OnDiskStorage...
code_fim
hard
{ "lang": "rust", "repo": "todun/libra", "path": "/config/src/config/safety_rules_config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let x1 = x.0; println!("First element of the above tuple is {}",x1); } fn plus_one(i: i32) -> i32 { i + 1 }<|fim_prefix|>// repo: nsrchemie/LearningRust path: /fn_pointers/src/main.rs fn main() { let f = plus_one; let six = f(5); println!("{}",six); let a = [0,1,2,3]; let p...
code_fim
medium
{ "lang": "rust", "repo": "nsrchemie/LearningRust", "path": "/fn_pointers/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nsrchemie/LearningRust path: /fn_pointers/src/main.rs fn main() { let f = plus_one; let six = f(5); println!("{}",six); let a = [0,1,2,3]; let part = &a[1..3]; println!("Piece of array: {:?}. Length of full array is {}",part, a.len()); <|fim_suffix|> let x1 = x.0; ...
code_fim
medium
{ "lang": "rust", "repo": "nsrchemie/LearningRust", "path": "/fn_pointers/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> b/c arrays are fixed size, not used often slices are like views of underlying arrays }<|fim_prefix|>// repo: monkeytroll/rust_mvc path: /src/rust_arr.rs fn main () { let s_a = [1,2,3]; let s_b: [i8; 3] = [4,5,6]; // Will throw error, len exceeds 3 // let s_c: [i8; 3] = [7,8,...
code_fim
medium
{ "lang": "rust", "repo": "monkeytroll/rust_mvc", "path": "/src/rust_arr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: monkeytroll/rust_mvc path: /src/rust_arr.rs fn main () { let s_a = [1,2,3]; let s_b: [i8; 3] = [4,5,6]; // Will throw error, len exceeds 3 // let s_c: [i8; 3] = [7,8,9,10]; <|fim_suffix|> println!("s_b, which has length: {}", s_b.len()); for (i, elem) in s_b.iter().enumer...
code_fim
medium
{ "lang": "rust", "repo": "monkeytroll/rust_mvc", "path": "/src/rust_arr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("s_b, which has length: {}", s_b.len()); for (i, elem) in s_b.iter().enumerate() { println!("i: {}\telement: {}", i, elem); } b/c arrays are fixed size, not used often slices are like views of underlying arrays }<|fim_prefix|>// repo: monkeytroll/rust_mvc path:...
code_fim
medium
{ "lang": "rust", "repo": "monkeytroll/rust_mvc", "path": "/src/rust_arr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn downcast_mut(&mut self) -> Result<&mut T, TypeMismatch> { if self.is_type() { Ok(self.as_any_mut().downcast_mut().unwrap()) } else { Err(TypeMismatch::new::<T, Self>(self)) } } #[cfg(feature = "std")] fn downcast(self: Box<Self>) -> Resul...
code_fim
hard
{ "lang": "rust", "repo": "fkoep/downcast-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fkoep/downcast-rs path: /src/lib.rs #![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] mod std { pub use core::*; } use std::any::{Any as StdAny, TypeId, type_name}; use std::fmt::{self, Debug, Display}; #[cfg(feature = "std")] use std::{error::Error, rc::Rc, sync::Ar...
code_fim
hard
{ "lang": "rust", "repo": "fkoep/downcast-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>static ASPECT_RATIO: AtomicU32 = AtomicU32::new(unsafe { mem::transmute(1f32) }); pub fn top_edge() -> f32 { 1.0 } pub fn bottom_edge() -> f32 { -1.0 } pub fn left_edge() -> f32 { - unsafe { mem::transmute/*::<_, f32>*/(ASPECT_RATIO.load(Relaxed)) } } pub fn right_edge() -> f32 { unsafe { mem::tra...
code_fim
hard
{ "lang": "rust", "repo": "chlobes/rps_game_client", "path": "/src/boiler_plate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chlobes/rps_game_client path: /src/boiler_plate.rs use crate::prelude::*; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::{WebGlProgram,HtmlImageElement,WebGlShader,HtmlCanvasElement,WebSocket,MessageEvent,Blob,FileReader,Document}; use js_sys::Uint8Array; use crate::vertex:...
code_fim
hard
{ "lang": "rust", "repo": "chlobes/rps_game_client", "path": "/src/boiler_plate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andreytkachenko/yarblas path: /src/executor.rs pub trait Executor { fn execute<F: FnOnce(usize) + Send + 'static + Copy + Sync>( &self, start: usize, end: usize, step: usize, f: F, ); } pub struct DefaultExecutor; impl Executor for DefaultExecutor...
code_fim
hard
{ "lang": "rust", "repo": "andreytkachenko/yarblas", "path": "/src/executor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let job_size = main_steps / thread_count; let mut prev_end = 0; for _ in 0..thread_count { let mut now_end = prev_end + job_size; if left_steps > 0 { now_end += 1; left_steps -= 1; } self.thread_pool....
code_fim
hard
{ "lang": "rust", "repo": "andreytkachenko/yarblas", "path": "/src/executor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut left_steps = num_steps % thread_count; let main_steps = num_steps - left_steps; let job_size = main_steps / thread_count; let mut prev_end = 0; for _ in 0..thread_count { let mut now_end = prev_end + job_size; if left_steps > 0 { ...
code_fim
hard
{ "lang": "rust", "repo": "andreytkachenko/yarblas", "path": "/src/executor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // pub fn count() // we should only count the number of items of the parent model } impl<S> Selector<S> where S: SelectorTrait, { /// Create `Selector` from Statment and columns. Executing this `Selector` /// will return a type `T` which implement `TryGetableMany`. pub fn with_col...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/sea-orm", "path": "/src/executor/select.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaw-sh/sea-orm path: /src/executor/select.rs _connection(); /// # /// use sea_orm::{entity::*, query::*, tests_cfg::cake, DeriveColumn, EnumIter}; /// /// #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] /// enum QueryAs { /// CakeName, /// } /// /// ...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/sea-orm", "path": "/src/executor/select.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaw-sh/sea-orm path: /src/executor/select.rs // /// #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] /// enum QueryAs { /// CakeName, /// } /// /// let res: Vec<String> = cake::Entity::find() /// .select_only() /// .column_as(cake::Column::Name, Q...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/sea-orm", "path": "/src/executor/select.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let test = "set variable 123 print variable * variable"; let tokens = Lexer::new(test).collect::<Vec<_>>(); assert_eq!( tokens, vec![ Token { kind: TokenKind::Set, span: Span { start: 0_usize, e...
code_fim
hard
{ "lang": "rust", "repo": "booleancoercion/jam0001", "path": "/fire-ferrets/src/lexer/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: booleancoercion/jam0001 path: /fire-ferrets/src/lexer/mod.rs mod token_kind; mod types; pub use token_kind::*; pub use types::*; use logos::Logos; pub struct Lexer<'input> { generated: logos::SpannedIter<'input, LogosToken>, eof: bool, } impl<'input> Lexer<'input> { pub fn new(in...
code_fim
hard
{ "lang": "rust", "repo": "booleancoercion/jam0001", "path": "/fire-ferrets/src/lexer/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atul9/canrun_rs path: /examples/benches/main.rs use canrun_examples::zebra::zebra; use criterion::{criterion_group, criterion_main, Criterion}; <|fim_suffix|>criterion_group!(benches, zebra_benchmark); criterion_main!(benches);<|fim_middle|>pub fn zebra_benchmark(c: &mut Criterion) { let mu...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/canrun_rs", "path": "/examples/benches/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>criterion_group!(benches, zebra_benchmark); criterion_main!(benches);<|fim_prefix|>// repo: Atul9/canrun_rs path: /examples/benches/main.rs use canrun_examples::zebra::zebra; use criterion::{criterion_group, criterion_main, Criterion}; <|fim_middle|>pub fn zebra_benchmark(c: &mut Criterion) { let mu...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/canrun_rs", "path": "/examples/benches/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} impl<'a, 'b> From<&'b Bytes<'a>> for RawCbor<'a> { fn from(bytes: &'b Bytes<'a>) -> RawCbor<'a> { RawCbor(bytes.bytes()) } } impl<'a> AsRef<[u8]> for RawCbor<'a> { fn as_ref(&self) -> &[u8] { self.0 } } impl<'a> Deref for RawCbor<'a> { type Target = [u8]; fn deref(& self) -> &Self::Targe...
code_fim
hard
{ "lang": "rust", "repo": "ilyadruzh/zen", "path": "/examples/rust/rust-cardano/cbor_event/src/de.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let vec = vec![0x64, 0x74, 0x65, 0x78, 0x74]; let mut raw = RawCbor::from(&vec); let text = raw.text().unwrap(); assert_eq!(&text, "text"); } #[test] fn text_empty() { let vec = vec![0x60]; let mut raw = RawCbor::from(&vec); let text =...
code_fim
hard
{ "lang": "rust", "repo": "ilyadruzh/zen", "path": "/examples/rust/rust-cardano/cbor_event/src/de.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ilyadruzh/zen path: /examples/rust/rust-cardano/cbor_event/src/de.rs LenType(byte)`: the CBOR is serialized in an unknown /// or unsupported format; /// - `Error::IndefiniteLenUnsupported(t)`: the Indefinite length is not /// supported for the given [`Type`] `t`; /// - `Error::IoError(io_err...
code_fim
hard
{ "lang": "rust", "repo": "ilyadruzh/zen", "path": "/examples/rust/rust-cardano/cbor_event/src/de.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn get_window_size() -> Result<(usize, usize), String> { unsafe { let mut winsize: libc::winsize = mem::uninitialized(); let exit_code = libc::ioctl(libc::STDOUT_FILENO, libc::TIOCGWINSZ, &mut winsize as *mut _); if exit_code == -1 || winsize.ws_col == 0 { Err("Fai...
code_fim
hard
{ "lang": "rust", "repo": "jagg/zen", "path": "/src/terminal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jagg/zen path: /src/terminal.rs extern crate libc; use libc::termios; use std::mem; pub struct Terminal { termios_c: termios, pub cols: usize, pub rows: usize, } impl Drop for Terminal { fn drop(&mut self) { if let Err(e) = self.disable_raw_mode() { print!(...
code_fim
hard
{ "lang": "rust", "repo": "jagg/zen", "path": "/src/terminal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Create graceful shutdown primitives let shutdown = GracefulShutdown::new(); // Hook SIGINT signal let sigint_shutdown = shutdown.clone(); ctrlc::set_handler(move || { info!("got SIGINT (Ctrl-C) signal, shutting down"); sigint_shutdown.shutdown(); }) .expect(...
code_fim
medium
{ "lang": "rust", "repo": "mersinvald/rustyrobot", "path": "/util/delete-forks/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mersinvald/rustyrobot path: /util/delete-forks/src/main.rs extern crate ctrlc; extern crate failure; extern crate rdkafka; extern crate rustyrobot; #[macro_use] extern crate log; extern crate chrono; extern crate fern; extern crate uuid; use failure::Error; use uuid::Uuid; use rustyrobot::{ ...
code_fim
hard
{ "lang": "rust", "repo": "mersinvald/rustyrobot", "path": "/util/delete-forks/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn main() { init_fern().unwrap(); // Create graceful shutdown primitives let shutdown = GracefulShutdown::new(); // Hook SIGINT signal let sigint_shutdown = shutdown.clone(); ctrlc::set_handler(move || { info!("got SIGINT (Ctrl-C) signal, shutting down"); ...
code_fim
hard
{ "lang": "rust", "repo": "mersinvald/rustyrobot", "path": "/util/delete-forks/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgilchrist/rslike path: /src/util/units/mod.rs mod direction; mod offset; mod point; mod rectangle; mod size; <|fim_suffix|>pub trait AsTuple<T> { fn as_tuple(&self) -> (T, T); }<|fim_middle|>pub use self::direction::Direction; pub use self::offset::Offset; pub use self::point::Point; pub u...
code_fim
medium
{ "lang": "rust", "repo": "jgilchrist/rslike", "path": "/src/util/units/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub trait AsTuple<T> { fn as_tuple(&self) -> (T, T); }<|fim_prefix|>// repo: jgilchrist/rslike path: /src/util/units/mod.rs mod direction; mod offset; mod point; mod rectangle; mod size; <|fim_middle|>pub use self::direction::Direction; pub use self::offset::Offset; pub use self::point::Point; pub u...
code_fim
medium
{ "lang": "rust", "repo": "jgilchrist/rslike", "path": "/src/util/units/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stbuehler/rust-hibp-index path: /src/data/sha1.rs use std::fmt; use std::ops::{Deref, DerefMut}; use std::str::FromStr; use super::FixedByteArray; /// SHA-1 hash data #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SHA1(pub [u8; 20]); impl SHA1 { /// Calculat...
code_fim
medium
{ "lang": "rust", "repo": "stbuehler/rust-hibp-index", "path": "/src/data/sha1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } impl AsMut<[u8; 20]> for SHA1 { fn as_mut(&mut self) -> &mut [u8; 20] { &mut self.0 } } impl fmt::Debug for SHA1 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.hex()) } } impl fmt::Display for SHA1 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fm...
code_fim
hard
{ "lang": "rust", "repo": "stbuehler/rust-hibp-index", "path": "/src/data/sha1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yberreby/steam-crypto-rs path: /src/symm/mod.rs use openssl::crypto::symm::{Crypter, Mode, Type}; use rand::random; #[cfg(test)] mod tests; /// Encrypt or decrypt an Initialization Vector with AES 256 ECB. fn crypt_iv(plain_iv: &[u8], key: &[u8], mode: Mode) -> Vec<u8> { let iv_crypter = Cry...
code_fim
hard
{ "lang": "rust", "repo": "yberreby/steam-crypto-rs", "path": "/src/symm/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Decrypt the IV stored in the first 16 bytes of `input` /// and use it to decrypt the remaining bytes. pub fn symmetric_decrypt(input: &[u8], key: &[u8]) -> Vec<u8> { let encrypted_iv = &input[0..16]; let plain_iv = crypt_iv(encrypted_iv, key, Mode::Decrypt); let encrypted_message = &input[16..]...
code_fim
hard
{ "lang": "rust", "repo": "yberreby/steam-crypto-rs", "path": "/src/symm/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let encrypted_iv = crypt_iv(plain_iv, key, Mode::Encrypt); let encrypted_message = crypt_message(message, key, plain_iv, Mode::Encrypt); let mut output = encrypted_iv; output.extend(encrypted_message.into_iter()); output } /// Generate a random IV and encrypt `input` with it and `key`. pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "yberreby/steam-crypto-rs", "path": "/src/symm/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Terkwood/lindenmayer-system path: /examples/helper/mod.rs pub use expression::cond::Cond; pub use expression_num::NumExpr as Expr; use lindenmayer_system::parametric::{PRule, PSym, PSystem}; pub use lindenmayer_system::parametric::{ParametricRule, ParametricSymbol, ParametricSystem}; use std::en...
code_fim
hard
{ "lang": "rust", "repo": "Terkwood/lindenmayer-system", "path": "/examples/helper/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> root } pub fn view_root(&self, a: usize) -> usize { let mut root = a; while root != self.graph[root].parent { root = self.graph[root].parent; } root } pub fn connected(&self, a: usize,...
code_fim
hard
{ "lang": "rust", "repo": "imkleats/rust-practice", "path": "/unionfind/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Initialize the graph vector for i in 0..(field_size + 2) { graph.push(Node{ parent: i, child_count: 1, open: false, }) } let mut perc = Percolator { ...
code_fim
hard
{ "lang": "rust", "repo": "imkleats/rust-practice", "path": "/unionfind/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imkleats/rust-practice path: /unionfind/src/main.rs pub mod qf { #[derive(Debug)] pub struct QuickFind { pub size: usize, pub graph: Vec<QuickFindNode>, } #[derive(Debug)] pub struct QuickFindNode { pub group: u32 } impl QuickFind { ...
code_fim
hard
{ "lang": "rust", "repo": "imkleats/rust-practice", "path": "/unionfind/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: antoyo/gtksourceview-rs path: /src/auto/completion.rs // This file was generated by gir (b010d34) from gir-files (71d73f0) // DO NOT EDIT use CompletionContext; use CompletionInfo; use CompletionProvider; use Error; use View; use ffi; use glib; use glib::Value; use glib::object::Downcast; use g...
code_fim
hard
{ "lang": "rust", "repo": "antoyo/gtksourceview-rs", "path": "/src/auto/completion.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn set_property_show_icons(&self, show_icons: bool) { unsafe { gobject_ffi::g_object_set_property(self.to_glib_none().0, "show-icons".to_glib_none().0, Value::from(&show_icons).to_glib_none().0); } } fn connect_activate_proposal<F: Fn(&Self) + 'static>(&self, f: F)...
code_fim
hard
{ "lang": "rust", "repo": "antoyo/gtksourceview-rs", "path": "/src/auto/completion.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>unsafe extern "C" fn hide_trampoline<P>(this: *mut ffi::GtkSourceCompletion, f: glib_ffi::gpointer) where P: IsA<Completion> { callback_guard!(); let f: &Box_<Fn(&P) + 'static> = transmute(f); f(&Completion::from_glib_none(this).downcast_unchecked()) } unsafe extern "C" fn move_cursor_trampol...
code_fim
hard
{ "lang": "rust", "repo": "antoyo/gtksourceview-rs", "path": "/src/auto/completion.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>] pub static mut pgResetTemplate_batteryConfig: batteryConfig_t = { let mut init = batteryConfig_s{vbatmaxcellvoltage: 43i32 as uint8_t, vbatmincellvoltage: 33i32 as uint8_t, vbatwarningcellvoltage: 35i32 as uint8_t, ...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/RustyFlight", "path": "/transpiled-original/spracingf3/src/src/main/sensors/battery.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>bc::c_float) * 100i32 as libc::c_float / batteryCapacity as libc::c_int as libc::c_float) as libc::c_int, 0i32, 100i32) as uint8_t } else { batteryPercentage = ...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/RustyFlight", "path": "/transpiled-original/spracingf3/src/src/main/sensors/battery.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaloisInc/RustyFlight path: /transpiled-original/spracingf3/src/src/main/sensors/battery.rs 4; pub const FEATURE_RX_PPM: C2RustUnnamed_2 = 1; /* base */ /* size */ // The parameter group number, the top 4 bits are reserved for version // Size of the group in RAM, the top 4 bits are reserved for ...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/RustyFlight", "path": "/transpiled-original/spracingf3/src/src/main/sensors/battery.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: furuhama/atcoder path: /abc173/src/bin/d.rs #[allow(unused_imports)] use proconio::{ fastout, input, marker::{Bytes, Chars, Isize1, Usize1}, }; <|fim_suffix|> a.sort(); a.reverse(); let mut ans = a[0]; for i in 0..n - 2 { ans += a[i / 2 + 1]; } echo!(an...
code_fim
medium
{ "lang": "rust", "repo": "furuhama/atcoder", "path": "/abc173/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..n - 2 { ans += a[i / 2 + 1]; } echo!(ans); }<|fim_prefix|>// repo: furuhama/atcoder path: /abc173/src/bin/d.rs #[allow(unused_imports)] use proconio::{ fastout, input, marker::{Bytes, Chars, Isize1, Usize1}, }; #[allow(unused_macros)] macro_rules! echo { ($($...
code_fim
easy
{ "lang": "rust", "repo": "furuhama/atcoder", "path": "/abc173/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moisutsu/AOJ-study path: /src/bin/8d.rs #[macro_use] mod input; fn main() { input! { s: String, p: String, } let mut ans = "No"; for s_i in 0..s.len() { let mut count = 0; for p_i in 0..p.len() { let index = if s_i + p_i >= s.len() { ...
code_fim
hard
{ "lang": "rust", "repo": "moisutsu/AOJ-study", "path": "/src/bin/8d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> break; } } if count == p.len() { ans = "Yes"; break; } } println!("{}", ans); }<|fim_prefix|>// repo: moisutsu/AOJ-study path: /src/bin/8d.rs #[macro_use] mod input; fn main() { input! { s: String, p: Strin...
code_fim
hard
{ "lang": "rust", "repo": "moisutsu/AOJ-study", "path": "/src/bin/8d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juicycleff/guardian-rust path: /backend/src/api/rest/account/mod.rs #[cfg(feature = "server-actix")] pub mod account_controller; #[cfg(feature = "server-acti<|fim_suffix|> "server-actix")] pub mod session_controller;<|fim_middle|>x")] pub mod account_module; #[cfg(feature =
code_fim
easy
{ "lang": "rust", "repo": "juicycleff/guardian-rust", "path": "/backend/src/api/rest/account/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> "server-actix")] pub mod session_controller;<|fim_prefix|>// repo: juicycleff/guardian-rust path: /backend/src/api/rest/account/mod.rs #[cfg(feature = "server-actix")] pub mod account_controller; #[cfg(feature = "server-acti<|fim_middle|>x")] pub mod account_module; #[cfg(feature =
code_fim
easy
{ "lang": "rust", "repo": "juicycleff/guardian-rust", "path": "/backend/src/api/rest/account/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // declare directories let home_dir = dirs::home_dir().ok_or_else(|| anyhow!("Could not get home dir"))?; let bash_dir = path::Path::new(&format!("{}/projects/scripts/bash/", dirs::home_dir().unwrap().into_os_string().into_string().unwrap()).to_string()); let templates_dir = path::Path::ne...
code_fim
hard
{ "lang": "rust", "repo": "jakewilliami/scripts", "path": "/rust/mktex/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakewilliami/scripts path: /rust/mktex/src/main.rs use std::{fs, env, process, path}; use dirs; // -g | --general Chooses the general template. // -c | --class Chooses the general template via the class. // -C | --classBib [DEPRECATED] Chooses the general template via the citations clas...
code_fim
medium
{ "lang": "rust", "repo": "jakewilliami/scripts", "path": "/rust/mktex/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yellowtides/rustpeuler path: /src/sol/s0069.rs // p69 sol https://projecteuler.net/problem=69 use crate::base; const MAXVAL: usize = 1e2 as usize; fn capped_prime_prod(input: u64) -> u64 { <|fim_suffix|>pub fn solve() -> u64 { // this solution is based on a heuristic approach //...
code_fim
hard
{ "lang": "rust", "repo": "yellowtides/rustpeuler", "path": "/src/sol/s0069.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sieve = base::compute_sieve(MAXVAL); // fetch the first 100 primes let mut ans: u64 = 1; let mut i: usize = 0; loop { if ans * sieve[i] < input { ans *= sieve[i]; i += 1; } else { break; } } ans } pu...
code_fim
medium
{ "lang": "rust", "repo": "yellowtides/rustpeuler", "path": "/src/sol/s0069.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tsavola/lep path: /examples/repl.rs // Copyright (c) 2019 Timo Savola. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. use std::process::exit; use std::time::{SystemTime, UNIX_EPOCH}; use rustyline::error::ReadlineError; use rustyline::Editor...
code_fim
hard
{ "lang": "rust", "repo": "tsavola/lep", "path": "/examples/repl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> state = res; } Err(msg) => { println!("error: {}", msg); } } } Err(ReadlineError::Eof) => { break; } Err(x) => { ...
code_fim
hard
{ "lang": "rust", "repo": "tsavola/lep", "path": "/examples/repl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Fun for Time { fn invoke(&self, args: &Obj) -> Res { if args.is::<()>() { match SystemTime::now().duration_since(UNIX_EPOCH) { Ok(n) => Ok(obj::int(n.as_secs() as i64)), Err(e) => Err(format!("time: {}", e)), } } else { ...
code_fim
hard
{ "lang": "rust", "repo": "tsavola/lep", "path": "/examples/repl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Executor for Smol { fn new() -> Result<Self, futures::io::Error> { Ok(Self) } fn spawn(&self, future: impl Future<Output = ()> + Send + 'static) { smol::spawn(future).detach(); } }<|fim_prefix|>// repo: Folyd/iced path: /futures/src/executor/smol.rs use crate::Execut...
code_fim
medium
{ "lang": "rust", "repo": "Folyd/iced", "path": "/futures/src/executor/smol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> smol::spawn(future).detach(); } }<|fim_prefix|>// repo: Folyd/iced path: /futures/src/executor/smol.rs use crate::Executor; use futures::Future; /// A `smol` runtime. #[cfg_attr(docsrs, doc(cfg(feature = "smol")))] #[derive(Debug)] pub struct Smol; impl Executor for Smol { fn new() -> ...
code_fim
medium
{ "lang": "rust", "repo": "Folyd/iced", "path": "/futures/src/executor/smol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Folyd/iced path: /futures/src/executor/smol.rs use crate::Executor; use futures::Future; /// A `smol` runtime. #[cfg_attr(docsrs, doc(cfg(feature = "smol")))] #[derive(Debug)] pub struct Smol; impl Executor for Smol { fn new() -> Result<Self, futures::io::Error> { <|fim_suffix|> sm...
code_fim
medium
{ "lang": "rust", "repo": "Folyd/iced", "path": "/futures/src/executor/smol.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern fn rust_main() -> ! { println!("Hello World!"); println!("This should be on line 2"); loop { } } #[cfg(not(test))] #[panic_handler] fn panic(info: &PanicInfo) -> ! { println!("{}", info); loop { } }<|fim_prefix|>// repo: venix-os/venix-kernel path: /src/lib.rs...
code_fim
medium
{ "lang": "rust", "repo": "venix-os/venix-kernel", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: venix-os/venix-kernel path: /src/lib.rs #![cfg_attr(not(test), no_std)] #![cfg_attr(test, allow(unused_imports))] #[cfg(test)] extern crate core; <|fim_suffix|>#[macro_use] mod drivers; #[no_mangle] pub extern fn rust_main() -> ! { println!("Hello World!"); println!("This should be on...
code_fim
medium
{ "lang": "rust", "repo": "venix-os/venix-kernel", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self.properties().manufacturer_data { Some(data) => from_manufacturer_data(&data), None => Err(ParseError::EmptyValue), } } } fn from_manufacturer_data(data: &[u8]) -> Result<SensorValues, ParseError> { if data.len() > 2 { let id = u16::from(d...
code_fim
hard
{ "lang": "rust", "repo": "lautis/ruuvitag-listener", "path": "/src/ruuvi.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lautis/ruuvitag-listener path: /src/ruuvi.rs use btleplug::api::{BDAddr, Central, CentralEvent, Peripheral}; use btleplug::bluez::adapter::ConnectedAdapter; use btleplug::bluez::manager::Manager; use ruuvi_sensor_protocol::{ParseError, SensorValues}; use std::eprintln; use std::sync::Arc; use st...
code_fim
hard
{ "lang": "rust", "repo": "lautis/ruuvitag-listener", "path": "/src/ruuvi.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }