text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: clucompany/macro_tt_utils path: /src/diagnostics/throw_note.rs use alloc::string::String; use crate::data::span::SpanElement; use proc_macro::TokenStream; use core::fmt::Debug; <|fim_suffix|> #[inline] pub fn throw(self) -> TokenStream { self.raw_throw(); crate::token_gen::empty_token() ...
code_fim
hard
{ "lang": "rust", "repo": "clucompany/macro_tt_utils", "path": "/src/diagnostics/throw_note.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn throw(self) -> TokenStream { self.raw_throw(); crate::token_gen::empty_token() } } #[inline] pub fn throw_note<S: SpanElement, I: Into<String> + Debug>(sp: S, str: I) -> TokenStream { ThrowNote::new(sp, str).throw() }<|fim_prefix|>// repo: clucompany/macro_tt_utils path: /src/di...
code_fim
medium
{ "lang": "rust", "repo": "clucompany/macro_tt_utils", "path": "/src/diagnostics/throw_note.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] pub fn throw_note<S: SpanElement, I: Into<String> + Debug>(sp: S, str: I) -> TokenStream { ThrowNote::new(sp, str).throw() }<|fim_prefix|>// repo: clucompany/macro_tt_utils path: /src/diagnostics/throw_note.rs use alloc::string::String; use crate::data::span::SpanElement; use proc_macro::Toke...
code_fim
medium
{ "lang": "rust", "repo": "clucompany/macro_tt_utils", "path": "/src/diagnostics/throw_note.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> TokenStream::from(tokens) // TokenStream::new() }<|fim_prefix|>// repo: mkatychev/proc-macro-workshop path: /builder/src/lib.rs extern crate proc_macro; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::quote; use syn::{parse_macro_input, DeriveInput}; <|fim_middle|>#[proc...
code_fim
hard
{ "lang": "rust", "repo": "mkatychev/proc-macro-workshop", "path": "/builder/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mkatychev/proc-macro-workshop path: /builder/src/lib.rs extern crate proc_macro; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::quote; use syn::{parse_macro_input, DeriveInput}; <|fim_suffix|> TokenStream::from(tokens) // TokenStream::new() }<|fim_middle|>#[proc...
code_fim
hard
{ "lang": "rust", "repo": "mkatychev/proc-macro-workshop", "path": "/builder/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("Hello, Out of the window! {}", utils::functions::sum(0,1)); thread::sleep(Duration::from_millis(6000)); }); }<|fim_prefix|>// repo: Schakkall/tetris path: /src/main.rs //use utils::functions::sum; use view::screen::show; use std::thread; use std::time::D...
code_fim
medium
{ "lang": "rust", "repo": "Schakkall/tetris", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Schakkall/tetris path: /src/main.rs //use utils::functions::sum; use view::screen::show; use std::thread; use std::time::Duration; <|fim_suffix|> println!("Hello, Out of the window! {}", utils::functions::sum(0,1)); thread::sleep(Duration::from_millis(6000)); }...
code_fim
hard
{ "lang": "rust", "repo": "Schakkall/tetris", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chbdetta/obiwan path: /src/ast/stmt.rs use super::binding::SingleNameBinding; use super::expr::Expr as EExpr; use crate::codegen::Codegen; use crate::eval::{Eval, Evaluator, Value}; use crate::token::{Token, TokenType}; #[derive(Debug, Clone, Codegen, Eq, PartialEq, Eval)] pub enum Stmt { B...
code_fim
hard
{ "lang": "rust", "repo": "chbdetta/obiwan", "path": "/src/ast/stmt.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Codegen for For { fn to_code(&self) -> String { format!( "for({};{};{}) {}", self.init.to_code(), self.cond.to_code(), self.modi.to_code(), self.body.to_code(), ) } } impl Codegen for Switch { fn to_code(&self) -...
code_fim
hard
{ "lang": "rust", "repo": "chbdetta/obiwan", "path": "/src/ast/stmt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut vec: Vec<String> = vec![]; for item in line.split('\t') { vec.push(item.to_string()); } vec } pub fn load_filedump(app_info: &AppInfo) -> String { let db = app_info.get_db_resolver(); let fname = app_info.get_config_server().get_dumpfile(); let file = File::ope...
code_fim
hard
{ "lang": "rust", "repo": "cqueirolo/21C1-Stormtroopers", "path": "/redis_server/src/data_base/filedump.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cqueirolo/21C1-Stormtroopers path: /redis_server/src/data_base/filedump.rs //! Crate in charge of saving and loading snapshots of the database. use crate::constants::{DBDUMP_INTERVAL_SECS, DBDUMP_PATH, ERROR_DBFILE_CREATE}; use crate::server::app_info::AppInfo; use crate::server::utils::timestam...
code_fim
medium
{ "lang": "rust", "repo": "cqueirolo/21C1-Stormtroopers", "path": "/redis_server/src/data_base/filedump.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_line(line: String) -> Vec<String> { let mut vec: Vec<String> = vec![]; for item in line.split('\t') { vec.push(item.to_string()); } vec } pub fn load_filedump(app_info: &AppInfo) -> String { let db = app_info.get_db_resolver(); let fname = app_info.get_config_serv...
code_fim
hard
{ "lang": "rust", "repo": "cqueirolo/21C1-Stormtroopers", "path": "/redis_server/src/data_base/filedump.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>:retry::Standard, > { handle: std::sync::Arc<super::Handle<C, M, R>>, inner: crate::input::create_detector_model_input::Builder, } impl<C, M, R> CreateDetectorModel<C, M, R> where C: smithy_client::bounds::SmithyConnector, M: smithy_client::bounds::SmithyMid...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/iotevents/src/client.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/iotevents/src/client.rs ption::Option<std::string::String>) -> Self { self.inner = self.inner.set_next_token(input); self } /// <p>The maximum number of results to be returned per request.</p> pub fn max_results(mut s...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/iotevents/src/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>lf.inner = self.inner.evaluation_method(inp); self } pub fn set_evaluation_method( mut self, input: std::option::Option<crate::model::EvaluationMethod>, ) -> Self { self.inner = self.inner.set_evaluation_method(input); sel...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/iotevents/src/client.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>where Extractor: axum::extract::FromRequest<()>, { } fn main() {}<|fim_prefix|>// repo: tokio-rs/axum path: /axum-macros/tests/from_request/pass/tuple.rs use axum_macros::FromRequest; #[derive(FromRequest)] struct Extractor(axum::http::HeaderMap, String); <|fim_middle|>fn assert_from_request()
code_fim
easy
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum-macros/tests/from_request/pass/tuple.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tokio-rs/axum path: /axum-macros/tests/from_request/pass/tuple.rs use axum_macros::FromRequest; <|fim_suffix|>fn assert_from_request() where Extractor: axum::extract::FromRequest<()>, { } fn main() {}<|fim_middle|>#[derive(FromRequest)] struct Extractor(axum::http::HeaderMap, String);
code_fim
medium
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum-macros/tests/from_request/pass/tuple.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NicolasLagaillardie/mpst_rust_github path: /tests/cancel_mod/cancel_11.rs use mpstthree::binary::struct_trait::{end::End, recv::Recv, send::Send}; use mpstthree::role::broadcast::RoleBroadcast; use mpstthree::role::end::RoleEnd; use mpstthree::{ broadcast_cancel, bundle_struct_fork_close_mul...
code_fim
hard
{ "lang": "rust", "repo": "NicolasLagaillardie/mpst_rust_github", "path": "/tests/cancel_mod/cancel_11.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn recurs_c(s: EndpointC, index: i64) -> Result<(), Box<dyn Error>> { match index { 0 => { let s = choose_mpst_multi_cancel_to_all!( s, Branching0fromCtoB::Done, => RoleB, => RoleA, RoleC, ...
code_fim
hard
{ "lang": "rust", "repo": "NicolasLagaillardie/mpst_rust_github", "path": "/tests/cancel_mod/cancel_11.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/lucet path: /lucet-wasi/tests/tests.rs mod test_helpers; use crate::test_helpers::{ init_tracing, lucet_wasi_tests_internal_ensure_linked, run, run_with_null_stdin, run_with_stdout, LUCET_WASI_ROOT, }; use lucet_wasi::WasiCtxBuilder; use std::io::{Read, Write}; use std::...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/lucet", "path": "/lucet-wasi/tests/tests.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>// ACF 2019-10-03: temporarily disabled until we figure out why it's behaving differently only in // one CI environment #[ignore] #[test] fn poll() { init_tracing(); let ctx = WasiCtxBuilder::new().args(&["poll".to_owned()]).unwrap(); let exitcode = run_with_null_stdin("poll.c", ctx).unwrap();...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/lucet", "path": "/lucet-wasi/tests/tests.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(tup.0,101); assert_eq!(tup.1,102); assert_eq!(tup.2,2); assert_eq!(tup.3,103); assert_eq!(tup.4,4); } { let mut tup=(0,1,2,3,4,5,6,7,8); let (e0,e1,e2,e3)=tup.fields_mut(fp!(0,1,2,8)); ...
code_fim
hard
{ "lang": "rust", "repo": "RalfJung/structural_crates", "path": "/structural/src/field_traits/tuple_impls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RalfJung/structural_crates path: /structural/src/field_traits/tuple_impls.rs use crate::{Structural,IntoFieldMut}; use crate::structural_trait::{FieldInfo,StructuralDyn}; use crate::field_traits::for_arrays::names; macro_rules! impl_tuple { (inner; ($field:tt,$field_ty:ident,$fiel...
code_fim
hard
{ "lang": "rust", "repo": "RalfJung/structural_crates", "path": "/structural/src/field_traits/tuple_impls.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> structural_alias!{ trait Tuple4{ mut move 0:u32, mut move 1:u32, mut move 2:u32, mut move 3:u32, } } fn takes_tuple4<This>(mut this:This) where This:Tuple4, { assert_eq!(this.fields(fp!(0,1)),(&6,&5)); ...
code_fim
hard
{ "lang": "rust", "repo": "RalfJung/structural_crates", "path": "/structural/src/field_traits/tuple_impls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: allchain/s3-server path: /tests/basic.rs //! cargo test --test basic -- --test-threads=1 mod common; use common::Request; use s3_server::fs::TokioFileSystem as FileSystem; use s3_server::headers::names::X_AMZ_CONTENT_SHA256; use s3_server::{path::S3Path, S3Service}; use anyhow::{Context, Res...
code_fim
hard
{ "lang": "rust", "repo": "allchain/s3-server", "path": "/tests/basic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[tokio::test] async fn get_object() { let (_, service) = setup_service().unwrap(); let bucket = "asd"; let key = "qwe"; let mut req = Request::new(Body::empty()); *req.method_mut() = Method::GET; *req.uri_mut() = format!("http://localhost/{}/{}", ...
code_fim
hard
{ "lang": "rust", "repo": "allchain/s3-server", "path": "/tests/basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[error("Unable to create a detector: {reason}")] CreateDetectorError { reason: String }, }<|fim_prefix|>// repo: jerry73204/apriltag-rust path: /apriltag/src/error.rs //! Defines the error type for the crate. /// The error type for the crate. #[derive(Debug, Clone, thiserror::Error)] pub enum E...
code_fim
medium
{ "lang": "rust", "repo": "jerry73204/apriltag-rust", "path": "/apriltag/src/error.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jerry73204/apriltag-rust path: /apriltag/src/error.rs //! Defines the error type for the crate. <|fim_suffix|> #[error("Unable to create an image: {reason}")] CreateImageError { reason: String }, #[error("Unable to create a detector: {reason}")] CreateDetectorError { reason: Str...
code_fim
medium
{ "lang": "rust", "repo": "jerry73204/apriltag-rust", "path": "/apriltag/src/error.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert y...
code_fim
hard
{ "lang": "rust", "repo": "TheusZer0/ctf-archives", "path": "/N1CTF/2021/rev/babyrust/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheusZer0/ctf-archives path: /N1CTF/2021/rev/babyrust/main.rs desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert...
code_fim
hard
{ "lang": "rust", "repo": "TheusZer0/ctf-archives", "path": "/N1CTF/2021/rev/babyrust/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rt you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert you Never gonna run around and desert...
code_fim
hard
{ "lang": "rust", "repo": "TheusZer0/ctf-archives", "path": "/N1CTF/2021/rev/babyrust/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut tmp = start; for &slot in BRUTE_FORCE_SLOTS { bf_prog[slot as usize] = tmp % self.database[slot as usize].len(); tmp /= self.database[slot as usize].len(); } 'done: loop { let mut number = 0; let mut b...
code_fim
hard
{ "lang": "rust", "repo": "gamozolabs/wow_priest_theorycraftin", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gamozolabs/wow_priest_theorycraftin path: /src/main.rs armor: 37, intellect: 14, ..Default::default() }, Item { name: "Elders Hat of Stamina", armor: 37, intellect: 14, ...
code_fim
hard
{ "lang": "rust", "repo": "gamozolabs/wow_priest_theorycraftin", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Mana = base mana + 1 mana for int for the first 20 int, then 15 mana // per int if int < 20 { mana + int } else { mana + 20 + (int - 20) * 15 } } fn worker(&'a mut self, wid: usize, start: usize, iters_to_run: usize, stats: Arc<St...
code_fim
hard
{ "lang": "rust", "repo": "gamozolabs/wow_priest_theorycraftin", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn writechar(c: u8) { // Wait until we are permitted to write. loop { let status: u8 = io::inport(SERIAL_BASE + LStat as u16); if (status & 0x20) != 0 { break; } } io::outport(SERIAL_BASE + RxTx as u16, c); } pub fn write(s: &str) { // Pull out the...
code_fim
hard
{ "lang": "rust", "repo": "flaper87/rustic", "path": "/src/serial/mod.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flaper87/rustic path: /src/serial/mod.rs /* * Copyright (c) 2013 Matthew Iselin * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copi...
code_fim
hard
{ "lang": "rust", "repo": "flaper87/rustic", "path": "/src/serial/mod.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> // Enable and clear the FIFO. io::outport(SERIAL_BASE + IIFifo as u16, 0xC7 as u8); // Set RTS/DSR, and enable IRQs for if/when INTEN == 1. io::outport(SERIAL_BASE + MCtrl as u16, 0x0B as u8); } fn writechar(c: u8) { // Wait until we are permitted to write. loop { let sta...
code_fim
hard
{ "lang": "rust", "repo": "flaper87/rustic", "path": "/src/serial/mod.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamwaffles/stm32-cube path: /common/src/apa106led.rs pub const ON_BYTE: u8 = 0b1111_1100; pub const OFF_BYTE: u8 = 0b1100_0000; pub const WARM_WHITE: Apa106Led = Apa106Led { red: 255, green: 183, blue: 76, }; pub const OFF: Apa106Led = Apa106Led { red: 0, green: 0, blue...
code_fim
hard
{ "lang": "rust", "repo": "jamwaffles/stm32-cube", "path": "/common/src/apa106led.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Ramp red down to 0, green up to 255 if thingy < 85 { Apa106Led { red: 255 - thingy * 3, green: thingy * 3, blue: 0, } } else if thingy < 170 { // Ramp red and blue up, leave green at 255 thingy -= 85; Apa106Led { ...
code_fim
hard
{ "lang": "rust", "repo": "jamwaffles/stm32-cube", "path": "/common/src/apa106led.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: micouy/veccentric path: /src/vecc.rs of owned and borrowed /// args), namely addition, subtraction, element-wise multiplication, /// element-wise division and multiplication & division by a number. (Note that /// you can only multiply and divide in the following order: `vector op number`, /// s...
code_fim
hard
{ "lang": "rust", "repo": "micouy/veccentric", "path": "/src/vecc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: micouy/veccentric path: /src/vecc.rs /// Generic vector with two components. /// /// It implements multiple operators (for each combination of owned and borrowed /// args), namely addition, subtraction, element-wise multiplication, /// element-wise division and multiplication & division by a n...
code_fim
hard
{ "lang": "rust", "repo": "micouy/veccentric", "path": "/src/vecc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Vecc { x: self.x.rem(rhs.x), y: self.y.rem(rhs.y), } } } // Borrowed & borrowed. impl<T> Rem<&Vecc<T>> for &Vecc<T> where T: Rem<Output = T> + Copy + Notf64, { type Output = Vecc<T>; fn rem(self, rhs: &Vecc<T>) -> Self::Output { Vecc { ...
code_fim
hard
{ "lang": "rust", "repo": "micouy/veccentric", "path": "/src/vecc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ktwu/aoc2020 path: /src/day24.rs #![allow(dead_code)] use crate::utils; use std::collections::{HashMap, HashSet}; use strum::IntoEnumIterator; use strum_macros::EnumIter; #[derive(EnumIter)] pub enum Direction { E, NE, SE, W, NW, SW, } impl Direction { pub fn delt...
code_fim
hard
{ "lang": "rust", "repo": "Ktwu/aoc2020", "path": "/src/day24.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for line in input { let tile = TileFloor::parse_tile(&line); if !black_tiles.remove(&tile) { black_tiles.insert(tile); } } TileFloor { black_tiles } } pub fn parse_tile(line: &str) -> (i32, i32) { let mut coordin...
code_fim
hard
{ "lang": "rust", "repo": "Ktwu/aoc2020", "path": "/src/day24.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] struct SampleDescriptionBox { full_box_header: FullBoxHeader, index: Vec<SampleEntryBox>, } #[derive(Debug)] struct SampleEntryBox { box_header: BoxHeader, data_reference_index: u16, }<|fim_prefix|>// repo: matsune/heif path: /src/bbox/moov/media.rs use crate::bbox::head...
code_fim
hard
{ "lang": "rust", "repo": "matsune/heif", "path": "/src/bbox/moov/media.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matsune/heif path: /src/bbox/moov/media.rs use crate::bbox::header::{BoxHeader, FullBoxHeader}; use crate::bbox::meta::dinf::DataEntryBox; #[derive(Debug)] pub struct MediaBox { box_header: BoxHeader, media_header_box: MediaHeaderBox, handler_box: HandlerBox, media_information_b...
code_fim
hard
{ "lang": "rust", "repo": "matsune/heif", "path": "/src/bbox/moov/media.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl std::fmt::Debug for DataReferenceBox { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "DataReferenceBox {:?}", self.full_box_header) } } #[derive(Debug)] struct SampleTableBox { box_header: BoxHeader, sample_description_box: SampleDescriptionBox, }...
code_fim
hard
{ "lang": "rust", "repo": "matsune/heif", "path": "/src/bbox/moov/media.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Connect via HTTP/2. Failure to connect will not fall back to old /// versions, unless HTTP/1.1 is negotiated via TLS ALPN before the session /// begins. /// /// If HTTP/2 support is not compiled in, then using this strategy will /// always result in an error. /// /// Th...
code_fim
hard
{ "lang": "rust", "repo": "sagebind/isahc", "path": "/src/config/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sagebind/isahc path: /src/config/mod.rs iguring an easy // handle. use self::{proxy::Proxy, request::SetOpt}; use crate::{ auth::{Authentication, Credentials}, is_http_version_supported, }; use curl::easy::Easy2; use std::{net::IpAddr, time::Duration}; pub(crate) mod client; pub(crate)...
code_fim
hard
{ "lang": "rust", "repo": "sagebind/isahc", "path": "/src/config/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Bind local socket connections to a particular network interface. /// /// # Examples /// /// Bind to an IP address. /// /// ``` /// use isahc::{ /// prelude::*, /// config::NetworkInterface, /// HttpClient, /// Request, /// }; /// ...
code_fim
hard
{ "lang": "rust", "repo": "sagebind/isahc", "path": "/src/config/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: setup graphics and input and sound let args: Vec<String> = std::env::args().collect(); let rom_loader = RomLoader::new(args[1].clone()); let mut display = Display::new(); let mut cpu = Cpu::new(); cpu.load_program(&rom_loader); loop { cpu.emulate_cycle(); ...
code_fim
medium
{ "lang": "rust", "repo": "Seantz12/rusty-chip8", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Seantz12/rusty-chip8 path: /src/main.rs mod cpu; mod display; mod font; mod rom_loader; mod keys; use cpu::Cpu; use display::Display; use rom_loader::RomLoader; <|fim_suffix|> // TODO: setup graphics and input and sound let args: Vec<String> = std::env::args().collect(); let rom_loa...
code_fim
hard
{ "lang": "rust", "repo": "Seantz12/rusty-chip8", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HichuYamichu/advent path: /src/solutions/y2020/day03.rs pub fn a(input: String) -> String { let mut grid = input.lines().map(|l| l.chars().cycle()); let mut trees = 0; grid.next(); let mut y_axis = 3; for mut line in grid { let c = line.nth(y_axis).unwrap(); i...
code_fim
hard
{ "lang": "rust", "repo": "HichuYamichu/advent", "path": "/src/solutions/y2020/day03.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn b(input: String) -> String { let slopes = &[ Slope { right: 1, down: 1 }, Slope { right: 3, down: 1 }, Slope { right: 5, down: 1 }, Slope { right: 7, down: 1 }, Slope { right: 1, down: 2 }, ]; slopes .iter() .map(|s| { ...
code_fim
medium
{ "lang": "rust", "repo": "HichuYamichu/advent", "path": "/src/solutions/y2020/day03.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Guess the number!"); let secret_number = get_secret_number(1, 100); loop { println!("type your guess here:"); let mut player_guess = String::new(); io::stdin() .read_line(&mut player_guess) .expect("Failed to read line"); // g...
code_fim
medium
{ "lang": "rust", "repo": "dylanbuchi/guessing-game", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if player_guess == secret_number { break; } } } fn check_player_guess(&player_guess: &u32, &secret_number: &u32) { match player_guess.cmp(&secret_number) { Ordering::Greater => println!("Too big!"), Ordering::Less => println!("Too small!"), Orde...
code_fim
medium
{ "lang": "rust", "repo": "dylanbuchi/guessing-game", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dylanbuchi/guessing-game path: /src/main.rs use rand::Rng; use std::cmp::Ordering; use std::io; fn main() { play_guessing_game(); } // generates a random number from start (inclusive) to end (inclusive) fn get_secret_number(start: u32, end: u32) -> u32 { rand::thread_rng().gen_range(st...
code_fim
medium
{ "lang": "rust", "repo": "dylanbuchi/guessing-game", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); }<|fim_prefix|>// repo: akiles/embassy path: /docs/modules/ROOT/examples/basic/src/main.rs #![no_std] #![no_main] #![feature(type_alias_impl_trait)] use defmt::*; ...
code_fim
hard
{ "lang": "rust", "repo": "akiles/embassy", "path": "/docs/modules/ROOT/examples/basic/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akiles/embassy path: /docs/modules/ROOT/examples/basic/src/main.rs #![no_std] #![no_main] #![feature(type_alias_impl_trait)] use defmt::*; use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::peripherals::P0_13; use embassy_time::{Duration, Timer}...
code_fim
medium
{ "lang": "rust", "repo": "akiles/embassy", "path": "/docs/modules/ROOT/examples/basic/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytefall/debugbox path: /src/gui/main.rs use iced::{button, Align, Button, Column, Element, Sandbox, Text}; use zbus::Connection; #[derive(Default)] pub struct DebugBox { cpu_run: button::State, console: String, } #[derive(Debug, Clone, Copy)] pub enum Message { CpuRun, } impl Sandbox for ...
code_fim
hard
{ "lang": "rust", "repo": "bytefall/debugbox", "path": "/src/gui/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn new() -> Self { Self::default() } fn title(&self) -> String { String::from("DebugBox") } fn update(&mut self, message: Self::Message) { match message { Message::CpuRun => { let conn = pollster::block_on(Connection::session()).unwrap(); let result = pollster::block_on(conn.call_m...
code_fim
medium
{ "lang": "rust", "repo": "bytefall/debugbox", "path": "/src/gui/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> String::from("DebugBox") } fn update(&mut self, message: Self::Message) { match message { Message::CpuRun => { let conn = pollster::block_on(Connection::session()).unwrap(); let result = pollster::block_on(conn.call_method(Some("com.dosbox"), "/cpu", Some("com.dosbox"), "run", &())).unwr...
code_fim
medium
{ "lang": "rust", "repo": "bytefall/debugbox", "path": "/src/gui/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn collides(&self, board: &Board) -> bool { let cells = self.get_cells(); for (x, y) in cells { if x < 0 || y < 0 || x >= board.columns() as isize { return true; } if y >= board.rows() as isize { continue; ...
code_fim
hard
{ "lang": "rust", "repo": "battesonb/tetris-rs", "path": "/src/tetromino.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: battesonb/tetris-rs path: /src/tetromino.rs use macroquad::{color::Color, rand}; use crate::board::Board; #[derive(Clone)] pub struct Tetromino { pub name: TetrominoName, pub structure: TetrominoStructure, pub rotation: TetrominoRotation, // bottom-left of Tetromino pub x: ...
code_fim
hard
{ "lang": "rust", "repo": "battesonb/tetris-rs", "path": "/src/tetromino.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let structure_length = structure.get_length(); let x = rand::gen_range( 0, ((board.columns() as isize) - structure_length) as i32 + 1, ); Tetromino { name: tetromino_name, structure, rotation: TetrominoRotation::Z...
code_fim
hard
{ "lang": "rust", "repo": "battesonb/tetris-rs", "path": "/src/tetromino.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexander-jackson/advent-of-code-2020 path: /day16/src/main.rs use std::collections::HashMap; use std::ops::RangeInclusive; use std::str::FromStr; use regex::Regex; #[macro_use] extern crate lazy_static; lazy_static! { static ref RULE: Regex = Regex::new(r"^([a-z ]*): (\d*)-(\d*) or (\d*)...
code_fim
hard
{ "lang": "rust", "repo": "alexander-jackson/advent-of-code-2020", "path": "/day16/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let others = blocks .next() .unwrap() .split('\n') .skip(1) .map(|x| Ticket::from(x)); let solution: usize = others.map(|t| rules.check(&t).iter().sum::<usize>()).sum(); println!("Part 1 Solution: {}", solution); }<|fim_prefix|>// repo: alexander-jacks...
code_fim
hard
{ "lang": "rust", "repo": "alexander-jackson/advent-of-code-2020", "path": "/day16/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LayGPark/rust_study path: /shoe_size/src/lib.rs #[derive(PartialEq, Debug)] pub struct Shoe { pub size: u32, pub style: String, } /// shoe_size 와 동일한 신발들을 반환한다. /// /// # Examples /// /// ``` /// #[derive(PartialEq, Debug)] /// pub struct Shoe { /// pub size: u32, /// pub style: Strin...
code_fim
hard
{ "lang": "rust", "repo": "LayGPark/rust_study", "path": "/shoe_size/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut counter = Counter::new(); assert_eq!(counter.next(), Some(1)); assert_eq!(counter.next(), Some(2)); assert_eq!(counter.next(), Some(3)); assert_eq!(counter.next(), Some(4)); assert_eq!(counter.next(), Some(5)); assert_eq!(counter.next(), None); } #[test] fn using...
code_fim
hard
{ "lang": "rust", "repo": "LayGPark/rust_study", "path": "/shoe_size/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn parse_dec() { let instruction: Instruction = "dec a".parse().unwrap(); assert_eq!(instruction, Instruction::Dec(Register::A)); } #[test] fn parse_jnz() { let instruction: Instruction = "jnz a 2".parse().unwrap(); assert_eq!(instruction, Instr...
code_fim
hard
{ "lang": "rust", "repo": "rnestler/advent_of_code_2016", "path": "/12/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rnestler/advent_of_code_2016 path: /12/src/lib.rs use std::str::FromStr; pub fn puzzle(input: &str) -> i32 { let code: Vec<_> = input.lines().enumerate().map(|(k,v)| { Instruction::from_str(v).expect(&format!("Failed to parse line {}: {}", k, v)) }).collect(); let mut machin...
code_fim
hard
{ "lang": "rust", "repo": "rnestler/advent_of_code_2016", "path": "/12/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn jnz(&mut self, value: FromLocation, offset: i32) { let value = match value { FromLocation::Reg(reg) => self.get_reg(reg), FromLocation::Int(val) => val, }; if value != 0 { if offset > 0 { self.pc += offset as usize; ...
code_fim
hard
{ "lang": "rust", "repo": "rnestler/advent_of_code_2016", "path": "/12/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dylanmckay/hllvm path: /src/sys/ir/context.rs use ContextRef; cpp! { #include "llvm/IR/LLVMContext.h" <|fim_suffix|> pub fn LLVMRustDestroyContext(ctx: ContextRef as "llvm::LLVMContext*") { delete ctx; } } #[cfg(test)] mod test { use super::*; #[test] fn can_cr...
code_fim
medium
{ "lang": "rust", "repo": "dylanmckay/hllvm", "path": "/src/sys/ir/context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; #[test] fn can_create_and_destroy() { let ctx = unsafe { LLVMRustCreateContext() }; unsafe { LLVMRustDestroyContext(ctx) }; } }<|fim_prefix|>// repo: dylanmckay/hllvm path: /src/sys/ir/context.rs use ContextRef; cpp! { #include "...
code_fim
hard
{ "lang": "rust", "repo": "dylanmckay/hllvm", "path": "/src/sys/ir/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl TaskIns { pub fn new(task_def: TaskDef) -> Self { TaskIns { id: Uuid::new_v4().to_string(), task_def, state: TaskState::RUNNING, } } pub fn run(&self, input: Option<Form>) { if let Some(f) = self.task_def.runner { f(...
code_fim
medium
{ "lang": "rust", "repo": "tokyohuang123/flow-rs", "path": "/flow-engine/src/task.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tokyohuang123/flow-rs path: /flow-engine/src/task.rs use crate::form::Form; use uuid::Uuid; type Callback = fn(Option<Form>); #[derive(PartialEq, Clone)] pub enum TaskKind { BeginEvent, UserTask, ReceiveTask, ServiceTask, EndEvent, } pub enum TaskState { NOTRUN, RU...
code_fim
hard
{ "lang": "rust", "repo": "tokyohuang123/flow-rs", "path": "/flow-engine/src/task.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MarkusAkesson/speck path: /src/lib.rs #![no_std] const ROUNDS: usize = 32; #[inline(always)] fn round(x: &mut u64, y: &mut u64, k: u64) { *x = x.rotate_right(8); *x = x.wrapping_add(*y); *x ^= k; *y = y.rotate_left(3); *y ^= *x; } #[inline(always)] fn inv_round(x: &mut u64,...
code_fim
hard
{ "lang": "rust", "repo": "MarkusAkesson/speck", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn decrypt() { let k: [u64; 2] = [0x0f0e0d0c0b0a0908, 0x0706050403020100]; let mut rk: [u64; 32] = [0; 32]; crate::key_schedule(&k, &mut rk); let ct: [u64; 2] = [0xa65d985179783265, 0x7860fedf5c570d18]; let expected: [u64; 2] = [0x6c61766975716520,...
code_fim
hard
{ "lang": "rust", "repo": "MarkusAkesson/speck", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sindrehan/mkl82z7-pac path: /src/mcg/c5.rs #[doc = "Register `C5` reader"] pub struct R(crate::R<C5_SPEC>); impl core::ops::Deref for R { type Target = crate::R<C5_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<C5_SPEC>> for R {...
code_fim
hard
{ "lang": "rust", "repo": "sindrehan/mkl82z7-pac", "path": "/src/mcg/c5.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Field `PLLSTEN` reader - PLL Stop Enable"] pub struct PLLSTEN_R(crate::FieldReader<bool, PLLSTEN_A>); impl PLLSTEN_R { pub(crate) fn new(bits: bool) -> Self { PLLSTEN_R(crate::FieldReader::new(bits)) } #[doc = r"Get enumerated values variant"...
code_fim
hard
{ "lang": "rust", "repo": "sindrehan/mkl82z7-pac", "path": "/src/mcg/c5.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrc/r4cppp path: /graphs/src/ref_graph.rs use std::cell::UnsafeCell; use std::collections::HashSet; use arena::TypedArena; struct Node<'a> { datum: &'static str, edges: UnsafeCell<Vec<&'a Node<'a>>>, } impl<'a> Node<'a> { fn new<'b>(datum: &'static str, arena: &'b TypedArena<Node<...
code_fim
medium
{ "lang": "rust", "repo": "nrc/r4cppp", "path": "/graphs/src/ref_graph.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { (*self.edges.get())[0] } } } fn foo<'a>(node: &'a Node<'a>) { println!("foo: {}", node.datum); } fn init<'a>(arena: &'a TypedArena<Node<'a>>) ->&'a Node<'a> { let root = Node::new("A", arena); let b = Node::new("B", arena); let c = Node::new("C",...
code_fim
hard
{ "lang": "rust", "repo": "nrc/r4cppp", "path": "/graphs/src/ref_graph.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>3. 根据表达式三条规则:以下 main 函数能正常编译 a. 首先 main 函数就是一个大的块表达式,因其签名并未标出返回值故其返回默认的单元 () 类型 b. main 函数体内最后一个分号会返回一个单元 () 类型 c. main 函数体内非末行分号不会求值,仅作为连接符的存在(函数体内行分隔符使用分号来分隔) // Rust 将语法分为基本的语句和表达式,如此可将带分号的行代码都以看作是返回单元类型的值,这样的代码即是 语句(因为单元值本身并没有什么意义);语句又分为声明语句和表达式语句 // Rust 中除声明语句外,一切皆为表达式(包括流...
code_fim
hard
{ "lang": "rust", "repo": "jiyilanzhou/chw", "path": "/book/tao_video/3_expression.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jiyilanzhou/chw path: /book/tao_video/3_expression.rs /* 0. 表达式和语句 a. 声明语句 声明语言一些基本要素,如定义结构体、函数,引入模块、赋值等 b. 流程控制语句 如条件分支、循环语句等 c. 表达式语句 返回相应值 d. 宏语句 用于文本替换或者生成指定代码 1. Rust 语法骨架 a. 语法骨架(源代码) #![allow(unused)] use std::collectio...
code_fim
hard
{ "lang": "rust", "repo": "jiyilanzhou/chw", "path": "/book/tao_video/3_expression.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sugyan/leetcode path: /others/november-leetcoding-challenge/week-3/3538/lib.rs pub struct Solution {} impl Solution { pub fn at_most_n_given_digit_set(digits: Vec<String>, n: i32) -> i32 { let digits: Vec<char> = digits.iter().map(|s| s.chars().next().unwrap()).collect(); le...
code_fim
hard
{ "lang": "rust", "repo": "sugyan/leetcode", "path": "/others/november-leetcoding-challenge/week-3/3538/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( 29523, Solution::at_most_n_given_digit_set( vec![String::from("1"), String::from("4"), String::from("9")], 1_000_000_000 ) ); } #[test] fn example_3() { assert_eq!( 1, ...
code_fim
hard
{ "lang": "rust", "repo": "sugyan/leetcode", "path": "/others/november-leetcoding-challenge/week-3/3538/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>plate<'static> { LoginTemplate { ayp: "hey there :)" } }<|fim_prefix|>// repo: OnlySharks/Onlysharks-Frontend path: /src/routes/login.rs use askama::Template; #[derive(Template)] #[template(path <|fim_middle|>= "login.html")] pub struct LoginTemplate<'a> { pub ayp: &'a str } #[get("/login")] pu...
code_fim
medium
{ "lang": "rust", "repo": "OnlySharks/Onlysharks-Frontend", "path": "/src/routes/login.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OnlySharks/Onlysharks-Frontend path: /src/routes/login.rs use askama::Template; #[derive(Template)] #[template(path <|fim_suffix|>plate<'static> { LoginTemplate { ayp: "hey there :)" } }<|fim_middle|>= "login.html")] pub struct LoginTemplate<'a> { pub ayp: &'a str } #[get("/login")] pu...
code_fim
medium
{ "lang": "rust", "repo": "OnlySharks/Onlysharks-Frontend", "path": "/src/routes/login.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &'a str } #[get("/login")] pub fn login_page() -> LoginTemplate<'static> { LoginTemplate { ayp: "hey there :)" } }<|fim_prefix|>// repo: OnlySharks/Onlysharks-Frontend path: /src/routes/login.rs use askama::Template; #[derive(Template)] #[template(path <|fim_middle|>= "login.html")] pub struct Log...
code_fim
medium
{ "lang": "rust", "repo": "OnlySharks/Onlysharks-Frontend", "path": "/src/routes/login.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //let v = vec![1, 2, 3]; //v[99]; // Enable the backtrace with Powershell: // > $Env:RUST_BACKTRACE=1 }<|fim_prefix|>// repo: lorancou/rust-book-practice path: /ch09-01-unrecoverable-errors-with-panic/src/main.rs // Unrecoverable Errors with panic! // https://doc.rust-lang.org/book/ch09-...
code_fim
easy
{ "lang": "rust", "repo": "lorancou/rust-book-practice", "path": "/ch09-01-unrecoverable-errors-with-panic/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> // Enable the backtrace with Powershell: // > $Env:RUST_BACKTRACE=1 }<|fim_prefix|>// repo: lorancou/rust-book-practice path: /ch09-01-unrecoverable-errors-with-panic/src/main.rs // Unrecoverable Errors with panic! // https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html fn...
code_fim
medium
{ "lang": "rust", "repo": "lorancou/rust-book-practice", "path": "/ch09-01-unrecoverable-errors-with-panic/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lorancou/rust-book-practice path: /ch09-01-unrecoverable-errors-with-panic/src/main.rs // Unrecoverable Errors with panic! // https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html fn main() { <|fim_suffix|> // Enable the backtrace with Powershell: // > $Env:RUST_BAC...
code_fim
medium
{ "lang": "rust", "repo": "lorancou/rust-book-practice", "path": "/ch09-01-unrecoverable-errors-with-panic/src/main.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>#[bench] fn extrac_image_info(b: &mut Bencher) { b.iter(|| { let result = extractor::extract_img_info("images/JAM19896.jpg"); assert!(result.is_ok()) }) }<|fim_prefix|>// repo: hsqlu/imagextractor path: /src/benches/mod.rs extern crate test; use self::test::Bencher; use crate::ex...
code_fim
hard
{ "lang": "rust", "repo": "hsqlu/imagextractor", "path": "/src/benches/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hsqlu/imagextractor path: /src/benches/mod.rs extern crate test; use self::test::Bencher; use crate::extractor; #[bench] fn gen_filename(b: &mut Bencher) { <|fim_suffix|>#[bench] fn extrac_image_info(b: &mut Bencher) { b.iter(|| { let result = extractor::extract_img_info("images/JA...
code_fim
hard
{ "lang": "rust", "repo": "hsqlu/imagextractor", "path": "/src/benches/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> D::app().seq.expect_and_replace(1, 2); D::app().eg.wait(0b1, EventGroupWaitFlags::CLEAR).unwrap(); // start waiting, switching to `task0` D::app().seq.expect_and_replace(5, 6); // return the control to `task0` } fn task4_body<System: Kernel, D: Driver<App<System>>>(_: usize) { D::ap...
code_fim
hard
{ "lang": "rust", "repo": "newAM/r3", "path": "/src/r3_test_suite/src/kernel_tests/event_group_order_fifo.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: newAM/r3 path: /src/r3_test_suite/src/kernel_tests/event_group_order_fifo.rs //! Sets an event group, waking up multiple tasks in a FIFO order. //! //! 1. (`seq`: 0 → 1) `task0` activates `task[1-4]` in a particular order. //! 2. (`seq`: 1 → 5) `task[1-4]` start waiting for a event bit to be set...
code_fim
hard
{ "lang": "rust", "repo": "newAM/r3", "path": "/src/r3_test_suite/src/kernel_tests/event_group_order_fifo.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] pub fn it_works() { let a = 60000; println!("{:x?}", to_u8_slice(&a)); assert_eq!([0x60, 0xea, 0, 0], to_u8_slice(&a)); } }<|fim_prefix|>// repo: astrojhgu/controller_rs path: /src/utils.rs use std; use std::slice; pub fn to_u8_slice<T>(src: &T) -> &[u8] where...
code_fim
easy
{ "lang": "rust", "repo": "astrojhgu/controller_rs", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: astrojhgu/controller_rs path: /src/utils.rs use std; use std::slice; pub fn to_u8_slice<T>(src: &T) -> &[u8] where T: Sized, { let sz = std::mem::size_of::<T>(); unsafe { slice::from_raw_parts(src as *const T as *const u8, sz) } } <|fim_suffix|> #[test] pub fn it_works() { ...
code_fim
easy
{ "lang": "rust", "repo": "astrojhgu/controller_rs", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m-kann0/atcoder-rust path: /examples/abc157_d.rs use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let answer = solve(&buf); println!("{}", answer); } fn solve(input: &str) -> String { let mut iterator = input....
code_fim
hard
{ "lang": "rust", "repo": "m-kann0/atcoder-rust", "path": "/examples/abc157_d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emptyrivers/advent2019 path: /src/main.rs use std::env; // solutions mod tyranny; // Day 1 mod opcodes; // Day 2 mod wires; // Day 3 fn main() { println!("Advent Module Runner"); let args: Vec<String> = env::args().collect(); let nanos = match &args[1][..] { "1" => tyran...
code_fim
hard
{ "lang": "rust", "repo": "emptyrivers/advent2019", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }