text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>fn part1(entries: &[u32]) -> u32 {
helper(entries, 2020).unwrap()
}
fn part2(entries: &[u32]) -> u32 {
for i in 0.. {
let x = entries[i];
if let Some(product) = helper(&entries[(i + 1)..], 2020 - x) {
return x * product;
}
}
unreachable!()
}
pub fn so... | code_fim | hard | {
"lang": "rust",
"repo": "timvermeulen/advent-of-code",
"path": "/src/solutions/year2020/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: timvermeulen/advent-of-code path: /src/solutions/year2020/day01.rs
use super::*;
fn helper(slice: &[u32], target: u32) -> Option<u32> {
let mut i = 0;
let mut j = slice.partition_point(|&x| x < target - slice[i]) - 1;
while i < j {
let sum = slice[i] + slice[j];
ma... | code_fim | medium | {
"lang": "rust",
"repo": "timvermeulen/advent-of-code",
"path": "/src/solutions/year2020/day01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::*;
use test::Bencher;
#[bench]
fn bench(b: &mut Bencher) {
let input = futures::executor::block_on(get_input(2020, 1)).unwrap();
b.iter(|| solve(&input));
}
}<|fim_prefix|>// repo: timvermeulen/advent-of-code path: /src/solutions/year2020/day01.rs
use super... | code_fim | hard | {
"lang": "rust",
"repo": "timvermeulen/advent-of-code",
"path": "/src/solutions/year2020/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imorph/vector path: /lib/vrl/compiler/src/expression/function_call.rs
rs()
.iter()
.enumerate()
.find(|(_, param)| param.keyword == k)
.map(|(pos, param)| {
if pos == index {
... | code_fim | hard | {
"lang": "rust",
"repo": "imorph/vector",
"path": "/lib/vrl/compiler/src/expression/function_call.rs",
"mode": "psm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut iter = self.arguments_fmt.iter().peekable();
while let Some(arg) = iter.next() {
f.write_str(arg)?;
if iter.peek().is_some() {
f.write_str(", ")?;
}
}
f.write_str(")")
}
}
impl fmt::Debug for FunctionCall {
... | code_fim | hard | {
"lang": "rust",
"repo": "imorph/vector",
"path": "/lib/vrl/compiler/src/expression/function_call.rs",
"mode": "spm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imorph/vector path: /lib/vrl/compiler/src/expression/function_call.rs
);
let mut maybe_fallible_arguments = false;
for node in arguments {
let (argument_span, argument) = node.take();
let parameter = match argument.keyword() {
// position... | code_fim | hard | {
"lang": "rust",
"repo": "imorph/vector",
"path": "/lib/vrl/compiler/src/expression/function_call.rs",
"mode": "psm",
"license": "MPL-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let supply = param_supply.value();
ctx.require(supply > 0, "erc20.on_init.fail: wrong 'supply' parameter");
ctx.state().get_int(VAR_SUPPLY).set_value(supply);
// we cannot use 'caller' here because on_init is always called from the 'root'
// so, owner of the initial supply must be pro... | code_fim | hard | {
"lang": "rust",
"repo": "kristofvdj88/battleships_iscp",
"path": "/smartcontract/wasp/contracts/rust/erc20/src/erc20.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> source_balance.set_value(source_balance.value() - amount);
target_balance.set_value(target_balance.value() + amount);
ctx.log("erc20.transfer.success");
}
// Moves the amount of tokens from sender to recipient using the allowance mechanism.
// Amount is then deducted from the caller’s allowan... | code_fim | hard | {
"lang": "rust",
"repo": "kristofvdj88/battleships_iscp",
"path": "/smartcontract/wasp/contracts/rust/erc20/src/erc20.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kristofvdj88/battleships_iscp path: /smartcontract/wasp/contracts/rust/erc20/src/erc20.rs
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
// implementation of ERC-20 smart contract for ISCP
// following https://ethereum.org/en/developers/tutorials/understand-the-erc-20-to... | code_fim | hard | {
"lang": "rust",
"repo": "kristofvdj88/battleships_iscp",
"path": "/smartcontract/wasp/contracts/rust/erc20/src/erc20.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc187/src/bin/e.rs
use std::collections::VecDeque;
use proconio::input;
use proconio::marker::Usize1;
fn adjacency_list(n: usize, uv: &Vec<(usize, usize)>) -> Vec<Vec<(usize, usize)>> {
let mut e = vec![vec![]; n];
for (i, &(u, v)) in... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc187/src/bin/e.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut c = vec![0_i64; n];
let mut d = vec![0_i64; n - 1];
for &(t_i, e_i, x_i) in tex.iter() {
match t_i {
0 => {
let (a_i, b_i) = ab[e_i];
if e[a_i].len() == 1 {
c[a_i] += x_i;
} else if p[a_i] == b_i {
... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc187/src/bin/e.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let key = "Snakeoil";
let result1: Vec<u8> = xxtea::encrypt_raw(&set1_unaligned.to_vec(), &key);
let result2: Vec<u8> = xxtea::encrypt_raw(&set1_aligned.to_vec(), &key);
assert_eq!(result1, result2);
assert_eq!(result1, set1_encrypted.to_vec());
// Check that encrypted length is... | code_fim | hard | {
"lang": "rust",
"repo": "Hanaasagi/XXTEA-Rust",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn run_raw_test_case() {
let set1_unaligned : [u8; 10] = [17, 18, 19, 20, 0, 0, 0, 0, 52, 238];
let set1_encrypted : [u8; 12] = [153, 30, 118, 66, 15, 149, 77, 188, 228, 138, 105, 92];
let set1_aligned : [u8; 12] = [17, 18, 19, 20, 0, 0, 0, 0, 52, 238, 0, 0];
... | code_fim | hard | {
"lang": "rust",
"repo": "Hanaasagi/XXTEA-Rust",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hanaasagi/XXTEA-Rust path: /tests/tests.rs
extern crate rand;
extern crate xxtea;
use std::str;
use rand::Rng;
fn rand_string() -> String {
let num = rand::thread_rng().gen_range(1, 256);
(0..num).map(|_| rand::random::<char>()).collect()
}
<|fim_suffix|> strs.join(" ")
}
fn run_t... | code_fim | medium | {
"lang": "rust",
"repo": "Hanaasagi/XXTEA-Rust",
"path": "/tests/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anyawal/youki path: /src/namespaces.rs
//! Namespaces provide isolation of resources for processes at a kernel level.
//! The namespaces are: Mount (filesystem),
//! Process (processes in a namespace have two PIDs, one for the global PID,
//! which is used by the main system and the second one i... | code_fim | hard | {
"lang": "rust",
"repo": "anyawal/youki",
"path": "/src/namespaces.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn gen_sample_linux_namespaces() -> Vec<LinuxNamespace> {
vec![
LinuxNamespaceBuilder::default()
.typ(LinuxNamespaceType::Mount)
.path("/dev/null")
.build()
.unwrap(),
LinuxNamespaceBuilder::default()
... | code_fim | hard | {
"lang": "rust",
"repo": "anyawal/youki",
"path": "/src/namespaces.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn chart_data_to_prices(mut chart_data: ChartData) -> Vec<Price> {
if chart_data.indicators.quote.len() != 1 {
return vec![];
}
let quote = chart_data.indicators.quote.remove(0);
let timestamps = chart_data.timestamp;
izip!(
"e.close,
"e.volume,
... | code_fim | hard | {
"lang": "rust",
"repo": "MabezDev/tickrs",
"path": "/src/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let quote = chart_data.indicators.quote.remove(0);
let timestamps = chart_data.timestamp;
izip!(
"e.close,
"e.volume,
"e.high,
"e.low,
"e.open,
×tamps,
)
.map(|(c, v, h, l, o, t)| Price {
close: *c,
... | code_fim | hard | {
"lang": "rust",
"repo": "MabezDev/tickrs",
"path": "/src/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MabezDev/tickrs path: /src/common.rs
use api::{model::ChartData, Range};
use itertools::izip;
use std::time::Duration;
#[derive(PartialEq, Clone, Copy, PartialOrd)]
pub enum TimeFrame {
Day1,
Week1,
Month1,
Month3,
Month6,
Year1,
Year5,
}
impl TimeFrame {
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "MabezDev/tickrs",
"path": "/src/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let one = x.2;
//array type
let a = [1, 2, 3, 4, 5];
let b: [i32; 5] = [1, 2, 3, 4, 5];
let a = [3; 5]; //5 elements with value 3
let first = a[0];
let second = a[1];
let index = 10;
let element = a[index]; // runtime error
println!("The value of element i... | code_fim | medium | {
"lang": "rust",
"repo": "OICIRUAM73/rust-learning",
"path": "/variables/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OICIRUAM73/rust-learning path: /variables/src/main.rs
fn main() {
//mutability
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
//shadowing
let y = 5;
let y = y + 1;
let y = y + 2;
println!("The value o... | code_fim | hard | {
"lang": "rust",
"repo": "OICIRUAM73/rust-learning",
"path": "/variables/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> //tuple type
let tup: (i32, f64, u8) = (500, 6.4, 1);
let tup2 = (500, 6.4, 1);
let (x, y, z) = tup2;
println!("The value of y is: {}", y);
let x: (i32, f64, u8) = (500, 6.4, 1);
let five_hundred = x.0;
let six_point_four = x.1;
let one = x.2;
//array type
... | code_fim | hard | {
"lang": "rust",
"repo": "OICIRUAM73/rust-learning",
"path": "/variables/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.interprete_tokens = Some(Box::new(
move |stream, current_index, name, count| interprete_optional_arg(name, count, &String::from(short_name), &String::from(long_name), stream, current_index)));
self
}
pub fn assembled(self) -> ArgDefinition {
ArgDefinition ... | code_fim | hard | {
"lang": "rust",
"repo": "kilianhelmenstein/colinear",
"path": "/src/args/builder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kilianhelmenstein/colinear path: /src/args/builder.rs
use args::Count;
use args::ArgDefinition;
use args::ArgValue;
use tokens::Token;
pub struct ArgDefinitionBuilder {
name: &'static str,
count: Count,
interprete_tokens: Option<Box<for<'a> Fn(&'a [Token], usize, &'static str, &Cou... | code_fim | medium | {
"lang": "rust",
"repo": "kilianhelmenstein/colinear",
"path": "/src/args/builder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yurydelendik/wasmeval path: /examples/hello.rs
use anyhow::{bail, Error};
use std::fs;
use std::path::Path;
use std::rc::Rc;
use std::sync::Arc;
<|fim_suffix|> &self.0
}
fn call(&self, _stack: &mut [Val]) -> Result<(), Trap> {
println!("Hello, world!");
Ok(())
... | code_fim | hard | {
"lang": "rust",
"repo": "yurydelendik/wasmeval",
"path": "/examples/hello.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
fn call(&self, _stack: &mut [Val]) -> Result<(), Trap> {
println!("Hello, world!");
Ok(())
}
}
fn main() -> Result<(), Error> {
let bin = fs::read(Path::new("examples/hello.wasm")).expect("file data");
let module = Module::new(bin.into_boxed_slice())?... | code_fim | hard | {
"lang": "rust",
"repo": "yurydelendik/wasmeval",
"path": "/examples/hello.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self(Arc::new(FuncType {
params: Box::new([]),
returns: Box::new([]),
}))
}
}
impl Func for Callback {
fn ty(&self) -> &Arc<FuncType> {
&self.0
}
fn call(&self, _stack: &mut [Val]) -> Result<(), Trap> {
println!("Hello, world!");
... | code_fim | medium | {
"lang": "rust",
"repo": "yurydelendik/wasmeval",
"path": "/examples/hello.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Bad URL.
p.cargo("pkgid https://example.com/crates-io")
.with_status(101)
.with_stderr(
"\
error: package ID specification `https://example.com/crates-io` did not match any packages
Did you mean one of these?
crates-io@0.1.0
",
)
.run();
// Ba... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/tests/testsuite/pkgid.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/cargo path: /tests/testsuite/pkgid.rs
//! Tests for the `cargo pkgid` command.
use cargo_test_support::project;
use cargo_test_support::registry::Package;
#[cargo_test]
fn simple() {
Package::new("bar", "0.1.0").publish();
let p = project()
.file(
"Cargo.t... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/tests/testsuite/pkgid.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Copy> Transformable for Vec<Vec<T>> {
fn transpose(mut self) -> Self {
for y in 0 .. self.len() {
for x in 0 .. y {
let tmp = self[x][y];
self[x][y] = self[y][x];
self[y][x] = tmp;
}
}
self
}
... | code_fim | hard | {
"lang": "rust",
"repo": "honnza/drops",
"path": "/AOC2020/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: honnza/drops path: /AOC2020/main.rs
assert!(content_str.ends_with(if count == 1 {"bag"} else {"bags"}));
(count, &content_str[
count_len + 1 .. content_str.len() - (if count == 1 {4} else {5})
])
}).collect()
};
... | code_fim | hard | {
"lang": "rust",
"repo": "honnza/drops",
"path": "/AOC2020/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: honnza/drops path: /AOC2020/main.rs
= ") {
let mask_str = &line[7..];
bitmax = u64::from_str_radix(&mask_str.chars().map(|c|
if c == 'X' {'1'} else {c}
).collect::<String>(), 2).unwrap();
bitmin = u64::from_str_r... | code_fim | hard | {
"lang": "rust",
"repo": "honnza/drops",
"path": "/AOC2020/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
from_bytes(bytes).ok()
}
}
impl<V, E, P> FromPValue<V, E, P> for Vertex<V, E, P>
where
V: 'static + Writable,
E: 'static + Writable,
P: 'static + Writable + Eq,
{
fn from_pvalue(v: PValue<V, E, P>) -> Result<Self> {... | code_fim | hard | {
"lang": "rust",
"repo": "dgandhi17/gremlite",
"path": "/gremlite/src/graph/vertex.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgandhi17/gremlite path: /gremlite/src/graph/vertex.rs
use heed::{BytesDecode, BytesEncode};
use postcard::{from_bytes, to_stdvec};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use super::{
parameter::{FromPValue, PValue, ToPValue},
Id, Writable,
};
use crate::error::{Erro... | code_fim | hard | {
"lang": "rust",
"repo": "dgandhi17/gremlite",
"path": "/gremlite/src/graph/vertex.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/libstd/sys/windows/args.rs
#![allow(dead_code)] // runtime init functions not used during testing
use crate::ffi::OsString;
use crate::fmt;
use crate::os::windows::prelude::*;
use crate::path::PathBuf;
use crate::slice;
use crate::sys::c;
use crate::sys::window... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/mir-verifier",
"path": "/lib/libstd/sys/windows/args.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn single_words() {
chk("EXE one_word", &["EXE", "one_word"]);
chk("EXE a", &["EXE", "a"]);
chk("EXE 😅", &["EXE", "😅"]);
chk("EXE 😅🤦", &["EXE", "😅🤦"]);
}
#[test]
fn official_examples() {
chk(r#"EXE "abc" d e"#, &["EXE", "abc", "d",... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/mir-verifier",
"path": "/lib/libstd/sys/windows/args.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: d0iasm/rvemu path: /src/devices/uart_wasm.rs
//! The uart module contains the implementation of a universal asynchronous receiver-transmitter
//! (UART) for WebAssembly. The device is 16550a UART, which is used in the QEMU virt machine. See more information
//! in http://byterunner.com/16550.htm... | code_fim | hard | {
"lang": "rust",
"repo": "d0iasm/rvemu",
"path": "/src/devices/uart_wasm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Write a byte to the transmit holding register.
pub fn write(&mut self, index: u64, value: u8, size: u8) -> Result<(), Exception> {
if size != BYTE {
return Err(Exception::StoreAMOAccessFault);
}
match index {
UART_THR => {
self.w... | code_fim | hard | {
"lang": "rust",
"repo": "d0iasm/rvemu",
"path": "/src/devices/uart_wasm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
uart,
clock: 0,
not_null: false,
window: web_sys::window().expect("failed to get a global window object"),
}
}
/// Return true if the byte buffer in UART is full.
pub fn is_interrupting(&mut self) -> bool {
self.cl... | code_fim | hard | {
"lang": "rust",
"repo": "d0iasm/rvemu",
"path": "/src/devices/uart_wasm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sixilli/BackendExtravaganza path: /rust-backend/src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#![allow(proc_macro_derive_resolution_fallback)]
<|fim_suffix|>mod config;
mod schema;
mod api;
mod models;
fn main() {
config::rocket().0.launch();
}<|fim_middle|>#[macro_use] extern cr... | code_fim | hard | {
"lang": "rust",
"repo": "sixilli/BackendExtravaganza",
"path": "/rust-backend/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod config;
mod schema;
mod api;
mod models;
fn main() {
config::rocket().0.launch();
}<|fim_prefix|>// repo: sixilli/BackendExtravaganza path: /rust-backend/src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#![allow(proc_macro_derive_resolution_fallback)]
<|fim_middle|>#[macro_use] extern cr... | code_fim | hard | {
"lang": "rust",
"repo": "sixilli/BackendExtravaganza",
"path": "/rust-backend/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vishusandy/mazes path: /src/util/ordinal.rs
use crate::trans::major::Major;
use crate::util::{Coord, Horizontal, Index, RowSize, Vertical, Visit};
use parse_display::{Display, FromStr};
#[derive(Debug, Display, FromStr, Clone, Copy, PartialEq, Eq)]
pub enum Ordinal {
#[display("Northwest")]... | code_fim | hard | {
"lang": "rust",
"repo": "vishusandy/mazes",
"path": "/src/util/ordinal.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cur = self.cur;
if self.count == 4 {
self.count = 0;
self.cur = self.start;
None
} else {
self.count += 1;
self.cur = self.cur.inc_cw();
Some(cur)
}
}
}
impl Default for OrdinalIter {
fn def... | code_fim | hard | {
"lang": "rust",
"repo": "vishusandy/mazes",
"path": "/src/util/ordinal.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for num in stdin_handle.lines()
.map(|l| l.expect("Should be able to read stdin"))
.map(|s| s.parse().expect("Each line must be a u64")) {
h.record(num).unwrap();
}
let stdout = std::io::stdout();
let mut stdout_handle = stdout.lock();
if compression {... | code_fim | hard | {
"lang": "rust",
"repo": "marshallpierce/hdrsample",
"path": "/examples/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marshallpierce/hdrsample path: /examples/cli.rs
/// Reads numbers from stdin, one per line, and writes them to a serialized histogram on stdout.
extern crate hdrsample;
extern crate clap;
use std::io::BufRead;
use clap::{App, Arg, SubCommand};
use hdrsample::Histogram;
use hdrsample::seriali... | code_fim | hard | {
"lang": "rust",
"repo": "marshallpierce/hdrsample",
"path": "/examples/cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *outcome.borrow() {
RuleOutcome::Success => "ok".green(),
RuleOutcome::Failure => "FAILED".red(),
RuleOutcome::Undetermined => "UNDETERMINED".red(),
}
}
/// Summary of result statistics generated from aggregating `RuleOutcome`s
/// results for multiple Rule evaluatio... | code_fim | hard | {
"lang": "rust",
"repo": "nathanaschbacher/cargo-culture",
"path": "/cargo-culture-kit/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nathanaschbacher/cargo-culture path: /cargo-culture-kit/src/lib.rs
t-level property
//! that has a clear description and can be checked.
//!
//! # Examples
//!
//! `check_culture_default` is the easiest way to get started,
//! as it provides a thin wrapper around the core `check_culture`
//! fun... | code_fim | hard | {
"lang": "rust",
"repo": "nathanaschbacher/cargo-culture",
"path": "/cargo-culture-kit/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn evaluate(&self, _context: RuleContext) -> RuleOutcome {
use std::time::{SystemTime, UNIX_EPOCH};
let since_the_epoch = match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(t) => t,
Err(_) => return RuleOutcome::Undetermined,
... | code_fim | hard | {
"lang": "rust",
"repo": "nathanaschbacher/cargo-culture",
"path": "/cargo-culture-kit/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maximeborges/svd2rust_efm32gg990 path: /src/dma/chreqmasks.rs
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::CHREQMASKS {
#[doc = r" Writes to the register"]
#[inline]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,... | code_fim | hard | {
"lang": "rust",
"repo": "maximeborges/svd2rust_efm32gg990",
"path": "/src/dma/chreqmasks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>oc = r" Writes raw bits to the field"]
#[inline]
pub fn bit(self, value: bool) -> &'a mut W {
const MASK: bool = true;
const OFFSET: u8 = 11;
self.w.bits &= !((MASK as u32) << OFFSET);
self.w.bits |= ((value & MASK) as u32) << OFFSET;
self.w
}
}
impl W {... | code_fim | hard | {
"lang": "rust",
"repo": "maximeborges/svd2rust_efm32gg990",
"path": "/src/dma/chreqmasks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for ds in d {
let d_d: Vec<char> = ds.chars().collect();
if ds.len() > res.len() && in_dictionary(&s_d, &d_d) {
res = ds;
}
}
res
}
}<|fim_prefix|>// repo: arthurDz/algorithm-studies path:... | code_fim | hard | {
"lang": "rust",
"repo": "arthurDz/algorithm-studies",
"path": "/rust/longest_word_in_dictionary_through_deleting.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s_d: Vec<char> = s.chars().collect();
let mut res = "".to_string();
for ds in d {
let d_d: Vec<char> = ds.chars().collect();
if ds.len() > res.len() && in_dictionary(&s_d, &d_d) {
res = ds;
... | code_fim | hard | {
"lang": "rust",
"repo": "arthurDz/algorithm-studies",
"path": "/rust/longest_word_in_dictionary_through_deleting.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arthurDz/algorithm-studies path: /rust/longest_word_in_dictionary_through_deleting.rs
use std::cmp::Ordering;
impl Solution {
pub fn find_longest_word(s: String, d: Vec<String>) -> String {
let mut d = d;
d.sort_by(|a, b| match b.len().cmp(&a.len()) {
Ordering::E... | code_fim | hard | {
"lang": "rust",
"repo": "arthurDz/algorithm-studies",
"path": "/rust/longest_word_in_dictionary_through_deleting.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>crate::scoped::scope;
pub use crate::sleep::sleep;
pub use crate::yield_now::yield_now;<|fim_prefix|>// repo: Xudong-Huang/may path: /src/coroutine.rs
// re-export coroutine interface
pub use crate::cancel::trigger_cancel_panic;
pub use crate::coroutine_impl::{
current, is_coroutine, park, park_timeo... | code_fim | medium | {
"lang": "rust",
"repo": "Xudong-Huang/may",
"path": "/src/coroutine.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xudong-Huang/may path: /src/coroutine.rs
// re-export coroutine interface
pub use crate::cancel::trigger_cancel_panic;
pub use c<|fim_suffix|>Coroutine,
};
pub use crate::join::JoinHandle;
pub use crate::park::ParkError;
pub use crate::scoped::scope;
pub use crate::sleep::sleep;
pub use crate::y... | code_fim | medium | {
"lang": "rust",
"repo": "Xudong-Huang/may",
"path": "/src/coroutine.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: u4ium/ray-tracer path: /src/scene/object/parsers/obj/polygon/vertex.rs
use crate::scene::object::parsers::common::{float::parse_float, whitespace::tws};
use nom::{bytes::complete::tag, combinator::opt, sequence::tuple, IResult};
<|fim_suffix|> assert_eq!(
parse_vertex("v 0.123 -0.234... | code_fim | hard | {
"lang": "rust",
"repo": "u4ium/ray-tracer",
"path": "/src/scene/object/parsers/obj/polygon/vertex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((input, Vertex { x, y, z, w }))
}
#[test]
fn test_parse_vertex() {
assert_eq!(
parse_vertex("v 0.123 -0.234 2.345 1.0\r\n"),
Ok((
"",
Vertex {
x: 0.123,
y: -0.234,
z: 2.345,
w: 1.0,
... | code_fim | hard | {
"lang": "rust",
"repo": "u4ium/ray-tracer",
"path": "/src/scene/object/parsers/obj/polygon/vertex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (input, _) = tws(tag("v"))(input)?;
let (input, (x, y, z, w)) = tuple((
tws(parse_float),
tws(parse_float),
tws(parse_float),
opt(tws(parse_float)),
))(input)?;
let w = w.unwrap_or(1.0);
Ok((input, Vertex { x, y, z, w }))
}
#[test]
fn test_parse_ve... | code_fim | medium | {
"lang": "rust",
"repo": "u4ium/ray-tracer",
"path": "/src/scene/object/parsers/obj/polygon/vertex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Calculate the length of the hypotenuse of a right-angle triangle given
/// legs of length `x` and `y`.
fn hypot(self, other: Self) -> Self;
/// Returns `e^(self) - 1` in a way that is accurate even if the
/// number is close to zero.
fn exp_m1(self) -> Self;
}
/// Raise a nu... | code_fim | medium | {
"lang": "rust",
"repo": "Coder-256/num-traits-flexible",
"path": "/src/ops/exp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Coder-256/num-traits-flexible path: /src/ops/exp.rs
/// Exponential functions.
pub trait Exponential {
/// Take the square root of a number.
///
/// Returns NaN if `self` is a negative floating-point number.
///
/// # Panics
///
/// If the implementing type doesn't ... | code_fim | hard | {
"lang": "rust",
"repo": "Coder-256/num-traits-flexible",
"path": "/src/ops/exp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: taotao54321/naitou_clone path: /src/your_move.rs
//!===================================================================
//! your 側の指し手を扱うモジュール。
//!
//! 原作をそこそこ忠実に移植。
//! 原作では your 側の打ち歩詰めは許される。また、your 側は自殺手を指して負けることができる。
//!
//! your 側では指し手を以下のように分類する:
//!
//! * pseudo-legal: 原作でプレイヤーが実際に指せる手の... | code_fim | hard | {
"lang": "rust",
"repo": "taotao54321/naitou_clone",
"path": "/src/your_move.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 二歩チェック
if matches!(pt, Piece::Pawn) {
let pawn_mask = PawnMask::from_board_side(pos.board(), your);
if pawn_mask.test(dst.x().get()) {
return false;
}
}
true
}
/// your 側の王手回避手を列挙する。
/// 成れる場合は必ず成る(原作での暗黙の仮定)。
/// 実際には王手を回避しない手も含まれるので、呼び出し側で適宜調べること。... | code_fim | hard | {
"lang": "rust",
"repo": "taotao54321/naitou_clone",
"path": "/src/your_move.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: webdesus/nom-lua53 path: /src/name.rs
use std::fmt;
use utils::{alpha_or_underscore, is_alphanum_or_underscore};
use nom::{self, IResult};
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct VarName<'a>(pub &'a [u8]);
// Print varnames as utf8 strings. After all, they are required to be ASCII
im... | code_fim | medium | {
"lang": "rust",
"repo": "webdesus/nom-lua53",
"path": "/src/name.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>named!(reserved, alt!(
tag!("and") | tag!("break") | tag!("do") | tag!("else") | tag!("elseif") | tag!("end") |
tag!("false") | tag!("for") | tag!("function") | tag!("goto") | tag!("if") | tag!("in") |
tag!("local") | tag!("nil") | tag!("not") | tag!("or") | tag!("repeat")| tag!("return") |
... | code_fim | medium | {
"lang": "rust",
"repo": "webdesus/nom-lua53",
"path": "/src/name.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yaozijian/mqttlib path: /src/tests/pkt_connect.rs
use std::io::{BufReader, BufWriter};
use bincode;
use crate::head::Head;
use crate::mqtt_packet::MqttPacket;
use crate::pkt_connect::PktConnect;
use crate::raw_packet::RawPacket;
use crate::utils::*;
#[test]
fn pkt_connect_read_write() -> binc... | code_fim | hard | {
"lang": "rust",
"repo": "yaozijian/mqttlib",
"path": "/src/tests/pkt_connect.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let MqttPacket::MqttPktConnect(pkt2) = pkt2 {
test_packet_equal(&pkt1, &pkt2);
Ok(())
} else {
invalid_data_error()
}
}
fn test_head_equal(head1: &Head, head2: &Head) {
assert_eq!(head1.pkt_type, head2.pkt_type);
assert_eq!(head1.pkt_flags, head2.pkt_flags);
assert_eq!(head1.body_len, head... | code_fim | hard | {
"lang": "rust",
"repo": "yaozijian/mqttlib",
"path": "/src/tests/pkt_connect.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: r-wheeler/tf_proto path: /src/protos/versions.rs
// This file is generated by rust-protobuf 2.6.2. Do not edit
// @generated
// https://github.com/Manishearth/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy)]
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(box_pointers)]
#![allow... | code_fim | hard | {
"lang": "rust",
"repo": "r-wheeler/tf_proto",
"path": "/src/protos/versions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> static mut instance: ::protobuf::lazy::Lazy<VersionDef> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const VersionDef,
};
unsafe {
instance.get(VersionDef::new)
}
}
}
impl ::protobuf::Clear for VersionDef ... | code_fim | hard | {
"lang": "rust",
"repo": "r-wheeler/tf_proto",
"path": "/src/protos/versions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for VersionDef {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\... | code_fim | hard | {
"lang": "rust",
"repo": "r-wheeler/tf_proto",
"path": "/src/protos/versions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Meyermagic/met path: /src/common.rs
/*
pub struct Argument {
short: char,
long: &'static str,
short_desc: &'static str,
long_desc: &'static str,
}
pub struct Command {
name: &'static str,
args: Vec<Argument>,
subcommands: Vec<Command>,
}
*/
use std::io;
use std::io::fs;
pub trait Met... | code_fim | medium | {
"lang": "rust",
"repo": "Meyermagic/met",
"path": "/src/common.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// Recursively copy the contents of a directory to another directory
pub fn copy_recursive(from: &Path, to: &Path) {
for entry in fs::walk_dir(from).unwrap() {
let path = entry.path_relative_from(from).unwrap();
match entry.lstat().unwrap().kind {
io::TypeFile => {
fs::copy(&from.join(&path),... | code_fim | medium | {
"lang": "rust",
"repo": "Meyermagic/met",
"path": "/src/common.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tracing::trace!("JsLoader.load: loaded");
let program = if fm.name.to_string().contains("node_modules") {
let comments = self.compiler.comments().clone();
let program = self.compiler.parse_js(
fm.clone(),
handler,
Es... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_node_bundler/src/loaders/swc.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_node_bundler/src/loaders/swc.rs
use std::{collections::HashMap, env, sync::Arc};
use anyhow::{bail, Context, Error};
use helpers::Helpers;
use swc::{
config::{GlobalInliningPassEnvs, InputSourceMap, IsModule, JscConfig, TransformConfig},
try_with_handle... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_node_bundler/src/loaders/swc.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Sleep goal update response.
#[derive(Deserialize, Debug)]
pub struct Response {
pub goal: super::Goal,
}<|fim_prefix|>// repo: mvertescher/fitbit-web-api-rs path: /src/sleep/goals/update.rs
//! Update sleep goals.
use serde_derive::{Deserialize, Serialize};
<|fim_middle|>/// Sleep goal update r... | code_fim | medium | {
"lang": "rust",
"repo": "mvertescher/fitbit-web-api-rs",
"path": "/src/sleep/goals/update.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvertescher/fitbit-web-api-rs path: /src/sleep/goals/update.rs
//! Update sleep goals.
use serde_derive::{Deserialize, Serialize};
<|fim_suffix|>/// Sleep goal update response.
#[derive(Deserialize, Debug)]
pub struct Response {
pub goal: super::Goal,
}<|fim_middle|>/// Sleep goal update r... | code_fim | medium | {
"lang": "rust",
"repo": "mvertescher/fitbit-web-api-rs",
"path": "/src/sleep/goals/update.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_input(reader: &io::Stdin) -> String {
let mut buffer = String::new();
reader.read_line(&mut buffer).ok().unwrap();
buffer.trim().to_string()
}<|fim_prefix|>// repo: fedeoliv/hackerrank-rust path: /algorithms/bit-manipulation/maximizing-xor/src/main.rs
// Problem: https://www.hackerr... | code_fim | medium | {
"lang": "rust",
"repo": "fedeoliv/hackerrank-rust",
"path": "/algorithms/bit-manipulation/maximizing-xor/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fedeoliv/hackerrank-rust path: /algorithms/bit-manipulation/maximizing-xor/src/main.rs
// Problem: https://www.hackerrank.com/challenges/maximizing-xor/problem
// Time: O(N*M); N = l and M = r
// Space: O(1)
use std::io;
fn find_max_xor(l: u16, r: u16) -> u16 {
<|fim_suffix|> let reader: io... | code_fim | hard | {
"lang": "rust",
"repo": "fedeoliv/hackerrank-rust",
"path": "/algorithms/bit-manipulation/maximizing-xor/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in l..(r + 1) {
for j in (i + 1)..(r + 1) {
let result: u16 = i ^ j;
if result > max_xor {
max_xor = result;
}
}
}
max_xor
}
fn main() {
let reader: io::Stdin = io::stdin();
let l: u16 = read_input(&reader).p... | code_fim | medium | {
"lang": "rust",
"repo": "fedeoliv/hackerrank-rust",
"path": "/algorithms/bit-manipulation/maximizing-xor/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanlth/Fluid-Solver path: /src/linear_solvers.rs
use std::mem;
use field::Field;
use scoped_threadpool::Pool;
// 0 1 2
// 0 1 2 0 1 2 0 1 2
// 0 1 2 3 4 5 6 7 8
//
//1 4 -1 0 -1 0 0 0 0 0
//2 -1 4 -1 0 -1 0 0 0 0
//3 0 -1 4 0 0 -1 0 0... | code_fim | hard | {
"lang": "rust",
"repo": "seanlth/Fluid-Solver",
"path": "/src/linear_solvers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let temp = &mut x.clone();
let x_clone = &x.clone();
let w = x.columns;
let h = x.rows;
let threads = 8;
let size = (w * h) / threads;
let mut pool = Pool::new(threads as u32);
for _ in 0..limit {
let mut j = 0;
let _ = pool.scoped(|scope| {
... | code_fim | hard | {
"lang": "rust",
"repo": "seanlth/Fluid-Solver",
"path": "/src/linear_solvers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = ctx.get_raw(0);
match value {
ValueRef::Null => stdev.add_null(),
ValueRef::Integer(i) => stdev.add(i as f64),
ValueRef::Real(f) => stdev.add(f),
ValueRef::Text(_) | ValueRef::Blob(_) => {
return Result::Err(rusqli... | code_fim | hard | {
"lang": "rust",
"repo": "hderms/qsv",
"path": "/src/db/functions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hderms/qsv path: /src/db/functions.rs
use rusqlite::functions::{Aggregate, Context, FunctionFlags};
use rusqlite::types::ValueRef;
use rusqlite::{Connection, Result};
use stats::OnlineStats;
pub(crate) fn add_udfs(connection: &Connection) -> Result<()> {
connection.create_scalar_function(
... | code_fim | hard | {
"lang": "rust",
"repo": "hderms/qsv",
"path": "/src/db/functions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = ctx.get_raw(0);
match value {
ValueRef::Null => mean.add_null(),
ValueRef::Integer(i) => mean.add(i as f64),
ValueRef::Real(f) => mean.add(f),
ValueRef::Text(_) | ValueRef::Blob(_) => {
return Result::Err(rusqlite:... | code_fim | hard | {
"lang": "rust",
"repo": "hderms/qsv",
"path": "/src/db/functions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Global clock struct
lazy_static! {
pub static ref CLK: Mutex<Clock> = Mutex::new(Clock {
pinwheel: (common::CLOCK_FREQUENCY / 10) - 1,
pindex: 0,
system_time: 0,
});
}
/// Initialize the ol clock
pub fn _clk_init() {
let mut divisor: i32;
println!("CLOCK");
... | code_fim | hard | {
"lang": "rust",
"repo": "jds8899/UROS",
"path": "/src/clock.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jds8899/UROS path: /src/clock.rs
///
/// clock.rs
///
/// Author: Jonathan Schenk
///
/// Clock module
///
////////////////////////////////////////////////////////////////////////////////
use core::ptr;
use core::ffi;
use spin::Mutex;
use lazy_static::lazy_static;
use crate::println;
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "jds8899/UROS",
"path": "/src/clock.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ///
/// Deals with the printing of the pinwheel
///
pub fn pin_deal(&mut self) {
self.pinwheel += 1;
if(self.pinwheel == (common::CLOCK_FREQUENCY / 10)) {
self.pinwheel = 0;
self.pindex += 1;
let ind = (self.pindex & 3) as usize;
... | code_fim | hard | {
"lang": "rust",
"repo": "jds8899/UROS",
"path": "/src/clock.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Export selected types from modules.
pub use future_help::log_errors;
pub use labels::{Endpoint, NodeId, NodeLinkId};
pub use link::Link;
pub use quic_link::Link as QuicLink;
pub use router::{generate_node_id, Router, RouterOptions};
pub use runtime::{run, spawn, wait_until};
pub use stream_framer::*;<|... | code_fim | hard | {
"lang": "rust",
"repo": "xyuan/fuchsia",
"path": "/src/connectivity/overnet/lib/core/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xyuan/fuchsia path: /src/connectivity/overnet/lib/core/src/lib.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Main Overnet functionality.
<|fim_suffix|>mod async_quic;
mo... | code_fim | medium | {
"lang": "rust",
"repo": "xyuan/fuchsia",
"path": "/src/connectivity/overnet/lib/core/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZcashFoundation/zebra path: /zebra-consensus/src/primitives.rs
//! Asynchronous verification of cryptographic primitives.
use tokio::sync::oneshot::error::RecvError;
use crate::BoxError;
pub mod ed25519;
pub mod groth16;
pub mod halo2;
pub mod redjubjub;
pub mod redpallas;
/// The maximum ba... | code_fim | hard | {
"lang": "rust",
"repo": "ZcashFoundation/zebra",
"path": "/zebra-consensus/src/primitives.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Fires off a task into the Rayon threadpool, awaits the result through a oneshot channel,
/// then converts the error to a [`BoxError`].
pub async fn spawn_fifo_and_convert<
E: 'static + std::error::Error + Into<BoxError> + Sync + Send,
F: 'static + FnOnce() -> Result<(), E> + Send,
>(
f: F... | code_fim | medium | {
"lang": "rust",
"repo": "ZcashFoundation/zebra",
"path": "/zebra-consensus/src/primitives.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl IoCostReport {
pub fn read(devnr: (u32, u32)) -> Result<Self> {
let kf = read_cgroup_nested_keyed_file("/sys/fs/cgroup/io.stat")?;
let vrate = match kf.get(&format!("{}:{}", devnr.0, devnr.1)) {
Some(map) => map
.get("cost.vrate")
.map(S... | code_fim | hard | {
"lang": "rust",
"repo": "liguang-li/resctl-demo",
"path": "/rd-agent-intf/src/report.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liguang-li/resctl-demo path: /rd-agent-intf/src/report.rs
sideloader.svc.name: sideloader systemd service name
// sideloader.svc.state: sideloader systemd service state
// sideloader.sysconf_warnings: sideloader system configuration warnings
// sideloader.overload: sideloader is in overloade... | code_fim | hard | {
"lang": "rust",
"repo": "liguang-li/resctl-demo",
"path": "/rd-agent-intf/src/report.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<I: Into<usize>> Load<I, u32> for Memory {
fn load_into(&self, index: I, value: &mut u32) {
let index = index.into();
*value = (self.0[index] as u32) & ((self.0[index + 1] as u32) << 8)
& ((self.0[index + 2] as u32) << 16)
& ((self.0[index + 3] as u32) << 24... | code_fim | hard | {
"lang": "rust",
"repo": "scottwillmoore/chip16",
"path": "/src_old/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scottwillmoore/chip16 path: /src_old/memory.rs
use std::mem;
pub trait Load<I, V> {
fn load(&self, index: I) -> V {
let mut value;
unsafe {
value = mem::uninitialized();
}
self.load_into(index, &mut value);
value
}
fn load_into(&s... | code_fim | hard | {
"lang": "rust",
"repo": "scottwillmoore/chip16",
"path": "/src_old/memory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<I: Into<usize>> Load<I, u32> for VideoMemory {
fn load_into(&self, index: I, value: &mut u32) {
let index = index.into();
*value = (self.0[index] as u32) & ((self.0[index + 1] as u32) << 8)
& ((self.0[index + 2] as u32) << 16)
& ((self.0[index + 3] as u32) ... | code_fim | hard | {
"lang": "rust",
"repo": "scottwillmoore/chip16",
"path": "/src_old/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isabella232/rust-png path: /png-sys/build.rs
use std::env;
use std::path::PathBuf;
use std::process::Command;
use std::process::Stdio;
fn main() {
let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
if host != target {
if env::var_os("CC").is_no... | code_fim | medium | {
"lang": "rust",
"repo": "isabella232/rust-png",
"path": "/png-sys/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run(cmd: &mut Command) {
println!("running: {:?}", cmd);
assert!(cmd.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
.unwrap()
.success());
}<|fim_prefix|>// repo: isabella232/rust-png path: /png-sys/build.rs
use std::env... | code_fim | medium | {
"lang": "rust",
"repo": "isabella232/rust-png",
"path": "/png-sys/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/usb/ep7_fifo_config.rs
#[doc = "Register `ep7_fifo_config` reader"]
pub struct R(crate::R<EP7_FIFO_CONFIG_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<EP7_FIFO_CONFIG_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/usb/ep7_fifo_config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `ep7_dma_tx_en` writer - "]
pub struct EP7_DMA_TX_EN_W<'a> {
w: &'a mut W,
}
impl<'a> EP7_DMA_TX_EN_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the fiel... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/usb/ep7_fifo_config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `ep7_tx_fifo_underflow` writer - "]
pub struct EP7_TX_FIFO_UNDERFLOW_W<'a> {
w: &'a mut W,
}
impl<'a> EP7_TX_FIFO_UNDERFLOW_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/usb/ep7_fifo_config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.