text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> // At this point, the change to NOTIFIED has always been observed with acquire // ordering, so we can just use a relaxed store here (instead of a swap). self.state.store(EMPTY, Relaxed); } // Does not actually need `unsafe` or `Pin`, but the pthread implementation does. ...
code_fim
hard
{ "lang": "rust", "repo": "jyn514/rust", "path": "/library/std/src/sys/unix/thread_parker/netbsd.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> To simplify things for the example, however, suppose you only have help from one Elf (a total of two workers) and that each step takes 60 fewer seconds (so that step A takes 1 second and step Z takes 26 seconds). Then, using the same instructions as above, this is how each second would be spen...
code_fim
hard
{ "lang": "rust", "repo": "deadalusai/advent-of-code", "path": "/2018/day7/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deadalusai/advent-of-code path: /2018/day7/src/main.rs extern crate util; extern crate itertools; extern crate regex; use util::{ read_input }; use itertools::Itertools; use std::collections::hash_map::HashMap; use std::cell::RefCell; fn main() { type Id = char; #[derive(Debug)] ...
code_fim
hard
{ "lang": "rust", "repo": "deadalusai/advent-of-code", "path": "/2018/day7/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> In this example, it would take 15 seconds for two workers to complete these steps. With 5 workers and the 60+ second step durations described above, how long will it take to complete all of the steps? */ #[derive(Copy, Clone)] struct Work { step: Id, time_remaining: u3...
code_fim
hard
{ "lang": "rust", "repo": "deadalusai/advent-of-code", "path": "/2018/day7/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uniformbuffer/orbtk-2d-engine-widget path: /src/battlefield/base_layer.rs use orbtk::prelude::*; use crate::battlefield::BattlefieldEvent; enum BaseLayerAction { NewEvents } #[derive(Default, AsAny)] pub struct BaseLayerState { actions: Vec<BaseLayerAction>, } impl BaseLayerState { ...
code_fim
hard
{ "lang": "rust", "repo": "uniformbuffer/orbtk-2d-engine-widget", "path": "/src/battlefield/base_layer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { ctx.widget().set::<String16>("name",String16::from("base_layer")); } fn update(&mut self, _: &mut Registry, ctx: &mut Context) { let actions: Vec<BaseLayerAction> = self.actions.drain(..).collect(); for action in actions { match action ...
code_fim
hard
{ "lang": "rust", "repo": "uniformbuffer/orbtk-2d-engine-widget", "path": "/src/battlefield/base_layer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Template for BaseLayer { fn template(self, id: Entity, ctx: &mut BuildContext) -> Self { let current_widget = ctx.get_widget(id); self.name("BaseLayer") .on_changed(|states, entity, property_name| { match property_name { "battlefield...
code_fim
hard
{ "lang": "rust", "repo": "uniformbuffer/orbtk-2d-engine-widget", "path": "/src/battlefield/base_layer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kryndex/lycaon path: /src/response/uuid.rs use failure::Error; use rocket::State; use rocket::http::{Header, Status}; use rocket::response::{Responder, Response}; use rocket::request::Request; use hostname; use uuid::Uuid; use grpc::backend; use config; use errors; #[derive(Debug, Serialize)] ...
code_fim
hard
{ "lang": "rust", "repo": "Kryndex/lycaon", "path": "/src/response/uuid.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn uuid_uuid() { let response = test_route(build_response()); let headers = response.headers(); assert_eq!(response.status(), Status::Accepted); assert!(headers.contains("Docker-Upload-UUID")); assert!(headers.contains("Location")); assert!(h...
code_fim
hard
{ "lang": "rust", "repo": "Kryndex/lycaon", "path": "/src/response/uuid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Settings { $f: x, ..self } } } }; } macro_rules! builder_pattern_impl_all { ( $( $f:ident: $t:ty, )* ) => { $( builder_pattern_impl!($f: $t); )* }; } builder_pattern_impl_all! { foo: bool, heh: i32, lel: Vec<String>, }<|fim_prefix|>// r...
code_fim
hard
{ "lang": "rust", "repo": "azdavis/try-rust", "path": "/macros/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>builder_pattern_impl_all! { foo: bool, heh: i32, lel: Vec<String>, }<|fim_prefix|>// repo: azdavis/try-rust path: /macros/src/main.rs fn main() { println!("Hello, world!"); let a = Settings::new(); println!("a = {:?}", a); let b = a.foo(true).heh(5).lel(vec!["fella".to_string()]); p...
code_fim
hard
{ "lang": "rust", "repo": "azdavis/try-rust", "path": "/macros/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azdavis/try-rust path: /macros/src/main.rs fn main() { println!("Hello, world!"); let a = Settings::new(); println!("a = {:?}", a); let b = a.foo(true).heh(5).lel(vec!["fella".to_string()]); println!("b = {:?}", b); } #[derive(Debug)] struct Settings { foo: bool, heh: i32, lel: ...
code_fim
medium
{ "lang": "rust", "repo": "azdavis/try-rust", "path": "/macros/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: randomPoison/COLLABORATE path: /collaborate-derive/src/lib.rs ame_test(name) || B::name_test(name) || C::name_test(name)` let name_test = variants.iter() .map(|variant| &variant.inner_type) .fold(None, |joined, current| { match joined { None => Som...
code_fim
hard
{ "lang": "rust", "repo": "randomPoison/COLLABORATE", "path": "/collaborate-derive/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: randomPoison/COLLABORATE path: /collaborate-derive/src/lib.rs occurrences: occurrences, data_type: data_type, }); } MemberType::Attribute => { // Map the `ChildOccurrences` to an `AttributeOccurrences`. ...
code_fim
hard
{ "lang": "rust", "repo": "randomPoison/COLLABORATE", "path": "/collaborate-derive/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #( #add_names )* } } }) } fn generate_struct_impl(config: StructMember) -> Result<quote::Tokens, String> { let StructMember { ident, element_name, attributes, children, text_contents, stub_me_out } = config; ...
code_fim
hard
{ "lang": "rust", "repo": "randomPoison/COLLABORATE", "path": "/collaborate-derive/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nikomatsakis/lark path: /components/lark-parser/src/syntax/fn_body.rs { if !parser.is(LexToken::Sigil) { return false; } let s = parser.peek_str(); self.operators.iter().any(|(text, _)| *text == s) } fn expect(&mut self, parser: &mut Parser<...
code_fim
hard
{ "lang": "rust", "repo": "nikomatsakis/lark", "path": "/components/lark-parser/src/syntax/fn_body.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nikomatsakis/lark path: /components/lark-parser/src/syntax/fn_body.rs xpression(self.scope)) } } #[derive(new, DebugWith)] struct Expression<'me, 'parse> { scope: &'me mut ExpressionScope<'parse>, } impl Syntax<'parse> for Expression<'me, 'parse> { type Data = ParsedExpression; ...
code_fim
hard
{ "lang": "rust", "repo": "nikomatsakis/lark", "path": "/components/lark-parser/src/syntax/fn_body.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn expect(&mut self, parser: &mut Parser<'parse>) -> Result<Self::Data, ErrorReported> { Ok(parser .expect(Expression::new(self.scope))? .to_hir_expression(self.scope)) } } #[derive(new, DebugWith)] struct Expression<'me, 'parse> { scope: &'me mut ExpressionSco...
code_fim
hard
{ "lang": "rust", "repo": "nikomatsakis/lark", "path": "/components/lark-parser/src/syntax/fn_body.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>simple_nonterminal!(a, 'a, (x, y, z)); // OK complex_nonterminal!(enum E {}); fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/nonterminal-matching.rs // Check that we are refusing to match on complex nonterminals for which tokens are // unavailable and we'd ...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/macros/nonterminal-matching.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>macro simple_nonterminal($nt_ident: ident, $nt_lifetime: lifetime, $nt_tt: tt) { macro n(a $nt_ident b $nt_lifetime c $nt_tt d) { struct S; } n!(a $nt_ident b $nt_lifetime c $nt_tt d); } macro complex_nonterminal($nt_item: item) { macro n(a $nt_item b) { struct S; } ...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/macros/nonterminal-matching.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/macros/nonterminal-matching.rs // Check that we are refusing to match on complex nonterminals for which tokens are // unavailable and we'd have to go through AST comparisons. #![feature(decl_macro)] <|fim_suffix|>simple_nonterminal!(a, 'a, (x,...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/macros/nonterminal-matching.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>}", e); std::process::exit(1); } }<|fim_prefix|>// repo: hecsalazarf/bjsys path: /server/src/bin/main.rs use server::app::App; #[tokio::main] a<|fim_middle|>sync fn main() { if let Err(e) = App::run().await { tracing::error!("{:#
code_fim
medium
{ "lang": "rust", "repo": "hecsalazarf/bjsys", "path": "/server/src/bin/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hecsalazarf/bjsys path: /server/src/bin/main.rs use server::app::App; #[tokio::main] async fn main() { if let Err(e) = App:<|fim_suffix|>}", e); std::process::exit(1); } }<|fim_middle|>:run().await { tracing::error!("{:#
code_fim
easy
{ "lang": "rust", "repo": "hecsalazarf/bjsys", "path": "/server/src/bin/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stuartlynn/geozero path: /geozero-shp/src/point_z.rs use crate::shp_reader::{is_no_data, NO_DATA}; use std::fmt; /// Point with `x`, `y`, `m`, `z` #[derive(PartialEq, Debug, Copy, Clone)] pub struct PointZ { pub x: f64, pub y: f64, pub z: f64, pub m: f64, } impl PointZ { pu...
code_fim
hard
{ "lang": "rust", "repo": "stuartlynn/geozero", "path": "/geozero-shp/src/point_z.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if is_no_data(self.m) { write!( f, "Point(x: {}, y: {}, z: {}, m: NO_DATA)", self.x, self.y, self.z ) } else { write!( f, "Point(x: {}, y: {}, z: {}, m: {})", ...
code_fim
hard
{ "lang": "rust", "repo": "stuartlynn/geozero", "path": "/geozero-shp/src/point_z.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /* Emulate if string is unknown at compile time */ let code = " fn test() > string {} "; let emulated_parser = ellie_parser::parser::Parser::new( code.to_string(), |_, _| ellie_parser::parser::ResolvedImport::default()...
code_fim
hard
{ "lang": "rust", "repo": "BrainWiggans/Ellie-Language", "path": "/tests/syntax/function.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "; let emulated_parser = ellie_parser::parser::Parser::new( code.to_string(), |_, _| ellie_parser::parser::ResolvedImport::default(), ellie_core::defs::ParserOptions::default(), ); let parsed = emulated_parser.map(); assert!( ...
code_fim
hard
{ "lang": "rust", "repo": "BrainWiggans/Ellie-Language", "path": "/tests/syntax/function.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BrainWiggans/Ellie-Language path: /tests/syntax/function.rs #[cfg(test)] mod function_tests { #[test] fn private_function_collected_with_no_error() { let code = "pri fn test() {}"; let emulated_parser = ellie_parser::parser::Parser::new( code.to_string(), ...
code_fim
hard
{ "lang": "rust", "repo": "BrainWiggans/Ellie-Language", "path": "/tests/syntax/function.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: U007D/fluent_validator path: /src/lib.rs #![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] #![allow(non_camel_case_types)] #![warn(missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unused_import_braces,...
code_fim
medium
{ "lang": "rust", "repo": "U007D/fluent_validator", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod unit_tests; pub use self::error::Error; pub type Result<T> = std::result::Result<T, Error>; pub trait Validator<T> { fn validate(T) -> Result<T>; } pub trait FluentValidator: Sized { fn validate<T: Validator<Self>>(self) -> Result<Self>; } impl<T> FluentValidator for T { f...
code_fim
medium
{ "lang": "rust", "repo": "U007D/fluent_validator", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl<T> FluentValidator for T { fn validate<U: Validator<Self>>(self) -> Result<Self> { U::validate(self) } }<|fim_prefix|>// repo: U007D/fluent_validator path: /src/lib.rs #![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] #![allow(non_camel...
code_fim
hard
{ "lang": "rust", "repo": "U007D/fluent_validator", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Roxxik/Hello-BareMetal-Rust path: /libBareMetal.rs #![allow(dead_code)] #[lang="panic_fmt"] #[no_mangle] #[allow(private_no_mangle_fns)] #[allow(unused_variables)] fn rust_begin_unwind(args: ::core::fmt::Arguments, file: &str, line: usize) -> ! { loop {} } #[lang="stack_exhausted"] #[no_ma...
code_fim
medium
{ "lang": "rust", "repo": "Roxxik/Hello-BareMetal-Rust", "path": "/libBareMetal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn b_file_close(hdl: u64); fn b_file_read(hdl: u64, buf: *mut u8, count: u64) -> u64; pub fn malloc(size: u64) -> *mut u8; pub fn realloc(ptr: *mut u8, size: u64) -> *mut u8; pub fn free(ptr: *mut u8); } pub fn output_char(c: char) { unsafe{ b_output_char(c as u8); } ...
code_fim
medium
{ "lang": "rust", "repo": "Roxxik/Hello-BareMetal-Rust", "path": "/libBareMetal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tehforsch/amazingGrame path: /src/game/mod.rs extern crate rand; pub mod input; pub mod object; pub mod spring; use self::input::{ Actions}; use self::object::{Object,ObjectType}; use self::spring::Spring; use ::simulation; use ::simulation::body::Body; use ::point::Point; use ::simulation::Wa...
code_fim
hard
{ "lang": "rust", "repo": "Tehforsch/amazingGrame", "path": "/src/game/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_ship_body(arena_size: Point) -> Body { let x = rand::random::<f64>() * (arena_size.x-LEFT_MARGIN) + LEFT_MARGIN; let y = 50.0; let mut b = Body::new(Point{x: x, y: y}, SHIP_MASS, SHIP_RADIUS); b.gravity_flag = 2; b } pub fn get_ships(num_ships: usize, arena_size: Point) -> ...
code_fim
hard
{ "lang": "rust", "repo": "Tehforsch/amazingGrame", "path": "/src/game/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl GasSizeOf for EntityKey { fn gas_size_of(&self) -> Gas { self.entity_type.gas_size_of() + self.entity_id.gas_size_of() } } impl GasSizeOf for LoadRelatedRequest { fn gas_size_of(&self) -> Gas { self.entity_type.gas_size_of() + self.entity_id.gas_size_of() ...
code_fim
hard
{ "lang": "rust", "repo": "graphprotocol/graph-node", "path": "/graph/src/runtime/gas/size_of.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: graphprotocol/graph-node path: /graph/src/runtime/gas/size_of.rs //! Various implementations of GasSizeOf; use crate::{ components::store::{EntityKey, EntityType, LoadRelatedRequest}, data::store::{scalar::Bytes, Value}, }; use super::{Gas, GasSizeOf, SaturatingInto as _}; impl GasSiz...
code_fim
hard
{ "lang": "rust", "repo": "graphprotocol/graph-node", "path": "/graph/src/runtime/gas/size_of.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl GasSizeOf for usize { fn const_gas_size_of() -> Option<Gas> { // Must be the same regardless of platform. u64::const_gas_size_of() } } impl GasSizeOf for EntityKey { fn gas_size_of(&self) -> Gas { self.entity_type.gas_size_of() + self.entity_id.gas_size_of() }...
code_fim
hard
{ "lang": "rust", "repo": "graphprotocol/graph-node", "path": "/graph/src/runtime/gas/size_of.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Represents the span of time that a given rule is valid for. /// Note that I have made the assumption that all ranges are /// left-inclusive and right-exclusive - that is to say, /// if the clocks go forward by 1 hour at 1am, the time 1am /// does not exist in local time (the clock goes from 00:59:59 /...
code_fim
hard
{ "lang": "rust", "repo": "musically-ut/chrono-tz", "path": "/src/timezone_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: musically-ut/chrono-tz path: /src/timezone_impl.rs use chrono::{Offset, TimeZone, NaiveDate, NaiveDateTime, LocalResult, FixedOffset}; use std::fmt::{Debug, Display, Formatter, Error}; use std::cmp::Ordering; use binary_search::binary_search; use super::timezones::Tz; #[derive(Copy, Clone, Part...
code_fim
hard
{ "lang": "rust", "repo": "musically-ut/chrono-tz", "path": "/src/timezone_impl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl TimeZone for Tz { type Offset = TzOffset; fn from_offset(offset: &Self::Offset) -> Self { offset.tz } fn offset_from_local_date(&self, local: &NaiveDate) -> LocalResult<Self::Offset> { let earliest = self.offset_from_local_datetime(&local.and_hms(0, 0, 0)); let latest...
code_fim
hard
{ "lang": "rust", "repo": "musically-ut/chrono-tz", "path": "/src/timezone_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doy/ruby-stacktrace path: /src/main.rs extern crate libc; extern crate regex; extern crate term; extern crate clap; use clap::{Arg, App, ArgMatches}; use libc::*; use std::process; use std::os::unix::prelude::*; use std::time::Duration; use std::thread; use std::ffi::{OsString, CStr}; use std::m...
code_fim
hard
{ "lang": "rust", "repo": "doy/ruby-stacktrace", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { let matches = parse_args(); let pid: pid_t = matches.value_of("PID").unwrap().parse().unwrap(); let command = matches.value_of("COMMAND").unwrap(); if command.clone() != "top" && command.clone() != "stackcollapse" { println!("COMMAND must be 'top' or 'stackcollapse. Tr...
code_fim
hard
{ "lang": "rust", "repo": "doy/ruby-stacktrace", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tirust/msp432e4 path: /src/usb0/lpmris.rs #[doc = r"Value read from the register"] pub struct R { bits: u8, } #[doc = r"Value to write to the register"] pub struct W { bits: u8, } impl super::LPMRIS { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "tirust/msp432e4", "path": "/src/usb0/lpmris.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits &= !(1 ...
code_fim
hard
{ "lang": "rust", "repo": "tirust/msp432e4", "path": "/src/usb0/lpmris.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(not(any( target_os = "linux", target_os = "android", target_os = "freebsd", target_os = "netbsd", target_os = "dragonflybsd", target_vendor = "apple" )))] fn preload_strings() -> (&'static str, &'static str) { use uucore::crash; crash!(1, "Command not supported for t...
code_fim
hard
{ "lang": "rust", "repo": "uutils/coreutils", "path": "/src/uu/stdbuf/src/stdbuf.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uutils/coreutils path: /src/uu/stdbuf/src/stdbuf.rs // This file is part of the uutils coreutils package. // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (ToDO) tempdir dyld dylib dragonfly...
code_fim
hard
{ "lang": "rust", "repo": "uutils/coreutils", "path": "/src/uu/stdbuf/src/stdbuf.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Azureki/codewars path: /highest-scoring-word/main.rs fn high(input: &str) -> &str { let mut pos = vec![0, 0]; let mut score = 0; let mut highest_score = 0; let mut begin = 0; let mut i = 0; for c in input.bytes(){ if c == b' '{ if score>highest_score{ ...
code_fim
medium
{ "lang": "rust", "repo": "Azureki/codewars", "path": "/highest-scoring-word/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let str = "what time are we climbing up the volcano"; println!("{}", high(str)); }<|fim_prefix|>// repo: Azureki/codewars path: /highest-scoring-word/main.rs fn high(input: &str) -> &str { let mut pos = vec![0, 0]; let mut score = 0; let mut highest_score = 0; let mut begin = 0; ...
code_fim
medium
{ "lang": "rust", "repo": "Azureki/codewars", "path": "/highest-scoring-word/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spl/ddl path: /crates/ddl/src/surface/delaborate.rs //! Converts the core syntax back into the surface syntax, reversing some (but //! not all) parts of elaboration. //! //! The naming of this pass is not entirely standard, but was one of the better //! ones to emerge from [this twitter discussi...
code_fim
hard
{ "lang": "rust", "repo": "spl/ddl", "path": "/crates/ddl/src/surface/delaborate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn delaborate_term_prec(term: &core::Term, prec: u8) -> surface::Term { let delaborate_paren_prec = |cond, surface_term: surface::Term| match cond { true => surface::Term::Paren(surface_term.span(), Box::new(surface_term)), false => surface_term, }; match term { co...
code_fim
hard
{ "lang": "rust", "repo": "spl/ddl", "path": "/crates/ddl/src/surface/delaborate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fyang93/rust-leetcode path: /src/p0030_substring_with_concatenation_of_all_words.rs use std::collections::HashMap; // 有点类似 bag-of-words pub fn find_substring(s: String, words: Vec<String>) -> Vec<i32> { let mut indices = vec![]; if words.is_empty() { return indices; } /...
code_fim
medium
{ "lang": "rust", "repo": "fyang93/rust-leetcode", "path": "/src/p0030_substring_with_concatenation_of_all_words.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> indices } #[cfg(test)] mod tests { use super::*; #[test] fn it_works() { let s = String::from("barfoothefoobarman"); let words = vec![String::from("foo"), String::from("bar")]; assert_eq!(find_substring(s, words), vec![0, 9]); } #[test] fn it_works_1(...
code_fim
hard
{ "lang": "rust", "repo": "fyang93/rust-leetcode", "path": "/src/p0030_substring_with_concatenation_of_all_words.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raygon-renderer/thermite path: /crates/thermite/src/math/pd.rs finite(); let xzero = x0.is_zero_or_subnormal(); let xsign = x0.is_negative(); if thermite_unlikely!((overflow | underflow).any()) { z = underflow.select(zero, z); z = overflow.select...
code_fim
hard
{ "lang": "rust", "repo": "raygon-renderer/thermite", "path": "/crates/thermite/src/math/pd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // high precision multiplication not needed here because abs(e3) <= 1 x = e3.nmul_adde(ln2, x); // x -= e3 * VM_LN2; // poly_13m + 1, Taylor coefficients for exp function, 1/n! let mut z = x.poly_p::<P>(&[ 1.0, // + 1 1.0 / 1.0, 1.0 / 2....
code_fim
hard
{ "lang": "rust", "repo": "raygon-renderer/thermite", "path": "/crates/thermite/src/math/pd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let x_small = hx0.lt(Vu64::<S>::splat(0x00100000)); let xs = x_small.select(x1p54, x); // note that this upcasts let b = x_small.select(b2, b1); let mut ui = xs.into_bits(); let mut hx = (ui >> 32) & m; // TODO: Fix this when stable isn't broken h...
code_fim
hard
{ "lang": "rust", "repo": "raygon-renderer/thermite", "path": "/crates/thermite/src/math/pd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let faction_list_clone_faction = SlotNoArgs::new(ui.tool.main_widget(), clone!( ui => move || { if let Err(error) = ui.load_clone_faction_dialog() { show_message_warning(&ui.tool.message_widget, error); } } )); ...
code_fim
hard
{ "lang": "rust", "repo": "Frodo45127/rpfm", "path": "/rpfm_ui/src/tools/unit_editor/variant_unit_editor/slots.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Frodo45127/rpfm path: /rpfm_ui/src/tools/unit_editor/variant_unit_editor/slots.rs //---------------------------------------------------------------------------// // Copyright (c) 2017-2023 Ismael Gutiérrez González. All rights reserved. // // This file is part of the Rusted PackFile Manager (RPF...
code_fim
hard
{ "lang": "rust", "repo": "Frodo45127/rpfm", "path": "/rpfm_ui/src/tools/unit_editor/variant_unit_editor/slots.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Limeth/pflc path: /src/parser.rs use nom::simple_errors::Context; use nom::Err::Error; use nom::ErrorKind; use nom::types::CompleteStr; use nom::{digit, space}; use ast::lexer; macro_rules! check_parser { ($parser_fn:ident; $input:expr => $rest:expr, $output:expr) => { assert_eq!($p...
code_fim
hard
{ "lang": "rust", "repo": "Limeth/pflc", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// named!(parse_i32<CompleteStr, i32>, // flat_map!( // recognize!( // tuple!( // opt!(alt!(tag!("+") | tag!("-"))), // digit, // opt!(tuple!( // alt!(tag!("e") | tag!("E")), // opt!(alt!(tag!("+") | tag!("-"))), // digit // ) // ...
code_fim
hard
{ "lang": "rust", "repo": "Limeth/pflc", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// {{{ i32 // macro_rules! parse_i32_base_variant_e { // ($prefix:expr, $digits:expr) => { // tuple!( // opt!(alt!(tag!("+") | tag!("-"))), // tag!($prefix), // many1!(is_a!($digits)), // opt!(tuple!( // alt!(tag!("e") | tag!("E")), // opt!(alt...
code_fim
hard
{ "lang": "rust", "repo": "Limeth/pflc", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Make use of our cached result from the previous directory mapping. let &(ref _relevant_file_comp_list, ref relevant_file_write_list) = reslist_builder::generate_directory_tree( args )?; for file_path in relevant_file_write_list { let os_path = OsString::from(file_path); ...
code_fim
hard
{ "lang": "rust", "repo": "Entropy-Soldier/ges-map-script-utility", "path": "/src/folder_compressor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if args.verbose { println!( "Compressed {}", relative_path.display() ); } Ok(()) } /// Takes an extension "X" and returns an extension "X.bz2" fn create_compressed_extension( uncompressed_pathbuf: &PathBuf ) -> OsString { // Source expects a sort of double-extension of xxx.bz...
code_fim
hard
{ "lang": "rust", "repo": "Entropy-Soldier/ges-map-script-utility", "path": "/src/folder_compressor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Entropy-Soldier/ges-map-script-utility path: /src/folder_compressor.rs // Copyright 2018 Entropy-Soldier // // Licensed under the MIT license: http://opensource.org/licenses/MIT // This file may not be copied, modified, or distributed except according to those terms. // ------------------------...
code_fim
hard
{ "lang": "rust", "repo": "Entropy-Soldier/ges-map-script-utility", "path": "/src/folder_compressor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut event_msg = PSTR(b"Hello in the event log\0".as_ptr() as _); unsafe { ReportEventA( HANDLE(event_log_handle.0), //h_event_log: T0__, ReportEvent_wType::EVENTLOG_WARNING_TYPE, // for type use EVENTLOG_WARNING_TYPE w_type: u16, 5, ...
code_fim
hard
{ "lang": "rust", "repo": "DaveAxiom/rust-rosetta", "path": "/tasks/write-to-a-windows-event-log/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> // use the Application event log let event_log_handle = unsafe { OpenEventLogA(PSTR::default(), "Application") }; let mut event_msg = PSTR(b"Hello in the event log\0".as_ptr() as _); unsafe { ReportEventA( HANDLE(event_log_handle.0), //h_event_log: T0__, ...
code_fim
hard
{ "lang": "rust", "repo": "DaveAxiom/rust-rosetta", "path": "/tasks/write-to-a-windows-event-log/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DaveAxiom/rust-rosetta path: /tasks/write-to-a-windows-event-log/src/main.rs #[cfg(windows)] mod bindings { ::windows::include_bindings!(); } #[cfg(windows)] use bindings::{ Windows::Win32::Security::{ GetTokenInformation, OpenProcessToken, PSID, TOKEN_ACCESS_MASK, TOKEN_INFORMA...
code_fim
hard
{ "lang": "rust", "repo": "DaveAxiom/rust-rosetta", "path": "/tasks/write-to-a-windows-event-log/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seandewar/challenge-solutions path: /leetcode/medium/flower-planting-with-no-adjacent.rs // https://leetcode.com/problems/flower-planting-with-no-adjacent // // Greedy solution. // // Because there are 4 possible colours for 3 possible paths from/into a node, we can simply choose // the colour f...
code_fim
hard
{ "lang": "rust", "repo": "seandewar/challenge-solutions", "path": "/leetcode/medium/flower-planting-with-no-adjacent.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> res[i as usize - 1] = used_colors .iter() .enumerate() .filter_map(|(i, &is_unused)| Some((i + 1) as _).filter(|_| !is_unused)) .next() .expect("4 possible colours for 3 paths implies that >= 1 colour is unused"); ...
code_fim
hard
{ "lang": "rust", "repo": "seandewar/challenge-solutions", "path": "/leetcode/medium/flower-planting-with-no-adjacent.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PatiPavanSai/rust-cardano path: /cardano/src/txbuild.rs //! Transaction Builder //! //! Simple way to build transaction step-by-step, //! with some complicated parts being abstracted //! in a simple api (add_output_policy). //! //! This also exposes generally raw API, which allow //! total flexi...
code_fim
hard
{ "lang": "rust", "repo": "PatiPavanSai/rust-cardano", "path": "/cardano/src/txbuild.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl From<fee::Error> for Error { fn from(e: fee::Error) -> Error { Error::FeeError(e) } } impl TxBuilder { /// Create a new empty transaction builder pub fn new() -> Self { TxBuilder { inputs: Vec::new(), outputs: Vec::new() } } /// Return the number of inputs in this buil...
code_fim
hard
{ "lang": "rust", "repo": "PatiPavanSai/rust-cardano", "path": "/cardano/src/txbuild.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oikos1/optics-monorepo path: /rust/optics-test/src/mocks/replica.rs #![allow(non_snake_case)] use async_trait::async_trait; use mockall::*; use ethers::core::types::{H256, U256}; use optics_core::{ accumulator::merkle::Proof, traits::{ChainCommunicationError, Common, DoubleUpdate, Rep...
code_fim
hard
{ "lang": "rust", "repo": "oikos1/optics-monorepo", "path": "/rust/optics-test/src/mocks/replica.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn _signed_update_by_old_root( &self, old_root: H256, ) -> Result<Option<SignedUpdate>, ChainCommunicationError> {} pub fn _signed_update_by_new_root( &self, new_root: H256, ) -> Result<Option<SignedUpdate>, ChainCommunic...
code_fim
hard
{ "lang": "rust", "repo": "oikos1/optics-monorepo", "path": "/rust/optics-test/src/mocks/replica.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn _signed_update_by_new_root( &self, new_root: H256, ) -> Result<Option<SignedUpdate>, ChainCommunicationError> {} pub fn _update(&self, update: &SignedUpdate) -> Result<TxOutcome, ChainCommunicationError> {} pub fn _double_update( ...
code_fim
hard
{ "lang": "rust", "repo": "oikos1/optics-monorepo", "path": "/rust/optics-test/src/mocks/replica.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// In an imperative language you might write a for loop to iterate through // multiply the values into a mutable variable. Or you might write code more // functionally with recursion and a match clause. But you can also use ranges // and iterators to solve this in rust.<|fim_prefix|>// repo: dcarney/rustl...
code_fim
hard
{ "lang": "rust", "repo": "dcarney/rustlings", "path": "/exercises/standard_library_types/iterators4.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn factorial_of_4() { assert_eq!(24, factorial(4)); assert_eq!(24, factorial_no_recursion(4)); } } // In an imperative language you might write a for loop to iterate through // multiply the values into a mutable variable. Or you might write code more // functionally wi...
code_fim
hard
{ "lang": "rust", "repo": "dcarney/rustlings", "path": "/exercises/standard_library_types/iterators4.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dcarney/rustlings path: /exercises/standard_library_types/iterators4.rs // iterators4.rs pub fn factorial(num: u64) -> u64 { match num { 1 | 2 => num, _ => num * factorial(num - 1), } } <|fim_suffix|> assert_eq!(1, factorial(1)); assert_eq!(1, factorial_n...
code_fim
hard
{ "lang": "rust", "repo": "dcarney/rustlings", "path": "/exercises/standard_library_types/iterators4.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// The way i read it, this would be another brute force attack. Which is boring. /// /// Password = seed rng with now(), throw a few (hundred) bytes away, take 2-4 outputs as random password. /// Reversing would only be a combination of the timebased brute force of previous exercises with matching a cert...
code_fim
hard
{ "lang": "rust", "repo": "Gellardo/cryptopals", "path": "/src/bin/s3c24.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gellardo/cryptopals path: /src/bin/s3c24.rs //! # MT19937 as a stream cipher //! By using a known plaintext, we can recover the keystream. //! As demonstrated in c23, the sequence of PRNG outputs can then be used to reconstruct the internal state. //! But since the challenge wants to use a 16 bi...
code_fim
hard
{ "lang": "rust", "repo": "Gellardo/cryptopals", "path": "/src/bin/s3c24.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(seed, recovered_seed.expect("no seed found")); } /// The way i read it, this would be another brute force attack. Which is boring. /// /// Password = seed rng with now(), throw a few (hundred) bytes away, take 2-4 outputs as random password. /// Reversing would only be a combination of the...
code_fim
hard
{ "lang": "rust", "repo": "Gellardo/cryptopals", "path": "/src/bin/s3c24.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>//println!("a + c is :{}",_a + _c as i32); //println!("x + c is :{}",__x + _c as i32 as f32); //println!("dx + x is :{}",_dx + _x as f32); //println!("a + x is : {}",_a + _x); //println!("s + b is :{}",_s + _b); //println!("ax + b is :{}",_ax + _b); //println!("s + c : {}",_s + _c as i32); //println!("ax...
code_fim
hard
{ "lang": "rust", "repo": "hanzalarohan123/Rust-Assigment_1", "path": "/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hanzalarohan123/Rust-Assigment_1 path: /main.rs //tiny.cc/IOTGS1 //Q1 // fn main() // { // println!("hello"); // //it wis not compiling due to missing " ! " after "println!" // } // //Q2 // fn main() { // let chocolate1 = 10; // let chocolate2 = 10; // let total: u32 = chocolate1 + cho...
code_fim
hard
{ "lang": "rust", "repo": "hanzalarohan123/Rust-Assigment_1", "path": "/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ShayMusachanov-dev/azure-functions-rs path: /azure-functions-sdk/src/commands/new.rs use crate::{ commands::TEMPLATES, util::{ create_from_template, last_segment_in_path, print_failure, print_running, print_success, }, }; use atty::Stream; use clap::{App, AppSettings, Arg, Ar...
code_fim
hard
{ "lang": "rust", "repo": "ShayMusachanov-dev/azure-functions-rs", "path": "/azure-functions-sdk/src/commands/new.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ::colored::control::set_override(match self.color { Some("auto") | None => ::atty::is(Stream::Stdout), Some("always") => true, Some("never") => false, _ => panic!("unsupported color option"), }); } pub fn execute(&self) -> Result<(),...
code_fim
hard
{ "lang": "rust", "repo": "ShayMusachanov-dev/azure-functions-rs", "path": "/azure-functions-sdk/src/commands/new.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fuchsch1234/lpc178x_7x path: /src/mcpwm/inten.rs #[doc = "Reader of register INTEN"] pub type R = crate::R<u32, super::INTEN>; #[doc = "Limit interrupt for channel 0.\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum ILIM0_A { #[doc = "0: Interrupt disabled."] INTE...
code_fim
hard
{ "lang": "rust", "repo": "fuchsch1234/lpc178x_7x", "path": "/src/mcpwm/inten.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Reader of field `ABORT`"] pub type ABORT_R = crate::R<bool, ABORT_A>; impl ABORT_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> ABORT_A { match self.bits { false => ABORT_A::INTERRUPT_DISA...
code_fim
hard
{ "lang": "rust", "repo": "fuchsch1234/lpc178x_7x", "path": "/src/mcpwm/inten.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let input = include_str!("../12.in").trim(); let instructions = parse(input); println!("{:?}", instructions); let ship_pos = navigate(&instructions); println!("part2: {}", ship_pos.x.abs() + ship_pos.y.abs()) }<|fim_prefix|>// repo: JensPfeifle/adventofcode-2020 path: /day...
code_fim
hard
{ "lang": "rust", "repo": "JensPfeifle/adventofcode-2020", "path": "/day12/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JensPfeifle/adventofcode-2020 path: /day12/src/main.rs fn parse(input: &str) -> Vec<(char, isize)> { let mut instructions: Vec<(char, isize)> = Vec::new(); for line in input.lines() { let d = line.chars().nth(0).unwrap(); let s: isize = line.chars().skip(1).collect::<Stri...
code_fim
hard
{ "lang": "rust", "repo": "JensPfeifle/adventofcode-2020", "path": "/day12/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match dir { 'R' => match angle { 90 => return Coords { x: y, y: -x }, 180 => return Coords { x: -x, y: -y }, 270 => return Coords { x: -y, y: x }, _ => panic!(), }, 'L' => match angle { 90 => return Coords { x: -y, y: ...
code_fim
medium
{ "lang": "rust", "repo": "JensPfeifle/adventofcode-2020", "path": "/day12/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MiyamonY/atcoder path: /abc/044/c/01/src/main.rs #[allow(unused_macros)] macro_rules! scan { () => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().to_string() } }; (;;) => { ...
code_fim
hard
{ "lang": "rust", "repo": "MiyamonY/atcoder", "path": "/abc/044/c/01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut ans: i64 = 0; for (num, v) in dp[n].iter().enumerate().skip(1) { for (sum, &n) in v.iter().enumerate() { if sum % num == 0 && sum / num == a { ans += n; } } } println!("{}", ans); }<|fim_prefix|>// repo: MiyamonY/atcoder pat...
code_fim
hard
{ "lang": "rust", "repo": "MiyamonY/atcoder", "path": "/abc/044/c/01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (n, a) = scan!(usize, usize); let vs = scan!(usize;;); let mut dp = vec![vec![vec![0; vs.iter().max().unwrap() * n + 1]; n + 1]; n + 1]; dp[0][0][0] = 1; // card num for (i, &v) in vs.iter().enumerate() { // selected num for j in 0..dp[i + 1].len() { ...
code_fim
hard
{ "lang": "rust", "repo": "MiyamonY/atcoder", "path": "/abc/044/c/01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tkonolige/embree-rs-1 path: /examples/support/src/display.rs use arcball::ArcballCamera; use cgmath::{SquareMatrix, Matrix4, Vector2, Vector3, Vector4}; use clock_ticks; use glium::glutin::{ElementState, Event, MouseButton, MouseScrollDelta, VirtualKeyCode, WindowEvent}; use ...
code_fim
hard
{ "lang": "rust", "repo": "tkonolige/embree-rs-1", "path": "/examples/support/src/display.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Display { pub fn new(w: u32, h: u32, title: &str) -> Display { let event_loop = glutin::EventsLoop::new(); let window_builder = glutin::WindowBuilder::new() .with_dimensions(w, h) .with_title(title); let context_builder = glutin::ContextBuilder::new...
code_fim
hard
{ "lang": "rust", "repo": "tkonolige/embree-rs-1", "path": "/examples/support/src/display.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kette-language/drip-old path: /crates/drip_parser/src/error.rs use drip_lexer::TokenKind; use std::fmt; use std::fmt::Formatter; use text_size::TextRange; #[derive(Debug, Clone, PartialEq)] pub struct ParseError { pub expected: Vec<TokenKind>, pub found: Option<TokenKind>, pub range...
code_fim
hard
{ "lang": "rust", "repo": "kette-language/drip-old", "path": "/crates/drip_parser/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (idx, expected_kind) in self.expected.iter().enumerate() { if is_first(idx) { write!(f, "{}", expected_kind)?; } else if is_last(idx) { write!(f, " or {}", expected_kind)?; } else { write!(f, ", {}", expected_k...
code_fim
hard
{ "lang": "rust", "repo": "kette-language/drip-old", "path": "/crates/drip_parser/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(found) = self.found { write!(f, ", but found {}", found)?; } Ok(()) } }<|fim_prefix|>// repo: kette-language/drip-old path: /crates/drip_parser/src/error.rs use drip_lexer::TokenKind; use std::fmt; use std::fmt::Formatter; use text_size::TextRange; #[...
code_fim
hard
{ "lang": "rust", "repo": "kette-language/drip-old", "path": "/crates/drip_parser/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // close substream substream.close().await.unwrap(); // try to read/write to closed substream; should error substream.write_all(MSG_INNER).await.unwrap_err(); substream.read_exact(&mut buf).await.unwrap_err(); // assert a close message was sent over the mi...
code_fim
hard
{ "lang": "rust", "repo": "nymtech/nym", "path": "/sdk/rust/nym-sdk/examples/libp2p_shared/substream.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = [0u8; 4]; let read_len = substream.read(&mut buf).await.unwrap(); assert_eq!(read_len, buf.len()); assert_eq!(buf.to_vec(), b"noot".to_vec()); let data = b"asdf".to_vec(); inbound_tx.send(data.clone()).unwrap(); let mut buf = [0u8; 4]...
code_fim
hard
{ "lang": "rust", "repo": "nymtech/nym", "path": "/sdk/rust/nym-sdk/examples/libp2p_shared/substream.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nymtech/nym path: /sdk/rust/nym-sdk/examples/libp2p_shared/substream.rs use super::message::{ ConnectionId, Message, OutboundMessage, SubstreamId, SubstreamMessage, TransportMessage, }; use futures::{ io::{Error as IoError, ErrorKind}, AsyncRead, AsyncWrite, }; use log::debug; use ny...
code_fim
hard
{ "lang": "rust", "repo": "nymtech/nym", "path": "/sdk/rust/nym-sdk/examples/libp2p_shared/substream.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }