text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: rust-fuzz/afl.rs path: /afl/examples/hello.rs #![allow(clippy::manual_assert)] <|fim_suffix|> afl::fuzz!(|data: &[u8]| { if data.first() == Some(&b'a') { panic!("Crash!"); } }); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "rust-fuzz/afl.rs", "path": "/afl/examples/hello.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> afl::fuzz!(|data: &[u8]| { if data.first() == Some(&b'a') { panic!("Crash!"); } }); }<|fim_prefix|>// repo: rust-fuzz/afl.rs path: /afl/examples/hello.rs #![allow(clippy::manual_assert)] <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "rust-fuzz/afl.rs", "path": "/afl/examples/hello.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let thrd = std::thread::spawn(move || { assert_eq!(mtx_ref.held_by_thread(), LockHeldState::NotHeldByThread); }); thrd.join().unwrap(); assert_eq!(mtx.held_by_thread(), LockHeldState::HeldByThread); std::mem::drop(lck); assert_eq!(mtx.held_by_thread(), LockHeldState::NotHeldByThread); }<|fim_pref...
code_fim
hard
{ "lang": "rust", "repo": "lightningdevkit/rust-lightning", "path": "/lightning/src/sync/test_lockorder_checks.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightningdevkit/rust-lightning path: /lightning/src/sync/test_lockorder_checks.rs use crate::sync::debug_sync::{RwLock, Mutex}; use super::{LockHeldState, LockTestExt}; use std::sync::Arc; #[test] #[should_panic] #[cfg(not(feature = "backtrace"))] fn recursive_lock_fail() { let mutex = Mutex...
code_fim
hard
{ "lang": "rust", "repo": "lightningdevkit/rust-lightning", "path": "/lightning/src/sync/test_lockorder_checks.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc317/src/bin/e/main.rs use std::collections::VecDeque; use grid_search::around; use proconio::{input, marker::Chars}; fn main() { input! { h: usize, w: usize, a: [Chars; h], }; let mut up = vec![vec![false; w];...
code_fim
hard
{ "lang": "rust", "repo": "ia7ck/competitive-programming", "path": "/AtCoder/abc317/src/bin/e/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (mut si, mut sj) = (0, 0); let (mut gi, mut gj) = (0, 0); for i in 0..h { for j in 0..w { if a[i][j] == 'S' { si = i; sj = j; } if a[i][j] == 'G' { gi = i; gj = j; } ...
code_fim
hard
{ "lang": "rust", "repo": "ia7ck/competitive-programming", "path": "/AtCoder/abc317/src/bin/e/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: synek317/rapid path: /src/errors/option_methods.rs use std::fmt::{Display, Debug}; use failure::{Error, err_msg}; pub trait OptionMethods { type TOk; fn ok_or_error<D>(self, context: D) -> Result<Self::TOk, Error> where D: Into<Error>; fn ok_or_else_error<F, D>(self, f: F)...
code_fim
hard
{ "lang": "rust", "repo": "synek317/rapid", "path": "/src/errors/option_methods.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn ok_or_error<D>(self, context: D) -> Result<Self::TOk, Error> where D: Into<Error> { self.ok_or(context).map_err(Into::into) } fn ok_or_else_error<F, D>(self, f: F) -> Result<Self::TOk, Error> where F: FnOnce() -> D, D: Into<Error> { self.ok_o...
code_fim
hard
{ "lang": "rust", "repo": "synek317/rapid", "path": "/src/errors/option_methods.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // read the configuration file let mut content = String::new(); let _ = File::open("boards.toml") .map(|mut f| f.read_to_string(&mut content)) .expect("could not read boards.toml"); let cfg: Config = toml::from_str(&content).unwrap(); // read the boar...
code_fim
hard
{ "lang": "rust", "repo": "steffengy/cargo-board", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steffengy/cargo-board path: /src/main.rs use std::collections::BTreeMap; use std::env; use std::fs::File; use std::io::Read; use std::process::Command; extern crate serde; #[macro_use] extern crate serde_derive; extern crate toml; #[derive(Debug, Deserialize)] struct Config { soc: BTreeMap...
code_fim
hard
{ "lang": "rust", "repo": "steffengy/cargo-board", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nutanp/SafeTrace path: /enclave/safetrace/enclave/src/lib.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses ...
code_fim
hard
{ "lang": "rust", "repo": "nutanp/SafeTrace", "path": "/enclave/safetrace/enclave/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: Replace u64 with *const u8, and pass it via the ocall using *const *const u8 pub fn save_to_untrusted_memory(data: &[u8]) -> Result<u64, EnclaveError> { let mut ptr = 0u64; match unsafe { ocall_save_to_memory(&mut ptr as *mut u64, data.as_c_ptr(), data.len()) } { sgx_status_t::SG...
code_fim
hard
{ "lang": "rust", "repo": "nutanp/SafeTrace", "path": "/enclave/safetrace/enclave/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::Solution; #[test] fn test_count_components() { let test_cases = vec![ ( 5, vec![ vec![0,1], vec![1,2], vec![2,3], vec![3,4], ...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_323.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caibirdme/leetcode_rust path: /src/prob_323.rs use std::collections::HashMap; struct UnionTree { parent: HashMap<i32, i32>, } impl UnionTree { fn new(n: i32) -> Self { let mut t = HashMap::new(); for i in 0..n { t.insert(i, i); } Self{ ...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_323.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>struct Solution; #[cfg(test)] mod tests { use super::Solution; #[test] fn test_count_components() { let test_cases = vec![ ( 5, vec![ vec![0,1], vec![1,2], vec![2,3], ...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_323.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vcashorg/vcash path: /core/src/libtx/error.rs // Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org...
code_fim
hard
{ "lang": "rust", "repo": "vcashorg/vcash", "path": "/core/src/libtx/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<keychain::Error> for Error { fn from(error: keychain::Error) -> Error { Error { inner: Context::new(ErrorKind::Keychain(error)), } } } impl From<transaction::Error> for Error { fn from(error: transaction::Error) -> Error { Error { inner: Context::new(ErrorKind::Transaction(error)...
code_fim
hard
{ "lang": "rust", "repo": "vcashorg/vcash", "path": "/core/src/libtx/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Error { inner: Context::new(ErrorKind::Secp(error)), } } } impl From<keychain::Error> for Error { fn from(error: keychain::Error) -> Error { Error { inner: Context::new(ErrorKind::Keychain(error)), } } } impl From<transaction::Error> for Error { fn from(error: transaction::Error) -> Er...
code_fim
hard
{ "lang": "rust", "repo": "vcashorg/vcash", "path": "/core/src/libtx/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vcombey/fallible_collections path: /src/try_clone.rs //! this module implements try clone for primitive rust types use super::TryClone; use crate::TryReserveError; macro_rules! impl_try_clone { ($($e: ty),*) => { $(impl TryClone for $e { #[inline(always)] fn...
code_fim
hard
{ "lang": "rust", "repo": "vcombey/fallible_collections", "path": "/src/try_clone.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(match self { Some(t) => Some(t.try_clone()?), None => None, }) } } // impl<T: Copy> TryClone for T { // fn try_clone(&self) -> Result<Self, TryReserveError> // where // Self: core::marker::Sized, // { // Ok(*self) // } // }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "vcombey/fallible_collections", "path": "/src/try_clone.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gwy15/leetcode path: /src/493.翻转对.rs /* * @lc app=leetcode.cn id=493 lang=rust * * [493] 翻转对 */ struct Solution; // @lc code=start #[allow(unused)] impl Solution { fn merge_sort(nums: &mut [i32]) -> usize { let n = nums.len(); if n <= 1 { return 0; } ...
code_fim
hard
{ "lang": "rust", "repo": "gwy15/leetcode", "path": "/src/493.翻转对.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uriegel/webview-app path: /src/app.rs //! This module contains all the important structs and implementations to create, configure //! and run an application containing only a webview. use std::{any::Any, env, net::SocketAddr, path::PathBuf, sync::{Arc, Mutex}}; #[cfg(target_os = "linux")] use g...
code_fim
hard
{ "lang": "rust", "repo": "uriegel/webview-app", "path": "/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(target_os = "linux")] impl Default for AppSettings { fn default()->Self { Self { application_id: "de.uriegel.webapp".to_string(), width: 800, height: 600, window_pos_storage_path: None, title: "".to_string(), url: "...
code_fim
hard
{ "lang": "rust", "repo": "uriegel/webview-app", "path": "/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Write a XFL float to the XRPLD trace log #[inline(always)] pub fn trace_float(msg: &[u8], float: XFL) -> Result<u64> { let res = unsafe { _c::trace_float(msg.as_ptr() as u32, msg.len() as u32, float.0) }; result_u64(res) }<|fim_prefix|>// repo: otov4its/xrpl-hooks path: /src/api/trace.rs use...
code_fim
hard
{ "lang": "rust", "repo": "otov4its/xrpl-hooks", "path": "/src/api/trace.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result_u64(res) } /// Write a XFL float to the XRPLD trace log #[inline(always)] pub fn trace_float(msg: &[u8], float: XFL) -> Result<u64> { let res = unsafe { _c::trace_float(msg.as_ptr() as u32, msg.len() as u32, float.0) }; result_u64(res) }<|fim_prefix|>// repo: otov4its/xrpl-hooks path...
code_fim
hard
{ "lang": "rust", "repo": "otov4its/xrpl-hooks", "path": "/src/api/trace.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: otov4its/xrpl-hooks path: /src/api/trace.rs use super::*; /// Write the contents of a buffer to the XRPLD trace log #[inline(always)] pub fn trace(msg: &[u8], data: &[u8], data_repr: DataRepr) -> Result<u64> { let res = unsafe { _c::trace( msg.as_ptr() as u32, ...
code_fim
hard
{ "lang": "rust", "repo": "otov4its/xrpl-hooks", "path": "/src/api/trace.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self {} } } #[async_trait] impl SchedulerClient for StandaloneClient { async fn get_executors(&self) -> Result<Vec<ExecutorMeta>> { //TODO connect to registrar to get a list of executors in this cluster using // protobuf messages and client.rs to send them Err(Ball...
code_fim
hard
{ "lang": "rust", "repo": "yordan-pavlov/ballista", "path": "/rust/ballista/src/scheduler/standalone.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yordan-pavlov/ballista path: /rust/ballista/src/scheduler/standalone.rs // Copyright 2020 Andy Grove // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://w...
code_fim
medium
{ "lang": "rust", "repo": "yordan-pavlov/ballista", "path": "/rust/ballista/src/scheduler/standalone.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: untoldwind/nftracker path: /server/src/device/parse.rs use log::error; use nom::character::complete::{alphanumeric1, char, digit1, space1}; use nom::combinator::map_res; use nom::error::{ParseError, VerboseError}; use nom::multi::count; use nom::sequence::{preceded, terminated}; use nom::IResult...
code_fim
hard
{ "lang": "rust", "repo": "untoldwind/nftracker", "path": "/server/src/device/parse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_parse_line() { let input = r#"enp3s0: 505360 1457 0 0 0 0 0 141 317888 1577 0 0 0 0 0 0"#; let (remain, stats) = parse_line::<VerboseError<&str>>(input).unwrap(); assert_that(&remain).is_equal...
code_fim
hard
{ "lang": "rust", "repo": "untoldwind/nftracker", "path": "/server/src/device/parse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn connect(addr: &SocketAddr, origin: Uri) -> impl Future<Item = ChordClient, Error = ()> { TcpStream::connect(addr) .map_err(|err| error!("tcp connect failed; err={:?}", err)) .and_then(move |sock| { Connection::handshake(sock, DefaultExecutor::current()) ...
code_fim
medium
{ "lang": "rust", "repo": "caipre/chord", "path": "/src/grpc/client/mod.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caipre/chord path: /src/grpc/client/mod.rs use { chord_rpc::v1::client::Chord, http::Uri, log::{error, info}, std::net::SocketAddr, tokio::{executor::DefaultExecutor, net::TcpStream, prelude::*}, tower_grpc::BoxBody, tower_h2::client::Connection, tower_http::AddOr...
code_fim
medium
{ "lang": "rust", "repo": "caipre/chord", "path": "/src/grpc/client/mod.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dandandan/parquet2 path: /src/write/page.rs use std::io::{Seek, SeekFrom, Write}; use std::sync::Arc; use parquet_format::{PageHeader as ParquetPageHeader, PageType}; use thrift::protocol::TCompactOutputProtocol; use thrift::protocol::TOutputProtocol; use crate::error::Result; use crate::read:...
code_fim
hard
{ "lang": "rust", "repo": "Dandandan/parquet2", "path": "/src/write/page.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(PageWriteSpec { header, header_size, offset: start_pos, bytes_written: end_pos - start_pos, statistics: compressed_page.statistics().transpose()?, }) } fn assemble_page_header(compressed_page: &CompressedPage) -> ParquetPageHeader { let mut page_head...
code_fim
hard
{ "lang": "rust", "repo": "Dandandan/parquet2", "path": "/src/write/page.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn es2020() -> impl Fold { chain!( nullish_coalescing(), optional_chaining(), export_namespace_from(), ) }<|fim_prefix|>// repo: timneutkens/swc path: /crates/swc_ecma_transforms_compat/src/es2020/mod.rs pub use self::{ export_namespace_from::export_namespace_from,...
code_fim
medium
{ "lang": "rust", "repo": "timneutkens/swc", "path": "/crates/swc_ecma_transforms_compat/src/es2020/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timneutkens/swc path: /crates/swc_ecma_transforms_compat/src/es2020/mod.rs pub use self::{ export_namespace_from::export_namespace_from, nullish_coalescing::nullish_coalescing, opt_chaining::optional_chaining, }; use swc_common::chain; use swc_ecma_visit::Fold; <|fim_suffix|>pub fn es20...
code_fim
medium
{ "lang": "rust", "repo": "timneutkens/swc", "path": "/crates/swc_ecma_transforms_compat/src/es2020/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for node in body.nodes.iter() { if let Some(CtrlFlow::Return(x)) = self.exec_ast_node(node, ctxt) { ret = x; break; } } self.pop_stack(); return ret; } else { panic!("calling non-fun value"); } }, &Expr::Op2(ref a, ref op, ref b) => { let a = s...
code_fim
hard
{ "lang": "rust", "repo": "memoryleak47/constraint-lang", "path": "/src/exec/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: memoryleak47/constraint-lang path: /src/exec/expr.rs use ast::{CtrlFlow, Expr, PostOp, Op2}; use ctxt::Ctxt; use super::{ExecState, Val}; impl ExecState { pub fn exec_expr(&mut self, expr: &Expr, ctxt: &Ctxt) -> Option<Val> { match expr { &Expr::Null => Some(Val::Null), &Expr::Num(x) =...
code_fim
hard
{ "lang": "rust", "repo": "memoryleak47/constraint-lang", "path": "/src/exec/expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sinesc/spacegame path: /src/level/system/collider.rs use prelude::*; use specs; use level::component; use level::WorldState; /** * Collider system * * This system detects colliding entities with a Bounding component and applies damage. */ pub struct Collider; #[derive(SystemData)] pub stru...
code_fim
hard
{ "lang": "rust", "repo": "sinesc/spacegame", "path": "/src/level/system/collider.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if a <= b { if let Some(explodes) = data.explodes.get(entity_a) { data.world_state.spawner(&data.lazy, &data.entities, explodes.spawner, Angle(0.), Some(position_a), None, None); } } else if b <= a { if let Some(ex...
code_fim
hard
{ "lang": "rust", "repo": "sinesc/spacegame", "path": "/src/level/system/collider.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: novolei/rusty-bunny path: /src/utils/github.rs extern crate percent_encoding; use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS}; <|fim_suffix|>pub fn construct_github_url(query: &str) -> String { if query == "gh" { let github_dotcom = "https://github.com"; gith...
code_fim
medium
{ "lang": "rust", "repo": "novolei/rusty-bunny", "path": "/src/utils/github.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn construct_github_url(query: &str) -> String { if query == "gh" { let github_dotcom = "https://github.com"; github_dotcom.to_string() } else if &query[..4] == "gh @" { let encoded_query = utf8_percent_encode(&query[4..], FRAGMENT).to_string(); let github_url =...
code_fim
medium
{ "lang": "rust", "repo": "novolei/rusty-bunny", "path": "/src/utils/github.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doninialessandro/rust-snippets path: /src/types_and_variables.rs mod constants; mod core_data_types; mod operators; mod scope<|fim_suffix|>unction(); operators::function(); scope::function(); constants::function(); stack_and_heap::function() }<|fim_middle|>; mod stack_and_heap; ...
code_fim
medium
{ "lang": "rust", "repo": "doninialessandro/rust-snippets", "path": "/src/types_and_variables.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> constants::function(); stack_and_heap::function() }<|fim_prefix|>// repo: doninialessandro/rust-snippets path: /src/types_and_variables.rs mod constants; mod core_data_types; mod operators; mod scope<|fim_middle|>; mod stack_and_heap; pub fn sub() { core_data_types::function(); operator...
code_fim
medium
{ "lang": "rust", "repo": "doninialessandro/rust-snippets", "path": "/src/types_and_variables.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaidiren/learn-rust path: /leetcode/passed/841/keys-and-rooms/src/main.rs struct Solution; use std::collections::HashSet; impl Solution { pub fn can_visit_all_rooms(rooms: Vec<Vec<i32>>) -> bool { let mut keys: HashSet<i32> = HashSet::new(); keys.insert(0); fn find_a...
code_fim
hard
{ "lang": "rust", "repo": "kaidiren/learn-rust", "path": "/leetcode/passed/841/keys-and-rooms/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // let t: Vec<Vec<i32>> = vec![vec![1, 3], vec![3, 0, 1], vec![2], vec![0]]; let t: Vec<Vec<i32>> = vec![ vec![13], vec![15, 29, 15, 22], vec![5, 18, 9], vec![7], vec![27], vec![27], vec![6, 28], vec![26], vec![34], ve...
code_fim
hard
{ "lang": "rust", "repo": "kaidiren/learn-rust", "path": "/leetcode/passed/841/keys-and-rooms/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { // let t: Vec<Vec<i32>> = vec![vec![1, 3], vec![3, 0, 1], vec![2], vec![0]]; let t: Vec<Vec<i32>> = vec![ vec![13], vec![15, 29, 15, 22], vec![5, 18, 9], vec![7], vec![27], vec![27], vec![6, 28], vec![26], vec![34]...
code_fim
hard
{ "lang": "rust", "repo": "kaidiren/learn-rust", "path": "/leetcode/passed/841/keys-and-rooms/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( result, self.expected_output, "invalid output in {}", self.name ); } } #[test] fn solution_tests() { let test_cases = vec![ TestCase { name: "Example 1", ...
code_fim
hard
{ "lang": "rust", "repo": "Gelio/algorithmic-challenges", "path": "/leetcode/135-candy/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let max_neighbor_candies = neighbors.iter().map(|n| candies[*n]).max().unwrap_or(0); candies[i] = max_neighbor_candies + 1; }; (0..ratings.len()).for_each(|i| { assign_candies(i, &mut visited, &edges, &mut candies); }); candies.iter().s...
code_fim
hard
{ "lang": "rust", "repo": "Gelio/algorithmic-challenges", "path": "/leetcode/135-candy/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gelio/algorithmic-challenges path: /leetcode/135-candy/src/lib.rs use std::{cell::RefCell, collections::HashMap}; type Edges = RefCell<Vec<usize>>; impl Solution { #[allow(dead_code)] pub fn candy(ratings: Vec<i32>) -> i32 { if ratings.is_empty() { return 0; ...
code_fim
hard
{ "lang": "rust", "repo": "Gelio/algorithmic-challenges", "path": "/leetcode/135-candy/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); println!("The secret number is: {}", secret_number); println!("Please input your guess."); let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("failed to re...
code_fim
hard
{ "lang": "rust", "repo": "buddseye/study-rust", "path": "/backup-1st-edition/3-1-guessing-game/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: buddseye/study-rust path: /backup-1st-edition/3-1-guessing-game/main.rs // https://rust-lang-ja.github.io/the-rust-programming-language-ja/1.6/book/guessing-game.html // use std::io::stdin; なんてこともできる use std::io; // python でいう def が rust の fn // c++ 同様 {} でスコープを指定。行端は ; fn main() { // print...
code_fim
hard
{ "lang": "rust", "repo": "buddseye/study-rust", "path": "/backup-1st-edition/3-1-guessing-game/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Solution::contains_duplicate(vec![1, 2, 3, 4]), false); } #[test] fn test_2() { assert_eq!(Solution::contains_duplicate(vec![1, 1, 1, 3, 3, 4, 3, 2, 4, 2]), true) } }<|fim_prefix|>// repo: santosh241/Windary path: /Rust/src/0217_contains_duplicate.rs //! Given ...
code_fim
medium
{ "lang": "rust", "repo": "santosh241/Windary", "path": "/Rust/src/0217_contains_duplicate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_1() { assert_eq!(Solution::contains_duplicate(vec![1, 2, 3, 4]), false); } #[test] fn test_2() { assert_eq!(Solution::contains_duplicate(vec![1, 1, 1, 3, 3, 4, 3, 2, 4, 2]), true) } }<|fim_prefix|>// repo: santosh241/Windary path: /Rust/src/0217_co...
code_fim
hard
{ "lang": "rust", "repo": "santosh241/Windary", "path": "/Rust/src/0217_contains_duplicate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: santosh241/Windary path: /Rust/src/0217_contains_duplicate.rs //! Given an array of integers, find if the array contains any duplicates. //! //! Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. //! //! Ex...
code_fim
medium
{ "lang": "rust", "repo": "santosh241/Windary", "path": "/Rust/src/0217_contains_duplicate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/substrate path: /primitives/npos-elections/fuzzer/src/common.rs // This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file ex...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/primitives/npos-elections/fuzzer/src/common.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Generate a set of inputs suitable for fuzzing an election algorithm /// /// Given parameters governing how many candidates and voters should exist, generates a voting /// scenario suitable for fuzz-testing an election algorithm. /// /// The returned candidate list is sorted. This sorting property shou...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/primitives/npos-elections/fuzzer/src/common.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pursuit/bev path: /src/system/field.rs use super::Character; use super::GameMap; use super::Player; use super::PlayerBundle; use super::Position; use super::Render; use super::TileSpriteHandles; use bevy::{asset::LoadState, prelude::*, sprite::TextureAtlasBuilder}; use bevy_tilemap::prelude::*...
code_fim
hard
{ "lang": "rust", "repo": "pursuit/bev", "path": "/src/system/field.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for mut map in query.iter_mut() { let floor_sprite: Handle<Texture> = asset_server.get_handle("texture/tiles/generic-rpg-Slice.png"); let wall_sprite: Handle<Texture> = asset_server.get_handle("texture/tiles/generic-rpg-tile02.png"); let texture_atlas = ...
code_fim
hard
{ "lang": "rust", "repo": "pursuit/bev", "path": "/src/system/field.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tiles.push(Tile { point: (0, 0), sprite_index: wall_idx, ..Default::default() }); let dwarf_sprite: Handle<Texture> = asset_server.get_handle("texture/sprite/sensei.png"); let dwarf_sprite_index = texture_atlas.get_texture_index(&dwarf_s...
code_fim
hard
{ "lang": "rust", "repo": "pursuit/bev", "path": "/src/system/field.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xuorig/anicca path: /src/diff/extensions.rs use serde::Serialize; use std::collections::{BTreeMap, HashMap}; pub type ExtensionKeyValue = (String, serde_json::Value); #[derive(Debug, Serialize)] pub struct ExtensionsDiff { pub added: Vec<ExtensionKeyValue>, pub removed: Vec<ExtensionKe...
code_fim
hard
{ "lang": "rust", "repo": "xuorig/anicca", "path": "/src/diff/extensions.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> ExtensionsDiff { added: extensions_added, removed: extensions_removed, changed: extensions_changed, } } } #[derive(Debug, Serialize)] pub struct ExtensionDiff { from: serde_json::Value, to: serde_json::Value, } impl ExtensionDiff { pub ...
code_fim
hard
{ "lang": "rust", "repo": "xuorig/anicca", "path": "/src/diff/extensions.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>impl ExtensionDiff { pub fn has_changes(&self) -> bool { self.from != self.to } pub fn from_values(base: &serde_json::Value, head: &serde_json::Value) -> Self { Self { from: base.clone(), to: head.clone(), } } }<|fim_prefix|>// repo: xuorig/...
code_fim
hard
{ "lang": "rust", "repo": "xuorig/anicca", "path": "/src/diff/extensions.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> self.communicator_to_orchestrator.send_message( library::MessageFromRendererToOrchestrator::Halted ).ok(); } pub fn halt(&mut self) { self.halt = true; } } //revolution impl Renderer { pub fn revolution(&mut self)...
code_fim
hard
{ "lang": "rust", "repo": "metasophiea/wgpu_experiment_1", "path": "/src/renderer/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: metasophiea/wgpu_experiment_1 path: /src/renderer/mod.rs use crate::library::{ Communicator, Communique, }; pub mod library; //declaration pub struct Renderer { //loop halt: bool, tick: usize, max_tick: usize, heed_max_tick...
code_fim
hard
{ "lang": "rust", "repo": "metasophiea/wgpu_experiment_1", "path": "/src/renderer/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StoriqaTeam/payments-gateway path: /src/models/account.rs use chrono::NaiveDateTime; use validator::Validate; use models::*; use schema::accounts; #[derive(Debug, Queryable, Clone)] pub struct Account { pub id: AccountId, pub user_id: UserId, pub currency: Currency, pub accoun...
code_fim
hard
{ "lang": "rust", "repo": "StoriqaTeam/payments-gateway", "path": "/src/models/account.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for CreateAccount { fn default() -> Self { Self { id: AccountId::generate(), user_id: UserId::generate(), currency: Currency::Eth, name: String::default(), callback_url: None, daily_limit_type: None, }...
code_fim
hard
{ "lang": "rust", "repo": "StoriqaTeam/payments-gateway", "path": "/src/models/account.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// The Low-Level interpretation of PAC data #[derive(Clone)] pub struct DPac { pub header: PacHeader, pub files: PacFiles, } impl DPac { pub fn import<R: Read + Seek>(reader: &mut R) -> Result<DPac> { let header = PacHeader::import(reader)?; let files = PacFiles::import(reade...
code_fim
medium
{ "lang": "rust", "repo": "MarimeGui/pac", "path": "/src/direct/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MarimeGui/pac path: /src/direct/mod.rs //! Contains basic interpretation of a Pac file, then re-used for higher interpretations pub mod files; pub mod header; <|fim_suffix|>/// The Low-Level interpretation of PAC data #[derive(Clone)] pub struct DPac { pub header: PacHeader, pub files:...
code_fim
medium
{ "lang": "rust", "repo": "MarimeGui/pac", "path": "/src/direct/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kurtoid/ktop path: /src/meter_widget.rs use core::num; use std::{ time::{SystemTime, UNIX_EPOCH}, usize, }; use bytefmt::format; use tui::{ buffer::Buffer, layout::Rect, style::{Color, Style}, symbols::bar, text::{Span, Spans}, widgets::Widget, }; use crate::zsw...
code_fim
hard
{ "lang": "rust", "repo": "Kurtoid/ktop", "path": "/src/meter_widget.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> make_bar_with_label(percentage, width, label, String::from("")) } const LABEL_WIDTH: usize = 5; fn make_bar_with_label<'a>( percentage: f32, width: usize, label: String, inner_label_prefix: String, ) -> Spans<'a> { // case 1: bar + space + label // |---| // case 2: b...
code_fim
hard
{ "lang": "rust", "repo": "Kurtoid/ktop", "path": "/src/meter_widget.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn make_bar<'a>(percentage: f32, width: usize, label: String) -> Spans<'a> { make_bar_with_label(percentage, width, label, String::from("")) } const LABEL_WIDTH: usize = 5; fn make_bar_with_label<'a>( percentage: f32, width: usize, label: String, inner_label_prefix: String, ) -> Spans<...
code_fim
hard
{ "lang": "rust", "repo": "Kurtoid/ktop", "path": "/src/meter_widget.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risooonho/storm path: /src/render/gl/texture_handle.rs use crate::render::gl::raw::{ resource, OpenGL, PixelFormat, PixelInternalFormat, PixelType, TextureBindingTarget, TextureLoadTarget, TextureMagFilterValue, TextureMinFilterValue, TextureParameterTarget, TextureUnit, TextureWrapValue...
code_fim
hard
{ "lang": "rust", "repo": "risooonho/storm", "path": "/src/render/gl/texture_handle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_texture(&self, texture: &Image) { let width = texture.width() as i32; let height = texture.height() as i32; let slice = texture.as_slice(); self.set_raw(width, height, slice); } fn set_raw<T: Sized>(&self, width: i32, height: i32, buffer: &[T]) { ...
code_fim
hard
{ "lang": "rust", "repo": "risooonho/storm", "path": "/src/render/gl/texture_handle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// This isn't in the `.userapp` section, so it can not be accessed (read or executed) from /// unprivileged code (since its memory region isn't in the MPU config). #[inline(never)] fn call_me_to_crash() { asm::nop(); } #[repr(align(256))] struct Aligned<T>(T); /// The first half of this data will b...
code_fim
hard
{ "lang": "rust", "repo": "helium/cortex-mpu", "path": "/demo-stm32l0xx/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: helium/cortex-mpu path: /demo-stm32l0xx/src/main.rs #![feature(asm)] #![no_std] #![no_main] use core::ptr; use cortex_m::{ asm, register::{control, lr}, }; use cortex_m_rt::{entry, exception, ExceptionFrame}; use cortex_m_semihosting::hprintln; use cortex_mpu::{ cortex_m0p::{CachePo...
code_fim
hard
{ "lang": "rust", "repo": "helium/cortex-mpu", "path": "/demo-stm32l0xx/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/2170_minimum_operations.rs use std::collections::HashMap; impl Solution { pub fn minimum_operations(nums: Vec<i32>) -> i32 { if nums.len() == 1 { return 0 } let len = nums.len(); let mut even = HashMap::new()...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/2170_minimum_operations.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>, v)| (v, k)).collect(); odd.sort(); let max_even = even.last().unwrap(); let max_odd = odd.last().unwrap(); let next_even = even.get(even.len() - 2).unwrap_or(&(0, 0)).0; let next_odd = odd.get(odd.len() - 2).unwrap_or(&(0, 0)).0; if max_even.1 != max_odd.1...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/2170_minimum_operations.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: techno-tanoC/azusa path: /src/lock_copy.rs use std::borrow::Cow; use std::io::SeekFrom; use std::path::*; use std::sync::Arc; use tokio::fs::File; use tokio::io::{self, BufReader, BufWriter, AsyncSeek}; use tokio::prelude::*; use tokio::sync::Mutex; use crate::error::Result; #[derive(Debug, Cl...
code_fim
hard
{ "lang": "rust", "repo": "techno-tanoC/azusa", "path": "/src/lock_copy.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let name = LockCopy::build_name(&"hello", 0, &"jpg"); assert_eq!(name, "hello.jpg"); let name = LockCopy::build_name(&"hello", 1, &"jpg"); assert_eq!(name, "hello(1).jpg"); let name = LockCopy::build_name(&"hello", 0, &""); assert_eq!(name, "hello"); ...
code_fim
hard
{ "lang": "rust", "repo": "techno-tanoC/azusa", "path": "/src/lock_copy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dotellie/gltf path: /gltf-utils/src/lib.rs mpl AccessorItem for f32 { fn from_slice(buf: &[u8]) -> Self { LE::read_f32(buf) } } impl<T: AccessorItem> AccessorItem for [T; 2] { fn from_slice(buf: &[u8]) -> Self { assert!(buf.len() >= 2 * size_of::<T>()); [T::f...
code_fim
hard
{ "lang": "rust", "repo": "dotellie/gltf", "path": "/gltf-utils/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(buf.len() >= 2 * size_of::<T>()); [T::from_slice(buf), T::from_slice(&buf[size_of::<T>() ..])] } } impl<T: AccessorItem> AccessorItem for [T; 3] { fn from_slice(buf: &[u8]) -> Self { assert!(buf.len() >= 3 * size_of::<T>()); [T::from_slice(buf), ...
code_fim
hard
{ "lang": "rust", "repo": "dotellie/gltf", "path": "/gltf-utils/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Weights<'a> { /// Reinterpret weights as u8. Lossy if the underlying iterator yields u16 /// or f32. pub fn into_u8(self) -> weights::CastingIter<'a, weights::U8> { weights::CastingIter::new(self) } /// Reinterpret weights as u16. Lossy if the underlying iterator yi...
code_fim
hard
{ "lang": "rust", "repo": "dotellie/gltf", "path": "/gltf-utils/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sam-wright/Advent-of-Code path: /2018/day8/src/main.rs use std::fs::File; use std::io::{self, Read}; #[derive(Default, Debug)] struct Node { child_nodes: Vec<Node>, metadata_entries: Vec<i32>, num_child_nodes: i32, num_metadata: i32, } impl Node { fn new(buffer: &[i32], mut...
code_fim
hard
{ "lang": "rust", "repo": "sam-wright/Advent-of-Code", "path": "/2018/day8/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut file = File::open("input.txt")?; //let mut file = File::open("test_input.txt")?; let mut contents = String::new(); file.read_to_string(&mut contents)?; contents = contents.replace(",", ""); let collection: Vec<i32> = contents[..contents.len() - 1] .spli...
code_fim
hard
{ "lang": "rust", "repo": "sam-wright/Advent-of-Code", "path": "/2018/day8/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> io::Result<()> { let mut file = File::open("input.txt")?; //let mut file = File::open("test_input.txt")?; let mut contents = String::new(); file.read_to_string(&mut contents)?; contents = contents.replace(",", ""); let collection: Vec<i32> = contents[..content...
code_fim
hard
{ "lang": "rust", "repo": "sam-wright/Advent-of-Code", "path": "/2018/day8/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Main task of the server // // message data flow: // listener -> process_tasks(sort, hash) -> broadcast_tasks // pub fn run(&mut self) -> Result<(), Box<dyn std::error::Error>> { let address = self.address; let peers = &self.peers; let mut receivers = Vec:...
code_fim
hard
{ "lang": "rust", "repo": "guangyuz/gossip_rust", "path": "/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !state.lock().unwrap().messages.contains_key(&index) { // sorting is implicitly done with HashMap state.lock().unwrap().messages.insert(index, message.bytes); Ok((message_to_broadcast, state, index)) } else { ...
code_fim
hard
{ "lang": "rust", "repo": "guangyuz/gossip_rust", "path": "/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guangyuz/gossip_rust path: /src/server.rs use std::net::SocketAddr; use std::collections::HashMap; use std::sync::{Arc, Mutex}; use std::error::Error; use crate::message::Message; use rand::{thread_rng, Rng}; extern crate tokio; use tokio::io; use tokio::net::{TcpListener, TcpStream}; use toki...
code_fim
hard
{ "lang": "rust", "repo": "guangyuz/gossip_rust", "path": "/src/server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Enet4/dicom-rs path: /core/src/dictionary/stub.rs //! This module contains a stub dictionary. use super::{DataDictionary, DataDictionaryEntryRef}; use crate::header::Tag; /// An empty attribute dictionary. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct ...
code_fim
hard
{ "lang": "rust", "repo": "Enet4/dicom-rs", "path": "/core/src/dictionary/stub.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> None } fn by_tag(&self, _: Tag) -> Option<&DataDictionaryEntryRef<'static>> { None } } impl DataDictionary for Box<StubDataDictionary> { type Entry = DataDictionaryEntryRef<'static>; fn by_name(&self, _: &str) -> Option<&DataDictionaryEntryRef<'static>> { None...
code_fim
hard
{ "lang": "rust", "repo": "Enet4/dicom-rs", "path": "/core/src/dictionary/stub.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn enable_features(&mut self, bits: u64) -> bool { self.feature_bits = bits; true } fn read_config(&mut self, offset: usize, size: usize) -> u64 { virtio::read_config_buffer(&self.config, offset, size) } fn start(&mut self, memory: &MemoryManager, mut queues: ...
code_fim
hard
{ "lang": "rust", "repo": "msgpo/pH", "path": "/src/devices/virtio_9p/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: msgpo/pH path: /src/devices/virtio_9p/mod.rs use std::sync::{Arc,RwLock}; use std::thread; use std::path::{PathBuf, Path}; use crate::memory::{GuestRam, MemoryManager}; use crate::virtio::{self,VirtioBus,VirtioDeviceOps, VirtQueue, Result}; use crate::devices::virtio_9p::server::Server; use cr...
code_fim
hard
{ "lang": "rust", "repo": "msgpo/pH", "path": "/src/devices/virtio_9p/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn read_config(&mut self, offset: usize, size: usize) -> u64 { virtio::read_config_buffer(&self.config, offset, size) } fn start(&mut self, memory: &MemoryManager, mut queues: Vec<VirtQueue>) { let vq = queues.pop().unwrap(); let root_dir = self.root_dir.clone(); ...
code_fim
hard
{ "lang": "rust", "repo": "msgpo/pH", "path": "/src/devices/virtio_9p/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> thread::sleep(Duration::from_secs(70)); let deadline = Instant::now() + Duration::from_secs(10); let (response, sidecars) = match reactor.run(proxy.add(request, deadline, &[])).unwrap() { Response::Ok { body, sidecars, .. } => (body, sidecars), Response::Err { error, .. } => p...
code_fim
hard
{ "lang": "rust", "repo": "danburkert/kudu-rs", "path": "/krpc-tests/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match proxy.send(call).wait().unwrap_err() { Error::TimedOut => (), error => panic!("unexpected error: {}", error), } assert_eq!(0, proxy_errors(&reporter.peek())); Ok(()) })) } #[test] fn cancel() { tokio::run(lazy(|| { let (_serve...
code_fim
hard
{ "lang": "rust", "repo": "danburkert/kudu-rs", "path": "/krpc-tests/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danburkert/kudu-rs path: /krpc-tests/src/lib.rs #![cfg(test)] extern crate env_logger; extern crate futures; extern crate krpc; extern crate tacho; extern crate tokio; #[macro_use] extern crate prost_derive; mod calculator_server; use std::sync::Arc; use std::time::{Duration, Instant}; use ...
code_fim
hard
{ "lang": "rust", "repo": "danburkert/kudu-rs", "path": "/krpc-tests/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct MockDependency(pub Crate, pub Crate); impl Middleware for MockDependency { fn before(&self, req: &mut Request) -> Result<(), Box<Show + 'static>> { let MockDependency(ref a, ref b) = *self; let crate_a = ::mock_crate(req, a.clone()); let crate_b = ::mock_crate(req, ...
code_fim
hard
{ "lang": "rust", "repo": "wycats/crates.io", "path": "/src/tests/middleware.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wycats/crates.io path: /src/tests/middleware.rs use std::fmt::Show; use conduit::Request; use conduit_middleware::Middleware; use semver; use cargo_registry::db::RequestTransaction; use cargo_registry::{Crate, User, Dependency}; use cargo_registry::dependency::Kind; pub struct MockUser(pub Us...
code_fim
medium
{ "lang": "rust", "repo": "wycats/crates.io", "path": "/src/tests/middleware.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let MockUser(ref u) = *self; ::mock_user(req, u.clone()); Ok(()) } } pub struct MockCrate(pub Crate); impl Middleware for MockCrate { fn before(&self, req: &mut Request) -> Result<(), Box<Show + 'static>> { let MockCrate(ref p) = *self; ::mock_crate(req, p...
code_fim
medium
{ "lang": "rust", "repo": "wycats/crates.io", "path": "/src/tests/middleware.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }