text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: hyperledger/indy-vdr path: /libindy_vdr/src/utils/macros.rs #![allow(unused_macros)] macro_rules! format_noop { ($($arg:tt)+) => { { // avoid unused variable warnings let _ = format_args!($($arg)+); } }; } #[cfg(not(feature = "log"))] macro_rules...
code_fim
hard
{ "lang": "rust", "repo": "hyperledger/indy-vdr", "path": "/libindy_vdr/src/utils/macros.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shamatar/arm_arith path: /benches/benchmark.rs use criterion::{black_box, criterion_group, criterion_main, Criterion}; use arm64_arith::*; use rand::*; fn b128(c: &mut Criterion) { <|fim_suffix|> c.bench_function("u128 wide mul", |bencher| bencher.iter(|| mul_assign(black_box(a), black_box(b...
code_fim
medium
{ "lang": "rust", "repo": "shamatar/arm_arith", "path": "/benches/benchmark.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// fn bm256(c: &mut Criterion) { // let mut rng = thread_rng(); // let a: [u64; 4] = rng.gen(); // let b: [u64; 4] = rng.gen(); // c.bench_function("u256 mont mul", |bencher| bencher.iter(|| mont_mul_assign_256(black_box(a), black_box(b)))); // } criterion_group!(benches, b128, b128_arm)...
code_fim
hard
{ "lang": "rust", "repo": "shamatar/arm_arith", "path": "/benches/benchmark.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("result: {:?}", pkcs7_remove(b"ICE ICE BABY\x04\x04\x04\x04")); println!("result: {:?}", pkcs7_remove(b"ICE ICE BABY\x05\x05\x05\x05")); println!("result: {:?}", pkcs7_remove(b"ICE ICE BABY\x01\x02\x03\x04")); }<|fim_prefix|>// repo: bollo35/cryptopals path: /src/bin/p015.rs extern crate ooga...
code_fim
easy
{ "lang": "rust", "repo": "bollo35/cryptopals", "path": "/src/bin/p015.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bollo35/cryptopals path: /src/bin/p015.rs extern crate ooga; use ooga::cipher_utils::pkcs7_remove; <|fim_suffix|> println!("result: {:?}", pkcs7_remove(b"ICE ICE BABY\x04\x04\x04\x04")); println!("result: {:?}", pkcs7_remove(b"ICE ICE BABY\x05\x05\x05\x05")); println!("result: {:?}", pkcs7_re...
code_fim
easy
{ "lang": "rust", "repo": "bollo35/cryptopals", "path": "/src/bin/p015.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>giga = OldDuration::seconds(10_i64.pow(9)); start + giga }<|fim_prefix|>// repo: coreyja/exercism-challenges path: /rust/gigasecond/src/lib.rs use chrono::{DateTime, Utc}; use time::Duration as OldDuration; // Returns a Utc DateTime one billion seconds after start. <|fim_middle|>pub fn after(start: ...
code_fim
medium
{ "lang": "rust", "repo": "coreyja/exercism-challenges", "path": "/rust/gigasecond/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coreyja/exercism-challenges path: /rust/gigasecond/src/lib.rs use chrono::{DateTime, Utc}; use time::Duration as OldDuration<|fim_suffix|>giga = OldDuration::seconds(10_i64.pow(9)); start + giga }<|fim_middle|>; // Returns a Utc DateTime one billion seconds after start. pub fn after(start: ...
code_fim
medium
{ "lang": "rust", "repo": "coreyja/exercism-challenges", "path": "/rust/gigasecond/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: znewman01/rust-etcd path: /tests/auth_test.rs use etcd::auth::{self, AuthChange, NewUser, Role, RoleUpdate, UserUpdate}; use etcd::{BasicAuth, Client}; use tokio::runtime::Runtime; #[test] fn auth() { let client = Client::new(&["http://etcd:2379"], None).unwrap(); let basic_auth = Basi...
code_fim
medium
{ "lang": "rust", "repo": "znewman01/rust-etcd", "path": "/tests/auth_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let response = auth::enable(&client).await.unwrap(); assert_eq!(response.data, AuthChange::Changed); let mut update_guest = RoleUpdate::new("guest"); update_guest.revoke_kv_write_permission("/*"); auth::update_role(&authed_client, update_guest) .await ...
code_fim
hard
{ "lang": "rust", "repo": "znewman01/rust-etcd", "path": "/tests/auth_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0150_evaluate_reverse_polish_notation/mod.rs pub mod stack; pub trait Solution { fn eval_rpn(tokens: Vec<String>) -> i32; } #[cfg(test)] mod tests { use super::Solution; <|fim_suffix|> for (tokens, expected) in test_cases { assert_...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0150_evaluate_reverse_polish_notation/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run<S: Solution>() { let test_cases = [ (&["2", "1", "+", "3", "*"] as &[_], 9), (&["4", "13", "5", "/", "+"], 6), ( &["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"], 22, ), ...
code_fim
medium
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0150_evaluate_reverse_polish_notation/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reitermarkus/msp432p401r-pac path: /src/dma/dma_ch_srccfg.rs #[doc = "Reader of register DMA_CH_SRCCFG[%s]"] pub type R = crate::R<u32, super::DMA_CH_SRCCFG>; #[doc = "Writer for register DMA_CH_SRCCFG[%s]"] pub type W = crate::W<u32, super::DMA_CH_SRCCFG>; #[doc = "Register DMA_CH_SRCCFG[%s] `r...
code_fim
hard
{ "lang": "rust", "repo": "reitermarkus/msp432p401r-pac", "path": "/src/dma/dma_ch_srccfg.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !0xff) | ((value as u32) & 0xff); self.w } } impl R { #[doc = "Bits 0:7 - Device level DMA source mapping to channel input"] #[inli...
code_fim
hard
{ "lang": "rust", "repo": "reitermarkus/msp432p401r-pac", "path": "/src/dma/dma_ch_srccfg.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>inline(always)] pub fn dma_src(&self) -> DMA_SRC_R { DMA_SRC_R::new((self.bits & 0xff) as u8) } } impl W { #[doc = "Bits 0:7 - Device level DMA source mapping to channel input"] #[inline(always)] pub fn dma_src(&mut self) -> DMA_SRC_W { DMA_SRC_W { w: self } } }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "reitermarkus/msp432p401r-pac", "path": "/src/dma/dma_ch_srccfg.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risooonho/remote_colonies path: /src/renderer/godot2d/input.rs use gdnative::*; use std::time::SystemTime; use crate::local::player::PlayerAction; use crate::local::input::InputHandler; use crate::local::model::CelestialProperties; pub struct InputHandler2D { target_planet: Option<Celesti...
code_fim
hard
{ "lang": "rust", "repo": "risooonho/remote_colonies", "path": "/src/renderer/godot2d/input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> PlayerAction::Wait } } impl InputHandler2D { pub fn new()-> Self { InputHandler2D{ target_planet: None, primary_mouse_button_time: SystemTime::now() } } fn handle_mouse_button_event(&mut self, target: CelestialProperties, event: InputEvent...
code_fim
hard
{ "lang": "rust", "repo": "risooonho/remote_colonies", "path": "/src/renderer/godot2d/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rauchg/AzureSDKForRust path: /src/azure/core/headers.rs pub const RANGE_GET_CONTENT_MD5: &str = "x-ms-range-get-content-md5"; //=> [bool] } pub const LEASE_ID: &str = "x-ms-lease-id"; //=> [LeaseId] } pub const CLIENT_REQUEST_ID: &str = "x-ms-client-request-id"; //=> [String] } pub const BLOB_PU...
code_fim
hard
{ "lang": "rust", "repo": "rauchg/AzureSDKForRust", "path": "/src/azure/core/headers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>b-type"; pub const BLOB_CONTENT_LENGTH: &str = "x-ms-blob-content-length"; pub const BLOB_ACCESS_TIER: &str = "x-ms-access-tier"; pub const BLOB_SEQUENCE_NUMBER: &str = "x-ms-blob-sequence-number"; pub const IF_SEQUENCE_NUMBER_LE: &str = "x-ms-if-sequence-number-le"; pub const IF_SEQUENCE_NUMBER_LT: &str ...
code_fim
hard
{ "lang": "rust", "repo": "rauchg/AzureSDKForRust", "path": "/src/azure/core/headers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lar-rs/mio path: /src/injection.rs /// Autosampler /// /// /// // use std::prelude::*; use std::io; use super::{device,error,MioError}; use std::fs; // use std::stream::Stream; use std::path::{PathBuf}; use std::stream; use std::time::Duration; use std::prelude::*; use std::convert::TryFrom; ...
code_fim
hard
{ "lang": "rust", "repo": "lar-rs/mio", "path": "/src/injection.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Injection interface.. impl Injection { // type Velocity; pub fn rinsing(&self ) -> Result<u32> { let position = fs::read_to_string(self.path.join("position"))?.parse::<u32>()?; Ok(position) } pub fn max( &mut self) -> Result<u32> { let max = fs::read_to_string(s...
code_fim
hard
{ "lang": "rust", "repo": "lar-rs/mio", "path": "/src/injection.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self, input: &mut ArgsInput, context: &PosCtx<'a, T::Context>, ) -> ApplyResult { if let Some(s) = input.try_parse_value(&context.inner)? { if self.0.is_some() { return Err(ErrorInner::TooManyArgOccurrences { arg: context....
code_fim
hard
{ "lang": "rust", "repo": "Aloso/parkour", "path": "/src/actions/option.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aloso/parkour path: /src/actions/option.rs use palex::ArgsInput; use crate::util::{ArgCtx, Flag, PosCtx}; use crate::{ErrorInner, FromInput, FromInputValue, Parse}; use super::{ Action, ApplyResult, Reset, Set, SetOnce, SetPositional, SetSubcommand, Unset, }; impl<'a, V: FromInputValue<'a...
code_fim
hard
{ "lang": "rust", "repo": "Aloso/parkour", "path": "/src/actions/option.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 处理与当前bar的包含关系 fn process_contain_relationship(&mut self, bar: &Bar) -> bool { // 队列中有至少两个经过包含处理的Candle debug_assert!(self.window.len() >= 2); let direction = { let k1 = self.window.get(-2).unwrap(); let k2 = self.window.get(-1).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "gaoxiaojun/day", "path": "/src/fractal_detector.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gaoxiaojun/day path: /src/fractal_detector.rs use crate::bar::Bar; use crate::candle::Candle; use crate::fractal::Fractal; use crate::ringbuffer::RingBuffer; pub struct FractalDetector { window: RingBuffer<Candle>, next_index: u64, candles: Option<Vec<Bar>>, } impl FractalDetector ...
code_fim
hard
{ "lang": "rust", "repo": "gaoxiaojun/day", "path": "/src/fractal_detector.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_candle_merge_fx_detector() { let bars = load_eurusd_2021(); let mut fvec :Vec<Fractal> = Vec::new(); let mut fd = FractalDetector::new(); for bar in &bars { let f = fd.on_new_bar(bar); if let Some(fx) = f { fve...
code_fim
hard
{ "lang": "rust", "repo": "gaoxiaojun/day", "path": "/src/fractal_detector.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// From given files and checksums, find out the checksum algorithms #[derive(Debug, StructOpt)] #[structopt(rename_all = "kebab-case")] struct Reverse { /// Print some messages indicating progress #[structopt(short, long, parse(from_occurrences))] verbose: u64, /// Do more parallelism, in...
code_fim
hard
{ "lang": "rust", "repo": "FFY00/delsum", "path": "/src/bin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FFY00/delsum path: /src/bin.rs use delsum_lib::checksum::{RelativeIndex, Relativity}; use delsum_lib::{find_algorithm, find_checksum, find_checksum_segments}; #[cfg(feature = "parallel")] use rayon::prelude::*; use std::ffi::OsString; use std::fs::File; use std::io::Read; use std::process::exit;...
code_fim
hard
{ "lang": "rust", "repo": "FFY00/delsum", "path": "/src/bin.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let files = read_files(&opts.files); let models = read_models(&opts.model, &opts.model_file); let is_single = models.len() <= 1; #[cfg(feature = "parallel")] let parallel = opts.parallel; #[cfg(not(feature = "parallel"))] let parallel = false; let print_sums = |model| { ...
code_fim
hard
{ "lang": "rust", "repo": "FFY00/delsum", "path": "/src/bin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result = if check_repeating_naturals(&result) { result.iter().map(|note| notes::note_as_flat(note, ref_notes)).collect() } else { result }; println!("{}", result.join(",")); } fn check_repeating_naturals(note_list: &Vec<String>) -> bool { let mut notes_iter = note_lis...
code_fim
medium
{ "lang": "rust", "repo": "tarsir/RustyChords", "path": "/src/theory/keys.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarsir/RustyChords path: /src/theory/keys.rs #[path = "notes.rs"] mod notes; pub fn get_key_signature(root_note: String, ref_notes: [&str; 12]) -> () { let intervals: [usize; 7] = [ 0, 2, 2, 1, 2, 2, 2 ]; let root_index: usize = match notes::get_note_index(&root_note, ref_no...
code_fim
hard
{ "lang": "rust", "repo": "tarsir/RustyChords", "path": "/src/theory/keys.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `P3SEL0_4` writer - P3SEL0_4"] pub struct P3SEL0_4_W<'a> { w: &'a mut W, } impl<'a> P3SEL0_4_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"]...
code_fim
hard
{ "lang": "rust", "repo": "chrismolli/msp430fr6972", "path": "/src/port_3_4/p3sel0.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chrismolli/msp430fr6972 path: /src/port_3_4/p3sel0.rs #[doc = "Register `P3SEL0` reader"] pub struct R(crate::R<P3SEL0_SPEC>); impl core::ops::Deref for R { type Target = crate::R<P3SEL0_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl core::co...
code_fim
hard
{ "lang": "rust", "repo": "chrismolli/msp430fr6972", "path": "/src/port_3_4/p3sel0.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexey-yakubov/rss-poller path: /src/config.rs use serde::Deserialize; use std::fs::File; use std::io::{BufReader, Read}; #[derive(Deserialize, Debug)] pub struct Config { pub input: Input, pub output: Output } #[derive(Deserialize, Debug)] pub struct Input { pub links: Vec<String>...
code_fim
hard
{ "lang": "rust", "repo": "alexey-yakubov/rss-poller", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn load_from_str(lines: &str) -> Result<Config, String> { match toml::from_str(lines) { Ok(config) => return Ok(config), Err(e) => { let mut err_msg = String::from("could not deserialize config: "); err_msg.push_str(&e.to_string()); ...
code_fim
hard
{ "lang": "rust", "repo": "alexey-yakubov/rss-poller", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_byte(byte: u8) -> Self { Self { carry: byte.get_bit(0), zero: byte.get_bit(1), interrupt_disable: byte.get_bit(2), decimal_mode: byte.get_bit(3), overflow: byte.get_bit(6), negative: byte.get_bit(7), } ...
code_fim
hard
{ "lang": "rust", "repo": "roscale/nesmulator", "path": "/src/flags.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: roscale/nesmulator path: /src/flags.rs use crate::util::BitOperations; #[derive(Debug)] pub struct CPUFlags { pub carry: bool, pub zero: bool, pub interrupt_disable: bool, pub decimal_mode: bool, pub overflow: bool, pub negative: bool, } <|fim_suffix|> pub fn to_byte...
code_fim
hard
{ "lang": "rust", "repo": "roscale/nesmulator", "path": "/src/flags.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ranma42/rust-mmap path: /src/lib.rs extern crate libc; use std::io::{Error,ErrorKind}; /* Only allow some combinations: R, RW, RX The other four combinations are not allowed for the following reasons: - 0: not being able to access the data can be achieved without mapping anything at all - ...
code_fim
hard
{ "lang": "rust", "repo": "ranma42/rust-mmap", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { libc::UnmapViewOfFile(self.ptr); // Ignore any error, memory safety will ensure that those // pages are not accessed anymore } // Just in case, be paranoid about data structure contents self.ptr = std::ptr::null_mut(); s...
code_fim
hard
{ "lang": "rust", "repo": "ranma42/rust-mmap", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn quick_works() { let mut things = vec![4,2,3,1,12,10]; QuickSort.sort(&mut things); assert_eq!(things, &[1,2,3,4,10,12]); }<|fim_prefix|>// repo: valdemarceccon/orst path: /src/quicksort.rs use super::Sorter; pub struct QuickSort; fn quicksort<T: Ord>(slice: &mut [T]) { match s...
code_fim
hard
{ "lang": "rust", "repo": "valdemarceccon/orst", "path": "/src/quicksort.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: valdemarceccon/orst path: /src/quicksort.rs use super::Sorter; pub struct QuickSort; fn quicksort<T: Ord>(slice: &mut [T]) { match slice.len() { 0 | 1 => return, 2 => { if slice[0] > slice[1] { slice.swap(0,1); } return; ...
code_fim
hard
{ "lang": "rust", "repo": "valdemarceccon/orst", "path": "/src/quicksort.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SuperHuangXu/learn-rust path: /leetcode-number-complement/src/lib.rs // https://leetcode-cn.com/problems/number-complement/ pub fn find_complement(num: i32) -> i32 { println!("{:?}", 10 >> 1); println!("{:?}", 10 << 1); 0 } <|fim_suffix|> assert_eq!(find_complement(5), 2); ...
code_fim
medium
{ "lang": "rust", "repo": "SuperHuangXu/learn-rust", "path": "/leetcode-number-complement/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(find_complement(5), 2); } }<|fim_prefix|>// repo: SuperHuangXu/learn-rust path: /leetcode-number-complement/src/lib.rs // https://leetcode-cn.com/problems/number-complement/ <|fim_middle|>pub fn find_complement(num: i32) -> i32 { println!("{:?}", 10 >> 1); println!("{:?}",...
code_fim
hard
{ "lang": "rust", "repo": "SuperHuangXu/learn-rust", "path": "/leetcode-number-complement/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: orlyngerano/rust-blackjack path: /src/console.rs use std::io; use crate::game::{ blackjack::BlackJack, cards, player::Player, status::{GameRoundResult, State}, }; pub struct BlackJackConsole { black_jack: BlackJack, } impl BlackJackConsole { pub fn new(player_name: Stri...
code_fim
hard
{ "lang": "rust", "repo": "orlyngerano/rust-blackjack", "path": "/src/console.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input.clear(); stdin.read_line(input).expect("ooops"); let choiced = match input.trim() { "h" | "H" => true, "s" | "S" => false, _ => BlackJackConsole::ask_player_play_to_hit_or_stand(), }; choiced } fn ask_player_play(...
code_fim
hard
{ "lang": "rust", "repo": "orlyngerano/rust-blackjack", "path": "/src/console.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HarrisonMc555/exercism path: /rust/collatz-conjecture/src/lib.rs pub fn collatz(n: u64) -> Option<u64> { if n == 0 { return None; } let mut x = n; let mut count = 0; loop { match x { 1 => return Some(count), old_x => x = next_collatz(ol...
code_fim
easy
{ "lang": "rust", "repo": "HarrisonMc555/exercism", "path": "/rust/collatz-conjecture/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if n % 2 == 0 { n / 2 } else { 3 * n + 1 } }<|fim_prefix|>// repo: HarrisonMc555/exercism path: /rust/collatz-conjecture/src/lib.rs pub fn collatz(n: u64) -> Option<u64> { if n == 0 { return None; } let mut x = n; let mut count = 0; loop { m...
code_fim
easy
{ "lang": "rust", "repo": "HarrisonMc555/exercism", "path": "/rust/collatz-conjecture/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> rcl_publisher_init( &mut publisher_handle as *mut _, node_handle as *mut _, type_support, topic_c_string.as_ptr(), &publisher_options as *const _, ) .ok()?; } let handle = R...
code_fim
hard
{ "lang": "rust", "repo": "esteve/ros2_rust", "path": "/rclrs/src/node/publisher.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: esteve/ros2_rust path: /rclrs/src/node/publisher.rs use crate::error::{RclResult, ToRclResult}; use crate::qos::QoSProfile; use crate::{Handle, Node, NodeHandle}; use crate::rcl_bindings::*; use std::borrow::Borrow; use std::cell::{Ref, RefCell, RefMut}; use std::ffi::CString; use std::marker::P...
code_fim
hard
{ "lang": "rust", "repo": "esteve/ros2_rust", "path": "/rclrs/src/node/publisher.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let handle = &mut *self.get_mut(); let node_handle = &mut *self.node_handle().get_mut(); unsafe { rcl_publisher_fini(handle as *mut _, node_handle as *mut _); } } } pub struct Publisher<T> where T: rclrs_common::traits::MessageDefinition<T>, { pub h...
code_fim
hard
{ "lang": "rust", "repo": "esteve/ros2_rust", "path": "/rclrs/src/node/publisher.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Newlifer/k1921vk01t-pac path: /src/nt_qep0.rs ocs.rs/svd2rust/#read--modify--write-api).\n\nFor information about avaliable fields see [qposinit](qposinit) module"] pub type QPOSINIT = crate::Reg<u32, _QPOSINIT>; #[allow(missing_docs)] #[doc(hidden)] pub struct _QPOSINIT; #[doc = "`read()` metho...
code_fim
hard
{ "lang": "rust", "repo": "Newlifer/k1921vk01t-pac", "path": "/src/nt_qep0.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>method takes [qwdtmr::W](qwdtmr::W) writer structure"] impl crate::Writable for QWDTMR {} #[doc = "Watchdog timer register"] pub mod qwdtmr; #[doc = "Period watchdog timer register\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic...
code_fim
hard
{ "lang": "rust", "repo": "Newlifer/k1921vk01t-pac", "path": "/src/nt_qep0.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Newlifer/k1921vk01t-pac path: /src/nt_qep0.rs #[doc = "0x44 - Reset interrupt"] pub qclr: QCLR, #[doc = "0x48 - Emulation interrupt"] pub qfrc: QFRC, #[doc = "0x4c - Status interrupt"] pub qepsts: QEPSTS, #[doc = "0x50 - Timer register"] pub qctmr: QCTMR, #[doc =...
code_fim
hard
{ "lang": "rust", "repo": "Newlifer/k1921vk01t-pac", "path": "/src/nt_qep0.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn produces_correct_answer_for_example() { assert_eq!(2520, solve(10)); } #[test] fn produces_correct_answer_for_problem() { assert_eq!(232792560, solve(20)); } }<|fim_prefix|>// repo: Mathspy/euler_rust_practice path: /005_smallest_multiple/src/main.rs us...
code_fim
hard
{ "lang": "rust", "repo": "Mathspy/euler_rust_practice", "path": "/005_smallest_multiple/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mathspy/euler_rust_practice path: /005_smallest_multiple/src/main.rs use std::collections::hash_map::{Entry, HashMap}; use std::env; fn main() { let args: Vec<String> = env::args().collect(); println!( "{}", solve(args[1].parse().expect("Please input a valid integer")) ...
code_fim
hard
{ "lang": "rust", "repo": "Mathspy/euler_rust_practice", "path": "/005_smallest_multiple/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LukasKalbertodt/jswag path: /src/java/mod.rs /// Functionality to call original `java` and `javac` commands. /// /// The actual functionality is implemented in submodule `inner`. This parent /// module contains functions for pretty printing the output of `inner`. mod inner; use job::Job; use st...
code_fim
hard
{ "lang": "rust", "repo": "LukasKalbertodt/jswag", "path": "/src/java/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> inner::run(class, parent, job).map_err(|e| { match e { Error::JavaBinaryNotFound => { msg!( Error, "`{1}` was not found on the system. Make sure that `{1}` \ is installed and in your PATH. Aborting.", ...
code_fim
hard
{ "lang": "rust", "repo": "LukasKalbertodt/jswag", "path": "/src/java/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>on::ReadModifyWrite(RMWMnemonic::ROL, AddressingMode::ZeroPage)), 0x36 => Some(Instruction::ReadModifyWrite(RMWMnemonic::ROL, AddressingMode::ZeroPageX)), 0x2e => Some(Instruction::ReadModifyWrite(RMWMnemonic::ROL, AddressingMode::Absolute)), 0x3e => Some(Instruction::ReadModifyWri...
code_fim
hard
{ "lang": "rust", "repo": "jeroendehaas/sfoxidized", "path": "/src/sfoxidized/cpu/instruction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeroendehaas/sfoxidized path: /src/sfoxidized/cpu/instruction.rs pub enum AddressingMode { Immediate, ZeroPage, ZeroPageX, ZeroPageY, Absolute, AbsoluteX, AbsoluteY, IndexedIndirect, IndirectIndexed } pub enum JumpAddressingMode { Absolute, Indirect } pub enum SingleB...
code_fim
hard
{ "lang": "rust", "repo": "jeroendehaas/sfoxidized", "path": "/src/sfoxidized/cpu/instruction.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>(Instruction::SingleByte(SingleByteMnemonic::INX)), 0xc8 => Some(Instruction::SingleByte(SingleByteMnemonic::INY)), 0x4c => Some(Instruction::Jump(JumpAddressingMode::Absolute)), 0x6c => Some(Instruction::Jump(JumpAddressingMode::Indirect)), 0x20 => Some(Instruction::Misc(M...
code_fim
hard
{ "lang": "rust", "repo": "jeroendehaas/sfoxidized", "path": "/src/sfoxidized/cpu/instruction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl InboundGroupSession { /// Create a new inbound group session for the given room. /// /// These sessions are used to decrypt room messages. /// /// # Arguments /// /// * `sender_key` - The public curve25519 key of the account that /// sent us the session /// ///...
code_fim
hard
{ "lang": "rust", "repo": "mautamu/matrix-rust-sdk", "path": "/matrix_sdk_crypto/src/olm/group_sessions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Encrypt a room message for the given room. /// /// Beware that a group session needs to be shared before this method can be /// called using the `share_group_session()` method. /// /// Since group sessions can expire or become invalid if the room membership /// changes clie...
code_fim
hard
{ "lang": "rust", "repo": "mautamu/matrix-rust-sdk", "path": "/matrix_sdk_crypto/src/olm/group_sessions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mautamu/matrix-rust-sdk path: /matrix_sdk_crypto/src/olm/group_sessions.rs // Copyright 2020 The Matrix.org Foundation C.I.C. // // 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 ...
code_fim
hard
{ "lang": "rust", "repo": "mautamu/matrix-rust-sdk", "path": "/matrix_sdk_crypto/src/olm/group_sessions.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> async fn filter_to( &self, to: &mut Email<&str>, _meta: &mut MailMetadata<()>, _conn_meta: &mut ConnectionMetadata<()>, ) -> Decision { let loc = *to.localpart.raw(); if loc != "forbidden" { Decision::Accept } else { D...
code_fim
hard
{ "lang": "rust", "repo": "martell/yuubind", "path": "/smtp-server/examples/simple_stdio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: martell/yuubind path: /smtp-server/examples/simple_stdio.rs #![type_length_limit = "200000000"] use std::borrow::Cow; use async_trait::async_trait; use duplexify::Duplex; use futures::{executor, io, AsyncRead, AsyncReadExt}; use smtp_message::{Email, EscapedDataReader, Reply, ReplyCode}; use ...
code_fim
hard
{ "lang": "rust", "repo": "martell/yuubind", "path": "/smtp-server/examples/simple_stdio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rjmcguire/esprit path: /crates/easter/src/fun.rs use joker::track::*; use id::Id; use patt::Patt; use stmt::StmtListItem; <|fim_suffix|> self.id.untrack(); self.params.untrack(); self.body.untrack(); } } pub type Fun = Tracked<FunData>;<|fim_middle|>#[derive(Debug, ...
code_fim
hard
{ "lang": "rust", "repo": "rjmcguire/esprit", "path": "/crates/easter/src/fun.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Untrack for ParamsData { fn untrack(&mut self) { self.list.untrack(); } } #[derive(Debug, PartialEq)] pub struct FunData { pub id: Option<Id>, pub params: Params, pub body: Vec<StmtListItem> } impl Untrack for FunData { fn untrack(&mut self) { self.id.untrack...
code_fim
medium
{ "lang": "rust", "repo": "rjmcguire/esprit", "path": "/crates/easter/src/fun.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Untrack for FunData { fn untrack(&mut self) { self.id.untrack(); self.params.untrack(); self.body.untrack(); } } pub type Fun = Tracked<FunData>;<|fim_prefix|>// repo: rjmcguire/esprit path: /crates/easter/src/fun.rs use joker::track::*; use id::Id; use patt::Patt; ...
code_fim
hard
{ "lang": "rust", "repo": "rjmcguire/esprit", "path": "/crates/easter/src/fun.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexheretic/hacker-news-scraper path: /src/athing.rs use select::{ node::Node, predicate::{Class, Name}, }; /// Wrapper for a `tr.athing` html node /// /// Contains uri, title & rank data plus indicates `AThingLine2`. #[derive(Debug, Copy, Clone)] pub struct AThing<'a>(pub Node<'a>); i...
code_fim
hard
{ "lang": "rust", "repo": "alexheretic/hacker-news-scraper", "path": "/src/athing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let document = Document::from(ATHING_FRAGMENT); let athing = AThing(document.find(Class("athing")).next().unwrap()); let (uri, title) = athing.uri_and_title().expect("failed"); assert_eq!(&uri, "http://hardmath123.github.io/ambigrams.html"); assert_eq!(&title, "Wor...
code_fim
hard
{ "lang": "rust", "repo": "alexheretic/hacker-news-scraper", "path": "/src/athing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use std::collections::HashSet; asteroids .iter() .map(|pos| { let z: HashSet<_> = asteroids .iter() .filter(|&p| p != pos) .map(|p| { let x = pos.x - p.x; let y = pos.y - p.y; ...
code_fim
hard
{ "lang": "rust", "repo": "nesv/advent-of-code", "path": "/2019/src/bin/10.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nesv/advent-of-code path: /2019/src/bin/10.rs use aoc::{ day10::{Angle, Map, Position}, Input, }; use std::io::{Error, ErrorKind, Result}; fn main() -> Result<()> { let in_file: String = match std::env::args().nth(1) { Some(v) => v, None => { return Err(E...
code_fim
hard
{ "lang": "rust", "repo": "nesv/advent-of-code", "path": "/2019/src/bin/10.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_part1_b() { let input = Input::new_from_str(r#"#.#...#.#. .###....#. .#....#... ##.#.#.#.# ....#.#.#. .##..###.# ..#...##.. ..##....## ......#... .####.###."#).unwrap(); let map = Map::from(input.lines().unwrap()); let asteroids = map.asteroids(); let (visible, position) = ...
code_fim
hard
{ "lang": "rust", "repo": "nesv/advent-of-code", "path": "/2019/src/bin/10.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rybergy/apollo path: /src/benchmark/performance.rs use crate::{common::*, othello::Disc, solve::Search}; use clap::ArgMatches; use rand::{thread_rng, Rng}; use std::time::SystemTime; pub fn main(matches: &ArgMatches) -> Result<(), String> { let n = matches .value_of("number") ...
code_fim
hard
{ "lang": "rust", "repo": "rybergy/apollo", "path": "/src/benchmark/performance.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let generated = alg.nodes_generated(); generateds[i] += generated as f64; let elapsed = start.elapsed().unwrap(); let ms = elapsed.subsec_millis(); times[i] += ms as f64; } } for &sum in generated...
code_fim
hard
{ "lang": "rust", "repo": "rybergy/apollo", "path": "/src/benchmark/performance.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kuy/elevato-rs path: /src/passenger.rs use amethyst::{ ecs::prelude::{Component, DenseVecStorage}, prelude::*, }; use rand::Rng; use crate::floor::NUM_OF_FLOORS; <|fim_suffix|>impl Component for Passenger { type Storage = DenseVecStorage<Self>; } fn gen_from_and_to() -> (i32, i32)...
code_fim
hard
{ "lang": "rust", "repo": "kuy/elevato-rs", "path": "/src/passenger.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rng = rand::thread_rng(); let from = rng.gen_range(0, NUM_OF_FLOORS); loop { let to = rng.gen_range(0, NUM_OF_FLOORS); if from != to { return (from, to); } } } pub fn spawn_passenger(world: &mut World, n: i32) { let (floor, dest) = gen_from_...
code_fim
hard
{ "lang": "rust", "repo": "kuy/elevato-rs", "path": "/src/passenger.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Passenger { pub id: i32, pub status: Status, pub floor: i32, } impl Passenger { fn new(id: i32, floor: i32, dest: i32) -> Passenger { Passenger { id, status: Status::GoTo(dest), floor, } } } impl Component for Passenger {...
code_fim
medium
{ "lang": "rust", "repo": "kuy/elevato-rs", "path": "/src/passenger.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>p(&mut a, &mut b); std::mem::swap(&mut x, &mut u); } if x < 0 { x += b0 / a; } (a as Int, x as Int) }<|fim_prefix|>// repo: shino16/cp_rust path: /src/math/gcd/ext.rs type Int = u64; type IInt = i64; /// (g, x) where g = gcd(a, b), ax = g (mod b), 0 <= x < b/g pub fn extg...
code_fim
hard
{ "lang": "rust", "repo": "shino16/cp_rust", "path": "/src/math/gcd/ext.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shino16/cp_rust path: /src/math/gcd/ext.rs type Int = u64; type IInt = i64; /// (g, x) where g = gcd(a, b), ax = g (mod b), 0 <= x < b/g pub fn extgcd(a: Int, b: Int) -> (Int, Int) { let (mut a, mut b) = (a as IInt, b as IInt); let b0 = b; // A = [a, x, y; b, u, v], k = [-1; a; b], ...
code_fim
medium
{ "lang": "rust", "repo": "shino16/cp_rust", "path": "/src/math/gcd/ext.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: selu/build-info path: /build-info-proc/src/format/value/macros.rs use anyhow::Result; use proc_macro2::Span; use proc_macro_error::{abort, abort_if_dirty, emit_error}; use super::{as_arguments_1, Value}; pub(crate) fn call_macro(name: &str, args: &[Box<dyn Value>], span: Span) -> Result<Box<dy...
code_fim
hard
{ "lang": "rust", "repo": "selu/build-info", "path": "/build-info-proc/src/format/value/macros.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e for use in `build_info::format!`, as of now."; note = "The `nested` feature is enabled, but did not help."; ) } else { abort!(span, "Macro `{}!` cannot be called inside `build_info::format!`", name; note = "Only `concat!`, `env!` and `option_env!` are implemented for use in `bu...
code_fim
hard
{ "lang": "rust", "repo": "selu/build-info", "path": "/build-info-proc/src/format/value/macros.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn reset<T: ReadableHistogram>(&mut self, histogram: &T) { self.array_total_count = histogram.get_total_count(); self.count_at_this_value = 0; self.current_index = 0; self.current_value_at_index = 0; self.fresh_sub_bucket = true; self.next_value_at_i...
code_fim
hard
{ "lang": "rust", "repo": "soro/rusty-hdrhistogram", "path": "/src/iteration/iteration_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: soro/rusty-hdrhistogram path: /src/iteration/iteration_state.rs use core::ReadableHistogram; #[derive(Clone, Copy, Debug, PartialEq)] pub struct IterationState { pub array_total_count: u64, pub count_at_this_value: u64, pub current_index: u32, // TODO: maybe replace with highest...
code_fim
hard
{ "lang": "rust", "repo": "soro/rusty-hdrhistogram", "path": "/src/iteration/iteration_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n1t0/pyo3 path: /examples/rustapi_module/src/misc.rs use pyo3::prelude::*; use pyo3::wrap_pyfunction; <|fim_suffix|>#[pymodule] fn misc(_py: Python<'_>, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(issue_219, m)?)?; Ok(()) }<|fim_middle|>#[pyfunction] fn issue_219() -...
code_fim
medium
{ "lang": "rust", "repo": "n1t0/pyo3", "path": "/examples/rustapi_module/src/misc.rs", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> m.add_function(wrap_pyfunction!(issue_219, m)?)?; Ok(()) }<|fim_prefix|>// repo: n1t0/pyo3 path: /examples/rustapi_module/src/misc.rs use pyo3::prelude::*; use pyo3::wrap_pyfunction; #[pyfunction] fn issue_219() -> PyResult<()> { // issue 219: acquiring GIL inside #[pyfunction] deadlocks. ...
code_fim
medium
{ "lang": "rust", "repo": "n1t0/pyo3", "path": "/examples/rustapi_module/src/misc.rs", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> 4 * ({ let mut t = (n + 2, 1u64, 1u64); while t.0 > 0 { t = (t.0 - 1, t.2, t.1 + t.2); } t.1 } - 1) }<|fim_prefix|>// repo: chengluyu/codewars path: /rust/5kyu/perimeter-of-squares-in-a-rectangle.rs // https://www.codewars.com/kata/perimeter-of-squares-in-a-rectangle/train...
code_fim
easy
{ "lang": "rust", "repo": "chengluyu/codewars", "path": "/rust/5kyu/perimeter-of-squares-in-a-rectangle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chengluyu/codewars path: /rust/5kyu/perimeter-of-squares-in-a-rectangle.rs // https://www.codewars.com/kata/perimeter-of-squares-in-a-rectangle/train/rust <|fim_suffix|> 4 * ({ let mut t = (n + 2, 1u64, 1u64); while t.0 > 0 { t = (t.0 - 1, t.2, t.1 + t.2); } t.1 }...
code_fim
easy
{ "lang": "rust", "repo": "chengluyu/codewars", "path": "/rust/5kyu/perimeter-of-squares-in-a-rectangle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self.0 { DecoderImpl::Wav(ref source) => source.size_hint(), DecoderImpl::Vorbis(ref source) => source.size_hint(), DecoderImpl::Flac(ref source) => source.size_hint(), } } } impl<R> Source for Decoder<R> where R: Read + Seek { #[inlin...
code_fim
hard
{ "lang": "rust", "repo": "BonsaiDen/rodio", "path": "/src/decoder/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BonsaiDen/rodio path: /src/decoder/mod.rs //! Decodes samples from an audio file. use std::error::Error; use std::fmt; use std::io::{Read, Seek}; use std::time::Duration; use Source; mod flac; mod vorbis; mod wav; /// Source of audio samples from decoding a file. /// /// Supports WAV, Vorbis...
code_fim
hard
{ "lang": "rust", "repo": "BonsaiDen/rodio", "path": "/src/decoder/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn to_raw(&self) -> &[u8] { unimplemented!(); } }<|fim_prefix|>// repo: abhijeetbhagat/arcturus path: /src/common/stunresponse.rs use std::net::Ipv4Addr; pub struct StunResponse {} impl StunResponse { pub fn new(xor_port: u16, xor_mapped_address: Ipv4Addr) -> Self { Stun...
code_fim
hard
{ "lang": "rust", "repo": "abhijeetbhagat/arcturus", "path": "/src/common/stunresponse.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abhijeetbhagat/arcturus path: /src/common/stunresponse.rs use std::net::Ipv4Addr; pub struct StunResponse {} impl StunResponse { pub fn new(xor_port: u16, xor_mapped_address: Ipv4Addr) -> Self { StunResponse { xor_port: xor_port, xor_mapped_address: xor_mapp...
code_fim
hard
{ "lang": "rust", "repo": "abhijeetbhagat/arcturus", "path": "/src/common/stunresponse.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Velfi/Rust-Vector-Field-Visualization path: /src/noise/mod.rs mod domain_warping_noise; use domain_warping_noise::DomainWarpingNoise; use noise::NoiseFn; use crate::noise::domain_warping_noise::DomainWarpingNoiseParams; pub fn new_noise_fn_by_index(index: usize) -> Box<dyn NoiseFn<[f64; 3]>> ...
code_fim
hard
{ "lang": "rust", "repo": "Velfi/Rust-Vector-Field-Visualization", "path": "/src/noise/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} 6 => { println!("now using Perlin Noise generator"); Box::new(noise::Perlin::new()) } 7 => { println!("now using Value Noise generator"); Box::new(noise::Value::new()) } 8 => { println!("now using Worley ...
code_fim
hard
{ "lang": "rust", "repo": "Velfi/Rust-Vector-Field-Visualization", "path": "/src/noise/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for neighbor in [ (current_pos.0 + 1, current_pos.1), (current_pos.0 - 1, current_pos.1), (current_pos.0, current_pos.1 + 1), (current_pos.0, current_pos.1 - 1), ].iter() { let distance = current.1 + 1; //println!("Ne...
code_fim
hard
{ "lang": "rust", "repo": "g-bartoszek/advent-of-code-2019", "path": "/day18/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: g-bartoszek/advent-of-code-2019 path: /day18/src/main.rs use std::io::BufRead; use std::cmp::{Ordering, Reverse}; use std::thread::current; #[derive(PartialEq, Debug, Clone)] enum Field { Wall, Empty, Key(char), Door(char), Start, Undefined } type Point = (i32,i32); typ...
code_fim
hard
{ "lang": "rust", "repo": "g-bartoszek/advent-of-code-2019", "path": "/day18/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Qwuke/guac_rs path: /src/maine.rs extern crate actix; extern crate futures; use actix::prelude::*; use futures::Future; use std::io; /// Define message struct Ping; impl Message for Ping { type Result = Result<bool, io::Error>; } struct Pong; impl Message for Pong { type Result = Re...
code_fim
hard
{ "lang": "rust", "repo": "Qwuke/guac_rs", "path": "/src/maine.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("FakeOtherActor is alive"); } fn stopped(&mut self, ctx: &mut Context<Self>) { println!("FakeOtherActor is stopped"); } } /// Define handler for `Ping` message impl Handler<Ping> for MyActor { type Result = Result<bool, io::Error>; fn handle(&mut self, msg: ...
code_fim
hard
{ "lang": "rust", "repo": "Qwuke/guac_rs", "path": "/src/maine.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mavdi/cargo path: /tests/test_cargo_test.rs use support::{project, execs, basic_bin_manifest, COMPILING, cargo_dir}; use hamcrest::{assert_that, existing_file}; use cargo::util::process; fn setup() {} test!(cargo_test_simple { let p = project("foo") .file("Cargo.toml", basic_bin_ma...
code_fim
hard
{ "lang": "rust", "repo": "mavdi/cargo", "path": "/tests/test_cargo_test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_that(p.cargo_process("cargo-build"), execs()); assert_that(&p.bin("foo"), existing_file()); assert_that( process(p.bin("foo")), execs().with_stdout("hello\n")); assert_that(p.process(cargo_dir().join("cargo-test")), execs().with_stdout(format!("{} foo v0.5....
code_fim
hard
{ "lang": "rust", "repo": "mavdi/cargo", "path": "/tests/test_cargo_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ument collection let remaining_money = bank_balance.unwrap() + wallet_balance.unwrap(); let actual_money = remaining_money - (payment_balance.unwrap() + savings_balance.unwrap()); let daily_budget = actual_money / util::get_days_till_next_salary(); println!("Your Current Daily Budget is: {}", da...
code_fim
medium
{ "lang": "rust", "repo": "mark-lumbao/budget-calc", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }