text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: yc0/7daysofrust path: /day1/results/src/main.rs use std::collections::HashMap; use std::env::args; fn main() { let mut hm = HashMap::new(); hm.insert(1, "Apple"); hm.insert(3, "Cargo"); hm.insert(5, "Eagle"); let mut rst = match &hm.get(&3) { Some(v) => v, _ =...
code_fim
hard
{ "lang": "rust", "repo": "yc0/7daysofrust", "path": "/day1/results/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KevinMackenzie/ferric-falcon path: /src/main.rs use nalgebra::base::*; mod math; <|fim_suffix|> println!("Hello, world!"); let v0 = Vector3::new(1.0, 2.0, 3.0); let n = 2.0 * v0; let r = math::ray::Ray{pos: v0, dir: Unit::new_normalize(Vector3::new(0.0, 1.0, 1.0))}; let s = r...
code_fim
easy
{ "lang": "rust", "repo": "KevinMackenzie/ferric-falcon", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Hello, world!"); let v0 = Vector3::new(1.0, 2.0, 3.0); let n = 2.0 * v0; let r = math::ray::Ray{pos: v0, dir: Unit::new_normalize(Vector3::new(0.0, 1.0, 1.0))}; let s = r.derive(4.0); println!("{}", n); println!("{}", s); println!("{}", r); }<|fim_prefix|>// repo:...
code_fim
easy
{ "lang": "rust", "repo": "KevinMackenzie/ferric-falcon", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use audio_barcode::test_utils::*; use std::sync::{Arc, Mutex}; #[test] fn test_send_and_receive_message() { const SAMPLE_RATE: u32 = 44100; const MESSAGES: [&str; 5] = ["Test Message", "Another Message", "", "Hi", "😀😁😂😃😄😅"];...
code_fim
hard
{ "lang": "rust", "repo": "Unrud/audio-barcode", "path": "/examples/web/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Unrud/audio-barcode path: /examples/web/src/lib.rs extern crate audio_barcode; extern crate js_sys; use audio_barcode::{ Transceiver, ATTACK_TIME, BEEP_TIME, PACKET_LEN, PAYLOAD_LEN, RELEASE_TIME, SYMBOL_BITS, SYMBOL_COUNT, SYMBOL_MNEMONICS, }; use wasm_bindgen::prelude::*; pub const M...
code_fim
hard
{ "lang": "rust", "repo": "Unrud/audio-barcode", "path": "/examples/web/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut bits = Vec::<bool>::with_capacity(PAYLOAD_LEN * SYMBOL_BITS); for &symbol in payload.iter() { for i in (0..SYMBOL_BITS).rev() { bits.push((symbol >> i) & 1 == 1); } } // check for marker of new message if bits[0] == tr...
code_fim
hard
{ "lang": "rust", "repo": "Unrud/audio-barcode", "path": "/examples/web/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kayryu/mweb path: /src/main.rs mod web; use web::{Handler, WebServer}; fn main() { println!("Hello, world!"); env_logger::init(); let handler = Handler {}; let server = WebServer::new(handler); server.launch(); } <|fim_suffix|> //Parse uri and assign it to variable...
code_fim
hard
{ "lang": "rust", "repo": "Kayryu/mweb", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut tls = tls::Config::default(); tls.add_root_cert_file_pem(std::path::Path::new("ca_cert.pem")).unwrap(); println!("tls load success"); let mut stream = tls.connect(addr.host().unwrap_or(""), stream) .unwrap(); println!("tls bind success"); ...
code_fim
hard
{ "lang": "rust", "repo": "Kayryu/mweb", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Print boot message println!("Flower kernel boot!"); println!("-------------------\n"); // Reset colors terminal::STDOUT.write().set_color(color!(White on Black)) .expect("Color should be supported"); let mut controller = ps2::CONTROLLER.lock(); match controller.ini...
code_fim
hard
{ "lang": "rust", "repo": "memoryruins/flower", "path": "/kernel/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_use] mod terminal; mod drivers; /// Kernel main function #[no_mangle] pub extern fn kmain() -> ! { interrupts::init(); terminal::STDOUT.write().clear().expect("Screen clear failed"); print_flower().expect("Flower print failed"); terminal::STDOUT.write().set_color(color!(Green o...
code_fim
hard
{ "lang": "rust", "repo": "memoryruins/flower", "path": "/kernel/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: memoryruins/flower path: /kernel/src/lib.rs #![no_std] #![feature(asm)] #![feature(lang_items)] #![feature(const_fn)] #![feature(unique, const_unique_new)] #![feature(slice_rotate)] #![feature(try_from)] #![feature(nll)] #![feature(inclusive_range_syntax)] #![feature(type_ascription)] #![featur...
code_fim
hard
{ "lang": "rust", "repo": "memoryruins/flower", "path": "/kernel/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> //fn main() { // if let Some(v) = opt_val(60) { // println!("{}", v); // } //}<|fim_prefix|>// repo: meilier/rust-error-handle path: /src/demo_09_01_option_if_some.rs fn opt_val(num: i32) -> Option<String> { if num >= 60 { return Some("foo bar".to_string()); } None } <|...
code_fim
hard
{ "lang": "rust", "repo": "meilier/rust-error-handle", "path": "/src/demo_09_01_option_if_some.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meilier/rust-error-handle path: /src/demo_09_01_option_if_some.rs fn opt_val(num: i32) -> Option<String> { if num >= 60 { return Some("foo bar".to_string()); } None } #[cfg(test)] mod tests { use super::*; <|fim_suffix|> //fn main() { // if let Some(v) = opt_val(60) ...
code_fim
medium
{ "lang": "rust", "repo": "meilier/rust-error-handle", "path": "/src/demo_09_01_option_if_some.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: philipdaquin/cloud-readers-rs path: /src/cache/cursor.rs use std::io::{self, Read, Seek, SeekFrom}; use anyhow::anyhow; use super::FileManager; /// Cursor that allows the to Read/Seek through a [`FileManager`]. /// /// Blocks if bytes are read that were not yet downloaded /// Fails if bytes a...
code_fim
hard
{ "lang": "rust", "repo": "philipdaquin/cloud-readers-rs", "path": "/src/cache/cursor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[tokio::test] async fn test_read_complete_file() { let file_size = 100; let (download_cache, file_manager) = init_mock(file_size).await; // we schedule the download of the whole file file_manager .queue_download(vec![Range { start: 0, ...
code_fim
hard
{ "lang": "rust", "repo": "philipdaquin/cloud-readers-rs", "path": "/src/cache/cursor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: autozimu/LanguageClient-neovim path: /src/vimext.rs use crate::language_client::LanguageClient; use crate::types::LCNamespace; use anyhow::Result; <|fim_suffix|> if let Some(namespace_id) = self.get_state(|state| state.namespace_ids.get(&ns_name).cloned())? { ...
code_fim
medium
{ "lang": "rust", "repo": "autozimu/LanguageClient-neovim", "path": "/src/vimext.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(namespace_id) = self.get_state(|state| state.namespace_ids.get(&ns_name).cloned())? { Ok(namespace_id) } else { let namespace_id = self.vim()?.create_namespace(&ns_name)?; self.update_state(|state| { state....
code_fim
medium
{ "lang": "rust", "repo": "autozimu/LanguageClient-neovim", "path": "/src/vimext.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ezaanm/money-market-contracts path: /packages/moneymarket/src/interest_model.rs use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_bignumber::{Decimal256, Uint256}; use cosmwasm_std::HumanAddr; <|fim_suffix|>#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Jso...
code_fim
medium
{ "lang": "rust", "repo": "ezaanm/money-market-contracts", "path": "/packages/moneymarket/src/interest_model.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ashkenazic/mir-verifier path: /test/conc_eval/traits/static_self.rs struct S(u32); trait T { fn g(&self) -> u32; } impl T for S { fn g(&self) -> u32 { self.0 } <|fim_suffix|>const ARG: S = S(42); #[cfg(with_main)] fn main() { println!("{:?}", f(ARG)); }<|fim_middle|>} fn f(s: S) -...
code_fim
easy
{ "lang": "rust", "repo": "Ashkenazic/mir-verifier", "path": "/test/conc_eval/traits/static_self.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", f(ARG)); }<|fim_prefix|>// repo: Ashkenazic/mir-verifier path: /test/conc_eval/traits/static_self.rs struct S(u32); trait T { fn g(&self) -> u32; } <|fim_middle|>impl T for S { fn g(&self) -> u32 { self.0 } } fn f(s: S) -> u32 { s.g() } const ARG: S = S(42); #[cfg(wit...
code_fim
medium
{ "lang": "rust", "repo": "Ashkenazic/mir-verifier", "path": "/test/conc_eval/traits/static_self.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rvanasa/funqy path: /src/stdlib.rs use error::*; use parser::parse; use ast::Exp; use engine::*; use eval::*; use types::*; pub fn create_ctx(path: &str) -> Ret<Context> { let mut ctx = Context::new(path.to_string()); ctx.add_macro("import", &lib_import)?; ctx.add_macro("sup", &lib_sup)?; c...
code_fim
hard
{ "lang": "rust", "repo": "rvanasa/funqy", "path": "/src/stdlib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn lib_len(exp: &Exp, ctx: &Context) -> Ret<RunVal> { let val = eval_exp(exp, ctx); Ok(RunVal::Index(build_gate(&val, ctx) .map(|g| g.len()) .unwrap_or_else(|| build_state(val).len()))) } fn lib_slice(exp: &Exp, ctx: &Context) -> Ret<RunVal> { fn to_slice_params(val: RunVal) -> Ret<(usize, usize)>...
code_fim
hard
{ "lang": "rust", "repo": "rvanasa/funqy", "path": "/src/stdlib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn lib_fold(exp: &Exp, ctx: &Context) -> Ret<RunVal> { match exp { &Exp::Tuple(ref args) if args.len() == 3 => { let mut current = eval_exp(&args[0], ctx); let input = eval_exp(&args[1], ctx); let func = eval_exp(&args[2], ctx); if let RunVal::Func(fn_ctx_rc, pat, body, _ty) = func { le...
code_fim
hard
{ "lang": "rust", "repo": "rvanasa/funqy", "path": "/src/stdlib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn try_me() { outermost::middle_function(); outermost::middle_secret_function(); outermost::inside::inner_function(); outermost::inside::secret_function(); } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }<|fim_prefix|>// repo: dsxragnarok/ru...
code_fim
medium
{ "lang": "rust", "repo": "dsxragnarok/rust-book-exercises", "path": "/library/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dsxragnarok/rust-book-exercises path: /library/src/lib.rs // Rules of item visibility // * If an item is public, it can be accessed through any of its parent modules // * If an item is private, it can be accessed only by its immediate parent module and any of the parent's child modules <|fim_su...
code_fim
hard
{ "lang": "rust", "repo": "dsxragnarok/rust-book-exercises", "path": "/library/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.is_occupied(&(next_seat.0 as usize, next_seat.1 as usize)) { return true; } else if self.is_empty(&(next_seat.0 as usize, next_seat.1 as usize)) { return false; } } } } impl PubWait...
code_fim
hard
{ "lang": "rust", "repo": "mjedwabn/aoc2020", "path": "/day11/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mjedwabn/aoc2020 path: /day11/src/lib.rs pub mod day11 { use std::io::BufRead; pub fn count_occupied_seats(input: &mut dyn BufRead) -> usize { let mut wa: WaitingAreaA = make_waiting_area(input); wa.model_arriving_people(); return wa.get_occupied_seats_count(); ...
code_fim
hard
{ "lang": "rust", "repo": "mjedwabn/aoc2020", "path": "/day11/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(wa.occupied_adjacent_seats(&(1, 1)), 0); assert_eq!(wa.occupied_adjacent_seats(&(0, 0)), 0); assert_eq!(wa.occupied_adjacent_seats(&(1, 2)), 0); } #[test] fn some_occupied_seats() { let wa = day11::make_waiting_area(&mut r...
code_fim
hard
{ "lang": "rust", "repo": "mjedwabn/aoc2020", "path": "/day11/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alexander89/awesome-home path: /src/launchpad/src/twins/launchpad_twin/mod.rs use self::events as ev; use crate::twin::Twin; use crate::twin::{mk_publish_request, tag_with_id}; use actyx_sdk::service::{EventService, PublishResponse}; use actyx_sdk::{tag, Event, Payload, TagSet}; pub mod events; ...
code_fim
hard
{ "lang": "rust", "repo": "Alexander89/awesome-home", "path": "/src/launchpad/src/twins/launchpad_twin/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[allow(dead_code)] pub async fn emit_mission_activated( service: impl EventService, launchpad_id: String, mission_id: String, ) -> Result<PublishResponse, anyhow::Error> { service .publish(mk_publish_request( tag_launchpad_id(&launch...
code_fim
hard
{ "lang": "rust", "repo": "Alexander89/awesome-home", "path": "/src/launchpad/src/twins/launchpad_twin/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: likr/egraph-rs path: /crates/python/src/layout/mod.rs mod kamada_kawai; mod mds; mod sgd; mod stress_majorization; <|fim_suffix|>pub fn register(py: Python<'_>, m: &PyModule) -> PyResult<()> { mds::register(py, m)?; kamada_kawai::register(py, m)?; stress_majorization::register(py, m...
code_fim
easy
{ "lang": "rust", "repo": "likr/egraph-rs", "path": "/crates/python/src/layout/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn register(py: Python<'_>, m: &PyModule) -> PyResult<()> { mds::register(py, m)?; kamada_kawai::register(py, m)?; stress_majorization::register(py, m)?; sgd::register(py, m)?; Ok(()) }<|fim_prefix|>// repo: likr/egraph-rs path: /crates/python/src/layout/mod.rs mod kamada_kawai; m...
code_fim
easy
{ "lang": "rust", "repo": "likr/egraph-rs", "path": "/crates/python/src/layout/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xbcsmith/macadam path: /src/lib.rs #[macro_use] extern crate diesel; extern crate dotenv; pub mod models; pub mod schema; use diesel::prelude::*; use dotenv::dotenv; use std::env; use models::NewReceipt; <|fim_suffix|>pub fn create_receipt(conn: &SqliteConnection, name: &str, status: &str) ...
code_fim
hard
{ "lang": "rust", "repo": "xbcsmith/macadam", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn create_receipt(conn: &SqliteConnection, name: &str, status: &str) -> usize { use schema::receipts; let new_receipt = NewReceipt { name, status }; diesel::insert_into(receipts::table) .values(&new_receipt) .execute(conn) .expect("Error saving new receipt") }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "xbcsmith/macadam", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ejfamanas/rust-training path: /functions/higher_order_functions/src/main.rs // functions that take functions, or return functions, or both // f(g) {let x = g()} // functions that return other functions are called generators // f() -> g() -> x <|fim_suffix|> if above_limit(isq) { ...
code_fim
hard
{ "lang": "rust", "repo": "ejfamanas/rust-training", "path": "/functions/higher_order_functions/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let limit: u32 = 500; let mut sum: u32 = 0; let is_even: fn(u32) -> bool = |x: u32| -> bool { x % 2 == 0 }; // cannot type this here as impl Trait is not allowed outside of function and // inherent method return types let above_limit = greater_than(limit); for i in 0.. { ...
code_fim
medium
{ "lang": "rust", "repo": "ejfamanas/rust-training", "path": "/functions/higher_order_functions/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dan-sf/advent_of_code path: /2018/day11/solution2.rs // This solution is pretty much brute force, however, when getting the max value for each point we // keep track of the previously summed square and use that along with the 'L' of the new square // moving diagonally. For example, for the follo...
code_fim
hard
{ "lang": "rust", "repo": "dan-sf/advent_of_code", "path": "/2018/day11/solution2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Sum the new row/col of this square for j in 0..i { current += grid[row+j][col+i]; current += grid[row+i][col+j]; } current += grid[row+i][col+i]; if current > max_value { max_value = current; size = i as i32; ...
code_fim
hard
{ "lang": "rust", "repo": "dan-sf/advent_of_code", "path": "/2018/day11/solution2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn generate_grid(serial: i32, size: usize) -> Vec<Vec<i32>> { let mut grid: Vec<Vec<i32>> = vec![vec![0;size];size]; for row in 0..size { for col in 0..size { let x = col as i32; let y = row as i32; grid[row][col] = get_power(x, y, serial); } ...
code_fim
hard
{ "lang": "rust", "repo": "dan-sf/advent_of_code", "path": "/2018/day11/solution2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: regendo/advent-of-code-2019 path: /day10/src/lib.rs #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub struct Point2D(pub usize, pub usize); #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub struct Vec2D(pub i32, pub i32); impl Point2D { /// Compute distance (2D vector) between two points. /// ...
code_fim
hard
{ "lang": "rust", "repo": "regendo/advent-of-code-2019", "path": "/day10/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let selected = Point2D::with_highest_visibility(points); assert_eq!(Some(210), selected.map(|p| p.filter_visible(points).len())); assert_eq!(Some(Point2D(11, 13)), selected); } #[test] fn fire_laser_from_11_13() { let map = ".#..##.###...####### ##.############..#...
code_fim
hard
{ "lang": "rust", "repo": "regendo/advent-of-code-2019", "path": "/day10/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /src/tools/clippy/tests/ui/missing_trait_methods.rs #![allow(unused, clippy::needless_lifetimes)] #![warn(clippy::missing_trait_methods)] trait A { fn provided() {} } trait B { fn required(); fn a(_: usize) -> usize { <|fim_suffix|>impl B for Complete { fn...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/src/tools/clippy/tests/ui/missing_trait_methods.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl B for Complete { fn required() {} fn a(_: usize) -> usize { 2 } fn b<T: AsRef<[u8]>>(a: &T) -> &[u8] { a.as_ref() } } fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /src/tools/clippy/tests/ui/missing_trait_methods.rs #![allow(unused, clippy::needless_l...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/src/tools/clippy/tests/ui/missing_trait_methods.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { Meta::Path(_) => true, Meta::List(_) => false, Meta::NameValue(_) => true, } } fn get_list_like_nested(&self) -> Option<&PunctuatedNestedMeta> { match self { Meta::Path(_) => Some(empty_meta_nested()), ...
code_fim
hard
{ "lang": "rust", "repo": "rheehot/syn-ext", "path": "/src/meta.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rheehot/syn-ext path: /src/meta.rs use syn::{punctuated::Punctuated, token::Comma, Meta, NestedMeta}; pub(crate) type PunctuatedNestedMeta = Punctuated<NestedMeta, Comma>; <|fim_suffix|> fn is_name_value_like(&self) -> bool; } fn empty_meta_nested() -> &'static PunctuatedNestedMeta { ...
code_fim
hard
{ "lang": "rust", "repo": "rheehot/syn-ext", "path": "/src/meta.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> match self { Meta::Path(_) => Some(empty_meta_nested()), Meta::List(list) => Some(&list.nested), Meta::NameValue(_) => None, } } }<|fim_prefix|>// repo: rheehot/syn-ext path: /src/meta.rs use syn::{punctuated::Punctuated, token::Comma, Meta, NestedM...
code_fim
medium
{ "lang": "rust", "repo": "rheehot/syn-ext", "path": "/src/meta.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GREsau/schemars path: /schemars/tests/ui/invalid_attrs.rs use schemars::JsonSchema; <|fim_suffix|>#[derive(JsonSchema)] #[schemars(default = 0, foo, deny_unknown_fields, deny_unknown_fields)] pub struct Struct2; fn main() {}<|fim_middle|>#[derive(JsonSchema)] #[serde(default = 0, foo, deny_unk...
code_fim
medium
{ "lang": "rust", "repo": "GREsau/schemars", "path": "/schemars/tests/ui/invalid_attrs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(JsonSchema)] #[schemars(default = 0, foo, deny_unknown_fields, deny_unknown_fields)] pub struct Struct2; fn main() {}<|fim_prefix|>// repo: GREsau/schemars path: /schemars/tests/ui/invalid_attrs.rs use schemars::JsonSchema; <|fim_middle|>#[derive(JsonSchema)] #[serde(default = 0, foo, deny_unk...
code_fim
medium
{ "lang": "rust", "repo": "GREsau/schemars", "path": "/schemars/tests/ui/invalid_attrs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use background::Background; pub use car::Car; pub use dog::Dog; pub use enemy::Enemy; pub use mud::Mud; pub use player::Player; // #[derive(Copy, Clone, Debug, Default, Deserialize, PrefabData, Serialize)] // #[prefab(Component)] // pub struct Background; // impl Component for Background { // ty...
code_fim
medium
{ "lang": "rust", "repo": "AaronShah2/SGDA_Game_Jam_Proj", "path": "/src/components/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AaronShah2/SGDA_Game_Jam_Proj path: /src/components/mod.rs // use amethyst::{ // assets::PrefabData, // derive::PrefabData, // ecs::{Component, DenseVecStorage, Entity, WriteStorage}, // Error, // }; // use serde::{Deserialize, Serialize}; mod background; mod car; mod dog; mod e...
code_fim
hard
{ "lang": "rust", "repo": "AaronShah2/SGDA_Game_Jam_Proj", "path": "/src/components/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// #[derive(Copy, Clone, Debug, Default, Deserialize, PrefabData, Serialize)] // #[prefab(Component)] // pub struct Enemy; // impl Component for Enemy { // type Storage = DenseVecStorage<Self>; // }<|fim_prefix|>// repo: AaronShah2/SGDA_Game_Jam_Proj path: /src/components/mod.rs // use amethyst::{ /...
code_fim
medium
{ "lang": "rust", "repo": "AaronShah2/SGDA_Game_Jam_Proj", "path": "/src/components/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let stdin = std::io::stdin(); let input_reader: Box<dyn BufRead> = match opts.input { Some(ref p) => Box::new(BufReader::new(File::open(p)?)), None => Box::new(stdin.lock()), }; if !opts.quiet && opts.input.is_none() { println!("Reading from STDIN..."); } i...
code_fim
hard
{ "lang": "rust", "repo": "connormai/stammer-input-rust", "path": "/src/bin/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut output_file = match opts.output { Some(ref p) => Some(BufWriter::new(File::create(p)?)), None => None, }; for line in input_reader.lines() { let line = line?; if !opts.quiet && opts.input.is_some() { println!("In: {}", line); } ...
code_fim
hard
{ "lang": "rust", "repo": "connormai/stammer-input-rust", "path": "/src/bin/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: connormai/stammer-input-rust path: /src/bin/main.rs #![feature(custom_attribute)] use stammer::{Dict, Engine}; use failure::Error; use serde_json; use std::fs::File; use std::io::BufRead; use std::io::Write; use std::io::{BufReader, BufWriter}; use std::path::PathBuf; use structopt::StructOpt;...
code_fim
hard
{ "lang": "rust", "repo": "connormai/stammer-input-rust", "path": "/src/bin/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Good-Vibez/ct path: /component/cargo/rustbug00/src/main.rs pub fn main() { f::<(), _>(|_| {}); } fn f<S, P>(p: P) <|fim_suffix|>pub trait Trait<'a> { type Item; } impl<'a, S> Trait<'a> for S { type Item = (); }<|fim_middle|>where P: for<'r> FnOnce(<S as Trait<'r>>::Item), S: ...
code_fim
medium
{ "lang": "rust", "repo": "Good-Vibez/ct", "path": "/component/cargo/rustbug00/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Trait<'a> { type Item; } impl<'a, S> Trait<'a> for S { type Item = (); }<|fim_prefix|>// repo: Good-Vibez/ct path: /component/cargo/rustbug00/src/main.rs pub fn main() { f::<(), _>(|_| {}); } fn f<S, P>(p: P) <|fim_middle|>where P: for<'r> FnOnce(<S as Trait<'r>>::Item), S: ...
code_fim
medium
{ "lang": "rust", "repo": "Good-Vibez/ct", "path": "/component/cargo/rustbug00/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/traits/trait-privacy.rs // build-pass (FIXME(62277): could be check-pass?) #![allow(dead_code)] mod foo { pub use self::bar::T; mod bar { pub trait T { fn f(&self) {} <|fim_suffix|> use foo::T; ().f(); // Check...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/traits/trait-privacy.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let error = ::std::thread::spawn(|| {}).join().unwrap_err(); error.type_id(); // Regression test for #21670 } fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/traits/trait-privacy.rs // build-pass (FIXME(62277): could be check-pass?) #![allow(dead_code)] mod...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/traits/trait-privacy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( solve_part1(vec![ String::from("abcdef"), String::from("bababc"), String::from("abbcde"), String::from("abcccd"), String::from("aabcdd"), String::from("abcdee"), ...
code_fim
hard
{ "lang": "rust", "repo": "EdeMeijer/aoc2018", "path": "/src/days/day2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EdeMeijer/aoc2018 path: /src/days/day2.rs //! Solutions for https://adventofcode.com/2018/day/2 use std::collections::HashMap; use std::collections::HashSet; use utils::data::load_data; use utils::data::non_empty_lines; #[allow(dead_code)] pub fn part1() { println!("{}", solve_part1(get_pu...
code_fim
hard
{ "lang": "rust", "repo": "EdeMeijer/aoc2018", "path": "/src/days/day2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> non_empty_lines(load_data("day2")) } #[cfg(test)] mod test { use super::*; #[test] fn test_count_letters() { assert_eq!( count_letters(String::from("abbccccb")), hashmap! { 'a' => 1, 'b' => 3, 'c' => 4, ...
code_fim
hard
{ "lang": "rust", "repo": "EdeMeijer/aoc2018", "path": "/src/days/day2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: popboykingdjko/awstream path: /profiling/evaluation/src/lib.rs //! Library of functions and structs to help with AWStream evaluation. #![deny(missing_docs)] extern crate csv; #[macro_use] extern crate itertools; extern crate rand; #[macro_use] extern crate log; extern crate rayon; #[macro_use]...
code_fim
hard
{ "lang": "rust", "repo": "popboykingdjko/awstream", "path": "/profiling/evaluation/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Gets the filename of bandwidth file. pub fn derive_bw_file(&self, dir: &str) -> String { format!("{}/bw-{}x{}x{}.csv", dir, self.width, self.skip, self.quant) } /// Opens accuracy file. pub fn open_acc_file(&self, dir: &str) -> File { let filename = self.derive_acc...
code_fim
hard
{ "lang": "rust", "repo": "popboykingdjko/awstream", "path": "/profiling/evaluation/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // the time cost, in sec let mut results = vec![]; // the buffer is 1GiB const TOTAL_SENT: usize = 1 << 30; // packet sizes let sizes = [4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 524288]; let mut buf = vec![1u8; 524288]; let pid = unsafe { fork() }; if pid != 0...
code_fim
hard
{ "lang": "rust", "repo": "noirgif/CS736-benchmark", "path": "/src/pipe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noirgif/CS736-benchmark path: /src/pipe.rs // measure pipe latency #![allow(unused_imports)] use libc::{c_int, c_void, fork, kill, pipe, read, write, SIGKILL}; use std::fs::File; use std::io::prelude::*; #[macro_use] mod measure; // times to loop const LOOP_NUM: usize = 100000; const LOOP_NUM...
code_fim
hard
{ "lang": "rust", "repo": "noirgif/CS736-benchmark", "path": "/src/pipe.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Command::new("rfkill") .stdin(Stdio::null()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .arg("unblock") .arg("bluetooth") .spawn()?; Ok(()) }<|fim_prefix|>// repo: debuglines/air-quality-cli path: /src/runner/bluetooth.rs use std::error::Error...
code_fim
hard
{ "lang": "rust", "repo": "debuglines/air-quality-cli", "path": "/src/runner/bluetooth.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: debuglines/air-quality-cli path: /src/runner/bluetooth.rs use std::error::Error; use std::process::{Command, Stdio}; use std::thread; use std::time::Duration; pub fn restart_bluetooth() -> Result<(), Box<dyn Error>> { Command::new("rfkill") .stdin(Stdio::null()) .stdout(Stdi...
code_fim
medium
{ "lang": "rust", "repo": "debuglines/air-quality-cli", "path": "/src/runner/bluetooth.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: t20/rust-examples path: /example1_while.rs fn main() { let hi = "hi"; let mut count = 0; //inmuttable variable while count < 10 { <|fim_suffix|>%s is %d", hi, count)); count += 1; } }<|fim_middle|> io::println(hi); io::println(fmt!("
code_fim
easy
{ "lang": "rust", "repo": "t20/rust-examples", "path": "/example1_while.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: t20/rust-examples path: /example1_while.rs fn main() { let hi = "hi"; let mut count =<|fim_suffix|>%s is %d", hi, count)); count += 1; } }<|fim_middle|> 0; //inmuttable variable while count < 10 { io::println(hi); io::println(fmt!("
code_fim
medium
{ "lang": "rust", "repo": "t20/rust-examples", "path": "/example1_while.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>%s is %d", hi, count)); count += 1; } }<|fim_prefix|>// repo: t20/rust-examples path: /example1_while.rs fn main() { let hi = "hi"; let mut count = 0; //inmuttable variable while count < 10 { <|fim_middle|> io::println(hi); io::println(fmt!("
code_fim
easy
{ "lang": "rust", "repo": "t20/rust-examples", "path": "/example1_while.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let key_handle = context .create_primary( Hierarchy::Owner, &encryption_decryption_key_pub(), Some(&key_auth), None, None, None, ) .unwrap() .key_handle; ...
code_fim
hard
{ "lang": "rust", "repo": "eclipseo/rust-tss-esapi", "path": "/tss-esapi/tests/context_tests/tpm_commands/asymmetric_primitives_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eclipseo/rust-tss-esapi path: /tss-esapi/tests/context_tests/tpm_commands/asymmetric_primitives_tests.rs // Copyright 2021 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 mod test_rsa_encrypt_decrypt { use crate::common::{create_ctx_with_session, encryption_decrypt...
code_fim
hard
{ "lang": "rust", "repo": "eclipseo/rust-tss-esapi", "path": "/tss-esapi/tests/context_tests/tpm_commands/asymmetric_primitives_tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut stmt = conn.prepare("select id from users order by id desc limit 1")?; let id:u32 = stmt.query_row(&[], |row| row.get(0))?; println!("created used with id: {}", id); Ok(id) }*/<|fim_prefix|>// repo: hamaluik/scribbler-server path: /src/db/setup.rs use errors::Error; use db::pool:...
code_fim
medium
{ "lang": "rust", "repo": "hamaluik/scribbler-server", "path": "/src/db/setup.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hamaluik/scribbler-server path: /src/db/setup.rs use errors::Error; use db::pool::DatabasePool; pub fn initialize_tables(pool: &DatabasePool) -> Result<(), Error> { let conn = match pool.get() { Ok(c) => c, Err(_) => return Err(Error::PoolError) }; if let Err(e) = c...
code_fim
hard
{ "lang": "rust", "repo": "hamaluik/scribbler-server", "path": "/src/db/setup.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /*if let Err(e) = conn.execute("create table if not exists items_shared ( id integer primary key, owner integer not null version int not null, content text not null, salt text not null, nonce text not null, foreign key...
code_fim
hard
{ "lang": "rust", "repo": "hamaluik/scribbler-server", "path": "/src/db/setup.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>extern "C" fn bar() -> i32 { return 0; } fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/extern/extern-ffi-fn-with-body.rs extern "C" { fn foo() -> i32 { //~ ERROR incorrect `fn` inside `extern` block <|fim_middle|> return 0; } }
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/extern/extern-ffi-fn-with-body.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/extern/extern-ffi-fn-with-body.rs extern "C" { fn foo() -> i32 { //~ ERROR incorrect `fn` inside `extern` block <|fim_suffix|>extern "C" fn bar() -> i32 { return 0; } fn main() {}<|fim_middle|> return 0; } }
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/extern/extern-ffi-fn-with-body.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl InventoryNewItemFormCategory { #[tracing::instrument( target = "packager::html::build", name = "build_inventory_new_item_form_category", fields(component = "InventoryNewItemFormCategory"), skip(categories) )] pub fn build( active_category: Option<&m...
code_fim
hard
{ "lang": "rust", "repo": "hakoerber/packager", "path": "/rust/src/view/inventory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hakoerber/packager path: /rust/src/view/inventory.rs "width: {width}%;position:absolute;left:0;bottom:0;right:0;", width=( (category.total_weight() as f64) ...
code_fim
hard
{ "lang": "rust", "repo": "hakoerber/packager", "path": "/rust/src/view/inventory.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct InventoryNewItemFormWeight; impl InventoryNewItemFormWeight { #[tracing::instrument( target = "packager::html::build", name = "build_inventory_new_item_form_weight", fields(component = "InventoryNewItemFormWeight") )] pub fn build() -> Markup { html!...
code_fim
hard
{ "lang": "rust", "repo": "hakoerber/packager", "path": "/rust/src/view/inventory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //here I use 'b' and 'c' and step generated in 23.txt directly let begin = 107_900; let end = 124_900; let step = 17; let primes = generate_primes(f64::from(end).sqrt() as i32 + 1); (begin..=end) .step_by(step) .filter(|num| { for p in primes.iter() { ...
code_fim
hard
{ "lang": "rust", "repo": "Observer42/advent-of-code-2017", "path": "/src/day23.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Observer42/advent-of-code-2017 path: /src/day23.rs use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::Read; use std::io::Result; pub fn solve() -> Result<()> { let mut file = File::open("input/23.txt")?; let mut raw_input = String::new(); file.read_to_string(&...
code_fim
hard
{ "lang": "rust", "repo": "Observer42/advent-of-code-2017", "path": "/src/day23.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: muzudho/kifuwarabe-shogi-entry-model path: /src/look_and_model/recording/captured_move.rs use crate::look_and_model::recording::{CapturedMove, FireAddress}; impl CapturedMove { pub fn new(source: FireAddress, destinati<|fim_suffix|>ce: source, destination: destination, }...
code_fim
medium
{ "lang": "rust", "repo": "muzudho/kifuwarabe-shogi-entry-model", "path": "/src/look_and_model/recording/captured_move.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>on: FireAddress) -> Self { CapturedMove { source: source, destination: destination, } } }<|fim_prefix|>// repo: muzudho/kifuwarabe-shogi-entry-model path: /src/look_and_model/recording/captured_move.rs use crate::look_and_model::recording::{CapturedMove, FireAd...
code_fim
medium
{ "lang": "rust", "repo": "muzudho/kifuwarabe-shogi-entry-model", "path": "/src/look_and_model/recording/captured_move.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let builder = Builder::new_from_string(SRC); let search_bar: SearchBar = builder.get_object("search_bar").unwrap(); let popover: Popover = builder.get_object("search_popover").unwrap(); popover.set_position(PositionType::Top); popover.set_relative_to(&button); window.show_all(); ...
code_fim
medium
{ "lang": "rust", "repo": "Cogitri/gtk-bug-1779", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cogitri/gtk-bug-1779 path: /src/main.rs use gtk::*; fn main() { if gtk::init().is_err() { println!("Failed to initialize GTK."); return; } <|fim_suffix|> const SRC: &str = include_str!("ui/find_replace.glade"); let builder = Builder::new_from_string(SRC); le...
code_fim
hard
{ "lang": "rust", "repo": "Cogitri/gtk-bug-1779", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /src/lib/diagnostics/inspect/rust/src/format/container.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { mapped_vmo::Mapping, std::{cmp::min,...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/lib/diagnostics/inspect/rust/src/format/container.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] impl WritableBlockContainer for &[u8] { fn write_bytes(&self, offset: usize, bytes: &[u8]) -> usize { if offset >= self.len() { return 0; } let bytes_written = min(self.len() - offset, bytes.len()); let base = (self.as_ptr() as usize).checked_ad...
code_fim
medium
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/lib/diagnostics/inspect/rust/src/format/container.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if offset >= self.len() { return 0; } let bytes_written = min(self.len() - offset, bytes.len()); let base = (self.as_ptr() as usize).checked_add(offset).unwrap() as *mut u8; unsafe { std::ptr::copy_nonoverlapping(bytes.as_ptr(), base, bytes_written) }; ...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/lib/diagnostics/inspect/rust/src/format/container.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl From<FromUtf8Error> for Error { fn from(e:FromUtf8Error) -> Self { Error { error: format!("{:?}", e) } } } impl From<RuntimeError> for Error{ fn from(e: RuntimeError) -> Self { Error{ error: format!("{:?}",e) } } } impl From<E...
code_fim
hard
{ "lang": "rust", "repo": "mechtronium/wasm_membrane", "path": "/host/rust/wasm_membrane_host/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mechtronium/wasm_membrane path: /host/rust/wasm_membrane_host/src/error.rs use wasmer::{CompileError, RuntimeError, ExportError, InstantiationError}; use std::fmt::{Formatter, Debug}; use core::fmt; use std::string::FromUtf8Error; use std::sync::PoisonError; use std::io; #[derive(Debug, Clone)]...
code_fim
hard
{ "lang": "rust", "repo": "mechtronium/wasm_membrane", "path": "/host/rust/wasm_membrane_host/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NLincoln/tracer path: /tracer/src/main.rs use std::f32; use libtrace::{ material::{Dialectric, Diffuse, Lambertian, Material, Metal}, texture, BvhNode, Hitable, MovingSphere, StaticSphere, Vec3, }; use image::flat::NormalForm::ColumnMajorPacked; use indicatif::{ProgressBar, ProgressSty...
code_fim
hard
{ "lang": "rust", "repo": "NLincoln/tracer", "path": "/tracer/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut scene: Scene = serde_yaml::from_reader(fs::File::open(matches.value_of("input").unwrap())?)?; let num_pixels = scene.image.num_pixels(); let progress_bar = ProgressBar::new(num_pixels as u64); progress_bar.set_style(ProgressStyle::default_bar().template( "[{elapsed...
code_fim
hard
{ "lang": "rust", "repo": "NLincoln/tracer", "path": "/tracer/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Token::new(syntax_kind, self.len()) } fn line_comment(&mut self) -> SyntaxKind { // consume "/" self.bump(); self.bump_while(|c| c != '\n'); SyntaxKind::Comment } fn block_comment(&mut self) -> SyntaxKind { // consume "*" self.bump...
code_fim
hard
{ "lang": "rust", "repo": "Vengarioth/sky-sl", "path": "/crates/sky-sl/src/lexer/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vengarioth/sky-sl path: /crates/sky-sl/src/lexer/mod.rs use crate::syn::cst::SyntaxKind; mod cursor; mod identifier; mod literal; mod token; use cursor::*; use identifier::*; use literal::*; pub use token::*; pub fn tokenize(mut input: &str) -> Vec<Token> { let mut result = Vec::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "Vengarioth/sky-sl", "path": "/crates/sky-sl/src/lexer/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // consume "*" self.bump(); while let Some(c) = self.bump() { match c { '*' if self.first() == Some('/') => { // consume "/" self.bump(); break; }, _ => (), ...
code_fim
hard
{ "lang": "rust", "repo": "Vengarioth/sky-sl", "path": "/crates/sky-sl/src/lexer/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/typify path: /typify/tests/schemas.rs // Copyright 2023 Oxide Computer Company use std::{error::Error, fs::File, io::BufReader}; use expectorate::assert_contents; use glob::glob; use quote::quote; use schemars::schema::RootSchema; use serde_json::json; use typify::{TypeSpace, Typ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/typify", "path": "/typify/tests/schemas.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let schema_raw = json! { { "enum": [ 1, "one" ] } }; let schema = serde_json::from_value(schema_raw).unwrap(); let mut type_space = TypeSpace::new( TypeSpaceSettings::default() .with_replacement( "HandGeneratedType", ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/typify", "path": "/typify/tests/schemas.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heyrutvik/turing-script-rs path: /src/parser.rs use crate::core::ast::{Dir, Kind, Step, Sym, Term}; use crate::helper; use combine::attempt; use combine::error::ParseError; use combine::parser::char::{alpha_num, char, letter, spaces, string}; use combine::stream::Stream; use combine::{between, c...
code_fim
hard
{ "lang": "rust", "repo": "heyrutvik/turing-script-rs", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>where I: Stream<Item = char>, I::Error: ParseError<I::Item, I::Range, I::Position>, { ( char(ROUND_OPEN).skip(spaces()), ident().skip(spaces()), choice((symbol(), char(UNDERSCORE).map(|_| Term::Symbol(Sym::Any)))).skip(spaces()), operation(), ident().ski...
code_fim
hard
{ "lang": "rust", "repo": "heyrutvik/turing-script-rs", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }