text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: mishaszu/RUST-INTRO path: /src/ex1/arrays_vectors_strings/src/vectors.rs
fn vectors() {
println!("vectors");
let mut a = Vec::new();
a.push(1);
a.push(1);
a.push(1);
let idx: usize = 0;
a[idx] = 321;
// a[3] = 44;
a.push(44);
<|fim_suffix|> println!("vect... | code_fim | hard | {
"lang": "rust",
"repo": "mishaszu/RUST-INTRO",
"path": "/src/ex1/arrays_vectors_strings/src/vectors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kenkeiras/miniline path: /src/main.rs
mod symbols;
mod segments;
use std::env;
use segments::connection::connect_last;
use segments::connection::connect_segments;
use segments::error::error_segment;
use segments::path::path_segments;
use segments::virtualenv::virtualenv_segment;
use segments... | code_fim | hard | {
"lang": "rust",
"repo": "kenkeiras/miniline",
"path": "/src/main.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> let clean_colors : String = "\\[\x1b[0m\\]".to_string();
let first_segment : String = error_segment(error);
let virtualenv_segment : Option<String> = virtualenv_segment();
let second_segment : String = path_segments();
print!("{clean}{error} ",
clean=clean_colors,
... | code_fim | hard | {
"lang": "rust",
"repo": "kenkeiras/miniline",
"path": "/src/main.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/clock_gettime.rs
/// Get time of specific clock.
///
/// # Example
///
/// ```
/// let mut tp = nc::timespec_t::default();
/// let ret = unsafe { nc::clock_gettime(nc::CLOCK_REALTIME_COARSE, &mut tp) };
/// assert!(ret.is_ok());
/// assert!(tp.tv_sec > 0);
/// ```
p... | code_fim | medium | {
"lang": "rust",
"repo": "XuShaohua/nc",
"path": "/src/calls/clock_gettime.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ck as usize;
let tp_ptr = tp as *mut timespec_t as usize;
syscall2(SYS_CLOCK_GETTIME, which_clock, tp_ptr).map(drop)
}<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/clock_gettime.rs
/// Get time of specific clock.
///
/// # Example
///
/// ```
/// let mut tp = nc::timespec_t::default();
///... | code_fim | hard | {
"lang": "rust",
"repo": "XuShaohua/nc",
"path": "/src/calls/clock_gettime.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KevinWMatthews/rust-options path: /src/bin/unwrap_or.rs
/*
Get the value from an Option<T> or a default value.
The default value is directly provided by the caller.
Doesn't panic! Grabs a towel.
Should be safe to use, unlike unwrap().
https://doc.rust-lang.org/std/option/enum.Option.html#method... | code_fim | medium | {
"lang": "rust",
"repo": "KevinWMatthews/rust-options",
"path": "/src/bin/unwrap_or.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let option = Some(42);
let value = option.unwrap_or(0);
println!("value: {}", value);
let option: Option<i32> = None;
let value = option.unwrap_or(0);
println!("value: {}", value);
}<|fim_prefix|>// repo: KevinWMatthews/rust-options path: /src/bin/unwrap_or.rs
/*
Get the value fr... | code_fim | medium | {
"lang": "rust",
"repo": "KevinWMatthews/rust-options",
"path": "/src/bin/unwrap_or.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut s = S {
x: 3,
y: 3,
};
let ans = s("what"); //~ ERROR mismatched types
let ans = s();
//~^ ERROR this function takes 1 parameter but 0 parameters were supplied
let ans = s("burma", "shave");
//~^ ERROR this function takes 1 parameter but 2... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/mismatched_types/overloaded-calls-bad.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = S {
x: 3,
y: 3,
};
let ans = s("what"); //~ ERROR mismatched types
let ans = s();
//~^ ERROR this function takes 1 parameter but 0 parameters were supplied
let ans = s("burma", "shave");
//~^ ERROR this function takes 1 parameter but 2 parameters ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/mismatched_types/overloaded-calls-bad.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/mismatched_types/overloaded-calls-bad.rs
#![feature(fn_traits, unboxed_closures)]
use std::ops::FnMut;
struct S {
x: isize,
y: isize,
}
impl FnMut<(isize,)> for S {
extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isiz... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/mismatched_types/overloaded-calls-bad.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/deno-ftp path: /src/lib.rs
use deno_core::plugin_api::*;
// All ops are registered here
pub fn deno_plugin_init(interface: &mut dyn Interface) {
interface.register_op("connect", op_connect);
}
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_middle|>#[cfg(test)]
mod tests {... | code_fim | easy | {
"lang": "rust",
"repo": "isgasho/deno-ftp",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: isgasho/deno-ftp path: /src/lib.rs
use deno_core::plugin_api::*;
// All ops are registered here
pub fn deno_plugin_init(interface: &mut dyn Interface) {
interface.register_op("connect", op_connect);
}
<|fim_middle|>#[cfg(test)]
mod tests {... | code_fim | easy | {
"lang": "rust",
"repo": "isgasho/deno-ftp",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: janhrastnik/adventofcode path: /aoc2021/src/day9.rs
use std::fs::File;
use std::io::{self, BufRead};
pub fn part_one() -> usize {
let file = File::open("input/day9-1.txt").expect("some error when reading file");
let lines: Vec<Vec<usize>> = io::BufReader::new(file)
.lines()
... | code_fim | hard | {
"lang": "rust",
"repo": "janhrastnik/adventofcode",
"path": "/aoc2021/src/day9.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // find the basins
for minimum in minimums {
let mut candidate_list: Vec<(usize, usize)> = Vec::new();
let mut checked_elements: Vec<(usize, usize)> = Vec::new();
let mut basin_count = 0;
candidate_list.push(minimum);
while candidate_list.len() > 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "janhrastnik/adventofcode",
"path": "/aoc2021/src/day9.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1danielcoelho/raytracing-rust path: /src/utils.rs
use rand::Rng;
use crate::vec3::Vec3;
pub fn random_in_unit_sphere() -> Vec3 {
let mut rng = rand::thread_rng();
loop {
// Random point within [-1, 1] cube
let p = Vec3::new(
2.0 * rng.gen::<f64>() - 1.0,
... | code_fim | hard | {
"lang": "rust",
"repo": "1danielcoelho/raytracing-rust",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn reflect(v: &Vec3, n: &Vec3) -> Vec3 {
return *v - n * v.dot(n) * 2.0;
}
pub fn refract(v: &Vec3, n: &Vec3, ni_over_nt: f64) -> Option<Vec3> {
let uv = v.normalized();
let dt = uv.dot(n);
let discriminant = 1.0 - ni_over_nt * ni_over_nt * (1.0 - dt * dt);
if discriminant > 0.0 {... | code_fim | hard | {
"lang": "rust",
"repo": "1danielcoelho/raytracing-rust",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn random_in_unit_disk() -> Vec3 {
let mut rng = rand::thread_rng();
loop {
let p = Vec3::new(rng.gen::<f64>(), rng.gen::<f64>(), 0.0) * 2.0 - Vec3::new(1.0, 1.0, 0.0);
if p.dot(&p) < 1.0 {
return p;
}
}
}
pub fn reflect(v: &Vec3, n: &Vec3) -> Vec3 {
... | code_fim | medium | {
"lang": "rust",
"repo": "1danielcoelho/raytracing-rust",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rysiekp/latte path: /src/ast.rs
#[derive(Debug, Clone)]
pub struct Program(pub Vec<Def>);
#[derive(Debug, Clone)]
pub enum Def {
DFun(Type, String, Vec<Arg>, Vec<Stmt>),
}
#[derive(Debug, Clone)]
pub struct Arg(pub Type, pub String);
#[derive(Debug, Clone)]
pub enum Stmt {
Empty,
... | code_fim | hard | {
"lang": "rust",
"repo": "rysiekp/latte",
"path": "/src/ast.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Item {
pub fn get_id(&self) -> String {
match *self {
Item::NoInit(ref id) => id.clone(),
Item::Init(ref id, _) => id.clone(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Expr {
EVar(String),
EIntLit(i32),
EBoolLit(bool),
EStr... | code_fim | hard | {
"lang": "rust",
"repo": "rysiekp/latte",
"path": "/src/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BinOp {
Add,
Sub,
Mul,
Div,
Mod,
LT,
LE,
EQ,
NEQ,
GT,
GE,
And,
Or,
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Type {
TInt,
TString,
TBool,
TVoid,
TFunc(Box<Type>, Vec<Type>... | code_fim | hard | {
"lang": "rust",
"repo": "rysiekp/latte",
"path": "/src/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[must_use]
pub fn difference(&self, other: &Self) -> CustomSet<T> {
CustomSet::new(
&self
.collection
.iter()
.cloned()
.filter(|c| !other.contains(c))
.collect::<Vec<_>>(),
)
}
}<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "exercism/rust",
"path": "/exercises/practice/custom-set/.meta/example.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exercism/rust path: /exercises/practice/custom-set/.meta/example.rs
#[derive(Debug)]
pub struct CustomSet<T> {
collection: Vec<T>,
}
impl<T: Ord + Clone> PartialEq for CustomSet<T> {
fn eq(&self, other: &Self) -> bool {
self.collection.iter().all(|x| other.contains(&x))
... | code_fim | hard | {
"lang": "rust",
"repo": "exercism/rust",
"path": "/exercises/practice/custom-set/.meta/example.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const PATH: &str = "test_data/utf8_all_chars.txt";
group.bench_function("baseline (built-in)", |b| b.iter(|| {
let s = fs::read_to_string(PATH).unwrap();
let stream = s.chars();
black_box(consume_iterator(stream));
}));
group.bench_function("batch size: MAX", |b| b... | code_fim | medium | {
"lang": "rust",
"repo": "tunococ/reword",
"path": "/benches/utf8_converters.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> group.bench_function("baseline (built-in)", |b| b.iter(|| {
let s = fs::read_to_string(PATH).unwrap();
let stream = s.chars();
black_box(consume_iterator(stream));
}));
group.bench_function("batch size: MAX", |b| b.iter(|| {
let stream = read_utf8_stream(PATH, u... | code_fim | medium | {
"lang": "rust",
"repo": "tunococ/reword",
"path": "/benches/utf8_converters.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tunococ/reword path: /benches/utf8_converters.rs
use std::fs;
use criterion::{black_box, criterion_group, Criterion};
use reword::io::*;
fn consume_iterator<I: Iterator>(i: I) -> usize {
<|fim_suffix|>fn bench_decode_utf8_stream_from_file(c: &mut Criterion) {
let mut group = c.benchmark_g... | code_fim | medium | {
"lang": "rust",
"repo": "tunococ/reword",
"path": "/benches/utf8_converters.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[radmin_macros::from_similar(RoleRequest)]
#[derive(Deserialize, Debug)]
pub struct RoleCreateForm {
pub name: String,
pub label: Option<String>,
pub description: Option<String>,
pub is_super: bool,
}
impl Submitable for RoleCreateForm {
fn submit(self, conn: &PgConnection) -> Result... | code_fim | medium | {
"lang": "rust",
"repo": "Type-3/rAdmin",
"path": "/src/acl/forms/role.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Type-3/rAdmin path: /src/acl/forms/role.rs
use crate::ServerError;
use diesel::PgConnection;
use serde::Deserialize;
use crate::acl::factories::RoleFactory;
use crate::acl::requests::RoleRequest;
use crate::traits::Submitable;
<|fim_suffix|>impl Submitable for RoleCreateForm {
fn submit(se... | code_fim | hard | {
"lang": "rust",
"repo": "Type-3/rAdmin",
"path": "/src/acl/forms/role.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> RoleFactory::default()
.name(self.name)
.label(self.label)
.description(self.description)
.is_super(self.is_super)
.insert(&conn);
Ok(())
}
}<|fim_prefix|>// repo: Type-3/rAdmin path: /src/acl/forms/role.rs
use crate::ServerE... | code_fim | hard | {
"lang": "rust",
"repo": "Type-3/rAdmin",
"path": "/src/acl/forms/role.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn wrap_error_to_error(self) -> LispError;
}
impl <TError> WrapError for TError
where TError: Error + Send + 'static {
fn wrap_error_to_err<TResult>(self) -> LispResult<TResult> {
Err(self.wrap_error_to_error())
}
fn wrap_error_to_error(self) -> LispError {
let err = ... | code_fim | medium | {
"lang": "rust",
"repo": "tyleo/simplisp",
"path": "/src/error/wrap_error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let err = Box::new(self);
LispErrorKind::ErrorWrapper(err).into()
}
}<|fim_prefix|>// repo: tyleo/simplisp path: /src/error/wrap_error.rs
use std::error::Error;
use error::Error as LispError;
use error::ErrorKind as LispErrorKind;
use error::Result as LispResult;
pub trait WrapError ... | code_fim | medium | {
"lang": "rust",
"repo": "tyleo/simplisp",
"path": "/src/error/wrap_error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyleo/simplisp path: /src/error/wrap_error.rs
use std::error::Error;
use error::Error as LispError;
use error::ErrorKind as LispErrorKind;
use error::Result as LispResult;
<|fim_suffix|> Err(self.wrap_error_to_error())
}
fn wrap_error_to_error(self) -> LispError {
let er... | code_fim | hard | {
"lang": "rust",
"repo": "tyleo/simplisp",
"path": "/src/error/wrap_error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avranju/iotedge-k8s path: /edgelet/iotedged/src/windows.rs
// Copyright (c) Microsoft. All rights reserved.
use std::cell::RefCell;
use std::env;
use std::ffi::OsString;
use std::time::Duration;
use failure::ResultExt;
use futures::prelude::*;
use futures::sync::oneshot;
use windows_service::s... | code_fim | hard | {
"lang": "rust",
"repo": "avranju/iotedge-k8s",
"path": "/edgelet/iotedged/src/windows.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // setup a channel for notifying service stop/shutdown
let (sender, receiver) = oneshot::channel();
let sender = RefCell::new(Some(sender)); // register() takes Fn, not FnMut
// setup the service control handler
let status_handle = register(
IOTEDGED_SERVICE_NAME,
move... | code_fim | hard | {
"lang": "rust",
"repo": "avranju/iotedge-k8s",
"path": "/edgelet/iotedged/src/windows.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akiles/embassy path: /embassy-stm32/src/crc/v2v3.rs
use embassy_hal_common::{into_ref, PeripheralRef};
use crate::pac::crc::vals;
use crate::pac::CRC as PAC_CRC;
use crate::peripherals::CRC;
use crate::rcc::sealed::RccPeripheral;
use crate::Peripheral;
pub struct Crc<'d> {
_peripheral: Per... | code_fim | hard | {
"lang": "rust",
"repo": "akiles/embassy",
"path": "/embassy-stm32/src/crc/v2v3.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Feeds an slice of bytes into the CRC peripheral. Returns the computed checksum.
pub fn feed_bytes(&mut self, bytes: &[u8]) -> u32 {
for byte in bytes {
unsafe {
PAC_CRC.dr8().write_value(*byte);
}
}
unsafe { PAC_CRC.dr().read() }
... | code_fim | hard | {
"lang": "rust",
"repo": "akiles/embassy",
"path": "/embassy-stm32/src/crc/v2v3.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
// Init CRC value
PAC_CRC.init().write_value(self._config.crc_init_value);
#[cfg(crc_v3)]
PAC_CRC.pol().write_value(self._config.crc_poly);
// configure CR components
// (reverse I/O, polysize, poly)
PAC_... | code_fim | hard | {
"lang": "rust",
"repo": "akiles/embassy",
"path": "/embassy-stm32/src/crc/v2v3.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/match-stress/src/macros.rs
macro_rules! ast_struct {
(
$(#[$attr:meta])*
pub struct $name:ident $($rest:tt)*
) => {
$(#[$attr])*
#[derive(PartialEq)]
pub struct $name $($rest)*
};
}
macr... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/match-stress/src/macros.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> $(
maybe_ast_struct! {
$(#[$variant_attr])*
pub struct $member $($rest)*
}
)*
)
}
macro_rules! maybe_ast_struct {
(
$(#[$attr:meta])*
pub struct $name:ident
) => ();
($($rest:tt)*) => (ast_struct! { $... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/match-stress/src/macros.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
#[doc = "Bit 14"]
#[inline(always)]
pub fn sio(&self) -> SIO_R {
SIO_R::new(((self.bits >> 14) & 0x01) != 0)
}
#[doc = "Bit 13"]
#[inline(always)]
pub fn vreg_and_chip_reset(&self) -> VREG_AND_CHIP_RESET_R {
VREG_AND_CHIP_RESET_R::new(((self.bits >> 13) & 0x0... | code_fim | hard | {
"lang": "rust",
"repo": "9ary/rp2040-pac",
"path": "/src/psm/frce_on.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 9ary/rp2040-pac path: /src/psm/frce_on.rs
32, super::FRCE_ON>;
#[doc = "Register FRCE_ON `reset()`'s with value 0"]
impl crate::ResetValue for super::FRCE_ON {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Reader of field `proc1`"]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "9ary/rp2040-pac",
"path": "/src/psm/frce_on.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn vreg_and_chip_reset(&self) -> VREG_AND_CHIP_RESET_R {
VREG_AND_CHIP_RESET_R::new(((self.bits >> 13) & 0x01) != 0)
}
#[doc = "Bit 12"]
#[inline(always)]
pub fn xip(&self) -> XIP_R {
XIP_R::new(((self.bits >> 12) & 0x01) != 0)
}
#[doc = "Bit 11"]
#[inl... | code_fim | hard | {
"lang": "rust",
"repo": "9ary/rp2040-pac",
"path": "/src/psm/frce_on.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CleanCut/legion path: /src/internals/serialize/ser.rs
//! World serialization types.
use super::{
entities::ser::EntitiesLayoutSerializer, packed::ser::PackedLayoutSerializer, UnknownType,
WorldField,
};
use crate::internals::{
query::filter::LayoutFilter, storage::component::Compon... | code_fim | hard | {
"lang": "rust",
"repo": "CleanCut/legion",
"path": "/src/internals/serialize/ser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn serialize_world<S, F, W>(
serializer: S,
world: &World,
filter: &F,
world_serializer: &W,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
F: LayoutFilter,
W: WorldSerializer,
{
let human_readable = serializer.is_human_readable();
let mut root = serializer.serialize... | code_fim | hard | {
"lang": "rust",
"repo": "CleanCut/legion",
"path": "/src/internals/serialize/ser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn sum_function(a: i32, b: i32) {
println!("{}", a + b);
}
fn double_function(a: i32, b: i32, c: i32) {
println!("{}", a * b * c)
}
fn div_function(a: f64, b: f64) -> f64 {
a / b
}
fn model_function(a: i32, b: i32) -> i32 {
a % b
}
fn xx_function(a: i32, b: i32) -... | code_fim | medium | {
"lang": "rust",
"repo": "midninght-starchen/rust-study",
"path": "/four_days/four_days.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: midninght-starchen/rust-study path: /four_days/four_days.rs
fn main() {
//zhuerba_function();
//another_function(32);
//sum_function(2, 3);
// double_function(75, 7, 5);
println!("{}", div_function(5571.2, 3.5));
println!("{}", model_function(10, 3));
println!("{:?}"... | code_fim | medium | {
"lang": "rust",
"repo": "midninght-starchen/rust-study",
"path": "/four_days/four_days.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flxo/rogcat path: /src/terminal.rs
// Copyright © 2016 Felix Obenhuber
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without lim... | code_fim | hard | {
"lang": "rust",
"repo": "flxo/rogcat",
"path": "/src/terminal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..chunks {
write_preamble(&mut buffer)?;
let c = if chunks == 1 {
" "
} else if i == 0 {
" ┌ "
} else if i == chunks - 1 {
" └ "
} else {
" ├ "
};
... | code_fim | hard | {
"lang": "rust",
"repo": "flxo/rogcat",
"path": "/src/terminal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as _
}
}
impl crate::FieldSpec for CLKOUTSEL1_A {
type Ux = u8;
}
impl CLKOUTSEL1_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> Option<CLKOUTSEL1_A> {
match self.bits {
0 => Some(CLKOUTSEL1_A::DISABLED),
... | code_fim | hard | {
"lang": "rust",
"repo": "BogdanOlar/efm32pg1b-pac",
"path": "/src/cmu/ctrl.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BogdanOlar/efm32pg1b-pac path: /src/cmu/ctrl.rs
:R<CTRL_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<CTRL_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<CTRL_SPEC>) -> Self {
R(reader)
}
}
#[doc = "R... | code_fim | hard | {
"lang": "rust",
"repo": "BogdanOlar/efm32pg1b-pac",
"path": "/src/cmu/ctrl.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BogdanOlar/efm32pg1b-pac path: /src/cmu/ctrl.rs
)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<CTRL_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<CTRL_SPEC>) -> Self {
R(reader)
}
}
#[doc = "Register `CTRL` writer"]
pub struct... | code_fim | hard | {
"lang": "rust",
"repo": "BogdanOlar/efm32pg1b-pac",
"path": "/src/cmu/ctrl.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bgluzman/rust-raytracer-in-a-weekend path: /src/material.rs
use vec3::{ElemT, Vec3};
use ray::Ray;
use hi<|fim_suffix|>&HitRecord<T>) -> Option<(Vec3<T>, Ray<T>)>;
}<|fim_middle|>table::HitRecord;
pub trait Material<T: ElemT> {
fn scatter(&self, r_in: &Ray<T>, rec: | code_fim | medium | {
"lang": "rust",
"repo": "bgluzman/rust-raytracer-in-a-weekend",
"path": "/src/material.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>> {
fn scatter(&self, r_in: &Ray<T>, rec: &HitRecord<T>) -> Option<(Vec3<T>, Ray<T>)>;
}<|fim_prefix|>// repo: bgluzman/rust-raytracer-in-a-weekend path: /src/material.rs
use vec3::{ElemT, Vec3};
use ray::Ray;
use hi<|fim_middle|>table::HitRecord;
pub trait Material<T: ElemT | code_fim | easy | {
"lang": "rust",
"repo": "bgluzman/rust-raytracer-in-a-weekend",
"path": "/src/material.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::env::set_var("RUST_LOG", "actix_web=debug,paste_cross=debug");
env_logger::init();
let app_host = std::env::var("APP_HOST").expect("APP_HOST not found.");
let app_port = std::env::var("APP_PORT").expect("APP_PORT not found.");
let app_url = format!("{}:{}", &app_host, &app_port);... | code_fim | hard | {
"lang": "rust",
"repo": "m77can/paster",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m77can/paster path: /src/main.rs
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate log;
<|fim_suffix|>#[actix_rt::main]
async fn main... | code_fim | hard | {
"lang": "rust",
"repo": "m77can/paster",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match Some(1) {
Some(c) if c <= 1 => (),
Some(_) => (),
None => (),
}
}
}<|fim_prefix|>// repo: ani003/prusti_panic_test path: /sample_tests/loops_117/test2.rs
// thread 'rustc' panicked at 'not implemented: NonMutatingUse(ShallowBorrow)'... | code_fim | easy | {
"lang": "rust",
"repo": "ani003/prusti_panic_test",
"path": "/sample_tests/loops_117/test2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ani003/prusti_panic_test path: /sample_tests/loops_117/test2.rs
// thread 'rustc' panicked at 'not implemented: NonMutatingUse(ShallowBorrow)'
// prusti-interface/src/environment/loops.rs:117:22
<|fim_suffix|> loop {
match Some(1) {
Some(c) if c <= 1 => (),
So... | code_fim | easy | {
"lang": "rust",
"repo": "ani003/prusti_panic_test",
"path": "/sample_tests/loops_117/test2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Which records this combinations is part of
/// This method will clone the data, so its recommended to have its result stored
/// in a local variable to avoid it being called multiple times
fn get_contained_in_records(&self) -> RecordsSet {
self.contained_in_records.clone()
... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/synthetic-data-showcase",
"path": "/packages/core/src/processing/aggregator/aggregated_count.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: microsoft/synthetic-data-showcase path: /packages/core/src/processing/aggregator/aggregated_count.rs
use super::typedefs::RecordsSet;
use serde::{Deserialize, Serialize};
#[cfg(feature = "pyo3")]
use pyo3::prelude::*;
<|fim_suffix|> self.count
}
/// Which records this combinati... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/synthetic-data-showcase",
"path": "/packages/core/src/processing/aggregator/aggregated_count.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "pyo3")]
#[cfg_attr(feature = "pyo3", pymethods)]
impl AggregatedCount {
/// How many times the combination appears on the records
#[getter]
fn count(&self) -> usize {
self.count
}
/// Which records this combinations is part of
/// This method will clone th... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/synthetic-data-showcase",
"path": "/packages/core/src/processing/aggregator/aggregated_count.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // calling Unsafe functions
use std::slice;
let some_vector = vec![1, 2, 3, 4];
let ptr = some_vector.as_ptr();
let len = some_vector.len();
// `std::slice::from_raw_parts` creates a slice given a pointer to the first element and a
// length
unsafe {
let my_slice: ... | code_fim | medium | {
"lang": "rust",
"repo": "franktly/rust_by_example",
"path": "/unsafe_op_and_compatibility/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ptr: *mut u8 = &mut 10u8 as *mut u8;
unsafe {
if let Some(val_back) = ptr.as_ref() {
println!("got back the value: {}", val_back);
let val = &*ptr;
println!("2 got back the value: {}", val);
let val = *ptr;
println!("3 got b... | code_fim | hard | {
"lang": "rust",
"repo": "franktly/rust_by_example",
"path": "/unsafe_op_and_compatibility/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: franktly/rust_by_example path: /unsafe_op_and_compatibility/src/main.rs
// Four primary things that unsafe is used for:
// 1. dereferencing raw pointers
// 2. calling functions or methods which are `unsafe`(including calling a function over FFI)
// 3. accessing or modifying static mutable variab... | code_fim | hard | {
"lang": "rust",
"repo": "franktly/rust_by_example",
"path": "/unsafe_op_and_compatibility/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
input! {
mut n: usize,
}
let mut flag = false;
while n > 0 {
if n % 10 == 7 {
flag = true;
}
n /= 10;
}
if flag {
println!("Yes");
} else {
println!("No");
}
}<|fim_prefix|>// repo: likr/atcoder path: ... | code_fim | medium | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc162/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
mut n: usize,
}
let mut flag = false;
while n > 0 {
if n % 10 == 7 {
flag = true;
}
n /= 10;
}
if flag {
println!("Yes");
} else {
println!("No");
}
}<|fim_prefix|>// repo: likr/atcoder path: /abc162/src/... | code_fim | medium | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc162/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likr/atcoder path: /abc162/src/bin/a.rs
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::u... | code_fim | medium | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc162/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hhandika/yap path: /src/qc/parser.rs
parse_input_csv(buff, input, &mut raw_seqs, &mut lcounts, is_id, is_rename)
} else {
panic!(
"{:?} IS INVALID INPUT FILES. THE EXTENSION MUST BE .conf OR .csv.",
input
);
}
println!("Total samples: {}", lco... | code_fim | hard | {
"lang": "rust",
"repo": "hhandika/yap",
"path": "/src/qc/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hhandika/yap path: /src/qc/parser.rs
?} IS INVALID INPUT FILES. THE EXTENSION MUST BE .conf OR .csv.",
input
);
}
println!("Total samples: {}", lcounts);
raw_seqs
}
fn parse_input_ini<R: BufRead>(buff: R, raw_seqs: &mut Vec<RawSeq>, lcount: &mut usize) {
buf... | code_fim | hard | {
"lang": "rust",
"repo": "hhandika/yap",
"path": "/src/qc/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.id = String::from(id);
}
fn get_dir(&mut self, is_id: bool, is_rename: bool) {
if !is_id && !is_rename {
self.dir = PathBuf::from(&self.id);
} else if is_rename {
self.dir = PathBuf::from(&self.outname.as_ref().unwrap());
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "hhandika/yap",
"path": "/src/qc/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn count_unanimous_answers(group_answers: &Vec<&str>) -> u32 {
if group_answers.len() == 0 {
0
} else {
// assume the first group's answers are unanimous among all groups
let starting_answers: Vec<char> = group_answers[0].chars().collect();
group_answers
... | code_fim | hard | {
"lang": "rust",
"repo": "bholmesdev/code-advent-cal-2020",
"path": "/day-6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bholmesdev/code-advent-cal-2020 path: /day-6/src/main.rs
use array_tool::vec::Intersect;
use std::collections::HashSet;
use std::fs::read_to_string;
fn format_groups_flattened(input_file: &str) -> Vec<String> {
input_file
.split("\n\n") // split up the groups
.map(|s| s.repl... | code_fim | hard | {
"lang": "rust",
"repo": "bholmesdev/code-advent-cal-2020",
"path": "/day-6/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match input_file {
Ok(input_file) => {
let part_1 = format_groups_flattened(&input_file)
.iter()
.fold(0, |answer_count, group| {
answer_count + count_unique_answers(group)
});
let part_2 = format_grou... | code_fim | hard | {
"lang": "rust",
"repo": "bholmesdev/code-advent-cal-2020",
"path": "/day-6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>"{}", universe);
print!("{}[2J", 27 as char);
}<|fim_prefix|>// repo: mariiillo/golis path: /src/ui/cli.rs
use std::{thread, time};
use std::fmt;
pub fn print(universe: &dyn fmt::Display) {
thread::slee<|fim_middle|>p(time::Duration::from_millis(200));
println!( | code_fim | easy | {
"lang": "rust",
"repo": "mariiillo/golis",
"path": "/src/ui/cli.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mariiillo/golis path: /src/ui/cli.rs
use std::{thread, time};
use std::fmt;
pub fn pri<|fim_suffix|>p(time::Duration::from_millis(200));
println!("{}", universe);
print!("{}[2J", 27 as char);
}<|fim_middle|>nt(universe: &dyn fmt::Display) {
thread::slee | code_fim | easy | {
"lang": "rust",
"repo": "mariiillo/golis",
"path": "/src/ui/cli.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>p(time::Duration::from_millis(200));
println!("{}", universe);
print!("{}[2J", 27 as char);
}<|fim_prefix|>// repo: mariiillo/golis path: /src/ui/cli.rs
use std::{thread, time};
use std::fmt;
pub fn pri<|fim_middle|>nt(universe: &dyn fmt::Display) {
thread::slee | code_fim | easy | {
"lang": "rust",
"repo": "mariiillo/golis",
"path": "/src/ui/cli.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //
// - reset the count to 0 at which point run() may be invoked again and will execute
// its closure
//
self.lock.unlock(|_| 0);
}
}
unsafe impl<T> Sync for Once<T> {}
unsafe impl<T> Send for Once<T> {}
impl<T> Drop for Once<T> {
fn drop(&mut self) ->... | code_fim | hard | {
"lang": "rust",
"repo": "opaugam/rsm",
"path": "/src/primitives/once.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: opaugam/rsm path: /src/primitives/once.rs
//! A simple "once" (e.g a singleton) owning a closure. This construct is typically used to
//! run some initialization code or create some shared object. It holds a value that is constructed
//! by the closure and remains accessible throughout its lifet... | code_fim | hard | {
"lang": "rust",
"repo": "opaugam/rsm",
"path": "/src/primitives/once.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_left_right_rotate() {
let mut set: RedBlackTreeSet<u32> = RedBlackTreeSet::new();
set.insert(3);
set.insert(1);
set.insert(2);
match &(set.head) {
Some(box_node) => {
assert_eq!(box_node.data, 2);
assert_eq!(box_node.color, Color::Black);... | code_fim | hard | {
"lang": "rust",
"repo": "keshihoriuchi/exercism-rust",
"path": "/red-black-tree/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: keshihoriuchi/exercism-rust path: /red-black-tree/src/lib.rs
return true;
}
println!("{:?}", route);
match route[len - 2] {
(Color::Red, Direction::Left) => {
if let (_, Direction::Left) = route[len - 3] {
... | code_fim | hard | {
"lang": "rust",
"repo": "keshihoriuchi/exercism-rust",
"path": "/red-black-tree/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 右左回転
// 1. Bを黒に変える
// 2. NoneとC(B.left)をスワップ
// 3. T3(C.right)とNone(B.left)をスワップ
// 4. None(C.right)とB(A.right)をスワップ
// 5. CとAをスワップ
// 6. None(A.right)とT2(C.left)をスワップ
// 7. AとNone(C.left)をスワップ
// 8. 根を黒に変える
fn rotate_r_l(&mut self, route: &[(Color, Direction)]) ... | code_fim | hard | {
"lang": "rust",
"repo": "keshihoriuchi/exercism-rust",
"path": "/red-black-tree/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mpl Solution {
pub fn is_same_tree(p: Option<Rc<RefCell<TreeNode>>>, q: Option<Rc<RefCell<TreeNode>>>) -> bool {
if p.is_none() && q.is_none() {
true
}
// if let p = TreeNode
if p.is_some() && q.is_some() && p.val == q.val {
is_same_tree(p.left, q.le... | code_fim | medium | {
"lang": "rust",
"repo": "fengqinglingyu/algorithms",
"path": "/is_same_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if let p = TreeNode
if p.is_some() && q.is_some() && p.val == q.val {
is_same_tree(p.left, q.left) && is_same_tree(p.right, q.right)
}
false
}
}<|fim_prefix|>// repo: fengqinglingyu/algorithms path: /is_same_tree.rs
// Definition for a binary tree node.
#[deriv... | code_fim | medium | {
"lang": "rust",
"repo": "fengqinglingyu/algorithms",
"path": "/is_same_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fengqinglingyu/algorithms path: /is_same_tree.rs
// Definition for a binary tree node.
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeN<|fim_suffix|>mpl Solution {
pub fn is_same_tree(p: Opti... | code_fim | medium | {
"lang": "rust",
"repo": "fengqinglingyu/algorithms",
"path": "/is_same_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: keshihoriuchi/exercism-rust path: /anagram/src/lib.rs
#![warn(clippy::all)]
use std::collections::HashMap;
use std::collections::HashSet;
pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&'a str]) -> HashSet<&'a str> {
// 文字の出現回数のMapを作って比較する
let word_low = &word.to_lowercase();
... | code_fim | medium | {
"lang": "rust",
"repo": "keshihoriuchi/exercism-rust",
"path": "/anagram/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut word_map: HashMap<char, u32> = HashMap::new();
w.chars().for_each(|c| {
let v = match &word_map.get(&c) {
None => 1,
Some(v) => *v + 1,
};
word_map.insert(c, v);
});
word_map
}<|fim_prefix|>// repo: keshihoriuchi/exercism-rust path: ... | code_fim | hard | {
"lang": "rust",
"repo": "keshihoriuchi/exercism-rust",
"path": "/anagram/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // We expect that `block_hashes` is sorted descending by height.
// So if we cannot find the current one from local, we cannot find
// the next either.
debug!("getblocks stopping since {:x} is not found", block_hash);
break;
... | code_fim | hard | {
"lang": "rust",
"repo": "nasa8x/ckb",
"path": "/sync/src/synchronizer/get_blocks_process.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nasa8x/ckb path: /sync/src/synchronizer/get_blocks_process.rs
use crate::block_status::BlockStatus;
use crate::synchronizer::Synchronizer;
use crate::MAX_BLOCKS_IN_TRANSIT_PER_PEER;
use ckb_logger::{debug, warn};
use ckb_network::{CKBProtocolContext, PeerIndex};
use ckb_protocol::{cast, GetBlock... | code_fim | hard | {
"lang": "rust",
"repo": "nasa8x/ckb",
"path": "/sync/src/synchronizer/get_blocks_process.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self
.synchronizer
.shared()
.contains_block_status(&block_hash, BlockStatus::BLOCK_VALID)
{
debug!(
"ignoring get_block {:x} request from peer={} for unverified",
block_hash... | code_fim | hard | {
"lang": "rust",
"repo": "nasa8x/ckb",
"path": "/sync/src/synchronizer/get_blocks_process.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xmc-rs/xmc4-hal path: /src/usb.rs
pub trait UsbExt {
fn constrain(self) -> Usb;
}
impl UsbExt for Usb {
fn constrain(self) -> Usb {
<|fim_suffix|>#[cfg(test)]
mod tests {
#[test]
fn nothing() {
// Do nothing test
}
}<|fim_middle|> Usb {}
}
}
pub struct U... | code_fim | medium | {
"lang": "rust",
"repo": "xmc-rs/xmc4-hal",
"path": "/src/usb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xmc-rs/xmc4-hal path: /src/usb.rs
pub trait UsbExt {
fn constrain(self) -> Usb;
<|fim_suffix|> // Do nothing test
}
}<|fim_middle|>}
impl UsbExt for Usb {
fn constrain(self) -> Usb {
Usb {}
}
}
pub struct Usb {}
// IMPLEMENT PERIPHERAL AFTER THIS LINE
#[cfg(tes... | code_fim | medium | {
"lang": "rust",
"repo": "xmc-rs/xmc4-hal",
"path": "/src/usb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.unify(match_type, Rc::clone(&constr_type)).unwrap();
}
}
}
}
/*pub struct TypeResolveVisitor<'a> {
tv: &'a TypeVisitor
}
impl<'a> TypeResolveVisitor<'a> {
pub fn new(tv: &'a TypeVisitor) -> TypeResolveVisitor {
TypeResolveVisitor { tv }
}
... | code_fim | hard | {
"lang": "rust",
"repo": "amit-mondal/funlang",
"path": "/src/types/type_visit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn typecheck_match(&mut self, match_type: Rc<Type>, p: &Pattern, branch_env: Id<TypeEnv>) {
match p {
Pattern::Var(name) => {
let type_scheme = self
.env_stack
.lookup(&((*name).to_owned()), branch_env)
.un... | code_fim | hard | {
"lang": "rust",
"repo": "amit-mondal/funlang",
"path": "/src/types/type_visit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amit-mondal/funlang path: /src/types/type_visit.rs
use super::free_var_visit::FreeVarVisitor;
use super::type_env::{FixedTypeEnvStack, TypeEnv};
use super::{PlaceholderGenerator, Type, TypeError};
use crate::ast::*;
use id_arena::Id;
use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use... | code_fim | hard | {
"lang": "rust",
"repo": "amit-mondal/funlang",
"path": "/src/types/type_visit.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub mod schema;
mod ser;
pub mod totp;
pub mod wallet;
#[macro_use]
extern crate diesel;<|fim_prefix|>// repo: cyclefortytwo/knockturn-allee path: /src/lib.rs
#[macro_use]
mod macros;
pub mod app;
pub mod blocking;
pub mod clients;
pub mod cron;
pub mod db;
pub mod errors;
pub mod extractor;
pub mod f... | code_fim | medium | {
"lang": "rust",
"repo": "cyclefortytwo/knockturn-allee",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyclefortytwo/knockturn-allee path: /src/lib.rs
#[macro_use]
mod macros;
pub mod app;
pub mod blocking;
pub mod clients;
pub mod cron;
p<|fim_suffix|>rs;
pub mod models;
pub mod node;
pub mod qrcode;
pub mod rates;
#[allow(unused_imports)]
pub mod schema;
mod ser;
pub mod totp;
pub mod wallet;
... | code_fim | medium | {
"lang": "rust",
"repo": "cyclefortytwo/knockturn-allee",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn absolute_fee(&self, tx: &Transaction) -> Option<u64> {
let sum_outputs: u64 = tx.output.iter().map(|o| o.value).sum();
let mut sum_inputs: u64 = 0;
for input in tx.input.iter() {
let outputs_values = self.txs_output_values.get(&input.previous_output.txid)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "RCasatta/bitcoin_logger",
"path": "/src/store.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RCasatta/bitcoin_logger path: /src/store.rs
use crate::flush::{BitcoinLog, Data, OutputValues, TxidOutputValues};
use crate::{LoggerOptions, Result, NAME};
use bitcoin::consensus::deserialize;
use bitcoin::{Block, BlockHash, Transaction, Txid};
use bitcoincore_rpc::RpcApi;
use flate2::bufread::D... | code_fim | hard | {
"lang": "rust",
"repo": "RCasatta/bitcoin_logger",
"path": "/src/store.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get(&self, txid: &Txid) -> Option<&Transaction> {
self.txs.get(txid)
}
pub fn height(&self, txid: &Txid) -> Option<u32> {
self.txs_height.get(txid).cloned()
}
// fee rate in sat/vbytes
pub fn fee_rate(&self, txid: &Txid) -> Option<f64> {
let tx = se... | code_fim | hard | {
"lang": "rust",
"repo": "RCasatta/bitcoin_logger",
"path": "/src/store.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustPython/RustPython path: /vm/src/protocol/mod.rs
mod buffer;
mod callable;
mod iter;
mod mapping;
mod number;
mod object;
mod sequence;
pub use buffer::{BufferDescriptor, Buf<|fim_suffix|>yNumberMethods, PyNumberSlots,
PyNumberTernaryOp, PyNumberUnaryFunc,
};
pub use sequence::{PySequenc... | code_fim | hard | {
"lang": "rust",
"repo": "RustPython/RustPython",
"path": "/vm/src/protocol/mod.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>yNumberMethods, PyNumberSlots,
PyNumberTernaryOp, PyNumberUnaryFunc,
};
pub use sequence::{PySequence, PySequenceMethods};<|fim_prefix|>// repo: RustPython/RustPython path: /vm/src/protocol/mod.rs
mod buffer;
mod callable;
mod iter;
mod mapping;
mod number;
mod object;
mod sequence;
pub use buffer::... | code_fim | hard | {
"lang": "rust",
"repo": "RustPython/RustPython",
"path": "/vm/src/protocol/mod.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KevinGrandon/overlord path: /src/overlord/util.rs
// Generic utils for rust and not specific to core Overlord functionality... The
// intent is these utilities will either be replaced, moved or become useless...
use std::fmt::{Show, Formatter, FormatError};
<|fim_suffix|>impl PathWrapper {
pu... | code_fim | medium | {
"lang": "rust",
"repo": "KevinGrandon/overlord",
"path": "/src/overlord/util.rs",
"mode": "psm",
"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.