text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fn write_be<S: Serialize<BigEndian, Self>>(&mut self, ser: S) -> Res<()> { ser.serialize(self) } fn write_le<S: Serialize<LittleEndian, Self>>(&mut self, ser: S) -> Res<()> { ser.serialize(self) } } /** Use this to `write` in **little** endian. Wrapper for `EWrite<LittleEndian>`. This exists so...
code_fim
hard
{ "lang": "rust", "repo": "lcdr/endio", "path": "/src/write.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// BACnet primitive application value types #[derive(Debug, PartialEq)] pub enum PrimitiveValue { Null, Boolean(bool), Unsigned(u32), Signed(i32), Real(f32), Double(f64), // OctetString([u8]), // not yey implemented as a working, non-ugly type signature will take // some t...
code_fim
hard
{ "lang": "rust", "repo": "platy/bacnet-rs", "path": "/src/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: platy/bacnet-rs path: /src/ast.rs //! Defining an abstract syntax tree for bacnet APDUs use object; /// Defines the whole body of a BACnet APDU message #[derive(Debug, PartialEq)] pub enum ApduHeader { /// BACnet Confirmed Request - Clause 20.1.2 /// Transfers a variable length request...
code_fim
hard
{ "lang": "rust", "repo": "platy/bacnet-rs", "path": "/src/ast.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kixiron/crunch-lang path: /crates/crunch-codegen/src/llvm/types/mod.rs mod integer; mod sealed_any_type; mod ty; mod type_kind; pub use integer::{IntType, IntWidth, Unknown, I1}; pub(crate) use sealed_any_type::SealedAnyType; pub(crate) use ty::Type; pub use type_kind::TypeKind; use crate::llv...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/crunch-lang", "path": "/crates/crunch-codegen/src/llvm/types/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> args.into_iter() .map(|arg| Type::from_raw(arg.assume_init())) .collect() } } pub fn num_args(self) -> u32 { unsafe { LLVMCountParamTypes(self.as_mut_ptr()) } } pub(crate) const fn as_mut_ptr(self) -> *mut LLVMType { sel...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/crunch-lang", "path": "/crates/crunch-codegen/src/llvm/types/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn make_array(self, len: u32) -> Result<ArrayType<'ctx>> { self.as_ty().make_array(len) } fn element_type(self) -> Result<Type<'ctx>> { unsafe { Type::from_raw(LLVMGetElementType(self.as_mut_ptr())) } } } macro_rules! impl_any_ty { ($($ty:ident),* $(,)?) => { ...
code_fim
hard
{ "lang": "rust", "repo": "Kixiron/crunch-lang", "path": "/crates/crunch-codegen/src/llvm/types/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-bam/src/record/codec/encoder/data/field/tag.rs use bytes::BufMut; use noodles_sam::record::data::field::Tag; pub fn put_tag<B>(dst: &mut B, tag: Tag) where B: BufMut, { dst.put(&tag.as_ref()[..]); } <|fim_suffix|> #[test] fn test_put_tag() { ...
code_fim
easy
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-bam/src/record/codec/encoder/data/field/tag.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use noodles_sam::record::data::field::tag; let mut buf = Vec::new(); put_tag(&mut buf, tag::ALIGNMENT_HIT_COUNT); assert_eq!(buf, [b'N', b'H']); } }<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-bam/src/record/codec/encoder/data/field/tag.rs use bytes::BufMut; ...
code_fim
medium
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-bam/src/record/codec/encoder/data/field/tag.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_put_tag() { use noodles_sam::record::data::field::tag; let mut buf = Vec::new(); put_tag(&mut buf, tag::ALIGNMENT_HIT_COUNT); assert_eq!(buf, [b'N', b'H']); } }<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-bam/src/record/codec/encoder/d...
code_fim
medium
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-bam/src/record/codec/encoder/data/field/tag.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tim-Zhang/rust-protobuf path: /protobuf-codegen/src/gen/field/option_kind.rs use crate::gen::inside::protobuf_crate_path; use crate::gen::rust_types_values::RustType; use crate::Customize; /// Optional fields can be stored are `Option<T>` or `SingularPtrField<T>`. #[derive(Copy, Clone, Eq, Part...
code_fim
hard
{ "lang": "rust", "repo": "Tim-Zhang/rust-protobuf", "path": "/protobuf-codegen/src/gen/field/option_kind.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn unwrap_or_else(&self, what: &str, default_value: &str) -> String { match self { _ => format!("{}.unwrap_or_else(|| {})", what, default_value), } } pub(crate) fn unwrap_ref_or_else(&self, what: &str, default_value: &str) -> String { match self ...
code_fim
hard
{ "lang": "rust", "repo": "Tim-Zhang/rust-protobuf", "path": "/protobuf-codegen/src/gen/field/option_kind.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn unwrap_ref_or_else(&self, what: &str, default_value: &str) -> String { match self { _ => format!("{}.unwrap_or_else(|| {})", what, default_value), } } pub(crate) fn wrap_value(&self, value: &str, customize: &Customize) -> String { match self {...
code_fim
hard
{ "lang": "rust", "repo": "Tim-Zhang/rust-protobuf", "path": "/protobuf-codegen/src/gen/field/option_kind.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/openssl-sys/src/bio.rs use libc::*; use *; pub const BIO_TYPE_NONE: c_int = 0; pub const BIO_CTRL_EOF: c_int = 2; pub const BIO_CTRL_INFO: c_int = 3; pub const BIO_CTRL_FLUSH: c_int = 11; pub const BIO_CTRL_DGRAM_QUERY_MTU: c_int = 40; pub const BIO_C_SE...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/openssl-sys/src/bio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub const BIO_FLAGS_READ: c_int = 0x01; pub const BIO_FLAGS_WRITE: c_int = 0x02; pub const BIO_FLAGS_IO_SPECIAL: c_int = 0x04; pub const BIO_FLAGS_RWS: c_int = BIO_FLAGS_READ | BIO_FLAGS_WRITE | BIO_FLAGS_IO_SPECIAL; pub const BIO_FLAGS_SHOULD_RETRY: c_int = 0x08; pub type bio_info_cb = Option<unsafe...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/openssl-sys/src/bio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nvzqz/packed_simd path: /src/codegen/math/float/sqrte.rs //! Vertical floating-point `sqrt` #![allow(unused)] use llvm::simd_fsqrt; // FIXME 64-bit 1 elem vectors sqrte use crate::*; crate trait Sqrte { fn sqrte(self) -> Self; } macro_rules! impl_vsqrt { ($vid:ident: $llvm_fn:ident)...
code_fim
hard
{ "lang": "rust", "repo": "nvzqz/packed_simd", "path": "/src/codegen/math/float/sqrte.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn mk_id(&self) -> NodeId { let id = self.id_counter.get(); self.id_counter.set(id + 1); NodeId::new(id) } pub(crate) fn try_parse<R, P>(&mut self, parser: &mut P) -> Option<R> where P: Parse<'a, Output = R>, { let backtrack_idx = sel...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/l-lang", "path": "/src/lc-parse/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andyyu2004/l-lang path: /src/lc-parse/src/parser.rs use super::*; use codespan::ByteIndex; use lc_ast::*; use lc_error::*; use lc_index::Idx; use lc_lex::*; use lc_session::Session; use lc_span::{self, kw, FileIdx, Span, SpanIdx, Symbol, ROOT_FILE_IDX}; use std::cell::Cell; use std::error::Error...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/l-lang", "path": "/src/lc-parse/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// expect identifier starting with uppercase letter /// see comments on `expect_lident` on return values pub(crate) fn expect_uident(&mut self) -> ParseResult<'a, Ident> { let ident = self.expect_ident()?; if !ident.is_upper() { self.build_err(ident.span, ParseErro...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/l-lang", "path": "/src/lc-parse/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> VirtualKeyCode::Q => { if map[self.position.1 as usize][self.position.0 as usize] == TileType::Stair { self.new_level = true } }, VirtualKeyCode::Escape => self.quit = t...
code_fim
hard
{ "lang": "rust", "repo": "Steampunkery/roguelike_i2", "path": "/src/player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Steampunkery/roguelike_i2 path: /src/player.rs use crate::map::{TileType, DungeonMap}; use rltk::VirtualKeyCode; pub struct Player { pub position: (i32, i32), pub has_moved: bool, pub quit: bool, pub new_level: bool, } impl Player { fn move_player(&mut self, delta_x: i32, ...
code_fim
hard
{ "lang": "rust", "repo": "Steampunkery/roguelike_i2", "path": "/src/player.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn handle_input(&mut self, map: &DungeonMap, keycode: Option<VirtualKeyCode>) { match keycode { Some(key) => { match key { // Numpad VirtualKeyCode::Numpad8 => self.move_player(0, -1, map), VirtualKeyCo...
code_fim
hard
{ "lang": "rust", "repo": "Steampunkery/roguelike_i2", "path": "/src/player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tjahyaf/aoc-2020 path: /day-8/src/main.rs use std::fs; use std::io::{self, BufRead}; #[derive(Debug)] enum Cmd { Acc(i32), Jmp(i32), Nop(i32), } fn main() { let commands: Vec<Cmd> = io::BufReader::new(fs::File::open("./input.txt").unwrap()) .lines() .flatten() ...
code_fim
hard
{ "lang": "rust", "repo": "tjahyaf/aoc-2020", "path": "/day-8/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn execute_all( mut reg: Register, commands: &[Cmd], ran: &mut [bool], history: &mut Vec<Register>, ) -> Register { while reg.next < commands.len() && !ran[reg.next] { history.push(reg); ran[reg.next] = true; reg = reg.exec(&commands[reg.next]); } reg }...
code_fim
hard
{ "lang": "rust", "repo": "tjahyaf/aoc-2020", "path": "/day-8/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abhishekg785/experiments-with-rust path: /mutation/mut1.rs fn leader() { let mut vec = Vec::new(); vec.push(1); vec.push(2); use(&vec); //borrowing concept } <|fim_suffix|> } fn main() { loader(); }<|fim_middle|>fn use(vec:&Vec<i32) {
code_fim
easy
{ "lang": "rust", "repo": "abhishekg785/experiments-with-rust", "path": "/mutation/mut1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} fn main() { loader(); }<|fim_prefix|>// repo: abhishekg785/experiments-with-rust path: /mutation/mut1.rs fn leader() { let mut vec = Vec::new(); vec.push(1); vec.push(2); use(&vec); //borrowing concept } <|fim_middle|>fn use(vec:&Vec<i32) {
code_fim
easy
{ "lang": "rust", "repo": "abhishekg785/experiments-with-rust", "path": "/mutation/mut1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/winapi/v0_3/crate/src/um/nb30.rs // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files i...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/nb30.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>st NCBACTION: UCHAR = 0x77; pub const NCBFINDNAME: UCHAR = 0x78; pub const NCBTRACE: UCHAR = 0x79; pub const ASYNCH: UCHAR = 0x80; pub const NRC_GOODRET: UCHAR = 0x00; pub const NRC_BUFLEN: UCHAR = 0x01; pub const NRC_ILLCMD: UCHAR = 0x03; pub const NRC_CMDTMO: UCHAR = 0x05; pub const NRC_INCOMP: UCHAR = ...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/nb30.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub const HANGUP_COMPLETE: UCHAR = 0x05; pub const SESSION_ABORTED: UCHAR = 0x06; STRUCT!{struct LANA_ENUM { length: UCHAR, lana: [UCHAR; MAX_LANA + 1], }} pub type PLANA_ENUM = *mut LANA_ENUM; STRUCT!{struct FIND_NAME_HEADER { node_count: WORD, reserved: UCHAR, unique_group: UCHAR, }...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/nb30.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foxfriends/gmlpp path: /src/gmlpp/ast/literal.rs use std::fmt::{self, Display, Formatter}; use std::str::FromStr; use super::fragment::Fragment; use super::super::tokenizer::{Token, Tokens}; use error::{Error, ParseError}; #[derive(Clone, Debug)] pub enum Literal { Numeric(f64), Boolea...
code_fim
hard
{ "lang": "rust", "repo": "foxfriends/gmlpp", "path": "/src/gmlpp/ast/literal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match tokens.next() { Token::BinLiteral(bin) => Ok(Literal::Numeric(i64::from_str_radix(&bin, 2)? as f64)), Token::HexLiteral(hex) => Ok(Literal::Numeric(i64::from_str_radix(&hex, 2)? as f64)), Token::DecLiteral(dec) => Ok(Literal::Numeric(f64::from_str(&dec)?))...
code_fim
hard
{ "lang": "rust", "repo": "foxfriends/gmlpp", "path": "/src/gmlpp/ast/literal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Literal::Numeric(n) => n.fmt(f), Literal::Boolean(b) => b.fmt(f), Literal::String(s) => write!(f, "{:?}", s), Literal::Char(c) => write!(f, "{:?}", c), Literal::Undefined => write!(f, "undefined"), } } } impl Fra...
code_fim
medium
{ "lang": "rust", "repo": "foxfriends/gmlpp", "path": "/src/gmlpp/ast/literal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tinco/entity_rust path: /src/events/mod.rs /// The event system will have a trigger function that takes an /// argument that decides if the event will be triggered this tick /// or the next tick. The default should be next tick to prevent /// inadvertent infinite loop bugs. /// /// The event sys...
code_fim
hard
{ "lang": "rust", "repo": "tinco/entity_rust", "path": "/src/events/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub type HandlerFn = fn(Arc<Any>, &Vec<Data>, Vec<MappedSharedMutexReadGuard<Any>>, Vec<MappedSharedMutexWriteGuard<Any>>); pub struct Handler { handler_fn: HandlerFn, state: Arc<Any+Sync+Send>, component_types: Vec<TypeId>, mut_component_types: Vec<TypeId> } pub struct Handl...
code_fim
hard
{ "lang": "rust", "repo": "tinco/entity_rust", "path": "/src/events/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Add the current speed to the position. m.position += m.velocity; let rect = app.window_rect(); if (m.position.x > rect.right()) || (m.position.x < rect.left()) { m.velocity.x = m.velocity.x * -1.0; } if (m.position.y > rect.top()) || (m.position.y < rect.bottom()) { ...
code_fim
hard
{ "lang": "rust", "repo": "MacTuitui/nannou", "path": "/nature_of_code/chp_01_vectors/1_2_bouncingball_vectors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MacTuitui/nannou path: /nature_of_code/chp_01_vectors/1_2_bouncingball_vectors.rs // The Nature of Code // Daniel Shiffman // http://natureofcode.com // // Example 1-2: Bouncing Ball, with Vector! use nannou::prelude::*; fn main() { nannou::app(model).update(update).run(); } struct Model {...
code_fim
hard
{ "lang": "rust", "repo": "MacTuitui/nannou", "path": "/nature_of_code/chp_01_vectors/1_2_bouncingball_vectors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let test_cases = vec![ (vec![0.5,0.5,0.5,0.5,0.5], 0, 0.03125), //(vec![0.9135438348889597,0.32438744165539823,0.3868611933705496,0.9871121517253313,0.09876739266164869,0.1443522802956042,0.36162923554484294,0.6625872890913753,0.7826203138601814,0.27460883851315077,0.003296...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_1230.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caibirdme/leetcode_rust path: /src/prob_1230.rs use std::cmp::min; impl Solution { pub fn probability_of_heads(mut prob: Vec<f64>, mut target: i32) -> f64 { let n = prob.len(); if n == 0 { return 0f64; } if n == 1 { return prob[0]; ...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_1230.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>B, PSUBSW, PSUBUSB, PSUBUSW, PSUBW, PUNPCKHBW, PUNPCKHDQ, PUNPCKHWD, PUNPCKLBW, PUNPCKLDQ, PUNPCKLWD, PXOR }<|fim_prefix|>// repo: faineance/vpu path: /src/runtime/codegen/x86_64/mmx.rs //todo annotate pub enum MMXInstr { EMMS, MOVD, MOVQ, PACK...
code_fim
hard
{ "lang": "rust", "repo": "faineance/vpu", "path": "/src/runtime/codegen/x86_64/mmx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: faineance/vpu path: /src/runtime/codegen/x86_64/mmx.rs //todo annotate pub enum MMXInstr { EMMS, MOVD, MOVQ, PACKSSDW, PACKSSWB, PACKUSWB, PADDB, PADDD, PADDSB, PADDSW, PADDUSB, PADDUSW, PADDW, PAND, PANDN, PCMPEQB, PCMPEQD, ...
code_fim
medium
{ "lang": "rust", "repo": "faineance/vpu", "path": "/src/runtime/codegen/x86_64/mmx.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> PMULHW, PMULLW, POR, PSLLD, PSLLQ, PSLLW, PSRAD, PSRAW, PSRLD, PSRLQ, PSRLW, PSUBB, PSUBD, PSUBSB, PSUBSW, PSUBUSB, PSUBUSW, PSUBW, PUNPCKHBW, PUNPCKHDQ, PUNPCKHWD, PUNPCKLBW, PUNPCKLDQ, PUNPCKLWD, PXOR }<|...
code_fim
medium
{ "lang": "rust", "repo": "faineance/vpu", "path": "/src/runtime/codegen/x86_64/mmx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>> 'L', 0b111111100100100100011000 => 'P', 0b111111100100100110011001 => 'R', 0b111110000001000001111110 => 'U', 0b100011100101101001110001 => 'Z', _ => '?', } }) .collect() }<|fim_prefix|>// repo: D...
code_fim
hard
{ "lang": "rust", "repo": "Defelo/AdventOfCode", "path": "/lib/parsing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>011110100001100101010111 => 'G', 0b111111001000001000111111 => 'H', 0b000010000001100001111111 => 'J', 0b000010000001100001111110 => 'J', 0b111111001000010110100001 => 'K', 0b111111000001000001000001 => 'L', 0b...
code_fim
hard
{ "lang": "rust", "repo": "Defelo/AdventOfCode", "path": "/lib/parsing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Defelo/AdventOfCode path: /lib/parsing.rs pub fn parse_ascii(dots: &[&[bool]]) -> String { (0..((dots[0].len() + 1) / 5)) .map(|n| { let k = (5 * n..5 * n + 4) .flat_map(|j| (0..6).map(move |i| dots[i][j])) .fold(0, |acc, dot| (acc << 1) | ...
code_fim
hard
{ "lang": "rust", "repo": "Defelo/AdventOfCode", "path": "/lib/parsing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(formatter, "Monitor shows nothing for now" ) } } impl<T> Monitor<T> { pub fn new(monitored: T) -> Self { let inner = MonitorInner { data: sync::Mutex::new(monitored), predicate: (sync::Mutex::new(false), sync::Condvar::new()) }; Monit...
code_fim
medium
{ "lang": "rust", "repo": "BillBarnhill/rtps", "path": "/src/sync/monitor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Monitor<T> { pub fn new(monitored: T) -> Self { let inner = MonitorInner { data: sync::Mutex::new(monitored), predicate: (sync::Mutex::new(false), sync::Condvar::new()) }; Monitor( sync::Arc::new(inner) ) } pub fn wait(&self) -> Result<(...
code_fim
medium
{ "lang": "rust", "repo": "BillBarnhill/rtps", "path": "/src/sync/monitor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BillBarnhill/rtps path: /src/sync/monitor.rs use std::{ sync, fmt }; pub struct Monitor<T>( sync::Arc<MonitorInner<T>> ); struct MonitorInner<T> { data: sync::Mutex<T>, predicate: (sync::Mutex<bool>, sync::Condvar) } impl<T> fmt::Debug for Monitor<T> { fn fmt(&self, formatter:...
code_fim
hard
{ "lang": "rust", "repo": "BillBarnhill/rtps", "path": "/src/sync/monitor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cobrand/hexgrid-rs path: /src/error.rs use std::fmt; pub type Result<T> = ::std::result::Result<T,Error>; #[derive(Debug,Copy,Clone,Eq,PartialEq)] pub enum Reason { NegativeMapLength, OutOfRange, AlreadyOccupied, MissingTarget, ForbiddenLocation, UnknownReason } #[deriv...
code_fim
medium
{ "lang": "rust", "repo": "Cobrand/hexgrid-rs", "path": "/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl ::std::error::Error for Error { fn description(&self) -> &str { match self.reason { Reason::NegativeMapLength => { "map was created with a negative length" }, Reason::OutOfRange => { "want to access something that is not ...
code_fim
medium
{ "lang": "rust", "repo": "Cobrand/hexgrid-rs", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Error { pub fn new(reason:Reason) -> Error { Error { reason: reason } } } impl ::std::error::Error for Error { fn description(&self) -> &str { match self.reason { Reason::NegativeMapLength => { "map was created with a negati...
code_fim
medium
{ "lang": "rust", "repo": "Cobrand/hexgrid-rs", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<RantsError> for Error { fn from(error: RantsError) -> Self { Error::Rants(error) } } impl From<native_tls::Error> for Error { fn from(error: native_tls::Error) -> Self { Error::NativeTls(error) } }<|fim_prefix|>// repo: habitat-sh/habitat path: /components/sup/src/event/error.rs //! Ev...
code_fim
hard
{ "lang": "rust", "repo": "habitat-sh/habitat", "path": "/components/sup/src/event/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: habitat-sh/habitat path: /components/sup/src/event/error.rs //! Event subsystem-specific error handling use rants::{error::Error as RantsError, native_tls}; use std::{error, fmt, result}; pub type Result<T> = result::Result<T, Error>; #[derive(Debug)] pub enum ...
code_fim
hard
{ "lang": "rust", "repo": "habitat-sh/habitat", "path": "/components/sup/src/event/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { Error::ConnectNatsServer => "Could not establish connection to NATS server".fmt(f), Error::HabitatCore(_) => "{}".fmt(f), Error::NativeTls(e) => format!("{}", e).fmt(f), Error::Rants(e) => format!("{}", e).fmt(f), } } } impl...
code_fim
hard
{ "lang": "rust", "repo": "habitat-sh/habitat", "path": "/components/sup/src/event/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>)] #![allow(non_snake_case)] include!(concat!(env!("OUT_DIR"), "/bindings.rs"));<|fim_prefix|>// repo: nsmryan/jsmn-rs path: /src/raw.rs //! //! This module provides raw bindings to the jsmn library, //! generated by bindgen. It is not needed for most use cases, //! as the more Rustic interface <|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "nsmryan/jsmn-rs", "path": "/src/raw.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nsmryan/jsmn-rs path: /src/raw.rs //! //! This module provides raw bindings to the jsmn library, //! generated by <|fim_suffix|>)] #![allow(non_snake_case)] include!(concat!(env!("OUT_DIR"), "/bindings.rs"));<|fim_middle|>bindgen. It is not needed for most use cases, //! as the more Rustic int...
code_fim
medium
{ "lang": "rust", "repo": "nsmryan/jsmn-rs", "path": "/src/raw.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(output) } } #[napi] pub fn mdx_compile( value: String, option: Buffer, signal: Option<AbortSignal>, ) -> napi::Result<AsyncTask<MdxCompileTask>> { let task = MdxCompileTask { input: value, option, }; Ok(AsyncTask::with_optional_signal(task, signal)) ...
code_fim
hard
{ "lang": "rust", "repo": "vercel/next.js", "path": "/packages/next-swc/crates/napi/src/mdx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> compile(value.as_str(), &option) .map_err(|err| napi::Error::new(Status::GenericFailure, format!("{:?}", err))) }<|fim_prefix|>// repo: vercel/next.js path: /packages/next-swc/crates/napi/src/mdx.rs use napi::bindgen_prelude::*; use turbopack_binding::features::mdxjs::{compile, Options}; pub...
code_fim
hard
{ "lang": "rust", "repo": "vercel/next.js", "path": "/packages/next-swc/crates/napi/src/mdx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vercel/next.js path: /packages/next-swc/crates/napi/src/mdx.rs use napi::bindgen_prelude::*; use turbopack_binding::features::mdxjs::{compile, Options}; pub struct MdxCompileTask { pub input: String, pub option: Buffer, } impl Task for MdxCompileTask { type Output = String; typ...
code_fim
hard
{ "lang": "rust", "repo": "vercel/next.js", "path": "/packages/next-swc/crates/napi/src/mdx.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liang610/flux path: /libflux/src/flux/semantic/walk/test_utils.rs use crate::ast; use crate::parser::parse_string; use crate::semantic::convert; use crate::semantic::fresh::Fresher; use crate::semantic::nodes; pub fn compi<|fim_suffix|>() > 0 { panic!(format!("got errors on parsing: {:?...
code_fim
medium
{ "lang": "rust", "repo": "liang610/flux", "path": "/libflux/src/flux/semantic/walk/test_utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>"".to_string(), package: "main".to_string(), files: vec![file], }; convert::convert_with(ast_pkg, &mut Fresher::default()).unwrap() }<|fim_prefix|>// repo: liang610/flux path: /libflux/src/flux/semantic/walk/test_utils.rs use crate::ast; use crate::parser::parse_string; use crate:...
code_fim
medium
{ "lang": "rust", "repo": "liang610/flux", "path": "/libflux/src/flux/semantic/walk/test_utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests; pub(crate) use self::tree_restore::RestoredTree;<|fim_prefix|>// repo: matter-labs/zksync path: /core/bin/zksync_core/src/state_keeper/state_restore/mod.rs //! This module contains the logic to restore state keeper state from the database. <|fim_middle|>pub(crate) mod db; pub(cr...
code_fim
easy
{ "lang": "rust", "repo": "matter-labs/zksync", "path": "/core/bin/zksync_core/src/state_keeper/state_restore/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) use self::tree_restore::RestoredTree;<|fim_prefix|>// repo: matter-labs/zksync path: /core/bin/zksync_core/src/state_keeper/state_restore/mod.rs //! This module contains the logic to restore state keeper state from the database. <|fim_middle|>pub(crate) mod db; pub(crate) mod tree_restore; #...
code_fim
medium
{ "lang": "rust", "repo": "matter-labs/zksync", "path": "/core/bin/zksync_core/src/state_keeper/state_restore/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matter-labs/zksync path: /core/bin/zksync_core/src/state_keeper/state_restore/mod.rs //! This module contains the logic to restore state keeper state from the database. <|fim_suffix|>#[cfg(test)] mod tests; pub(crate) use self::tree_restore::RestoredTree;<|fim_middle|>pub(crate) mod db; pub(cr...
code_fim
easy
{ "lang": "rust", "repo": "matter-labs/zksync", "path": "/core/bin/zksync_core/src/state_keeper/state_restore/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drmason13/macroquad-pong path: /src/consts.rs pub const PADDLE_HEIGHT: f32 = 100.0; pub const PADDLE_WIDTH: f32 = 20.0; pub const PADDLE_HEIGHT_HALF: f32 = PADDLE_HEIGHT * 0.5; pub const PADDLE_WIDTH_HALF: f32 = PADDLE_WIDTH * 0.5; <|fim_suffix|>/// A fixed size screen so that the browser windo...
code_fim
medium
{ "lang": "rust", "repo": "drmason13/macroquad-pong", "path": "/src/consts.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub const SCORE_FONT_SIZE: f32 = 72.0; /// A fixed size screen so that the browser window doesn't affect the gameplay pub const GAME_HEIGHT: f32 = 600.0; pub const GAME_WIDTH: f32 = 800.0;<|fim_prefix|>// repo: drmason13/macroquad-pong path: /src/consts.rs pub const PADDLE_HEIGHT: f32 = 100.0; pub const...
code_fim
easy
{ "lang": "rust", "repo": "drmason13/macroquad-pong", "path": "/src/consts.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mockersf/concourse-slack-notifier path: /src/message.rs use serde::Serialize; use crate::{AlertType, OutParams}; use concourse_resource::BuildMetadata; #[derive(Serialize)] pub struct Message { pub color: String, pub text: Option<String>, pub icon_url: String, } struct FormattedBu...
code_fim
hard
{ "lang": "rust", "repo": "mockersf/concourse-slack-notifier", "path": "/src/message.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn into_slack_message( self, build_metadata: BuildMetadata, params: &OutParams, ) -> slack_push::Message { let formatted_build_info = formatted_build_info_from_params(&build_metadata); slack_push::Message { attachments: Some(vec![slack...
code_fim
hard
{ "lang": "rust", "repo": "mockersf/concourse-slack-notifier", "path": "/src/message.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! unexpected_eof { ($input: expr) => {{ use crate::parser::error::{Error, ErrorKind}; Err(nom::Err::Error(Error { input: $input, error: ErrorKind::UnexpectedEOF("something else".to_owned()), })) }}; } #[macro_export] macro...
code_fim
hard
{ "lang": "rust", "repo": "LaplaceKorea/quil-rust", "path": "/src/parser/macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LaplaceKorea/quil-rust path: /src/parser/macros.rs /** * Copyright 2021 Rigetti Computing * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache....
code_fim
hard
{ "lang": "rust", "repo": "LaplaceKorea/quil-rust", "path": "/src/parser/macros.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_and() { assert_and(false, false, false, false); assert_and(true, false, false, false); assert_and(false, true, false, false); assert_and(true, true, false, false); assert_and(false, false, true, false); assert_and(true, false, true, f...
code_fim
hard
{ "lang": "rust", "repo": "Orchaldir/rusted_social_simulation", "path": "/rusted_social_simulation/src/social/condition.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Orchaldir/rusted_social_simulation path: /rusted_social_simulation/src/social/condition.rs /// A condition that can evaluate to true or false given a context. pub trait Condition<T> { fn evaluate(&self, context: &T) -> bool; } /// A condition that always evaluates to a fixed value. pub stru...
code_fim
hard
{ "lang": "rust", "repo": "Orchaldir/rusted_social_simulation", "path": "/rusted_social_simulation/src/social/condition.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alex-dukhno/rust-tdd-katas path: /old-katas-iteration-03/calculator_ast_kata/src/day_07.rs use std::iter::Peekable; use std::str::{Chars, FromStr}; #[derive(Debug, PartialEq)] pub enum Ast { Num(f64), Op(char, Box<Ast>, Box<Ast>), } impl Ast { fn parse_num(chars: &mut Peekable<Char...
code_fim
hard
{ "lang": "rust", "repo": "alex-dukhno/rust-tdd-katas", "path": "/old-katas-iteration-03/calculator_ast_kata/src/day_07.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn many_operations() { assert_eq!( Ast::from_str("3+9*8-32/4"), Ok(Ast::Op( '-', Box::new(Ast::Op( '+', Box::new(Ast::Num(3.0)), Box::new(Ast::Op( ...
code_fim
hard
{ "lang": "rust", "repo": "alex-dukhno/rust-tdd-katas", "path": "/old-katas-iteration-03/calculator_ast_kata/src/day_07.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> $( impl $crate::router::CapabilityVisitor for $name { type CapabilityDecl = $cap_decl; fn visit( &mut self, _decl: &Self::CapabilityDecl ) -> Result<(), $crate::error::RoutingError> { ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/lib/routing/src/availability.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/lib/routing/src/availability.rs // Copyright 2022 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 { crate::error::AvailabilityRoutingError, cm_rust::{ ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/lib/routing/src/availability.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, _decl: &Self::CapabilityDecl ) -> Result<(), $crate::error::RoutingError> { Ok(()) } } )* }; } make_availability_visitor!(AvailabilityServiceVisitor, { OfferDecl => OfferServ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/lib/routing/src/availability.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>x4000_1000 as *mut u8) }; *byte1 = 0x11; assert_eq!(*byte6, 0xFF); assert_eq!(*byte5, 0x01); println!("test end"); 0 }<|fim_prefix|>// repo: DaixuanLi/UndergradCourseProject path: /OperatingSystem_Rust/usr/rust/src/bin/page_replace_test.rs #![no_std] #![no_main] extern crate alloc; ...
code_fim
medium
{ "lang": "rust", "repo": "DaixuanLi/UndergradCourseProject", "path": "/OperatingSystem_Rust/usr/rust/src/bin/page_replace_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DaixuanLi/UndergradCourseProject path: /OperatingSystem_Rust/usr/rust/src/bin/page_replace_test.rs #![no_std] #![no_main] extern crate alloc; #[macro_use] extern crate user; #[no_mangle] pub fn main() -> usize { println!("test be<|fim_suffix|>x4000_1000 as *mut u8) }; *byte1 = 0x11; ...
code_fim
hard
{ "lang": "rust", "repo": "DaixuanLi/UndergradCourseProject", "path": "/OperatingSystem_Rust/usr/rust/src/bin/page_replace_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>u8) }; *byte5 = 0x01; let byte0 = unsafe { &mut *(0x4000_0000 as *mut u8) }; *byte0 = 0x10; let byte1 = unsafe { &mut *(0x4000_1000 as *mut u8) }; *byte1 = 0x11; assert_eq!(*byte6, 0xFF); assert_eq!(*byte5, 0x01); println!("test end"); 0 }<|fim_prefix|>// repo: DaixuanL...
code_fim
medium
{ "lang": "rust", "repo": "DaixuanLi/UndergradCourseProject", "path": "/OperatingSystem_Rust/usr/rust/src/bin/page_replace_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn finds_closest_returns_itself_when_appropriate() { let entity_id = EntityId::new(1024, 0); let center_pos = WorldPosition { room: Axial::new(0, 0), pos: Axial::new(14, 14), }; let expected_id = EntityId::new(2040, 0); let e...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/simulation/src/scripting_api/find_api.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> storage: &World, position: WorldPosition, filter: F, ) -> Result<Option<EntityId>, ExecutionError> where F: Fn(EntityId) -> bool, { let WorldPosition { room, pos } = position; let entities_by_pos = storage.view::<WorldPosition, EntityComponent>(); let room = entities_by_pos ...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/simulation/src/scripting_api/find_api.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kissmikijr/caolo-backend path: /sim/simulation/src/scripting_api/find_api.rs use super::*; use crate::components::{EntityComponent, PositionComponent}; use crate::indices::WorldPosition; use crate::profile; use crate::world::World; use cao_lang::{prelude::*, StrPointer}; use std::convert::TryFro...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/simulation/src/scripting_api/find_api.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Operation succeeded but provided output buffer is too small BufferTooSmall, /// The user-provided input is too large InputTooLarge, /// NitroSecureModule cannot fulfill request due to internal errors InternalError, } /// Operations that a NitroSecureModule should implement. ...
code_fim
hard
{ "lang": "rust", "repo": "donkersgoed/aws-nitro-enclaves-nsm-api", "path": "/nsm-io/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: donkersgoed/aws-nitro-enclaves-nsm-api path: /nsm-io/src/lib.rs // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 #![deny(missing_docs)] //! NitroSecurityModule IO //! # Overview //! This module contains the structure definitions t...
code_fim
hard
{ "lang": "rust", "repo": "donkersgoed/aws-nitro-enclaves-nsm-api", "path": "/nsm-io/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> u32, end: u32) -> String { if start > end {(end..=start) .map(|x|verse(x)) .rev() .collect::<Vec<String>>()} else {(start..=end) .map(|x|verse(x)) .collect::<Vec<String>>()} .join("\n") }<|fim_prefix|>// repo: goiw111/ex_rust path: /beer-s...
code_fim
hard
{ "lang": "rust", "repo": "goiw111/ex_rust", "path": "/beer-song/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goiw111/ex_rust path: /beer-song/src/lib.rs pub fn verse(n: u32) -> String { return format!("{} {}", match n { 1 => format!("1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around,"), i @ 2..=99 => format!("{0} bottles of bee...
code_fim
hard
{ "lang": "rust", "repo": "goiw111/ex_rust", "path": "/beer-song/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: killercup/rune path: /crates/rune/src/ast/expr_select.rs use crate::ast; use crate::ast::utils; use crate::{IntoTokens, Parse, ParseError, Parser}; use runestick::Span; /// A select expression that selects over a collection of futures. #[derive(Debug, Clone)] pub struct ExprSelect { /// The...
code_fim
hard
{ "lang": "rust", "repo": "killercup/rune", "path": "/crates/rune/src/ast/expr_select.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl IntoTokens for ExprSelectBranch { fn into_tokens(&self, context: &mut crate::MacroContext, stream: &mut crate::TokenStream) { self.pat.into_tokens(context, stream); self.eq.into_tokens(context, stream); self.expr.into_tokens(context, stream); self.rocket.into_token...
code_fim
hard
{ "lang": "rust", "repo": "killercup/rune", "path": "/crates/rune/src/ast/expr_select.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let queue: Arc<MsQueue<String>> = Arc::new(MsQueue::new()); let redis_producer_queue = queue.clone(); let listener = thread::spawn(move || { let channel = "suricata"; let client = Client::open("redis://10.0.0.13/").unwrap(); let mut pubsub = client.get_pub...
code_fim
hard
{ "lang": "rust", "repo": "ndenev/eve-rust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ndenev/eve-rust path: /src/main.rs extern crate crossbeam; extern crate chrono; extern crate docopt; extern crate redis; extern crate serde; extern crate serde_json; use std::thread; use std::sync::Arc; use std::net::IpAddr; use std::str::FromStr; use crossbeam::sync::MsQueue; use chrono::DateT...
code_fim
hard
{ "lang": "rust", "repo": "ndenev/eve-rust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let file_producer_queue = queue.clone(); let reader = thread::spawn(move || { return; let eve_file = File::open("eve.json").unwrap(); let mut eve_reader = BufReader::new(&eve_file); for event in eve_reader.lines() { file_producer_queue.push(event.unwrap...
code_fim
hard
{ "lang": "rust", "repo": "ndenev/eve-rust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Io for MaybeHttpsStream { #[inline] fn poll_read(&mut self) -> Async<()> { match *self { MaybeHttpsStream::Http(ref mut s) => s.poll_read(), MaybeHttpsStream::Https(ref mut s) => s.poll_read(), } } #[inline] fn poll_write(&mut self) -> Asyn...
code_fim
hard
{ "lang": "rust", "repo": "alexcrichton/hyper-tls", "path": "/src/stream.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexcrichton/hyper-tls path: /src/stream.rs use std::fmt; use std::io::{self, Read, Write}; use futures::Async; use tokio_core::io::Io; use tokio_core::net::TcpStream; use tokio_tls::TlsStream; /// A stream that might be protected with TLS. pub enum MaybeHttpsStream { /// A stream over pla...
code_fim
hard
{ "lang": "rust", "repo": "alexcrichton/hyper-tls", "path": "/src/stream.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ozerovandrei/selectel-mks-cli path: /src/task.rs use anyhow::{bail, Context, Result}; use selectel_mks::task; use selectel_mks::Client; use term_table::row::Row; use term_table::table_cell::{Alignment, TableCell}; use term_table::{Table, TableStyle}; use crate::json; pub(crate) fn get(client: ...
code_fim
hard
{ "lang": "rust", "repo": "ozerovandrei/selectel-mks-cli", "path": "/src/task.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> table.add_row(Row::new(vec![ TableCell::new(&task.id), TableCell::new(&task.started_at.to_rfc3339()), TableCell::new(updated_at), TableCell::new(&task.task_type), TableCell::new(&task.status), ])); } println!("{}", table....
code_fim
hard
{ "lang": "rust", "repo": "ozerovandrei/selectel-mks-cli", "path": "/src/task.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut sig: i8 = 0; let mut unsig: u8 = 0; sig += 127; unsig += 255; assert!(sig == i8::max_value() && unsig == u8::max_value()); } // Like any variable in Rust, integers are immutable unless declared otherwise #[test] fn mutating_ints() { let mut num: i8 = 1; num += 2; a...
code_fim
hard
{ "lang": "rust", "repo": "bravmi/rust-koans", "path": "/src/koans/integer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bravmi/rust-koans path: /src/koans/integer.rs // As the name implies, unsigned integers (u8, u16, u32, u64) cannot be negative #[test] fn unsigned_ints() { assert!(u8::min_value() == 0); } // Unsigned integers can be reduced only as far as their minimum value of 0 #[test] fn sub_unsigned_in...
code_fim
hard
{ "lang": "rust", "repo": "bravmi/rust-koans", "path": "/src/koans/integer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: renxingliang/pam_groupmap path: /src/config.rs use std::fs::File; use std::io; use std::io::prelude::*; use toml; use std::collections::BTreeMap; // Connection and Operation timeouts in seconds. const LDAP_CONN_TIMEOUT: u64 = 2; const LDAP_OP_TIMEOUT: u64 = 5; #[derive(Debug)] pub struct Confi...
code_fim
hard
{ "lang": "rust", "repo": "renxingliang/pam_groupmap", "path": "/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> LDAP_CONN_TIMEOUT } fn default_op_timeout() -> u64 { LDAP_OP_TIMEOUT } #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct Config { pub ldap: LdapConfig, pub mappings: Mappings, } #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct LdapConfig { ...
code_fim
medium
{ "lang": "rust", "repo": "renxingliang/pam_groupmap", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct Config { pub ldap: LdapConfig, pub mappings: Mappings, } #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct LdapConfig { pub uri: String, pub user: String, pub pass: String, #[serde(default ...
code_fim
hard
{ "lang": "rust", "repo": "renxingliang/pam_groupmap", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: therobertc/escrow-program path: /rust/src/instruction.rs use { crate::state::{EscrowExecute, EscrowReceive}, borsh::{BorshDeserialize, BorshSerialize}, }; #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, Debug, Clone)] pub struct InitEscrowArgs { pub data: EscrowReceive, } #[repr(C)...
code_fim
hard
{ "lang": "rust", "repo": "therobertc/escrow-program", "path": "/rust/src/instruction.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }