text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: rickenharp/perilous_wilds_rust path: /src/unnatural_feature.rs use std::fmt::Display; mod arcane; mod divine; mod planar; use crate::dice::Rollable; pub use crate::unnatural_feature::arcane::Arcane; pub use crate::unnatural_feature::divine::Divine; pub use crate::unnatural_feature::planar::Plan...
code_fim
medium
{ "lang": "rust", "repo": "rickenharp/perilous_wilds_rust", "path": "/src/unnatural_feature.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl UnnaturalFeature { pub fn new<T: ?Sized>(dice: &mut T) -> UnnaturalFeature where T: Rollable, { match dice.roll() { 1..=9 => UnnaturalFeature::Arcane(Arcane::new(dice)), 10..=11 => UnnaturalFeature::Planar(Planar::new(dice)), 12..=12 => ...
code_fim
medium
{ "lang": "rust", "repo": "rickenharp/perilous_wilds_rust", "path": "/src/unnatural_feature.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heliumbrain/axum path: /src/body.rs //! HTTP body utilities. use crate::BoxError; use crate::Error; mod stream_body; <|fim_suffix|>#[doc(no_inline)] pub use http_body::{Body as HttpBody, Empty, Full}; #[doc(no_inline)] pub use hyper::body::Body; #[doc(no_inline)] pub use bytes::Bytes; /// ...
code_fim
medium
{ "lang": "rust", "repo": "heliumbrain/axum", "path": "/src/body.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Convert a [`http_body::Body`] into a [`BoxBody`]. pub fn box_body<B>(body: B) -> BoxBody where B: http_body::Body<Data = Bytes> + Send + Sync + 'static, B::Error: Into<BoxError>, { body.map_err(Error::new).boxed() } pub(crate) fn empty() -> BoxBody { box_body(http_body::Empty::new()) ...
code_fim
hard
{ "lang": "rust", "repo": "heliumbrain/axum", "path": "/src/body.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> chi.sort_by(|(a, _), (b, _)| a.partial_cmp(b).unwrap()); let (_, msg) = chi.first().unwrap(); let msg = str::from_utf8(&msg).expect("Failed to parse decrypted text"); print!("Decoded msg: {}", msg); }<|fim_prefix|>// repo: Adynatos/cryptopals-rust path: /src/bin/ex4.rs use cryptopals::br...
code_fim
hard
{ "lang": "rust", "repo": "Adynatos/cryptopals-rust", "path": "/src/bin/ex4.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Adynatos/cryptopals-rust path: /src/bin/ex4.rs use cryptopals::break_single_xor; use cryptopals::chi_squared; use std::fs; use std::str; <|fim_suffix|> let (_, msg) = chi.first().unwrap(); let msg = str::from_utf8(&msg).expect("Failed to parse decrypted text"); print!("Decoded msg: {...
code_fim
hard
{ "lang": "rust", "repo": "Adynatos/cryptopals-rust", "path": "/src/bin/ex4.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for line in encrypted { let line = hex::decode(line).expect("Error during hex-decoding line"); let (decrypted, _key) = break_single_xor(&line); chi.push((chi_squared(&decrypted), decrypted)); } chi.sort_by(|(a, _), (b, _)| a.partial_cmp(b).unwrap()); let (_, msg) ...
code_fim
medium
{ "lang": "rust", "repo": "Adynatos/cryptopals-rust", "path": "/src/bin/ex4.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct SelectBox { pub width: u32, pub height: u32, pub options: Vec<String>, } impl Draw for SelectBox { fn draw(&self) {} }<|fim_prefix|>// repo: abiriadev/gui path: /src/component.rs use crate::Draw; pub struct Button { pub width: u32, pub height: u32, pub label: Stri...
code_fim
medium
{ "lang": "rust", "repo": "abiriadev/gui", "path": "/src/component.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct TextField { pub place_holder: String, } impl Draw for TextField { fn draw(&self) { // } } pub struct SelectBox { pub width: u32, pub height: u32, pub options: Vec<String>, } impl Draw for SelectBox { fn draw(&self) {} }<|fim_prefix|>// repo: abiriadev/gui ...
code_fim
medium
{ "lang": "rust", "repo": "abiriadev/gui", "path": "/src/component.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abiriadev/gui path: /src/component.rs use crate::Draw; pub struct Button { pub width: u32, pub height: u32, pub label: String, } impl Draw for Button { fn draw(&self) { // } } pub struct TextField { pub place_holder: String, } <|fim_suffix|>impl Draw for Selec...
code_fim
medium
{ "lang": "rust", "repo": "abiriadev/gui", "path": "/src/component.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>z) = add(x) replace(y, z) //! //! remove(x) + skip(y) = remove(x) skip(y) //! remove(x) + add(y) = replace(x, y) //! remove(x) + remove(y) = remove(x + y) //! remove(x) + replace(y, z) = replace(x + y, z) //! //! replace(x, y) + skip(z) = replace(x, y) skip(z) //! replace(x, y) + ad...
code_fim
hard
{ "lang": "rust", "repo": "Reeywhaar/bin_diff", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Reeywhaar/bin_diff path: /src/lib.rs //! # bin_diff //! //! A library for creating, applying and combining binary diff format. //! //! # Usage //! To make custom library for diffing you own format you need to implement [WithIndexes](../bin_diff/indexes/trait.WithIndexes.html) trait on your input...
code_fim
hard
{ "lang": "rust", "repo": "Reeywhaar/bin_diff", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>d(x) next(nil , skip(y - x)) //! //! add(x) | add (y) = add(y) next(add(x)) //! //! add(x) | remove(y) = //! x = y: nil //! x > y: next(add(y..x)) //! x < y: next(nil, remove(y - x)) //! //! add(x) | replace(y, z) = //! x = y : next(nil, add(z)) //! x > y : add(z) next(add(y..x)) //! x < y : next(ni...
code_fim
hard
{ "lang": "rust", "repo": "Reeywhaar/bin_diff", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: binh-vu/semantic-modeling path: /mira/src/assembling/mod.rs pub mod models; pub mod features; pub mod auto_label; pub mod searching; pub <|fim_suffix|>od interactive_modeling; mod tests; pub use self::models::*; pub use self::features::*; pub use self::predicting::*; pub use self::interactive_m...
code_fim
medium
{ "lang": "rust", "repo": "binh-vu/semantic-modeling", "path": "/mira/src/assembling/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>od interactive_modeling; mod tests; pub use self::models::*; pub use self::features::*; pub use self::predicting::*; pub use self::interactive_modeling::*;<|fim_prefix|>// repo: binh-vu/semantic-modeling path: /mira/src/assembling/mod.rs pub mod models; pub mod features; pub mod auto_label; pub mod sear...
code_fim
medium
{ "lang": "rust", "repo": "binh-vu/semantic-modeling", "path": "/mira/src/assembling/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(None, iter.next()); stars } fn read_file(path: &str) -> String { use ::std::io::Read; let mut f = ::std::fs::File::open(path).unwrap(); let mut buf = String::new(); f.read_to_string(&mut buf).unwrap(); buf } // fn l1(file: &str) { // let stars: Vec<Star> = parse_stars(read_fi...
code_fim
hard
{ "lang": "rust", "repo": "fredmorcos/attic", "path": "/Coding/Planet/finder_l4_bad/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredmorcos/attic path: /Coding/Planet/finder_l4_bad/src/main.rs #![feature(tool_lints)] #![warn(clippy::all)] use std::str::FromStr; struct Star { name: String, light_curve: Vec<i32>, } enum Feature { Flare, Transit, Random, NoEvent, } impl ::std::fmt::Display for Feature { fn ...
code_fim
hard
{ "lang": "rust", "repo": "fredmorcos/attic", "path": "/Coding/Planet/finder_l4_bad/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> // fn is_noise(&self, i: usize) -> bool { // let (l, h) = self.normal_luminosity_range(); // let val = f64::from(self.light_curve[i]); // val >= l && val <= h // } // fn is_flare(&self, i: usize) -> bool { // let (_, h) = self.normal_luminosity_range(); // let val = f64::from(se...
code_fim
hard
{ "lang": "rust", "repo": "fredmorcos/attic", "path": "/Coding/Planet/finder_l4_bad/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update(&mut self, other: &GameState, action: &Action) { println!("{:?}", other); println!("{:?}", action); } }<|fim_prefix|>// repo: esnowkropla/tcg path: /src/state/mod.rs use std::collections::HashMap; use super::config::Config; use super::action::Action; mod cards; mod...
code_fim
hard
{ "lang": "rust", "repo": "esnowkropla/tcg", "path": "/src/state/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: esnowkropla/tcg path: /src/state/mod.rs use std::collections::HashMap; use super::config::Config; use super::action::Action; mod cards; mod zones; mod players; <|fim_suffix|> fn push_deck(&mut self, deck: &HashMap<u64, u8>, player: Player) -> () { for (card, &num) in deck.iter() { ...
code_fim
hard
{ "lang": "rust", "repo": "esnowkropla/tcg", "path": "/src/state/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(pflichtsolo_runden) = self.regelsatz_registry.variante.pflichtsolo_alle_n_runden { if self.anzahl_normale_spiele_gespielt == pflichtsolo_runden*4 { self.solo_gespielt = [false;4]; } ...
code_fim
hard
{ "lang": "rust", "repo": "Rapunzel77/rust-doko-server", "path": "/core/src/turnier.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Rapunzel77/rust-doko-server path: /core/src/turnier.rs use std::sync::Arc; use crate::regelsatz::RegelsatzRegistry; use crate::spiel::*; /// Dies ist ein Turnier aus Sicht der Regln. Verwaltung von Spielernamen, Netzwerkverbindungen /// etc. erfolgen separat. pub struct Turnier { regelsat...
code_fim
hard
{ "lang": "rust", "repo": "Rapunzel77/rust-doko-server", "path": "/core/src/turnier.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// arbeitet das Spielergebnis in die Turnierdaten ein und liefert true genau dann, wenn das /// Turnier mit diesem Spiel beendet ist pub fn on_spiel_ergebnis(&mut self, spiel: Spiel) -> bool { match &spiel.phase { SpielPhase::Abgeschlossen(data) => { match...
code_fim
hard
{ "lang": "rust", "repo": "Rapunzel77/rust-doko-server", "path": "/core/src/turnier.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut out = String::new(); let mut n = self.clone(); for &(name, value) in Self::ROMAN_PAIRS.iter() { while n >= value { n -= value; out.push_str(name); } } assert!(n == 0); out } } #[cfg(test)] ...
code_fim
medium
{ "lang": "rust", "repo": "sametaylak/RomanNumeral", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_to_roman_numeral() { assert_eq!(1.to_roman_numeral(), "I"); assert_eq!(2.to_roman_numeral(), "II"); assert_eq!(3.to_roman_numeral(), "III"); assert_eq!(4.to_roman_numeral(), "IV"); assert_eq!(5.to_r...
code_fim
hard
{ "lang": "rust", "repo": "sametaylak/RomanNumeral", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sametaylak/RomanNumeral path: /src/main.rs trait RomanNumeral { const ROMAN_PAIRS: &'static[(&'static str, i32)] = &[ ("M", 1000), ("CM", 900), ("D", 500), ("CD", 400), ("C", 100), ("XC", 90), ("L", 50), ("XL", 40), ("X", 10), ("IX", 9), ("V", 5), ("IV", 4...
code_fim
hard
{ "lang": "rust", "repo": "sametaylak/RomanNumeral", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>on<i32>, /// The number of slow frequency triggers during stalled drive disk exercises to cause the drive to be softfailed. #[serde(rename = "max_slow_frequency")] pub max_slow_frequency: Option<i32>, /// The maximum amount of time, in seconds, to remain stalled before softfailing the driv...
code_fim
hard
{ "lang": "rust", "repo": "cholcombe973/isilon", "path": "/src/models/node_driveconfig_node_stall.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/node_driveconfig_node_stall.rs #[allow(unused_imports)] use serde_json::Value; #[derive(Debug, Serialize, Deserialize)] pub struct NodeDriveconfigNodeStall { /// The amount of time in seconds with no stalls before ignoring previous stalls. #[serde(r...
code_fim
hard
{ "lang": "rust", "repo": "cholcombe973/isilon", "path": "/src/models/node_driveconfig_node_stall.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown", "source": "the-stack-v2" }
<|fim_suffix|>2>, /// Maximum delay in seconds after an ECC correction during a scan. #[serde(rename = "scan_max_ecc_delay")] pub scan_max_ecc_delay: Option<i32>, /// Total bytes of error-free reads to complete a scan. #[serde(rename = "scan_size")] pub scan_size: Option<i32>, /// Delay in s...
code_fim
hard
{ "lang": "rust", "repo": "cholcombe973/isilon", "path": "/src/models/node_driveconfig_node_stall.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) { if self.day == self.days_in_month { self.month = match self.month { Month::January => Month::February, Month::February => Month::March, Month::March => Month::April, Month::April => Month::May, Month::May => Month::June, Mont...
code_fim
hard
{ "lang": "rust", "repo": "seanpont/rusty_euler", "path": "/src/p19.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seanpont/rusty_euler path: /src/p19.rs /// You are given the following information, but you may prefer to do some research for yourself. /// /// 1 Jan 1900 was a Monday. /// Thirty days has September, /// April, June and November. /// All the rest have thirty-one, /// Saving February alone, /// ...
code_fim
hard
{ "lang": "rust", "repo": "seanpont/rusty_euler", "path": "/src/p19.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn solve() { let mut answer = 1; let mut c = Calendar::new(); while c.year < 2001 { c.next(); // How many Sundays fell on the first of the month during the twentieth century if c.year >= 1901 && c.day_of_week == DayOfWeek::Sunday && c.day == 1 { answer += 1 } } println...
code_fim
hard
{ "lang": "rust", "repo": "seanpont/rusty_euler", "path": "/src/p19.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arn-the-long-beard/seed-routing path: /router_derive/src/lib.rs #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } } extern crate convert_case; extern crate proc_macro; extern crate proc_macro_error; use crate::{default_route::get_default_route, routin...
code_fim
hard
{ "lang": "rust", "repo": "arn-the-long-beard/seed-routing", "path": "/router_derive/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match default_variant.fields { Fields::Named(_) => abort!(Diagnostic::new( Level::Error, "Default route need to be simple".into() )), Fields::Unnamed(_) => abort!(Diagnostic::new( Level::Error, "Default route need to be simple".in...
code_fim
hard
{ "lang": "rust", "repo": "arn-the-long-beard/seed-routing", "path": "/router_derive/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ClaireMcKayBowen/opendp path: /rust/opendp-ffi/src/meas/mod.rs #[cfg(all(feature="floating-point", feature="contrib"))] pub mod gaussian; #[cfg(feature="contrib")] pub mod geometric; #[cfg(feature="contrib")] pub mod rando<|fim_suffix|>d laplace; #[cfg(all(feature="floating-point", feature="cont...
code_fim
medium
{ "lang": "rust", "repo": "ClaireMcKayBowen/opendp", "path": "/rust/opendp-ffi/src/meas/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>d laplace; #[cfg(all(feature="floating-point", feature="contrib"))] pub mod ptr;<|fim_prefix|>// repo: ClaireMcKayBowen/opendp path: /rust/opendp-ffi/src/meas/mod.rs #[cfg(all(feature="floating-point", feature="contrib"))] pub mod gaussian; #[cfg(feature="contrib")] pub mod geometric; #[cfg(feature="cont...
code_fim
medium
{ "lang": "rust", "repo": "ClaireMcKayBowen/opendp", "path": "/rust/opendp-ffi/src/meas/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[fail(display = "cryptoballot validation: threshold is invalid for number of authenticators")] InvalidAuthThreshold, #[fail(display = "cryptoballot validation: invalid public key")] InvalidPublicKey, #[fail(display = "cryptoballot validation: election mismatch")] ElectionMismatc...
code_fim
hard
{ "lang": "rust", "repo": "StevanMokranjac/cryptoballot", "path": "/cryptoballot/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StevanMokranjac/cryptoballot path: /cryptoballot/src/error.rs use crate::*; use failure::Fail; /// Error types #[derive(Debug, Fail)] pub enum Error { #[fail(display = "cryptoballot: sinature error: {}", 0)] SignatureError(ed25519_dalek::SignatureError), #[fail(display = "cryptobal...
code_fim
hard
{ "lang": "rust", "repo": "StevanMokranjac/cryptoballot", "path": "/cryptoballot/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndreaCatania/video_ludo path: /examples/utils/mod.rs use std::borrow::Cow; use glium::{ glutin::{self, Event, WindowEvent}, index::PrimitiveType, texture::{ClientFormat, RawImage2d}, Display, Program, Surface, Texture2d, VertexBuffer, }; pub fn render<F: FnMut(&Display) -> Opt...
code_fim
hard
{ "lang": "rust", "repo": "AndreaCatania/video_ludo", "path": "/examples/utils/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> program!(display, 140 => { vertex: " #version 140 uniform mat4 matrix; in vec2 position; in vec2 tex_coords; out vec2 v_tex_coords; void main() { gl_Position = matrix...
code_fim
hard
{ "lang": "rust", "repo": "AndreaCatania/video_ludo", "path": "/examples/utils/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>!"), // each arm has a pattern, and a execution block Ordering::Equal => println!("You win!"), } }<|fim_prefix|>// repo: johnfoley3/rust-guide path: /snippets/match.rs use std::cmp::Ordering; fn main() { let secret_number = 2; let guess = 3; match guess.cmp(&secret_number) { // ...
code_fim
medium
{ "lang": "rust", "repo": "johnfoley3/rust-guide", "path": "/snippets/match.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johnfoley3/rust-guide path: /snippets/match.rs use std::cmp::Ordering; fn main() { let secret_number = 2; let guess = 3; match guess.cmp(&secr<|fim_suffix|>!"), // each arm has a pattern, and a execution block Ordering::Equal => println!("You win!"), } }<|fim_middle|>et...
code_fim
hard
{ "lang": "rust", "repo": "johnfoley3/rust-guide", "path": "/snippets/match.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_u32(&mut self) -> Result<u32> { if self.remaining_len() >= 4 { let u = BigEndian::read_u32(&self.data[self.position..]); self.position += 4; Ok(u) } else { Err(Error::BufferTooShort) } } pub fn read_string(&mut self) -> Result<&'a [u8]> { let len ...
code_fim
hard
{ "lang": "rust", "repo": "21re/ssh-key-sign-rs", "path": "/src/encoding.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 21re/ssh-key-sign-rs path: /src/encoding.rs use crate::error::{Error, Result}; use byteorder::{BigEndian, ByteOrder}; pub struct Reader<'a> { data: &'a [u8], position: usize, } impl<'a> Reader<'a> { pub fn new(data: &'a [u8]) -> Reader<'a> { Reader { data, position: 0 } } #[inli...
code_fim
hard
{ "lang": "rust", "repo": "21re/ssh-key-sign-rs", "path": "/src/encoding.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn write_u8(&mut self, b: u8) { self.buffer.push(b); } pub fn write_u32(&mut self, i: u32) { let mut bytes = [0u8; 4]; BigEndian::write_u32(&mut bytes, i); self.buffer.extend_from_slice(&bytes); } pub fn write_string(&mut self, s: &[u8]) { let mut len_bytes = [0u8; 4]; ...
code_fim
hard
{ "lang": "rust", "repo": "21re/ssh-key-sign-rs", "path": "/src/encoding.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut parser = Parser::new(); let output = parser .parse(PREMATURE_PROGRAM) .expect_err("The code in premature.bf shouldn't produce a valid instruction list."); assert_eq!(output, SyntaxError::PrematureEndWhile(2, 1)) // expect an error on line 2, character 1 } #[test] fn test_unmatc...
code_fim
hard
{ "lang": "rust", "repo": "oreganoli/bfc-rs", "path": "/src/parser/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oreganoli/bfc-rs path: /src/parser/tests.rs const NEWLINE_PRINTING_PROGRAM: &str = include_str!("../../newline.bf"); // same thing as we did with the NASM template while writing HWDPC const PREMATURE_PROGRAM: &str = include_str!("../../premature.bf"); const UNMATCHED_PROGRAM: &str = include_str!...
code_fim
hard
{ "lang": "rust", "repo": "oreganoli/bfc-rs", "path": "/src/parser/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut parser = Parser::new(); let output = parser .parse(UNMATCHED_PROGRAM) .expect_err("The code in unmatched.bf shouldn't produce a valid instruction list."); assert_eq!(output, SyntaxError::UnclosedWhile(1, 8)) // expect an error or line 1, character 8 }<|fim_prefix|>// repo: oreg...
code_fim
hard
{ "lang": "rust", "repo": "oreganoli/bfc-rs", "path": "/src/parser/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustls/rustls path: /rustls/src/key_log.rs /// This trait represents the ability to do something useful /// with key material, such as logging it to a file for debugging. /// /// Naturally, secrets passed over the interface are *extremely* /// sensitive and can break the security of past, presen...
code_fim
hard
{ "lang": "rust", "repo": "rustls/rustls", "path": "/rustls/src/key_log.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> true } } /// KeyLog that does exactly nothing. pub struct NoKeyLog; impl KeyLog for NoKeyLog { fn log(&self, _: &str, _: &[u8], _: &[u8]) {} #[inline] fn will_log(&self, _label: &str) -> bool { false } }<|fim_prefix|>// repo: rustls/rustls path: /rustls/src/key_log.r...
code_fim
hard
{ "lang": "rust", "repo": "rustls/rustls", "path": "/rustls/src/key_log.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emabee/rust-hdbconnect path: /hdbconnect_impl/src/conn/tcp_client/sync_plain_tcp_client.rs use crate::ConnectParams; use std::net::TcpStream; #[derive(Debug)] pub struct SyncPlainTcpClient { params: ConnectParams, reader: std::io::BufReader<TcpStream>, writer: std::io::BufWriter<Tcp...
code_fim
hard
{ "lang": "rust", "repo": "emabee/rust-hdbconnect", "path": "/hdbconnect_impl/src/conn/tcp_client/sync_plain_tcp_client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn connect_params(&self) -> &ConnectParams { &self.params } pub fn writer(&mut self) -> &mut std::io::BufWriter<TcpStream> { &mut self.writer } pub fn reader(&mut self) -> &mut std::io::BufReader<TcpStream> { &mut self.reader } }<|fim_prefix|>// repo: ...
code_fim
hard
{ "lang": "rust", "repo": "emabee/rust-hdbconnect", "path": "/hdbconnect_impl/src/conn/tcp_client/sync_plain_tcp_client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/rand/v0_8/crate/src/rngs/adapter/mod.rs // Copyright 2018 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https:...
code_fim
medium
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/rand/v0_8/crate/src/rngs/adapter/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(deprecated)] pub use self::read::{ReadError, ReadRng}; pub use self::reseeding::ReseedingRng;<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/rand/v0_8/crate/src/rngs/adapter/mod.rs // Copyright 2018 Developers of the Rand project. // // Licensed under the Apache License, Version ...
code_fim
medium
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/rand/v0_8/crate/src/rngs/adapter/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns a mutable reference to the cell at the given `index`. pub fn mut_cell(&mut self, index: usize) -> &mut Cell { &mut self.cells[index] } /// Get the indices for the neighbors of the cell at the given `index`. pub fn get_neighbor_indices(&self, index: usize) -> Vec<usize> { ...
code_fim
hard
{ "lang": "rust", "repo": "TimBednarzyk/life-nd", "path": "/src/sim.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TimBednarzyk/life-nd path: /src/sim.rs use rand::{self, Rng}; /// A single cell in the simulation #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Cell { Dead, Alive, } impl ::std::convert::From<bool> for Cell { fn from(val: bool) -> Cell { if val { Cell::Alive } else { Cell::...
code_fim
hard
{ "lang": "rust", "repo": "TimBednarzyk/life-nd", "path": "/src/sim.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Convert the coordinates to an index and add it to the list n_inds.push(self.coords_to_index(&n_coords)); } n_inds } /// Performs a single step in the simulation. pub fn step(&mut self) { let last_state = self.clone(); let mut alive_neighbors; for (index, cell)...
code_fim
hard
{ "lang": "rust", "repo": "TimBednarzyk/life-nd", "path": "/src/sim.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_flip_mirror_gray_enlarge() { let all_image = image::open("./src/test_pictures/flip_mirror_gray_enlarge.png".to_string()).expect("TEST ERROR"); let mut test_img = imagestruct::MainImage::new("./src/test_pictures/beach.jpeg".to_string()); test_img = test_img.flip_image(); test_im...
code_fim
hard
{ "lang": "rust", "repo": "caameron/Pixel-Converter", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(gray_image.pixels().eq(test_img.img.pixels()), true); } #[test] fn test_enlarge() { let enlarge_image = image::open("./src/test_pictures/enlarge.png".to_string()).expect("TEST ERROR"); let mut test_img = imagestruct::MainImage::new("./src/test_pictu...
code_fim
hard
{ "lang": "rust", "repo": "caameron/Pixel-Converter", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caameron/Pixel-Converter path: /src/main.rs extern crate image; extern crate rand; use std::io; mod crop; mod enlarge; mod flip; mod grayscale; mod imagestruct; mod jumbler; mod mirror; mod pixelate; mod rotate180; mod rotate270; mod rotate90; //Main Function for the project. fn main() { /...
code_fim
hard
{ "lang": "rust", "repo": "caameron/Pixel-Converter", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 4nt1g0/burst-rust path: /src/lib.rs #![feature(iterator_step_by)] #![feature(libc)] #![feature(conservative_impl_trait)] extern crate ocl; extern crat<|fim_suffix|>tern crate serde_derive; extern crate serde_json; extern crate serde; extern crate reqwest; extern crate config; #[macro_use] exter...
code_fim
medium
{ "lang": "rust", "repo": "4nt1g0/burst-rust", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>tern crate serde_derive; extern crate serde_json; extern crate serde; extern crate reqwest; extern crate config; #[macro_use] extern crate lazy_static; #[macro_use] extern crate arrayref; pub mod mine; pub mod plot; pub mod util;<|fim_prefix|>// repo: 4nt1g0/burst-rust path: /src/lib.rs #![feature(itera...
code_fim
medium
{ "lang": "rust", "repo": "4nt1g0/burst-rust", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laanwj/k210-sdk-stuff path: /rust/embgfx/src/main.rs #![allow(dead_code)] #![allow(non_snake_case)] #![allow(non_camel_case_types)] #![no_std] #![no_main] use embedded_graphics::fonts::Font6x8; use embedded_graphics::image::ImageBmp; use embedded_graphics::pixelcolor::raw::{RawData, RawU16}; us...
code_fim
hard
{ "lang": "rust", "repo": "laanwj/k210-sdk-stuff", "path": "/rust/embgfx/src/main.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let mut stdout = Stdout(&mut tx); io_mux_init(); io_set_power(); writeln!(stdout, "First frame").unwrap(); let dmac = p.DMAC.configure(); let spi = p.SPI0.constrain(); let mut lcd = LCD::new(spi, &dmac, dma_channel::CHANNEL0); lcd.init(); lcd.set_direction(lcd::direct...
code_fim
hard
{ "lang": "rust", "repo": "laanwj/k210-sdk-stuff", "path": "/rust/embgfx/src/main.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let mut local_input = input.clone(); local_input.push(1_f64); dgemm_s(m, n, k, alpha, &local_input, &self.delta, 1_f64, &mut self.weights, Transpose::Ordinary, Transpose::None); } } #[cfg(test)] mod test_neuronal { use super...
code_fim
hard
{ "lang": "rust", "repo": "farhaven/network", "path": "/src/layer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: farhaven/network path: /src/layer.rs use crate::matrixmath::{dgemm_s, Transpose}; use crate::nonlinearity::Nonlinearity; use rand::distributions::{Normal, Distribution}; #[derive(Debug)] pub struct Neuronal { pub output: Vec<f64>, delta: Vec<f64>, weights: Vec<f64>, shape: (usi...
code_fim
hard
{ "lang": "rust", "repo": "farhaven/network", "path": "/src/layer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prz23/zinc path: /zinc-compiler/src/semantic/element/type/function/intrinsic/stdlib/tests.rs NDEX_ARRAY + 1, expected: "[{scalar}; N]".to_owned(), found: Type::integer_unsigned(None, zinc_const::bitlength::BYTE).to_string(), })); let result = crate::semantic::tests::comp...
code_fim
hard
{ "lang": "rust", "repo": "prz23/zinc", "path": "/zinc-compiler/src/semantic/element/type/function/intrinsic/stdlib/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prz23/zinc path: /zinc-compiler/src/semantic/element/type/function/intrinsic/stdlib/tests.rs e; fn main() { let signature = Signature { r: Point { x: 1 as field, y: 2 as field }, s: 3 as field, pk: Point { x: 4 as field, y: 5 as field }, }; let message = [tru...
code_fim
hard
{ "lang": "rust", "repo": "prz23/zinc", "path": "/zinc-compiler/src/semantic/element/type/function/intrinsic/stdlib/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut index = repo.index().unwrap(); index.read(false).unwrap(); let author = repo.signature().unwrap(); let tree_oid = index.write_tree().unwrap(); let tree = repo.find_tree(tree_oid).unwrap(); let branch = repo.find_branch(&self.task, BranchType::Local...
code_fim
hard
{ "lang": "rust", "repo": "jadencarver/superconductor", "path": "/src/state/state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn save_update(&mut self, repo: &Repository, rng: &mut rand::ThreadRng) { let mut index = repo.index().unwrap(); index.read(false).unwrap(); let author = repo.signature().unwrap(); let tree_oid = index.write_tree().unwrap(); let tree = repo.find_tree(tree_oid)....
code_fim
hard
{ "lang": "rust", "repo": "jadencarver/superconductor", "path": "/src/state/state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jadencarver/superconductor path: /src/state/state.rs use std::path::Path; use git2::Repository; use git2::ObjectType; use git2::BranchType; use rand::Rng; use termion::color; use rand; use crate::task::Task; use yaml_rust::yaml::Hash; use yaml_rust::{Yaml, YamlEmitter}; #[derive(Debug, Clone,...
code_fim
hard
{ "lang": "rust", "repo": "jadencarver/superconductor", "path": "/src/state/state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp153/rtc/icsr.rs #[doc = "Register `ICSR` reader"] pub type R = crate::R<ICSR_SPEC>; #[doc = "Register `ICSR` writer"] pub type W = crate::W<ICSR_SPEC>; #[doc = "Field `ALRAWF` reader - ALRAWF"] pub type ALRAWF_R = crate::BitReader; #[doc = "...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/rtc/icsr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>d against non-secure access. Refer to Section50.3.4: RTC secure protection modes.\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`icsr::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/rtc/icsr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>= 0) } #[doc = "Bit 7 - INIT"] #[inline(always)] pub fn init(&self) -> INIT_R { INIT_R::new(((self.bits >> 7) & 1) != 0) } #[doc = "Bit 16 - RECALPF"] #[inline(always)] pub fn recalpf(&self) -> RECALPF_R { RECALPF_R::new(((self.bits >> 16) & 1) != 0) } }...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/rtc/icsr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bluedot-community/bluefire path: /bluefire_backend/src/router.rs is Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of // the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/ //! Functionality related to routing....
code_fim
hard
{ "lang": "rust", "repo": "bluedot-community/bluefire", "path": "/bluefire_backend/src/router.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn match_segment(&self, segment: &str) -> RouteMatch { match self.segment { Segment::Exact { name } => { if segment == name { RouteMatch::Exact } else { RouteMatch::NoMatch } } ...
code_fim
hard
{ "lang": "rust", "repo": "bluedot-community/bluefire", "path": "/bluefire_backend/src/router.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(cache.put("5", 5), None); assert_eq!(cache.len(), 4); assert_eq!( items(&mut cache), [("5", 5), ("4", 4), ("3", 3), ("2", 2)], "Least-recently-used item evicted." ); assert_eq!(cache.put("6", 6), None); assert_eq!(cache.put("7", 7), None); as...
code_fim
hard
{ "lang": "rust", "repo": "YoshieraHuang/LRUMap", "path": "/src/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut cache = TestMap::default(); assert_eq!(cache.put("1", 1), None); assert_eq!(cache.put("2", 2), None); assert_eq!(cache.put("3", 3), None); assert_eq!(cache.put("4", 4), None); assert_eq!(cache.len(), 4); assert_eq!( items(&mut cache), [("4", 4), ("3", 3...
code_fim
hard
{ "lang": "rust", "repo": "YoshieraHuang/LRUMap", "path": "/src/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YoshieraHuang/LRUMap path: /src/tests.rs use super::*; type TestMap = LRUMap<&'static str, i32, 4>; fn items<K, T, const N: usize>(map: &mut LRUMap<K, T, N>) -> Vec<(K, T)> where K: Hash + Eq + Clone, T: Clone { let mut v = Vec::new(); for (k, val) in map.iter() { v.pu...
code_fim
hard
{ "lang": "rust", "repo": "YoshieraHuang/LRUMap", "path": "/src/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>dTypeComputer, SidTypeLabel, }} pub type PSID_NAME_USE = *mut SID_NAME_USE; STRUCT!{struct SID_AND_ATTRIBUTES { Sid: PSID, Attributes: DWORD, }} pub type PSID_AND_ATTRIBUTES = *mut SID_AND_ATTRIBUTES; //9802 pub const ACL_REVISION: BYTE = 2; pub const ACL_REVISION_DS: BYTE = 4; pub const ACL_R...
code_fim
hard
{ "lang": "rust", "repo": "trlim/winapi-rs", "path": "/src/um/winnt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>IVIA: WORD = 0x01; pub const SUBLANG_QUECHUA_ECUADOR: WORD = 0x02; pub const SUBLANG_QUECHUA_PERU: WORD = 0x03; pub const SUBLANG_ROMANIAN_ROMANIA: WORD = 0x01; pub const SUBLANG_ROMANSH_SWITZERLAND: WORD = 0x01; pub const SUBLANG_RUSSIAN_RUSSIA: WORD = 0x01; pub const SUBLANG_SAKHA_RUSSIA: WORD = 0x01; p...
code_fim
hard
{ "lang": "rust", "repo": "trlim/winapi-rs", "path": "/src/um/winnt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trlim/winapi-rs path: /src/um/winnt.rs TRICORE: WORD = 0x0520; pub const IMAGE_FILE_MACHINE_CEF: WORD = 0x0CEF; pub const IMAGE_FILE_MACHINE_EBC: WORD = 0x0EBC; pub const IMAGE_FILE_MACHINE_AMD64: WORD = 0x8664; pub const IMAGE_FILE_MACHINE_M32R: WORD = 0x9041; pub const IMAGE_FILE_MACHINE_CEE: ...
code_fim
hard
{ "lang": "rust", "repo": "trlim/winapi-rs", "path": "/src/um/winnt.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ctx = rpc.context(); // The connection is now closed, asked to respawn if needed if ctx.did_update.load(Ordering::SeqCst) { server_tx.send(ServerSignal::Respawn).await.ok(); } ctx.dispose().await; }); } let mut tx_counter = 0; loop { tokio::select! { _ = exit_barrier.w...
code_fim
hard
{ "lang": "rust", "repo": "sergei-dyshel/vscode", "path": "/cli/src/tunnels/control_server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> rpc.register_sync("ping", |_: EmptyObject, _| Ok(EmptyObject {})); rpc.register_sync("gethostname", |_: EmptyObject, _| handle_get_hostname()); rpc.register_async("serve", move |params: ServeParams, c| async move { handle_serve(c, params).await }); rpc.register_async("update", |p: UpdateParams, c| ...
code_fim
hard
{ "lang": "rust", "repo": "sergei-dyshel/vscode", "path": "/cli/src/tunnels/control_server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sergei-dyshel/vscode path: /cli/src/tunnels/control_server.rs nnections may not be closed when this returns; use // `close_all_clients()` on the ServerTermination to make this happen. pub async fn serve( log: &log::Logger, mut tunnel: ActiveTunnel, launcher_paths: &LauncherPaths, code_server...
code_fim
hard
{ "lang": "rust", "repo": "sergei-dyshel/vscode", "path": "/cli/src/tunnels/control_server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tetcoin-staging/ink-waterfall path: /lang_macro/src/lib.rs // Copyright 2018-2021 Parity Technologies (UK) Ltd. // // 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 at // ...
code_fim
hard
{ "lang": "rust", "repo": "tetcoin-staging/ink-waterfall", "path": "/lang_macro/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // We should get rid of this `sleep` std::thread::sleep(std::time::Duration::from_secs(timeout)); std::process::Command::new("pkill") .args(&["-9", "-f", "geckodriver"]) .output() .expect("can not ...
code_fim
hard
{ "lang": "rust", "repo": "tetcoin-staging/ink-waterfall", "path": "/lang_macro/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jpalvarezl/async_rocket_playground path: /src/main.rs #![feature(async_closure, proc_macro_hygiene, decl_macro, option_result_contains)] extern crate log; #[macro_use] extern crate rocket; <|fim_suffix|>use crate::routes::*; use std::time::Duration; #[launch] fn rocket() -> _ { env_logge...
code_fim
medium
{ "lang": "rust", "repo": "jpalvarezl/async_rocket_playground", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use crate::routes::*; use std::time::Duration; #[launch] fn rocket() -> _ { env_logger::init(); let client = reqwest::Client::builder() .connect_timeout(Duration::from_millis(20000)) .build() .unwrap(); rocket::build() .mount("/", active_routes()) .re...
code_fim
medium
{ "lang": "rust", "repo": "jpalvarezl/async_rocket_playground", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> env_logger::init(); let client = reqwest::Client::builder() .connect_timeout(Duration::from_millis(20000)) .build() .unwrap(); rocket::build() .mount("/", active_routes()) .register("/", error_catchers()) .manage(client) }<|fim_prefix|>// repo:...
code_fim
medium
{ "lang": "rust", "repo": "jpalvarezl/async_rocket_playground", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tustvold/rust-playground path: /lib/kinesis/src/topology.rs use crate::shutdown; use futures::future::BoxFuture; use futures::FutureExt; use rusoto_core::RusotoError; use rusoto_kinesis::{Kinesis, KinesisClient, ListShardsError, ListShardsInput}; use std::convert::{TryFrom, TryInto}; use std::st...
code_fim
hard
{ "lang": "rust", "repo": "tustvold/rust-playground", "path": "/lib/kinesis/src/topology.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl TopologyClient { async fn list_shards(&self) -> Result<Topology> { let mut next_token = None; let mut open_shards: Vec<Shard> = Vec::new(); loop { let input = if next_token.is_some() { ListShardsInput { next_token, ...
code_fim
hard
{ "lang": "rust", "repo": "tustvold/rust-playground", "path": "/lib/kinesis/src/topology.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn set_foe(&mut self, foe: String); fn set_friend(&mut self, friend: String); fn set_i_dunno(&mut self, i_dunno: bool); } const SINGLE_CALL_GAS: u64 = 100_000_000_000_000; // Simple cross contract calls #[near_bindgen] impl Con1 { /// Deploy Con2 from within Con1 to a new address: c3.YOURADDRESS....
code_fim
hard
{ "lang": "rust", "repo": "thor314/near_cross_n_sim_ex", "path": "/c1/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, #[callback] #[serializer(borsh)] name: String, ); } #[near_bindgen] impl Con1 { pub fn cb_set_name(&mut self, #[callback] name: String) { self.set_name(name); } } #[near_bindgen] impl Con1 { /// Call `get_friend` and use it to call `set_name` locally, using `cb_set_nam...
code_fim
hard
{ "lang": "rust", "repo": "thor314/near_cross_n_sim_ex", "path": "/c1/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thor314/near_cross_n_sim_ex path: /c1/src/lib.rs #![allow(dead_code)] #![allow(unused_imports)] use near_sdk::{ borsh::{self, BorshDeserialize, BorshSerialize}, env, ext_contract, near_bindgen, Promise, PromiseOrValue, }; #[cfg(target = "wasm32")] #[global_allocator] static ALLOC: near_sdk:...
code_fim
hard
{ "lang": "rust", "repo": "thor314/near_cross_n_sim_ex", "path": "/c1/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vpetrigo/rust_book path: /smart-ptr/src/main.rs use std::rc::{Rc, Weak}; use std::cell::{RefCell, Ref}; use std::borrow::BorrowMut; #[derive(Debug)] pub struct Node { value: i32, adjacent: RefCell<Vec<Weak<Node>>>, } impl Node { pub fn new(value: i32) -> Node { Node { ...
code_fim
hard
{ "lang": "rust", "repo": "vpetrigo/rust_book", "path": "/smart-ptr/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn add_node(&mut self, id: usize) { self.nodes.insert(id - 1, Rc::new(Node::new(id as i32))); } pub fn add_adjacent(&self, id: usize, adj: usize) { unsafe { self.nodes.get_unchecked(id - 1) .borrow_mut() .add_adjacent(Rc::downgra...
code_fim
hard
{ "lang": "rust", "repo": "vpetrigo/rust_book", "path": "/smart-ptr/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: treetertot/raytracer path: /src/color.rs use crate::rtweekend::clamp; use crate::vec3::Color; pub(crate) fn clamp_color(pixel_color: &Color, samples_per_pixel: usize) -> (u8, u8, u8) { let r = pixel_color.x; let g = pixel_color.y; let b = pixel_color.z; <|fim_suffix|> ( ...
code_fim
hard
{ "lang": "rust", "repo": "treetertot/raytracer", "path": "/src/color.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ( (256.0 * clamp(r, 0.0, 0.999)) as u16 as u8, (256.0 * clamp(g, 0.0, 0.999)) as u16 as u8, (256.0 * clamp(b, 0.0, 0.999)) as u16 as u8, ) }<|fim_prefix|>// repo: treetertot/raytracer path: /src/color.rs use crate::rtweekend::clamp; use crate::vec3::Color; pub(crate) fn c...
code_fim
hard
{ "lang": "rust", "repo": "treetertot/raytracer", "path": "/src/color.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // filter results, only return the list which have least size temp .into_iter() .filter(|v| v.len() == min_size && v.last() == Some(&end_word)) .collect() } fn find_ladders(begin_word: String, end_word: String, word_list: Vec<String>) -> Vec<Vec<String>> { use std::collections::{HashSet...
code_fim
hard
{ "lang": "rust", "repo": "dainslef/RustPractice", "path": "/src/leetcode/q126_word_ladder_ii.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }