text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: tiagodeliberali/logstreamer path: /src/lib.rs
mod communication;
mod core;
mod endpoint;
mod storage;
pub use crate::co<|fim_suffix|>ate::core::{Content, OffsetValue, TopicAddress};
pub use crate::endpoint::{Broker, Client, Controller};
pub use crate::storage::{Cluster, Partition};<|fim_middle|... | code_fim | medium | {
"lang": "rust",
"repo": "tiagodeliberali/logstreamer",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn fft_real_forward_f64() {
fft_real_forward::<f64>();
}
// assumes complex FFT is okay
fn fft_real_backward<T: Num>() {
for size_ref in &[1, 2, 3, 4, 5, 6, 7, 8, 16, 32, 40, 49, 64, 128] {
let size = *size_ref;
// real FFT
let setup1: Setup<T> = Setup::new(&Optio... | code_fim | hard | {
"lang": "rust",
"repo": "yvt/yfft-rs",
"path": "/tests/realfft.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yvt/yfft-rs path: /tests/realfft.rs
extern crate num_complex;
extern crate num_traits;
extern crate yfft;
use num_traits::One;
use yfft::*;
// TODO: test all kernels --- currently, only the kernels for the highest possible ISA are tested
fn assert_num_slice_approx_eq<T: yfft::Num>(got: &[T],... | code_fim | hard | {
"lang": "rust",
"repo": "yvt/yfft-rs",
"path": "/tests/realfft.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Write out previous locus
if let Some(del) = del_iter.next_if(|d| d.start <= vr1.x) {
let s = vc.del_output(del);
writeln!(
vwrt,
"{}\t{... | code_fim | hard | {
"lang": "rust",
"repo": "heathsc/baldur",
"path": "/src/process.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let no_change =
vr2.alleles.len() == n_orig_alleles && vr1.alleles.len() == n_orig_alleles;
// See if deletion allele from allele 2 still present in retained joint allele
if vr2.alleles.len() == 1
... | code_fim | hard | {
"lang": "rust",
"repo": "heathsc/baldur",
"path": "/src/process.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heathsc/baldur path: /src/process.rs
use std::{
collections::HashSet,
fs::File,
io::{BufWriter, Write},
};
use log::Level::Trace;
use r_htslib::*;
use crate::{
alleles::*,
cli::Config,
context::*,
deletions::*,
depth::*,
fisher::FisherTest,
freq::{estim... | code_fim | hard | {
"lang": "rust",
"repo": "heathsc/baldur",
"path": "/src/process.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Subst(addr, re, pat, flags) => {
let (start, end) = addr
.resolve_range(&interp.buffer)
.ok_or(InvocationError::AddressNonResolvable)?;
let flags = flags.unwrap_or_else(|| {
if re.is_none() && pat.is_n... | code_fim | hard | {
"lang": "rust",
"repo": "eulegang/er-rusted",
"path": "/src/ed/cmd/action.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let markmod = MarkMod::After {
start: line,
delta: (interp.env.cut.len() as i64),
};
Ok((true, markmod))
}
Write(addr, syncer, quit) => {
let (start, end) = addr
... | code_fim | hard | {
"lang": "rust",
"repo": "eulegang/er-rusted",
"path": "/src/ed/cmd/action.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eulegang/er-rusted path: /src/ed/cmd/action.rs
= it.next() {
while let Some(line) = it.next() {
insert.push(' ');
insert.push_str(line.trim_start());
}
interp.buffer.insert(start, vec![i... | code_fim | hard | {
"lang": "rust",
"repo": "eulegang/er-rusted",
"path": "/src/ed/cmd/action.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
load_owner(deps.as_ref().storage, name_fixture(1).owner).unwrap(),
vec![],
);
save(deps.as_mut().storage, &name_fixture(1)).unwrap();
assert_eq!(
load_owner(deps.as_ref().storage, name_fixture(1).owner).unwrap(),
v... | code_fim | hard | {
"lang": "rust",
"repo": "nymtech/nym",
"path": "/contracts/name-service/src/state/names.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nymtech/nym path: /contracts/name-service/src/state/names.rs
_id(store: &dyn Storage, name_id: NameId) -> bool {
names().has(store, name_id)
}
pub fn has_name(store: &dyn Storage, name: &NymName) -> bool {
load_name(store, name).is_ok()
}
pub fn load_id(store: &dyn Storage, name_id: Na... | code_fim | hard | {
"lang": "rust",
"repo": "nymtech/nym",
"path": "/contracts/name-service/src/state/names.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
load_address(deps.as_ref().storage, &name_fixture(1).name.address).unwrap(),
vec![],
);
save(deps.as_mut().storage, &name_fixture(1)).unwrap();
assert_eq!(
load_address(deps.as_ref().storage, &name_fixture(1).name.address).unw... | code_fim | hard | {
"lang": "rust",
"repo": "nymtech/nym",
"path": "/contracts/name-service/src/state/names.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: georust/geo path: /geo-bool-ops-benches/src/tests.rs
use anyhow::{bail, Context, Result};
use geo::prelude::*;
use geo_booleanop::boolean::BooleanOp as OtherBOp;
use geo_types::*;
use geojson::{Feature, GeoJson};
use glob::glob;
use log::{error, info};
use serde_derive::Serialize;
use std::{
... | code_fim | hard | {
"lang": "rust",
"repo": "georust/geo",
"path": "/geo-bool-ops-benches/src/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> e.downcast::<String>().map(|b| *b).unwrap_or_else(|e| {
e.downcast::<&str>()
.map(|b| b.to_string())
.unwrap_or_else(|e| resume_unwind(e))
})
}
fn try_run_fixture(fix: &Path) -> Result<Vec<TestCase>> {
let data = read_to_string(f... | code_fim | hard | {
"lang": "rust",
"repo": "georust/geo",
"path": "/geo-bool-ops-benches/src/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let prev_p1 = convert_mpoly(&p1);
let prev_p2 = convert_mpoly(&p2);
info!("p1: {wkt}", wkt = p1.to_wkt());
info!("p2: {wkt}", wkt = p2.to_wkt());
fc.features
.into_iter()
.skip(2)
.map(|feat| -> Re... | code_fim | hard | {
"lang": "rust",
"repo": "georust/geo",
"path": "/geo-bool-ops-benches/src/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn write_map_args_type_hint<Input, Output, MapFn, Args>(_: &MapFn, args: Args) -> Args
where
MapFn: FnOnce(Input) -> Output,
Output: crate::BinWrite<Args = Args>,
{
args
}
pub fn write_try_map_args_type_hint<Input, Output, MapFn, Args>(_: &MapFn, args: Args) -> Args
where
MapFn: FnOnc... | code_fim | hard | {
"lang": "rust",
"repo": "ShabbirHasan1/binrw",
"path": "/binrw/src/private.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShabbirHasan1/binrw path: /binrw/src/private.rs
use crate::{
error::CustomError,
io::{self, Seek, Write},
BinRead, BinResult, Error, ReadOptions, WriteOptions,
};
#[cfg(not(feature = "std"))]
use alloc::{boxed::Box, string::String};
pub enum AssertErrorFn<M, E> {
Message(M),
... | code_fim | hard | {
"lang": "rust",
"repo": "ShabbirHasan1/binrw",
"path": "/binrw/src/private.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: feather-rs/feather path: /feather/protocol/src/codec.rs
use crate::{io::VarInt, ProtocolVersion, Readable, Writeable};
use aes::Aes128;
use bytes::BytesMut;
use cfb8::{
cipher::{AsyncStreamCipher, NewCipher},
Cfb8,
};
use flate2::{
bufread::{ZlibDecoder, ZlibEncoder},
Compression... | code_fim | hard | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/protocol/src/codec.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Writes a packet into the provided writer.
pub fn encode(&mut self, packet: &impl Writeable, output: &mut Vec<u8>) -> anyhow::Result<()> {
packet.write(&mut self.staging_buf, ProtocolVersion::V1_16_2)?;
if let Some(threshold) = self.compression {
self.encode_compres... | code_fim | hard | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/protocol/src/codec.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emerentius/ProjectEuler path: /p461_almost_pi/src/main.rs
extern crate ord_subset;
use ord_subset::OrdVar;
use std::f64::consts::PI;
const N: f64 = 10_000.0;
fn f(k: u32) -> f64 { (k as f64/N).exp() - 1.0 }
<|fim_suffix|> // k1^2+k2^2 and f1+f2 for any combination of k1, k2, f1, f2: f1 + f2... | code_fim | medium | {
"lang": "rust",
"repo": "Emerentius/ProjectEuler",
"path": "/p461_almost_pi/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (k1, f1) in (0..).map(|k| (k, f(k)))
.take_while(|&(_,f1)| f1 < PI)
{
for (k2, f2) in (k1..).map(|k| (k, f(k)))
.take_while(|&(_, f2)| f1 + f2 < PI)
{
f_sums.push( (f1+f2, k1*k1 + k2*k2) );
}
}
f_sums.sort_by(|&(f1, _), &(f2, _)|... | code_fim | medium | {
"lang": "rust",
"repo": "Emerentius/ProjectEuler",
"path": "/p461_almost_pi/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> f_sums.sort_by(|&(f1, _), &(f2, _)| f1.partial_cmp(&f2).unwrap());
let mut min_err = std::f64::INFINITY;
let mut k_sq_sum = 0;
for &(f12_sum, k12_sq_sum) in f_sums.iter() {
let idx = f_sums.binary_search_by(|&(f_sum, _)| {
f_sum.partial_cmp(&(PI-f12_sum)).unwrap()... | code_fim | hard | {
"lang": "rust",
"repo": "Emerentius/ProjectEuler",
"path": "/p461_almost_pi/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn subpackage(
dir: &TempDir,
name: &str,
with: Vec<(&str, &str)>,
without: Vec<&str>,
) -> PathBuf {
let (package, _dir) = package(with, without);
let package = package.unwrap();
let archive = {
let path = dir.path().join("kcps");
fs::create_dir(&path).unwrap();
pac... | code_fim | hard | {
"lang": "rust",
"repo": "CertainLach/kct",
"path": "/crates/kct_package/tests/package_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (package, _dir) = package(
vec![(
"templates/main.jsonnet",
"function(values = null, files = null) { values: values }",
)],
vec![],
);
let package = package.unwrap();
let rendered = package.compile(None, None).unwrap_err();
match rendered {
Error::RenderIssue... | code_fim | hard | {
"lang": "rust",
"repo": "CertainLach/kct",
"path": "/crates/kct_package/tests/package_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CertainLach/kct path: /crates/kct_package/tests/package_test.rs
mod fixtures;
mod helpers;
use fixtures::Fixture;
use kct_helper::json;
use kct_package::{error::Error, Package, Release};
use serde_json::{Map, Value};
use std::fs;
use std::path::PathBuf;
use tempfile::TempDir;
fn package(with: ... | code_fim | hard | {
"lang": "rust",
"repo": "CertainLach/kct",
"path": "/crates/kct_package/tests/package_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// STREAM as instantiated with a 31-bit little endian counter and 1-bit
/// "last block" flag stored as the most significant bit of the counter
/// when interpreted as a 32-bit integer.
///
/// The 31-bit + 1-bit value is stored as the last 4 bytes of the AEAD nonce.
pub struct StreamLE31<A>
where
A:... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/traits",
"path": "/aead/src/stream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustCrypto/traits path: /aead/src/stream.rs
tioned paper.
//!
//! ## Diagram
//!
//! 
//!
//! Legend:
//!
//! - 𝐄k: AEAD encryption under key `k`
//! - 𝐌: message
//! - 𝐍: nonce
//! - 𝐀... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/traits",
"path": "/aead/src/stream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn deser_structure_int_array_options(
decoder: &mut smithy_xml::decode::ScopedDecoder,
) -> Result<crate::model::IntArrayOptions, smithy_xml::decode::XmlError> {
#[allow(unused_mut)]
let mut builder = crate::model::IntArrayOptions::builder();
while let Some(mut tag) = decoder.next_tag(... | code_fim | hard | {
"lang": "rust",
"repo": "JesseWright/aws-sdk-rust",
"path": "/sdk/cloudsearch/src/xml_deser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn deser_structure_double_array_options(
decoder: &mut smithy_xml::decode::ScopedDecoder,
) -> Result<crate::model::DoubleArrayOptions, smithy_xml::decode::XmlError> {
#[allow(unused_mut)]
let mut builder = crate::model::DoubleArrayOptions::builder();
while let Some(mut tag) = decoder.... | code_fim | hard | {
"lang": "rust",
"repo": "JesseWright/aws-sdk-rust",
"path": "/sdk/cloudsearch/src/xml_deser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JesseWright/aws-sdk-rust path: /sdk/cloudsearch/src/xml_deser.rs
ub fn parse_http_generic_error(
response: &http::Response<bytes::Bytes>,
) -> Result<smithy_types::Error, smithy_xml::decode::XmlError> {
crate::rest_xml_wrapped_errors::parse_generic_error(response.body().as_ref())
}
#[al... | code_fim | hard | {
"lang": "rust",
"repo": "JesseWright/aws-sdk-rust",
"path": "/sdk/cloudsearch/src/xml_deser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pauan/rust-signals path: /src/lib.rs
le` could do, it wouldn't be very useful,
/// because `RwLock` already exists!
///
/// The major difference between `Mutable` and `RwLock` is that it is possible
/// to be efficiently notified whenever the `Mutable` changes:
///
/// ```rust
/// # use futures_... | code_fim | hard | {
"lang": "rust",
"repo": "Pauan/rust-signals",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> },
/// VecDiff::Pop {} => {
/// // ...
/// },
/// VecDiff::Clear {} => {
/// // ...
/// },
/// }
///
/// async {}
/// });
/// ```
///
/// Just like `SignalExt::for_each`, the `SignalVecExt::for_each` method returns
/// a `Future`.
///
... | code_fim | hard | {
"lang": "rust",
"repo": "Pauan/rust-signals",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pauan/rust-signals path: /src/lib.rs
ncelableFuture};
/// # Tutorial
///
/// This tutorial is long, but it's intended to explain everything you need to
/// know in order to use Signals.
///
/// It is highly recommended to read through all of it.
///
/// ## `Mutable`
///
/// Before I can fully ... | code_fim | hard | {
"lang": "rust",
"repo": "Pauan/rust-signals",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rodrigocfd/winsafe path: /src/ole/aliases.rs
use crate::co;
/// A [`Result` alias](crate#errors-and-result-aliases) for COM error codes,
/// which returns an [`HRESULT`](crate::co::HRESULT) on failure.
///
/// # Examples
///
/// Converting into <|fim_suffix|>lt: w::AnyResult<()> = hr_res... | code_fim | hard | {
"lang": "rust",
"repo": "rodrigocfd/winsafe",
"path": "/src/ole/aliases.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>et win_result: w::SysResult<()> = Err(co::ERROR::FILE_NOT_FOUND);
///
/// let hr_result: w::HrResult<()> = win_result.map_err(|err| err.to_hresult());
/// ```
pub type HrResult<T> = Result<T, co::HRESULT>;<|fim_prefix|>// repo: rodrigocfd/winsafe path: /src/ole/aliases.rs
use crate::co;
/// A [`Re... | code_fim | hard | {
"lang": "rust",
"repo": "rodrigocfd/winsafe",
"path": "/src/ole/aliases.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitrandir77/AdventOfCode2020 path: /src/03_toboggan_trajectory.rs
use std::io::{self, BufRead};
fn check_slope(lines: &[String], right: usize, down: usize) -> i64 {
let mut x = 0; // current tobogan position
let mut tree_count = 0;
for (line_no, line) in lines.iter().skip(down).enum... | code_fim | medium | {
"lang": "rust",
"repo": "mitrandir77/AdventOfCode2020",
"path": "/src/03_toboggan_trajectory.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lines: Vec<_> = stdin.lock().lines().map(|x| x.unwrap()).collect();
println!(
"{}",
check_slope(&lines, 1, 1)
* check_slope(&lines, 3, 1)
* check_slope(&lines, 5, 1)
* check_slope(&lines, 7, 1)
* check_slope(&lines, 1, 2)
);
}... | code_fim | medium | {
"lang": "rust",
"repo": "mitrandir77/AdventOfCode2020",
"path": "/src/03_toboggan_trajectory.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stdin = io::stdin();
let lines: Vec<_> = stdin.lock().lines().map(|x| x.unwrap()).collect();
println!(
"{}",
check_slope(&lines, 1, 1)
* check_slope(&lines, 3, 1)
* check_slope(&lines, 5, 1)
* check_slope(&lines, 7, 1)
* chec... | code_fim | medium | {
"lang": "rust",
"repo": "mitrandir77/AdventOfCode2020",
"path": "/src/03_toboggan_trajectory.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc312/src/bin/a/main.rs
use proconio::input;
fn main() {
<|fim_suffix|> let words = ["ACE", "BDF", "CEG", "DFA", "EGB", "FAC", "GBD"];
if words.contains(&s.as_str()) {
println!("Yes");
} else {
println!("No");
}
}<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/abc312/src/bin/a/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let words = ["ACE", "BDF", "CEG", "DFA", "EGB", "FAC", "GBD"];
if words.contains(&s.as_str()) {
println!("Yes");
} else {
println!("No");
}
}<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc312/src/bin/a/main.rs
use proconio::input;
fn main() {
<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/abc312/src/bin/a/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> static IKEV2_INIT_REQ: &[u8] = include_bytes!("../assets/ike-sa-init-req.bin");
#[test]
fn test_ipsec_ike_message() {
let bytes = IKEV2_INIT_REQ;
let expected_header = IkeV2Header {
init_spi: 0x54c184961bc3fd77,
resp_spi: 0x0,
next_payload: ... | code_fim | hard | {
"lang": "rust",
"repo": "rusticata/ipsec-parser",
"path": "/tests/ikev2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rusticata/ipsec-parser path: /tests/ikev2.rs
extern crate ipsec_parser;
extern crate nom;
mod ikev2 {
use ipsec_parser::*;
#[rustfmt::skip]
static IKEV2_MSG: &[u8] = &[
0x00, 0x00, 0x00, 0x00, 0xbc, 0xa1, 0x93, 0x7a, 0x7c, 0x2f, 0xf5, 0xb9, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,... | code_fim | hard | {
"lang": "rust",
"repo": "rusticata/ipsec-parser",
"path": "/tests/ikev2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut mtud = default_mtud();
assert!(!mtud.black_hole_detected(Instant::now()));
assert_eq!(mtud.black_hole_detector.suspicious_loss_bursts, 0);
}
#[test]
fn mtu_discovery_disabled_does_nothing() {
let mut mtud = MtuDiscovery::disabled(1_200, 1_200);
... | code_fim | hard | {
"lang": "rust",
"repo": "quinn-rs/quinn",
"path": "/quinn-proto/src/connection/mtud.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quinn-rs/quinn path: /quinn-proto/src/connection/mtud.rs
st_probed_mtu) >= BINARY_SEARCH_MINIMUM_CHANGE
{
return Some(self.upper_bound);
}
return None;
}
Some(next_mtu as u16)
}
}
#[derive(Clone)]
struct BlackHoleDetector... | code_fim | hard | {
"lang": "rust",
"repo": "quinn-rs/quinn",
"path": "/quinn-proto/src/connection/mtud.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quinn-rs/quinn path: /quinn-proto/src/connection/mtud.rs
disabled(plpmtu: u16, min_mtu: u16) -> Self {
Self::with_state(plpmtu, min_mtu, None)
}
fn with_state(current_mtu: u16, min_mtu: u16, state: Option<EnabledMtuDiscovery>) -> Self {
Self {
current_mtu,
... | code_fim | hard | {
"lang": "rust",
"repo": "quinn-rs/quinn",
"path": "/quinn-proto/src/connection/mtud.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gokzrlp/Sushumna path: /consensus/txpool/main.rs
// sushumna
// Copyright 2016-2017 Cryptape Technologies LLC.
// This program is free software: you can redistribute it
// and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation,
// eith... | code_fim | hard | {
"lang": "rust",
"repo": "gokzrlp/Sushumna",
"path": "/consensus/txpool/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::sync::mpsc::channel;
use std::thread;
use threadpool::ThreadPool;
const THREAD_POOL_NUMBER: usize = 2;
fn main() {
dotenv::dotenv().ok();
// Always print backtrace on panic.
::std::env::set_var("RUST_BACKTRACE", "1");
sushumna_log::format(LogLevelFilter::Info);
info!("sushum... | code_fim | hard | {
"lang": "rust",
"repo": "gokzrlp/Sushumna",
"path": "/consensus/txpool/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
fn evaluate(&self, s: &SurfaceInteraction) -> T2 {
self.tex1.evaluate(s) * self.tex2.evaluate(s)
}
}
pub fn create_scale_float(
_t2w: &Transform, tp: &mut TextureParams) -> Option<Arc<TextureFloat>> {
let s = ScaleTexture::new(
tp.get_floattexture("tex1", 1.0),
t... | code_fim | hard | {
"lang": "rust",
"repo": "alexmeli100/pbrt-rust",
"path": "/src/textures/scaled.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexmeli100/pbrt-rust path: /src/textures/scaled.rs
use std::sync::Arc;
use crate::core::texture::{Textures, Texture, TextureFloat, TextureSpec, SpectrumT};
use crate::core::interaction::SurfaceInteraction;
use crate::core::transform::Transform;
use crate::core::paramset::TextureParams;
use crat... | code_fim | hard | {
"lang": "rust",
"repo": "alexmeli100/pbrt-rust",
"path": "/src/textures/scaled.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut doc = Document::new(renderer);
let end = timestamp_ms();
doc.trigger_test();
println!("{} ", end - start);
}<|fim_prefix|>// repo: taochunyu/editor_lib path: /document/src/main.rs
use std::rc::Rc;
use renderer::Renderer;
use renderer::host::debug_host::DebugHost;
use editor::vie... | code_fim | hard | {
"lang": "rust",
"repo": "taochunyu/editor_lib",
"path": "/document/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: taochunyu/editor_lib path: /document/src/main.rs
use std::rc::Rc;
use renderer::Renderer;
use renderer::host::debug_host::DebugHost;
use editor::view::View;
use document::Document;
use std::time::{SystemTime, UNIX_EPOCH};
use editor::node::Node;
fn timestamp_ms() -> i64 {
<|fim_suffix|> let ... | code_fim | hard | {
"lang": "rust",
"repo": "taochunyu/editor_lib",
"path": "/document/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if sysinfo::System::IS_SUPPORTED {
let s = sysinfo::System::new();
assert_eq!(s.networks().iter().count(), 0);
let s = sysinfo::System::new_all();
assert!(s.networks().iter().count() > 0);
}
}<|fim_prefix|>// repo: GuillaumeGomez/sysinfo path: /tests/network.rs
// ... | code_fim | medium | {
"lang": "rust",
"repo": "GuillaumeGomez/sysinfo",
"path": "/tests/network.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuillaumeGomez/sysinfo path: /tests/network.rs
// Take a look at the license at the top of the repository in the LICENSE file.
// This test is used to ensure that the networks are not loaded by default.
<|fim_suffix|> if sysinfo::System::IS_SUPPORTED {
let s = sysinfo::System::new()... | code_fim | medium | {
"lang": "rust",
"repo": "GuillaumeGomez/sysinfo",
"path": "/tests/network.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub(crate) fn fetch_sub(&self, amount: usize) {
let count = self.counter.fetch_sub(amount, Ordering::AcqRel);
if count - amount == 0 {
self.event.set();
} else if self.event.is_set() {
self.event.reset();
}
}
/// This metho... | code_fim | hard | {
"lang": "rust",
"repo": "lilymara-onesignal/raii-counter",
"path": "/src/internal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lilymara-onesignal/raii-counter path: /src/internal.rs
use futures_intrusive::sync::ManualResetEvent;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
#[derive(Debug, Clone)]
pub(crate) struct Counter {
counter: Arc<AtomicUsize>,
event: Arc<ManualResetEvent>,
}
<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "lilymara-onesignal/raii-counter",
"path": "/src/internal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn account_resource(&self) -> ChannelAccountResource {
let access_path = AccessPath::new_for_data_path(
self.account.address,
DataPath::channel_account_path(self.participant.address),
);
self.get_channel_account_resource(&access_path)
}
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/stargate",
"path": "/sgtypes/src/channel.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jolestar/stargate path: /sgtypes/src/channel.rs
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
channel_transaction::{ChannelOp, ChannelTransactionRequestAndOutput},
sg_error::SgError,
};
use atomic_refcell::AtomicRefCell;
use crypto::... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/stargate",
"path": "/sgtypes/src/channel.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicholastmosher/atsam4s16b-rs path: /src/spi/mr/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::MR {
#[doc = r" Modifies the contents of the register"]
#[inline]
p... | code_fim | hard | {
"lang": "rust",
"repo": "nicholastmosher/atsam4s16b-rs",
"path": "/src/spi/mr/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PacktPublishing/Rust-Standard-Library-Cookbook path: /Chapter01/src/bin/constructor.rs
fn main() {
// We don't need to care about
// the internal structure of NameLength
// Instead, we can just call it's constructor
let name_length = NameLength::new("John");
<|fim_suffix|>struct... | code_fim | medium | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Standard-Library-Cookbook",
"path": "/Chapter01/src/bin/constructor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl NameLength {
// The user doesn't need to setup length
// We do it for him!
fn new(name: &str) -> Self {
NameLength {
length: name.len(),
name.to_string(),
}
}
fn print(&self) {
println!(
"The name '{}' is '{}' characters... | code_fim | medium | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Standard-Library-Cookbook",
"path": "/Chapter01/src/bin/constructor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LaurentMazare/tch-rs path: /examples/llama/sentencepiece.rs
// A very naive sentencepiece encoder/decoder, this only supports the BPE model and not the unigram
// one.
use anyhow::{bail, Context, Result};
use std::collections::{HashMap, HashSet};
pub struct Tokenizer {
encoder: HashMap<Vec<u... | code_fim | hard | {
"lang": "rust",
"repo": "LaurentMazare/tch-rs",
"path": "/examples/llama/sentencepiece.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn bpe(&self, s: &str) -> Vec<usize> {
let mut buffer = [0u8; 4];
let mut word: Vec<Vec<u8>> = vec![];
for c in s.chars() {
let buffer = c.encode_utf8(&mut buffer);
word.push(buffer.as_bytes().to_vec())
}
if word.is_empty() {
... | code_fim | hard | {
"lang": "rust",
"repo": "LaurentMazare/tch-rs",
"path": "/examples/llama/sentencepiece.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = [0u8; 4];
let mut word: Vec<Vec<u8>> = vec![];
for c in s.chars() {
let buffer = c.encode_utf8(&mut buffer);
word.push(buffer.as_bytes().to_vec())
}
if word.is_empty() {
return Vec::new();
}
while ... | code_fim | hard | {
"lang": "rust",
"repo": "LaurentMazare/tch-rs",
"path": "/examples/llama/sentencepiece.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hwchen/beryl path: /src/backend.rs
use failure::Error;
use futures::Future;
use crate::dataframe::DataFrame;
use crate::query_ir::QueryIr;
pub trait Backend {
/// Takes in a SQL string, outputs a DataFrame, which will go on to be formatted into the
/// desired query output format.
... | code_fim | medium | {
"lang": "rust",
"repo": "hwchen/beryl",
"path": "/src/backend.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// takes &self, but only required to be able to trun Backend into
/// a trait object. It's not needed for any of the logic
fn generate_sql(&self, query_ir: QueryIr) -> String;
}
impl Clone for Box<dyn Backend + Send + Sync> {
fn clone(&self) -> Box<Backend + Send + Sync> {
self.b... | code_fim | medium | {
"lang": "rust",
"repo": "hwchen/beryl",
"path": "/src/backend.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linkerd/linkerd2-proxy path: /linkerd/app/inbound/src/metrics/error/http.rs
use super::ErrorKind;
use linkerd_app_core::{
metrics::{metrics, Counter, FmtMetrics, ServerLabel},
svc::{self, stack::NewMonitor},
transport::{labels::TargetAddr, OrigDstAddr},
Error,
};
use parking_lot:... | code_fim | hard | {
"lang": "rust",
"repo": "linkerd/linkerd2-proxy",
"path": "/linkerd/app/inbound/src/metrics/error/http.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> svc::stack::MonitorNewService<T> for HttpErrorMetrics
where
T: svc::Param<OrigDstAddr>,
T: svc::Param<ServerLabel>,
{
type MonitorService = MonitorHttpErrorMetrics;
#[inline]
fn monitor(&self, target: &T) -> Self::MonitorService {
let OrigDstAddr(addr) = target.param()... | code_fim | hard | {
"lang": "rust",
"repo": "linkerd/linkerd2-proxy",
"path": "/linkerd/app/inbound/src/metrics/error/http.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nathanmcmillan/scroll-and-sigil-rust path: /client/src/webgl/system.rs
use crate::webgl;
use crate::webgl::buffer::WebGlRenderBuffer;
use std::rc::Rc;
use web_sys::WebGl2RenderingContext;
use web_sys::WebGl2RenderingContext as GL;
use web_sys::WebGlProgram;
use web_sys::WebGlTexture;
pub struct... | code_fim | hard | {
"lang": "rust",
"repo": "nathanmcmillan/scroll-and-sigil-rust",
"path": "/client/src/webgl/system.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn bind_and_draw(&self, b: &WebGlRenderBuffer) {
let count = b.buffer.index_position as i32;
if count == 0 {
return;
}
let context = &self.context;
context.bind_vertex_array(b.vao.as_ref());
context.draw_elements_with_i32(GL::TRIANGLES, c... | code_fim | hard | {
"lang": "rust",
"repo": "nathanmcmillan/scroll-and-sigil-rust",
"path": "/client/src/webgl/system.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(i) = x {
Some(i+1)
} else {
None
}
// 两种写法等价的
// match x {
// None => None,
// Some(i) => Some(i+1)
// }
}
fn main() {
let home = IpAddr::V4(127, 0, 0,1);
let lookback = IpAddr::V6(String::from("::1"));
let m = Message::Writ... | code_fim | medium | {
"lang": "rust",
"repo": "Talbot3/FlyLab",
"path": "/examples/demo-node-addon/hi-rust/rust/hello_enum/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Talbot3/FlyLab path: /examples/demo-node-addon/hi-rust/rust/hello_enum/src/main.rs
// 将任意类型的数据放入枚举成员中, 包括结构体
enum IpAddr {
V4(u8, u8, u8, u8),
V6(String)
}
enum Message {
Quit,
// 包含一个匿名结构体
Move { x: i32, y: i32 },
Write(String),
ChangeColor(i32, i32, i32),
}
<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "Talbot3/FlyLab",
"path": "/examples/demo-node-addon/hi-rust/rust/hello_enum/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmgolembiowski/esp8266-wifi-serial path: /src/parser.rs
use core::str::FromStr;
use nom::{alt, char, character::streaming::digit1, do_parse, named, opt, tag, IResult};
use crate::net::{IpAddr, Ipv4Addr};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CommandResponse {
Connected { l... | code_fim | hard | {
"lang": "rust",
"repo": "dmgolembiowski/esp8266-wifi-serial",
"path": "/src/parser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let raw = b"1,CONNECT\r\n";
let event = CommandResponse::parse(raw.as_ref()).unwrap().1;
assert_eq!(event, CommandResponse::Connected { link_id: 1 })
}
#[test]
fn test_parse_close() {
let raw = b"1,CLOSED\r\n";
let event = CommandResponse::parse(raw.as_ref()).unwrap().1;
assert_... | code_fim | hard | {
"lang": "rust",
"repo": "dmgolembiowski/esp8266-wifi-serial",
"path": "/src/parser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adrian-wechner/actix-web path: /actix-files/src/buffered.rs
use std::fs;
use std::os::unix::fs::MetadataExt;
use std::time::{SystemTime, UNIX_EPOCH};
use std::path::PathBuf;
use futures::{Future, Async, Poll, Stream};
use bytes::Bytes;
use std::{io, cmp};
use actix_web::http::header::{self, Ent... | code_fim | hard | {
"lang": "rust",
"repo": "adrian-wechner/actix-web",
"path": "/actix-files/src/buffered.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if precondition_failed {
return Ok(resp.status(StatusCode::PRECONDITION_FAILED).finish());
} else if not_modified {
return Ok(resp.status(StatusCode::NOT_MODIFIED).finish());
}
let reader = ChunkedReadFile {
offset,
size: len... | code_fim | hard | {
"lang": "rust",
"repo": "adrian-wechner/actix-web",
"path": "/actix-files/src/buffered.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> resp.header(header::ACCEPT_RANGES, "bytes");
let mut length = self.md.len();
let mut offset = 0;
// check for range header
if let Some(ranges) = req.headers().get(&header::RANGE) {
if let Ok(rangesheader) = ranges.to_str() {
if let Ok(r... | code_fim | hard | {
"lang": "rust",
"repo": "adrian-wechner/actix-web",
"path": "/actix-files/src/buffered.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: immortal/sandbox path: /rust/daemon/src/main.rs
use nix::unistd::daemon;
use std::process;
use std::{thread, time};
<|fim_suffix|> if let Ok(_) = daemon(false, false) {
println!(" my pid {}", process::id());
let mut count = 0u32;
loop {
count += 1;
... | code_fim | easy | {
"lang": "rust",
"repo": "immortal/sandbox",
"path": "/rust/daemon/src/main.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(_) = daemon(false, false) {
println!(" my pid {}", process::id());
let mut count = 0u32;
loop {
count += 1;
print!("{} ", count);
if count == 300 {
println!("OK, that's enough");
// Exit this loop
... | code_fim | easy | {
"lang": "rust",
"repo": "immortal/sandbox",
"path": "/rust/daemon/src/main.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rconan/cirrus path: /examples/list_bucket.rs
use cirrus;
use log::LevelFilter;
use simple_logger::SimpleLogger;
use std::env;
// Usage:
// cargo run --example list_bucket -- us-east-2 gmto.starccm csv.gz
// cargo run --example list_bucket -- us-west-2 gmto.modeling
<|fim_suffix|> SimpleL... | code_fim | medium | {
"lang": "rust",
"repo": "rconan/cirrus",
"path": "/examples/list_bucket.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut args = env::args().skip(1);
let region = args.next().unwrap();
let bucket = args.next().unwrap();
let suffix = args.next();
let cfd_keys = cirrus::list(
®ion,
&bucket,
"Baseline2020/b2019_0z_0az_cd_12ms/OPDData_OPD_Data_",
suffix.as_deref(),
... | code_fim | medium | {
"lang": "rust",
"repo": "rconan/cirrus",
"path": "/examples/list_bucket.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_file_dst(&self, file: &File) -> String {
match &self.fields.patterns {
Some(patterns) => {
for pattern in patterns {
if file.matches_pattern(&pattern) {
return pattern.new_folder.to_owned();
... | code_fim | hard | {
"lang": "rust",
"repo": "BUYA-USA/organize",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BUYA-USA/organize path: /src/config.rs
use crate::cli::Cli;
use crate::file::File;
use serde::Deserialize;
use std::collections::HashMap;
use std::fs;
use std::io::{Error, ErrorKind};
use std::path::Path;
#[derive(Debug, PartialEq, Deserialize)]
pub struct Pattern {
pub(crate) regex: String... | code_fim | hard | {
"lang": "rust",
"repo": "BUYA-USA/organize",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steadylearner/Rust-Full-Stack path: /async/concurrent_requests/src/main_draft.rs
// Make my own version with it.(Done)
// Code from: http://patshaughnessy.net/2020/1/20/downloading-100000-files-using-async-rust
//
// Cargo.toml:
// [dependencies]
// tokio = { version = "0.2", features = ["full"... | code_fim | medium | {
"lang": "rust",
"repo": "steadylearner/Rust-Full-Stack",
"path": "/async/concurrent_requests/src/main_draft.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let paths: Vec<String> = read_lines("urls.txt")?;
// https://docs.rs/futures-preview/0.3.0-alpha.17/futures/stream/trait.StreamExt.html#method.buffer_unordered
// https://docs.rs/futures-preview/0.3.0-alpha.17/futures/s... | code_fim | medium | {
"lang": "rust",
"repo": "steadylearner/Rust-Full-Stack",
"path": "/async/concurrent_requests/src/main_draft.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anvie/rust-project.g8 path: /src/main/g8/src/bin/$app_name;format="normalize"$_main.rs
extern crate $app_name;format="snake"$;
extern crate docopt;
extern crate rustc_serialize;
#[macro_use]
extern crate log;
extern crate env_logger;
use docopt::Docopt;
const USAGE:&'static str = "
$name$ CL... | code_fim | medium | {
"lang": "rust",
"repo": "anvie/rust-project.g8",
"path": "/src/main/g8/src/bin/$app_name;format=\"normalize\"$_main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.flag_version {
println!("{}", $app_name;format="snake"$::build::VERSION);
}
if args.cmd_hello {
say_hello(&args.arg_name);
}
}
fn say_hello(name:&str){
println!("hello {}!", name);
}<|fim_prefix|>// repo: anvie/rust-project.g8 path: /src/main/g8/src/bin/$app... | code_fim | hard | {
"lang": "rust",
"repo": "anvie/rust-project.g8",
"path": "/src/main/g8/src/bin/$app_name;format=\"normalize\"$_main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qpdb/mentat path: /query-projector/src/relresult.rs
// Copyright 2018 Mozilla
//
// 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/licenses/LICENS... | code_fim | hard | {
"lang": "rust",
"repo": "qpdb/mentat",
"path": "/query-projector/src/relresult.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if src.is_empty() {
RelResult::empty(0)
} else {
let width = src.get(0).map(|r| r.len()).unwrap_or(0);
RelResult {
width,
values: src
.into_iter()
.flat_map(|r| r.into_iter().map(|v|... | code_fim | hard | {
"lang": "rust",
"repo": "qpdb/mentat",
"path": "/query-projector/src/relresult.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chop0/discord-census path: /src/discord.rs
use rand::Rng;
use serde::Deserialize;
use std::env;
use std::time::Duration;
use tokio::time::sleep;
use crate::util::deserialize_number_from_string;
macro_rules! add_humanlike_imperfection {
($thing_to_make_non_sus:expr) => {
$thing_to_m... | code_fim | hard | {
"lang": "rust",
"repo": "chop0/discord-census",
"path": "/src/discord.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let response = add_humanlike_imperfection!(client.get(format!(
"{}/guilds/{}/messages/search?content={}",
self.api_url, guild_id, content
)))
.header("authorization", &self.token)
.send()
.await?;
// println!("Status: {}\n, {:#?}", ... | code_fim | hard | {
"lang": "rust",
"repo": "chop0/discord-census",
"path": "/src/discord.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let known_urls = web::Data::new(KnownUrls {
urls: RwLock::new(HashMap::new()),
});
debug!("Allocated RwLock and HashMap for known URLs");
HttpServer::new(move || {
App::new()
.route("/shorten", web::post().to(shorten))
.route("/{redirect_id}", web::... | code_fim | hard | {
"lang": "rust",
"repo": "harrytucker/short-iron",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Wraps a `Mutex` around a `HashMap` for storing URLs and their shortened
/// variants.
#[derive(Debug)]
pub struct KnownUrls {
urls: RwLock<HashMap<LongURL, ShortUrl>>,
}
/// Sets up the HttpServer and shared resources.
///
/// Configured here:
/// - Tracing Subscriber (Logging)
/// - KnownUrls sh... | code_fim | hard | {
"lang": "rust",
"repo": "harrytucker/short-iron",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harrytucker/short-iron path: /src/main.rs
//! Short Iron is a silly pun about golf and URL shortening.
//!
//! # Overview
//!
//! Actix-Web based API for shortening URLs. Includes functionality such as
//! structured logging, robust error handling, and URL shortening!
//!
//! # Endpoints
//! ## ... | code_fim | hard | {
"lang": "rust",
"repo": "harrytucker/short-iron",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scottschroeder/storyestimate path: /src/estimates/vote/mod.rs
mod public;
pub use self::public::{PublicVote, PublicVoteState};
#[derive(Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum VoteState {
Empty,
Hidden(u32),
Visible(u32),
}
impl VoteState {
... | code_fim | hard | {
"lang": "rust",
"repo": "scottschroeder/storyestimate",
"path": "/src/estimates/vote/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut v = VoteState::new();
assert_eq!(v, VoteState::Empty);
v.vote(3);
assert_eq!(v, VoteState::Hidden(3));
v.clear();
assert_eq!(v, VoteState::Hidden(3));
}
#[test]
fn vote_reset() {
let mut v = VoteState::new();
assert_eq!(v, VoteState::Empty);
v.vote(3);
v.re... | code_fim | hard | {
"lang": "rust",
"repo": "scottschroeder/storyestimate",
"path": "/src/estimates/vote/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Leowbattle/clr_lite path: /clr_lite/src/vm/internal_method/System_Console.rs
use super::*;
use std::collections::HashMap;
// Named this way because there is already write! in Rust.
fn console_write(clr: &mut ClrLite, params: &mut [Value]) -> Result<Option<Value>, String> {
<|fim_suffix|>pub(su... | code_fim | hard | {
"lang": "rust",
"repo": "Leowbattle/clr_lite",
"path": "/clr_lite/src/vm/internal_method/System_Console.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(super) fn load_internal_methods(h: &mut HashMap<String, InternalMethod>) {
h.insert(
"Void System.Console.Write(System.String)".to_string(),
console_write,
);
}<|fim_prefix|>// repo: Leowbattle/clr_lite path: /clr_lite/src/vm/internal_method/System_Console.rs
use super::*;
use std::collections... | code_fim | hard | {
"lang": "rust",
"repo": "Leowbattle/clr_lite",
"path": "/clr_lite/src/vm/internal_method/System_Console.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn foo<'a>(data: &mut Chars<'a>) {
bar(mk_unexpected_char_err)
//~^ ERROR lifetime parameter `'a` declared on fn `mk_unexpected_char_err`
//~| WARNING hard error in a future release
}
fn bar<F>(t: F)
// No type can satisfy this requirement, since `'a` does not
// appear in any of the ... | code_fim | hard | {
"lang": "rust",
"repo": "vadimcn/rust",
"path": "/src/test/compile-fail/associated-types/cache/wasm-issue-32330.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vadimcn/rust path: /src/test/compile-fail/associated-types/cache/wasm-issue-32330.rs
// Copyright 2014 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... | code_fim | hard | {
"lang": "rust",
"repo": "vadimcn/rust",
"path": "/src/test/compile-fail/associated-types/cache/wasm-issue-32330.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut checkpoint = started;
let mut should_close = false;
while !should_close {
let start = frames.start;
for _ in &mut frames {
factory.maintain(&mut families);
event_loop.poll_events(|event| match event {
Event::WindowEvent { event: ... | code_fim | hard | {
"lang": "rust",
"repo": "memoryruins/rendy-pbr",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.