text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> while n > 0 {
n /= 5;
result += n;
}
result
}
}
// @lc code=end<|fim_prefix|>// repo: itkrt2y/LeetCode path: /172.factorial-trailing-zeroes.rs
/*
* @lc app=leetcode id=172 lang=rust
*
* [172] Factorial Trailing Zeroes
*/
<|fim_middle|>// @lc code=... | code_fim | medium | {
"lang": "rust",
"repo": "itkrt2y/LeetCode",
"path": "/172.factorial-trailing-zeroes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[no_mangle]
pub fn evaluate_file(filename: *const c_char) -> JsonnetResult {
unsafe {
if !_VM_LOCK {
_VM = jsonnet_make();
_VM_LOCK = true;
}
let mut error : size_t = 0 as size_t;
let data = jsonnet_evaluate_file(_VM,filename,&mut error);
if error == 0 {
Ok(ctos(data))... | code_fim | hard | {
"lang": "rust",
"repo": "yuduanchen/rust-jsonnet",
"path": "/src/ffi/command.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
#[warn(private_no_mangle_fns)]
fn ctos(msg : *const c_char)-> String{
let buf = unsafe { CStr::from_ptr(msg).to_bytes() };
let val = String::from_utf8(buf.to_vec()).unwrap();
return val;
}
pub struct Jsonnet;
impl Jsonnet {
#[no_mangle]
pub fn evaluate_file(filename: *const c_char) -> JsonnetRe... | code_fim | medium | {
"lang": "rust",
"repo": "yuduanchen/rust-jsonnet",
"path": "/src/ffi/command.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yuduanchen/rust-jsonnet path: /src/ffi/command.rs
#[warn(unused_imports)]
extern crate libc;
use libc::size_t;
use libc::c_char;
use std::ffi::CStr;
#[warn(unused_mut)]
#[repr(C)]
struct JsonnetVm;
static mut _VM_LOCK:bool = false;
static mut _VM :*mut JsonnetVm = 0 as *mut JsonnetVm;
pub ty... | code_fim | hard | {
"lang": "rust",
"repo": "yuduanchen/rust-jsonnet",
"path": "/src/ffi/command.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nGb);
let input = typos::tokens::Word::new(input, 0).unwrap();
assert_eq!(
corrections.correct_word(input),
Some(typos::Status::Corrections(vec![
std::borrow::Cow::Borrowed(output)
]))
);
b.... | code_fim | hard | {
"lang": "rust",
"repo": "crate-ci/typos",
"path": "/crates/typos-cli/benches/corrections.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crate-ci/typos path: /crates/typos-cli/benches/corrections.rs
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
fn bench_dict_load(c: &mut Criterion) {
let mut group = c.benchmark_group("load");
group.bench_function(BenchmarkId::new("load", "builtin"), |b| {
... | code_fim | hard | {
"lang": "rust",
"repo": "crate-ci/typos",
"path": "/crates/typos-cli/benches/corrections.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gadomski/sdf-rs path: /src/main.rs
//! Executable toolkit for working with sdf files.
extern crate docopt;
extern crate env_logger;
extern crate rustc_serialize;
extern crate sdf;
use std::process::exit;
use std::u32;
use docopt::Docopt;
use sdf::error::Error;
const USAGE: &'static str = "
... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/sdf-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.flag_version {
let library_version = sdf::library_version().unwrap_or_else(|e| {
error_exit("Unable to get library version", e)
});
println!(" sdf-rs version: {}", env!("CARGO_PKG_VERSION"));
println!(" sdfifc api version: {}.{}",
... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/sdf-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.cmd_info {
let info = file.info().unwrap_or_else(|e| error_exit("Unable to retrieve file info", e));
println!(" instrument: {}", info.instrument);
println!(" serial: {}", info.serial);
println!(" epoch: {}", info.epoch);
println!(... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/sdf-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut node = None;
for s in str_key.split('/') {
let next = self.get_common().ifind(node, s);
if next == None {
return None
}
node = next;
}
node
}
fn walk_dir<'a>(&'a self, oid: ObjectKey) -> DirIte... | code_fim | hard | {
"lang": "rust",
"repo": "Kimundi/snowmew",
"path": "/src/snowmew/common.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kimundi/snowmew path: /src/snowmew/common.rs
use cow::btree::{BTreeMap, BTreeMapIterator, BTreeSet, BTreeSetIterator};
#[deriving(Clone, Default)]
pub struct FrameInfo {
count: uint, /* unique frame identifier */
time: f64, /* current time in seconds */
delta: f64, /* time fro... | code_fim | hard | {
"lang": "rust",
"repo": "Kimundi/snowmew",
"path": "/src/snowmew/common.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gs-akhan/learning-rust path: /src/devowel.rs
fn main() {
println!("{}", "Removing Vowels from A String");
let input = String::from("Hello Rust Programmers");
<|fim_suffix|>fn remove_vowel(input: String) -> String {
let mut result = String::new();
for (_, c) in input.chars().enu... | code_fim | easy | {
"lang": "rust",
"repo": "gs-akhan/learning-rust",
"path": "/src/devowel.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result = String::new();
for (_, c) in input.chars().enumerate() {
match c {
'a' | 'e' | 'i' | 'o' | 'u' => {},
_ => result.push(c),
}
}
result
}<|fim_prefix|>// repo: gs-akhan/learning-rust path: /src/devowel.rs
fn main() {
println!("{}... | code_fim | medium | {
"lang": "rust",
"repo": "gs-akhan/learning-rust",
"path": "/src/devowel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn part2(input: &str) -> isize {
let w = input.lines().map(|l| l.split(",").map(|s| (&s[0..1], s[1..].parse::<isize>().unwrap())).collect::<Vec<_>>()).collect::<Vec<_>>();
let mut closest = (999999999999999isize, 999999999999999999isize);
let mut steps = 999999999999isize;
let mut vis... | code_fim | hard | {
"lang": "rust",
"repo": "0e4ef622/aoc",
"path": "/2019/day03/overkillquadtree/src/solution.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0e4ef622/aoc path: /2019/day03/overkillquadtree/src/solution.rs
use std::collections::HashSet;
use std::collections::HashMap;
struct LineSeg {
start: (isize, isize),
end: (isize, isize),
}
pub fn part1(input: &str) -> isize {
let w = input.lines().map(|l| l.split(",").map(|s| (&s[0... | code_fim | hard | {
"lang": "rust",
"repo": "0e4ef622/aoc",
"path": "/2019/day03/overkillquadtree/src/solution.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn cpu_usage() {
let cpu = Cpu::new(CGROUPS_PATH.to_string());
let res = Cpu::get_system_cpu_usage(&cpu);
assert!(res.unwrap() > 0);
}
#[test]
fn per_cpu() {
let cpu = Cpu::new(CGROUPS_PATH.to_string());
let res = Cpu::get_per_cpu_usage(... | code_fim | hard | {
"lang": "rust",
"repo": "Max-Meldrum/enya",
"path": "/stats/src/cpu.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Max-Meldrum/enya path: /stats/src/cpu.rs
use crate::util;
use std::fs::File;
use std::io::{BufRead, BufReader};
use crate::error::ErrorKind::*;
use crate::error::*;
use crate::sysconf::*;
lazy_static! {
static ref CLOCK_TICKS: u64 =
clock_ticks().expect("Unable to fetch clock tick... | code_fim | hard | {
"lang": "rust",
"repo": "Max-Meldrum/enya",
"path": "/stats/src/cpu.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.all_pais.iter().all(|e| (e.number == 1 || e.number == 9) && e.pai_type != PaiType::JIHAI)
}
pub fn num_sangenpais(&self) -> usize {
if let Combination::Normal(c) = &self.combination {
c.mentsus
.iter()
.filter(|e| e.pais[0].is_sange... | code_fim | hard | {
"lang": "rust",
"repo": "rick0000/shanten_rs",
"path": "/src/hora_candidate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rick0000/shanten_rs path: /src/hora_candidate.rs
n);
}
if self.yaku_info.ippatsu {
self.add_yaku(YakuName::Ippatsu, 1, 0, menzen);
}
if menzen && self.yaku_info.hora_type == HoraType::Tsumo {
self.add_yaku(YakuName::MenzenchinTsumoho, 1, 0,... | code_fim | hard | {
"lang": "rust",
"repo": "rick0000/shanten_rs",
"path": "/src/hora_candidate.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut all_pais = Vec::new();
for mentsu in &mentsus {
all_pais.extend(&mentsu.pais)
}
let furos = Vec::new();
let pattern = FixedHoraPattern::new(head, mentsus);
let combination = Combination::Normal(pattern);
let candidate = get_hora... | code_fim | hard | {
"lang": "rust",
"repo": "rick0000/shanten_rs",
"path": "/src/hora_candidate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imos/icfpc2021 path: /src/bin/show_problem.rs
use icfpc2021::paths::*;
use icfpc2021::*;
<|fim_suffix|> let args: Vec<_> = std::env::args().collect();
let prob = if args.len() < 2 {
read_input()
} else {
read_input_from_file(&args[1])
};
render_problem_svg(&p... | code_fim | medium | {
"lang": "rust",
"repo": "imos/icfpc2021",
"path": "/src/bin/show_problem.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> render_problem_svg(&prob, std::io::stdout())
}<|fim_prefix|>// repo: imos/icfpc2021 path: /src/bin/show_problem.rs
use icfpc2021::paths::*;
use icfpc2021::*;
<|fim_middle|>// Usage: show_problem [problem.json]
fn main() -> std::io::Result<()> {
let args: Vec<_> = std::env::args().collect();
... | code_fim | hard | {
"lang": "rust",
"repo": "imos/icfpc2021",
"path": "/src/bin/show_problem.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args: Vec<_> = std::env::args().collect();
let prob = if args.len() < 2 {
read_input()
} else {
read_input_from_file(&args[1])
};
render_problem_svg(&prob, std::io::stdout())
}<|fim_prefix|>// repo: imos/icfpc2021 path: /src/bin/show_problem.rs
use icfpc2021::path... | code_fim | medium | {
"lang": "rust",
"repo": "imos/icfpc2021",
"path": "/src/bin/show_problem.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: weichweich/rust-genetic path: /src/individual.rs
use rand::Rng;
#[derive(Clone)]
pub struct Individual {
pub genes: Vec<i8>,
pub size: usize,
pub solution: &'static [i8],
}
impl Individual {
pub fn new(solution: &'static [i8]) -> Individual {
let mut genes = Vec::new();
let siz... | code_fim | hard | {
"lang": "rust",
"repo": "weichweich/rust-genetic",
"path": "/src/individual.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = rand::thread_rng();
for _i in 0..size {
genes.push(rng.gen::<bool>() as i8);
}
Individual {
genes,
size,
solution,
}
}
pub fn set_gene(&mut self, index: usize, value: i8) {
self.genes[index] = value;
}
pub fn get_fitness(&self) -> u... | code_fim | medium | {
"lang": "rust",
"repo": "weichweich/rust-genetic",
"path": "/src/individual.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-osdev/acpi path: /aml/src/name_object.rs
use crate::{
misc::{arg_obj, debug_obj, local_obj, ArgNum, LocalNum},
namespace::{AmlName, NameComponent},
opcode::{opcode, DUAL_NAME_PREFIX, MULTI_NAME_PREFIX, NULL_NAME, PREFIX_CHAR, ROOT_CHAR},
parser::{choice, comment_scope, consu... | code_fim | hard | {
"lang": "rust",
"repo": "rust-osdev/acpi",
"path": "/aml/src/name_object.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{:?}", self.as_str())
}
}
pub fn name_seg<'a, 'c>() -> impl Parser<'a, 'c, NameSeg>
where
'c: 'a,
{
/*
* NameSeg := <LeadNameChar NameChar NameChar NameChar>
*/
// TODO: can we write this better?
move |input, context: &'c mut AmlContext| {
let (inp... | code_fim | hard | {
"lang": "rust",
"repo": "rust-osdev/acpi",
"path": "/aml/src/name_object.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asterycs/aoc2019 path: /src/bin/23.rs
use std::collections::{VecDeque};
use common::*;
use intcode::*;
struct Computer {
vm: IntcodeVM,
input_queue: VecDeque<i64>,
output_queue: VecDeque<i64>
}
impl Computer {
fn new(program: &Vec<i64>) -> Computer {
Computer{vm: Intco... | code_fim | hard | {
"lang": "rust",
"repo": "asterycs/aoc2019",
"path": "/src/bin/23.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(packet_queue) = packet_queues.get_mut(address as usize) {
packet_queue.push(Packet{x, y});
} else {
if address == 255 {
return Ok(y);
}
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "asterycs/aoc2019",
"path": "/src/bin/23.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wusyong/iota.mam.rust path: /iota-mam-sys/build.rs
// iota-mam-sys/build.rs
use std::process::Command;
macro_rules! get(($name:expr) => (ok!(env::var($name))));
macro_rules! ok(($expression:expr) => ($expression.unwrap()));
macro_rules! log {
($fmt:expr) => (println!(concat!("iota-mam-sys/b... | code_fim | hard | {
"lang": "rust",
"repo": "wusyong/iota.mam.rust",
"path": "/iota-mam-sys/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output = PathBuf::from(&get!("OUT_DIR"));
log_var!(output);
let source = PathBuf::from("entangled/");
log_var!(source);
let lib_dir = output; //.join(format!("lib-{}", LIB_OUTPUT));
log_var!(lib_dir);
if lib_dir.exists() {
log!("Dir... | code_fim | hard | {
"lang": "rust",
"repo": "wusyong/iota.mam.rust",
"path": "/iota-mam-sys/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[fastout]
fn main() {
input! {
n: u64,
}
let answer = (1..)
.take_while(|&i| i * i <= n)
.fold(0, |acc, i| (acc + (n - i * i) / i / 2 + 1) % MOD);
println!("{}", answer);
}<|fim_prefix|>// repo: sugyan/atcoder path: /arc125/src/bin/b.rs
use proconio::{fastout, inp... | code_fim | easy | {
"lang": "rust",
"repo": "sugyan/atcoder",
"path": "/arc125/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sugyan/atcoder path: /arc125/src/bin/b.rs
use proconio::{fastout, input};
const MOD: u64 = 998_244_353;
<|fim_suffix|> input! {
n: u64,
}
let answer = (1..)
.take_while(|&i| i * i <= n)
.fold(0, |acc, i| (acc + (n - i * i) / i / 2 + 1) % MOD);
println!("{... | code_fim | easy | {
"lang": "rust",
"repo": "sugyan/atcoder",
"path": "/arc125/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sugyan/atcoder path: /arc125/src/bin/b.rs
use proconio::{fastout, input};
<|fim_suffix|>#[fastout]
fn main() {
input! {
n: u64,
}
let answer = (1..)
.take_while(|&i| i * i <= n)
.fold(0, |acc, i| (acc + (n - i * i) / i / 2 + 1) % MOD);
println!("{}", answ... | code_fim | easy | {
"lang": "rust",
"repo": "sugyan/atcoder",
"path": "/arc125/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<MaxPool> for RawMaxPool {
fn from(maxpool: MaxPool) -> Self {
let MaxPool {
stride_x,
stride_y,
size,
padding,
maxpool_depth,
out_channels,
antialiasing,
common,
} = maxpool;
... | code_fim | hard | {
"lang": "rust",
"repo": "Xuxue1/yolo-dl",
"path": "/darknet-config/src/config/max_pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
stride_x,
stride_y,
size,
padding,
maxpool_depth,
out_channels,
antialiasing,
common,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub(super) struct Raw... | code_fim | hard | {
"lang": "rust",
"repo": "Xuxue1/yolo-dl",
"path": "/darknet-config/src/config/max_pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xuxue1/yolo-dl path: /darknet-config/src/config/max_pool.rs
use super::*;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(from = "RawMaxPool", into = "RawMaxPool")]
pub struct MaxPool {
pub stride_x: usize,
pub stride_y: usize,
pub size: usize,
pub p... | code_fim | hard | {
"lang": "rust",
"repo": "Xuxue1/yolo-dl",
"path": "/darknet-config/src/config/max_pool.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32g4xx-hal path: /src/fdcan/interrupt.rs
//! Interrupt types.
use core::ops;
#[allow(unused_imports)] // for intra-doc links only
use crate::fdcan::{FdCan, Rx};
/// FdCAN interrupt sources.
///
/// These can be individually enabled and disabled in the FdCAN peripheral. Note that e... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32g4xx-hal",
"path": "/src/fdcan/interrupt.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Interrupts {
/// No Interrupt masks selected
pub fn none() -> Self {
Self::from_bits_truncate(0)
}
}
impl From<Interrupt> for Interrupts {
#[inline]
fn from(i: Interrupt) -> Self {
Self::from_bits_truncate(i as u32)
}
}
/// Adds an interrupt to the interrupt ... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32g4xx-hal",
"path": "/src/fdcan/interrupt.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liambloom/vec2d path: /src/bin/main.rs
use vec2d::*;
fn main() {
let mut v = matrix![[1, 2, 3], [4, 5, 6]];
//*v[0] = [5, 6];
//println!("v:<|fim_suffix|>, {}], [{}, {}]]", v[0][0], v[0][1], v[1][0], v[1][1]);
}<|fim_middle|> {}, v.as_ptr(): {}", &v.v as *const )
println!("[[{} | code_fim | easy | {
"lang": "rust",
"repo": "liambloom/vec2d",
"path": "/src/bin/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {}, v.as_ptr(): {}", &v.v as *const )
println!("[[{}, {}], [{}, {}]]", v[0][0], v[0][1], v[1][0], v[1][1]);
}<|fim_prefix|>// repo: liambloom/vec2d path: /src/bin/main.rs
use vec2d::*;
fn main() {
let mut v = matrix![[1, 2,<|fim_middle|> 3], [4, 5, 6]];
//*v[0] = [5, 6];
//println!("v: | code_fim | easy | {
"lang": "rust",
"repo": "liambloom/vec2d",
"path": "/src/bin/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_data_structures/stable_map.rs
pub use rustc_hash::FxHashMap;
use std::borrow::Borrow;
use std::collections::hash_map::Entry;
use std::fmt;
use std::hash::Hash;
/// A deterministic wrapper around FxHashMap that does not provide iteration suppor... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_data_structures/stable_map.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
where
K: Borrow<Q>,
Q: Hash + Eq,
{
self.base.get_mut(k)
}
pub fn insert(&mut self, k: K, v: V) -> Option<V> {
self.base.insert(k, v)
}
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_data_structures/stable_map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> reader
.read_exact(&mut encoded_payload)
.with_context(|| "failed to read payload")?;
debug!(logger, "read payload");
let span_data: SpanData =
bincode::deserialize(&encoded_payload[..]).expect("failed to deserialise payload");
debug!(... | code_fim | hard | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/tools/trace-forwarder/src/handler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let span_data: SpanData =
bincode::deserialize(&encoded_payload[..]).expect("failed to deserialise payload");
debug!(logger, "deserialised payload");
if dump_only {
debug!(logger, "dump-only: {:?}", span_data);
} else {
let batch = vec!... | code_fim | hard | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/tools/trace-forwarder/src/handler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/tools/trace-forwarder/src/handler.rs
// Copyright (c) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
use anyhow::{anyhow, Context, Result};
use byteorder::{ByteOrder, NetworkEndian};
use futures::executor::block_on;
use opente... | code_fim | hard | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/tools/trace-forwarder/src/handler.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VedaRePowered/ctru-rs path: /ctru-rs/src/srv.rs
pub struct Srv(());
impl Srv {
pub fn init() -> ::Result<Srv> {
unsafe {
let r = ::libctru::srvInit();
if r < 0 {
Err(r.into())
} else {
Ok(Srv(()))
}
... | code_fim | easy | {
"lang": "rust",
"repo": "VedaRePowered/ctru-rs",
"path": "/ctru-rs/src/srv.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { ::libctru::srvExit() };
}
}<|fim_prefix|>// repo: VedaRePowered/ctru-rs path: /ctru-rs/src/srv.rs
pub struct Srv(());
impl Srv {
pub fn init() -> ::Result<Srv> {
unsafe {
let r = ::libctru::srvInit();
if r < 0 {
Err(r.into())
... | code_fim | easy | {
"lang": "rust",
"repo": "VedaRePowered/ctru-rs",
"path": "/ctru-rs/src/srv.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Serialize, Deserialize)]
struct Test {
#[serde(
deserialize_with = "deserialize_time",
serialize_with = "serialize_time"
)]
time: u32,
}
let data_in = "time\n01:01:01\n";
let parsed: Test = csv::Reader::from_reader(data_in.as_byt... | code_fim | hard | {
"lang": "rust",
"repo": "rust-transit/gtfs-structure",
"path": "/src/serde_helpers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-transit/gtfs-structure path: /src/serde_helpers.rs
use chrono::NaiveDate;
use rgb::RGB8;
use serde::de::{self, Deserialize, Deserializer};
use serde::ser::Serializer;
pub fn deserialize_date<'de, D>(deserializer: D) -> Result<NaiveDate, D::Error>
where
D: Deserializer<'de>,
{
let s... | code_fim | hard | {
"lang": "rust",
"repo": "rust-transit/gtfs-structure",
"path": "/src/serde_helpers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_serialize_time() {
#[derive(Serialize, Deserialize)]
struct Test {
#[serde(
deserialize_with = "deserialize_time",
serialize_with = "serialize_time"
)]
time: u32,
}
let data_in = "time\n01:01:01\n";
let parsed: Test = csv:... | code_fim | hard | {
"lang": "rust",
"repo": "rust-transit/gtfs-structure",
"path": "/src/serde_helpers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bruceherve/graph-node path: /graph/src/components/ethereum/stream.rs
use failure::Error;
use futures::Stream;
use crate::prelude::*;
<|fim_suffix|> fn build(
&self,
logger: Logger,
deployment_id: SubgraphDeploymentId,
log_filter: EthereumLogFilter,
) -> S... | code_fim | hard | {
"lang": "rust",
"repo": "bruceherve/graph-node",
"path": "/graph/src/components/ethereum/stream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
logger: Logger,
deployment_id: SubgraphDeploymentId,
log_filter: EthereumLogFilter,
) -> Self::Stream;
}<|fim_prefix|>// repo: bruceherve/graph-node path: /graph/src/components/ethereum/stream.rs
use failure::Error;
use futures::Stream;
use crate::prelude::*;
... | code_fim | medium | {
"lang": "rust",
"repo": "bruceherve/graph-node",
"path": "/graph/src/components/ethereum/stream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_order_id_from_chain(&self, key: Vec<u8>) -> Result<Option<u64>, IpseClientError> {
async_std::task::block_on(async {
let account_id = PairSigner::new(AccountKeyring::Alice.pair()).account_id();
let orders: Vec<Order<AccountId, Balance>> = self.sub_cli.orders(None... | code_fim | hard | {
"lang": "rust",
"repo": "IPSE-TEAM/ipse-client",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IPSE-TEAM/ipse-client path: /src/lib.rs
mod calls;
mod error;
use crate::error::IpseClientError;
use calls::{
AccountId, Balance, CreateOrderCallExt, DeleteCallExt, IpseRuntime as Runtime, OrdersStoreExt,
};
use futures::{future, TryFutureExt};
use http::Uri;
use ipfs_api::{IpfsClient, TryF... | code_fim | hard | {
"lang": "rust",
"repo": "IPSE-TEAM/ipse-client",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_order_id(&self, key: Vec<u8>) -> Result<Option<u64>, IpseClientError> {
if let Some(id) = self.key_to_id.get(key.as_ref()).cloned() {
Ok(Some(id))
} else {
self.get_order_id_from_chain(key)
}
}
fn get_order_id_from_chain(&self, key: Vec<u... | code_fim | hard | {
"lang": "rust",
"repo": "IPSE-TEAM/ipse-client",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ul/sound-garden-2 path: /synth-modules/src/feedback.rs
//! # Feedback
//!
//! Feedback comb filter with variable delay time and gain.
//!
//! Sources to connect: input to delay, delay time, gain.
use delay::Delay;
use sample::Sample;
<|fim_suffix|> pub fn sample(&mut self, input: Sample, del... | code_fim | hard | {
"lang": "rust",
"repo": "ul/sound-garden-2",
"path": "/synth-modules/src/feedback.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Feedback {
pub fn new(sample_rate: usize, max_delay: Sample) -> Self {
let delay = Delay::new(sample_rate, max_delay);
Feedback { delay, output: 0.0 }
}
pub fn sample(&mut self, input: Sample, delay: Sample, gain: Sample) -> Sample {
let delayed = self.delay.sampl... | code_fim | medium | {
"lang": "rust",
"repo": "ul/sound-garden-2",
"path": "/synth-modules/src/feedback.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function_over_inputs(
"Shockley model",
move |b, trace_name| {
let diode_device_type = TwoTerminalDevice::Diode;
let trace = TwoTerminalGuiTrace::from(
diode_device_type
.load_from_csv(format!("res/{}.csv", trace_name)... | code_fim | medium | {
"lang": "rust",
"repo": "Erikovsky/curve-tracer",
"path": "/benches/benchmark.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Erikovsky/curve-tracer path: /benches/benchmark.rs
#[macro_use]
extern crate criterion;
use std::time::Duration;
use criterion::black_box;
use criterion::BatchSize;
use criterion::Criterion;
use ks_curve_tracer::dut::trace::{TraceWithModel, TwoTerminalGuiTrace};
use ks_curve_tracer::dut::Devi... | code_fim | medium | {
"lang": "rust",
"repo": "Erikovsky/curve-tracer",
"path": "/benches/benchmark.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn criterion_benchmark(c: &mut Criterion) {
c.bench_function_over_inputs(
"Shockley model",
move |b, trace_name| {
let diode_device_type = TwoTerminalDevice::Diode;
let trace = TwoTerminalGuiTrace::from(
diode_device_type
.loa... | code_fim | medium | {
"lang": "rust",
"repo": "Erikovsky/curve-tracer",
"path": "/benches/benchmark.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: althonos/uniprot.rs path: /src/uniparc/model/db_reference.rs
use std::io::BufRead;
use quick_xml::events::BytesStart;
use quick_xml::Reader;
use crate::error::Error;
use crate::parser::utils::attributes_to_hashmap;
use crate::parser::utils::decode_attribute;
use crate::parser::utils::decode_op... | code_fim | medium | {
"lang": "rust",
"repo": "althonos/uniprot.rs",
"path": "/src/uniparc/model/db_reference.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let attributes = attributes_to_hashmap(event)?;
let ty = attributes
.get(&b"type"[..])
.ok_or(Error::MissingAttribute("type", "dbReference"))?
.unescape_and_decode_value(reader)?;
let id = attributes
.get(&b"id"[..])
.ok_o... | code_fim | hard | {
"lang": "rust",
"repo": "althonos/uniprot.rs",
"path": "/src/uniparc/model/db_reference.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: starblue/dust path: /dust-atsamd09/src/port.rs
use dust::gpio::port;
use volatile_register::{RO, RW, WO};
#[repr(C)]
pub struct Regs {
pub dir: RW<u32>,
pub dirclr: RW<u32>,
pub dirset: RW<u32>,
pub dirtgl: RW<u32>,
pub out: RW<u32>,
pub outclr: RW<u32>,
pub outset: ... | code_fim | hard | {
"lang": "rust",
"repo": "starblue/dust",
"path": "/dust-atsamd09/src/port.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let port = unsafe { &mut *::PORT };
assert_eq!(address(&port.dir), 0x41004400);
assert_eq!(address(&port.dirclr), 0x41004404);
assert_eq!(address(&port.dirset), 0x41004408);
assert_eq!(address(&port.dirtgl), 0x4100440c);
assert_eq!(address(&port.out), 0x410... | code_fim | hard | {
"lang": "rust",
"repo": "starblue/dust",
"path": "/dust-atsamd09/src/port.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theotherphil/spimdy path: /src/lib.rs
#![feature(test)]
extern crate test;
extern crate rand;
extern crate rayon;
extern crate packed_simd;
pub use kernel::*;
pub use vector_types::*;
use std::arch::x86_64::*;
use packed_simd::*;
//use rayon::prelude::*;
fn bool_array_from_m256i(x: __m256i) ->... | code_fim | hard | {
"lang": "rust",
"repo": "theotherphil/spimdy",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn f32_array_from_m256(x: __m256) -> [f32; 8] {
let mut a = [0.0; 8];
unsafe {
_mm256_storeu_ps(a.as_mut_ptr(), x);
}
a
}
/// Generates a debug implementation for a type that contains a single __m256i field.
/// The compiler-derived implementation treats ___m256i as four 64 bit in... | code_fim | hard | {
"lang": "rust",
"repo": "theotherphil/spimdy",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod ciphersuite;
mod codec;
pub mod config;
mod creds;
pub mod extensions;
pub mod framing;
mod group;
pub mod key_packages;
mod messages;
mod schedule;
mod tree;
/// Single place, re-exporting the most used public functions.
pub mod prelude;<|fim_prefix|>// repo: jannik4/openmls path: /src/lib.rs
//! #... | code_fim | medium | {
"lang": "rust",
"repo": "jannik4/openmls",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Single place, re-exporting the most used public functions.
pub mod prelude;<|fim_prefix|>// repo: jannik4/openmls path: /src/lib.rs
//! # OpenMLS
//!
//! ## Errors
//!
//! Each module has an `errors.rs` defining module specific errors that are used
//! within the crate. This exposes some of the
//! m... | code_fim | medium | {
"lang": "rust",
"repo": "jannik4/openmls",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jannik4/openmls path: /src/lib.rs
//! # OpenMLS
//!
//! ## Errors
//!
//! Each module has an `errors.rs` defining module specific errors that are used
//! within the crate. This exposes some of the
//! module errors that are publicly relevant.
//! All errors implement `Debug`, `Display`, `Partia... | code_fim | medium | {
"lang": "rust",
"repo": "jannik4/openmls",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yulincoder/Controller-Device path: /device-connection-rs-async/src/middleware_wrapper/redis_wrapper.rs
use std::time::SystemTime;
#[allow(unused_imports)]
use log::{
error,
info,
};
use redis::{
aio::Connection,
AsyncCommands,
cmd as redis_cmd,
RedisResult,
};
pub struc... | code_fim | hard | {
"lang": "rust",
"repo": "yulincoder/Controller-Device",
"path": "/device-connection-rs-async/src/middleware_wrapper/redis_wrapper.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// 获取hash表指定key的指定字段
pub async fn hget(&mut self, key: &str, field: &str) -> Result<String, ()> {
let cli = if let Some(conn) = &mut self.conn {
conn
} else {
error!("Redis conn in RedisConn struct is None");
return Err(());
};
... | code_fim | hard | {
"lang": "rust",
"repo": "yulincoder/Controller-Device",
"path": "/device-connection-rs-async/src/middleware_wrapper/redis_wrapper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// 设置指定key的hash表,并设置指定字段和指定值
pub async fn hset(&mut self, key: &str, field: &str, value: &str) -> Result<Option<usize>, ()> {
let cli = if let Some(conn) = &mut self.conn {
conn
} else {
error!("Redis conn in RedisConn struct is None");
return ... | code_fim | hard | {
"lang": "rust",
"repo": "yulincoder/Controller-Device",
"path": "/device-connection-rs-async/src/middleware_wrapper/redis_wrapper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>p_hal::timer::Timer3Pwm]
/// * OC1A (Timer/Counter1 output compare match A output)
/// * PCINT1 (pin change interrupt 1)
pub d9: atmega_hal::port::PB1 = pb1,
/// `D10`
///
/// * **PWM**: [atmega328p_hal::timer::Timer3Pwm]
/// * SS (SPI bus master sla... | code_fim | hard | {
"lang": "rust",
"repo": "Rahix/avr-hal",
"path": "/arduino-hal/src/port/uno.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rahix/avr-hal path: /arduino-hal/src/port/uno.rs
pub use atmega_hal::port::{mode, Pin, PinOps, PinMode};
avr_hal_generic::renamed_pins! {
type Pin = Pin;
/// Pins of the **Arduino Uno**.
///
/// This struct is best initialized via the [`arduino_hal::pins!()`][crate::pins] macro... | code_fim | hard | {
"lang": "rust",
"repo": "Rahix/avr-hal",
"path": "/arduino-hal/src/port/uno.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Krankdud/now-playing path: /src/main.rs
#![windows_subsystem = "windows"]
extern crate sdl2;
use sdl2::event::Event;
use sdl2::pixels::Color;
use serde::Deserialize;
use std::fs::File;
use std::io;
use std::io::Read;
use std::time::Duration;
mod song;
use song::SongReader;
mod text;
use text... | code_fim | hard | {
"lang": "rust",
"repo": "Krankdud/now-playing",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config = match load_config() {
Ok(config) => config,
Err(e) => {
println!("Error: {}", e);
default_config()
}
};
let ctx = sdl2::init().unwrap();
let video_ctx = ctx.video().unwrap();
let ttf_ctx = sdl2::ttf::init().expect("Failed to... | code_fim | hard | {
"lang": "rust",
"repo": "Krankdud/now-playing",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/math-and-algorithm/src/bin/087.rs
use proconio::input;
<|fim_suffix|> input! {
n: usize,
};
let modp = 1_000_000_007;
let x = (1 + n) * n / 2 % modp;
let ans = x * x % modp;
println!("{}", ans);
}<|fim_middle|>fn ... | code_fim | easy | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/math-and-algorithm/src/bin/087.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
n: usize,
};
let modp = 1_000_000_007;
let x = (1 + n) * n / 2 % modp;
let ans = x * x % modp;
println!("{}", ans);
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/math-and-algorithm/src/bin/087.rs
use proconio::input;
<|fim_middle|>fn ... | code_fim | easy | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/math-and-algorithm/src/bin/087.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: obsidian-rs/obsidian path: /examples/main.rs
mod middleware;
use middleware::logger_example::*;
use serde::*;
use std::{fmt, fmt::Display};
use obsidian::{
context::Context,
router::{header, Responder, Response, Router},
App, ObsidianError, StatusCode,
};
// Testing example
#[deri... | code_fim | hard | {
"lang": "rust",
"repo": "obsidian-rs/obsidian",
"path": "/examples/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> app.scope("admin", |router: &mut Router| {
router.get("test", |ctx: Context| async move {
ctx.build("Hello admin test").ok()
});
router.get("test2", |ctx: Context| async move {
ctx.build("Hello admin test 2").ok()
});
});
app.scope("for... | code_fim | hard | {
"lang": "rust",
"repo": "obsidian-rs/obsidian",
"path": "/examples/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stbuehler/rust-hibp-index path: /src/errors.rs
//! Error types
/// Error when parsing key types
#[derive(thiserror::Error, Debug)]
pub enum KeyTypeParseError {
/// Parsed key type is invalid (probably not ASCII printable)
#[error("Invalid key type {0:?}")]
Invalid(String),
}
/// Error when ... | code_fim | hard | {
"lang": "rust",
"repo": "stbuehler/rust-hibp-index",
"path": "/src/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Table read error
///
/// The table is the part of the index that tells us where keys with a given
/// prefix are stored.
#[derive(thiserror::Error, Debug)]
pub enum TableReadError {
/// IO read error
#[error("IO error: {0}")]
IOError(#[from] std::io::Error),
/// Invalid depth
#[error("Invalid dep... | code_fim | hard | {
"lang": "rust",
"repo": "stbuehler/rust-hibp-index",
"path": "/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JoelWaterworth/rust_game_engine path: /src/renderer/mesh/mod.rs
use ash::vk;
pub use ash::version::{V1_0, InstanceV1_0, DeviceV1_0, EntryV1_0};
use ash::util::*;
use std::ops::Drop;
use std::sync::Arc;
use std::u32;
use std::u64;
use std::ptr;
use std::mem;
use std::mem::align_of;
use std::ffi:... | code_fim | hard | {
"lang": "rust",
"repo": "JoelWaterworth/rust_game_engine",
"path": "/src/renderer/mesh/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe fn copy_buffer(device: &Arc<Device>, command_buffer: vk::CommandBuffer, source: vk::Buffer, destination: vk::Buffer, region: vk::BufferCopy) {
record_submit_commandbuffer(&device,
command_buffer,
&[vk::PIPELINE_STAGE_TOP_OF_PIPE_BI... | code_fim | hard | {
"lang": "rust",
"repo": "JoelWaterworth/rust_game_engine",
"path": "/src/renderer/mesh/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for &v in &a[k] {
x.swap(k, v);
if !visit.contains_key(&x) {
que.push_back(x.clone());
visit.insert(x.clone(), d+1);
}
x.swap(k, v);
}
}
if let Some(ans) = visit.get(&g) {
println!("{}", ans);
... | code_fim | hard | {
"lang": "rust",
"repo": "emakryo/cmpro",
"path": "/src/abc224/src/bin/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emakryo/cmpro path: /src/abc224/src/bin/d.rs
#![allow(unused_macros, unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
use proconio::marker::Usize1;
macro_rules! dbg {
($($xs:expr),+) => {
if cfg!(debug_assertions) {
std::dbg!($($xs),+)
} else... | code_fim | hard | {
"lang": "rust",
"repo": "emakryo/cmpro",
"path": "/src/abc224/src/bin/d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn use_sfi() {
let sfi = Sfi;
sfi.get();
}<|fim_prefix|>// repo: te-ori/learning-rust path: /intro_generics/src/sample_trait.rs
trait First {
fn get(&self)
u i32,
}
<|fim_middle|>struct Sfi;
impl First for Sfi {
u = 20;
fn get(&self) {
println!("self.u {}", self::u)... | code_fim | medium | {
"lang": "rust",
"repo": "te-ori/learning-rust",
"path": "/intro_generics/src/sample_trait.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("self.u {}", self::u);
}
}
pub fn use_sfi() {
let sfi = Sfi;
sfi.get();
}<|fim_prefix|>// repo: te-ori/learning-rust path: /intro_generics/src/sample_trait.rs
trait First {
fn get(&self)
u i32,
}
struct Sfi;
<|fim_middle|>impl First for Sfi {
u = 20;
fn ge... | code_fim | easy | {
"lang": "rust",
"repo": "te-ori/learning-rust",
"path": "/intro_generics/src/sample_trait.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: te-ori/learning-rust path: /intro_generics/src/sample_trait.rs
trait First {
fn get(&self)
u i32,
}
struct Sfi;
<|fim_suffix|> println!("self.u {}", self::u);
}
}
pub fn use_sfi() {
let sfi = Sfi;
sfi.get();
}<|fim_middle|>impl First for Sfi {
u = 20;
fn ge... | code_fim | easy | {
"lang": "rust",
"repo": "te-ori/learning-rust",
"path": "/intro_generics/src/sample_trait.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mod diff_mode {
use super::*;
#[test]
fn no_delimiter() {
let mut output = ColoredOuput::new();
let mut values = Values::new(&mut output, Mode::Diff, "");
write_values(&mut values);
assert_eq!(output.chunks(), &[OutputChunk::plai... | code_fim | hard | {
"lang": "rust",
"repo": "0xack13/rew",
"path": "/src/bin/rew/output.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xack13/rew path: /src/bin/rew/output.rs
use crate::utils::HasRange;
use common::color::{spec_bold_color, spec_color};
use common::output::write_error;
use common::symbols::{DIFF_IN, DIFF_OUT};
use std::error::Error;
use std::io::{Result, Write};
use std::ops::Range;
use termcolor::{Color, Write... | code_fim | hard | {
"lang": "rust",
"repo": "0xack13/rew",
"path": "/src/bin/rew/output.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn write_values(values: &mut Values<&mut ColoredOuput>) {
values.write("a", "b").unwrap();
values.write("c", "d").unwrap();
}
#[test]
fn write_pattern() {
use super::*;
use std::fmt;
#[derive(Debug)]
struct CustomError {}
impl Error... | code_fim | hard | {
"lang": "rust",
"repo": "0xack13/rew",
"path": "/src/bin/rew/output.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pmnxis/libtock-rs path: /unittest/src/kernel/mod.rs
use crate::kernel_data::{with_kernel_data, KernelData, KERNEL_DATA};
use crate::{ExpectedSyscall, SyscallLogEntry};
// TODO: Create a fake/ directory, and move this code into fake/kernel.rs.
// Create fake/syscalls/ and move the fake system ca... | code_fim | hard | {
"lang": "rust",
"repo": "pmnxis/libtock-rs",
"path": "/unittest/src/kernel/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// -----------------------------------------------------------------------------
// Crate implementation details below.
// -----------------------------------------------------------------------------
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn expected_syscall_queue() {
use li... | code_fim | hard | {
"lang": "rust",
"repo": "pmnxis/libtock-rs",
"path": "/unittest/src/kernel/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use libtock_platform::YieldNoWaitReturn::Upcall;
use std::matches;
use ExpectedSyscall::YieldNoWait;
let kernel = Kernel::new();
with_kernel_data(|kernel_data| assert!(kernel_data.unwrap().expected_syscalls.is_empty()));
kernel.add_expected_syscall(YieldNoWa... | code_fim | hard | {
"lang": "rust",
"repo": "pmnxis/libtock-rs",
"path": "/unittest/src/kernel/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> copy(
"./src/proto/google.protobuf.rs",
"./src/proto/google_protobuf.rs",
)
.unwrap();
copy(
"./src/proto/trinsic.services.rs",
"./src/proto/trinsic_services.rs",
)
.unwrap();
remove_file("./src/proto/google.protobuf.rs").unwrap();
remove_fil... | code_fim | hard | {
"lang": "rust",
"repo": "sethjback/sdk",
"path": "/cli/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sethjback/sdk path: /cli/build.rs
use std::fs::{copy, remove_file};
fn main() {
let config = tonic_build::configure()
.build_server(false)
.out_dir("./src/proto");
<|fim_suffix|> copy(
"./src/proto/google.protobuf.rs",
"./src/proto/google_protobuf.rs",
... | code_fim | hard | {
"lang": "rust",
"repo": "sethjback/sdk",
"path": "/cli/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> config
.type_attribute(
"JsonPayload",
"#[derive(::serde::Serialize, ::serde::Deserialize)]",
)
.type_attribute(
"JsonPayload.json",
"#[derive(::serde::Serialize, ::serde::Deserialize)]",
)
.compile_with_config(
... | code_fim | hard | {
"lang": "rust",
"repo": "sethjback/sdk",
"path": "/cli/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("What is your name?");
let mut myName = String::new(); // declaring a new/empty String
io::stdin().read_line(&mut myName); // putting the user input into "myName" (btw. no Error handling here)
println!("It is good to meet you, {}", myName);
println!("The length of you name is... | code_fim | medium | {
"lang": "rust",
"repo": "niilz/Automate-the-Boring-Stuff-with-Rust",
"path": "/ch_01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.