text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>impl<'a, T> Iterator for IterPreorder<'a, T> {
type Item = &'a T; // type parameter
fn next(&mut self) -> Option<Self::Item> {
// push popped elements.right, then .left to s, if they exist
let popped_var = self.stack.pop();
match popped_var {
Some(ref x) => {
match x.right {
Some(ref... | code_fim | hard | {
"lang": "rust",
"repo": "bryzhao/side_projects",
"path": "/btree_iterative_exercise.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn eof(&mut self, _source: &wyst_source::Source, span: Span) {
self.done = true;
if let Some(_) = self.current_parent {
panic!("eof() called when there was still an open delimiter")
};
if self.stack.len() > 0 {
panic!("eof() called when there w... | code_fim | hard | {
"lang": "rust",
"repo": "wycats/wyst",
"path": "/crates/lex/src/tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
tokens,
&[
b.ws(" "),
b.word("hello"),
b.ws(" "),
b.delimited(Delimiter::Brace, |b| {
vec![
b.ws(" "),
... | code_fim | hard | {
"lang": "rust",
"repo": "wycats/wyst",
"path": "/crates/lex/src/tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wycats/wyst path: /crates/lex/src/tree.rs
use std::collections::VecDeque;
use wyst_core::{unit_tests, wyst_copy, wyst_data};
use wyst_source::{AddSpan, Offset, Span, Spanned};
use crate::reader::{Reader, ReaderNext};
use crate::{delegate::QuoteResult, standard::Delimiter};
#[wyst_copy]
pub en... | code_fim | hard | {
"lang": "rust",
"repo": "wycats/wyst",
"path": "/crates/lex/src/tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OrangeBacon/adventofcode2020 path: /src/days/day20.rs
use anyhow::Result;
use hashbrown::HashSet;
use libaoc::{aoc, AocResult, Timer};
use regex::Regex;
use std::cell::RefCell;
use std::collections::BTreeMap;
#[derive(Clone, Debug, Copy)]
struct Adjacency {
id: usize,
side: usize,
f... | code_fim | hard | {
"lang": "rust",
"repo": "OrangeBacon/adventofcode2020",
"path": "/src/days/day20.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let part1 = adjacency_sums
.iter()
.fold(1, |acc, (id, val)| if *val == 2 { acc * id } else { acc });
timer.lap("Part 1");
let image_size = (input.len() as f32).sqrt() as usize;
let mut image = vec![vec![0usize; image_size]; image_size];
// first cell
image[0][0]... | code_fim | hard | {
"lang": "rust",
"repo": "OrangeBacon/adventofcode2020",
"path": "/src/days/day20.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/frunk path: /src/validated.rs
use super::hlist::*;
use std::ops::Add;
#[derive(PartialEq, Eq, Debug)]
pub enum Validated<T, E>
where T: HList
{
Ok(T),
Err(Vec<E>),
}
impl<T, E> Validated<T, E>
where T: HList
{
/// Returns true if this validation is Ok, false o... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/frunk",
"path": "/src/validated.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::super::hlist::*;
use super::*;
#[test]
fn test_adding_ok_results() {
let r1: Result<String, String> = Result::Ok(String::from("hello"));
let r2: Result<i32, String> = Result::Ok(1);
let v = r1.into_validated() + r2;
assert_eq!(v, Validated::Ok(hl... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/frunk",
"path": "/src/validated.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vijaylaxmid/fluvio path: /src/stream-model/src/store/mod.rs
mod concurrent_hashmap;
pub mod actions;
mod metadata;
mod filter;
mod dual_store;
<|fim_suffix|>pub use filter::*;
pub use concurrent_hashmap::*;
pub use metadata::*;
pub use dual_store::*;
// re-export epoch
pub use crate::epoch::*;... | code_fim | easy | {
"lang": "rust",
"repo": "vijaylaxmid/fluvio",
"path": "/src/stream-model/src/store/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// re-export epoch
pub use crate::epoch::*;<|fim_prefix|>// repo: vijaylaxmid/fluvio path: /src/stream-model/src/store/mod.rs
mod concurrent_hashmap;
pub mod actions;
mod metadata;
mod filter;
mod dual_store;
<|fim_middle|>#[cfg(feature = "k8")]
pub mod k8;
pub use filter::*;
pub use concurrent_hashmap... | code_fim | medium | {
"lang": "rust",
"repo": "vijaylaxmid/fluvio",
"path": "/src/stream-model/src/store/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hukumka/ranger path: /src/lens.rs
use std::marker::PhantomData;
pub trait Lens<I: ?Sized, O: ?Sized> {
fn get<R, F: FnOnce(&O) -> R>(&mut self, input: &I, func: F) -> R;
<|fim_suffix|>impl<I, O, F, T> Lens<I, O> for FnLens<I, O, F, T>
where
I: ?Sized,
O: ?Sized,
F: FnMut(&I) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "hukumka/ranger",
"path": "/src/lens.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> func((self.f)(input).as_ref())
}
}
pub struct FnRefLens<I: ?Sized, O: ?Sized, F> {
f: F,
_m1: PhantomData<I>,
_m2: PhantomData<O>,
}
impl<I, O, F> Lens<I, O> for FnRefLens<I, O, F>
where
I: ?Sized,
O: ?Sized,
F: FnMut(&I) -> &O,
{
fn get<R, F2: FnOnce(&O) -> R>(&m... | code_fim | hard | {
"lang": "rust",
"repo": "hukumka/ranger",
"path": "/src/lens.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tiles_high = tiles_high as f32;
vertex_data[index].uv[0] = x / tiles_wide;
vertex_data[index].uv[1] = y / tiles_high + tile_height_uv;
vertex_data[index + 1].uv[0] = x / tiles_wid... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/spellcaster-sacrifice",
"path": "/src/components/map/tiled.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agmcleod/spellcaster-sacrifice path: /src/components/map/tiled.rs
use specs::{Component, HashMapStorage};
use tiled;
use crate::renderer::Vertex;
pub struct TiledMap {
pub data: Vec<Vertex>,
// assuming usage of one tileset for now
pub tileset: String,
}
impl TiledMap {
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/spellcaster-sacrifice",
"path": "/src/components/map/tiled.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Then, add the top 3-5 top tracks for each user-artist pair that aren't already in there evn
// if there is no track-level intersection, meaning that each user's favorites that for
// shared artists are included
let artists_intersection = user1_artists.iter().filter(|artist| {
us... | code_fim | hard | {
"lang": "rust",
"repo": "beyonddream-productions/spotifytrack",
"path": "/backend/src/shared_playlist_gen.rs",
"mode": "spm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beyonddream-productions/spotifytrack path: /backend/src/shared_playlist_gen.rs
use rand::prelude::*;
use crate::{
models::{Track, User},
DbConn,
};
pub(crate) fn generate_shared_playlist_track_spotify_ids(
conn1: DbConn,
conn2: DbConn,
conn3: DbConn,
conn4: DbConn,
... | code_fim | hard | {
"lang": "rust",
"repo": "beyonddream-productions/spotifytrack",
"path": "/backend/src/shared_playlist_gen.rs",
"mode": "psm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: serrano90/rust-microservice path: /src/services/customer/src/infrastructure/repository/customer_repository.rs
/**
* ORM Customer Repository
*/
use diesel::RunQueryDsl;
use crate::domain::dto::customer::CustomerDTO;
use crate::domain::dto::customer::CustomerDTOList;
use crate::domain::entity::... | code_fim | hard | {
"lang": "rust",
"repo": "serrano90/rust-microservice",
"path": "/src/services/customer/src/infrastructure/repository/customer_repository.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let conn = &self.db.conn;
let new_customer = NewCustomer {
id: customer.id(),
first_name: customer.name(),
last_name: customer.last_name(),
email: customer.email(),
hotel_id: customer.hotel_id(),
};
let result = ... | code_fim | medium | {
"lang": "rust",
"repo": "serrano90/rust-microservice",
"path": "/src/services/customer/src/infrastructure/repository/customer_repository.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raimon49/rust-reference-study path: /src/main.rs
use std::collections::HashMap;
type Table = HashMap<String, Vec<String>>;
fn show(table: &Table) {
for (artist, works) in table {
// 関数showの仮引数が&Table型の場合、forループ変数artistも&String型となる
println!("works by {}:", artist);
f... | code_fim | hard | {
"lang": "rust",
"repo": "raimon49/rust-reference-study",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct Anime {
name: &'static str,
bachdel_pass: bool
};
let aria = Anime{ name: "Aria: The Animation", bachdel_pass: true };
let anime_ref = &aria;
assert_eq!(anime_ref.name, "Aria: The Animation");
assert_eq!(anime_ref.bachdel_pass, true);
assert_eq!((*anime_r... | code_fim | hard | {
"lang": "rust",
"repo": "raimon49/rust-reference-study",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frostyplanet/snips-rs path: /snips_derive/src/lib.rs
#![recursion_limit = "512"]
#[macro_use]
extern crate quote;
extern crate syn;
extern crate proc_macro;
use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};
use syn::{MetaNameValue, MetaList};
use syn::Meta::{List, NameValu... | code_fim | hard | {
"lang": "rust",
"repo": "frostyplanet/snips-rs",
"path": "/snips_derive/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn derive_snips_input(ast: &syn::DeriveInput) -> TokenStream {
let name = &ast.ident;
let n = "ahhaha";
if let syn::Data::Struct(ref s) = ast.data {
let mut headers_fields: Vec<String> = Vec::new();
let mut param_fields: Vec<String> = Vec::new();
let mut elm_fields: V... | code_fim | hard | {
"lang": "rust",
"repo": "frostyplanet/snips-rs",
"path": "/snips_derive/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadowsocks/shadowsocks-rust path: /crates/shadowsocks/src/lib.rs
//! Shadowsocks Core Library
#![crate_type = "lib"]
<|fim_suffix|>pub mod config;
pub mod context;
pub mod dns_resolver;
pub mod manager;
pub mod net;
pub mod plugin;
pub mod relay;
mod security;<|fim_middle|>pub use self::{
... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use shadowsocks_crypto as crypto;
pub mod config;
pub mod context;
pub mod dns_resolver;
pub mod manager;
pub mod net;
pub mod plugin;
pub mod relay;
mod security;<|fim_prefix|>// repo: shadowsocks/shadowsocks-rust path: /crates/shadowsocks/src/lib.rs
//! Shadowsocks Core Library
#![crate_type = "l... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args: Vec<String> = env::args().collect();
let query = &args[1];
let mut socket = UdpSocket::bind("127.0.0.1:45678").expect("couldn't bind to address");
socket.send_to(&[0; 10], "8.8.8.8:53").expect("couldn't send data");
}
fn construct_message(domain: &String) {
//
}<|fim_pref... | code_fim | hard | {
"lang": "rust",
"repo": "kumarde/dns",
"path": "/a_record/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kumarde/dns path: /a_record/src/main.rs
use std::net::{IpAddr, UdpSocket};
struct RR_Header {
name: String,
type: u16,
class: u16,
ttl: u32,
rdlength: u16
}
<|fim_suffix|>struct Question {
name: String,
Qtype: u16,
Qclass: u16
}
fn main() {
let args: ... | code_fim | medium | {
"lang": "rust",
"repo": "kumarde/dns",
"path": "/a_record/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for ExprId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "#{}", self.id)
}
}
impl From<usize> for ExprId {
fn from(id: usize) -> ExprId {
ExprId { id: id }
}
}
#[derive(Debug, Clone)]
pub struct FieldAccessInfo {
pub record_id: T... | code_fim | hard | {
"lang": "rust",
"repo": "jaffa4/siko-1",
"path": "/crates/siko_ir/src/expr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jaffa4/siko-1 path: /crates/siko_ir/src/expr.rs
use crate::class::ClassMemberId;
use crate::data::TypeDefId;
use crate::function::FunctionId;
use crate::pattern::BindGroup;
use crate::pattern::PatternId;
use siko_util::format_list;
use std::fmt;
#[derive(Debug, Clone, Copy)]
pub struct Function... | code_fim | hard | {
"lang": "rust",
"repo": "jaffa4/siko-1",
"path": "/crates/siko_ir/src/expr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "#{}", self.id)
}
}
impl From<usize> for ExprId {
fn from(id: usize) -> ExprId {
ExprId { id: id }
}
}
#[derive(Debug, Clone)]
pub struct FieldAccessInfo {
pub record_id: TypeDefId,
pub index: usize,
}
impl fmt::Display for FieldAccessInfo {
fn fmt(&sel... | code_fim | hard | {
"lang": "rust",
"repo": "jaffa4/siko-1",
"path": "/crates/siko_ir/src/expr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> } else {
let id = buckets.len();
let file_name = format!("{}.data", id);
let mut path = output_dir.clone();
files.push(file_name.clone());
path.push(file_name);
let path: std::path::PathBuf = path... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/rust-vulkan-renderer",
"path": "/rvrc/src/bundle_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vengarioth/rust-vulkan-renderer path: /rvrc/src/bundle_builder.rs
use crate::Error;
use rvr_assets::{shader::ShaderAsset, AssetType};
use tinypath::Path;
use std::io::prelude::*;
use std::fs::OpenOptions;
const MAX_FILE_SIZE: usize = 4294967295;
#[derive(Debug)]
struct BundleEntry {
addres... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/rust-vulkan-renderer",
"path": "/rvrc/src/bundle_builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let location = rvr_assets::AssetLocation::new(
entry.address,
entry.asset_type,
index,
offset,
entry.data.len(),
);
locations.push(location);
} ... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/rust-vulkan-renderer",
"path": "/rvrc/src/bundle_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TanTanDev/bevy-inspector-egui path: /examples/vec_as_dropdown.rs
use bevy::prelude::*;
use bevy_inspector_egui::{Inspectable, InspectorPlugin};
use std::fmt::{Debug, Display};
pub struct VecAsDropdown<T>
where
T: Clone + Display + PartialEq,
{
from: Vec<T>,
selected: usize,
}
impl<T... | code_fim | hard | {
"lang": "rust",
"repo": "TanTanDev/bevy-inspector-egui",
"path": "/examples/vec_as_dropdown.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let vec_of_ints = VecAsDropdown::new(vec![100, 200, 300, 400]);
let vec_of_strings = VecAsDropdown::new(
vec!["Some", "Thing", "And Another"]
.iter()
.map(|s| s.to_string())
.collect(),
);
Data {
vec_of... | code_fim | hard | {
"lang": "rust",
"repo": "TanTanDev/bevy-inspector-egui",
"path": "/examples/vec_as_dropdown.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Berteun/adventofcode2019 path: /day01_rs/src/main.rs
use std::cmp;
use std::fs::File;
use std::io::{prelude::*, BufReader};
fn read_input() -> Vec<u32> {
let file = File::open("input_day01.txt").unwrap();
let reader = BufReader::new(file);
let mut vec = Vec::new();
for line in ... | code_fim | hard | {
"lang": "rust",
"repo": "Berteun/adventofcode2019",
"path": "/day01_rs/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn compute_fuel_with_fuel(masses: &[u32]) -> u32 {
let mut fuel = 0;
for mass in masses {
let base_fuel = mass / 3 - 2;
fuel += base_fuel + fuel_for_fuel(base_fuel)
}
return fuel;
}
fn main() {
let mass_list = read_input();
let fuel = compute_fuel(&mass_list);
... | code_fim | hard | {
"lang": "rust",
"repo": "Berteun/adventofcode2019",
"path": "/day01_rs/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mass_list = read_input();
let fuel = compute_fuel(&mass_list);
println!("Part 01: {}", fuel);
let fuel_with_fuel = compute_fuel_with_fuel(&mass_list);
println!("Part 02: {}", fuel_with_fuel);
}<|fim_prefix|>// repo: Berteun/adventofcode2019 path: /day01_rs/src/main.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "Berteun/adventofcode2019",
"path": "/day01_rs/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michelepagot/granchiettimarini path: /src/print.rs
pub fn run(){
let x = 9;
println!("Cia Ciao {} {}", x, "Gino");
println!("Sopra<|fim_suffix|>{:x} Octal={:0}", 20, 20, 20);
println!("Debug {:?}", (1, (1.2, "no"), 1==2, 12 + 1));
}<|fim_middle|> la {0} la {1} campa, sotto la {0}... | code_fim | medium | {
"lang": "rust",
"repo": "michelepagot/granchiettimarini",
"path": "/src/print.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>{:x} Octal={:0}", 20, 20, 20);
println!("Debug {:?}", (1, (1.2, "no"), 1==2, 12 + 1));
}<|fim_prefix|>// repo: michelepagot/granchiettimarini path: /src/print.rs
pub fn run(){
let x = 9;
println!("Cia Ciao {} {}", x, "Gino");
println!("Sopra<|fim_middle|> la {0} la {1} campa, sotto la {0}... | code_fim | medium | {
"lang": "rust",
"repo": "michelepagot/granchiettimarini",
"path": "/src/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn switch(&mut self, state: &mut State, entity: Entity) {
if self.checked {
self.checked = false;
if let Some(icon_unchecked) = &self.icon_unchecked {
entity.set_text(state, &icon_unchecked);
}
entity.set_checked(state, false);
... | code_fim | hard | {
"lang": "rust",
"repo": "SonicZentropy/tuix",
"path": "/core/src/widgets/checkbox.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn on_unchecked(mut self, event: Event) -> Self {
self.on_unchecked = Some(event);
self
}
}
impl BuildHandler for Checkbox {
type Ret = Entity;
fn on_build(&mut self, state: &mut State, entity: Entity) -> Self::Ret {
entity
.set_font(state, "icons")... | code_fim | hard | {
"lang": "rust",
"repo": "SonicZentropy/tuix",
"path": "/core/src/widgets/checkbox.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SonicZentropy/tuix path: /core/src/widgets/checkbox.rs
#![allow(dead_code)]
use crate::widgets::*;
use crate::{BuildHandler, Event, EventHandler};
use crate::{PropSet, State, Color};
use crate::style::layout::{Align, Justify};
const ICON_CHECK: &str = "\u{2713}";
#[derive(Clone, Copy, Debug,... | code_fim | hard | {
"lang": "rust",
"repo": "SonicZentropy/tuix",
"path": "/core/src/widgets/checkbox.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GreenLoofa/ray_tracer path: /src/vec3.rs
use std::ops::{Add, Sub, Div, Mul, Neg};
#[derive(Debug, Copy)]
pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
impl Vec3 {
pub fn new(x: f64, y: f64, z: f64) -> Vec3 {
Vec3{x, y, z}
}
pub fn make_unit_vector(&mu... | code_fim | hard | {
"lang": "rust",
"repo": "GreenLoofa/ray_tracer",
"path": "/src/vec3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Mul<f64> for Vec3 {
type Output = Vec3;
fn mul(self, val: f64) -> Vec3 {
Vec3 {
x: self.x * val,
y: self.y * val,
z: self.z * val
}
}
}
impl Mul<Vec3> for f64 {
type Output = Vec3;
fn mul(self, other: Vec3) -> Vec3 {
V... | code_fim | hard | {
"lang": "rust",
"repo": "GreenLoofa/ray_tracer",
"path": "/src/vec3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn mul(self, val: f64) -> Vec3 {
Vec3 {
x: self.x * val,
y: self.y * val,
z: self.z * val
}
}
}
impl<'a> Mul<&'a Vec3> for f64 {
type Output = Vec3;
fn mul(self, other: &'a Vec3) -> Vec3 {
Vec3 {
x: self * other.x,
... | code_fim | hard | {
"lang": "rust",
"repo": "GreenLoofa/ray_tracer",
"path": "/src/vec3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[actix_rt::test]
async fn should_send_and_wait_for_response() {
// Arrange
let threads = 5;
let buffer_size = 10;
let sender = start_blocking_runner(threads, buffer_size, move || TestRunner {
callback: Arc::new(move |message: String| {
... | code_fim | hard | {
"lang": "rust",
"repo": "Toure/tornado",
"path": "/tornado/common/src/pool/blocking_pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Toure/tornado path: /tornado/common/src/pool/blocking_pool.rs
use crate::pool::{ReplyRequest, Runner, Sender};
use async_channel::{bounded, unbounded};
use log::*;
use std::thread;
/// Executes a blocking callback every time a message is sent to the returned Sender.
/// The callback is executed... | code_fim | hard | {
"lang": "rust",
"repo": "Toure/tornado",
"path": "/tornado/common/src/pool/blocking_pool.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::*;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::time::Duration;
use tokio::time;
#[actix_rt::test]
async fn should_execute_max_parallel_blocking_tasks() {
// Arrange
let threads = 5;
let buffer_size = 10;
... | code_fim | hard | {
"lang": "rust",
"repo": "Toure/tornado",
"path": "/tornado/common/src/pool/blocking_pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hdxia/attestation-agent path: /src/kbc_modules/mod.rs
// Copyright (c) 2021 Alibaba Cloud
//
// SPDX-License-Identifier: Apache-2.0
//
// Add your specific kbc declaration here.
// For example: "pub mod sample_kbc;"
#[cfg(feature = "sample_kbc")]
pub mod sample_kbc;
// add isecl kbc module
#[c... | code_fim | hard | {
"lang": "rust",
"repo": "hdxia/attestation-agent",
"path": "/src/kbc_modules/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "sample_kbc")]
{
let instantiate_func: KbcInstantiateFunc = Box::new(|kbs_uri: String| -> KbcInstance {
Box::new(sample_kbc::SampleKbc::new(kbs_uri))
});
mod_list.insert("sample_kbc".to_string(), instantiate_func);
... | code_fim | medium | {
"lang": "rust",
"repo": "hdxia/attestation-agent",
"path": "/src/kbc_modules/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryuz/jelly path: /projects/kv260/kv260_jfive_simple_controller/app/apu/src/main.rs
#![allow(dead_code)]
use std::fs::File;
use std::io::{Read, BufReader};
use jelly_mem_access::*;
const REG_JFIVE_CORE_ID : usize = 0x0;
const REG_JFIVE_CORE_VERSION : usize = 0x1;
const REG_JFIVE_CORE_DATE... | code_fim | hard | {
"lang": "rust",
"repo": "ryuz/jelly",
"path": "/projects/kv260/kv260_jfive_simple_controller/app/apu/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // mmap uio
println!("\nuio open");
let uio_acc = UioAccessor::<usize>::new_with_name("uio_pl_peri").unwrap();
println!("uio_pl_peri phys addr : 0x{:x}", uio_acc.phys_addr());
println!("uio_pl_peri size : 0x{:x}", uio_acc.size());
unsafe {
// メモリアドレスでアクセス
prin... | code_fim | medium | {
"lang": "rust",
"repo": "ryuz/jelly",
"path": "/projects/kv260/kv260_jfive_simple_controller/app/apu/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // program download
let mut reader = BufReader::new(File::open("../jfive/jfive_sample.bin").unwrap());
let mut buf: [u8; 4] = [0; 4];
let mut adr: usize = 0;
loop {
match reader.read(&mut buf).unwrap() {
0 => break,
_ => {
let data = u32:... | code_fim | hard | {
"lang": "rust",
"repo": "ryuz/jelly",
"path": "/projects/kv260/kv260_jfive_simple_controller/app/apu/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bassj/rise path: /src/rise/graphics/material/mod.rs
mod uniform;
pub use uniform::{CameraUniform, Uniform, UniformBinding};
<|fim_suffix|>pub use material::{Material, MaterialBuilder};
mod material_instance;
pub use material_instance::{MaterialInstance, MaterialInstanceBuilder};<|fim_middle... | code_fim | easy | {
"lang": "rust",
"repo": "bassj/rise",
"path": "/src/rise/graphics/material/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use material_instance::{MaterialInstance, MaterialInstanceBuilder};<|fim_prefix|>// repo: bassj/rise path: /src/rise/graphics/material/mod.rs
mod uniform;
pub use uniform::{CameraUniform, Uniform, UniformBinding};
<|fim_middle|>mod material;
pub use material::{Material, MaterialBuilder};
mod mat... | code_fim | medium | {
"lang": "rust",
"repo": "bassj/rise",
"path": "/src/rise/graphics/material/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let headers = carrier::headers::Headers::decode(&osaka::sync!(stream)).expect("headers");
println!("{:?}", headers);
into_raw_mode().expect("into raw mode");
unsafe {
libc::atexit(atexit);
}
loop {
let mut buf = [1; 1024];
match stdin.read(&mut buf[1..]) {... | code_fim | hard | {
"lang": "rust",
"repo": "devguardio/carrier",
"path": "/rust/src/shell.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devguardio/carrier path: /rust/src/shell.rs
use carrier::error::Error;
use libc;
use log::warn;
use nix::fcntl;
use osaka::mio;
use osaka::osaka;
use osaka::Future;
use std::fs;
use std::io::{Read, Write};
use std::mem;
use std::os::unix::io::AsRawFd;
use byteorder::{BigEndian, ReadBytesExt};
us... | code_fim | hard | {
"lang": "rust",
"repo": "devguardio/carrier",
"path": "/rust/src/shell.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>or: an alias for `Reg<TVE_AUTO_DETECTION_STATUS_SPEC>`"]
pub type TVE_AUTO_DETECTION_STATUS =
crate::Reg<tve_auto_detection_status::TVE_AUTO_DETECTION_STATUS_SPEC>;
#[doc = "TV Encoder Auto Detection Status Register"]
pub mod tve_auto_detection_status;
#[doc = "tve_auto_detection_debounce_setting (rw)... | code_fim | hard | {
"lang": "rust",
"repo": "duskmoon314/aw-pac",
"path": "/d1-pac/src/tve.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /d1-pac/src/tve.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - TV Encoder Clock Gating Register"]
pub tve_clock_gating: TVE_CLOCK_GATING,
#[doc = "0x04 - TV Encoder Configuration Register"]
pub tve_configuration: TVE_C... | code_fim | hard | {
"lang": "rust",
"repo": "duskmoon314/aw-pac",
"path": "/d1-pac/src/tve.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> set.union(6, 7);
assert_eq!(8, set.find(0));
assert_eq!(8, set.find(1));
assert_eq!(8, set.find(2));
assert_eq!(8, set.find(3));
assert_eq!(8, set.find(4));
assert_eq!(8, set.find(5));
assert_eq!(8, set.find(6));
assert_eq!(8, set.fin... | code_fim | hard | {
"lang": "rust",
"repo": "diffeo/kodama",
"path": "/src/union.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let p = self.parents[cluster];
if p == cluster {
None
} else {
Some(p)
}
}
/// Relabel the cluster labels in each step of a complete dendrogram.
///
/// If the given method requires the dendrogram to be sorted, then the
/// steps... | code_fim | hard | {
"lang": "rust",
"repo": "diffeo/kodama",
"path": "/src/union.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: diffeo/kodama path: /src/union.rs
use std::usize;
use crate::dendrogram::Dendrogram;
use crate::Method;
/// A specialized implementation of union-find for linkage.
///
/// This union-find implementation represents a set of cluster labels. It
/// supports fast lookups and fast unions.
///
/// T... | code_fim | hard | {
"lang": "rust",
"repo": "diffeo/kodama",
"path": "/src/union.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KerrMetric/rust-chain path: /src/main.rs
use command::commands;
use std::collections::VecDeque;
fn main() {
<|fim_suffix|> command
.run()
.unwrap_or_else(|e| panic!("failed to run. because {}", e));
println!("completed!");
}<|fim_middle|> println!("Start Rust Chain!")... | code_fim | hard | {
"lang": "rust",
"repo": "KerrMetric/rust-chain",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> command
.run()
.unwrap_or_else(|e| panic!("failed to run. because {}", e));
println!("completed!");
}<|fim_prefix|>// repo: KerrMetric/rust-chain path: /src/main.rs
use command::commands;
use std::collections::VecDeque;
fn main() {
println!("Start Rust Chain!");
let mut... | code_fim | medium | {
"lang": "rust",
"repo": "KerrMetric/rust-chain",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let game = Game::new("greyson", "julia");
let expected = "\
==================================
TURN: 1
greyson:
A B C D E F G H I J
_______________________________
1 | . . . . . . . . . .
2 | . . . . . . . . . .
3 | . . . . . . . .... | code_fim | medium | {
"lang": "rust",
"repo": "mtthwcmpbll/rust-battleship",
"path": "/game/src/game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> display
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn game_creation() {
let game = Game::new("greyson", "julia");
let expected = "\
==================================
TURN: 1
greyson:
A B C D E F G H I J
_____________________________... | code_fim | hard | {
"lang": "rust",
"repo": "mtthwcmpbll/rust-battleship",
"path": "/game/src/game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mtthwcmpbll/rust-battleship path: /game/src/game.rs
use crate::player::Player;
use crate::board::Board;
pub struct Game {
pub player1: Player,
pub player2: Player,
pub board: Board,
}
impl Game {
pub fn new(p1: &str, p2: &str) -> Game {
Game {
player1: Playe... | code_fim | medium | {
"lang": "rust",
"repo": "mtthwcmpbll/rust-battleship",
"path": "/game/src/game.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ytakano/baremetalisp path: /kernel/src/driver/device/mod.rs
/// The files in this directory must be moved to crate::bsp
<|fim_suffix|>// Pine64, Allwineer sunxi
#[cfg(feature = "pine64")]
pub(crate) mod allwinner;<|fim_middle|>// Raspberry Pi 4, Broadcom BCM2xxx
#[cfg(any(feature = "raspi3", fe... | code_fim | medium | {
"lang": "rust",
"repo": "ytakano/baremetalisp",
"path": "/kernel/src/driver/device/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Pine64, Allwineer sunxi
#[cfg(feature = "pine64")]
pub(crate) mod allwinner;<|fim_prefix|>// repo: ytakano/baremetalisp path: /kernel/src/driver/device/mod.rs
/// The files in this directory must be moved to crate::bsp
<|fim_middle|>// Raspberry Pi 4, Broadcom BCM2xxx
#[cfg(any(feature = "raspi3", fe... | code_fim | medium | {
"lang": "rust",
"repo": "ytakano/baremetalisp",
"path": "/kernel/src/driver/device/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hooops/crypto-crawler-rs path: /crypto-markets/src/exchanges/binance/binance_inverse.rs
use super::utils::{binance_http_get, parse_filter};
use crate::{error::Result, market::*, Market, MarketType};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
#[de... | code_fim | hard | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-markets/src/exchanges/binance/binance_inverse.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let raw_markets = fetch_inverse_markets_raw()?;
let markets = raw_markets
.into_iter()
.map(|m| {
Market {
exchange: "binance".to_string(),
market_type: if m.contractType == "PERPETUAL" {
MarketType::InverseSwap
... | code_fim | hard | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-markets/src/exchanges/binance/binance_inverse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yrashk/hbbft path: /src/broadcast/mod.rs
//! Reliable broadcast algorithm.
use std::collections::{HashMap, HashSet};
use std::net::{TcpStream, TcpListener, SocketAddr};
use errors::ResultExt;
use task::{Error, MessageLoop, Task};
use proto::message::{MessageProto, ValueProto, EchoProto, ReadyPro... | code_fim | medium | {
"lang": "rust",
"repo": "yrashk/hbbft",
"path": "/src/broadcast/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match self.task.receive_message() {
Ok(message) => self.on_message_received(message).unwrap(),
Err(Error::ProtobufError(e)) => warn!("Protobuf error {}", e),
Err(e) => {
warn!("Critical error {:?}", e);
... | code_fim | hard | {
"lang": "rust",
"repo": "yrashk/hbbft",
"path": "/src/broadcast/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(two_sum(vec!(2, 7, 11, 15), 9), vec!(0, 1));
}<|fim_prefix|>// repo: bachue/rust-leetcode path: /1. Two Sum/src/main.rs
use std::collections::HashMap;
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut nums_map: HashMap<i32, i32> = HashMap::with_capacity(nums.len());
... | code_fim | medium | {
"lang": "rust",
"repo": "bachue/rust-leetcode",
"path": "/1. Two Sum/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bachue/rust-leetcode path: /1. Two Sum/src/main.rs
use std::collections::HashMap;
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut nums_map: HashMap<i32, i32> = HashMap::with_capacity(nums.len());
for i in 0..nums.len() {
if let Some(&get_index) = nums_map.get(&... | code_fim | medium | {
"lang": "rust",
"repo": "bachue/rust-leetcode",
"path": "/1. Two Sum/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod failing {
use monolith::utils;
#[test]
fn sub_domain_must_not_be_within_domain() {
assert!(!utils::domain_is_within_domain(
"news.ycombinator.com",
"ycombinator.com"
));
}
#[test]
fn domain_must_not_be_within_top_level_doma... | code_fim | hard | {
"lang": "rust",
"repo": "Y2Z/monolith",
"path": "/tests/utils/domain_is_within_domain.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Y2Z/monolith path: /tests/utils/domain_is_within_domain.rs
// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║
// ... | code_fim | hard | {
"lang": "rust",
"repo": "Y2Z/monolith",
"path": "/tests/utils/domain_is_within_domain.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qeedquan/challenges path: /leetcode/flip-string-to-monotone-increasing.rs
/*
A binary string is monotone increasing if it consists of some number of 0's (possibly none), followed by some number of 1's (also possibly none).
You are given a binary string s. You can flip s[i] changing it from 0 t... | code_fim | medium | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/leetcode/flip-string-to-monotone-increasing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(minflips("00110"), 1);
assert_eq!(minflips("010110"), 2);
assert_eq!(minflips("00011000"), 2);
}
fn minflips(string: &str) -> isize {
let mut flips = 0;
let mut ones = 0;
for ch in string.chars() {
if ch == '0' {
if ones == 0 {
contin... | code_fim | medium | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/leetcode/flip-string-to-monotone-increasing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix-protocol/src/handshake/refs/async_io.rs
use crate::handshake::{refs, refs::parse::Error, Ref};
/// Parse refs from the given input line by line. Protocol V2 is required for this to succeed.
pub async fn from_v2_refs(in_refs: &mut dyn gix_transport::client::ReadlineBufR... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-protocol/src/handshake/refs/async_io.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some(line) = in_refs
.readline()
.await
.transpose()?
.transpose()?
.and_then(|l| l.as_bstr())
{
refs::shared::parse_v1(number_of_possible_symbolic_refs_for_lookup, &mut out_refs, line)?;
}
Ok(out_refs.into_iter().map(Into::into).co... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-protocol/src/handshake/refs/async_io.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: feds01/lang path: /compiler/hash-ast/src/parse.rs
//! Hash compiler module for parsing source code into AST
//!
//! All rights reserved 2021 (c) The Hash Language authors
use crate::{
ast::{self, *},
error::{ParseError, ParseResult},
module::{ModuleBuilder, Modules},
resolve::{M... | code_fim | hard | {
"lang": "rust",
"repo": "feds01/lang",
"path": "/compiler/hash-ast/src/parse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut errors = errors.into_inner().unwrap();
if let Some(err) = errors.pop_front() {
Err(err)
} else {
// @@Todo: return all errors.
let modules = module_builder.build();
Ok((maybe_interactive_node, modules))
}
}
}
impl... | code_fim | hard | {
"lang": "rust",
"repo": "feds01/lang",
"path": "/compiler/hash-ast/src/parse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let txid =
cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None).unwrap();
let out = cl.get_tx_out(&txid, 0, Some(false)).unwrap();
assert!(out.is_none());
let out = cl.get_tx_out(&txid, 0, Some(true)).unwrap();
assert!(out.is_some());
let _ = cl.g... | code_fim | hard | {
"lang": "rust",
"repo": "rust-bitcoin/rust-bitcoincore-rpc",
"path": "/integration_test/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-bitcoin/rust-bitcoincore-rpc path: /integration_test/src/main.rs
cl);
test_add_ban(&cl);
test_set_network_active(&cl);
test_get_index_info(&cl);
test_stop(cl);
}
fn test_get_network_info(cl: &Client) {
let _ = cl.get_network_info().unwrap();
}
fn test_get_mining_info(c... | code_fim | hard | {
"lang": "rust",
"repo": "rust-bitcoin/rust-bitcoincore-rpc",
"path": "/integration_test/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-bitcoin/rust-bitcoincore-rpc path: /integration_test/src/main.rs
xid,
vout: unspent.vout,
sequence: None,
};
let mut output = HashMap::new();
output.insert(RANDOM_ADDRESS.to_string(), btc(1));
let psbt = cl
.wallet_create_funded_psbt(&[input.clone()],... | code_fim | hard | {
"lang": "rust",
"repo": "rust-bitcoin/rust-bitcoincore-rpc",
"path": "/integration_test/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvark/naga path: /src/front/wgsl/tests.rs
use super::parse_str;
#[test]
fn parse_comment() {
parse_str(
"//
////
///////////////////////////////////////////////////////// asda
//////////////////// dad ////////// /
/////////////////////////////////////... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/naga",
"path": "/src/front/wgsl/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> parse_str(
"
fn foo() {}
fn bar() { foo(); }
",
)
.unwrap();
}
#[test]
fn parse_if() {
parse_str(
"
fn main() {
if (true) {
discard;
} else {}
if (0 != 1) {}
if (false) {
... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/naga",
"path": "/src/front/wgsl/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> parse_str(
"fn foo() {
var x: f32 = 1.0;
let px = &x;
let py = frexp(0.5, px);
}",
)
.unwrap();
}
#[test]
fn parse_struct_instantiation() {
parse_str(
"
struct Foo {
a: f32;
b: vec3<f32>;
};
[[stage(fragment)]]
... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/naga",
"path": "/src/front/wgsl/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = get_parsed_input();
// ...before running the program, replace position 1 with the value 12 and replace
// position 2 with the value 2.
input[1] = 12;
input[2] = 2;
let output = run(&mut input).unwrap();
assert_eq!(output[0], 3850704);... | code_fim | hard | {
"lang": "rust",
"repo": "andrewmwhite/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::io::{BufRead,BufReader};
use std::fs;
let fs = BufReader::new(fs::File::open("data/day2.input").unwrap());
let lines: Vec<String> = fs.lines()
.filter_map(std::result::Result::ok)
.collect();
... | code_fim | hard | {
"lang": "rust",
"repo": "andrewmwhite/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewmwhite/advent-of-code-2019 path: /src/day2.rs
/// --- Day 2: 1202 Program Alarm ---
///
/// https://adventofcode.com/2019/day/2
///
use std::error;
use std::fmt;
type Result<T> = std::result::Result<T, UnknownOpcodeError>;
#[derive(Debug, Clone)]
pub struct UnknownOpcodeError;
impl fmt:... | code_fim | hard | {
"lang": "rust",
"repo": "andrewmwhite/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(MeshShaderTexture {
buffer: texture_buffer,
image: texture_image,
location: gl.get_uniform_location(&program, "uTexture"),
})
... | code_fim | hard | {
"lang": "rust",
"repo": "AlcyZ/sdx-browser-game",
"path": "/src/renderer/mesh/shader/textures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let texture_image = JsFuture::from(load_image(data_array))
.await?
.dyn_into::<HtmlImageElement>()?;
let texture_buffer = gl.create_texture().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "AlcyZ/sdx-browser-game",
"path": "/src/renderer/mesh/shader/textures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlcyZ/sdx-browser-game path: /src/renderer/mesh/shader/textures.rs
use crate::definitions::gltf::{GlTf, GlTfMeshPrimitive};
use crate::loader::glb::GlbBuffer;
use js_sys::Promise;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
use web_sys::{
HtmlI... | code_fim | hard | {
"lang": "rust",
"repo": "AlcyZ/sdx-browser-game",
"path": "/src/renderer/mesh/shader/textures.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whiter4bbit/milliseriesdb path: /src/restapi/error.rs
use crate::storage::error::Error;
use serde_derive::Serialize;
use std::convert::Infallible;
use warp::http::StatusCode;
use warp::reject::{Reject, Rejection};
#[derive(Debug)]
struct NotFound {
series: String,
}
impl Reject for NotFoun... | code_fim | hard | {
"lang": "rust",
"repo": "whiter4bbit/milliseriesdb",
"path": "/src/restapi/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(not_found) = err.find::<NotFound>() {
code = StatusCode::NOT_FOUND;
message = format!("series '{}' not found", not_found.series);
} else if let Some(internal) = err.find::<InternalError>() {
code = StatusCode::INTERNAL_SERVER_ERROR;
message = format!("in... | code_fim | hard | {
"lang": "rust",
"repo": "whiter4bbit/milliseriesdb",
"path": "/src/restapi/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use internal::{
case,
offer_left,
offer_right,
};<|fim_prefix|>// repo: balzers/ferrite path: /src/session/choice/binary/mod.rs
mod external;
mod internal;
<|fim_middle|>pub use external::{
choose_left,
choose_right,
offer_choice,
};
| code_fim | medium | {
"lang": "rust",
"repo": "balzers/ferrite",
"path": "/src/session/choice/binary/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: balzers/ferrite path: /src/session/choice/binary/mod.rs
mod external;
mod internal;
<|fim_suffix|>pub use internal::{
case,
offer_left,
offer_right,
};<|fim_middle|>pub use external::{
choose_left,
choose_right,
offer_choice,
};
| code_fim | medium | {
"lang": "rust",
"repo": "balzers/ferrite",
"path": "/src/session/choice/binary/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruza-net/eru path: /src/main.rs
#[macro_use]
mod utils;
mod styles;
mod behavior;
mod components;
mod model;
<|fim_suffix|>fn main() {
components::App::run(fill![]).expect("error running application");
}<|fim_middle|>
use iced::Application;
| code_fim | easy | {
"lang": "rust",
"repo": "ruza-net/eru",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.