text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: tangmi/slang-rs path: /slang-sys/build.rs use cfg_if::cfg_if; use std::env; use std::fs; use std::fs::File; use std::io; use std::io::BufWriter; use std::io::Read; use std::io::Write; use std::path::Path; use std::path::PathBuf; use url::Url; /// Information about a Slang release zip struct Sla...
code_fim
hard
{ "lang": "rust", "repo": "tangmi/slang-rs", "path": "/slang-sys/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if (&*file.name()).ends_with('/') { fs::create_dir_all(&outpath)?; } else { if let Some(p) = outpath.parent() { if !p.exists() { fs::create_dir_all(&p)?; } } let mut outfile = fs::File::cre...
code_fim
hard
{ "lang": "rust", "repo": "tangmi/slang-rs", "path": "/slang-sys/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let bindings = bindgen::Builder::default() .clang_args(vec![ // bindgen doesn't assume *.h files are c++ "-x", "c++", "-std=c++11", ]) .header(slang_dir.join("slang.h").to_string_lossy()) .whitelist_type("slang_.*") ...
code_fim
hard
{ "lang": "rust", "repo": "tangmi/slang-rs", "path": "/slang-sys/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joriskes/adventofcode2020 path: /src/day07.rs use crate::aoc_utils::read_input; use regex::Regex; pub fn run(input_filename: &str) { let input = read_input(input_filename); part1(&input); part2(&input); } struct Bag { color: String, number: u32, parent_color: String, }...
code_fim
hard
{ "lang": "rust", "repo": "joriskes/adventofcode2020", "path": "/src/day07.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut count: u32 = 0; for bag in bags { if bag.parent_color == needle { count += &bag.number * count_inside(&bags, &bag.color); count += &bag.number; } } return count; } fn part2(input: &String) { let mut bags: Vec<Bag> = vec![]; for line...
code_fim
hard
{ "lang": "rust", "repo": "joriskes/adventofcode2020", "path": "/src/day07.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut result_bags: Vec<Bag> = vec![]; let regex_string = r"(?P<start_prefix>[a-z]+) (?P<start_color>[a-z]+) bags contain (?P<contents>.*)+"; let regex = Regex::new(&regex_string).unwrap(); let capture_result = regex.captures(line).expect("Invalid bag line"); let regex_string_...
code_fim
hard
{ "lang": "rust", "repo": "joriskes/adventofcode2020", "path": "/src/day07.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: memoryruins/bismite path: /ast/src/visit.rs use crate::*; pub trait Visitor: Sized { fn visit_module(&mut self, module: &Module) { walk::module(self, module); } fn visit_item(&mut self, item: &Item) { walk::item(self, item); } fn visit_function(&mut self, f...
code_fim
hard
{ "lang": "rust", "repo": "memoryruins/bismite", "path": "/ast/src/visit.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn visit_node(&mut self, node: &AstNode) { walk::node(self, node) } fn visit_statement(&mut self, _: &Statement) { todo!() } fn visit_expression(&mut self, _: &Expression) { todo!() } fn visit_use(&mut self, _: &Use) { todo!() } } pub mod...
code_fim
hard
{ "lang": "rust", "repo": "memoryruins/bismite", "path": "/ast/src/visit.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielverkamp/crosvm path: /gpu_display/src/gpu_display_win/math_util.rs // Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::any::type_name; use std::fmt; use euclid::point2; use euclid::size2...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/gpu_display/src/gpu_display_win/math_util.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> size2(self.height, self.width) } #[inline] fn shorter_edge(&self) -> i32 { std::cmp::min(self.width, self.height) } #[inline] fn aspect_ratio(&self) -> f32 { self.width as f32 / self.height as f32 } #[inline] fn is_square(&self) -> bool { ...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/gpu_display/src/gpu_display_win/math_util.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>} impl SysRectExtension for RECT { #[inline] fn to_rect(&self) -> Rect { Rect::new( point2(self.left, self.top), size2(self.right - self.left, self.bottom - self.top), ) } } pub trait PointExtension { fn to_sys_point(&self) -> POINT; } impl PointE...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/gpu_display/src/gpu_display_win/math_util.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: // Do something with this D: #[allow(dead_code)] pub fn available_languages( ) -> Result<(Vec<String>, Vec<String>), Box<dyn Error>> { let langfiles = Self::langfiles()?; let mut languages = Vec::new(); let mut aliases = Vec::new(); for lf in la...
code_fim
hard
{ "lang": "rust", "repo": "m-rsha/spacework", "path": "/src/config/languagefile.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /* let mut langfiles = Vec::new(); for entry in fs::read_dir( Path::new(&env::var("CARGO_MANIFEST_DIR")?) .join("langs/"))? { let entry = entry?.path(); if entry.is_file() { ...
code_fim
hard
{ "lang": "rust", "repo": "m-rsha/spacework", "path": "/src/config/languagefile.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m-rsha/spacework path: /src/config/languagefile.rs use serde::Deserialize; use std::collections::HashMap; use std::error::Error; use std::process::{Command, Output}; use std::str; #[derive(Debug, Deserialize)] pub struct LanguageFile { pub language: Language, pub cmd: Cmd, pub work...
code_fim
hard
{ "lang": "rust", "repo": "m-rsha/spacework", "path": "/src/config/languagefile.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>be marked as valid pub valid_enclave_quote_statuses: Cow<'a, [Cow<'a, str>]>, }<|fim_prefix|>// repo: devashishdxt/chain-enclave-ra path: /ra-client/src/config.rs use std::borrow::Cow; pub struct EnclaveCertVerifierConfig<'a> { /// Path to <|fim_middle|>PEM file containing attestation report sig...
code_fim
medium
{ "lang": "rust", "repo": "devashishdxt/chain-enclave-ra", "path": "/ra-client/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: devashishdxt/chain-enclave-ra path: /ra-client/src/config.rs use std::borrow::Cow; pub struct EnclaveCertVerifierConfig<'a> { /// Path to <|fim_suffix|>be marked as valid pub valid_enclave_quote_statuses: Cow<'a, [Cow<'a, str>]>, }<|fim_middle|>PEM file containing attestation report sig...
code_fim
medium
{ "lang": "rust", "repo": "devashishdxt/chain-enclave-ra", "path": "/ra-client/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kalebmorris/f18-assignments path: /assign6/src/executor.rs use std::mem; use std::sync::{mpsc, Mutex, Arc}; use std::thread; use future::{Future, Poll}; use future_util::*; /* * Core executor interface. */ pub trait Executor { fn spawn<F>(&mut self, f: F) where F: Future<Item = ()> +...
code_fim
hard
{ "lang": "rust", "repo": "kalebmorris/f18-assignments", "path": "/assign6/src/executor.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Executor for MultiThreadExecutor { fn spawn<F>(&mut self, f: F) where F: Future<Item = ()> + 'static, { self.sender.send(Some(Box::new(f))).unwrap(); } fn wait(&mut self) { let len = self.threads.len(); for _ in 0..len { self.sender.send(None).unwrap(); } take...
code_fim
hard
{ "lang": "rust", "repo": "kalebmorris/f18-assignments", "path": "/assign6/src/executor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // - MAXBPS: the max bits per seconds allowed. we're looking at how much // data was sent since last time and if needed, pause more let elapsed = precise_time_s() - *last_tick; let over_bandwidth = f64::value_from(data.len()).unwrap() - (elap...
code_fim
hard
{ "lang": "rust", "repo": "tarekziade/tinap_rust", "path": "/src/throttled_copy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut sdelay = delay.get_or_insert_with(|| Delay::new(Duration::from_millis(current_delay))); let pdelay = Pin::new(&mut sdelay); futures_core::ready!(pdelay.poll(cx)); // writing the data... let i = fut...
code_fim
hard
{ "lang": "rust", "repo": "tarekziade/tinap_rust", "path": "/src/throttled_copy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarekziade/tinap_rust path: /src/throttled_copy.rs // https://docs.rs/async-std/0.99.9/src/async_std/io/copy.rs.html#44-100 use std::pin::Pin; use std::time::Duration; use async_std::future::Future; use async_std::io::{self, BufRead, BufReader, Read, Write}; use async_std::task::{Context, Poll...
code_fim
hard
{ "lang": "rust", "repo": "tarekziade/tinap_rust", "path": "/src/throttled_copy.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wacko-professional/rust-book path: /ownership/slice_type/slices/src/main.rs fn main() { // a string slice is a reference to part of a String // internally the slice data structure stores the starting position and the length of the slice let mut s = String::from("hello, world"); ...
code_fim
medium
{ "lang": "rust", "repo": "wacko-professional/rust-book", "path": "/ownership/slice_type/slices/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } else { for i in 0..self.indices.len() { self.indices[i] = i; } self.indices.extend(self.indices.len()..k); self.pool.prefill(k); } } } impl<I> Iterator for Combinations<I> where I: Iterator, I::Item: Clone...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/itertools/src/combinations.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/vendor/itertools/src/combinations.rs use std::fmt; use std::iter::FusedIterator; use super::lazy_buffer::LazyBuffer; use alloc::vec::Vec; /// An iterator to iterate through all the `k`-length combinations in an iterator. /// /// See [`.combinatio...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/itertools/src/combinations.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum Relationship<'a> { BelongsTo(Option<&'a Record<'a>>), HasOne(Option<Record<'a>>), HasMany(Vec<Record<'a>>), }<|fim_prefix|>// repo: coeuvre/stone_data path: /src/relationship.rs use std::collections::HashMap; use model::{Model, Record}; pub type RelationshipTypes =...
code_fim
hard
{ "lang": "rust", "repo": "coeuvre/stone_data", "path": "/src/relationship.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coeuvre/stone_data path: /src/relationship.rs use std::collections::HashMap; use model::{Model, Record}; pub type RelationshipTypes = HashMap<&'static str, RelationshipType>; pub type Relationships<'a> = HashMap<String, Relationship<'a>>; #[derive(Debug)] pub enum RelationshipType { Belon...
code_fim
hard
{ "lang": "rust", "repo": "coeuvre/stone_data", "path": "/src/relationship.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn load_month_kills(year: i32, month: u32) -> usize { let mut total = 0; let mut date = Utc.ymd(year, month, 1); while date.month() == month as u32 { let kills = load_day_kills(year, month, date.day()); if 0 == kills { break; } date = date + Duration...
code_fim
hard
{ "lang": "rust", "repo": "seb-odessa/zkb", "path": "/tools/load.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seb-odessa/zkb path: /tools/load.rs #[macro_use] extern crate log; use lib::api; use lib::api::Killmail; use lib::models::{DB, Hash}; use std::collections::HashMap; use chrono::{Duration, TimeZone, Datelike, Utc, NaiveDate}; use std::io::Write; use std::thread; use std::time::Instant; use cro...
code_fim
hard
{ "lang": "rust", "repo": "seb-odessa/zkb", "path": "/tools/load.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: japaric-archived/linalg.rs path: /src/ops/sub/mod.rs #![doc(hidden)] // Implements `a - b` as `{ a -= b; a }` macro_rules! assign { ($lhs:ty { $($rhs:ty { $($bound:ident),+ }),+, }) => { $( impl<'a, 'b, 'c, T> Sub<$rhs> for $lhs where T: Neg<Output=T>, $(T: $bound),+ { ...
code_fim
easy
{ "lang": "rust", "repo": "japaric-archived/linalg.rs", "path": "/src/ops/sub/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.sub_assign(rhs); self } } )+ }; } mod col; mod mat; mod row;<|fim_prefix|>// repo: japaric-archived/linalg.rs path: /src/ops/sub/mod.rs #![doc(hidden)] // Implements `a - b` as `{ a -= b; a }` macro_rules! assign { ...
code_fim
easy
{ "lang": "rust", "repo": "japaric-archived/linalg.rs", "path": "/src/ops/sub/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for number_1 in &*numbers { for number_2 in &*numbers { for number_3 in &*numbers { if number_1 + number_2 + number_3 == 2020 { return Ok(number_1 * number_2 * number_3); } } } } Err("Combination not found") }<|fim_prefix|>// repo: holzingk/advent-of-code-2020 path: /src...
code_fim
medium
{ "lang": "rust", "repo": "holzingk/advent-of-code-2020", "path": "/src/bin/day01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: holzingk/advent-of-code-2020 path: /src/bin/day01.rs use std::fs::File; use std::io::{BufReader, BufRead}; fn main() { let file = File::open("./data/01").unwrap(); let reader = BufReader::new(file); let numbers: Vec<i32> = reader.lines().map(|s| s.unwrap().parse::<i32>().unwrap())....
code_fim
hard
{ "lang": "rust", "repo": "holzingk/advent-of-code-2020", "path": "/src/bin/day01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stevenlr/macro-serde path: /macroserde/src/de/place.rs #[macro_export] macro_rules! make_place_type { ($vis:vis $name:ident) => { #[allow(unused)] $vis struct $name<T> { $vis out: Option<T>, } impl<T> $nam<|fim_suffix|> unsafe { &mut *...
code_fim
medium
{ "lang": "rust", "repo": "stevenlr/macro-serde", "path": "/macroserde/src/de/place.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { &mut *{ out as *mut Option<T> as *mut Self } } } } } }<|fim_prefix|>// repo: stevenlr/macro-serde path: /macroserde/src/de/place.rs #[macro_export] macro_rules! make_place_type { ($vis:vis $name:ident) => { #[allow(unus<|fim_middle|>ed)] $...
code_fim
medium
{ "lang": "rust", "repo": "stevenlr/macro-serde", "path": "/macroserde/src/de/place.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { internal: Rc::downgrade(internal), } } } /// Clone the Weak reference inside the WRC. impl<T> Clone for WRC<T> { fn clone(&self) -> Self { Self { internal: Weak::clone(&self.internal), } } } impl<T: CloneName> CloneName for RRC<T...
code_fim
hard
{ "lang": "rust", "repo": "lorenzoditucci/calyx", "path": "/calyx/src/ir/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lorenzoditucci/calyx path: /calyx/src/ir/common.rs use super::CloneName; use std::cell::RefCell; use std::rc::{Rc, Weak}; /// Alias for a RefCell contained in an Rc reference. #[allow(clippy::upper_case_acronyms)] pub type RRC<T> = Rc<RefCell<T>>; /// A Wrapper for a weak RefCell pointer. /// ...
code_fim
medium
{ "lang": "rust", "repo": "lorenzoditucci/calyx", "path": "/calyx/src/ir/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn hash_is_different(file_hash: String, content: &[u8]) -> io::Result<bool> { let hasher = Sha1::new_with_prefix(content); let content_hash = format!("{:x}", hasher.finalize()); Ok(file_hash != content_hash) } pub struct NoopArtifactWriter; impl ArtifactWriter for NoopArtifactWriter { fn ...
code_fim
hard
{ "lang": "rust", "repo": "facebook/relay", "path": "/compiler/crates/relay-compiler/src/build_project/artifact_writer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebook/relay path: /compiler/crates/relay-compiler/src/build_project/artifact_writer.rs /* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use std::fmt::W...
code_fim
hard
{ "lang": "rust", "repo": "facebook/relay", "path": "/compiler/crates/relay-compiler/src/build_project/artifact_writer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { // let mut bitree = BiTree::create("abd..e..c.f..").unwrap(); let mut bitree = BiTree::create("ab..cd...").unwrap(); bitree.pre_order(); println!(""); bitree.swap(); bitree.pre_order(); }<|fim_prefix|>// repo: flaribbit/Data-structure-review-reference path: /sel...
code_fim
hard
{ "lang": "rust", "repo": "flaribbit/Data-structure-review-reference", "path": "/self2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // let mut bitree = BiTree::create("abd..e..c.f..").unwrap(); let mut bitree = BiTree::create("ab..cd...").unwrap(); bitree.pre_order(); println!(""); bitree.swap(); bitree.pre_order(); }<|fim_prefix|>// repo: flaribbit/Data-structure-review-reference path: /self2.rs struct ...
code_fim
hard
{ "lang": "rust", "repo": "flaribbit/Data-structure-review-reference", "path": "/self2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flaribbit/Data-structure-review-reference path: /self2.rs struct BiTree { value: char, left: Option<Box<BiTree>>, right: Option<Box<BiTree>>, } impl BiTree { fn create_node(iter: &mut std::str::Chars) -> Option<Box<BiTree>> { let value = iter.next().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "flaribbit/Data-structure-review-reference", "path": "/self2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plaflamme/advent-2018 path: /src/puzzle15/mod.rs (Hash, PartialOrd, Ord, PartialEq, Eq, Debug, Clone, Copy)] struct Pt { top: u16, left: u16 } impl Pt { fn new(top: u16, left: u16) -> Self { Pt { top, left } } fn pt_left(&self) -> Option<Self> { if self.left > 0 { So...
code_fim
hard
{ "lang": "rust", "repo": "plaflamme/advent-2018", "path": "/src/puzzle15/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plaflamme/advent-2018 path: /src/puzzle15/mod.rs se std::cell::RefCell; use std::cmp::{Reverse, Ordering}; #[derive(Hash, PartialOrd, Ord, PartialEq, Eq, Debug, Clone, Copy)] struct Pt { top: u16, left: u16 } impl Pt { fn new(top: u16, left: u16) -> Self { Pt { top, left } } ...
code_fim
hard
{ "lang": "rust", "repo": "plaflamme/advent-2018", "path": "/src/puzzle15/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Outcome::Solved(rounds, sum) } fn round(&mut self) -> RoundOutcome { self.all_units.sort_by_key(|x| x.borrow().pos); let mut turn_outcomes = Vec::new(); for current_unit in self.all_units.iter() { match self.turn(&current_unit) { TurnOu...
code_fim
hard
{ "lang": "rust", "repo": "plaflamme/advent-2018", "path": "/src/puzzle15/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tertsdiepraam/vrp path: /vrp-pragmatic/src/constraints/skills.rs #[cfg(test)] #[path = "../../tests/unit/constraints/skills_test.rs"] mod skills_test; use hashbrown::HashSet; use std::slice::Iter; use std::sync::Arc; use vrp_core::construction::constraints::*; use vrp_core::construction::heuris...
code_fim
hard
{ "lang": "rust", "repo": "tertsdiepraam/vrp", "path": "/vrp-pragmatic/src/constraints/skills.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match (job_skills.one_of.as_ref(), vehicle_skills) { (Some(job_skills), Some(vehicle_skills)) => job_skills.iter().any(|skill| vehicle_skills.contains(skill)), (Some(skills), None) if skills.is_empty() => true, (Some(_), None) => false, _ => true, } } fn check_none...
code_fim
hard
{ "lang": "rust", "repo": "tertsdiepraam/vrp", "path": "/vrp-pragmatic/src/constraints/skills.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avtrujillo/RustSudokuSolver path: /src/possibilities.rs use smallvec::SmallVec as SmallVec; use crate::progress_state::ProgressState as ProgressState; #[derive(Clone, Copy, PartialEq, Debug)] pub struct Possibilities { digits: [bool; 9] // "true" indicates that the digit (index + 1) is a po...
code_fim
hard
{ "lang": "rust", "repo": "avtrujillo/RustSudokuSolver", "path": "/src/possibilities.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Warning: only call this after making sure that there's only one remaining possibility // otherwise you'll just get the first possibility let solution_ind = self.digits.iter().enumerate().find( |(_ind, bool_val)| **bool_val ).expect("Couldn't find a solution")...
code_fim
hard
{ "lang": "rust", "repo": "avtrujillo/RustSudokuSolver", "path": "/src/possibilities.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn remaining(&self) -> SmallVec<[u8; 9]> { (1..=9).filter( |digit| self.get_digit_bool(*digit) ).collect() } pub fn eliminated(&self) -> SmallVec<[u8; 9]> { (1..=9).filter( |ind| !self.get_digit_bool(*ind) ).collect() } fn g...
code_fim
hard
{ "lang": "rust", "repo": "avtrujillo/RustSudokuSolver", "path": "/src/possibilities.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where S: Serializer, { let output = match self { Self::Strict => "strict", Self::Warn => "warn", Self::None => "none", }; serializer.serialize_str(output) } }<|fim_prefix|>// repo: bazaah/jira-rs path: /crates/libjira/src/op...
code_fim
medium
{ "lang": "rust", "repo": "bazaah/jira-rs", "path": "/crates/libjira/src/options/issue/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self::Strict } } impl Serialize for ValidateQuery { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let output = match self { Self::Strict => "strict", Self::Warn => "warn", Self::None => "...
code_fim
medium
{ "lang": "rust", "repo": "bazaah/jira-rs", "path": "/crates/libjira/src/options/issue/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bazaah/jira-rs path: /crates/libjira/src/options/issue/mod.rs mod create; mod get; mod metadata; mod search; use super::*; pub use {create::*, get::*, metadata::*, search::*}; /// Validation level for JQL statements passed /// to the Jira instance. /// /// - Strict: the default level, any err...
code_fim
hard
{ "lang": "rust", "repo": "bazaah/jira-rs", "path": "/crates/libjira/src/options/issue/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[require_permissions(category = "3")] pub fn delete_category( state: Data<AppState>, category_delete: ComplexQuery<CategoryDelete>, ) -> impl HandlerResponse<usize> { state .db .send(category_delete.into_inner()) .map_err(ImmortalError::ignore) .flatten() ...
code_fim
hard
{ "lang": "rust", "repo": "LyunKi/immortal-blog-server", "path": "/backend/src/handlers/categories.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LyunKi/immortal-blog-server path: /backend/src/handlers/categories.rs use actix_web::web::{Data, HttpRequest, Json, Path}; use common::{extractors::ComplexQuery, HandlerResponse, ImmortalError}; use crate::{utils, AppState}; use immortal_blog_derive::require_permissions; use share::{ domai...
code_fim
hard
{ "lang": "rust", "repo": "LyunKi/immortal-blog-server", "path": "/backend/src/handlers/categories.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[require_permissions(category = "3")] pub fn update_category( state: Data<AppState>, id: Path<i32>, category_update: Json<CategoryUpdateInfo>, ) -> impl HandlerResponse<()> { state .db .send(CategoryUpdate( id.into_inner(), category_update.into_inne...
code_fim
hard
{ "lang": "rust", "repo": "LyunKi/immortal-blog-server", "path": "/backend/src/handlers/categories.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_public_key_pin() { let security = Security::new().referrer_policy(ReferrerPolicy::UnsafeUrl); let client = create_client(security); let req = client.get("/"); let response = req.dispatch(); assert_eq!(response.status(), Status::Ok); let res_headers = response.heade...
code_fim
medium
{ "lang": "rust", "repo": "ant1441/rocket-security-fairing", "path": "/tests/referrer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ant1441/rocket-security-fairing path: /tests/referrer.rs #![feature(plugin)] #![plugin(rocket_codegen)] extern crate rocket; extern crate rocket_security; mod common; use rocket::http::Status; <|fim_suffix|> let req = client.get("/"); let response = req.dispatch(); assert_eq!(resp...
code_fim
hard
{ "lang": "rust", "repo": "ant1441/rocket-security-fairing", "path": "/tests/referrer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let security = Security::new().referrer_policy(ReferrerPolicy::UnsafeUrl); let client = create_client(security); let req = client.get("/"); let response = req.dispatch(); assert_eq!(response.status(), Status::Ok); let res_headers = response.headers(); assert_ne!(res_headers.le...
code_fim
medium
{ "lang": "rust", "repo": "ant1441/rocket-security-fairing", "path": "/tests/referrer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yrong/rust-examples path: /rpl/_11_collections/exercises/exercise_2_solution/src/main.rs // Convert strings to pig latin (_Keep in mind the details about UTF-8 encoding!_). fn main() { println!("{:10} -> {}", "apple", pigify("apple")); println!("{:10} -> {}", "first", pigify("first")); ...
code_fim
hard
{ "lang": "rust", "repo": "yrong/rust-examples", "path": "/rpl/_11_collections/exercises/exercise_2_solution/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// let's first make it work for a single word. // // pigify returns an owned String because // it doesn't have to retain ownership // to the returned String. fn pigify(w: &str) -> String { // get an utf-8 character iterator let mut chars = w.chars(); // get the first utf-8 char, and move the ...
code_fim
hard
{ "lang": "rust", "repo": "yrong/rust-examples", "path": "/rpl/_11_collections/exercises/exercise_2_solution/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Get `ProtocolData` by `ProtocolVersion`. GetProtocolData { /// The protocol version. protocol_version: ProtocolVersion, /// Responder to call with the result. responder: Responder<Result<Option<Box<ProtocolData>>, engine_state::Error>>, }, /// Commit gen...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/effect/requests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Abstract RPC request. /// /// An RPC request is an abstract request that does not concern itself with serialization or /// transport. #[derive(Debug)] #[must_use] pub enum RpcRequest<I> { /// Submit a deploy to be announced. SubmitDeploy { /// The deploy to be announced. deploy...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/effect/requests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /node/src/effect/requests.rs it: _, }) => write!( formatter, "list for inclusion: instant {} height {} next_finalized {}", context.timestamp(), context.height(), n...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/node/src/effect/requests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TabbyML/tabby path: /crates/rust-cxx-cmake-bridge/src/lib.rs use std::{io::Write, path::PathBuf}; // ## lib_name: "protobufd" // ## dir: "..../api_circuits/target/debug/build/lib-circuits-wrapper-49025516ce40925e/out/build/_deps/protobuf_fetch-build" // rustc-link-search=native=..../api_circuit...
code_fim
hard
{ "lang": "rust", "repo": "TabbyML/tabby", "path": "/crates/rust-cxx-cmake-bridge/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_read_cmake_generated_to_output() { let input = "/some/libA.a /some/libB.so"; let mut stdout = Vec::new(); read_cmake_generated_to_output(input, &mut stdout); assert_eq!( std::str::from_utf8(&stdout).unwrap(), "cargo:rustc-lin...
code_fim
hard
{ "lang": "rust", "repo": "TabbyML/tabby", "path": "/crates/rust-cxx-cmake-bridge/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.modb(Flags::NZVC.bits(), u8::rol); Ok(()) } //////////////////////////////////////////////////////////////////////////////// fn ror<A : AddressLines>(&mut self) -> Result<(), CpuErr> { self.rwmod8::<A>( Flags::NZC.bits(), u8::ror)?; Ok(()) } fn r...
code_fim
hard
{ "lang": "rust", "repo": "gazliddon/rustrex", "path": "/src/cpu/cpucore.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gazliddon/rustrex path: /src/cpu/cpucore.rs /////////////////////////////////////////////////////////// fn deca< A : AddressLines>(&mut self) -> Result<(), CpuErr> { self.moda( Flags::NZV.bits(), u8::dec); Ok(()) } fn decb< A : AddressLines>(&mut self) -> Result<(...
code_fim
hard
{ "lang": "rust", "repo": "gazliddon/rustrex", "path": "/src/cpu/cpucore.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gazliddon/rustrex path: /src/cpu/cpucore.rs } fn pushu_word(&mut self, v : u16) -> Result<(), CpuErr> { let u = self.regs.u.wrapping_sub(2); self.mem.store_word(u,v); self.regs.u = u ; Ok(()) } fn popu_byte(&mut self) -> Result<u8, CpuErr> { ...
code_fim
hard
{ "lang": "rust", "repo": "gazliddon/rustrex", "path": "/src/cpu/cpucore.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("| {} | {} | {} |", " ", "average", "median"); println!("|:----|----:|-----:|"); println!( "| baseline | {:?} | {:?} |", baseline_avg, baseline_median ); println!( "| wall_clock | {:?} | {:?} |", wall_clock_avg, wall_clock_median ); ...
code_fim
hard
{ "lang": "rust", "repo": "Cecca/timing-time", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cecca/timing-time path: /src/main.rs use std::time::{Duration, Instant}; fn run_baseline(n: usize, m: usize) -> (Duration, usize) { let v: Vec<usize> = (0..m).collect(); let start = Instant::now(); let mut sum: usize = 0; for _ in 0..n { sum += v.iter().sum::<usize>(); ...
code_fim
hard
{ "lang": "rust", "repo": "Cecca/timing-time", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn write_chunk<W>(&self, write: &mut W) -> Result<()> where W: Write + Seek; } #[derive(Debug, Eq, PartialEq)] pub(crate) struct Header { chunk_identifiers: Vec<ChunkIdentifier>, } impl Header { pub fn new(chunk_identifiers: impl Into<Vec<ChunkIdentifier>>) -> Self { Head...
code_fim
hard
{ "lang": "rust", "repo": "finalfusion/finalfusion-rust", "path": "/src/chunks/io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // magic + model version (u32) + chunk ids len (u32), chunk ids (len * u32) (MAGIC.len() + mem::size_of_val(&MODEL_VERSION) + mem::size_of::<u32>() + self.chunk_identifiers.len() * mem::size_of::<u32>()) as u64 } fn write_chunk<W>(&self, write: ...
code_fim
hard
{ "lang": "rust", "repo": "finalfusion/finalfusion-rust", "path": "/src/chunks/io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: finalfusion/finalfusion-rust path: /src/chunks/io.rs use std::convert::TryFrom; use std::fmt::{self, Display}; use std::fs::File; use std::io::{BufReader, Read, Seek, Write}; use std::mem; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use crate::error::{Error, Result}; const MOD...
code_fim
hard
{ "lang": "rust", "repo": "finalfusion/finalfusion-rust", "path": "/src/chunks/io.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nolik/CodeSignal path: /src/task/array_change.rs /* You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input. Example <|fim_suffix|>pub fn ar...
code_fim
medium
{ "lang": "rust", "repo": "nolik/CodeSignal", "path": "/src/task/array_change.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn array_change(mut input_array: Vec<i32>) -> i32 { let mut counter = 0; for item in 0..input_array.len() - 1 { if input_array[item] >= input_array[item + 1] { counter += input_array[item] + 1 - input_array[item + 1]; input_array[item + 1] = input_array[item] +...
code_fim
medium
{ "lang": "rust", "repo": "nolik/CodeSignal", "path": "/src/task/array_change.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> builder.files(common_files.into_iter()); builder.include(target_ledakemlt12_leaktime_dir).files( scheme_ledakemlt12_leaktime_files .into_iter() .map(|p| p.unwrap().to_string_lossy().into_owned()), ); builder.include(target_ledakemlt32_leaktime_dir).files( ...
code_fim
hard
{ "lang": "rust", "repo": "thomwiggers/pqcrypto", "path": "/pqcrypto-ledacryptkem/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomwiggers/pqcrypto path: /pqcrypto-ledacryptkem/build.rs extern crate cc; extern crate glob; use std::path::Path; fn main() { let target_ledakemlt12_leaktime_dir = Path::new("pqclean/crypto_kem/ledakemlt12/leaktime"); let scheme_ledakemlt12_leaktime_files = glob::glob( target...
code_fim
hard
{ "lang": "rust", "repo": "thomwiggers/pqcrypto", "path": "/pqcrypto-ledacryptkem/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GrandmasterTash/nails path: /src/clients/auth.rs use serde_json::json; use serde::Deserialize; use crate::{utils::http::post, utils::{context::RequestContext, errors::InternalError}}; /// /// This is an example of how to make a downstream HTTP request via another service. /// // Dummy example ...
code_fim
hard
{ "lang": "rust", "repo": "GrandmasterTash/nails", "path": "/src/clients/auth.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let response = post(format!("{}/auth/get-claims", ctx.config().auth_address)) .header("content-type", "application/json") .query_param("param1", "value1") .json(&json!({ "token": "eg session token from source request here" })) .send(ctx) .await?; match resp...
code_fim
hard
{ "lang": "rust", "repo": "GrandmasterTash/nails", "path": "/src/clients/auth.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Dummy example response body from an example request. #[derive(Debug, Deserialize)] pub struct ClaimResponse { claims: Vec<String> } /// /// Pass the session token to the remote auth service to check if the claim is assigned. /// /// This is just an example downstream HTTP request. /// pub async fn...
code_fim
medium
{ "lang": "rust", "repo": "GrandmasterTash/nails", "path": "/src/clients/auth.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vhdirk/tepl-rs path: /tepl/src/auto/gutter_renderer_folds.rs // This file was generated by gir (https://github.com/gtk-rs/gir @ 7f5a2b5) // from gir-files (https://github.com/gtk-rs/gir-files @ 2b56823) // DO NOT EDIT use ffi; use glib::object::IsA; use glib::translate::*; use glib_ffi; use gob...
code_fim
medium
{ "lang": "rust", "repo": "vhdirk/tepl-rs", "path": "/tepl/src/auto/gutter_renderer_folds.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<O: IsA<GutterRendererFolds>> GutterRendererFoldsExt for O { //fn set_state(&self, state: /*Ignored*/GutterRendererFoldsState) { // unsafe { TODO: call ffi::tepl_gutter_renderer_folds_set_state() } //} }<|fim_prefix|>// repo: vhdirk/tepl-rs path: /tepl/src/auto/gutter_renderer_folds.rs...
code_fim
hard
{ "lang": "rust", "repo": "vhdirk/tepl-rs", "path": "/tepl/src/auto/gutter_renderer_folds.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let f = File::open(path).unwrap(); let mut reader = BufReader::new(f); let mut line = String::new(); let begin = format!("{} begin", id); let end = format!("{} end", id); let mut add_line = false; let mut content = String::new(); while reader.read_line(&mut line).unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/blocktest", "path": "/src/block.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkkit/blocktest path: /src/block.rs use std::collections::HashMap; use std::ffi::OsStr; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; use pad::{PadStr, Alignment}; fn split(line: &str, comment: &str) -> String { let code: Vec<&str> = line.split(comment).colle...
code_fim
medium
{ "lang": "rust", "repo": "forkkit/blocktest", "path": "/src/block.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jasonrhansen/RustedNES path: /rustednes-common/src/time/system_time_source.rs use crate::time::TimeSource; use time::OffsetDateTime; pub struct SystemTimeSource {} <|fim_suffix|> (OffsetDateTime::now_utc() - OffsetDateTime::UNIX_EPOCH).whole_nanoseconds() as u64 } }<|fim_middle|>im...
code_fim
medium
{ "lang": "rust", "repo": "jasonrhansen/RustedNES", "path": "/rustednes-common/src/time/system_time_source.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct SystemTimeSource {} impl TimeSource for SystemTimeSource { fn time_ns(&self) -> u64 { (OffsetDateTime::now_utc() - OffsetDateTime::UNIX_EPOCH).whole_nanoseconds() as u64 } }<|fim_prefix|>// repo: jasonrhansen/RustedNES path: /rustednes-common/src/time/system_time_source.rs use...
code_fim
easy
{ "lang": "rust", "repo": "jasonrhansen/RustedNES", "path": "/rustednes-common/src/time/system_time_source.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl TimeSource for SystemTimeSource { fn time_ns(&self) -> u64 { (OffsetDateTime::now_utc() - OffsetDateTime::UNIX_EPOCH).whole_nanoseconds() as u64 } }<|fim_prefix|>// repo: jasonrhansen/RustedNES path: /rustednes-common/src/time/system_time_source.rs use crate::time::TimeSource; <|fim...
code_fim
easy
{ "lang": "rust", "repo": "jasonrhansen/RustedNES", "path": "/rustednes-common/src/time/system_time_source.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mgottschlag/rp2040-pac path: /src/clocks/fc0_max_khz.rs #[doc = "Register `FC0_MAX_KHZ` reader"] pub struct R(crate::R<FC0_MAX_KHZ_SPEC>); impl core::ops::Deref for R { type Target = crate::R<FC0_MAX_KHZ_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 ...
code_fim
hard
{ "lang": "rust", "repo": "mgottschlag/rp2040-pac", "path": "/src/clocks/fc0_max_khz.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `FC0_MAX_KHZ` writer - "] pub struct FC0_MAX_KHZ_W<'a> { w: &'a mut W, } impl<'a> FC0_MAX_KHZ_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u32) -> &'a mut W { self.w.bits = (self.w.bits & !...
code_fim
hard
{ "lang": "rust", "repo": "mgottschlag/rp2040-pac", "path": "/src/clocks/fc0_max_khz.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Spuffynism/cryptopals path: /src/aes/state.rs use aes; use aes::math; #[derive(Debug, Clone, PartialEq)] pub struct State { data: [[u8; 4]; aes::Nb], } impl State { pub fn from_part(part: &[u8]) -> State { let mut state = State::empty(); for r in 0..4 { for ...
code_fim
hard
{ "lang": "rust", "repo": "Spuffynism/cryptopals", "path": "/src/aes/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn add_round_key_test() { let key_schedule: &[[u8; 4]; 4] = &[ [0x13, 0x11, 0x1d, 0x7f], [0xe3, 0x94, 0x4a, 0x17], [0xf3, 0x07, 0xa7, 0x8b], [0x4d, 0x2b, 0x30, 0xc5] ]; let mut state = State { data: [ ...
code_fim
hard
{ "lang": "rust", "repo": "Spuffynism/cryptopals", "path": "/src/aes/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YZITE/encsess2 path: /demo-zsittle/src/bin/yzesd2-client.rs #![forbid(deprecated, unsafe_code)] use serde::Deserialize; use std::{collections::HashMap, sync::Arc}; #[derive(Debug, Deserialize)] struct ConfigServer { connect: String, pubkey: String, } #[derive(Debug, Deserialize)] stru...
code_fim
hard
{ "lang": "rust", "repo": "YZITE/encsess2", "path": "/demo-zsittle/src/bin/yzesd2-client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use futures_util::io::{self, AsyncBufReadExt, AsyncReadExt, AsyncWriteExt}; let sess = yz_encsess::Session::new(stream, config) .await .expect("unable to establish session"); let (srd, mut swr) = sess.split(); // Create async stdin and stdout handle...
code_fim
hard
{ "lang": "rust", "repo": "YZITE/encsess2", "path": "/demo-zsittle/src/bin/yzesd2-client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Sample Output 100 things taken 6 at a time is 1192052400 exactly. 20 things taken 5 at a time is 15504 exactly. 18 things taken 6 at a time is 18564 exactly. */ fn main() { assert_eq!(combinations(100, 6), 1192052400); assert_eq!(combinations(20, 5), 15504); assert_eq!(combinations(18, 6), ...
code_fim
hard
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/uva/369-combinations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qeedquan/challenges path: /uva/369-combinations.rs /* Computing the exact number of ways that N things can be taken M at a time can be a great challenge when N and/or M become very large. Challenges are the stuff of contests. Therefore, you are to make just such a computation given the followin...
code_fim
medium
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/uva/369-combinations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(combinations(100, 6), 1192052400); assert_eq!(combinations(20, 5), 15504); assert_eq!(combinations(18, 6), 18564); assert_eq!(combinations(20, 21), 0); assert_eq!(combinations(20, 20), 1); } fn combinations(mut n: isize, mut m: isize) -> isize { if m > n { retur...
code_fim
hard
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/uva/369-combinations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn main() { let r = Ray::new(Vector3::zero(), Vector3::new(1.0, 0.0, 0.0)); let uv = as_unit_vector(Vector3::new(1.0, 1.0, 1.0)); println!("{}", r); println!("{}", uv.x); }<|fim_prefix|>// repo: Vorapsak/RayTracing path: /src/utils/ray.rs use utils::vector3::*; use std::fmt; #[derive(Copy, Clone...
code_fim
medium
{ "lang": "rust", "repo": "Vorapsak/RayTracing", "path": "/src/utils/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vorapsak/RayTracing path: /src/utils/ray.rs use utils::vector3::*; use std::fmt; #[derive(Copy, Clone)] pub struct Ray { pub origin: Vector3, pub direction: Vector3 } <|fim_suffix|> pub fn point_at(self, t: f64) -> Vector3 { return self.origin + self.direction * t } } impl fmt::Display f...
code_fim
medium
{ "lang": "rust", "repo": "Vorapsak/RayTracing", "path": "/src/utils/ray.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/devices/tests/v2/compat/test.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. <|fim_suffix|>#[fasync::run_singlethreaded(test)] async fn test_sample_...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/devices/tests/v2/compat/test.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0o-de-lally/rustSTARK path: /src/example_proof.rs f8b7077b52054909fdf3a2d49c04f3992e16085fd213b47d4d08ea753c17c918a0603104ef113b61c1a4e6dc3c0f2f8cd00f8efe8e18b6a6520a0097ba07ebe12e7f62161a15c2b9f7889335fc0700ad0965a5eb5c18b61cd20b4e6d0613a0fa8b10ad799d1b6b45171bbd0b0409bf58d0082f4a5000b8558b2465...
code_fim
hard
{ "lang": "rust", "repo": "0o-de-lally/rustSTARK", "path": "/src/example_proof.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }