text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> /// A command representing an auto-configuration detector. Use `ICUConfig::new()` to create.
pub struct ICUConfig {
rep: Command,
}
impl ICUConfig {
/// Creates a new ICUConfig.
pub fn new() -> Self {
ICUConfig {
rep: Command::new("pkg-... | code_fim | hard | {
"lang": "rust",
"repo": "google/rust_icu",
"path": "/rust_icu_uloc/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: google/rust_icu path: /rust_icu_uloc/build.rs
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/license... | code_fim | hard | {
"lang": "rust",
"repo": "google/rust_icu",
"path": "/rust_icu_uloc/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn point_at_parameter(self: &Self, t: f64) -> Vector {
self.origin + self.direction * t
}
}<|fim_prefix|>// repo: DanCardin/man-ray path: /src/ray.rs
use crate::vector::Vector;
#[derive(Clone, Copy, Debug)]
pub struct Ray {
pub origin: Vector,
pub direction: Vector,
}
<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "DanCardin/man-ray",
"path": "/src/ray.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DanCardin/man-ray path: /src/ray.rs
use crate::vector::Vector;
#[derive(Clone, Copy, Debug)]
pub struct Ray {
pub origin: Vector,
pub direction: Vector,
}
<|fim_suffix|> pub fn point_at_parameter(self: &Self, t: f64) -> Vector {
self.origin + self.direction * t
}
}<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "DanCardin/man-ray",
"path": "/src/ray.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BugenZhao/raytracing.rs path: /src/main.rs
#![allow(dead_code)]
mod material;
mod object;
mod ray;
mod render;
mod scene;
mod texture;
mod vec3;
mod world;
<|fim_suffix|> render::render_image(scene::examples::cornell_box(64))?;
Ok(())
}<|fim_middle|>fn main() -> anyhow::Result<()> {
| code_fim | easy | {
"lang": "rust",
"repo": "BugenZhao/raytracing.rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> render::render_image(scene::examples::cornell_box(64))?;
Ok(())
}<|fim_prefix|>// repo: BugenZhao/raytracing.rs path: /src/main.rs
#![allow(dead_code)]
mod material;
mod object;
mod ray;
mod render;
mod scene;
mod texture;
mod vec3;
mod world;
<|fim_middle|>fn main() -> anyhow::Result<()> {
| code_fim | easy | {
"lang": "rust",
"repo": "BugenZhao/raytracing.rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut opts = crate::linearize(&opts);
sort_least_to_most_general(&mut opts);
let before = opts
.optimizations
.iter()
.map(|o| {
o.matches
.ite... | code_fim | hard | {
"lang": "rust",
"repo": "1Crazymoney/wasmtime",
"path": "/cranelift/peepmatic/src/linear_passes.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> (IsPowerOfTwo(a), IsPowerOfTwo(b)) => a.cmp(&b),
(IsPowerOfTwo(_), _) => Ordering::Less,
(_, IsPowerOfTwo(_)) => Ordering::Greater,
(BitWidth(a), BitWidth(b)) => a.cmp(&b),
(BitWidth(_), _) => Ordering::Less,
(_, BitWidth(_)) => Ordering::Greater,
... | code_fim | hard | {
"lang": "rust",
"repo": "1Crazymoney/wasmtime",
"path": "/cranelift/peepmatic/src/linear_passes.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1Crazymoney/wasmtime path: /cranelift/peepmatic/src/linear_passes.rs
// NB: we *cannot* use an unstable sort here, because we want deterministic
// compilation of optimizations to automata.
optimizations.sort_by(compare_optimization_generality);
debug_assert!(is_sorted_by_generalit... | code_fim | hard | {
"lang": "rust",
"repo": "1Crazymoney/wasmtime",
"path": "/cranelift/peepmatic/src/linear_passes.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> defmt::info!("Starting blinky");
loop {
for &level in &[Level::High, Level::Low] {
led1.set_level(level);
delay.delay_ms(600);
led2.set_level(level);
delay.delay_ms(600);
led3.set_level(level);
delay.delay_ms(600);
... | code_fim | medium | {
"lang": "rust",
"repo": "lulf/stm32wl-hal",
"path": "/examples/examples/gpio-blink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut dp: pac::Peripherals = defmt::unwrap!(pac::Peripherals::take());
let cp: pac::CorePeripherals = defmt::unwrap!(pac::CorePeripherals::take());
let gpiob: PortB = PortB::split(dp.GPIOB, &mut dp.RCC);
let mut led1 = Output::default(gpiob.b9);
let mut led2 = Output::default(gpiob.... | code_fim | medium | {
"lang": "rust",
"repo": "lulf/stm32wl-hal",
"path": "/examples/examples/gpio-blink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lulf/stm32wl-hal path: /examples/examples/gpio-blink.rs
// Blinks the 3 LEDs on the NUCLEO-WL55JC2 in a sequence.
#![no_std]
#![no_main]
use defmt_rtt as _; // global logger
use panic_probe as _; // panic handler
use stm32wl_hal::{
self as hal,
cortex_m::delay::Delay,
gpio::{Level,... | code_fim | hard | {
"lang": "rust",
"repo": "lulf/stm32wl-hal",
"path": "/examples/examples/gpio-blink.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test(
&Instruction {
mnemonic: Mnemonic::PCMPEQB,
operand1: Some(Direct(MM7)),
operand2: Some(IndirectScaledIndexedDisplaced(
RDI,
RSI,
Four,
1530167701,
Some(OperandSize::Qw... | code_fim | hard | {
"lang": "rust",
"repo": "ftilde/rust-x86asm",
"path": "/src/test/instruction_tests/instr_pcmpeqb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ftilde/rust-x86asm path: /src/test/instruction_tests/instr_pcmpeqb.rs
use instruction_def::*;
use test::run_test;
use Operand::*;
use Reg::*;
use RegScale::*;
use RegType::*;
use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
#[test]
fn pcmpeqb_1() {... | code_fim | hard | {
"lang": "rust",
"repo": "ftilde/rust-x86asm",
"path": "/src/test/instruction_tests/instr_pcmpeqb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lucky4Luuk/rocket path: /src/util.rs
use tui::layout::{Layout, Direction, Constraint, Rect};
pub fn centered_rect_perc(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
let popup_layout = Layout::default()
.direction(Direction::Vertical)
.constraints(
[
... | code_fim | hard | {
"lang": "rust",
"repo": "Lucky4Luuk/rocket",
"path": "/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn centered_rect_set(x: u16, y: u16, r: Rect) -> Rect {
let percent_x = ((x as f32) / (r.width as f32) * 100f32) as u16;
let percent_y = ((y as f32) / (r.height as f32) * 100f32) as u16;
centered_rect_perc(percent_x, percent_y, r)
}<|fim_prefix|>// repo: Lucky4Luuk/rocket path: /src/util.... | code_fim | hard | {
"lang": "rust",
"repo": "Lucky4Luuk/rocket",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kcolford/swagger-rs path: /src/one_any_of.rs
//! Implementations of OpenAPI `oneOf` and `anyOf` types, assuming rules are just types
#[cfg(feature = "conversion")]
use frunk_enum_derive::LabelledGenericEnum;
use serde::{
de::Error,
Deserialize, Deserializer, Serialize, Serializer,
__... | code_fim | hard | {
"lang": "rust",
"repo": "kcolford/swagger-rs",
"path": "/src/one_any_of.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let content = Content::deserialize(deserializer)?;
$(
if let Ok(inner) = $i::deserialize(ContentRefDeserializer::<De::Error>::new(&content)) {
return Ok(Self::$i(inner));
}
)*
Er... | code_fim | hard | {
"lang": "rust",
"repo": "kcolford/swagger-rs",
"path": "/src/one_any_of.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maksnester/some-release-tests path: /i3df/build.rs
use heck::CamelCase;
use indexmap::IndexMap;
use quote::{format_ident, quote};
use std::collections::HashMap;
use std::env;
use std::error::Error;
use std::fs;
use std::io::Write;
use proc_macro2::TokenStream;
use serde::{Deserialize, Serialize... | code_fim | hard | {
"lang": "rust",
"repo": "maksnester/some-release-tests",
"path": "/i3df/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let match_pattern = quote! {
#geometry_id_num => {
#snake_name_collection_ident = #primitive_parse_function(node_ids, indices, attributes)?;
},
};
let to_renderables = quote! {
for item in &raw_primitives.#snake_name_collection_i... | code_fim | hard | {
"lang": "rust",
"repo": "maksnester/some-release-tests",
"path": "/i3df/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlexApps99/egui path: /egui/src/any/serializable/type_id.rs
use std::any::Any;
/// We need this because `TypeId` can't be deserialized or serialized directly, but this can be done using hashing. However, there is a small possibility that different types will have intersection by hashes of their... | code_fim | medium | {
"lang": "rust",
"repo": "AlexApps99/egui",
"path": "/egui/src/any/serializable/type_id.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<std::any::TypeId> for TypeId {
#[inline]
fn from(id: std::any::TypeId) -> Self {
Self(epaint::util::hash(id))
}
}<|fim_prefix|>// repo: AlexApps99/egui path: /egui/src/any/serializable/type_id.rs
use std::any::Any;
/// We need this because `TypeId` can't be deserialized or ... | code_fim | medium | {
"lang": "rust",
"repo": "AlexApps99/egui",
"path": "/egui/src/any/serializable/type_id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArnaudValensi/rust-opengl-game-engine path: /src/material.rs
use cgmath::{Matrix3, Matrix4, Vector3, Vector4};
use shader::Shader;
use std::ffi::{CStr, CString};
use texture::Texture;
#[derive(Debug, Clone)]
pub struct Material {
shader: Shader,
texture: Texture,
}
impl Default for Mat... | code_fim | hard | {
"lang": "rust",
"repo": "ArnaudValensi/rust-opengl-game-engine",
"path": "/src/material.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_vector4_array(&self, name: &str, array: &[f32]) {
let c_string = CString::new(name).unwrap();
let c_str = c_string.as_c_str();
unsafe {
self.shader.setVector4Array(c_str, array);
}
}
pub fn set_integer(&self, name: &str, value: i32) {
... | code_fim | hard | {
"lang": "rust",
"repo": "ArnaudValensi/rust-opengl-game-engine",
"path": "/src/material.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> format_removed(&semicolon_token?).fmt(f)
}
}<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/js/classes/empty_class_member.rs
use crate::prelude::*;
use rome_js_syntax::JsEmptyClassMember;
use rome_js_syntax::JsEmptyClassMemberFields;
<|fim_middle|>#[derive(Debug, Clone... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_js_formatter/src/js/classes/empty_class_member.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/js/classes/empty_class_member.rs
use crate::prelude::*;
use rome_js_syntax::JsEmptyClassMember;
use rome_js_syntax::JsEmptyClassMemberFields;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsEmptyClassMember;
<|fim_suffix|> let J... | code_fim | medium | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_js_formatter/src/js/classes/empty_class_member.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 20
}
/// Push a 16-bit register to the stack.
///
/// Takes 16 cycles.
///
/// # Examples
///
/// ```asm
/// PUSH BC ; STACK <<- BC
/// ```
pub fn push_r16(cpu: &mut Cpu, r16: &Reg16) -> u8 {
let value = cpu.registers.read16(r16);
push_stack_d16(cpu, value);
16
}
/// Pop the contents of... | code_fim | hard | {
"lang": "rust",
"repo": "Palmr/lameboy",
"path": "/src/lameboy/cpu/instructions/sixteen_bit_loads.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Palmr/lameboy path: /src/lameboy/cpu/instructions/sixteen_bit_loads.rs
use crate::lameboy::cpu::instructions::stack::{pop_stack_d16, push_stack_d16};
use crate::lameboy::cpu::registers::{Flags, Reg16};
use crate::lameboy::cpu::Cpu;
/// Load a 16-bit value into a 16-bit register.
///
/// Takes 1... | code_fim | hard | {
"lang": "rust",
"repo": "Palmr/lameboy",
"path": "/src/lameboy/cpu/instructions/sixteen_bit_loads.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astro/bip-rs path: /bip_utracker/test/test_connect.rs
use std::thread::{self};
use std::time::{Duration};
use bip_util::bt::{self};
use bip_utracker::{TrackerClient, TrackerServer, ClientRequest};
use bip_utracker::announce::{ClientState, AnnounceEvent};
<|fim_suffix|>#[test]
#[allow(unused)]
... | code_fim | medium | {
"lang": "rust",
"repo": "astro/bip-rs",
"path": "/bip_utracker/test/test_connect.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let server_addr = "127.0.0.1:3505".parse().unwrap();
let mock_handler = MockTrackerHandler::new();
let server = TrackerServer::run(server_addr, mock_handler).unwrap();
thread::sleep(Duration::from_millis(100));
let mut client = TrackerClient::new("127.0.0.1:4505".parse().unwr... | code_fim | medium | {
"lang": "rust",
"repo": "astro/bip-rs",
"path": "/bip_utracker/test/test_connect.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let send_token = client.request(server_addr, ClientRequest::Announce(
[0u8; bt::INFO_HASH_LEN].into(),
ClientState::new(0, 0, 0, AnnounceEvent::None)
)).unwrap();
let (recv_token, res) = responses.recv().unwrap();
assert_eq!(send_token, recv_token);
assert!(re... | code_fim | hard | {
"lang": "rust",
"repo": "astro/bip-rs",
"path": "/bip_utracker/test/test_connect.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: himanoa/testament-api path: /src/models/entry.rs
#![allow(proc_macro_derive_resolution_fallback)]
use chrono::NaiveDateTime;
use models::user::User;
use schema::entries;
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, Insertable)]
#[table_name = "entries"]
pub struct NewEntry {
pub us... | code_fim | hard | {
"lang": "rust",
"repo": "himanoa/testament-api",
"path": "/src/models/entry.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, Insertable)]
#[table_name = "entries"]
pub struct NewEntry {
pub user_id: i32,
pub title: String,
pub body: String,
pub published: bool,
}<|fim_prefix|>// repo: himanoa/testament-api path: /src/models/entry.rs
#![allow(proc_macro_derive_resolution_f... | code_fim | hard | {
"lang": "rust",
"repo": "himanoa/testament-api",
"path": "/src/models/entry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asvedr/oolang path: /src/preludelib.rs
use type_check::tclass::*;
use type_check::pack::*;
use syn::type_sys::*;
use std::collections::HashMap;
pub struct Prelude {
pub pack : Box<Pack>,
pub cfns : HashMap<String,String>
}
impl Prelude {
pub fn new() -> Prelude {
let mut pa... | code_fim | hard | {
"lang": "rust",
"repo": "asvedr/oolang",
"path": "/src/preludelib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>th!(arr, "len", type_fn!(vec![], Type::int()), true);
meth!(arr, "get", type_fn!(vec![Type::int()], type_c!("a".to_string())), false);
}
{
let mut asc = newc!("Asc", "_std_asc", vec!["a".to_string(),"b".to_string()], vec![]);
meth!(asc, "len", type_fn!(v... | code_fim | hard | {
"lang": "rust",
"repo": "asvedr/oolang",
"path": "/src/preludelib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lovasoa/t-digest path: /src/main.rs
extern crate tdigest;
use tdigest::Tdigest;
fn main() {
let mut t = Tdigest::new(1000.0);
t.add_weighted(469.20, 1.0);
match t.save_centroids("/tmp/centroid.json".to_string()) {
Ok(_) => (),
Err(err) => eprintln!("That didn't wor... | code_fim | hard | {
"lang": "rust",
"repo": "lovasoa/t-digest",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Compute CDFs
// println!("cdf(100) {}", t.cdf(100.0));
// println!("cdf(200) {}", t.cdf(200.0));
// println!("cdf(300) {}", t.cdf(300.0));
// println!("cdf(400) {}", t.cdf(400.0));
// println!("cdf(500) {}", t.cdf(500.0));
// Print centroids
// println!("{}",... | code_fim | hard | {
"lang": "rust",
"repo": "lovasoa/t-digest",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: miquels/webnis path: /webnis-nss/src/webnis.rs
use std::time::{Duration, SystemTime};
use std::os::unix::net::UnixStream;
use std::io::{BufRead,BufReader};
use std::thread::sleep;
use std::io::Write;
use super::nss::{Passwd,Group,uid_t,gid_t,NssResult,NssError};
static SOCKADDR: &'static str ... | code_fim | hard | {
"lang": "rust",
"repo": "miquels/webnis",
"path": "/webnis-nss/src/webnis.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// connect to webnis-bind.
let mut socket = match UnixStream::connect(SOCKADDR) {
Ok(s) => s,
Err(e) => {
debug!("connect to {}: {}", SOCKADDR, e);
return Err(e)?;
},
};
socket.set_read_timeout(Some(Duration::from_millis(REQUEST_READ_TIMEOUT... | code_fim | hard | {
"lang": "rust",
"repo": "miquels/webnis",
"path": "/webnis-nss/src/webnis.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = Foo { value: 90 };
let result = value.get();
println!("{}", result);
//
// impl MyTrait for Foo { // error: conflicting implementations of trait
// // `MyTrait` for type `Foo`
// fn get(&self) -> usize { self.v... | code_fim | medium | {
"lang": "rust",
"repo": "rustkas/error-index",
"path": "/main_tests/tests/e0119.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustkas/error-index path: /main_tests/tests/e0119.rs
/*
There are conflicting trait implementations for the same type.
*/
#[cfg(test)]
mod tests {
#[allow(dead_code)]
#[test]
//cargo test --test e0119 with_error1 -- --nocapture
fn with_error1() {
<|fim_suffix|> impl<T> M... | code_fim | hard | {
"lang": "rust",
"repo": "rustkas/error-index",
"path": "/main_tests/tests/e0119.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::data_types::OfficialAward;
pub use self::data_types::AwardOptions;
pub use self::data_types::MainPageInputs;<|fim_prefix|>// repo: nrobert-dev/aww.arder path: /src/data_structures/mod.rs
pub mod database;
pub mod data_types;
<|fim_middle|>pub use self::database::KEY;
pub use self::database... | code_fim | medium | {
"lang": "rust",
"repo": "nrobert-dev/aww.arder",
"path": "/src/data_structures/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nrobert-dev/aww.arder path: /src/data_structures/mod.rs
pub mod database;
pub mod data_types;
<|fim_suffix|>pub use self::data_types::OfficialAward;
pub use self::data_types::AwardOptions;
pub use self::data_types::MainPageInputs;<|fim_middle|>pub use self::database::KEY;
pub use self::database... | code_fim | medium | {
"lang": "rust",
"repo": "nrobert-dev/aww.arder",
"path": "/src/data_structures/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aev-mambro2/mambro path: /lib/db/src/lib.rs
/// Handles data input and output to our
/// data store.
///
/// Author: A.E.Veltstra
/// Since: 2.19.501.900
/// Version: 2.20.1103.1006
///
//The 1 method in this module returns a Result.
use Result;
<|fim_suffix|>/// Creates a connection to our dat... | code_fim | hard | {
"lang": "rust",
"repo": "aev-mambro2/mambro",
"path": "/lib/db/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Creates a connection to our data store.
///
/// # Examples
/// ```rust
/// extern crate db;
/// use db;
///
/// let maybe_connection = db::try_connect();
/// assert!(maybe_connection.is_ok());
///
/// ```
///
/// # Throws
/// Error if the data store cannot be found or opened.
pub fn try_connect() -> R... | code_fim | hard | {
"lang": "rust",
"repo": "aev-mambro2/mambro",
"path": "/lib/db/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/substrate path: /frame/system/src/extensions/check_spec_version.rs
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/frame/system/src/extensions/check_spec_version.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Config + Send + Sync> CheckSpecVersion<T> {
/// Create new `SignedExtension` to check runtime version.
pub fn new() -> Self {
Self(sp_std::marker::PhantomData)
}
}
impl<T: Config + Send + Sync> SignedExtension for CheckSpecVersion<T> {
type AccountId = T::AccountId;
type Call = <T as Confi... | code_fim | medium | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/frame/system/src/extensions/check_spec_version.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(<Pallet<T>>::runtime_version().spec_version)
}
fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
self.validate(who, call, info, len).map(|_| ())
}
}<|fim_prefix|>// repo: ... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/frame/system/src/extensions/check_spec_version.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: georich/rust_lang_book path: /privacy_examples/src/lib.rs
mod outermost {
pub fn middle_function() {}
fn middle_secret_function() {}
mod inside {
pub fn inner_function() {
::outermost::middle_secret_function();
}
fn secret_function() {}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "georich/rust_lang_book",
"path": "/privacy_examples/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// or user glob
use TrafficLight::*;
fn main() {
let red = Red;
let yellow = Yellow;
let green = Green;
}<|fim_prefix|>// repo: georich/rust_lang_book path: /privacy_examples/src/lib.rs
mod outermost {
pub fn middle_function() {}
fn middle_secret_function() {}
mod inside {
... | code_fim | medium | {
"lang": "rust",
"repo": "georich/rust_lang_book",
"path": "/privacy_examples/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/ferros path: /src/cap/irq_handler.rs
use core::marker::PhantomData;
use typenum::*;
use selfe_sys::*;
use crate::cap::irq_handler::weak::WIRQHandler;
use crate::cap::{Cap, CapType, LocalCap, MaxIRQCount, Movable, Notification, PhantomCap};
use crate::error::{ErrorExt, SeL4Error};
///... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/ferros",
"path": "/src/cap/irq_handler.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<IRQ: Unsigned, SetState: IRQSetState> CapType for IRQHandler<IRQ, SetState> where
IRQ: IsLess<MaxIRQCount, Output = True>
{
}
impl<IRQ: Unsigned, SetState: IRQSetState> Movable for IRQHandler<IRQ, SetState> where
IRQ: IsLess<MaxIRQCount, Output = True>
{
}
impl<IRQ: Unsigned, SetState: IRQS... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/ferros",
"path": "/src/cap/irq_handler.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> task::spawn(async move {
if timeout.await.is_err() {
panic!("future not closed in time");
}
});
// assert
assert_eq!("test1", receiver.recv().await.unwrap().container_name);
assert_eq!("test2", receiver.recv().await.unwrap().... | code_fim | hard | {
"lang": "rust",
"repo": "thomaszub/docker2mqtt",
"path": "/src/docker/events/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[tokio::test]
async fn stop_receive_loop_if_stream_closed() {
// arrange
let stream = tokio_stream::empty();
let (event_sender, _) = broadcast::channel(500);
// act
let timeout = tokio::time::timeout(
Duration::from_millis(100),
sup... | code_fim | hard | {
"lang": "rust",
"repo": "thomaszub/docker2mqtt",
"path": "/src/docker/events/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomaszub/docker2mqtt path: /src/docker/events/mod.rs
use std::collections::HashMap;
use bollard::{errors::Error, models::SystemEventsResponse, system::EventsOptions, Docker};
use tokio::{sync::broadcast, task};
use tokio_stream::{Stream, StreamExt};
use tracing::error;
use crate::events::{Con... | code_fim | hard | {
"lang": "rust",
"repo": "thomaszub/docker2mqtt",
"path": "/src/docker/events/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: caibirdme/leetcode_rust path: /src/match_192/prob_5429.rs
impl Solution {
pub fn get_strongest(mut arr: Vec<i32>, k: i32) -> Vec<i32> {
arr.sort();
let n = arr.len();
let m = arr[(n-1)/2];
arr.sort_by(|&a,&b| {
let absa = Self::abs(a-m);
... | code_fim | medium | {
"lang": "rust",
"repo": "caibirdme/leetcode_rust",
"path": "/src/match_192/prob_5429.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_get_strongest() {
let test_cases = vec![
(vec![1,2,3,4,5], 2, vec![5,1]),
(vec![1,1,3,5,5], 2, vec![5,5]),
(vec![6,7,11,7,6,8], 5, vec![11,8,6,6,7]),
];
for (nums, k, expect) in test_cases {
assert_eq!(Solution... | code_fim | medium | {
"lang": "rust",
"repo": "caibirdme/leetcode_rust",
"path": "/src/match_192/prob_5429.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn chip8_video_operations() {
let mut machine = Machine::new(Box::new(keyboard::nop_wait_key_callback));
// Draw - Pixels not overwritten
machine.memory.data[0x202] = 0xFF;
machine.memory.data[0x203] = 0x1F;
machine.cpu.i = 0x202;
machine.cpu.v[0x0] = 10;
machine.cpu.v... | code_fim | hard | {
"lang": "rust",
"repo": "etscrivner/chipokto",
"path": "/okto/tests/machine_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: etscrivner/chipokto path: /okto/tests/machine_tests.rs
extern crate okto;
use okto::cpu;
use okto::keyboard;
use okto::machine::Machine;
use okto::{OktoError, OktoErrorKind};
#[test]
fn machine_initialization() {
let machine = Machine::new(Box::new(keyboard::nop_wait_key_callback));
/... | code_fim | hard | {
"lang": "rust",
"repo": "etscrivner/chipokto",
"path": "/okto/tests/machine_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn chip8_keyboard_operations() {
let mut machine = Machine::new(Box::new(keyboard::nop_wait_key_callback));
// SkipKey - Key pressed
machine.keyboard.keys[3] = keyboard::KeyState::Pressed;
machine.cpu.v[0xA] = 3;
machine.cpu.pc = 0x200;
machine.execute(cpu::Operation::Skip... | code_fim | hard | {
"lang": "rust",
"repo": "etscrivner/chipokto",
"path": "/okto/tests/machine_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let url = Url::parse(&self.default_bundles[0].url)
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "failed to parse url"))?;
if url.scheme() == "file" {
// load the local zip file.
let file_path = url.to_file_path().map_err(|_| {
... | code_fim | hard | {
"lang": "rust",
"repo": "tectonic-typesetting/tectonic",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tectonic-typesetting/tectonic path: /src/config.rs
// Copyright 2016-2021 the Tectonic Project
// Licensed under the MIT License.
//! User configuration settings for the Tectonic engine.
//!
//! Because Tectonic has a goal of having a high level of reproducibility, we
//! aim to *avoid* persist... | code_fim | hard | {
"lang": "rust",
"repo": "tectonic-typesetting/tectonic",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dznqbit/advent-of-code path: /2016/day-6/src/main.rs
use std::slice;
use std::str;
use std::fmt::Write;
use std::io::{self, Read};
use std::collections::HashMap;
fn build_cols(lines:&Vec<&str>) -> Vec<String> {
let num_cols = lines.first().unwrap().len();
let mut cols:Vec<String> = Vec::wi... | code_fim | medium | {
"lang": "rust",
"repo": "dznqbit/advent-of-code",
"path": "/2016/day-6/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = String::new();
let mut stdin = io::stdin();
if let Err(why) = stdin.read_to_string(&mut input) { panic!("Could not read STDIN: {}", why); }
let s = input.trim().clone();
let lines:Vec<&str> = s.split("\n").collect();
if lines.len() == 0 { println!("No lines! :("); return; }
... | code_fim | hard | {
"lang": "rust",
"repo": "dznqbit/advent-of-code",
"path": "/2016/day-6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if lines.len() == 0 { println!("No lines! :("); return; }
// for (i, line) in lines.iter().enumerate() { println!("{:03}: {}", i, line); }
let cols = build_cols(&lines);
// for col in cols { println!("{}", col); }
let pt1_code:String = cols.iter().map(|col| most_frequent_char(&col)).collect(... | code_fim | hard | {
"lang": "rust",
"repo": "dznqbit/advent-of-code",
"path": "/2016/day-6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgbyrne/jacl-rs path: /src/types.rs
use indexmap::map::IndexMap;
#[derive(Clone, Debug)]
pub enum Value {
Key(String),
Tuple(Vec<Value>),
<|fim_suffix|>#[derive(Clone, Debug)]
pub enum Struct {
Object { entries: Entries, props: Props},
Table { entries: Entries },
Map { prop... | code_fim | medium | {
"lang": "rust",
"repo": "jgbyrne/jacl-rs",
"path": "/src/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug)]
pub enum Struct {
Object { entries: Entries, props: Props},
Table { entries: Entries },
Map { props: Props },
}<|fim_prefix|>// repo: jgbyrne/jacl-rs path: /src/types.rs
use indexmap::map::IndexMap;
#[derive(Clone, Debug)]
pub enum Value {
Key(String),
Tuple(V... | code_fim | medium | {
"lang": "rust",
"repo": "jgbyrne/jacl-rs",
"path": "/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn read_resp(&self, tcp: &TcpStream) -> Result<Resp, Error> {
let mut r = BufReader::new(tcp);
let mut deser = serde_bencode::de::Deserializer::new(&mut r);
let val: BencodeValue = serde::Deserialize::deserialize(&mut deser)?;
Ok(TryFrom::try_from(val)?)
}
/... | code_fim | hard | {
"lang": "rust",
"repo": "mluts/unrepl",
"path": "/src/nrepl.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mluts/unrepl path: /src/nrepl.rs
pub mod ops;
pub mod session;
use crate::bencode;
use failure::Fail;
use serde::ser::SerializeMap;
use serde::{Deserialize, Serialize, Serializer};
use serde_bencode::value::Value as BencodeValue;
use std::collections::HashMap;
use std::convert::{From, Into, Try... | code_fim | hard | {
"lang": "rust",
"repo": "mluts/unrepl",
"path": "/src/nrepl.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
// use serde_json::json;
#[test]
fn to_value() {
let node_bool = NodeBool::new_distinct();
assert_eq!(node_bool.to_value("users"), vec!["DISTINCT"]);
}
}<|fim_prefix|>// repo: cargo-crates/orm-rs path: /src/nodes/node_bool.rs
use ... | code_fim | hard | {
"lang": "rust",
"repo": "cargo-crates/orm-rs",
"path": "/src/nodes/node_bool.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cargo-crates/orm-rs path: /src/nodes/node_bool.rs
use serde_json::{json, Value as JsonValue};
use crate::nodes::NodeAble;
#[derive(Clone, Debug)]
pub struct NodeBool {
condition: JsonValue,
value: bool,
r#type: String
}
impl NodeBool {
fn new(value: bool, r#type: &str) -> Self {... | code_fim | hard | {
"lang": "rust",
"repo": "cargo-crates/orm-rs",
"path": "/src/nodes/node_bool.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let max_profile: MaxProfile = self.parse_table("maxp");
println!("Got max profile {max_profile:?}");
let glyph_indexes_to_codepoints = parse_character_map(self);
let mut all_glyphs = vec![];
let mut codepoints_to_glyph_indexes = BTreeMap::new();
for i in 0... | code_fim | hard | {
"lang": "rust",
"repo": "codyd51/axle",
"path": "/rust_programs/ttf_renderer/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct FontParser<'a> {
font_data: &'a [u8],
head: Option<HeadTable>,
pub(crate) table_headers: BTreeMap<&'a str, TableHeader<'a>>,
}
impl<'a> FontParser<'a> {
pub fn new(font_data: &'a [u8]) -> Self {
Self {
font_data,
head: None,
table_hea... | code_fim | hard | {
"lang": "rust",
"repo": "codyd51/axle",
"path": "/rust_programs/ttf_renderer/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: codyd51/axle path: /rust_programs/ttf_renderer/src/parser.rs
ange_shift: BigEndianValue<u16>,
}
impl TransmuteFontBufInPlace for OffsetSubtableRaw {}
#[derive(Debug, Copy, Clone)]
struct OffsetSubtable {
scalar_type: u32,
num_tables: u16,
search_range: u16,
entry_selector: u16,... | code_fim | hard | {
"lang": "rust",
"repo": "codyd51/axle",
"path": "/rust_programs/ttf_renderer/src/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Sub<Pos> for Pos {
type Output = Vector;
fn sub(self, other: Pos) -> Self::Output {
Vector(Pos::from_bits(self.0.saturating_sub(other.0)))
}
}
impl Neg for Pos {
type Output = Pos;
fn neg(self) -> Self::Output {
Pos::from_bits(if self.0 == i64::MIN {
... | code_fim | hard | {
"lang": "rust",
"repo": "Ryan1729/rote",
"path": "/libs/abs/src/abs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryan1729/rote path: /libs/abs/src/abs.rs
MAX_F64: f64 = Self::MAX.0 as f64;
#[must_use]
pub fn from_f32(f: f32) -> Self {
u!{std::num::FpCategory}
let scaled = f * Self::SCALE_F32;
match scaled.classify() {
Normal => {
if f64::from(... | code_fim | hard | {
"lang": "rust",
"repo": "Ryan1729/rote",
"path": "/libs/abs/src/abs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryan1729/rote path: /libs/abs/src/abs.rs
nce `SCALE` is a power of 2, which is below `f32::MAX`
// there isn't actually any precision loss in this case.
#[allow(clippy::cast_precision_loss)]
const SCALE_F32: f32 = Self::SCALE as f32;
const FRAC_BIT_MASK: i64 = Self::SCALE - 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "Ryan1729/rote",
"path": "/libs/abs/src/abs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn export<P: AsRef<Path>>(
image_repository: &ImageRepository,
name: &str,
tarball: P,
) -> Result<(), Error> {
let stack: Vec<(Vec<u8>, BtrfsSend)> = get_btrfs_subvolume_stack(image_repository, name)?
.iter()
.map(|b| get_btrfs_send(image_repository, b).map(|v| ... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/ruthless",
"path": "/src/oci_image.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AgustinCB/ruthless path: /src/oci_image.rs
{
stack.push(i);
current_name = i
.parent_uuid
.to_vec()
.iter()
.map(|u| *u as char)
.collect::<String>();
}
Ok(stack)
}
fn path_to_c_pointer(path: &PathBuf) -> *cons... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/ruthless",
"path": "/src/oci_image.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn process_base_subvolume(
snapshot_work_bench: &PathBuf,
name: &str,
image_repository: &ImageRepository,
) -> Result<(), Error> {
let subvolume_path = image_repository.path.join(name);
for entry_result in read_dir(&subvolume_path)? {
let entry = entry_result?;
copy(ent... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/ruthless",
"path": "/src/oci_image.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = r#"use mega::ultra::namespace;"#;
let expected = Ok((
UseStatement::new(
Location::test(1, 1),
ExpressionTree::new_with_leaves(
Location::test(1, 16),
ExpressionTreeNode::operator(ExpressionOpe... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zinc-syntax/src/parser/statement/use.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prz23/zinc path: /zinc-syntax/src/parser/statement/use.rs
//!
//! The `use` statement parser.
//!
use std::cell::RefCell;
use std::rc::Rc;
use zinc_lexical::Keyword;
use zinc_lexical::Lexeme;
use zinc_lexical::Symbol;
use zinc_lexical::Token;
use zinc_lexical::TokenStream;
use crate::error::E... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zinc-syntax/src/parser/statement/use.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn update_and_get_authenticators(
pool: &web::Data<DbPool>,
) -> Result<Vec<models::Authenticator>, Error> {
let conn = get_db_conn(pool);
let authenticators = web::block(move || {
let mut authenticators = actions::get_all_authenticators(&conn)?;
let now = now();
... | code_fim | hard | {
"lang": "rust",
"repo": "hmir/sned-server",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hmir/sned-server path: /src/main.rs
&metadata_str)
.map_err(|_| error::ErrorBadRequest("Could not parse request"))?;
Ok(metadata)
}
fn try_delete_file(file_path: &PathBuf) {
std::fs::remove_file(file_path).ok();
}
fn validate_bytes_written(
file_path: &PathBuf,
bytes_wr... | code_fim | hard | {
"lang": "rust",
"repo": "hmir/sned-server",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hmir/sned-server path: /src/main.rs
ticator: String,
}
#[derive(Deserialize)]
struct DownloadRequestPayload {
username: String,
download_id: String,
signed_authenticator: String,
}
#[derive(Deserialize)]
struct RegisterRequestPayload {
username: String,
public_key: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "hmir/sned-server",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexcrichton/cargo-stats path: /src/bin/download.rs
extern crate curl;
extern crate serialize;
use curl::http;
use std::io::{mod, fs, File};
use std::io::fs::PathExtensions;
use std::str;
use serialize::{json, Decodable};
use std::sync::TaskPool;
#[deriving(Decodable)]
struct Crate {
id: ... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/cargo-stats",
"path": "/src/bin/download.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let p = TaskPool::new(8);
let (tx, rx) = channel();
let mut amt = 0;
for c in crates.iter() {
let tx = tx.clone();
let url = format!("{}/api/v1/crates/{}/{}/download", HOST, c.id,
c.max_version);
let dst = Path::new(format!("dl/{}/{}-{}.cra... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/cargo-stats",
"path": "/src/bin/download.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for Clock {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{:0>2}:{:0>2}",
self.hours.to_string(),
self.minutes.to_string()
)
}
}<|fim_prefix|>// repo: sjoshid/exercism path: /rust/clock/src/lib.rs
use std:... | code_fim | medium | {
"lang": "rust",
"repo": "sjoshid/exercism",
"path": "/rust/clock/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sjoshid/exercism path: /rust/clock/src/lib.rs
use std::fmt::{Display, Formatter, Result};
#[derive(PartialEq, Debug)]
pub struct Clock {
minutes: i32,
hours: i32,
}
<|fim_suffix|> Clock { hours, minutes }
}
pub fn add_minutes(&self, minutes: i32) -> Self {
Clock... | code_fim | hard | {
"lang": "rust",
"repo": "sjoshid/exercism",
"path": "/rust/clock/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nguyend24/DennyBot path: /src/bin/denny_bot/test_server/mod.rs
use serenity::model::id::RoleId;
use serenity::prelude::Context;
use serenity::model::channel::Reaction;
pub async fn _reaction_add_test(ctx: &Context, reaction: &Reaction) {
let guild_id = match reaction.guild_id {
... | code_fim | hard | {
"lang": "rust",
"repo": "nguyend24/DennyBot",
"path": "/src/bin/denny_bot/test_server/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn _reaction_remove_test(ctx: &Context, reaction: &Reaction) {
let guild_id = match reaction.guild_id {
Some(id) => id,
None => {
println!("add_role_rules_verified - guild id not found");
return
}
};
if guild_id.as_u64() == &3... | code_fim | hard | {
"lang": "rust",
"repo": "nguyend24/DennyBot",
"path": "/src/bin/denny_bot/test_server/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicolasjhampton/rust-server-framework path: /http/src/request_mod/request.rs
use std::io::{BufReader, BufRead, Read};
use crate::headers::Headers;
use super::Route;
use std::fmt;
#[derive(Debug)]
pub struct Request<R> {
pub reader: BufReader<Box<R>>,
pub headers: Headers,
pub route... | code_fim | hard | {
"lang": "rust",
"repo": "nicolasjhampton/rust-server-framework",
"path": "/http/src/request_mod/request.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<R: Read> fmt::Display for Request<R> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{route}\n{headers}\r\n{body}",
route = self.route,
headers = self.headers,
body = self.body.as_ref().unwrap()
)
}
}<|fim_prefix|>// ... | code_fim | hard | {
"lang": "rust",
"repo": "nicolasjhampton/rust-server-framework",
"path": "/http/src/request_mod/request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut raw_headers = String::new();
loop {
let line = Request::unwind(&mut reader);
if line.is_empty() || line == "\r\n" {
break;
} else {
raw_headers.push_str(format!("{}\n", line).as_str());
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "nicolasjhampton/rust-server-framework",
"path": "/http/src/request_mod/request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blogscot/a-simple-interpreter path: /tests/integration_tests.rs
extern crate basic_interpreter;
#[cfg(test)]
mod tests {
use basic_interpreter::{interpreter::*, utils::number::Number::Nil};
#[test]
fn begin_then_end() {
let mut interpreter = Interpreter::new(
r#"
PROGRAM em... | code_fim | hard | {
"lang": "rust",
"repo": "blogscot/a-simple-interpreter",
"path": "/tests/integration_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
#[should_panic]
fn should_panic_identifiers_cannot_contain_underscores() {
let mut interpreter = Interpreter::new(
r#"
PROGRAM NoUnderscore;
VAR an_int : INTEGER;
BEGIN
an_int := 10
END."#,
);
assert_eq!(interpreter.interpret(), Ok(Nil));
}
#[tes... | code_fim | hard | {
"lang": "rust",
"repo": "blogscot/a-simple-interpreter",
"path": "/tests/integration_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (index, line) in input_lines.iter().enumerate() {
let col = (index * 3) % width;
if line.chars().nth(col).unwrap() == '#' { count += 1 };
}
println!("{}", count);
}<|fim_prefix|>// repo: laurst/aoc-2020 path: /031.rs
use std::env;
use std::fs;
fn main() {
let args: Ve... | code_fim | medium | {
"lang": "rust",
"repo": "laurst/aoc-2020",
"path": "/031.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laurst/aoc-2020 path: /031.rs
use std::env;
use std::fs;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = args[1].clone();
let input_data = match fs::read_to_string(&filename) {
Ok(data) => data,
Err(_) => {
let filename = filenam... | code_fim | medium | {
"lang": "rust",
"repo": "laurst/aoc-2020",
"path": "/031.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let width = input_lines[0].len();
let mut count = 0;
for (index, line) in input_lines.iter().enumerate() {
let col = (index * 3) % width;
if line.chars().nth(col).unwrap() == '#' { count += 1 };
}
println!("{}", count);
}<|fim_prefix|>// repo: laurst/aoc-2020 path: /0... | code_fim | medium | {
"lang": "rust",
"repo": "laurst/aoc-2020",
"path": "/031.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davenza/ndarray-linalg path: /src/operator.rs
//! Linear Operator
use ndarray::*;
use super::types::*;
pub trait Operator<A, S, D>
where
S: Data<Elem = A>,
D: Dimension,
{
fn op(&self, &ArrayBase<S, D>) -> Array<A, D>;
}
pub trait OperatorInto<S, D>
where
S: DataMut,
D: D... | code_fim | hard | {
"lang": "rust",
"repo": "davenza/ndarray-linalg",
"path": "/src/operator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.