text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>fn is_valid_2(n: u32) -> bool { let mut ds = math::digits(n); let mut count = 1; let mut prev = match ds.next() { Some(d) => d, None => return false, }; let mut has_duplicate = false; for d in ds { if d > prev { return false; } else if d ...
code_fim
hard
{ "lang": "rust", "repo": "ryanpbrewster/advent-of-code-2019", "path": "/days/day04/day04.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: project-ela/eir path: /src/emulator/execute.rs use std::cmp::min; use x86asm::instruction::{ mnemonic::{self, Mnemonic}, operand::{ immediate::Immediate, memory::{Displacement, Memory}, offset::Offset, register::{self, Register}, Operand, }, ...
code_fim
hard
{ "lang": "rust", "repo": "project-ela/eir", "path": "/src/emulator/execute.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use Flags::*; use Mnemonic::*; let flag = match mnemonic { Sete => self.cpu.get_flag(ZF), Setg => !self.cpu.get_flag(ZF) && self.cpu.get_flag(SF) == self.cpu.get_flag(OF), Setge => self.cpu.get_flag(SF) == self.cpu.get_flag(OF), Setl ...
code_fim
hard
{ "lang": "rust", "repo": "project-ela/eir", "path": "/src/emulator/execute.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn description(&self) -> &str { &self.message } fn cause(&self) -> Option<&dyn Error> { self.source() } } #[derive(Debug)] pub enum JqError { IoError(std::io::Error), ParserError(serde_json::Error), NonScalarValueError(ValueError) } impl From<std::io::Error> ...
code_fim
hard
{ "lang": "rust", "repo": "isabella232/prom_json_exporter", "path": "/src/jq.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isabella232/prom_json_exporter path: /src/jq.rs use std::error::Error; use std::fmt; use std::process::Stdio; use std::process::Output; use std::process::Command; use std::io::prelude::*; use crate::utils; #[derive(Clone)] pub struct Jq {} impl Jq { pub fn new() -> Result<Self, std::io::E...
code_fim
hard
{ "lang": "rust", "repo": "isabella232/prom_json_exporter", "path": "/src/jq.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>DI(r1,r1,i&0xfff)); vecs2.push(Insts::ADDI(r1,r1,i&0xfff)); }, Insts::LAL(r1,s)=>{ vecs.push(Insts::AUIPCL(r1,(&s).to_string())); vecs2.push(Insts::AUIPCL(r1,(&s).to_string())); vecs.push(Insts::ADDIL(r1,r1,(&s).to_string())); vecs2.push(Ins...
code_fim
hard
{ "lang": "rust", "repo": "mptommy/cpuex", "path": "/cpuex-simulator/ringo/src/inst.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mptommy/cpuex path: /cpuex-simulator/ringo/src/inst.rs op7_11:rd, op12_14:0b001, op15_19:r1, op20_24:r2, op25_31:0b0010000, optype:inst, ..Default::default() ...
code_fim
hard
{ "lang": "rust", "repo": "mptommy/cpuex", "path": "/cpuex-simulator/ringo/src/inst.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mptommy/cpuex path: /cpuex-simulator/ringo/src/inst.rs ..Default::default() } }, Insts::SLTU(r,r1,r2)=>{ Instruction{ op0_6:0b0110011, op7_11:r, op12_14:0b011, ...
code_fim
hard
{ "lang": "rust", "repo": "mptommy/cpuex", "path": "/cpuex-simulator/ringo/src/inst.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn flags(&self) -> &Box<ThreadedStore<FlagPath, Flag, Error = BannerError>> { &self.flag_store } pub fn paths(&self) -> &Box<ThreadedStore<String, FlagPath, Error = BannerError>> { &self.path_store } pub fn users(&self) -> &Box<ThreadedStore<String, User, Error = ...
code_fim
hard
{ "lang": "rust", "repo": "augustuswm/masquerade", "path": "/src/api/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: augustuswm/masquerade path: /src/api/state.rs use error::BannerError; use flag::{Flag, FlagPath}; use store::ThreadedStore; use user::User; pub type FlagStore = ThreadedStore<FlagPath, Flag, Error = BannerError>; pub type PathStore = ThreadedStore<String, FlagPath, Error = BannerError>; pub typ...
code_fim
hard
{ "lang": "rust", "repo": "augustuswm/masquerade", "path": "/src/api/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Auterion/px4-ulog-rs path: /src/unpack/mod.rs use std::io::{Error, ErrorKind, Result}; use std::iter::*; /// Convert a array of eight u8 elements into a u64 /// Assumes little endianness. /// /// # Examples /// ``` /// use px4_ulog::unpack; /// let arr: [u8; 8] = [7, 6, 5, 4, 3, 2, 1, 0]; /// a...
code_fim
hard
{ "lang": "rust", "repo": "Auterion/px4-ulog-rs", "path": "/src/unpack/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Convert a array of four u8 elements into a i32 /// Assumes little endianness. /// /// # Examples /// ``` /// use px4_ulog::unpack; /// let arr: [u8; 4] = [1, 0, 0, 255]; /// assert_eq!(unpack::as_i32_le(&arr), -16777215); /// ``` pub fn as_i32_le(arr: &[u8]) -> i32 { as_u32_le(arr) as i32 } /...
code_fim
hard
{ "lang": "rust", "repo": "Auterion/px4-ulog-rs", "path": "/src/unpack/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Convert a u8 slice to a string /// /// # Examples /// ``` /// use px4_ulog::unpack; /// let arr: [u8; 5] = [72, 101, 108, 108, 111]; /// assert_eq!(unpack::as_str(&arr).unwrap(), "Hello"); /// ``` pub fn as_str(arr: &[u8]) -> Result<&str> { std::str::from_utf8(arr).map_err(|_| Error::new(Error...
code_fim
hard
{ "lang": "rust", "repo": "Auterion/px4-ulog-rs", "path": "/src/unpack/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LiLiu88/buzz-rust path: /code/examples/direct_s3.rs use std::sync::Arc; use arrow_parquet::file::reader::{FileReader, Length, SerializedFileReader}; use buzz::clients::{s3, CachedFile, RangeCache}; <|fim_suffix|> let reader = SerializedFileReader::new(file).expect("Failed to create ...
code_fim
hard
{ "lang": "rust", "repo": "LiLiu88/buzz-rust", "path": "/code/examples/direct_s3.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let file = CachedFile::new(file_id, 461966527, Arc::new(cache), dler_id, dler_creator); // download footer let prefetch_size = 1024 * 1024; file.prefetch(file.len() - prefetch_size, prefetch_size as usize); let reader = SerializedFileReader::new(file).expect("Failed t...
code_fim
hard
{ "lang": "rust", "repo": "LiLiu88/buzz-rust", "path": "/code/examples/direct_s3.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (dler_id, dler_creator) = s3::downloader_creator("us-east-2"); let file_id = s3::file_id("ursa-labs-taxi-data", "2009/01/data.parquet"); let file = CachedFile::new(file_id, 461966527, Arc::new(cache), dler_id, dler_creator); // download footer let prefetch_size = 1024 * 1...
code_fim
hard
{ "lang": "rust", "repo": "LiLiu88/buzz-rust", "path": "/code/examples/direct_s3.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aeyakovenko/solana path: /sdk/program/src/loader_v4.rs //! The v3 built-in loader program. //! //! This is the loader of the program runtime v2. use crate::pubkey::Pubkey; <|fim_suffix|>/// Cooldown before a program can be un-/redeployed again pub const DEPLOYMENT_COOLDOWN_IN_SLOTS: u64 = 750;...
code_fim
medium
{ "lang": "rust", "repo": "aeyakovenko/solana", "path": "/sdk/program/src/loader_v4.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Cooldown before a program can be un-/redeployed again pub const DEPLOYMENT_COOLDOWN_IN_SLOTS: u64 = 750; /// LoaderV4 account states #[repr(C)] #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Copy, AbiExample)] pub struct LoaderV4State { /// Slot that the program was last initialize...
code_fim
medium
{ "lang": "rust", "repo": "aeyakovenko/solana", "path": "/sdk/program/src/loader_v4.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noshi91/n91lib_rs path: /src/algorithm/hafnian.rs /* References [1] Björklund, A. (2012, January). Counting perfect matchings as fast as Ryser. In Proceedings of the twenty-third annual ACM-SIAM symposium on Discrete Algorithms (pp. 914-921). Society for Industrial and Applied ...
code_fim
hard
{ "lang": "rust", "repo": "noshi91/n91lib_rs", "path": "/src/algorithm/hafnian.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> let x = b.pop().unwrap(); let y = b.pop().unwrap(); let zero = self.f(b.clone()); for (b, x) in zip(&mut b, &x) { for (b, y) in zip(b, &y) { *b += self.bound(x.clone() * y.clone() << 1); } } for (b, y) in zip(&mut b,...
code_fim
hard
{ "lang": "rust", "repo": "noshi91/n91lib_rs", "path": "/src/algorithm/hafnian.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(vec![0], generate_spinlock(3,0)); assert_eq!(vec![0,1], generate_spinlock(3,1)); assert_eq!(vec![0,2,1], generate_spinlock(3,2)); assert_eq!(vec![0,2,3,1], generate_spinlock(3,3)); assert_eq!(vec![0,2,4,3,1], generate_spinlock(3,4)); assert_eq!(ve...
code_fim
medium
{ "lang": "rust", "repo": "Keirua/advent2017", "path": "/d17/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Keirua/advent2017 path: /d17/src/lib.rs pub fn generate_spinlock(nb_iterations: usize, max_value: i32) -> Vec<i32> { let mut v:Vec<i32> = Vec::new(); v.push(0); let mut pos:usize = 0; for current_value in 1..max_value+1 { pos = (pos + nb_iterations) % v.len(); v.i...
code_fim
medium
{ "lang": "rust", "repo": "Keirua/advent2017", "path": "/d17/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/54_spiral_order.rs impl Solution { pub fn spiral_order(matrix: Vec<Vec<i32>>) -> Vec<i32> { spiral_order(matrix) } } <|fim_suffix|> if matrix.is_empty() { return vec![]; } let (m, n) = (matrix.len(), matrix[0].len()); ...
code_fim
medium
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/54_spiral_order.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if matrix.is_empty() { return vec![]; } let (m, n) = (matrix.len(), matrix[0].len()); let mut res = vec![]; let (mut l, mut r, mut t, mut b) = (0, n - 1, 0, m - 1); while l <= r && t <= b { for i in l..=r { res.push(matrix[t][i]); } t += ...
code_fim
medium
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/54_spiral_order.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: origel/origel path: /programs/coreutils/src/bin/echo.rs #![deny(warnings)] extern crate coreutils; extern crate extra; use std::env; use std::io::{stdout, stderr, Write}; use std::process::exit; use coreutils::ArgParser; use extra::option::OptionalExt; const MAN_PAGE: &'static str = /* @MANST...
code_fim
hard
{ "lang": "rust", "repo": "origel/origel", "path": "/programs/coreutils/src/bin/echo.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Print to standard output let mut first = true; for arg in parser.args.iter().map(|x| x.as_bytes()) { if first { first = false; } else if !(parser.found(&'s') || parser.found("no-spaces")) { stdout.write(&[b' ']).try(&mut stderr); } if ...
code_fim
hard
{ "lang": "rust", "repo": "origel/origel", "path": "/programs/coreutils/src/bin/echo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/3_length_of_longest_substring.rs use std::collections::HashMap; use std::cmp; struct Solution {} impl Solution { fn length_of_longest_substring(s: String) -> i32 { let mut map = HashMap::new(); let mut start = 0; let mut max =...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/3_length_of_longest_substring.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/* impl Solution { pub fn length_of_longest_substring(s: String) -> i32 { let mut seen = [-1; 128]; let mut start = 0; let mut max = 0; for (i, c) in s.bytes().enumerate() { let i = i as i32; let c = c as usize; let j = seen[c]; ...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/3_length_of_longest_substring.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self.globals.get(id) { Some(ty) => Ok(ty.clone().to_lvalue()), None => panic!("TestReduceContext::get_global"), } } fn get_constant( &self, _: &hir::ConstantBufferId, _: &str, ) -> Result<hir::ExpressionType, hir::TypeError>...
code_fim
hard
{ "lang": "rust", "repo": "Trark/slp", "path": "/src/transform/hst_to_hir/src/rel/rel_reduce.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tex_ty = Type::from_layout(hir::TypeLayout::Object(hir::ObjectType::RWTexture2D( dty.clone(), ))); let c = TestReduceContext::new() .global(tex_0, tex_ty.clone()) .global(tex_1, tex_ty.clone()); let rel = reduce(pel, &c); let expected_rel = Sequence { ...
code_fim
hard
{ "lang": "rust", "repo": "Trark/slp", "path": "/src/transform/hst_to_hir/src/rel/rel_reduce.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Trark/slp path: /src/transform/hst_to_hir/src/rel/rel_reduce.rs duce transform to turn pel expressions into rel expressions use super::rel::*; use crate::pel; use crate::typer::FunctionOverload; use slp_lang_hir as hir; #[cfg(test)] use slp_lang_hir::ToExpressionType; use slp_lang_hir::Type; #[...
code_fim
hard
{ "lang": "rust", "repo": "Trark/slp", "path": "/src/transform/hst_to_hir/src/rel/rel_reduce.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Melon-Tropics/quicktype path: /test/fixtures/rust/main.rs mod module_under_test; extern crate serde; #[macro_use] extern crate serde_derive; <|fim_suffix|> let result = serde_json::to_string(&top_level).unwrap(); println!("{}", &result); }<|fim_middle|>extern crate serde_jso...
code_fim
hard
{ "lang": "rust", "repo": "Melon-Tropics/quicktype", "path": "/test/fixtures/rust/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let result = serde_json::to_string(&top_level).unwrap(); println!("{}", &result); }<|fim_prefix|>// repo: Melon-Tropics/quicktype path: /test/fixtures/rust/main.rs mod module_under_test; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; use modu...
code_fim
hard
{ "lang": "rust", "repo": "Melon-Tropics/quicktype", "path": "/test/fixtures/rust/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iyonaga/project-euler-rust path: /src/bin/012.rs fn solve(divisors: u64) -> u64 { let mut answer: u64 = 0; for i in 2.. { let num: u64 = (1..i).sum(); if get_factors_total(num) > divisors { answer = num; break; } } answer } fn g...
code_fim
hard
{ "lang": "rust", "repo": "iyonaga/project-euler-rust", "path": "/src/bin/012.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(28, super::solve(5)); assert_eq!(76576500, super::solve(500)); } }<|fim_prefix|>// repo: iyonaga/project-euler-rust path: /src/bin/012.rs fn solve(divisors: u64) -> u64 { let mut answer: u64 = 0; for i in 2.. { let num: u64 = (1..i).sum(); if get_f...
code_fim
hard
{ "lang": "rust", "repo": "iyonaga/project-euler-rust", "path": "/src/bin/012.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>about not failing cases (not going to happen with user input...) if let Some(index) = multilingual.find('п') { println!("{:?}", &multilingual[index..]); } let could_default = match int_arg { 0..1 => "One" 2 => "Two", 3..5 => "Many", _ => "I can't count t...
code_fim
hard
{ "lang": "rust", "repo": "mark-jordanovic-lewis/learning_rust", "path": "/05_strings_1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mark-jordanovic-lewis/learning_rust path: /05_strings_1.rs fn main() { // std::env::args() returns an iterator over &str println!("Raw arguments are all strings, note the \"'s:"); for arg in std::env::args() { println!("{:?}", arg); } println!(""); // we can use s...
code_fim
hard
{ "lang": "rust", "repo": "mark-jordanovic-lewis/learning_rust", "path": "/05_strings_1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(Ok(val)) } } pub trait IntoParserIter: Sized { type Item; type Error; fn parse_iter<R: Read>(self, reader: R) -> ParserIter<R, Self> where ParserIter<R, Self>: Iterator<Item = Result<Self::Item, Self::Error>>; } impl<T> IntoParserIter for Option<T> where T: ...
code_fim
hard
{ "lang": "rust", "repo": "eira-fransham/wasm-reader", "path": "/wasm-reader-traits/src/iter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eira-fransham/wasm-reader path: /wasm-reader-traits/src/iter.rs use crate::Parser; use std::io::Read; pub struct ParserIter<R, P> { reader: R, parser: P, } impl<R, P> ParserIter<R, P> { pub fn new(reader: R, parser: P) -> Self { ParserIter { reader, parser } } } impl<R...
code_fim
hard
{ "lang": "rust", "repo": "eira-fransham/wasm-reader", "path": "/wasm-reader-traits/src/iter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> github_client .create_comment( issue_comment_payload.repository_full_name(), issue_comment_payload.issue_number(), body.to_string(), ) .unwrap(); } }<|fim_prefix|>// repo: kunicmarko20/lendabot path: /lendabot...
code_fim
hard
{ "lang": "rust", "repo": "kunicmarko20/lendabot", "path": "/lendabot-github/src/command/ping.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kunicmarko20/lendabot path: /lendabot-github/src/command/ping.rs use crate::payload::IssueCommentEventPayload; use lendabot::github::GithubClient; <|fim_suffix|> github_client .create_comment( issue_comment_payload.repository_full_name(), issue...
code_fim
hard
{ "lang": "rust", "repo": "kunicmarko20/lendabot", "path": "/lendabot-github/src/command/ping.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: osu-crypto/swanky path: /fancy-garbling/src/twopac/mod.rs // -*- mode: rust; -*- // // This file is part of t<|fim_suffix|>of two-party secure computation. pub mod semihonest;<|fim_middle|>wopac. // Copyright © 2019 Galois, Inc. // See LICENSE for licensing information. //! Implementations
code_fim
medium
{ "lang": "rust", "repo": "osu-crypto/swanky", "path": "/fancy-garbling/src/twopac/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>of two-party secure computation. pub mod semihonest;<|fim_prefix|>// repo: osu-crypto/swanky path: /fancy-garbling/src/twopac/mod.rs // -*- mode: rust; -*- // // This file is part of t<|fim_middle|>wopac. // Copyright © 2019 Galois, Inc. // See LICENSE for licensing information. //! Implementations
code_fim
medium
{ "lang": "rust", "repo": "osu-crypto/swanky", "path": "/fancy-garbling/src/twopac/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> CVault { context: Cell::new(vault), } } }<|fim_prefix|>// repo: nilslice/ockam path: /implementations/rust/vault/src/c/mod.rs use crate::error::VaultFailError; use crate::types::{PublicKey, SecretKey, SecretKeyAttributes, SecretKeyContext}; use c_bindings::*; use std::cell...
code_fim
easy
{ "lang": "rust", "repo": "nilslice/ockam", "path": "/implementations/rust/vault/src/c/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nilslice/ockam path: /implementations/rust/vault/src/c/mod.rs use crate::error::VaultFailError; use crate::types::{PublicKey, SecretKey, SecretKeyAttributes, SecretKeyContext}; use c_bindings::*; use std::cell::Cell; use zeroize::Zeroize; <|fim_suffix|> CVault { context: Cell...
code_fim
hard
{ "lang": "rust", "repo": "nilslice/ockam", "path": "/implementations/rust/vault/src/c/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>= document.get_element_by_id("game-of-life-canvas").unwrap(); let canvas: web_sys::HtmlCanvasElement = canvas.dyn_into::<HtmlCanvasElement>()?; let ctx: CanvasRenderingContext2d = canvas.get_context("2d")?.unwrap().dyn_into()?; Ok(ctx) }<|fim_prefix|>// repo: nlicitra/wasm-game-of-life path: /src/...
code_fim
medium
{ "lang": "rust", "repo": "nlicitra/wasm-game-of-life", "path": "/src/canvas.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|><HtmlCanvasElement>()?; let ctx: CanvasRenderingContext2d = canvas.get_context("2d")?.unwrap().dyn_into()?; Ok(ctx) }<|fim_prefix|>// repo: nlicitra/wasm-game-of-life path: /src/canvas.rs use wasm_bindgen::JsCast; use wasm_bindgen::JsValue; use web_sys::*; pub fn initialize_canvas_context() -> Resu...
code_fim
hard
{ "lang": "rust", "repo": "nlicitra/wasm-game-of-life", "path": "/src/canvas.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nlicitra/wasm-game-of-life path: /src/canvas.rs use wasm_bindgen::JsCast; use wasm_bindgen::JsValue; use web_sys::*; pub fn initialize_canvas_context() -> Result<CanvasR<|fim_suffix|><HtmlCanvasElement>()?; let ctx: CanvasRenderingContext2d = canvas.get_context("2d")?.unwrap().dyn_into()?; ...
code_fim
hard
{ "lang": "rust", "repo": "nlicitra/wasm-game-of-life", "path": "/src/canvas.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rossmacarthur/rephrase path: /gamepad/src/joycon.rs //! Nintendo Switch Pro controller. use crate::*; /// Convert the `Report` into Joycon specific bytes. pub fn into_input_report_bytes(report: Report) -> [u8; 13] { let Report { status: Status { buttons,...
code_fim
medium
{ "lang": "rust", "repo": "rossmacarthur/rephrase", "path": "/gamepad/src/joycon.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> buf[0] = 0x3f; buf[1] = counter.unwrap_or(0); buf[2] = 0x80 & 0x01; // high nibble battery, low nibble connection info // Digital buttons let bit_flags: [(usize, u8, Buttons); 14] = [ (3, 0x01, Buttons::WEST), (3, 0x02, Buttons::NORTH), (3, 0x04, Buttons::SOUTH...
code_fim
medium
{ "lang": "rust", "repo": "rossmacarthur/rephrase", "path": "/gamepad/src/joycon.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn to_json_impl(key: String, val: &'static str) -> Json { Json::String(format!("{}:{}", key, val)) }<|fim_prefix|>// repo: venkat299/harvest_rust path: /src/data/symbol_enum.rs use rustc_serialize::json::{ToJson, Json}; #[derive(Debug, RustcDecodable, RustcEncodable)] pub enum Symbol { YESBANK, ...
code_fim
medium
{ "lang": "rust", "repo": "venkat299/harvest_rust", "path": "/src/data/symbol_enum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: venkat299/harvest_rust path: /src/data/symbol_enum.rs use rustc_serialize::json::{ToJson, Json}; #[derive(Debug, RustcDecodable, RustcEncodable)] pub enum Symbol { YESBANK, SBIN, } impl Symbol { fn get_str(&self) -> &'static str { <|fim_suffix|>fn to_json_impl(key: String, val: &'st...
code_fim
hard
{ "lang": "rust", "repo": "venkat299/harvest_rust", "path": "/src/data/symbol_enum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> to_json_impl("product".to_string(), self.get_str()) } } fn to_json_impl(key: String, val: &'static str) -> Json { Json::String(format!("{}:{}", key, val)) }<|fim_prefix|>// repo: venkat299/harvest_rust path: /src/data/symbol_enum.rs use rustc_serialize::json::{ToJson, Json}; #[derive(De...
code_fim
medium
{ "lang": "rust", "repo": "venkat299/harvest_rust", "path": "/src/data/symbol_enum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yeliknewo/rs-polyclops path: /src/keyboard.rs use std::collections::{HashMap}; use glium::glutin::{ElementState, VirtualKeyCode}; <|fim_suffix|>impl Keyboard { pub fn new() -> Keyboard{ Keyboard{ keys: HashMap::new(), } } pub fn is_key_down(&self, key: V...
code_fim
medium
{ "lang": "rust", "repo": "yeliknewo/rs-polyclops", "path": "/src/keyboard.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_key_down(&self, key: VirtualKeyCode) -> ElementState { match self.keys.get(&key) { Some(down) => *down, None => ElementState::Released, } } pub fn set_key_state(&mut self, key: VirtualKeyCode, state: ElementState) { self.keys.insert(ke...
code_fim
medium
{ "lang": "rust", "repo": "yeliknewo/rs-polyclops", "path": "/src/keyboard.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Neurrone/rust-libaudioverse path: /src/nodes/properties/node_state_property.rs use super::super::super::libaudioverse_sys; use super::super::super::{Error, Result}; use check; use std::os::raw::c_int; /// used to indicate the state of a node. #[repr(i32)] pub enum NodeState { /// Th...
code_fim
hard
{ "lang": "rust", "repo": "Neurrone/rust-libaudioverse", "path": "/src/nodes/properties/node_state_property.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* pub fn always_play(&self) -> Result<()> { self.set_int(NodeState::AlwaysPlaying as i32) } pub fn play(&self) -> Result<()> { self.set_int(NodeState::Playing as i32) } pub fn pause(&self) -> Result<()> { self.set_int(NodeState::Paused a...
code_fim
hard
{ "lang": "rust", "repo": "Neurrone/rust-libaudioverse", "path": "/src/nodes/properties/node_state_property.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.buffer.clear(); write!(&mut self.buffer, "{}", self.properties.height).unwrap(); canvas_style.set_property("height", &self.buffer).unwrap(); } else { tracing::error!( "attempted to scale canvas #{} without a rendering context", ...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/differential-render", "path": "/src/timeline/canvas.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match message { CanvasMessage::Render(timestamp) => { if let Some(callback) = self.properties.render.as_deref() { tracing::trace!("rendering canvas #{}", self.properties.id); let context = self.context.as_ref().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/differential-render", "path": "/src/timeline/canvas.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kixiron/differential-render path: /src/timeline/canvas.rs use std::{ f64, fmt::{self, Debug, Write}, rc::Rc, }; use wasm_bindgen::JsCast; use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement}; use yew::{ html, services::{render::RenderTask, RenderService}, Component,...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/differential-render", "path": "/src/timeline/canvas.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[graphql_object()] impl Query { fn apiVersion() -> &str { "1.0" } // Arguments to resolvers can either be simple types or input objects. // To gain access to the context, we specify a argument // that is a reference to the Context type. // Juniper automatically injects the correct cont...
code_fim
hard
{ "lang": "rust", "repo": "bragaigor/graphql_server", "path": "/src/graphql_schema.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bragaigor/graphql_server path: /src/graphql_schema.rs #[warn(unused_variables)] #[allow(dead_code)] // use rocket::{response::content, State}; use juniper::{ graphql_object, EmptySubscription, FieldResult, GraphQLEnum, GraphQLInputObject, GraphQLObject, RootNode, EmptyMutation, }; use std...
code_fim
hard
{ "lang": "rust", "repo": "bragaigor/graphql_server", "path": "/src/graphql_schema.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// TODO: What is this? This is probably used to insert new elements into the Database #[derive(GraphQLInputObject)] #[graphql(description = "A humanoid creature in the Star Wars universe")] struct NewSuperHero { name: String, super_powers: Vec<Powers>, home_planet: String, } // To make our co...
code_fim
hard
{ "lang": "rust", "repo": "bragaigor/graphql_server", "path": "/src/graphql_schema.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rayrrr/rust-mp4ameta path: /src/tag.rs pub fn set_album_artist(&mut self, album_artist: impl Into<String>) { self.set_data(atom::ALBUM_ARTIST, Data::Utf8(album_artist.into())); } /// Removes the album artist (aART). pub fn remove_album_artist(&mut self) { self.remov...
code_fim
hard
{ "lang": "rust", "repo": "rayrrr/rust-mp4ameta", "path": "/src/tag.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.set_data(atom::TRACK_NUMBER, Data::Reserved(vec)); } /// Removes the track number and the total number of tracks (trkn). pub fn remove_track_number(&mut self) { self.remove_data(atom::TRACK_NUMBER); } /// Returns the disk number and total number of disks (disk). ...
code_fim
hard
{ "lang": "rust", "repo": "rayrrr/rust-mp4ameta", "path": "/src/tag.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rayrrr/rust-mp4ameta path: /src/tag.rs et_data(atom::COMPOSER, Data::Utf8(composer.into())); } /// Removes the composer (©wrt). pub fn remove_composer(&mut self) { self.remove_data(atom::COMMENT); } /// Returns the copyright (cprt). pub fn copyright(&self) -> Op...
code_fim
hard
{ "lang": "rust", "repo": "rayrrr/rust-mp4ameta", "path": "/src/tag.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ilumsden/rust-serialization-benchmark path: /src/main.rs mod record; mod types; mod data; mod result; use crate::record::Record; use crate::data::{STRING_COUNT, STRING_VALUE, INTEGERS}; use crate::result::TestResult; use std::env; use std::time::{Duration, Instant}; use avro_rs::{Writer, Reade...
code_fim
hard
{ "lang": "rust", "repo": "ilumsden/rust-serialization-benchmark", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = ron::ser::to_string(&rec).unwrap(); { let rec2 = ron::de::from_str(&buf).unwrap(); if rec != rec2 { panic!("Serde TOML failed to serialize and deserialize the record correctly."); }; } let start = Instant::now(); for _i in 0..iteratio...
code_fim
hard
{ "lang": "rust", "repo": "ilumsden/rust-serialization-benchmark", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut gen = DragonGenerator::new("10000"); gen.extend_up_to(20); assert_eq!("10000011110010000111", format!("{}", gen)); gen.checksum(); assert_eq!("01100", format!("{}", gen)); } #[test] fn my_input() { let mut gen = DragonGenerator::new("01111010110010011"); gen.exte...
code_fim
hard
{ "lang": "rust", "repo": "isabella232/advent-of-code-2016", "path": "/src/day_16.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isabella232/advent-of-code-2016 path: /src/day_16.rs #![allow(dead_code)] struct DragonGenerator { vec: Vec<bool>, } impl DragonGenerator { fn new(init: &str) -> DragonGenerator { Self { vec: init .chars() .map(|c| match c { '0' => false, '1' =>...
code_fim
hard
{ "lang": "rust", "repo": "isabella232/advent-of-code-2016", "path": "/src/day_16.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: InnPatron/smpl path: /smpli/src/builtins/vec.rs use failure::Error; use smpl::prelude::{UnparsedModule, parse_module}; use std::cell::RefCell; use std::rc::Rc; use crate::*; pub const MOD_VEC: &'static str = "vec"; pub const VEC_NEW: &'static str = "new"; pub const VEC_LEN: &'static str = "le...
code_fim
hard
{ "lang": "rust", "repo": "InnPatron/smpl", "path": "/smpli/src/builtins/vec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Value::Int(2), result); } #[test] fn interpreter_vec_get() { let mod1 = " mod mod1; use vec; fn test() -> int { let v = vec::new(type int)(); v = vec::push(type int)(v, 123); v = vec::push(type int)(v, 456); let a = vec::get_value(type int)(v, 0); let b = vec::get_value(type int)(v, ...
code_fim
hard
{ "lang": "rust", "repo": "InnPatron/smpl", "path": "/smpli/src/builtins/vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn test() -> int { let v = vec::new(type int)(); v = vec::push(type int)(v, 123); v = vec::push(type int)(v, 456); v = vec::push(type int)(v, 789); v = vec::remove(type int)(v, 1); return vec::get_value(type int)(v, 1); } "; let result = vec_test!(mod1, "mod1", "test", vec![]); assert_eq!(Valu...
code_fim
hard
{ "lang": "rust", "repo": "InnPatron/smpl", "path": "/smpli/src/builtins/vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-datetime/zoneinfo-data path: /src/data/Asia/Yakutsk.rs // ------ // This file is autogenerated! // Any changes you make may be overwritten. // ------ use std::borrow::Cow; use datetime::zone::{StaticTimeZone, FixedTimespanSet, FixedTimespan}; pub static ZONE: StaticTimeZone<'static> = S...
code_fim
hard
{ "lang": "rust", "repo": "rust-datetime/zoneinfo-data", "path": "/src/data/Asia/Yakutsk.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>-25T17:00:00.000 UTC offset: 32400, // UTC offset 32400, DST offset 0 is_dst: false, name: Cow::Borrowed("YAKT"), }), (1080406800, FixedTimespan { // 2004-03-27T17:00:00.000 UTC offset: 36000, // UTC offset 32400, DST offset 3600 ...
code_fim
hard
{ "lang": "rust", "repo": "rust-datetime/zoneinfo-data", "path": "/src/data/Asia/Yakutsk.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(value.to_string()) } } impl SerializeForInsert for i16 { fn serialize(_type: &Type, value: &i16) -> Result<String, Box<dyn Error + Sync + Send>> { Ok(value.to_string()) } } impl SerializeForInsert for i32 { fn serialize(_type: &Type, value: &i32) -> Result<String, Box<...
code_fim
hard
{ "lang": "rust", "repo": "alexchamberlain/pg_gensql", "path": "/src/serialize_for_insert.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexchamberlain/pg_gensql path: /src/serialize_for_insert.rs use std::error::Error; use std::fmt; use fallible_iterator::FallibleIterator; use itertools::{process_results, Itertools}; use postgres_protocol::escape::escape_literal; use tokio_postgres::types::{FromSql, Kind, Type}; use uuid::Uuid...
code_fim
hard
{ "lang": "rust", "repo": "alexchamberlain/pg_gensql", "path": "/src/serialize_for_insert.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JosephLing/liquid-rust path: /crates/core/src/model/scalar/datetime.rs use std::fmt; use std::ops; use chrono::TimeZone; use super::Date; /// The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59. pub type FixedOffset = chrono::FixedOffset; /// Liquid's native date + time type. ...
code_fim
hard
{ "lang": "rust", "repo": "JosephLing/liquid-rust", "path": "/crates/core/src/model/scalar/datetime.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>const DATE_TIME_FORMAT: &str = "%Y-%m-%d %H:%M:%S %z"; mod friendly_date_time { use super::*; use serde::{self, Deserialize, Deserializer, Serializer}; pub(crate) fn serialize<S>(date: &DateTimeImpl, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let...
code_fim
hard
{ "lang": "rust", "repo": "JosephLing/liquid-rust", "path": "/crates/core/src/model/scalar/datetime.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let triangle = super::SimpleTriangle { base: 42, height: 42, }; assert_eq!(triangle.get_area(), 882); } } #[cfg(test)] mod sides_triangle { #[test] fn get_semi_perimeter() { let triangle = super::SidesTriangle { side_a: 42.0...
code_fim
medium
{ "lang": "rust", "repo": "mateusfg7/GeoMath", "path": "/src/forms/triangle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mateusfg7/GeoMath path: /src/forms/triangle.rs pub struct SimpleTriangle { pub base: i32, pub height: i32, } impl SimpleTriangle { pub fn get_area(&self) -> i32 { (&self.base * &self.height) / 2 } } pub struct SidesTriangle { pub side_a: f32, pub side_b: f32, ...
code_fim
hard
{ "lang": "rust", "repo": "mateusfg7/GeoMath", "path": "/src/forms/triangle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(triangle.get_area(), 882); } } #[cfg(test)] mod sides_triangle { #[test] fn get_semi_perimeter() { let triangle = super::SidesTriangle { side_a: 42.0, side_b: 42.0, side_c: 42.0, }; assert_eq!(triangle.get_semi_pe...
code_fim
medium
{ "lang": "rust", "repo": "mateusfg7/GeoMath", "path": "/src/forms/triangle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn display_messages( &self, messages: &[Message], display_sms: bool, utc_time_zone: bool, ) -> Result<(), Box<dyn Error>> { let (_, columns) = self.term.size(); for msg in messages { let dt = if utc_time_zone { ...
code_fim
hard
{ "lang": "rust", "repo": "cpilatre/clinch", "path": "/src/display.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cpilatre/clinch path: /src/display.rs use crate::config::ServicesMap; use crate::domain::{Message, SinchData}; use chrono::Utc; use chrono::{DateTime, Local}; use console::{style, truncate_str, Term}; use std::error::Error; use std::str::FromStr; pub struct Display { term: Term, ...
code_fim
hard
{ "lang": "rust", "repo": "cpilatre/clinch", "path": "/src/display.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let file_dec = slog_term::PlainSyncDecorator::new(file); let file_drain = slog_term::FullFormat::new(file_dec).build().fuse(); let term_dec = slog_term::PlainSyncDecorator::new(std::io::stdout()); let term_drain = slog_term::FullFormat::new(term_dec).build().fuse(); let dupe_drain = ...
code_fim
hard
{ "lang": "rust", "repo": "Treevs/cratify", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn build_subscription_scheduler() -> JobScheduler<'static> { let mut sched = JobScheduler::new(); // Run every three hours let schedule = "0 0 0,3,6,9,12,15,18,21 * * * *"; sched.add(Job::new(schedule.parse().unwrap(), fulfill_subscriptions)); sched } fn fulfill_subscriptions() { ...
code_fim
hard
{ "lang": "rust", "repo": "Treevs/cratify", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Treevs/cratify path: /src/main.rs #![feature(custom_attribute)] #![feature(plugin)] #![plugin(rocket_codegen)] #![allow(proc_macro_derive_resolution_fallback)] #[macro_use] extern crate diesel_migrations; #[macro_use] extern crate diesel; #[macro_use] extern crate slog; #[macro_use] extern c...
code_fim
hard
{ "lang": "rust", "repo": "Treevs/cratify", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(process_cli_pattern("/test".to_string()), "/test"); assert_eq!(process_cli_pattern("C:/test".to_string()), "C:/test"); assert_eq!(process_cli_pattern("./test".to_string()), "./test"); assert_eq!(process_cli_pattern("test".to_string()), "./test"); assert_eq!(process_cli_patte...
code_fim
hard
{ "lang": "rust", "repo": "leaysgur/dprint", "path": "/crates/dprint/src/cli/patterns.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leaysgur/dprint path: /crates/dprint/src/cli/patterns.rs use std::path::{Path, PathBuf}; use dprint_cli_core::types::ErrBox; use crate::environment::Environment; use crate::utils::{is_absolute_pattern, is_negated_glob, GlobMatcher, GlobMatcherOptions, GlobPattern, GlobPatterns}; use super::co...
code_fim
hard
{ "lang": "rust", "repo": "leaysgur/dprint", "path": "/crates/dprint/src/cli/patterns.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> file_patterns.into_iter().map(|pattern| process_config_pattern(pattern)).collect() } fn process_config_pattern(file_pattern: String) -> String { // make config patterns that start with `/` be relative if file_pattern.starts_with("/") { format!(".{}", file_pattern) } else if file_pattern.start...
code_fim
hard
{ "lang": "rust", "repo": "leaysgur/dprint", "path": "/crates/dprint/src/cli/patterns.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pitust/liboh path: /src/prelude.rs pub use alloc::{ borrow, boxed::Box, collections, collections::*, collections::*, fmt, format, slice, stri<|fim_suffix|> core::sync::atomic::*; pub use crate::{main, println};<|fim_middle|>ng::*, vec, vec::Vec, prelude::v1::* }; pub use
code_fim
easy
{ "lang": "rust", "repo": "pitust/liboh", "path": "/src/prelude.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> core::sync::atomic::*; pub use crate::{main, println};<|fim_prefix|>// repo: pitust/liboh path: /src/prelude.rs pub use alloc::{ borrow, boxed::Box, collections, collections::*, collections::*, fmt, format, slice, stri<|fim_middle|>ng::*, vec, vec::Vec, prelude::v1::* }; pub use
code_fim
easy
{ "lang": "rust", "repo": "pitust/liboh", "path": "/src/prelude.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pitust/liboh path: /src/prelude.rs pub use alloc::{ borrow, boxed::Box, collections, c<|fim_suffix|>ng::*, vec, vec::Vec, prelude::v1::* }; pub use core::sync::atomic::*; pub use crate::{main, println};<|fim_middle|>ollections::*, collections::*, fmt, format, slice, stri
code_fim
easy
{ "lang": "rust", "repo": "pitust/liboh", "path": "/src/prelude.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>const BITSET_INTERNAL_SIZE: usize = std::mem::size_of::<u8>() * 8; const BITSET_SIZE: usize = 1 + FIELDS_NB / BITSET_INTERNAL_SIZE; struct SimpleBitSet { bits: [u8; BITSET_SIZE], } impl SimpleBitSet { const fn init(n: usize) -> Self { let leftover_bits = n % BITSET_INTERNAL_SIZE; ...
code_fim
hard
{ "lang": "rust", "repo": "SilvestrePerret/adventofcode-2020", "path": "/day-04/part-1/enizor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SilvestrePerret/adventofcode-2020 path: /day-04/part-1/enizor.rs use std::env::args; use std::time::Instant; fn main() { let now = Instant::now(); let output = run(&args().nth(1).expect("Please provide an input")); let elapsed = now.elapsed(); println!("_duration:{}", elapsed.as_...
code_fim
hard
{ "lang": "rust", "repo": "SilvestrePerret/adventofcode-2020", "path": "/day-04/part-1/enizor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.current_token.kind == TokenKind::PuncComma { self.expect_and_eat_tok(TokenKind::PuncComma); } else if self.current_token.kind != TokenKind::PuncCloseParen { self.emit_err_at_current_tok(format!( "Expected {} or {} token af...
code_fim
hard
{ "lang": "rust", "repo": "lukechu10/owllang-compiler", "path": "/owlc-parser/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let res = parser.parse_statement(); let mut errors = ErrorReporter::new(source.clone()); errors.merge_from(&lexer_error_reporter); errors.merge_from(&parser_error_reporter); assert!(!errors.has_errors()); res } /// Utility function for tests fn...
code_fim
hard
{ "lang": "rust", "repo": "lukechu10/owllang-compiler", "path": "/owlc-parser/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lukechu10/owllang-compiler path: /owlc-parser/src/parser.rs ut ErrorReporter) -> Self { let first_token = lexer.next().unwrap_or(Token { kind: TokenKind::EndOfFile, span: BytePos(0).to(BytePos(1)), }); Self { src: Rc::clone(&lexer.src)...
code_fim
hard
{ "lang": "rust", "repo": "lukechu10/owllang-compiler", "path": "/owlc-parser/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: notryanb/scrap_iron path: /src/main.rs use std::io::{Read, Write, BufReader, BufRead}; use std::net::{TcpListener, TcpStream}; use std::thread; use std::path::Path; use std::env; use std::fs::File; fn main() { <|fim_suffix|> for line in reader.by_ref().lines() { if line.unwrap() == "...
code_fim
hard
{ "lang": "rust", "repo": "notryanb/scrap_iron", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn send_response(mut stream: TcpStream) { let mut f = File::open("public/index.html").unwrap(); let mut response = String::new(); f.read_to_string(&mut response); stream.write(response.as_bytes()).unwrap(); }<|fim_prefix|>// repo: notryanb/scrap_iron path: /src/main.rs use std::io::{Rea...
code_fim
medium
{ "lang": "rust", "repo": "notryanb/scrap_iron", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }