text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: rodrigocfd/winsafe path: /src/user/handles/mod.rs mod haccel; mod hcursor; mod hdc; mod hdesk; mod hdwp; mod hhook; mod hicon; mod hinstance; mod hmenu; mod hmonitor; mod hprocess; mod hwnd; <|fim_suffix|>pub mod traits { pub use super::haccel::user_Haccel; pub use super::hcurs...
code_fim
hard
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/user/handles/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: soarlab/gelpia path: /src/gelpia_utils/src/lib.rs /* Basic interval implementation and other common functions/data structures */ // External libraries use std::cmp::{PartialOrd, Ordering, PartialEq, Ord}; use std::f64::{NEG_INFINITY, INFINITY}; // Internal libraries extern crate gr; use gr::G...
code_fim
hard
{ "lang": "rust", "repo": "soarlab/gelpia", "path": "/src/gelpia_utils/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..x.len() { let d_i = dfx[i]; let x_i = x[i]; let x_0_i = x_0[i]; if (x_i.lower() - x_0_i.lower()).abs() < 0.001 || (x_i.upper() - x_0_i.upper()).abs() < 0.001 { return false; } if d_i.lower() <= 0.0 && d_i.upper() >= 0.0 { ...
code_fim
hard
{ "lang": "rust", "repo": "soarlab/gelpia", "path": "/src/gelpia_utils/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.pf < other.pf { return Ordering::Greater; } else if self.pf == other.pf { if self.p > other.p { return Ordering::Greater; } else if self.p == other.p { return Ordering::Equal; } ...
code_fim
hard
{ "lang": "rust", "repo": "soarlab/gelpia", "path": "/src/gelpia_utils/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: automerge/automerge path: /rust/automerge/src/parents.rs use crate::op_set; use crate::op_set::OpSet; use crate::types::ObjId; use crate::{clock::Clock, exid::ExId, Prop}; /// An iterator over the "parents" of an object /// /// The "parent" of an object in this context is the ([`ExId`], [`Prop`...
code_fim
hard
{ "lang": "rust", "repo": "automerge/automerge", "path": "/rust/automerge/src/parents.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// A component of a path to an object #[derive(Debug, PartialEq, Eq)] pub struct Parent { /// The object ID this component refers to pub obj: ExId, /// The property within `obj` this component refers to pub prop: Prop, /// Whether this component is "visible" /// /// An "invisi...
code_fim
hard
{ "lang": "rust", "repo": "automerge/automerge", "path": "/rust/automerge/src/parents.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn one_bit_adder() { for (inn, out) in half_adder_input_output() { let (a, b) = inn; assert_eq!(half_adder(a, b), out); } }<|fim_prefix|>// repo: PacktPublishing/The-Complete-Rust-Programming-Reference-Guide path: /Chapter03/logic_gates/tests/half_adder.rs // logic_gates/t...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/The-Complete-Rust-Programming-Reference-Guide", "path": "/Chapter03/logic_gates/tests/half_adder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PacktPublishing/The-Complete-Rust-Programming-Reference-Guide path: /Chapter03/logic_gates/tests/half_adder.rs // logic_gates/tests/half_adder.rs use logic_gates::{and, xor}; pub type Sum = u8; pub type Carry = u8; pub fn half_adder_input_output() -> Vec<((u8, u8), (Sum, Carry))> { vec![...
code_fim
medium
{ "lang": "rust", "repo": "PacktPublishing/The-Complete-Rust-Programming-Reference-Guide", "path": "/Chapter03/logic_gates/tests/half_adder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /src/recovery/system/src/setup.rs // Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use anyhow::{anyhow, Context, Error}; use futures::channel::mpsc; use roui...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/recovery/system/src/setup.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_ota_json(request: &Request) -> Result<DevhostConfig, Error> { let mut host_addr = request.remote_addr().ip().to_string(); if request.remote_addr().is_ipv6() { host_addr = format!("[{}]", host_addr); } let mut body = request.data().ok_or(anyhow!("Post body already read?"))?...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/recovery/system/src/setup.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_control_register() { let control_reg = ControlRegister::from(0x00000078); assert!(control_reg.write_buffer() == 1); assert!(control_reg.exception_handling() == 1); assert!(control_reg._26bit_address_faults() == 1); assert!(control_reg.abort_model() == 1); }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "devins2518/Chaaya", "path": "/aakil/src/arm9/coprocessor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: devins2518/Chaaya path: /aakil/src/arm9/coprocessor.rs use crate::utils::{Endianness, Register}; use modular_bitfield::prelude::*; pub(super) struct Cp15 { main_id_reg: Register, cache_type_reg: Register, tcm_size_reg: Register, control_reg: ControlRegister, // ?????? i have...
code_fim
hard
{ "lang": "rust", "repo": "devins2518/Chaaya", "path": "/aakil/src/arm9/coprocessor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", arr); } } impl<T: Float> Hook<T> for ShowPrefixed { fn call(&self, arr: &crate::ndarray_ext::NdArrayView<T>) { println!("{} {:?}", self.0, arr); } } impl<T: Float> Hook<T> for ShowShape { fn call(&self, arr: &crate::ndarray_ext::NdArrayView<T>) { ...
code_fim
hard
{ "lang": "rust", "repo": "raskr/rust-autograd", "path": "/src/hooks.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raskr/rust-autograd path: /src/hooks.rs //! You can register hooks on `ag::Tensor` objects for debugging. //! ```rust //! use autograd as ag; //! use ag::tensor_ops as T; //! //! ag::run(|ctx| { //! let a: ag::Tensor<f32> = T::zeros(&[4, 2], ctx).show(); //! let b: ag::Tensor<f32> = T::one...
code_fim
hard
{ "lang": "rust", "repo": "raskr/rust-autograd", "path": "/src/hooks.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>()); } else { buffer.push(c); } }); String::from_iter(buffer) }<|fim_prefix|>// repo: abhijat/bonfire path: /src/utils.rs use std::iter::FromIterator; pub fn snakeify(s: &str) -> String { let mut buffer: Vec<char> = <|fim_middle|>Vec::new(); s.chars().for_eac...
code_fim
medium
{ "lang": "rust", "repo": "abhijat/bonfire", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abhijat/bonfire path: /src/utils.rs use std::iter::FromIterator; pub fn snakeify(s: &str) -> String { let mut buffer: Vec<char> = <|fim_suffix|>()); } else { buffer.push(c); } }); String::from_iter(buffer) }<|fim_middle|>Vec::new(); s.chars().for_eac...
code_fim
medium
{ "lang": "rust", "repo": "abhijat/bonfire", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let a = vec4!(1.2, ..); assert_eq!(a.x, 1.2); assert_eq!(a.y, 0.0); assert_eq!(a.z, 0.0); assert_eq!(a.w, 0.0); let a = vec4!(1, 2, ..); assert_eq!(a.x, 1); assert_eq!(a.y, 2); assert_eq!(a.z, 0); assert_eq!(a.w, 0); let a = vec4!(1.2); assert_eq!(a.x, 1.2);...
code_fim
hard
{ "lang": "rust", "repo": "dopitz/vulkanism", "path": "/nobs-vkmath/src/vec4.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dopitz/vulkanism path: /nobs-vkmath/src/vec4.rs use crate::common_traits::*; use crate::vec2::Vec2; use crate::vec3::Vec3; #[repr(C)] #[derive(Default, Clone, Copy, Debug)] pub struct Vec4<T> { pub x: T, pub y: T, pub z: T, pub w: T, } // Constructors impl<T: Copy> Vec4<T> { pub fn r...
code_fim
hard
{ "lang": "rust", "repo": "dopitz/vulkanism", "path": "/nobs-vkmath/src/vec4.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rnhall/rust-bio path: /src/data_structures/kmer.rs //Declares a structure with a variable length encoding scheme. Memory is allocated //for each 4 nucleotides as a single u8 in a vector of u8 values. use std::fmt; use std::ops::BitXor; use std::ops::Not; //Should I include mutable kmers and im...
code_fim
hard
{ "lang": "rust", "repo": "rnhall/rust-bio", "path": "/src/data_structures/kmer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl IntoIterator for Kmer { type Item = u8; type IntoIter = KmerIter; fn into_iter(self) -> Self::IntoIter { KmerIter { kmer: self, position: 0, nucleotide: 0, } } } //BITWISE IMPLEMENTATIONS impl BitXor for Kmer { type Output = Se...
code_fim
hard
{ "lang": "rust", "repo": "rnhall/rust-bio", "path": "/src/data_structures/kmer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jerald/yoloxide path: /src/parser.rs Stat::Assignment(value, Op::AddAssign, parse_expression(window)?) }, (Some(ident @ Token::Identifier(_)), Some(Token::Minus), Some(Token::Equal)) => { let value = Value::from(ident.clone()); window.move_view...
code_fim
hard
{ "lang": "rust", "repo": "Jerald/yoloxide", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _ => return Ok(left) }; window.move_view(2); match expr_order(window) { Ok(right) => { // Found a right hand side for our rule, so construct the object let expr = Expr::BinaryOp(op, Box::new(left), Box::new(right)); extend_equal...
code_fim
hard
{ "lang": "rust", "repo": "Jerald/yoloxide", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { println!("\n------ binding_test() ------"); binding_test(); }<|fim_prefix|>// repo: terzeron/rust_test path: /flow_control/matching/binding/src/main.rs fn binding_test() { fn age() -> u32 { 15 } <|fim_middle|> println!("Tell me type of person you are"); match a...
code_fim
hard
{ "lang": "rust", "repo": "terzeron/rust_test", "path": "/flow_control/matching/binding/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: terzeron/rust_test path: /flow_control/matching/binding/src/main.rs fn binding_test() { fn age() -> u32 { 15 } println!("Tell me type of person you are"); match age() { 0 => println!("I'm not born yet I guess"), // @를 이용하여 값을 변수에 바인딩함 n @ 1...12 =...
code_fim
easy
{ "lang": "rust", "repo": "terzeron/rust_test", "path": "/flow_control/matching/binding/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitchmindtree/ecml path: /src/gp/expr.rs //! Items related to expressions. use fnv::{FnvHashMap, FnvHashSet}; use petgraph::{self, Incoming, Outgoing}; use petgraph::visit::{Dfs, EdgeRef, Topo}; use rand::Rng; use std::mem; /// A node/expression type that can be evaluated to a single value. pu...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/ecml", "path": "/src/gp/expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Generate the final depth of nodes. for a in curr.drain(..) { for _ in 0..g[a].arity() { let b = g.add_node(Terminal::generate(rng)); g.add_edge(b, a, ()); } } g } /// Generate an expression tree using the ...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/ecml", "path": "/src/gp/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamesmunns/slack-rs-api path: /src/channels.rs ut params = HashMap::new(); params.insert("name", name); let response = try!(client.send_authed("channels.create", token, params)); parse_slack_response(response, true) } #[derive(Clone,Debug,RustcDecodable)] pub struct CreateResponse {...
code_fim
hard
{ "lang": "rust", "repo": "jamesmunns/slack-rs-api", "path": "/src/channels.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let client = MockSlackWebRequestSender::respond_with(r#"{"ok": true}"#); let result = kick(&client, "TEST_TOKEN", "TEST_CHANNEL", "U12345678"); if let Err(err) = result { panic!(format!("{:?}", err)); } } #[test] fn leave_ok_response() { let...
code_fim
hard
{ "lang": "rust", "repo": "jamesmunns/slack-rs-api", "path": "/src/channels.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0781_rabbits_in_forest/mod.rs pub mod buckets; pub trait Solution { fn num_rabbits(answers: Vec<i32>) -> i32; } #[cfg(test)] mod tests { use super::Solution; <|fim_suffix|> for (answers, expected) in test_cases { assert_eq!(S::num_...
code_fim
medium
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0781_rabbits_in_forest/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (answers, expected) in test_cases { assert_eq!(S::num_rabbits(answers.to_vec()), expected); } } }<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0781_rabbits_in_forest/mod.rs pub mod buckets; pub trait Solution { fn num_rabbits(answers: Vec<i32>) -> i32;...
code_fim
medium
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0781_rabbits_in_forest/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mafik/looper path: /src/lib.rs //! Clean abstraction for a single-threaded event loop. Built as a lightweight wrapper around the `std::sync::mpsc` package. //! //! # Example usage: //! //! ```rust //! use mrogalski_looper::{Handler, Sender, run}; //! //! struct ExampleHandler { //! data: Vec...
code_fim
medium
{ "lang": "rust", "repo": "mafik/looper", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Runs the event loop on the current thread. pub fn run<EVENT: Send, HANDLER: Handler<EVENT>>(mut handler: HANDLER) { let (tx, rx) = std::sync::mpsc::channel(); handler.start(tx); let mut running = true; while running { running = match rx.recv() { Ok(event) => handler...
code_fim
medium
{ "lang": "rust", "repo": "mafik/looper", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> rule i(literal: &'static str) -> &'input str = input:quiet!{$([_]*<{literal.chars().count()}>)} {? if crate::util::eq_ignore_case(input, literal) { Ok(input) } else { Err(literal) } } rule iden...
code_fim
hard
{ "lang": "rust", "repo": "csnover/earthquake-rust", "path": "/libearthquake/src/lingo/compiler/lexer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> rule ident_first_char() = quiet!{[c if is_ident(c) && !is_digit(c)]} / expected!("<ident>"); rule ident_char() = quiet!{[c if is_ident(c)]} / expected!("<ident>"); rule digit() = quiet!{[c if is_digit(c)]} / ...
code_fim
hard
{ "lang": "rust", "repo": "csnover/earthquake-rust", "path": "/libearthquake/src/lingo/compiler/lexer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: csnover/earthquake-rust path: /libearthquake/src/lingo/compiler/lexer.rs //! Lingo source code lexer. use super::{Error, Result}; use crate::{ lingo::{prelude::*, symbol::VmSymbolTable}, util::{char_attrs, char_fold, CharAttrs}, }; use peg::{Parse, ParseElem, ParseSlice, RuleResult}; #...
code_fim
hard
{ "lang": "rust", "repo": "csnover/earthquake-rust", "path": "/libearthquake/src/lingo/compiler/lexer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/rustybuzz path: /src/ot/contextual.rs use ttf_parser::parser::{LazyArray16, Offset}; use crate::tables::gsubgpos::*; use super::MAX_CONTEXT_LENGTH; use super::apply::{Apply, ApplyContext, WouldApply, WouldApplyContext}; use super::matching::{ match_backtrack, match_class, match_cove...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rustybuzz", "path": "/src/ot/contextual.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let idx = usize::from(record.sequence_index); if idx >= count { continue; } // Don't recurse to ourself at same position. // Note that this test is too naive, it doesn't catch longer loops. if idx == 0 && record.lookup_index == ctx.lookup_index ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rustybuzz", "path": "/src/ot/contextual.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let chunks = ((days as f64) / 180.0).ceil() as i64; let ranges: Vec<[NaiveDate; 2]> = (0..chunks).into_iter().map(|chunk_idx| { [posted_after + chrono::Duration::days(chunk_idx * 180), std::cmp::min(posted_before, posted_after + chrono::Duration::days((chunk_idx + 1) * 180))] })....
code_fim
hard
{ "lang": "rust", "repo": "fluxxu/mws-rs", "path": "/mws-cli/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fluxxu/mws-rs path: /mws-cli/src/main.rs extern crate mws; use chrono::offset::TimeZone; use chrono::{DateTime, NaiveDate, Utc}; use std::path::PathBuf; use structopt::StructOpt; use mws::client::{Client, Method}; mod env; use self::env::Env; #[derive(Debug, StructOpt)] #[structopt(name = "m...
code_fim
hard
{ "lang": "rust", "repo": "fluxxu/mws-rs", "path": "/mws-cli/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let duration = posted_before - posted_after; let days = duration.num_days(); if days < 0 { panic!("invalid date range") } let chunks = ((days as f64) / 180.0).ceil() as i64; let ranges: Vec<[NaiveDate; 2]> = (0..chunks).into_iter().map(|chunk_idx| { [p...
code_fim
hard
{ "lang": "rust", "repo": "fluxxu/mws-rs", "path": "/mws-cli/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn shift_lookahead(&mut self) -> Token { let x = Token::new(Tag::Error, TokenInfo::NoInfo); let out = std::mem::replace(&mut self.lookahead, x); self.lookahead = self.scanner.scan(); out } }<|fim_prefix|>// repo: AntonioCarta/dragon_compiler path: /src/parser.r...
code_fim
hard
{ "lang": "rust", "repo": "AntonioCarta/dragon_compiler", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl Parser { pub fn new(mut scanner : Scanner) -> Self { Parser { lookahead : scanner.scan(), scanner : scanner, ast_root : None, } } pub fn parse(&mut self) { self.ast_root = Some(Program::parse(self)); } pub fn g...
code_fim
medium
{ "lang": "rust", "repo": "AntonioCarta/dragon_compiler", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AntonioCarta/dragon_compiler path: /src/parser.rs /* Parser for imperative language. */ use lexer::{Scanner, Token, Tag, TokenInfo}; use ast::statement::Program; use std; <|fim_suffix|> impl Parser { pub fn new(mut scanner : Scanner) -> Self { Parser { lookahead : sc...
code_fim
medium
{ "lang": "rust", "repo": "AntonioCarta/dragon_compiler", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Amjad50/CHIP-8 path: /src/system/memory.rs use std::fs::File; use std::io::{Read}; pub struct Memory { memory: [u8; 0x1000], // 4095 byte memory // user programs should only use memory from 0x200 } impl Memory { pub fn new() -> Memory { let mut mem = [...
code_fim
hard
{ "lang": "rust", "repo": "Amjad50/CHIP-8", "path": "/src/system/memory.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Memory { memory: mem } } pub fn read_file(&mut self, file: &mut File) { file.read(&mut self.memory[0x200..]).unwrap(); } pub fn store(&mut self, addr: u16, value: u8) { assert_eq!(addr < 0x1000, true); self.memory[addr as usize] = value; } pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "Amjad50/CHIP-8", "path": "/src/system/memory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn jump_to(addr: *mut u8) -> ! { unsafe { asm!("br $0" : : "r"(addr as usize)); loop { asm!("nop" :::: "volatile") } } } #[no_mangle] pub unsafe extern "C" fn kmain() { // Turn on the light 1 second to show that the Pi is ready. // Then turn off the light. let mut gpi...
code_fim
medium
{ "lang": "rust", "repo": "foTok/swiftOS", "path": "/boot_loader/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foTok/swiftOS path: /boot_loader/src/lib.rs #![allow(clippy::all)] #![feature(asm)] #![no_builtins] #![feature(optin_builtin_traits)] #![no_std] use core::result::Result::{Ok, Err}; use pi::timer; use pi::uart; use pi::gpio; use std::mem; use std::xmodem::Xmodem; <|fim_suffix|>fn jump_to(addr:...
code_fim
medium
{ "lang": "rust", "repo": "foTok/swiftOS", "path": "/boot_loader/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lichen-liu/dv-in-rust path: /o2versioner/src/util/tests_helper.rs //! Testing related helper functions use super::tcp; use futures::prelude::*; use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::panic::{RefUnwindSafe, UnwindSafe}; use tokio::io::AsyncBufReadExt; use tokio::io::A...
code_fim
hard
{ "lang": "rust", "repo": "lichen-liu/dv-in-rust", "path": "/o2versioner/src/util/tests_helper.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tokio::io::copy(&mut reader, &mut writer) .then(move |result| { match result { Ok(amt) => trace!("-> ECHOED {} BYTES", amt), Err(e) => error!("-> ERROR ON ECHOING: {}", e), }; ...
code_fim
hard
{ "lang": "rust", "repo": "lichen-liu/dv-in-rust", "path": "/o2versioner/src/util/tests_helper.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dylanmckay/minecraft path: /src/protocol/packet/types/handshake.rs use protocol::types::*; pub const STATE_STATUS: VarInt = VarInt(1); pub const STATE_LOGIN: VarInt = VarInt(2); <|fim_suffix|>define_packet!(0x07 => Statistics; [ statistics: Array<Statistic> ]);<|fim_middle|>define_packet!(...
code_fim
hard
{ "lang": "rust", "repo": "dylanmckay/minecraft", "path": "/src/protocol/packet/types/handshake.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>define_packet!(0x07 => Statistics; [ statistics: Array<Statistic> ]);<|fim_prefix|>// repo: dylanmckay/minecraft path: /src/protocol/packet/types/handshake.rs use protocol::types::*; pub const STATE_STATUS: VarInt = VarInt(1); pub const STATE_LOGIN: VarInt = VarInt(2); <|fim_middle|>define_packet!(...
code_fim
hard
{ "lang": "rust", "repo": "dylanmckay/minecraft", "path": "/src/protocol/packet/types/handshake.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gvvynplaine/bottom path: /src/canvas/canvas_colours.rs use crate::{constants::*, options::ConfigColours, utils::error}; use anyhow::Context; use colour_utils::*; use tui::style::{Color, Style}; mod colour_utils; pub struct CanvasColours { pub currently_selected_text_colour: Color, pub c...
code_fim
hard
{ "lang": "rust", "repo": "gvvynplaine/bottom", "path": "/src/canvas/canvas_colours.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_cpu_colours(&mut self, colours: &[String]) -> error::Result<()> { let max_amount = std::cmp::min(colours.len(), NUM_COLOURS); for (itx, colour) in colours.iter().enumerate() { if itx >= max_amount { break; } self.cpu_colour...
code_fim
hard
{ "lang": "rust", "repo": "gvvynplaine/bottom", "path": "/src/canvas/canvas_colours.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_all_cpu_colour(&mut self, colour: &str) -> error::Result<()> { self.all_colour_style = get_style_from_config(colour)?; Ok(()) } pub fn set_cpu_colours(&mut self, colours: &[String]) -> error::Result<()> { let max_amount = std::cmp::min(colours.len(), NUM_COL...
code_fim
hard
{ "lang": "rust", "repo": "gvvynplaine/bottom", "path": "/src/canvas/canvas_colours.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ezracelli/google-api-rust-client path: /crates/accessapproval/v1/src/lib.rs er( default = "{ ::std::default::Default::default() }", setter(into) )] #[serde(rename = "filter")] ...
code_fim
hard
{ "lang": "rust", "repo": "ezracelli/google-api-rust-client", "path": "/crates/accessapproval/v1/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[serde(skip_serializing_if = "::std::option::Option::is_none")] #[doc = "More detail about certain reason types. See comments for each type above."] pub detail: ::std::option::Option<::std::string::String>, #[builder(default = "{ ::std::default::Default::default() }", sette...
code_fim
hard
{ "lang": "rust", "repo": "ezracelli/google-api-rust-client", "path": "/crates/accessapproval/v1/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ezracelli/google-api-rust-client path: /crates/accessapproval/v1/src/lib.rs bug, PartialEq, derive_builder :: Builder, serde :: Serialize, serde :: Deserialize, )] pub struct QueryPara...
code_fim
hard
{ "lang": "rust", "repo": "ezracelli/google-api-rust-client", "path": "/crates/accessapproval/v1/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut protocol_engine: ProtocolEngine<EchoClient> = mai::protocol_engine(EchoClientHandler) .with(InitialBufferSize(Kilobytes(32))) .with(InitialBufferPoolSize(16)) .with(MaxBufferPoolSize(128)) .build(); let token = protocol_engine.manage(stream); let _ = pro...
code_fim
hard
{ "lang": "rust", "repo": "zslayton/mai", "path": "/examples/echo/client/src/round_trip.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zslayton/mai path: /examples/echo/client/src/round_trip.rs extern crate mio; extern crate mai; extern crate env_logger; //use mio::Token; use mio::tcp::{TcpSocket, TcpStream}; use mai::*; struct EchoCodec; struct EchoClient; struct EchoClientHandler; #[derive(Default)] struct EchoSession { p...
code_fim
hard
{ "lang": "rust", "repo": "zslayton/mai", "path": "/examples/echo/client/src/round_trip.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let bytes = message.as_bytes(); if bytes.len() > buffer.len() { return Err(EncodingError::InsufficientBuffer); } for (index, &byte) in bytes.iter().enumerate() { buffer[index] = byte; } Ok(BytesWritten(bytes.len())) } fn decode(&mut self, buffer: &[u8]) -> Decodi...
code_fim
hard
{ "lang": "rust", "repo": "zslayton/mai", "path": "/examples/echo/client/src/round_trip.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>= i32; #[doc = "*Required features: `\"Win32_Storage_Packaging_Opc\"`*"] pub const OPC_COMPRESSION_NONE: OPC_COMPRESSION_OPTIONS = -1i32; #[doc = "*Required features: `\"Win32_Storage_Packaging_Opc\"`*"] pub const OPC_COMPRESSION_NORMAL: OPC_COMPRESSION_OPTIONS = 0i32; #[doc = "*Required features: `\"Win3...
code_fim
hard
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/windows-sys/src/Windows/Win32/Storage/Packaging/Opc/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: giodamelio/little_boxes path: /vendor/windows-sys/src/Windows/Win32/Storage/Packaging/Opc/mod.rs oid; pub type IOpcPart = *mut ::core::ffi::c_void; pub type IOpcPartEnumerator = *mut ::core::ffi::c_void; pub type IOpcPartSet = *mut ::core::ffi::c_void; pub type IOpcPartUri = *mut ::core::ffi::c_...
code_fim
hard
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/windows-sys/src/Windows/Win32/Storage/Packaging/Opc/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32f7/src/stm32f750/dma2/s5cr.rs *self == CIRC_A::Disabled } #[doc = "Circular mode enabled"] #[inline(always)] pub fn is_enabled(&self) -> bool { *self == CIRC_A::Enabled } } #[doc = "Field `CIRC` writer - Circular mode"] ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f7/src/stm32f750/dma2/s5cr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } impl PINCOS_R { #[doc = "Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> PINCOS_A { match self.bits { false => PINCOS_A::Psize, true => PINCOS_A::Fixed4, } } #[doc = "The offset size f...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f7/src/stm32f750/dma2/s5cr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32f7/src/stm32f750/dma2/s5cr.rs py, Debug, PartialEq, Eq)] pub enum HTIE_A { #[doc = "0: HT interrupt disabled"] Disabled = 0, #[doc = "1: HT interrupt enabled"] Enabled = 1, } impl From<HTIE_A> for bool { #[inline(always)] fn from(va...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f7/src/stm32f750/dma2/s5cr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// If three squares are aligned (can have a diagonal or cardinal line drawn between them) fn aligned(a: P::Square, b: P::Square, c: P::Square) -> bool; }<|fim_prefix|>// repo: itotallyrock/oxide path: /interface/src/game/line.rs use crate::game::Position; /// Board mask specifically for lines b...
code_fim
medium
{ "lang": "rust", "repo": "itotallyrock/oxide", "path": "/interface/src/game/line.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itotallyrock/oxide path: /interface/src/game/line.rs use crate::game::Position; /// Board mask specifically for lines between any given squares pub trait LineMask<P: Position> { /// Board mask between two squares if they're connected including endpoints (empty if mis-aligned) fn line_fi...
code_fim
medium
{ "lang": "rust", "repo": "itotallyrock/oxide", "path": "/interface/src/game/line.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn reset(&mut self) { self.regs.values_mut().for_each(|v| *v = 0); self.pc = 0; self.in_queue.clear(); self.sent = 0; self.blocked = false; self.finished = false; *self.regs.entry('p').or_insert(0) = self.id as i64; } } impl Cpu { fn ste...
code_fim
hard
{ "lang": "rust", "repo": "chrisvittal/aoc-2017", "path": "/src/bin/day18.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chrisvittal/aoc-2017 path: /src/bin/day18.rs extern crate aoc; use std::collections::{HashMap, VecDeque}; use std::rc::Rc; use std::str::FromStr; const INPUT: &'static str = "data/day18"; fn main() { let input = aoc::file::to_single_parsed(INPUT); let mut cpu0 = Cpu::from_instruction...
code_fim
hard
{ "lang": "rust", "repo": "chrisvittal/aoc-2017", "path": "/src/bin/day18.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone,Eq,Copy,PartialEq,Debug)] enum Inst { Snd(char), Set(char, i64), SetR(char, char), AddReg(char, char), AddLit(char, i64), MulReg(char, char), MulLit(char, i64), ModReg(char, char), ModLit(char, i64), Rcv(char), Jgz(char, i64), JgzR(char,char),...
code_fim
hard
{ "lang": "rust", "repo": "chrisvittal/aoc-2017", "path": "/src/bin/day18.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dbg!(get_maximum_gold(vec![ vec![0, 6, 0], vec![5, 8, 7], vec![0, 9, 0], ])); dbg!(get_maximum_gold(vec![ vec![1, 0, 7, 0, 0, 0], vec![2, 0, 6, 0, 1, 0], vec![3, 5, 6, 7, 4, 2], vec![4, 3, 1, 0, 2, 0], vec![3, 0, 5, 0, 20, 0] ...
code_fim
hard
{ "lang": "rust", "repo": "ccqpein/Arithmetic-Exercises", "path": "/Path-with-Maximum-Gold/PwMG.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ccqpein/Arithmetic-Exercises path: /Path-with-Maximum-Gold/PwMG.rs use std::collections::HashSet; pub fn get_maximum_gold(grid: Vec<Vec<i32>>) -> i32 { let mut largest = 0; for x in 0..grid.len() { for y in 0..grid[0].len() { if grid[x][y] != 0 { let ...
code_fim
hard
{ "lang": "rust", "repo": "ccqpein/Arithmetic-Exercises", "path": "/Path-with-Maximum-Gold/PwMG.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> dbg!(get_maximum_gold(vec![ vec![1, 0, 7], vec![2, 0, 6], vec![3, 4, 5], vec![0, 3, 0], vec![9, 0, 20] ])); dbg!(get_maximum_gold(vec![ vec![0, 6, 0], vec![5, 8, 7], vec![0, 9, 0], ])); dbg!(get_maximum_gold(vec![ ...
code_fim
hard
{ "lang": "rust", "repo": "ccqpein/Arithmetic-Exercises", "path": "/Path-with-Maximum-Gold/PwMG.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Rtype::Tsig } } impl<'a, Octs: Octets + ?Sized> ParseRecordData<'a, Octs> for Tsig<Octs::Range<'a>, ParsedDname<Octs::Range<'a>>> { fn parse_rdata( rtype: Rtype, parser: &mut Parser<'a, Octs>, ) -> Result<Option<Self>, ParseError> { if rtype == Rtype::Tsig ...
code_fim
hard
{ "lang": "rust", "repo": "NLnetLabs/domain", "path": "/src/rdata/tsig.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns a reference to the algorithm name. /// /// TSIG encodes the algorithm used for keys and signatures as a domain /// name. It does, however, only use the format. No structure is used at /// all. pub fn algorithm(&self) -> &N { &self.algorithm } /// Return...
code_fim
hard
{ "lang": "rust", "repo": "NLnetLabs/domain", "path": "/src/rdata/tsig.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NLnetLabs/domain path: /src/rdata/tsig.rs ctets::serialize_octets", deserialize_with = "octseq::serde::DeserializeOctets::deserialize_octets", bound( serialize = "Octs: octseq::serde::SerializeOctets", deserialize = "Octs: octseq::serde::De...
code_fim
hard
{ "lang": "rust", "repo": "NLnetLabs/domain", "path": "/src/rdata/tsig.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>use app::App; fn main(){ print!("gen,"); print!("chase,"); print!("align,"); print!("cohension,"); print!("separate"); println!(""); let mut app = App::new(); for i in 1..100 { app.show_window(); app.print_params(i); app.next...
code_fim
medium
{ "lang": "rust", "repo": "stmtk1/chase_and_runaway", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stmtk1/chase_and_runaway path: /src/main.rs extern crate rand; extern crate piston; extern crate glutin_window; extern crate opengl_graphics; extern crate graphics; <|fim_suffix|> print!("gen,"); print!("chase,"); print!("align,"); print!("cohension,"); pr...
code_fim
medium
{ "lang": "rust", "repo": "stmtk1/chase_and_runaway", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn bytes(&self) -> Vec<u8> { format!( r#"upstream fastcgi_backend {{ server {}:9000; }} upstream fastcgi_backend_debug {{ server {}:9000; }}"#, self.backend, self.backend_debug ) .into_bytes() } } impl NginxUpstream { pub fn toggle_xdebug(&...
code_fim
hard
{ "lang": "rust", "repo": "shakyShane/wf2", "path": "/wf2_core/src/recipes/m2/output_files/nginx_upstream.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_nginxupstream_xdebug_disabled() -> Result<(), failure::Error> { let ctx = Context::new("/Users/shane/acme"); let us = NginxUpstream::from_ctx(&ctx)?; let expected = "upstream fastcgi_backend { server php:9000; } upstream fastcgi_backend_debug { server php-debug:9000; }"; ...
code_fim
hard
{ "lang": "rust", "repo": "shakyShane/wf2", "path": "/wf2_core/src/recipes/m2/output_files/nginx_upstream.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shakyShane/wf2 path: /wf2_core/src/recipes/m2/output_files/nginx_upstream.rs use crate::context::Context; use crate::file::File; use crate::recipes::m2::services::php::PhpService; use crate::recipes::m2::services::php_debug::PhpDebugService; use crate::services::Service; use std::path::PathBuf; ...
code_fim
hard
{ "lang": "rust", "repo": "shakyShane/wf2", "path": "/wf2_core/src/recipes/m2/output_files/nginx_upstream.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> replace ( self . block Block : : new ( next_label ) ) Instruction : : branch_conditional ( cond next_label merge_label ) ) ; } / / / Emit an unconditional branch to the merge block and compute merged / / / values . / / / / / / Use final_values as the merged values contributed by the current / / / block a...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/naga/src/back/spv/selection.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/naga/src/back/spv/selection.rs / * ! Generate SPIR - V conditional structures . Builders for if structures with and s . The types in this module track the information needed to emit SPIR - V code for complex conditional structures like those wh...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/naga/src/back/spv/selection.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> if suffix.len() != 0 { return format!("{}{}", chars.collect::<String>(), suffix); } suffix }<|fim_prefix|>// repo: vpetrigo/rust_book path: /containers/src/bin/task_two.rs use std::io; fn main() { println!("Hello from task_two"); let mut user_input = String::new(); io::s...
code_fim
hard
{ "lang": "rust", "repo": "vpetrigo/rust_book", "path": "/containers/src/bin/task_two.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vpetrigo/rust_book path: /containers/src/bin/task_two.rs use std::io; fn main() { println!("Hello from task_two"); let mut user_input = String::new(); io::stdin().read_line(&mut user_input).expect("Enter a word"); println!("Pig word: {}", convert_to_pig(&user_input.trim().to_str...
code_fim
medium
{ "lang": "rust", "repo": "vpetrigo/rust_book", "path": "/containers/src/bin/task_two.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", n); // mutation has to be explicit s2.borrow_mut().push_str(" dolly"); println!("{:?} {}",s2.borrow(), s); println!("{:?}", split(s2.clone())); }<|fim_prefix|>// repo: ArnaudValensi/rust-opengl-game-engine path: /src/shared.rs use std::rc::Rc; use std::cell::{RefCe...
code_fim
hard
{ "lang": "rust", "repo": "ArnaudValensi/rust-opengl-game-engine", "path": "/src/shared.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe {self.as_ptr().as_ref().unwrap()} } } /* // Cute, but useless, since it needs to be mutable // and so can't be shared anyway impl <'a, T> DerefMut for Shared<T> { #[inline] fn deref_mut(&mut self) -> &mut T { unsafe {self.as_ptr().as_mut().unwrap()} } } */ fn split ...
code_fim
hard
{ "lang": "rust", "repo": "ArnaudValensi/rust-opengl-game-engine", "path": "/src/shared.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ArnaudValensi/rust-opengl-game-engine path: /src/shared.rs use std::rc::Rc; use std::cell::{RefCell,Ref, RefMut}; use std::ops::Deref; use std::fmt; #[derive(Clone)] struct Shared<T> { v: Rc<RefCell<T>> } impl <T> Shared<T> { fn new(t: T)-> Shared<T> { Shared{v: Rc::new(RefCell...
code_fim
hard
{ "lang": "rust", "repo": "ArnaudValensi/rust-opengl-game-engine", "path": "/src/shared.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>athBuf::from(path)) } } } else { // Assume no argument indicates to go to the home directory env::home_dir() }; // Try to navigate to the new path let exit_code : usize = match opt_path { Some(new_path) => { match env::set_current_di...
code_fim
hard
{ "lang": "rust", "repo": "Lacaranian/carbine-shell", "path": "/src/builtins/cd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lacaranian/carbine-shell path: /src/builtins/cd.rs use std::path::PathBuf; use std::env; use constants::*; pub fn exec(args: Vec<String>) -> ShellStatus { // Determine where the caller wants to go let opt_path: Option<PathBuf> = if args.len() > 1 { // Use the first argument as ...
code_fim
hard
{ "lang": "rust", "repo": "Lacaranian/carbine-shell", "path": "/src/builtins/cd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KillingSpark/lumberjack-rs path: /src/tests.rs #[cfg(test)] #[test] fn it_works() { use crate::Conf; use std::io::Write; let path = "./test_logs"; if std::fs::metadata(&path).is_ok() { std::fs::remove_dir_all(&path).unwrap(); } std::fs::create_dir(&path).unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "KillingSpark/lumberjack-rs", "path": "/src/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> log_dir: path.into(), name_template: "mylog.log".to_owned(), }; let mut logger = crate::new(conf).unwrap(); logger.write_all("111111111\n".as_bytes()).unwrap(); logger.write_all("222222222\n".as_bytes()).unwrap(); logger.write_all("333333333\n".as_bytes()).unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "KillingSpark/lumberjack-rs", "path": "/src/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digama0/mm0 path: /mm0-rs/components/mmcc/src/build_ast.rs self.push_label(name, LabelId(group, i.try_into().expect("label number overflow"))); } group } /// Push a type variable. Uses of `name` as a type will resolve to this variable. /// Type variables are not scoped, since ...
code_fim
hard
{ "lang": "rust", "repo": "digama0/mm0", "path": "/mm0-rs/components/mmcc/src/build_ast.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>/// A match builder, which implements what amounts to a coroutine that collaborates with the /// client to build a match expression. #[derive(Debug)] pub struct MatchBuilder<T> { /// The span of the whole match expression. span: FileSpan, /// The scrutinee variable, if applicable. scvar: Option<Va...
code_fim
hard
{ "lang": "rust", "repo": "digama0/mm0", "path": "/mm0-rs/components/mmcc/src/build_ast.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Callable from `Start`, transitions to `Start`. /// Starts a `pat with cond` pattern, transitions to accept `pat`. /// When `pat` is finished, [`Pattern::with`] can be used to complete the with-pattern. pub fn with(&mut self, sp: &FileSpan) { if let Some(f) = self.pos.take() { let sp ...
code_fim
hard
{ "lang": "rust", "repo": "digama0/mm0", "path": "/mm0-rs/components/mmcc/src/build_ast.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: openbuttnakedgang/holter-wasm-app path: /src/cfg.rs use seed::prelude::*; use crate::device::Desc; pub async fn load(_desc: Desc) -> String { let scheme = fetch_scheme().await; <|fim_suffix|> let user: String = response .check_status() // ensure we've got 2xx status .e...
code_fim
medium
{ "lang": "rust", "repo": "openbuttnakedgang/holter-wasm-app", "path": "/src/cfg.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> scheme } async fn fetch_scheme() -> String { let response = fetch("public/scheme.json") .await .expect("HTTP request failed"); let user: String = response .check_status() // ensure we've got 2xx status .expect("status check failed") .text() .aw...
code_fim
medium
{ "lang": "rust", "repo": "openbuttnakedgang/holter-wasm-app", "path": "/src/cfg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn refcnt(&self) -> usize { self.refcnt } pub fn insert(&mut self, vm_page: *mut VmPage) { unsafe { let pages = self.pages; (*pages).insert(&((*vm_page).off as off_t), vm_page); } } }<|fim_prefix|>// repo: dalalsunil1986/aquila-kernel p...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/aquila-kernel", "path": "/src/mm/vm_object.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalalsunil1986/aquila-kernel path: /src/mm/vm_object.rs use prelude::*; use mm::vmm::*; use mm::kvmem::*; malloc_define!(M_VM_OBJECT, "vm-object\0", "virtual memory object\0"); /** * cached object */ pub struct VmObject { /** `vm_page`s loaded/contained in the vm object */ pub pages...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/aquila-kernel", "path": "/src/mm/vm_object.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_object<'a, I>(tokens: &mut I) -> Box<Json> where I: Iterator<Item = &'a Token<'a>> { let mut json_object = JsonObject::new(); loop { let next_token = tokens.next().unwrap(); if next_token.enum_type == Enums::RBRACE { break; } else if next_token.enum...
code_fim
hard
{ "lang": "rust", "repo": "sean-a-m/json-parser", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }