text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> W(writer)
}
}
#[doc = "Field `IEPTXRSAR` reader - IN endpoint FIFO4 transmit RAM start address"]
pub type IEPTXRSAR_R = crate::FieldReader<u16, u16>;
#[doc = "Field `IEPTXRSAR` writer - IN endpoint FIFO4 transmit RAM start address"]
pub type IEPTXRSAR_W<'a, const O: u8> =
crate::FieldWrite... | code_fim | hard | {
"lang": "rust",
"repo": "riscv-rust/gd32vf103-pac",
"path": "/src/usbfs_global/diep3tflen.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> //unsigned 32-bit integer variables
let mut serving: u32 = 0;
let mut timer: u32 = 0;
let mut seats: u32 = 0;
//Begin procedures
}
}
}<|fim_prefix|>// repo: HarmonEpsilon/Restaurant-rs path: /src/restaurant.rs
pub mod r... | code_fim | hard | {
"lang": "rust",
"repo": "HarmonEpsilon/Restaurant-rs",
"path": "/src/restaurant.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl Restaurant {
pub fn get_input() {
//string variables
let mut server_id: String;
let mut name: String;
let mut reservation: String;
let mut id: String;
let mut buffer_in: String;
//unsigned 32-bit integer ... | code_fim | medium | {
"lang": "rust",
"repo": "HarmonEpsilon/Restaurant-rs",
"path": "/src/restaurant.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HarmonEpsilon/Restaurant-rs path: /src/restaurant.rs
pub mod restaurant {
extern crate input_stream;
use dlist::dlist::Dlist;
use party::party::Party;
use table::table::Table;
use std::string::String;
use std::io;
use self::input_stream::InputStream;
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "HarmonEpsilon/Restaurant-rs",
"path": "/src/restaurant.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let vel_iter = velocities.iterate();
let acc_iter = accelerations.iterate();
for (vel, acc) in IterTuple::from((vel_iter, acc_iter)) {
vel.value += acc.value;
}
}
}<|fim_prefix|>// repo: Kailari/kokonaisuus path: /src/systems/apply_acceleration.rs
use crat... | code_fim | medium | {
"lang": "rust",
"repo": "Kailari/kokonaisuus",
"path": "/src/systems/apply_acceleration.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kailari/kokonaisuus path: /src/systems/apply_acceleration.rs
use crate::components::{AccelerationComponent, VelocityComponent};
use crate::iter::IterTuple;
use crate::storage::{Read, Write};
use crate::systems::System;
pub struct ApplyAccelerationSystem;
<|fim_suffix|> let vel_iter = ve... | code_fim | hard | {
"lang": "rust",
"repo": "Kailari/kokonaisuus",
"path": "/src/systems/apply_acceleration.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_minifier/src/compress/pure/strings.rs
_ecma_ast::*;
use swc_ecma_utils::{ExprExt, Type, Value};
use Value::Known;
use super::Pure;
impl Pure<'_> {
/// This only handles `'foo' + ('bar' + baz) because others are handled by
/// expression simplifier... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_minifier/src/compress/pure/strings.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_minifier/src/compress/pure/strings.rs
@ BinExpr {
op: op!(bin, "+"), ..
},
) => (e.span, &mut *e.left, &mut *r.left, &mut r.right),
_ => return,
},
_ => ret... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_minifier/src/compress/pure/strings.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let e = e.exprs[idx / 2].take();
new_tpl.exprs.push(e);
}
}
}
_ => {
let s = Atom::from(&*cur_str_value);
... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_minifier/src/compress/pure/strings.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AsyncRead for TlsStream {
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context,
buf: &mut ReadBuf,
) -> Poll<io::Result<()>> {
let me = self.get_mut();
macro_rules! poll_handshake {
($inner: expr) => {
match ready!(Pin::new($... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/crates/sidevm/host-runtime/src/tls.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let me = self.get_mut();
macro_rules! poll_shutdown {
($stream: expr) => {{
let rv = Pin::new($stream).poll_shutdown(cx);
if let Poll::Ready(_) = &rv {
*me = Self::Closed;
}
rv
}};
... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/crates/sidevm/host-runtime/src/tls.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phala-Network/phala-blockchain path: /crates/sidevm/host-runtime/src/tls.rs
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use futures::ready;
use once_cell::sync::Lazy;
use rustls_pemfile::Item;
use sidevm_env::tls::TlsServerConfig;... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/crates/sidevm/host-runtime/src/tls.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KiKoS0/ray-tracer path: /src/math/mod.rs
pub mod ray;
pub mod sphere;
pub mod vec3;
pub use self::ray::Ray;
pub use self::vec3::Vec3;
use super::rand::random;
use core::ops::Add;
use core::ops::Mul;
extern crate rand_distr;
use rand::Rng;
use rand_distr::{Distribution, UnitBall};
pub type Poi... | code_fim | hard | {
"lang": "rust",
"repo": "KiKoS0/ray-tracer",
"path": "/src/math/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline]
pub fn schlick(cosine: f64, ref_idx: f64) -> f64 {
let mut r0 = (1.0 - ref_idx) / (1.0 + ref_idx);
r0 = r0.powi(2);
r0 + (1.0 - r0) * (1.0 - cosine).powi(5)
}
mod tests {
use super::random_in_unit_sphere;
use std::io::Write;
#[test]
fn random_point() {
// let... | code_fim | hard | {
"lang": "rust",
"repo": "KiKoS0/ray-tracer",
"path": "/src/math/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cam-parra/libsovtoken path: /libsovtoken/src/logic/set_fees.rs
//! This module is for ???
use utils::ErrorCode;
use libc::c_char;
use logic::config::set_fees_config::{SetFees, SetFeesMap};
use logic::did::Did;
use serde_json;
use utils::constants::general::{JsonCallback, JsonCallbackUnwrapped};... | code_fim | hard | {
"lang": "rust",
"repo": "cam-parra/libsovtoken",
"path": "/libsovtoken/src/logic/set_fees.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let invalid_fees = json_c_pointer!({
"XFER_PUBLIC": 5,
"3": 1,
});
let (_, fees, _) = call_deserialize_inputs(None, Some(invalid_fees), None).unwrap();
assert_eq!(fees.fees.len(), 2);
assert_eq!(fees.fees.get("10001"), Some(&5));
as... | code_fim | hard | {
"lang": "rust",
"repo": "cam-parra/libsovtoken",
"path": "/libsovtoken/src/logic/set_fees.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CryZe/libtww path: /src/link/item.rs
macro_rules! items {
($($name:ident: $id:expr)*) => {
$(
pub const $name: u8 = $id;
)*
}
}
items! {
HEART_DROP: 0x00
GREEN_RUPEE_DROP: 0x01
BLUE_RUPEE_DROP: 0x02
YELLOW_RUPEE_DROP: 0x03
RED_RUPEE_DROP: ... | code_fim | hard | {
"lang": "rust",
"repo": "CryZe/libtww",
"path": "/src/link/item.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> GREEN_CHU_JELLY: 0x4A
BLUE_CHU_JELLY: 0x4B
MAP: 0x4C
COMPASS: 0x4D
BIG_KEY: 0x4E
EMPTY_BOTTLE: 0x50
RED_POTION: 0x51
GREEN_POTION: 0x52
BLUE_POTION: 0x53
ELIXIR_SOUP_HALF: 0x54
ELIXIR_SOUP: 0x55
WATER: 0x56
FAIRY: 0x57
FOREST_FIREFLY: 0x58
FOREST_W... | code_fim | hard | {
"lang": "rust",
"repo": "CryZe/libtww",
"path": "/src/link/item.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aggresss/playground-rust path: /tmp/examples/tmp010.rs
// Reference: https://blog.csdn.net/linysuccess/article/details/124939459
use std::{
cell::RefCell,
rc::Rc, vec,
};
<|fim_suffix|>pub fn inorder_traverse(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {
fn dfs(root: Option<Rc... | code_fim | hard | {
"lang": "rust",
"repo": "aggresss/playground-rust",
"path": "/tmp/examples/tmp010.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s1: TreeNode = TreeNode::new(2);
let s2: TreeNode = TreeNode::new(1);
let s3: TreeNode = TreeNode::new(3);
s1.left = Some(Rc::new(RefCell::new(s2)));
s1.right = Some(Rc::new(RefCell::new(s3)));
let root = Some(Rc::new(RefCell::new(s1)));
println!("{:?}", inorder_travers... | code_fim | medium | {
"lang": "rust",
"repo": "aggresss/playground-rust",
"path": "/tmp/examples/tmp010.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(x) = root {
dfs(x.borrow().left.clone(), list);
list.push(x.borrow().val);
dfs(x.borrow().right.clone(), list);
}
}
let mut list: Vec<i32> = vec![];
dfs(root, &mut list);
list
}
fn main() {
let mut s1: TreeNode = TreeNode... | code_fim | medium | {
"lang": "rust",
"repo": "aggresss/playground-rust",
"path": "/tmp/examples/tmp010.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aakhtar8/Quarter1_Batch3 path: /jan26/fileread2/src/main.rs
use std::io;
use std::fs;
fn read_username_from_file() -> Result<String, io::Error> {
<|fim_suffix|> let data = read_username_from_file();
println!("{:?}",data);
let username = match data {
Ok(s) => s,
E... | code_fim | easy | {
"lang": "rust",
"repo": "aakhtar8/Quarter1_Batch3",
"path": "/jan26/fileread2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = read_username_from_file();
println!("{:?}",data);
let username = match data {
Ok(s) => s,
Err(_) => "".to_string(),
};
println!("{}", username);
}<|fim_prefix|>// repo: aakhtar8/Quarter1_Batch3 path: /jan26/fileread2/src/main.rs
use std::io;
use std::fs... | code_fim | easy | {
"lang": "rust",
"repo": "aakhtar8/Quarter1_Batch3",
"path": "/jan26/fileread2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmilata/ektoboat path: /src/model.rs
use crate::util;
use crate::youtube;
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Album {
#[serde(skip)]
pub url: String,
#[serde(sk... | code_fim | hard | {
"lang": "rust",
"repo": "mmilata/ektoboat",
"path": "/src/model.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // relative to mp3_subdir
#[serde(skip_serializing_if = "Option::is_none")]
pub mp3_file: Option<PathBuf>,
// relative to video_subdir
#[serde(skip_serializing_if = "Option::is_none")]
pub video_file: Option<PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "mmilata/ektoboat",
"path": "/src/model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn blacklist() {
let black_artists = vec!["donald duck", "agh[0o]ri tantrik"];
let black_labels = vec!["sony", "sonic tantra .*", "supraphon"];
let blacklist = Blacklist::new(black_artists, black_labels).unwrap();
let album = Album {
url: "https... | code_fim | hard | {
"lang": "rust",
"repo": "mmilata/ektoboat",
"path": "/src/model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Show device info
println!("== Device info ==\n");
let hweui = rn.hweui().expect("Could not read hweui");
println!(" HW-EUI: {}", hweui);
let model = rn.model().expect("Could not read model");
println!(" Model: {:?}", model);
let version = rn.version().expect("Could ... | code_fim | medium | {
"lang": "rust",
"repo": "dbrgn/rn2xx3-rs",
"path": "/examples/show_info.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dbrgn/rn2xx3-rs path: /examples/show_info.rs
mod common;
use std::env;
use env_logger;
fn main() {
env_logger::init();
let args: Vec<String> = env::args().collect();
if args.len() != 2 {
println!("Usage: {} <path-to-serial>", args[0]);
println!("Example: {} /dev/t... | code_fim | medium | {
"lang": "rust",
"repo": "dbrgn/rn2xx3-rs",
"path": "/examples/show_info.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marccarre/project-euler-rust path: /src/iterators/mod.rs
// Make Fibonacci visible as part of the iterators module:
mod fibonacci;
pub <|fim_suffix|>s part of the iterators module:
mod integers;
pub use self::integers::Integers;<|fim_middle|>use self::fibonacci::Fibonacci;
// Make Primes visible... | code_fim | medium | {
"lang": "rust",
"repo": "marccarre/project-euler-rust",
"path": "/src/iterators/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>s module:
mod primes;
pub use self::primes::Primes;
// Make Integers visible as part of the iterators module:
mod integers;
pub use self::integers::Integers;<|fim_prefix|>// repo: marccarre/project-euler-rust path: /src/iterators/mod.rs
// Make Fibonacci visible as part of the iterators module:
mod fibon... | code_fim | medium | {
"lang": "rust",
"repo": "marccarre/project-euler-rust",
"path": "/src/iterators/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-can3/src/mb3_64b_word6.rs
#[doc = "Reader of register MB3_64B_WORD6"]
pub type R = crate::R<u32, super::MB3_64B_WORD6>;
#[doc = "Writer for register MB3_64B_WORD6"]
pub type W = crate::W<u32, super::MB3_64B_WORD6>;
#[doc = "Register MB3_64B_WORD6... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-can3/src/mb3_64b_word6.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: patchedsoul/althea_rs path: /rita/src/rita_common/debt_keeper/mod.rs
client gateway corner case, see rita client traffic watcher for more
/// details. This updates a debt identity matching only ip address and eth address.
#[derive(Message)]
pub struct WgKeyInsensitiveTrafficUpdate {
pub tra... | code_fim | hard | {
"lang": "rust",
"repo": "patchedsoul/althea_rs",
"path": "/rita/src/rita_common/debt_keeper/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // more traffic
for _ in 0..100 {
d.traffic_update(&ident, Int256::from(100))
}
// another payment, to make sure the state was all set right after
// the failure then success
assert_eq!(
d.send_update(&ident).unwrap(),
Deb... | code_fim | hard | {
"lang": "rust",
"repo": "patchedsoul/althea_rs",
"path": "/rita/src/rita_common/debt_keeper/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if debt_limit_enabled {
debt_data.debt = debt_limit(debt_data.debt.clone(), close_threshold.clone());
}
match (should_close, should_pay, payment_in_flight) {
(true, true, _) => panic!("Close threshold is less than pay threshold!"),
(true, false,... | code_fim | hard | {
"lang": "rust",
"repo": "patchedsoul/althea_rs",
"path": "/rita/src/rita_common/debt_keeper/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/leetcode-rust-7 path: /benches/bench_sorting.rs
//! cargo bench --bench bench_sorting
#![feature(test)]
extern crate algorithm;
extern crate test;
use algorithm::code_snippets::sorting::{
bubble_sort, my_quick_sort, random_numbers_test_case, selection_sort,
};
#[bench]
fn bench_bubb... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/leetcode-rust-7",
"path": "/benches/bench_sorting.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> bencher.iter(|| {
let mut nums = random_numbers_test_case();
nums.sort_unstable();
//assert!(nums.is_sorted());
});
}<|fim_prefix|>// repo: isgasho/leetcode-rust-7 path: /benches/bench_sorting.rs
//! cargo bench --bench bench_sorting
#![feature(test)]
extern crate algorith... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/leetcode-rust-7",
"path": "/benches/bench_sorting.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShZh-libraries/szimg path: /examples/barnsley_fern.rs
use rand::Rng;
use szimg::netpbm::{save_ppm, Mode};
const WIDTH: usize = 600;
const HEIGHT: usize = 600;
const ITER_TIME: usize = 100000;
// See https://en.wikipedia.org/wiki/Barnsley_fern for more details
fn iter(rng: &mut rand::prelude::T... | code_fim | hard | {
"lang": "rust",
"repo": "ShZh-libraries/szimg",
"path": "/examples/barnsley_fern.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pair = (0., 0.);
for _ in 0..ITER_TIME {
// Map to the payload array
let pos = (
80. * pair.0 + WIDTH as f32 / 2.,
HEIGHT as f32 - (50. * pair.1 + 50.),
);
data[pos.1 as usize][pos.0 as usize][1] = 255;
pair = iter(&mut rng, ... | code_fim | medium | {
"lang": "rust",
"repo": "ShZh-libraries/szimg",
"path": "/examples/barnsley_fern.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aconbere/gbe-v2 path: /src/instruction.rs
ibbles of an 8bit number as individual
* decimal numerals.
*
* For example 49 would be represented as
*
* 0100_1001
*
* the DAA function thus takes the A register and maps its value into BCD
*
*/
pub fn daa() -> Instruction {
Instruction::no... | code_fim | hard | {
"lang": "rust",
"repo": "aconbere/gbe-v2",
"path": "/src/instruction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/* Shift the contents of register r left into Carry. LSB of n set to 0.
*/
pub fn sla_r8(r: Registers8) -> Instruction {
Instruction::no_args(
format!("SLA R8 | {:?}", r),
Box::new(move |cpu: &mut CPU, _arg: u16| {
let value = cpu.registers.get8(r);
let out = h... | code_fim | hard | {
"lang": "rust",
"repo": "aconbere/gbe-v2",
"path": "/src/instruction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_dec_r8() {
let mut cpu = test_cpu();
cpu.registers.set8(Registers8::L, 0x01);
cpu.execute(&dec_r8(Registers8::L));
assert_eq!(cpu.registers.get8(Registers8::L), 0x00);
assert_eq!(cpu.registers.get_flag(Flag::Z), true);
assert_eq!(... | code_fim | hard | {
"lang": "rust",
"repo": "aconbere/gbe-v2",
"path": "/src/instruction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { &mut *self.ptr }
}
}
impl AVPacketBoxed {
pub fn from_ptr(ptr: *mut AVPacket) -> Self {
Self { ptr }
}
pub fn as_ptr(&self) -> *const AVPacket {
self.ptr as *const AVPacket
}
pub fn as_mut_ptr(&mut self) -> *mut AVPacket {
self.ptr
}
... | code_fim | hard | {
"lang": "rust",
"repo": "hlima/ffav-rs-hml",
"path": "/src/easy/owned.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hlima/ffav-rs-hml path: /src/easy/owned.rs
ref_mut(&mut self) -> &mut AVBSFContext {
unsafe { &mut *self.ptr }
}
}
impl AVBSFContextOwned {
/// Allocate a context for a given bitstream filter.
/// The caller must fill in the context parameters as described in the
/// doc... | code_fim | hard | {
"lang": "rust",
"repo": "hlima/ffav-rs-hml",
"path": "/src/easy/owned.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hlima/ffav-rs-hml path: /src/easy/owned.rs
let err = av_bsf_alloc(filter, &mut ptr);
if err < 0 {
Err(av_err2str(err).into())
} else {
Ok(Self { ptr })
}
}
}
}
/// Re... | code_fim | hard | {
"lang": "rust",
"repo": "hlima/ffav-rs-hml",
"path": "/src/easy/owned.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yrashk/clips.rs path: /clips/src/value.rs
use sys;
use std::ffi::{CStr, CString};
/// CLIPS value
pub struct Value(pub(crate) sys::CLIPSValue);
impl Value {
pub(crate) fn new(val: sys::clipsValue__bindgen_ty_1) -> Self {
Value(sys::CLIPSValue {
__bindgen_anon_1: val
... | code_fim | hard | {
"lang": "rust",
"repo": "yrashk/clips.rs",
"path": "/clips/src/value.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
macro_rules! value_access_for_int {
($ty: ty) => {
impl ValueAccess for $ty {
fn value(val: &Value) -> Option<$ty> {
match val.type_of() {
Type::Integer => unsafe { Some((*val.0.__bindgen_anon_1.integerValue).contents as $ty) },
_ => None,
... | code_fim | hard | {
"lang": "rust",
"repo": "yrashk/clips.rs",
"path": "/clips/src/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl_env_allocatable_for_integer!(u8);
impl_env_allocatable_for_integer!(i8);
impl_env_allocatable_for_integer!(u16);
impl_env_allocatable_for_integer!(i16);
impl_env_allocatable_for_integer!(u32);
impl_env_allocatable_for_integer!(i32);
impl_env_allocatable_for_integer!(u64);
impl_env_allocatable_for_int... | code_fim | hard | {
"lang": "rust",
"repo": "yrashk/clips.rs",
"path": "/clips/src/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("running 9 loops of the CPU");
for _ in 0..9 {
ee.execute();
println!("{}", ee.cpu());
}
}<|fim_prefix|>// repo: aji/bt68k path: /src/bin/run68k.rs
extern crate bt68k;
use bt68k::exec::*;
use bt68k::exec::interpret::*;
pub fn main() {
let mut rom = [
0x7... | code_fim | medium | {
"lang": "rust",
"repo": "aji/bt68k",
"path": "/src/bin/run68k.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aji/bt68k path: /src/bin/run68k.rs
extern crate bt68k;
use bt68k::exec::*;
use bt68k::exec::interpret::*;
pub fn main() {
let mut rom = [
0x7401, // moveq #1, d2
0x7001, // moveq #1, d0
0xd482, // addl d2, d2
0xd482, // addl d... | code_fim | medium | {
"lang": "rust",
"repo": "aji/bt68k",
"path": "/src/bin/run68k.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: influxdata/routerify path: /examples/error_handling.rs
use hyper::{Body, Request, Response, Server, StatusCode};
use routerify::{Router, RouterService};
use std::io;
use std::net::SocketAddr;
// A handler for "/" page.
async fn home_handler(_: Request<Body>) -> Result<Response<Body>, io::Error>... | code_fim | hard | {
"lang": "rust",
"repo": "influxdata/routerify",
"path": "/examples/error_handling.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/gleam/build.rs
extern
crate
gl_generator
;
use
gl_generator
:
:
{
Api
Fallbacks
Profile
Registry
}
;
use
std
:
:
env
;
use
std
:
:
fs
:
:
File
;
use
std
:
:
path
:
:
Path
;
fn
main
(
)
{
let
dest
=
env
:
:
var
(
"
OUT_DIR
"
)
.
unwrap
(
)
;
let... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/gleam/build.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
"
GL_CHROMIUM_copy_texture
"
"
GL_KHR_debug
"
"
GL_KHR_blend_equation_advanced
"
"
GL_KHR_blend_equation_advanced_coherent
"
"
GL_ANGLE_copy_texture_3d
"
"
GL_QCOM_tiled_rendering
"
]
;
let
gles_reg
=
Registry
:
:
new
(
Api
:
:
Gles2
/
/
using
3
.
1
to
get
SSBO
support
(
3
1
)
Profile
:
:
Core
Fallbacks
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/gleam/build.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> {
if self.remaining == 0 {
return None;
}
let index: f64;
let mut value: Vec<f64> = Vec::new();
match self.stream.read_f64::<LittleEndian>() {
Ok(f) => { index = f; },
Err(e) => { ret... | code_fim | hard | {
"lang": "rust",
"repo": "ShotaroTsuji/broto",
"path": "/src/reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct F64TSReader<'a, R: 'a> {
index_len : usize,
value_len : usize,
remaining : usize,
stream : &'a mut R,
phantom: PhantomData<&'a R>,
}
impl<'a, R> Iterator for F64TSReader<'a, R> where R: 'a + io::Read {
type Item = Result<(f64,Vec<f64>)>;
fn next(&m... | code_fim | hard | {
"lang": "rust",
"repo": "ShotaroTsuji/broto",
"path": "/src/reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShotaroTsuji/broto path: /src/reader.rs
use std::io;
use std::marker::PhantomData;
use byteorder::{LittleEndian, ReadBytesExt};
use header::{Header, BlockHeader, LogBlock, F64TSBlock};
use error::{Result, Error};
#[derive(Debug)]
pub enum Block {
Log(LogBlock),
F64TS(F64TSBlock),
}
#[d... | code_fim | hard | {
"lang": "rust",
"repo": "ShotaroTsuji/broto",
"path": "/src/reader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaneutt/lumen path: /lumen_runtime/src/otp/erlang/spawn_link_3/test/with_atom_module/with_atom_function.rs
use super::*;
mod with_empty_list_arguments;
mod with_non_empty_proper_list_arguments;
<|fim_suffix|> run!(
|arc_process| {
(
Just(arc_process.clon... | code_fim | hard | {
"lang": "rust",
"repo": "shaneutt/lumen",
"path": "/lumen_runtime/src/otp/erlang/spawn_link_3/test/with_atom_module/with_atom_function.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zeroows/socket.io-server-rust path: /socket_io_server/src/storage.rs
use socket_io_parser::packet::Packet;
use std::collections::HashSet;
use crate::error::BroadcastError;
pub trait Storage: 'static + Send + Sync + Sized {
fn new() -> Self;
fn add_all(&self, socket_id: &str, room_names... | code_fim | hard | {
"lang": "rust",
"repo": "zeroows/socket.io-server-rust",
"path": "/socket_io_server/src/storage.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Storage for DefaultStorage {
fn new() -> Self {
todo!()
}
fn add_all(&self, socket_id: &str, room_names: HashSet<String>) {
todo!()
}
fn del(&self, socket_id: &str, room_name: &str) {
todo!()
}
fn broadcast(
&self,
packet: Packet,... | code_fim | hard | {
"lang": "rust",
"repo": "zeroows/socket.io-server-rust",
"path": "/socket_io_server/src/storage.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // part 2
// O(N^3)
// for i in 0..n - 2{
// for j in i+1..n - 1 {
// for k in j+1..n {
// if xs[i] + xs[j] + xs[k]== 2020{
// println!("{}", xs[i]*xs[j]*xs[k]);
// break;
// }
// }
// }... | code_fim | hard | {
"lang": "rust",
"repo": "lauyh/aoc2020",
"path": "/01/src/App.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Part 2
// O(N^2Log(N))
for i in 0..n-1{ //O(N)
for j in i+1..n{
if let Ok(k) = xs.binary_search(&(2020-xs[i]-xs[j])) {
if j != k{
println!("{}", xs[i]*xs[j]*xs[k]);
break;
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "lauyh/aoc2020",
"path": "/01/src/App.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lauyh/aoc2020 path: /01/src/App.rs
fn main(){
// read file and throw err if encountered
let input = std::fs::read_to_string("input.txt").unwrap();
// split the input by new line, only take in not empty value, parse as int and map into array
let mut xs = input.split("\n").filt... | code_fim | hard | {
"lang": "rust",
"repo": "lauyh/aoc2020",
"path": "/01/src/App.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jrawsthorne/rust-bitcoin-node path: /src/protocol/mod.rs
pub mod consensus;
mod network;
mod timedata;
mod version_bits;
<|fim_suffix|>pub const WTXID_RELAY_VERSION: u32 = 70016;<|fim_middle|>pub use consensus::{get_block_subsidy, LockFlags, ScriptFlags, BASE_REWARD, COIN};
pub use network::Net... | code_fim | hard | {
"lang": "rust",
"repo": "jrawsthorne/rust-bitcoin-node",
"path": "/src/protocol/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const WTXID_RELAY_VERSION: u32 = 70016;<|fim_prefix|>// repo: jrawsthorne/rust-bitcoin-node path: /src/protocol/mod.rs
pub mod consensus;
mod network;
mod timedata;
mod version_bits;
<|fim_middle|>pub use consensus::{get_block_subsidy, LockFlags, ScriptFlags, BASE_REWARD, COIN};
pub use network::Net... | code_fim | hard | {
"lang": "rust",
"repo": "jrawsthorne/rust-bitcoin-node",
"path": "/src/protocol/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Solution;
use std::collections::{HashMap, HashSet};
use std::cmp::{max, min};
impl Solution {
pub fn find_subsequences(A: Vec<i32>) -> Vec<Vec<i32>> {
let MOD = 1e9 as i64 + 7;
let hash = |x: i64, y: i64| { (x * 233 + y + 101) % MOD };
let mut S = HashSet::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "slayerwalt/LeetCode",
"path": "/OJ/leet491/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slayerwalt/LeetCode path: /OJ/leet491/src/main.rs
// leet491
#![allow(dead_code)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
// #![allow(unused_mut)]
#![allow(unused_macros)]
#![allow(unused_imports)]
macro_rules! vec_of_strings {
($($x:expr),*) => (vec![$($x.to_string()),*]);
}... | code_fim | hard | {
"lang": "rust",
"repo": "slayerwalt/LeetCode",
"path": "/OJ/leet491/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub const fn is_upgrade(&self) -> bool {
matches!(self, Self::Upgrade { .. })
}
pub const fn is_despawn(&self) -> bool {
matches!(self, Self::Despawn)
}
pub const fn is_instant(&self) -> bool {
matches!(self, Self::Upgrade { .. } | Self::Despawn)
}
}<|fim_prefix|>// repo: steamro... | code_fim | hard | {
"lang": "rust",
"repo": "steamroller-airmash/airmash-server",
"path": "/server-config/src/effect.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steamroller-airmash/airmash-server path: /server-config/src/effect.rs
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(tag = "type", rename = "kebab-case")]
pub enum EffectPrototype {
Shield {
damage_mult: f32,
},
Inferno,
... | code_fim | hard | {
"lang": "rust",
"repo": "steamroller-airmash/airmash-server",
"path": "/server-config/src/effect.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub const fn is_fixed_speed(&self) -> bool {
matches!(self, Self::FixedSpeed { .. })
}
pub const fn is_upgrade(&self) -> bool {
matches!(self, Self::Upgrade { .. })
}
pub const fn is_despawn(&self) -> bool {
matches!(self, Self::Despawn)
}
pub const fn is_instant(&self) -> boo... | code_fim | medium | {
"lang": "rust",
"repo": "steamroller-airmash/airmash-server",
"path": "/server-config/src/effect.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The structure literal `{ ... }` quasi-operator.
Structure,
}
impl fmt::Display for Operator {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Path => write!(f, "::"),
_ => todo!(),
}
}
}<|fim_prefix|>// repo: prz23/... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zinc-syntax/src/tree/expression/tree/node/operator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prz23/zinc path: /zinc-syntax/src/tree/expression/tree/node/operator.rs
//!
//! The expression operator.
//!
use std::fmt;
///
/// An expression tree operator.
///
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Operator {
/// The `=` operator.
Assignment,
/// The `|=` operator.
... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zinc-syntax/src/tree/expression/tree/node/operator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ontio/ontology-wasm-cdt-rust path: /examples/oep8token/src/test.rs
use crate::{Oep8Token, Oep8TokenInstance};
use ontio_std::mock::build_runtime;
use ontio_std::types::{Address, U128};
#[test]
fn init() {
let mut token = Oep8TokenInstance;
let owner: Address = ostd::macros::base58!("AFm... | code_fim | hard | {
"lang": "rust",
"repo": "ontio/ontology-wasm-cdt-rust",
"path": "/examples/oep8token/src/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(token.name(token_id_1.clone()), "TokenNameFirst");
assert_eq!(token.name(token_id_2.clone()), "TokenNameSecond");
assert_eq!(token.name(token_id_3.clone()), "TokenNameThird");
assert_eq!(token.name(token_id_4.clone()), "TokenNameFourth");
assert_eq!(token.name(token_id_5.clo... | code_fim | hard | {
"lang": "rust",
"repo": "ontio/ontology-wasm-cdt-rust",
"path": "/examples/oep8token/src/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn approve_multi() {
let mut token = Oep8TokenInstance;
let owner: Address = ostd::macros::base58!("AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM");
let alice = Address::random();
build_runtime().witness(&[owner, alice]);
assert!(token.init());
let token_id_1 = format!("{}", 1);
l... | code_fim | hard | {
"lang": "rust",
"repo": "ontio/ontology-wasm-cdt-rust",
"path": "/examples/oep8token/src/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Uniquely identify a Backup (relative to data store)
///
/// We also call this a backup snaphost.
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct BackupDir {
/// Backup group
group: BackupGroup,
/// Backup timestamp
backup_time: i64,
// backup_time as rfc3339
backup_time_strin... | code_fim | hard | {
"lang": "rust",
"repo": "pimox/proxmox-backup",
"path": "/src/backup/backup_info.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pimox/proxmox-backup path: /src/backup/backup_info.rs
use crate::tools;
use anyhow::{bail, format_err, Error};
use std::os::unix::io::RawFd;
use std::path::{Path, PathBuf};
use proxmox::const_regex;
use super::manifest::MANIFEST_BLOB_NAME;
macro_rules! BACKUP_ID_RE {
() => {
r"[... | code_fim | hard | {
"lang": "rust",
"repo": "pimox/proxmox-backup",
"path": "/src/backup/backup_info.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johanneskoester/alpaca path: /src/query/grammar.rs
match seq_res {
Matched(pos,
_) =>
... | code_fim | hard | {
"lang": "rust",
"repo": "johanneskoester/alpaca",
"path": "/src/query/grammar.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johanneskoester/alpaca path: /src/query/grammar.rs
match step_res {
Matched(newpos, value)
=> {
repeat_po... | code_fim | hard | {
"lang": "rust",
"repo": "johanneskoester/alpaca",
"path": "/src/query/grammar.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ())
} else {
Failed
... | code_fim | hard | {
"lang": "rust",
"repo": "johanneskoester/alpaca",
"path": "/src/query/grammar.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
tmp = tmp / 10;
}
if (sum >= v[1] && sum <= v[2]){
ans += x;
// println!("ans:{}", ans);
}
}
println!("{}", ans);
}<|fim_prefix|>// repo: YsuOS/atcoder path: /some_sums/src/main.rs
fn main() {
let mut input = String::new();
std... | code_fim | medium | {
"lang": "rust",
"repo": "YsuOS/atcoder",
"path": "/some_sums/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YsuOS/atcoder path: /some_sums/src/main.rs
fn main() {
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let v: Vec<u32> = input.trim().split_whitespace()
.map(|x| x.parse().unwr<|fim_suffix|> loop {
// println!("tmp:{}", tmp);
... | code_fim | medium | {
"lang": "rust",
"repo": "YsuOS/atcoder",
"path": "/some_sums/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filosfino/shadowsocks-rust path: /src/relay/loadbalancing/server/mod.rs
//! Load balancer for picking servers
use std::sync::Arc;
<|fim_suffix|>pub trait LoadBalancer {
fn pick_server(&mut self) -> Arc<ServerConfig>;
fn total(&self) -> usize;
}<|fim_middle|>pub use self::roundrobin::Ro... | code_fim | medium | {
"lang": "rust",
"repo": "filosfino/shadowsocks-rust",
"path": "/src/relay/loadbalancing/server/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use config::ServerConfig;
pub mod roundrobin;
pub trait LoadBalancer {
fn pick_server(&mut self) -> Arc<ServerConfig>;
fn total(&self) -> usize;
}<|fim_prefix|>// repo: filosfino/shadowsocks-rust path: /src/relay/loadbalancing/server/mod.rs
//! Load balancer for picking servers
use std::sync::... | code_fim | easy | {
"lang": "rust",
"repo": "filosfino/shadowsocks-rust",
"path": "/src/relay/loadbalancing/server/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Command {
pub fn from_args(args: env::ArgsOs) -> Result<Command, UsageError> {
let mut inputs = Vec::new();
let mut script = None;
let mut do_write_wave = false;
let mut wave_file = None;
let mut play = false;
let mut notes = None;
let mut t... | code_fim | hard | {
"lang": "rust",
"repo": "depp/ultrafxr",
"path": "/rust/src/cmd_sfx.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: depp/ultrafxr path: /rust/src/cmd_sfx.rs
use crate::consolelogger::ConsoleLogger;
use crate::error::Failed;
use crate::evaluate::evaluate_program;
use crate::note::Note;
use crate::parseargs::{Arg, Args, UsageError};
use crate::parser::{ParseResult, Parser};
use crate::shell::quote_os;
use crate... | code_fim | hard | {
"lang": "rust",
"repo": "depp/ultrafxr",
"path": "/rust/src/cmd_sfx.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nabijaczleweli/gen-epub-book.rs path: /tests/ops/element/parse/errors.rs
use gen_epub_book::ops::BookElement;
use gen_epub_book::Error;
#[test]
fn url() {
assert_eq!(BookElement::parse("Network-Cover: http/i.imgur.com/ViQ2WED.jpg", ":", false),
Err(Error::Parse {
... | code_fim | hard | {
"lang": "rust",
"repo": "nabijaczleweli/gen-epub-book.rs",
"path": "/tests/ops/element/parse/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(BookElement::parse("Date: 1486564218", ":", true),
Err(Error::Parse {
tp: "datetime",
wher: "book element",
more: Some("not RFC3339, RFC2822, nor Unix timestamp w/timezone"),
}));
}<|fim_prefix|>// repo: ... | code_fim | hard | {
"lang": "rust",
"repo": "nabijaczleweli/gen-epub-book.rs",
"path": "/tests/ops/element/parse/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
Criterion::default().
bench_prog("fib", &Command::new("target/release/fib"));
}<|fim_prefix|>// repo: Ryman/criterion.rs path: /src/bin/prog.rs
extern crate criterion;
<|fim_middle|>use std::io::Command;
use criterion::Criterion;
| code_fim | easy | {
"lang": "rust",
"repo": "Ryman/criterion.rs",
"path": "/src/bin/prog.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryman/criterion.rs path: /src/bin/prog.rs
extern crate criterion;
use std::io::Command;
<|fim_suffix|>fn main() {
Criterion::default().
bench_prog("fib", &Command::new("target/release/fib"));
}<|fim_middle|>use criterion::Criterion;
| code_fim | easy | {
"lang": "rust",
"repo": "Ryman/criterion.rs",
"path": "/src/bin/prog.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OIEIEIO/betelgeuse path: /src/service.rs
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use std::sync::Arc;
use std::str::FromStr;
use std::time::Duration;
use std::thread;
use parking_lot::Mutex;
use codec::Encode;
use sp_runtime::{Perbill, generic::... | code_fim | hard | {
"lang": "rust",
"repo": "OIEIEIO/betelgeuse",
"path": "/src/service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::spawn(move || {
loop {
let metadata = worker.lock().metadata();
if let Some(metadata) = metadata {
match betelgeuse_pow::mine(
client.as_ref(),
&keystore,
&BlockId::Hash(metadata.best_hash),
&metadata.pre_hash,
metadata.pre_runtim... | code_fim | hard | {
"lang": "rust",
"repo": "OIEIEIO/betelgeuse",
"path": "/src/service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sdleffler/sludge path: /src/tiled/xml_parser.rs
})
}
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Image {
/// The filepath of the image
pub source: PathBuf,
pub width: i32,
pub height: i32,
pub transparent_colour: Option<Colour>,
}
impl Image {
fn new<R: Rea... | code_fim | hard | {
"lang": "rust",
"repo": "sdleffler/sludge",
"path": "/src/tiled/xml_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> LayerTile {
gid,
flip_h,
flip_v,
flip_d,
}
}
}
#[derive(Debug, PartialEq, Clone)]
pub struct Layer {
pub name: String,
pub opacity: f32,
pub visible: bool,
/// The tiles are arranged in rows. Each tile is a number which c... | code_fim | hard | {
"lang": "rust",
"repo": "sdleffler/sludge",
"path": "/src/tiled/xml_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sdleffler/sludge path: /src/tiled/xml_parser.rs
ng>,
) -> Result<Chunk, Error> {
let ((), (x, y, width, height)) = get_attrs!(
attrs,
optionals: [],
required: [
("x", x, |v: String| v.parse().ok()),
("y", y, |v: Stri... | code_fim | hard | {
"lang": "rust",
"repo": "sdleffler/sludge",
"path": "/src/tiled/xml_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", fib(10));
}
fn fib(n: i32) -> i32 {
if n == 0 { return 0; }
let mut a = 0;
let mut b = 1;
for _ in 2..n {
let c = a + b;
a = b;
b = c;
}
b
}<|fim_prefix|>// repo: vladris/scratch path: /rust/loops/src/main.rs
fn main() {
/*
lo... | code_fim | medium | {
"lang": "rust",
"repo": "vladris/scratch",
"path": "/rust/loops/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vladris/scratch path: /rust/loops/src/main.rs
fn main() {
/*
loop {
println!("again!");
}
*/
let mut number = 3;
while number != 0 {
println!("{}!", number);
number = number - 1;
}
let a = [10, 20, 30, 40, 50];
for element in a.iter... | code_fim | medium | {
"lang": "rust",
"repo": "vladris/scratch",
"path": "/rust/loops/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut lines_counter = 0.0;
while lines_counter < 1000.0 * self.size.0 {
if !self.current_cell.contains_node(&self.current_node) {
self.find_current_cell();
}
if !self.current_cell.contains_node(&self.current_node) {
br... | code_fim | hard | {
"lang": "rust",
"repo": "GuVictory/current_lines_2d",
"path": "/src/current_line_generator/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuVictory/current_lines_2d path: /src/current_line_generator/mod.rs
use crate::entity::cell::Cell;
use crate::entity::coords::Coords;
use crate::entity::node::Node;
use crate::interpolation::interpolation;
pub struct CurrentLineGenerator {
cells: Vec<Cell>,
nodes: Vec<Node>,
size: (... | code_fim | hard | {
"lang": "rust",
"repo": "GuVictory/current_lines_2d",
"path": "/src/current_line_generator/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leod/ash-urn path: /src/base/instance.rs
use super::validation::{check_validation_layer_support, populate_debug_messenger_create_info};
use crate::error::UrnError;
use crate::util::CString;
use crate::util::StringContainer;
use ash::version::EntryV1_0;
<|fim_suffix|> let mut debug_utils... | code_fim | hard | {
"lang": "rust",
"repo": "leod/ash-urn",
"path": "/src/base/instance.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut debug_utils_messenger_create_info = populate_debug_messenger_create_info();
let create_info = if settings.enable_validation {
create_info
.enabled_layer_names(validation_layer_names_cs.pointer.as_slice())
.push_next(&mut debug_utils_mess... | code_fim | medium | {
"lang": "rust",
"repo": "leod/ash-urn",
"path": "/src/base/instance.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn binomial132_overflow() {
assert!(131i128.choose(65).is_none());
}<|fim_prefix|>// repo: brain0/binomial-rs path: /tests/i128_overflow.rs
#![cfg(feature = "i128")]
extern crate binomial;
use binomial::Binomial;
<|fim_middle|>#[test]
fn binomial131_no_overflow() {
assert_eq!(
13... | code_fim | medium | {
"lang": "rust",
"repo": "brain0/binomial-rs",
"path": "/tests/i128_overflow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.