text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>// @has issue_32881/trait.Bar.html
// @has - '//code' "impl<'a> dyn Bar"
// @has - '//code' "impl<'a> Debug for dyn Bar"
pub use rustdoc_trait_object_impl::Bar;<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/rustdoc/inline_cross/issue-32881.rs
// aux-build:rustdoc-trait-object-imp... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/rustdoc/inline_cross/issue-32881.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/rustdoc/inline_cross/issue-32881.rs
// aux-build:rustdoc-trait-object-impl.rs
// build-aux-docs
// ignore-cross-compile
<|fim_suffix|>// @has issue_32881/trait.Bar.html
// @has - '//code' "impl<'a> dyn Bar"
// @has - '//code' "impl<'a> Debug for d... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/rustdoc/inline_cross/issue-32881.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erikjohnston/shaft path: /src/rest/mod.rs
//! Handles all REST endpoints
use actix_web::web::ServiceConfig;
use chrono;
use futures_cpupool::CpuPool;
use handlebars;
use handlebars::Handlebars;
use hyper_tls::HttpsConnector;
use serde::Deserialize;
use serde_json;
use std::sync::Arc;
use crat... | code_fim | hard | {
"lang": "rust",
"repo": "erikjohnston/shaft",
"path": "/src/rest/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn with_http_client(
config: AppConfig,
handlebars: Handlebars<'static>,
database: impl db::Database + 'static,
http_client: impl GenericHttpClient + 'static,
) -> AppState {
// Thread pool to use mainly for DB
let cpu_pool = CpuPool::new_num_cpu... | code_fim | hard | {
"lang": "rust",
"repo": "erikjohnston/shaft",
"path": "/src/rest/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Format pence into a pretty pounds string
fn format_pence_as_pounds(pence: i64) -> String {
if pence < 0 {
format!("-£{:2}.{:02}", -pence / 100, -pence % 100)
} else {
format!("£{:2}.{:02}", pence / 100, pence % 100)
}
}
/// Handlebars helper function for formatting pence a... | code_fim | hard | {
"lang": "rust",
"repo": "erikjohnston/shaft",
"path": "/src/rest/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alibaba/GraphScope path: /interactive_engine/executor/ir/graph_proxy/src/adapters/exp_store/partitioner.rs
//
//! Copyright 2021 Alibaba Group Holding Limited.
//!
//! Licensed under the Apache License, Version 2.0 (the "License");
//! you may not use this file except in compliance with the Lice... | code_fim | hard | {
"lang": "rust",
"repo": "alibaba/GraphScope",
"path": "/interactive_engine/executor/ir/graph_proxy/src/adapters/exp_store/partitioner.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PartitionInfo for SimplePartition {
fn get_partition_id<D: PartitionedData>(&self, data: &D) -> GraphProxyResult<PartitionId> {
Ok((data.get_partition_key_id() as usize % self.num_servers) as u32)
}
fn get_server_id(&self, partition_id: PartitionId) -> GraphProxyResult<ServerId> ... | code_fim | medium | {
"lang": "rust",
"repo": "alibaba/GraphScope",
"path": "/interactive_engine/executor/ir/graph_proxy/src/adapters/exp_store/partitioner.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnauf/hackathon_try path: /hackathon/hackathon/assignment_a/four/src/main.rs
use std::io;
fn main() {
let mut radius = String::new();
println!("Radius of a Sphere: ");
<|fim_suffix|>radius: f64 = radius.trim().parse().expect("invalid input");
let volume = 1.33333333333 * 3.142 * r... | code_fim | medium | {
"lang": "rust",
"repo": "mnauf/hackathon_try",
"path": "/hackathon/hackathon/assignment_a/four/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>radius * radius * radius;
println!("Volume of the sphere with radius {} is {:.2}",radius,volume);
}<|fim_prefix|>// repo: mnauf/hackathon_try path: /hackathon/hackathon/assignment_a/four/src/main.rs
use std::io;
fn main() {
let mut radius = String::new();
println!("Radius of a Sphere: ");
... | code_fim | hard | {
"lang": "rust",
"repo": "mnauf/hackathon_try",
"path": "/hackathon/hackathon/assignment_a/four/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bk-rs/consul-rs path: /consul-api-endpoint/consul-api-endpoint-macro/src/endpoint/query_option_names.rs
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::{
parse::{Parse, ParseStream},
Error as SynError, Ident, LitStr, Token,
};
// https://github.com/hashicorp/con... | code_fim | hard | {
"lang": "rust",
"repo": "bk-rs/consul-rs",
"path": "/consul-api-endpoint/consul-api-endpoint-macro/src/endpoint/query_option_names.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let query_option_name = if input.peek(Ident) {
input.parse::<Ident>()?
} else {
format_ident!("{}", input.parse::<LitStr>()?.value())
};
let name = match &query_option_name {
s if s == "ns" || s ... | code_fim | hard | {
"lang": "rust",
"repo": "bk-rs/consul-rs",
"path": "/consul-api-endpoint/consul-api-endpoint-macro/src/endpoint/query_option_names.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut inner = vec![];
loop {
let query_option_name = if input.peek(Ident) {
input.parse::<Ident>()?
} else {
format_ident!("{}", input.parse::<LitStr>()?.value())
};
let name = match &query_option_name {
... | code_fim | hard | {
"lang": "rust",
"repo": "bk-rs/consul-rs",
"path": "/consul-api-endpoint/consul-api-endpoint-macro/src/endpoint/query_option_names.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sformisano/reqwest-middleware path: /reqwest-retry/src/retryable.rs
use http::StatusCode;
use reqwest_middleware::Error;
/// Classification of an error/status returned by request.
#[derive(PartialEq, Eq)]
pub enum Retryable {
/// The failure was due to something tha might resolve in the fut... | code_fim | hard | {
"lang": "rust",
"repo": "sformisano/reqwest-middleware",
"path": "/reqwest-retry/src/retryable.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> || error.is_redirect()
{
Some(Retryable::Fatal)
} else {
// We omit checking if error.is_status() since we check that already.
// However, if Response::error_for_status is used ... | code_fim | hard | {
"lang": "rust",
"repo": "sformisano/reqwest-middleware",
"path": "/reqwest-retry/src/retryable.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkubasz/duck_rs path: /benches/benchmark.rs
#[macro_use]
extern crate criterion;
use criterion::{Criterion, BatchSize};
use criterion::black_box;
<|fim_suffix|>}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);<|fim_middle|>fn criterion_benchmark(c: &mut Criterion) {
| code_fim | easy | {
"lang": "rust",
"repo": "mkubasz/duck_rs",
"path": "/benches/benchmark.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn criterion_benchmark(c: &mut Criterion) {
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);<|fim_prefix|>// repo: mkubasz/duck_rs path: /benches/benchmark.rs
#[macro_use]
extern crate criterion;
<|fim_middle|>use criterion::{Criterion, BatchSize};
use criterion::black_box;
| code_fim | medium | {
"lang": "rust",
"repo": "mkubasz/duck_rs",
"path": "/benches/benchmark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = [0; PUBLIC_KEY_LENGTH];
stream.set_nonblocking(false)?;
(&mut (&*stream)).read_exact(&mut buffer)?;
stream.set_nonblocking(true)?;
let public_key = PublicKey::from_bytes(&buffer)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "martoko/kredit",
"path": "/src/networked_message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: martoko/kredit path: /src/networked_message.rs
use std::{array, io};
use std::io::{BufWriter, Read, Write};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, TcpStream};
use ed25519_dalek::*;
use crate::block;
use crate::block::Block;
#[derive(Debug, Clone)]
p... | code_fim | hard | {
"lang": "rust",
"repo": "martoko/kredit",
"path": "/src/networked_message.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = [0; 32];
stream.set_nonblocking(false)?;
(&mut (&*stream)).read_exact(&mut buffer)?;
stream.set_nonblocking(true)?;
let public_key = PublicKey::from_bytes(&buffer)?;
Ok(NetworkedMessage::Chall... | code_fim | hard | {
"lang": "rust",
"repo": "martoko/kredit",
"path": "/src/networked_message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern {
pub fn lzma_easy_encoder(stream: *mut lzma_stream, preset: u32, check: lzma_check) -> lzma_ret;
pub fn lzma_code(stream: *mut lzma_stream, action: lzma_action) -> lzma_ret;
pub fn lzma_end(stream: *mut lzma_stream);
pub fn lzma_auto_decoder(stream: *mut lzma_stream, memlimit: u64, flags: u32)... | code_fim | hard | {
"lang": "rust",
"repo": "fpgaminer/rust-lzma",
"path": "/src/lzma_sys.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fpgaminer/rust-lzma path: /src/lzma_sys.rs
use std::os::raw::c_void;
use std::mem;
#[repr(C)]
pub struct lzma_stream {
/// < Pointer to the next input byte.
pub next_in: *const u8,
/// < Number of available input bytes in next_in.
pub avail_in: usize,
/// < Total number of bytes read by l... | code_fim | hard | {
"lang": "rust",
"repo": "fpgaminer/rust-lzma",
"path": "/src/lzma_sys.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let groups = thread::spawn(|| {
let pipes = graph::build_input_graph();
let trees = graph::trees(&pipes);
println!("{:?}", trees.len());
});
traverse.join();
groups.join();
}<|fim_prefix|>// repo: bolshchikov/adventofcode-solutions path: /2017/day_12/src/main.rs
u... | code_fim | medium | {
"lang": "rust",
"repo": "bolshchikov/adventofcode-solutions",
"path": "/2017/day_12/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bolshchikov/adventofcode-solutions path: /2017/day_12/src/main.rs
use std::thread;
mod graph;
mod input;
fn main() {
<|fim_suffix|> let groups = thread::spawn(|| {
let pipes = graph::build_input_graph();
let trees = graph::trees(&pipes);
println!("{:?}", trees.len())... | code_fim | medium | {
"lang": "rust",
"repo": "bolshchikov/adventofcode-solutions",
"path": "/2017/day_12/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unnsa/rust path: /src/test/run-pass/issues/issue-39808.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// ... | code_fim | hard | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/run-pass/issues/issue-39808.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = if false {
Cow::Owned(format!("{:?}", panic!()))
} else {
Cow::Borrowed("")
};
}<|fim_prefix|>// repo: unnsa/rust path: /src/test/run-pass/issues/issue-39808.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this ... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/run-pass/issues/issue-39808.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_namespaces_clone(&self) -> Option<Vec<Self::Namespace>>;
}
pub trait NamespaceSpec {
fn get_type(&self) -> &String;
fn get_type_clone(&self) -> String;
fn get_path(&self) -> Option<&PathBuf>;
fn get_path_clone(&self) -> Option<PathBuf>;
}<|fim_prefix|>// repo: bernardolins/pla... | code_fim | hard | {
"lang": "rust",
"repo": "bernardolins/plankton",
"path": "/src/spec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bernardolins/plankton path: /src/spec.rs
use std::path::PathBuf;
pub trait Spec {
type Mount: MountSpec;
type Root: RootSpec;
type Process: ProcessSpec;
#[cfg(target_os = "linux")]
type Linux: LinuxSpec;
fn get_root(&self) -> Option<&Self::Root>;
fn get_root_clone(... | code_fim | hard | {
"lang": "rust",
"repo": "bernardolins/plankton",
"path": "/src/spec.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_env(&self) -> Option<&Vec<String>>;
fn get_env_clone(&self) -> Option<Vec<String>>;
fn get_args(&self) -> Option<&Vec<String>>;
fn get_args_clone(&self) -> Option<Vec<String>>;
}
pub trait ConsoleSizeSpec {
fn get_height(&self) -> u16;
fn get_width(&self) -> u16;
}
pub tra... | code_fim | hard | {
"lang": "rust",
"repo": "bernardolins/plankton",
"path": "/src/spec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: papamitra/AtCoder path: /sumitrust2019/d/src/main.rs
use std::collections::HashSet;
fn solve(s: &str) -> usize {
let mut n = s.len();
let s = s.chars().collect::<Vec<_>>();
let mut h1 = HashSet::new();
let mut v1 = Vec::new();
for c in s.iter().rev() {
h1.insert(c)... | code_fim | hard | {
"lang": "rust",
"repo": "papamitra/AtCoder",
"path": "/sumitrust2019/d/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ( $( $t:ty), +) => (
{
let mut line = String::new();
::std::io::stdin().read_line(&mut line).unwrap();
let mut iter = line.split_whitespace();
( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
}
);
}
#[allow(unused_macros)]
macro_... | code_fim | hard | {
"lang": "rust",
"repo": "papamitra/AtCoder",
"path": "/sumitrust2019/d/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>DCCP: field_display_e = 15;
#[doc = "< SCTP port"]
pub const BASE_PT_SCTP: field_display_e = 16;
#[doc = "< OUI resolution"]
pub const BASE_OUI: field_display_e = 17;
pub type field_display_e = u32;
#[doc = "< Field is not referenced"]
pub const HF_REF_TYPE_NONE: hf_ref_type = 0;
#[doc = "< Field is indir... | code_fim | hard | {
"lang": "rust",
"repo": "Fireball-Teeworlds/libtw2",
"path": "/wireshark-dissector/sys/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
::std::mem::size_of::<_packet_info>(),
400usize,
concat!("Size of: ", stringify!(_packet_info))
);
assert_eq!(
::std::mem::align_of::<_packet_info>(),
8usize,
concat!("Alignment of ", stringify!(_packet_info))
);
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "Fireball-Teeworlds/libtw2",
"path": "/wireshark-dissector/sys/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fireball-Teeworlds/libtw2 path: /wireshark-dissector/sys/src/lib.rs
fo>())).net_src as *const _ as usize },
136usize,
concat!(
"Offset of field: ",
stringify!(_packet_info),
"::",
stringify!(net_src)
)
);
assert_eq!(... | code_fim | hard | {
"lang": "rust",
"repo": "Fireball-Teeworlds/libtw2",
"path": "/wireshark-dissector/sys/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // comparison with a non dictionary column
let sql = "SELECT d1 FROM test WHERE d1 = d3";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+-------+",
"| d1 |",
"+-------+",
"| three |",
"+-------+",
];
assert_batche... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/core/tests/sql/select.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/core/tests/sql/select.rs
/ specific language governing permissions and limitations
// under the License.
use super::*;
use datafusion_common::ScalarValue;
use tempfile::TempDir;
#[tokio::test]
async fn query_get_indexed_field() -> Result<()> {
l... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/core/tests/sql/select.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/core/tests/sql/select.rs
_list",
DataType::List(Arc::new(Field::new("item", nested_dt.clone(), true))),
false,
)]));
let builder = PrimitiveBuilder::<Int64Type>::with_capacity(3);
let nested_lb = ListBuilder::new(builder);... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/core/tests/sql/select.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vincascm/rust-media-libs path: /rtmp/src/lib.rs
/*!
This crate contains APIs that can be used for low-level and high-level implementations
of Adobe's RTMP Protocol. Most of the code implements the
[1.0 RTMP specification](https://www.adobe.com/content/dam/acom/en/devnet/rtmp/pdf/rtmp_speci... | code_fim | hard | {
"lang": "rust",
"repo": "vincascm/rust-media-libs",
"path": "/rtmp/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>The `messages` module allows the unwrapping of inbound message payloads into proper `RtmpMessage`s,
as well as wrapping outbound messages into their payloads (to be then wrapped back into an RTMP
chunk).
## High Level APIs
Part of the RTMP protocol describes particular flows of messages back and f... | code_fim | hard | {
"lang": "rust",
"repo": "vincascm/rust-media-libs",
"path": "/rtmp/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saks/actix-web-async-await path: /src/lib.rs
#![feature(await_macro, futures_api, async_await)]
use actix_web::error::Error;
use futures::Future as Future01;
use std::future::Future;
use tokio_async_await::compat::backward::Compat;
<|fim_suffix|>macro_rules! define_compat {
($name:ident($(... | code_fim | medium | {
"lang": "rust",
"repo": "saks/actix-web-async-await",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>define_compat!(compat(arg1: Arg1));
define_compat!(compat2(arg1, arg2: Arg1, Arg2));
define_compat!(compat3(arg1, arg2, arg3: Arg1, Arg2, Arg3));
define_compat!(compat4(arg1, arg2, arg3, arg4: Arg1, Arg2, Arg3, Arg4));
define_compat!(compat5(
arg1,
arg2,
arg3,
arg4,
arg5: Arg1,
Arg... | code_fim | hard | {
"lang": "rust",
"repo": "saks/actix-web-async-await",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! define_compat {
($name:ident($($arg:ident),+: $($ty:ident),+)) => (
#[inline]
pub fn $name<F, Fut, Ret, Err, $($ty,)*>(f: F) -> impl Fn($($ty,)*) -> FutureResponse<Ret>
where
F: Fn($($ty,)*) -> Fut,
Fut: Future<Output = Result<Ret, Err>> + '... | code_fim | medium | {
"lang": "rust",
"repo": "saks/actix-web-async-await",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Trucash/Trucash path: /trucash/error.rs
use std::{error::Error, fmt};
#[derive(Debug)]
pub struct SuperError {
pub description: String,
pub place: String
}
impl Error for SuperError {
fn description(&self) -> &str {
<|fim_suffix|>impl fmt::Display for SuperError {
fn fmt(&self, f: &mut fmt... | code_fim | medium | {
"lang": "rust",
"repo": "Trucash/Trucash",
"path": "/trucash/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for SuperError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
return write!(f, "Error");
}
}<|fim_prefix|>// repo: Trucash/Trucash path: /trucash/error.rs
use std::{error::Error, fmt};
#[derive(Debug)]
pub struct SuperError {
pub description: String,
pub place: String
}... | code_fim | easy | {
"lang": "rust",
"repo": "Trucash/Trucash",
"path": "/trucash/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn cause(&self) -> Option<&Error> {
return Some(self);
}
}
impl fmt::Display for SuperError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
return write!(f, "Error");
}
}<|fim_prefix|>// repo: Trucash/Trucash path: /trucash/error.rs
use std::{error::Error, fmt};
#[derive(Debug)]
pub st... | code_fim | easy | {
"lang": "rust",
"repo": "Trucash/Trucash",
"path": "/trucash/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akashsharma95/wasmtime path: /crates/environ/src/address_map.rs
//! Data structures to provide transformation of the source
// addresses of a WebAssembly module into the native code.
use cranelift_codegen::ir;
use serde::{Deserialize, Serialize};
<|fim_suffix|>/// Function and its instructions... | code_fim | hard | {
"lang": "rust",
"repo": "akashsharma95/wasmtime",
"path": "/crates/environ/src/address_map.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Generated function body length.
pub body_len: u32,
}
/// Memory definition offset in the VMContext structure.
#[derive(Debug, Clone)]
pub enum ModuleMemoryOffset {
/// Not available.
None,
/// Offset to the defined memory.
Defined(u32),
/// Offset to the imported memory.
... | code_fim | medium | {
"lang": "rust",
"repo": "akashsharma95/wasmtime",
"path": "/crates/environ/src/address_map.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Memory definition offset in the VMContext structure.
#[derive(Debug, Clone)]
pub enum ModuleMemoryOffset {
/// Not available.
None,
/// Offset to the defined memory.
Defined(u32),
/// Offset to the imported memory.
Imported(u32),
}<|fim_prefix|>// repo: akashsharma95/wasmtime ... | code_fim | medium | {
"lang": "rust",
"repo": "akashsharma95/wasmtime",
"path": "/crates/environ/src/address_map.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pypaut/plants path: /plants/src/pattern.rs
use core::borrow::BorrowMut;
use rand::{thread_rng, Rng};
use std::cmp::Ordering::{Less, Equal, Greater};
use std::cmp::Ordering;
use std::iter::{Iterator, Rev};
use std::str::Chars;
use crate::iter_ctx::{IterCtx, LightCtx};
use crate::symbolstring::{Sy... | code_fim | hard | {
"lang": "rust",
"repo": "pypaut/plants",
"path": "/plants/src/pattern.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(!res);
}
}
impl Pattern {
pub fn new<'a>(pat : Symbol, r : SymbolString, p : f32,
left : Option<SymbolString>, right : Option<SymbolString>,
cond : Option<Box<BoolExp>>) -> Pattern {
Pattern{pattern: pat, replacement: r, p, left, right, cond}... | code_fim | hard | {
"lang": "rust",
"repo": "pypaut/plants",
"path": "/plants/src/pattern.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PillarDevelopment/TON-SDK path: /abi/abi_core/tests/compile-fail/no-empty-tuples-allowed-as-nested-type.rs
// error-pattern: the trait bound `(): ton_abi_core::types::ABISerialized` is not satisfied
<|fim_suffix|>fn main() {
let x = ABICall::<((),()), ()>::encode_function_call("foo", ((),()... | code_fim | medium | {
"lang": "rust",
"repo": "PillarDevelopment/TON-SDK",
"path": "/abi/abi_core/tests/compile-fail/no-empty-tuples-allowed-as-nested-type.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x = ABICall::<((),()), ()>::encode_function_call("foo", ((),()));
println!("{:?}", x);
}<|fim_prefix|>// repo: PillarDevelopment/TON-SDK path: /abi/abi_core/tests/compile-fail/no-empty-tuples-allowed-as-nested-type.rs
// error-pattern: the trait bound `(): ton_abi_core::types::ABISerialize... | code_fim | easy | {
"lang": "rust",
"repo": "PillarDevelopment/TON-SDK",
"path": "/abi/abi_core/tests/compile-fail/no-empty-tuples-allowed-as-nested-type.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Draw the cursor on the end if its not in the middle of the text
if retained.cursor == self.text.len() && retained.showing_cursor {
let at = at + Vector2::new(label_size.x, -font.height);
let bounds = (at, at + Vector2::new(cursor_w... | code_fim | hard | {
"lang": "rust",
"repo": "PyroFlareX/newport",
"path": "/crates/newport_imgui/src/widgets/text_edit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if builder.input().was_key_pressed(os::input::KEY_HOME) {
response = TextEditResponse::InputRecieved;
retained.cursor = 0;
if !shift_down {
retained.selection = retained.cursor;
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "PyroFlareX/newport",
"path": "/crates/newport_imgui/src/widgets/text_edit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PyroFlareX/newport path: /crates/newport_imgui/src/widgets/text_edit.rs
t,
Vector2,
};
pub struct TextEdit<'a> {
text: &'a mut String,
hint: String,
id: Id,
}
impl<'a> TextEdit<'a> {
pub fn singleline(text: &'a mut String) -> Self {
let id = (text as *mut String).... | code_fim | hard | {
"lang": "rust",
"repo": "PyroFlareX/newport",
"path": "/crates/newport_imgui/src/widgets/text_edit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pi = 3.141592;
println!("Pi is roughly {0:.3}", pi);
let name = "ruth";
println!("Ruth trimmed down to 3 characters is {0:.3}", name);
}<|fim_prefix|>// repo: gr4yha7/icarust path: /basics/src/print.rs
fn main() {
println!("hello {}!", "jamal");
println!("hello {name}!", name="tellorX");
... | code_fim | medium | {
"lang": "rust",
"repo": "gr4yha7/icarust",
"path": "/basics/src/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gr4yha7/icarust path: /basics/src/print.rs
fn main() {
println!("hello {}!", "jamal");
println!("hello {name}!", name="tellorX");
println!("hello {0} and {1}!", "peter", "paul");
println!("hello {:b}!", 30);
println!("hello {number:>width$}!", number=1, width=5);
println!("hello {num... | code_fim | medium | {
"lang": "rust",
"repo": "gr4yha7/icarust",
"path": "/basics/src/print.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/structs/struct-variant-privacy.rs
mod foo {
enum Bar {
Baz { a: isize }
}
}
<|fim_suffix|> match b {
foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private
}
}
fn main() {}<|fim_middle|>fn f(b: foo::Bar) {... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/structs/struct-variant-privacy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match b {
foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private
}
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/structs/struct-variant-privacy.rs
mod foo {
enum Bar {
Baz { a: isize }
}
}
<|fim_middle|>fn f(b: foo::Bar) {... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/structs/struct-variant-privacy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sangwon090/loco.rs path: /src/protocol/structs/chatroom.rs
/*
* Created on Wed Dec 02 2020
*
* Copyright (c) storycraft. Licensed under the MIT Licence.
*/
use serde::{Deserialize, Serialize};
use super::{chat::Chatlog, open_link::OpenLinkId, user::DisplayUserInfo};
/// LOGINLIST chatroom... | code_fim | hard | {
"lang": "rust",
"repo": "sangwon090/loco.rs",
"path": "/src/protocol/structs/chatroom.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Chatroom meta. Like chatroom profile, notice, etc.
///
/// serde does not support integer tag yet. We will switch to enum as fast as the support added.
/// Check serde#745
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatroomMeta {
/// Meta type. See ChatroomMetaType for predefined t... | code_fim | hard | {
"lang": "rust",
"repo": "sangwon090/loco.rs",
"path": "/src/protocol/structs/chatroom.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Last chat log
#[serde(rename = "lastChatLog")]
pub last_chat_log: Option<Chatlog>,
/// Push alert setting
#[serde(rename = "pushAlert")]
pub push_alert: bool,
/// Chatroom metas
#[serde(rename = "chatMetas")]
pub chat_metas: Vec<ChatroomMeta>,
/// true if Ope... | code_fim | hard | {
"lang": "rust",
"repo": "sangwon090/loco.rs",
"path": "/src/protocol/structs/chatroom.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BlockCat/CatZero path: /src/learn.rs
// use std::{hash::Hash, marker::PhantomData, rc::Rc};
// use mcts::{
// transposition_table::ApproxTable, tree_policy::AlphaGoPolicy, Evaluator, GameState,
// MCTSManager, SearchTree,
// };
// use rand::{prelude::SliceRandom, Rng};
// use crate::{A... | code_fim | hard | {
"lang": "rust",
"repo": "BlockCat/CatZero",
"path": "/src/learn.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pub struct GameResult<A>
// where
// A: AlphaGame,
// {
// histories: Vec<(A::State, Tensor<f32>)>,
// winner: Option<<A::State as GameState>::Player>,
// }
// impl<'a, A> GameResult<A>
// where
// A: AlphaGame,
// {
// pub fn new(
// winner: Option<<A::State as GameState>:... | code_fim | hard | {
"lang": "rust",
"repo": "BlockCat/CatZero",
"path": "/src/learn.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn unpack(app_m: &clap::ArgMatches, single_threaded: bool) {
if let Some(v) = app_m.values_of("unpack") {
let args: Vec<&str> = v.collect();
if single_threaded {
parser::unpack_to_folder(&args[0], &args[1]).unwrap();
} else {
parser::unpack_pipeline(&arg... | code_fim | hard | {
"lang": "rust",
"repo": "ava57r/v8unpack-rs",
"path": "/v8unpack/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(v) = app_m.values_of("pack") {
let args: Vec<&str> = v.collect();
builder::pack_from_folder(&args[0], &args[1]).unwrap();
}
}
fn build(app_m: &clap::ArgMatches, no_deflate: bool) {
if let Some(v) = app_m.values_of("build") {
let args: Vec<&str> = v.collect(... | code_fim | hard | {
"lang": "rust",
"repo": "ava57r/v8unpack-rs",
"path": "/v8unpack/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ava57r/v8unpack-rs path: /v8unpack/src/main.rs
extern crate v8unpack4rs;
use clap::{crate_authors, crate_version, App, Arg};
use std::io;
use v8unpack4rs::{builder, parser};
fn setup_logging(log_level: Option<&str>) -> Result<(), fern::InitError> {
let mut basic_config = fern::Dispatch::ne... | code_fim | hard | {
"lang": "rust",
"repo": "ava57r/v8unpack-rs",
"path": "/v8unpack/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = add_two(2, 1);
assert_eq!(result, 3);
}
}<|fim_prefix|>// repo: igncp/code-gym path: /rust/basic/tests/src/lib.rs
pub fn add_two(a: i32, b: u32) -> i32 {
a + b as i32
}
#[cfg(test)]
mod tests {
use super::*;
<|fim_middle|> #[test]
fn sums() {
| code_fim | easy | {
"lang": "rust",
"repo": "igncp/code-gym",
"path": "/rust/basic/tests/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: igncp/code-gym path: /rust/basic/tests/src/lib.rs
pub fn add_two(a: i32, b: u32) -> i32 {
a + b as i32
}
<|fim_suffix|> let result = add_two(2, 1);
assert_eq!(result, 3);
}
}<|fim_middle|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sums() {
| code_fim | medium | {
"lang": "rust",
"repo": "igncp/code-gym",
"path": "/rust/basic/tests/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvark/vange-rs path: /bin/road/game.rs
ref mut transform,
ref mut dynamo,
} => (dynamo, transform),
};
let (jump, roll, focus_point, line_buffer) = match sim_step {
SimulationStep::Intermediate => (None, 0.0, None, None),
... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/vange-rs",
"path": "/bin/road/game.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> profiling::scope!("Update");
self.stats.frame_deltas.push(delta * 1000.0);
if self.stats.frame_deltas.len() > self.ui.frame_history {
self.stats.frame_deltas.remove(0);
}
let focus_point = self
.cam
.intersect_height(self.level.... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/vange-rs",
"path": "/bin/road/game.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn reload(&mut self, device: &wgpu::Device) {
self.render.reload(device);
}
fn draw_ui(&mut self, context: &egui::Context) {
if !self.ui.enabled {
return;
}
let fd_points = egui::plot::PlotPoints::from_ys_f32(&self.stats.frame_deltas);
let ... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/vange-rs",
"path": "/bin/road/game.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thejpster/ke06z4-pac path: /src/kbi0/es.rs
#[doc = "Reader of register ES"]
pub type R = crate::R<u32, super::ES>;
#[doc = "Writer for register ES"]
pub type W = crate::W<u32, super::ES>;
#[doc = "Register ES `reset()`'s with value 0"]
impl crate::ResetValue for super::ES {
type Type = u32;
... | code_fim | hard | {
"lang": "rust",
"repo": "thejpster/ke06z4-pac",
"path": "/src/kbi0/es.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as _
}
}
#[doc = "Reader of field `KBEDG`"]
pub type KBEDG_R = crate::R<u32, KBEDG_A>;
impl KBEDG_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u32, KBEDG_A> {
use crate::Variant::*;
match self.bits {... | code_fim | hard | {
"lang": "rust",
"repo": "thejpster/ke06z4-pac",
"path": "/src/kbi0/es.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match err.downcast::<grpc::Status>() {
Ok(ref status) if status.code() == grpc::Code::InvalidArgument => {
tracing::debug!(message = "cannot recover", %status);
return Err(Unresolvable(()).into());
}
Ok(status) => tracing::debug!(... | code_fim | hard | {
"lang": "rust",
"repo": "jon-walton/linkerd2-proxy",
"path": "/linkerd/app/outbound/src/resolve.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jon-walton/linkerd2-proxy path: /linkerd/app/outbound/src/resolve.rs
use super::endpoint;
use indexmap::IndexSet;
use linkerd2_app_core::{
dns::Suffix,
dst::DstAddr,
exp_backoff::{ExponentialBackoff, ExponentialBackoffStream},
proxy::{
api_resolve::Metadata,
core:... | code_fim | hard | {
"lang": "rust",
"repo": "jon-walton/linkerd2-proxy",
"path": "/linkerd/app/outbound/src/resolve.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ust_use]
pub fn dmaen(&mut self) -> DMAEN_W<CFGR_SPEC, 0> {
DMAEN_W::new(self)
}
#[doc = "Bit 1 - Direct memory access configuration This bit is set and cleared by software to select between two DMA modes of operation and is effective only when DMAEN = 1. For more details, refer to Not... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h503/adc/cfgr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h503/adc/cfgr.rs
ble automatic injected group conversion after regular group conversion. Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no regular nor injected conversion is ongoing)."... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h503/adc/cfgr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>!= 0)
}
#[doc = "Bit 15 - Data alignment This bit is set and cleared by software to select right or left alignment. Refer to register, data alignment and offset (ADC_DR, OFFSET, OFFSET_CH, ALIGN). Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h503/adc/cfgr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Syfaro/foxbot path: /src/sites/mod.rs
let timeline =
egg_mode::tweet::user_timeline(user, false, false, token).with_page_size(200);
let (_timeline, feed) = timeline.start().await.map_err(Self::update_error)?;
let first_tweet = match feed.iter().nex... | code_fim | hard | {
"lang": "rust",
"repo": "Syfaro/foxbot",
"path": "/src/sites/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn url_supported(&self, url: &str) -> bool {
self.matcher.is_match(url)
}
fn url_id(&self, url: &str) -> Option<String> {
self.matcher
.captures(url)
.map(|captures| format!("Bluesky-{}-{}", &captures["repo"], &captures["rkey"]))
}
#[trac... | code_fim | hard | {
"lang": "rust",
"repo": "Syfaro/foxbot",
"path": "/src/sites/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Syfaro/foxbot path: /src/sites/mod.rs
submission in navigation");
if submissions.contains_key(&next_id) {
tracing::warn!("trying to visit already visited id");
break;
}
// If trying to load the root submission we were given, u... | code_fim | hard | {
"lang": "rust",
"repo": "Syfaro/foxbot",
"path": "/src/sites/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const EXAMPLE_DATA: [&'static str; 3] = ["London to Dublin = 464",
"London to Belfast = 518",
"Dublin to Belfast = 141"];
#[test]
fn examples_1() {
let map = RouteMap::build(&EXAMPLE_DATA.join("\... | code_fim | hard | {
"lang": "rust",
"repo": "cleech/adventofcode",
"path": "/src/day09/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
fn find_longest_route(&self) -> Option<usize> {
let mut data = self.cities.iter().collect::<Vec<_>>();
let permutations = permutohedron::Heap::new(&mut data);
permutations.filter_map(|p| self.get_total_route_distance(&p[..])).max()
}
}
#[cfg(test)]
mod test {
us... | code_fim | hard | {
"lang": "rust",
"repo": "cleech/adventofcode",
"path": "/src/day09/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cleech/adventofcode path: /src/day09/mod.rs
use std::cmp::{min, max};
use std::hash::{Hash, Hasher};
use std::collections::{HashSet, HashMap};
use std::ops::Add;
use std::str::FromStr;
extern crate itertools;
use self::itertools::Itertools;
extern crate permutohedron;
const DATA: &'static str... | code_fim | hard | {
"lang": "rust",
"repo": "cleech/adventofcode",
"path": "/src/day09/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if agreed > 1 {
solutions += 1;
}
}
println!("{}", solutions);
}<|fim_prefix|>// repo: mohammedSlimani/fiddling-rust path: /codeforces/team/src/main.rs
use std::io;
fn main() {
let mut problems = String::new();
io::stdin().read_line(&mut problems).expect("Err... | code_fim | medium | {
"lang": "rust",
"repo": "mohammedSlimani/fiddling-rust",
"path": "/codeforces/team/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mohammedSlimani/fiddling-rust path: /codeforces/team/src/main.rs
use std::io;
fn main() {
let mut problems = String::new();
io::stdin().read_line(&mut problems).expect("Error reading the number of problems");
let problems:u16 = problems.trim().parse().expect("Expected a positive num... | code_fim | medium | {
"lang": "rust",
"repo": "mohammedSlimani/fiddling-rust",
"path": "/codeforces/team/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "password-hash")]
#[cfg_attr(docsrs, doc(cfg(feature = "password-hash")))]
impl From<Algorithm> for Ident<'static> {
fn from(alg: Algorithm) -> Ident<'static> {
alg.ident()
}
}
#[cfg(feature = "password-hash")]
#[cfg_attr(docsrs, doc(cfg(feature = "password-hash")))]
impl<... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/password-hashes",
"path": "/balloon-hash/src/algorithm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "password-hash")]
#[cfg_attr(docsrs, doc(cfg(feature = "password-hash")))]
impl<'a> TryFrom<Ident<'a>> for Algorithm {
type Error = password_hash::Error;
fn try_from(ident: Ident<'a>) -> password_hash::Result<Algorithm> {
match ident {
Self::BALLOON_IDENT => Ok... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/password-hashes",
"path": "/balloon-hash/src/algorithm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustCrypto/password-hashes path: /balloon-hash/src/algorithm.rs
//! Balloon algorithms (e.g. Balloon, BalloonM).
use crate::{Error, Result};
use core::{
fmt::{self, Display},
str::FromStr,
};
#[cfg(feature = "password-hash")]
use password_hash::Ident;
/// Balloon primitive type: varia... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/password-hashes",
"path": "/balloon-hash/src/algorithm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn pass_enum() {
// We encode enum types as [id, [args...]].
#[allow(unused)]
#[derive(Debug, PartialEq, Serialize)]
enum Custom {
First,
Second,
}
let mut buf = [0x00; 3];
let val = Custom::Second;
val.serialize(&mut Serializer::new(&mut &mut buf... | code_fim | hard | {
"lang": "rust",
"repo": "datariot/msgpack-rust",
"path": "/rmp-serde/tests/se_macro.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Must be encoded as [].
let mut buf = vec![];
#[derive(Serialize)]
struct Struct;
let val = Struct;
val.serialize(&mut Serializer::new(&mut buf)).ok().unwrap();
assert_eq!(vec![0x90], buf);
}
#[test]
fn pass_struct_map() {
use std::io::Write;
use rmp::Marker;
... | code_fim | hard | {
"lang": "rust",
"repo": "datariot/msgpack-rust",
"path": "/rmp-serde/tests/se_macro.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: datariot/msgpack-rust path: /rmp-serde/tests/se_macro.rs
#![cfg_attr(feature = "serde_macros", feature(custom_derive, plugin))]
#![cfg_attr(feature = "serde_macros", plugin(serde_macros))]
#![cfg(feature = "serde_macros")]
extern crate serde;
extern crate rmp;
extern crate rmp_serde;
use serd... | code_fim | hard | {
"lang": "rust",
"repo": "datariot/msgpack-rust",
"path": "/rmp-serde/tests/se_macro.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let paths = if let Some(paths) = &self.paths {
PathSet::Paths(paths.clone())
} else if let Some(path_hash_prefixes) = &self.path_hash_prefixes {
PathSet::PathHashPrefixes(path_hash_prefixes.clone())
} else {
// Should warn that no paths are being... | code_fim | hard | {
"lang": "rust",
"repo": "awslabs/tough",
"path": "/tuftool/src/add_role.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awslabs/tough path: /tuftool/src/add_role.rs
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::common::load_metadata_repo;
use crate::datetime::parse_datetime;
use crate::error::{self, Result};
use crate::source::... | code_fim | hard | {
"lang": "rust",
"repo": "awslabs/tough",
"path": "/tuftool/src/add_role.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update(&mut self, bytes: &[u8]) {
self.value = self.crc.update(self.value, bytes);
}
pub const fn finalize(self) -> u16 {
finalize(self.crc.algorithm, self.value)
}
}<|fim_prefix|>// repo: mrhooray/crc-rs path: /src/crc16/nolookup.rs
use crate::crc16::{finalize, in... | code_fim | hard | {
"lang": "rust",
"repo": "mrhooray/crc-rs",
"path": "/src/crc16/nolookup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrhooray/crc-rs path: /src/crc16/nolookup.rs
use crate::crc16::{finalize, init, update_nolookup};
use crate::{Algorithm, Crc, Digest, NoTable};
impl Crc<NoTable<u16>> {
pub const fn new(algorithm: &'static Algorithm<u16>) -> Self {
Self {
algorithm,
table: ()... | code_fim | hard | {
"lang": "rust",
"repo": "mrhooray/crc-rs",
"path": "/src/crc16/nolookup.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roy-ganz/toql path: /crates/core/src/cache.rs
//! Cache to lookup static table information and SQL statements.
use crate::table_mapper_registry::TableMapperRegistry;
use std::{collections::HashSet, sync::RwLock};
<|fim_suffix|>impl Cache {
/// Creates a new `Cache` with 200 cache entries.
... | code_fim | hard | {
"lang": "rust",
"repo": "roy-ganz/toql",
"path": "/crates/core/src/cache.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Cache {
/// Creates a new `Cache` with 200 cache entries.
pub fn new() -> Self {
Cache {
registry: RwLock::new(TableMapperRegistry::default()),
registered_roots: RwLock::new(HashSet::new()),
}
}
}
impl Default for Cache {
fn default() -> Self {... | code_fim | hard | {
"lang": "rust",
"repo": "roy-ganz/toql",
"path": "/crates/core/src/cache.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let replica = Replica::new((TOPIC, 0), LEADER, vec![FOLLOWER]);
let mut leader_config = SpuConfig::default();
leader_config.log.base_dir = PathBuf::from(test_path);
leader_config.id = LEADER;
leader_config.private_endpoint = leader_addr();
let leader_gctx =... | code_fim | hard | {
"lang": "rust",
"repo": "kination/fluvio",
"path": "/src/spu/src/replication/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kination/fluvio path: /src/spu/src/replication/mod.rs
pub(crate) mod follower;
pub(crate) mod leader;
#[cfg(test)]
mod replica_test {
use std::path::PathBuf;
use std::time::Duration;
use fluvio_future::{test_async};
use fluvio_future::timer::sleep;
use flv_util::fixture::e... | code_fim | hard | {
"lang": "rust",
"repo": "kination/fluvio",
"path": "/src/spu/src/replication/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.