text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: szhongren/leetcode path: /rename_folders.rs use std::env; use std::fs::{read_dir, rename}; use std::path::PathBuf; fn main() -> std::io::Result<()> { <|fim_suffix|>fn remove_padding(folder: &str) -> &str { // pass ref to str immutably folder.trim_start_matches('0') }<|fim_middle|> let cu...
code_fim
hard
{ "lang": "rust", "repo": "szhongren/leetcode", "path": "/rename_folders.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> t.shift_char(); // check for ?: (non capturing group) let noncapturing = { if (t.len() > 1) { t.char_at(0) == '?' && t.char_at(1) == ':' } else { false } }; // adjust if (noncapturing) { ...
code_fim
hard
{ "lang": "rust", "repo": "devin909/regex-rust-file", "path": "/parse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: devin909/regex-rust-file path: /parse.rs use state::ParseState; use state::CharClass; use error::ParseError::*; // add functionality to // build in ~str to shift a number // of characters from the beginning trait RegexInputStr { fn shiftn_char(&mut self, times: uint); } impl RegexInputStr f...
code_fim
hard
{ "lang": "rust", "repo": "devin909/regex-rust-file", "path": "/parse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> macro_rules! test_parse( ($input: expr, $expect: pat) => ( { let mut ps = ParseState::new(); let ok = match parse_recursive(&mut $input, &mut ps) { $expect => true, _ => false }; //ps.trace(); assert!(ok); } ); ) #[te...
code_fim
hard
{ "lang": "rust", "repo": "devin909/regex-rust-file", "path": "/parse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn json_is_FORWARD_message(json: &str) -> bool { json.starts_with("{\"FORWARD\":") } pub fn json_is_GOSSIP_message(json: &str) -> bool { json.starts_with("{\"GOSSIP\":") } pub fn json_is_SCDGOSSIP_message(json: &str) -> bool { json.starts_with("{\"SCDGOSSIP\":") }<|fim_prefix|>// repo: ...
code_fim
medium
{ "lang": "rust", "repo": "eladschiller/self-stabilizing-cloud", "path": "/self-stabilizing-communication-abstractions/application/src/scd/messages.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn print_character_class(character: char) { if character.is_alphabetic() { println!("Alphabetical!"); } else if character.is_numeric() { println!("Numerical!"); } else { println!("Neither alphabetic nor numeric!"); } }<|fim_prefix|>// repo: simongibbons/rustlings p...
code_fim
medium
{ "lang": "rust", "repo": "simongibbons/rustlings", "path": "/primitive_types/primitive_types2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if character.is_alphabetic() { println!("Alphabetical!"); } else if character.is_numeric() { println!("Numerical!"); } else { println!("Neither alphabetic nor numeric!"); } }<|fim_prefix|>// repo: simongibbons/rustlings path: /primitive_types/primitive_types2.rs //...
code_fim
medium
{ "lang": "rust", "repo": "simongibbons/rustlings", "path": "/primitive_types/primitive_types2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simongibbons/rustlings path: /primitive_types/primitive_types2.rs // Fill in the rest of the line that has code missing! // No hints, there's no tricks, just get used to typing these :) <|fim_suffix|> let my_first_initial = 'C'; print_character_class(my_first_initial); let your_char...
code_fim
medium
{ "lang": "rust", "repo": "simongibbons/rustlings", "path": "/primitive_types/primitive_types2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MarinPostma/AOC2020 path: /src/day_8.rs use std::collections::HashSet; const INPUT: &str = include_str!("../inputs/day8.txt"); fn parse_pgm(input: &str) -> impl Iterator<Item=(&str, isize)> { input .lines() .map(|s| { let (inst, val) = s.split_at(3); ...
code_fim
hard
{ "lang": "rust", "repo": "MarinPostma/AOC2020", "path": "/src/day_8.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sample = r#"nop +0 acc +1 jmp +4 acc +3 jmp -3 acc -99 acc +1 jmp -4 acc +6"#; assert_eq!(day8(sample), 5); assert_eq!(day8(INPUT), 2025); } #[test] fn test_day8_pt2() { let sample = r#"nop +0 acc +1 jmp +4 acc +3 jmp -3 acc -99 acc +1 jmp -4 acc +6"#; ...
code_fim
hard
{ "lang": "rust", "repo": "MarinPostma/AOC2020", "path": "/src/day_8.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let tokens = Box::new(tok::tokenize(&contents)); match filter::parse_Filter(&Arc::new(resolved_file_path.to_owned()), tokens.into_iter()) { Ok(ref filter) => { let transform_result = filter.transform_begin(ctx.scope.clone(), ...
code_fim
hard
{ "lang": "rust", "repo": "stkfd/poe-superfilter", "path": "/src/ast/import.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stkfd/poe-superfilter path: /src/ast/import.rs use ast::{AstLocation, TransformedNode, Comment}; use ast::transform::{Transform, TransformContext}; use filter; use tok; use std::io::Read; use std::fs; use std::rc::Rc; use std::sync::Arc; use errors::{Result, ResultExt, ErrorKind, Error}; <|fim_...
code_fim
hard
{ "lang": "rust", "repo": "stkfd/poe-superfilter", "path": "/src/ast/import.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(TransformedNode::Root(ref nodes)) = transform_result.unwrap() { return Ok(Some( TransformedNode::ExpandedNodes( nodes.to_owned() ) )); ...
code_fim
hard
{ "lang": "rust", "repo": "stkfd/poe-superfilter", "path": "/src/ast/import.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // delete the first entity world.run(|mut all_storages: AllStoragesViewMut| { assert!(all_storages.delete_entity(entity_id0)); }); // add 2 more world.run( |(mut entities, mut u32s): (EntitiesViewMut, ViewMut<U32>)| { let entity_id2 = entities.add_entity(&m...
code_fim
medium
{ "lang": "rust", "repo": "leudz/shipyard", "path": "/tests/serde/entity_id.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leudz/shipyard path: /tests/serde/entity_id.rs use shipyard::*; struct U32(u32); impl Component for U32 {} #[test] fn entity_id_serde() { let world = World::default(); // create and check a couple entities let (entity_id0, _) = world.run( |(mut entities, mut u32s): (Entiti...
code_fim
hard
{ "lang": "rust", "repo": "leudz/shipyard", "path": "/tests/serde/entity_id.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Logical OR of all ERR status bits\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum VLD_A { #[doc = "0: No ERR bits are set."] _0 = 0, #[doc = "1: At least one ERR bit is set indicating a valid error exists that has not been cleared."] ...
code_fim
hard
{ "lang": "rust", "repo": "sindrehan/mkl82z7-pac", "path": "/src/dma/es.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sindrehan/mkl82z7-pac path: /src/dma/es.rs DBE_A { match self.bits { false => DBE_A::_0, true => DBE_A::_1, } } #[doc = "Checks if the value of the field is `_0`"] #[inline(always)] pub fn is_0(&self) -> bool { **self == DBE_A::_0 ...
code_fim
hard
{ "lang": "rust", "repo": "sindrehan/mkl82z7-pac", "path": "/src/dma/es.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Field `ECX` reader - Transfer Canceled"] pub struct ECX_R(crate::FieldReader<bool, ECX_A>); impl ECX_R { pub(crate) fn new(bits: bool) -> Self { ECX_R(crate::FieldReader::new(bits)) } #[doc = r"Get enumerated values variant"] #[inline(alw...
code_fim
hard
{ "lang": "rust", "repo": "sindrehan/mkl82z7-pac", "path": "/src/dma/es.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aresbit/yarve path: /src/test/test_bus.rs #[cfg(test)] mod test_bus { use crate::bus::Bus; use crate::dram::DRAM; use crate::device::Device; use crate::endianness::Endianness; #[test] fn test_bus_get_device_and_get_address_space_size() { let mut dram = DRAM::new...
code_fim
hard
{ "lang": "rust", "repo": "aresbit/yarve", "path": "/src/test/test_bus.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> bus.write_bytes(6, &[0x21, 0x22, 0x23, 0x24, 0x25]).unwrap(); assert_eq!( bus.read_bytes(5, 16).unwrap(), [ 0x10, 0x21, 0x22, 0x23, 0x24, 0x25, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F ] ); ...
code_fim
hard
{ "lang": "rust", "repo": "aresbit/yarve", "path": "/src/test/test_bus.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_write_bytes() { let mut dram = DRAM::new(16); match dram.write_bytes(0, &[ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F]) { Ok(()) => {}, Err(e) => { panic!("PANIC {:?...
code_fim
hard
{ "lang": "rust", "repo": "aresbit/yarve", "path": "/src/test/test_bus.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: be-cash/iguana path: /iguana/src/script.rs use bitcoin_cash::{TaggedOp, Opcode, serialize_op}; use wasm_bindgen::prelude::*; use crate::ByteArray; use std::sync::Arc; #[wasm_bindgen] pub struct Script { ops: Arc<[TaggedOp]>, } #[wasm_bindgen] pub struct Op { ops: Arc<[TaggedOp]>, i...
code_fim
hard
{ "lang": "rust", "repo": "be-cash/iguana", "path": "/iguana/src/script.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[wasm_bindgen(js_name = srcLine)] pub fn src_line(&self) -> u32 { self.tagged_op().src_line } #[wasm_bindgen(js_name = srcColumn)] pub fn src_column(&self) -> u32 { self.tagged_op().src_column } #[wasm_bindgen(js_name = srcCode)] pub fn src_code(&self...
code_fim
hard
{ "lang": "rust", "repo": "be-cash/iguana", "path": "/iguana/src/script.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[wasm_bindgen(js_name = srcColumn)] pub fn src_column(&self) -> u32 { self.tagged_op().src_column } #[wasm_bindgen(js_name = srcCode)] pub fn src_code(&self, max_width: u32) -> Option<String> { self.tagged_op().src_code.iter().filter_map(|&(width, ref src)| { ...
code_fim
hard
{ "lang": "rust", "repo": "be-cash/iguana", "path": "/iguana/src/script.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> aligned_size += range.1; } let mut seals = MemfdSeals::new(); seals.set_shrink_seal(); seals.set_grow_seal(); seals.set_seal_seal(); let mut shm = SharedMemory::named("crosvm_guest", aligned_size) .map_err(Error::MemoryCreationFail...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/vm_memory/src/guest_memory.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgreid/crosvm path: /vm_memory/src/guest_memory.rs create_shm(ranges)?); // Create memory regions let mut regions = Vec::<MemoryRegion>::new(); let mut offset = 0; for range in ranges { if let Some(last) = regions.last() { if last ...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/vm_memory/src/guest_memory.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgreid/crosvm path: /vm_memory/src/guest_memory.rs /// let start_addr = GuestAddress(0x1000); /// let mut gm = GuestMemory::new(&vec![(start_addr, 0x400)]).map_err(|_| ())?; /// assert_eq!(start_addr.checked_add(0x400), Some(gm.end_addr())); /// Ok(()) /// # } ...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/vm_memory/src/guest_memory.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Swynfel/rust-catan path: /catan/src/board/mod.rs mod error; pub mod utils; pub mod map; pub<|fim_suffix|>::Layout; pub use error::Error; pub use utils::{Coord, CoordType, DetailedCoordType};<|fim_middle|> mod layout; pub mod setup; pub use layout
code_fim
easy
{ "lang": "rust", "repo": "Swynfel/rust-catan", "path": "/catan/src/board/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>::Layout; pub use error::Error; pub use utils::{Coord, CoordType, DetailedCoordType};<|fim_prefix|>// repo: Swynfel/rust-catan path: /catan/src/board/mod.rs mod error; pub mod utils; pub mod map; pub<|fim_middle|> mod layout; pub mod setup; pub use layout
code_fim
easy
{ "lang": "rust", "repo": "Swynfel/rust-catan", "path": "/catan/src/board/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Swynfel/rust-catan path: /catan/src/board/mod.rs mod error; pub mod utils; pub mod map; pub mod layout; pub mod setup; pub use layout<|fim_suffix|>ils::{Coord, CoordType, DetailedCoordType};<|fim_middle|>::Layout; pub use error::Error; pub use ut
code_fim
easy
{ "lang": "rust", "repo": "Swynfel/rust-catan", "path": "/catan/src/board/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JeffreyRiggle/enigma-wasm path: /enigmarust/enigmawasm/src/enigma.rs pub use plugboard::Plugboard; pub use rotor::Rotor; pub use config::{Config, MachineConfig}; extern crate serde_json; pub struct Enigma { plugboard: Plugboard, rotors: Vec<Rotor>, reflector_map: Vec<String> } impl...
code_fim
hard
{ "lang": "rust", "repo": "JeffreyRiggle/enigma-wasm", "path": "/enigmarust/enigmawasm/src/enigma.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut iter = self.rotors.iter_mut(); let rotor1 = iter.next().unwrap(); &rotor1.move_rotor(); let rotor2 = iter.next().unwrap(); if rotor2.step != rotor2.position { return; } &rotor2.move_rotor(); let rotor3 = iter.next().unw...
code_fim
hard
{ "lang": "rust", "repo": "JeffreyRiggle/enigma-wasm", "path": "/enigmarust/enigmawasm/src/enigma.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaykh-qasim/Assignments path: /Quarter 1/4/q3/src/main.rs fn main() { let number = 5; let receive = square(number); println!("The square is : {:?}",receive); } <|fim_suffix|> println!("The number is : {}",val); (val * val) }<|fim_middle|>fn square(val: i64) -> (i64) {
code_fim
easy
{ "lang": "rust", "repo": "shaykh-qasim/Assignments", "path": "/Quarter 1/4/q3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("The number is : {}",val); (val * val) }<|fim_prefix|>// repo: shaykh-qasim/Assignments path: /Quarter 1/4/q3/src/main.rs fn main() { let number = 5; let receive = square(number); println!("The square is : {:?}",receive); } <|fim_middle|>fn square(val: i64) -> (i64) {
code_fim
easy
{ "lang": "rust", "repo": "shaykh-qasim/Assignments", "path": "/Quarter 1/4/q3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yusuke-eto/nock path: /nock03/src/main.rs fn main() { let str = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."; let splitted_str = str.replace(",", "").replace(".", ""); let wo<|fim_suffix|>(); for word in words { result.p...
code_fim
medium
{ "lang": "rust", "repo": "yusuke-eto/nock", "path": "/nock03/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>(); for word in words { result.push(word.len()); } println!("{:?}", result); }<|fim_prefix|>// repo: yusuke-eto/nock path: /nock03/src/main.rs fn main() { let str = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."; let splitted_s...
code_fim
medium
{ "lang": "rust", "repo": "yusuke-eto/nock", "path": "/nock03/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init(cfg: &Arc<Config>) -> (Gossip, GossipInit) { let (tx, rx) = channel(); let info = Arc::new(Mutex::new(Info::new())); return ( public::new(tx, &info), GossipInit { receiver: rx, info: info, config: cfg.clone(), } ); } ...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/cantal", "path": "/src/gossip/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tailhook/cantal path: /src/gossip/mod.rs mod config; mod proto; mod errors; mod peer; mod info; mod command; mod public; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; use std::time::Duration; use futures::Future; use futures::stream::Stream; use futures::sync::mpsc::{unbounded as chan...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/cantal", "path": "/src/gossip/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct GossipInit { receiver: UnboundedReceiver<command::Command>, info: Arc<Mutex<Info>>, config: Arc<Config>, } pub fn init(cfg: &Arc<Config>) -> (Gossip, GossipInit) { let (tx, rx) = channel(); let info = Arc::new(Mutex::new(Info::new())); return ( public::new(tx, &...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/cantal", "path": "/src/gossip/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> }; ($e:expr) => { try_or_print!($e, "Error: {error}") }; }<|fim_prefix|>// repo: StriderDM/tari path: /applications/tari_base_node/src/macros.rs macro_rules! try_or_print { ($e:expr, $($arg:tt)*) => { match $e { Ok(v) => v, Err(err) => { ...
code_fim
medium
{ "lang": "rust", "repo": "StriderDM/tari", "path": "/applications/tari_base_node/src/macros.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StriderDM/tari path: /applications/tari_base_node/src/macros.rs macro_rules! try_or_print { ($e:expr, $($arg:tt)*) => { match $<|fim_suffix|>n!($($arg)*, error=err); return; }, } }; ($e:expr) => { try_or_print!($e, "Error: {error}")...
code_fim
medium
{ "lang": "rust", "repo": "StriderDM/tari", "path": "/applications/tari_base_node/src/macros.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = Vec::new(); let mut slice = &bytes[..]; while result.len() < n_masks { let (these, remainder) = slice.split_at(8); let v64 = NetworkEndian::read_u64(these); if let Some(elt) = FE::from_u64_unbiased(v64) { result.p...
code_fim
hard
{ "lang": "rust", "repo": "teor2345/privcount_shamir", "path": "/rust/src/data.rs", "mode": "spm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_prefix|>// repo: teor2345/privcount_shamir path: /rust/src/data.rs use byteorder::{ByteOrder, NetworkEndian}; use crypto::digest::Digest; use crypto::sha3; use math::FE; #[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)] pub struct CtrId(pub u32); #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ClientK...
code_fim
hard
{ "lang": "rust", "repo": "teor2345/privcount_shamir", "path": "/rust/src/data.rs", "mode": "psm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_suffix|>ALWAYS_SEND_NUM_R::new(((self.bits >> 4) & 0x07) as u8) } #[doc = "Bit 3"] #[inline(always)] pub fn single_send_en(&self) -> SINGLE_SEND_EN_R { SINGLE_SEND_EN_R::new(((self.bits >> 3) & 0x01) != 0) } #[doc = "Bits 0:2"] #[inline(always)] pub fn single_send_num(&self...
code_fim
hard
{ "lang": "rust", "repo": "ForsakenHarmony/esp32c3-pac", "path": "/src/uhci/quick_sent.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/uhci/quick_sent.rs #[doc = "Reader of register QUICK_SENT"] pub type R = crate::R<u32, super::QUICK_SENT>; #[doc = "Writer for register QUICK_SENT"] pub type W = crate::W<u32, super::QUICK_SENT>; #[doc = "Register QUICK_SENT `reset()`'s with value 0"] impl ...
code_fim
hard
{ "lang": "rust", "repo": "ForsakenHarmony/esp32c3-pac", "path": "/src/uhci/quick_sent.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); self.w } } #[doc = "Reader of field `SINGLE_SEND_NUM...
code_fim
hard
{ "lang": "rust", "repo": "ForsakenHarmony/esp32c3-pac", "path": "/src/uhci/quick_sent.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl DummySmsSender { pub fn new() -> DummySmsSender { DummySmsSender { sms_messages_sent: Mutex::new(Vec::new()), } } } #[async_trait] impl SmsSender for DummySmsSender { async fn send(&self, phone_number: String, code: String) -> Result<(), Error> { match...
code_fim
medium
{ "lang": "rust", "repo": "kaanaslanyuksek/priv-ic", "path": "/backend/external/verification_code_sender/cli/src/dummy_sms_sender.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaanaslanyuksek/priv-ic path: /backend/external/verification_code_sender/cli/src/dummy_sms_sender.rs use async_trait::async_trait; use std::borrow::BorrowMut; use std::sync::Mutex; use types::Error; use verification_code_sender::sms_sender::SmsSender; <|fim_suffix|>impl DummySmsSender { pub...
code_fim
medium
{ "lang": "rust", "repo": "kaanaslanyuksek/priv-ic", "path": "/backend/external/verification_code_sender/cli/src/dummy_sms_sender.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait] impl SmsSender for DummySmsSender { async fn send(&self, phone_number: String, code: String) -> Result<(), Error> { match self.sms_messages_sent.lock() { Ok(mut mutex) => { mutex.borrow_mut().push((phone_number, code)); Ok(()) ...
code_fim
medium
{ "lang": "rust", "repo": "kaanaslanyuksek/priv-ic", "path": "/backend/external/verification_code_sender/cli/src/dummy_sms_sender.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mellowagain/darwin-libproc path: /darwin-libproc-sys/src/generated.rs assert_eq!( unsafe { &(*(::std::ptr::null::<rusage_info_v0>())).ri_pageins as *const _ as usize }, 48usize, concat!( "Offset of field: ", stri...
code_fim
hard
{ "lang": "rust", "repo": "mellowagain/darwin-libproc", "path": "/darwin-libproc-sys/src/generated.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( ::std::mem::size_of::<rusage_info_v2>(), 160usize, concat!("Size of: ", stringify!(rusage_info_v2)) ); assert_eq!( ::std::mem::align_of::<rusage_info_v2>(), 8usize, concat!("Alignment of ", stringify!(rusage_info_v2)) ); asser...
code_fim
hard
{ "lang": "rust", "repo": "mellowagain/darwin-libproc", "path": "/darwin-libproc-sys/src/generated.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mellowagain/darwin-libproc path: /darwin-libproc-sys/src/generated.rs Y: u32 = 2; pub const PROC_TTY_ONLY: u32 = 3; pub const PROC_UID_ONLY: u32 = 4; pub const PROC_RUID_ONLY: u32 = 5; pub const PROC_PPID_ONLY: u32 = 6; pub const PROC_KDBG_ONLY: u32 = 7; pub const PROC_FLAG_SYSTEM: u32 = 1; pub ...
code_fim
hard
{ "lang": "rust", "repo": "mellowagain/darwin-libproc", "path": "/darwin-libproc-sys/src/generated.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Start Pool Restart let mut request = pool .request_builder() .build_pool_restart_request(&trustee.did, "start", Some(&_datetime())) .unwrap(); let _response = helpers::sign_and_send_request(&trustee, &pool, &mut request).unwrap(); //...
code_fim
hard
{ "lang": "rust", "repo": "hyperledger/indy-vdr", "path": "/libindy_vdr/tests/pool_restart.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hyperledger/indy-vdr path: /libindy_vdr/tests/pool_restart.rs #[macro_use] mod utils; inject_dependencies!(); use indy_vdr::ledger::constants; use indy_vdr::utils::did::DidValue; use crate::utils::fixtures::*; #[test] fn empty() { // Empty test to run module } fn _datetime() -> String {...
code_fim
hard
{ "lang": "rust", "repo": "hyperledger/indy-vdr", "path": "/libindy_vdr/tests/pool_restart.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let _response = helpers::sign_and_send_request(&trustee, &pool, &mut request).unwrap(); // Cancel Pool Restart let mut request = pool .request_builder() .build_pool_restart_request(&trustee.did, "cancel", None) .unwrap(); let _response ...
code_fim
hard
{ "lang": "rust", "repo": "hyperledger/indy-vdr", "path": "/libindy_vdr/tests/pool_restart.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>y::builder().timeout(duration).build() }<|fim_prefix|>// repo: ericswanson-dfinity/agent-rs path: /ic-asset/src/convenience.rs use garcon::Delay; use std::time::Durat<|fim_middle|>ion; pub(crate) fn waiter_with_timeout(duration: Duration) -> Delay { Dela
code_fim
medium
{ "lang": "rust", "repo": "ericswanson-dfinity/agent-rs", "path": "/ic-asset/src/convenience.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>duration: Duration) -> Delay { Delay::builder().timeout(duration).build() }<|fim_prefix|>// repo: ericswanson-dfinity/agent-rs path: /ic-asset/src/convenience.rs use garcon::Delay; use std::time::Durat<|fim_middle|>ion; pub(crate) fn waiter_with_timeout(
code_fim
easy
{ "lang": "rust", "repo": "ericswanson-dfinity/agent-rs", "path": "/ic-asset/src/convenience.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ericswanson-dfinity/agent-rs path: /ic-asset/src/convenience.rs use garcon::Delay; use std::time::Duration; pub(crate) fn waiter_with_timeout(<|fim_suffix|>y::builder().timeout(duration).build() }<|fim_middle|>duration: Duration) -> Delay { Dela
code_fim
easy
{ "lang": "rust", "repo": "ericswanson-dfinity/agent-rs", "path": "/ic-asset/src/convenience.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn hvif_style_gradient_color_rgb_parser(input: &[u8], flags: u8) -> IResult<&[u8], (u8, u8, u8)> { let grayscale = HVIF_GRADIENT_FLAG_GRAYS.is_set_on(flags); let p = match grayscale { true => hvif_style_gradient_color_rgb_grays, false => hvif_style_gradient_color_rgb_nongrays, }; p(input) ...
code_fim
hard
{ "lang": "rust", "repo": "Lacaranian/hvif-rs", "path": "/src/parser/style.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn hvif_style_gradient_color_parser(input: &[u8], flags: u8) -> IResult<&[u8], HVIFGradientColor> { let (i1, so) = try_parse!(input, be_u8); let (i2, (r, g, b)) = try_parse!(i1, apply!(hvif_style_gradient_color_rgb_parser, flags)); let (i3, a) = try_parse!(i2, apply!(hvif_style_gradient_color_alpha_...
code_fim
hard
{ "lang": "rust", "repo": "Lacaranian/hvif-rs", "path": "/src/parser/style.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lacaranian/hvif-rs path: /src/parser/style.rs //! Parser for HVIF styles use nom::*; use types::*; named_attr!(#[doc = "Parses an HVIF style"], pub hvif_style<&[u8], HVIFStyle>, do_parse!( style_type: be_u8 >> style: apply!(style_type_to_parser, style_type) >> (style) ) ); fn s...
code_fim
hard
{ "lang": "rust", "repo": "Lacaranian/hvif-rs", "path": "/src/parser/style.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/relibc path: /src/platform/auxv_defs.rs pub const AT_NULL: usize = 0; /* End of vector */ pub const AT_IGNORE: usize = 1; /* Entry should be ignored */ pub const AT_EXECFD: usize = 2; /* File descriptor of program */ pub const AT_PHDR: usize = 3; /* Program headers for program */ pub co...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/relibc", "path": "/src/platform/auxv_defs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ying platform. */ pub const AT_HWCAP: usize = 16; /* Machine-dependent hints about */ pub const AT_FPUCW: usize = 18; /* Used FPU control word. */ pub const AT_DCACHEBSIZE: usize = 19; /* Data cache block size. */ pub const AT_ICACHEBSIZE: usize = 20; /* Instruction cache block size. */ pub const AT_U...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/relibc", "path": "/src/platform/auxv_defs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ing identifying real platforms.*/ pub const AT_RANDOM: usize = 25; /* Address of 16 random bytes. */ pub const AT_HWCAP2: usize = 26; /* More machine-dependent hints about*/ pub const AT_EXECFN: usize = 31; /* Filename of executable. */ #[cfg(target_os = "redox")] // XXX: The name AT_CWD is already use...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/relibc", "path": "/src/platform/auxv_defs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qeedquan/challenges path: /codegolf/numpad-word-search.rs /* Given an integer from 1 to 999 inclusive, output a truthy value if it appears horizontally, vertically, or diagonally, either forwards or backwards, anywhere in the 3x3 square of digits 1-9 on a standard number pad: 789 456 123 If th...
code_fim
hard
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/codegolf/numpad-word-search.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let vals = vec![ 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 14, 15, 21, 23, 24, 25, 26, 32, 35, 36, 41, 42, 45, 47, 48, 51, 52, 53, 54, 56, 57, 58, 59, 62, 63, 65, 68, 69, 74, 75, 78, 84, 85, 86, 87, 89, 95, 96, 98, 123, 147, 159, 258, 321, 357, 369, 456, 654, 741, 753, 789, 852, 951, 963,...
code_fim
hard
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/codegolf/numpad-word-search.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn numpad(x: isize) -> bool { let vals = vec![ 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 14, 15, 21, 23, 24, 25, 26, 32, 35, 36, 41, 42, 45, 47, 48, 51, 52, 53, 54, 56, 57, 58, 59, 62, 63, 65, 68, 69, 74, 75, 78, 84, 85, 86, 87, 89, 95, 96, 98, 123, 147, 159, 258, 321, 357, 369, 456, 654,...
code_fim
hard
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/codegolf/numpad-word-search.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> called_rule_stack.insert(target.get_rule_index()); self.look_work( target, stop_state, Some(new_ctx), look, look_busy, cal...
code_fim
hard
{ "lang": "rust", "repo": "xiaming9880/antlr4rust", "path": "/src/ll1_analyzer.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xiaming9880/antlr4rust path: /src/ll1_analyzer.rs use std::collections::HashSet; use std::ops::Deref; use std::sync::Arc; use bit_set::BitSet; use crate::atn::ATN; use crate::atn_config::ATNConfig; use crate::atn_state::{ATNState, ATNStateType}; use crate::interval_set::IntervalSet; use crate:...
code_fim
hard
{ "lang": "rust", "repo": "xiaming9880/antlr4rust", "path": "/src/ll1_analyzer.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: khayliang/fe2o3-cc path: /src/tokenizer.rs // TODO: Use Number token instead of Integer to support decimals #[derive(Debug, PartialEq, Clone)] pub enum Token<'a> { Keyword(&'a str), Identifier(&'a str), Integer(&'a str), OpenBrace, CloseBrace, OpenBracket, CloseBracke...
code_fim
hard
{ "lang": "rust", "repo": "khayliang/fe2o3-cc", "path": "/src/tokenizer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// TODO: cleanup tokenize function pub fn tokenize(code: &str) -> Vec<Token> { let mut tokens: Vec<Token> = Vec::new(); let mut found_token: bool = false; let mut token_start: usize = 0; for (idx, ch) in code.chars().enumerate() { if ch.is_whitespace() { if found_token...
code_fim
hard
{ "lang": "rust", "repo": "khayliang/fe2o3-cc", "path": "/src/tokenizer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cbreeden/fontkit path: /src/table/mod.rs // pub mod maxp; use primitives::Tag; /// Tagged tables are tables that are accessed from the Font. pub trait TaggedTable<'tbl> { fn tag() -> Tag; } <|fim_suffix|> Tag($tag) } } )* ) }<|fim_middle|>mac...
code_fim
medium
{ "lang": "rust", "repo": "cbreeden/fontkit", "path": "/src/table/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cbreeden/fontkit path: /src/table/mod.rs // pub mod maxp; use primitives::Tag; <|fim_suffix|>macro_rules! impl_tagged_table { ($($name:ty => $tag:expr),* $(,)*) => ( $( impl<'tbl> TaggedTable<'tbl> for $name { fn tag() -> Tag { Tag($tag) ...
code_fim
medium
{ "lang": "rust", "repo": "cbreeden/fontkit", "path": "/src/table/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Tag($tag) } } )* ) }<|fim_prefix|>// repo: cbreeden/fontkit path: /src/table/mod.rs // pub mod maxp; use primitives::Tag; <|fim_middle|>/// Tagged tables are tables that are accessed from the Font. pub trait TaggedTable<'tbl> { fn tag() -> Tag; } mac...
code_fim
hard
{ "lang": "rust", "repo": "cbreeden/fontkit", "path": "/src/table/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // The neighbor validator that includes/excludes certain peers by applying custom criteria. let neighbor_validator = EntryNodeNeighborValidator::new(); // The peer store for persisting discovered peers. let mut peerstore_options = RocksDbPeerStoreConfigOptions::default(); peerstore_op...
code_fim
hard
{ "lang": "rust", "repo": "iotaledger/bee", "path": "/bee-node/bee-node/src/entrynode/builder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iotaledger/bee path: /bee-node/bee-node/src/entrynode/builder.rs // Copyright 2021-2022 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use std::{ any::{type_name, Any, TypeId}, collections::HashMap, convert::Infallible, }; use async_trait::async_trait; use bee_autopeering::{ ...
code_fim
hard
{ "lang": "rust", "repo": "iotaledger/bee", "path": "/bee-node/bee-node/src/entrynode/builder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: max-b/rusty-pi-2-fs path: /fat32/src/lib.rs #![feature(decl_macro)] #![feature(extern_prelude)] #![allow(safe_packed_borrows)] #![feature(vec_resize_default)] #![feature(nll)] <|fim_suffix|>#[cfg(test)] mod ebpb_tests; mod mbr; mod util; pub mod traits; pub mod vfat; pub use mbr::*;<|fim_mid...
code_fim
medium
{ "lang": "rust", "repo": "max-b/rusty-pi-2-fs", "path": "/fat32/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod mbr_tests; #[cfg(test)] mod ebpb_tests; mod mbr; mod util; pub mod traits; pub mod vfat; pub use mbr::*;<|fim_prefix|>// repo: max-b/rusty-pi-2-fs path: /fat32/src/lib.rs #![feature(decl_macro)] #![feature(extern_prelude)] #![allow(safe_packed_borrows)] #![feature(vec_resize_default)...
code_fim
easy
{ "lang": "rust", "repo": "max-b/rusty-pi-2-fs", "path": "/fat32/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gmadrid/itools path: /src/main.rs extern crate itools; use std::error::Error; use std::fs::File; use std::path::{Path, PathBuf}; use itools::neardups::{ bool_to_option, expand_file_list, new_counter, output::Output, Config, Hasher, ItoolsError, PersistedCache, Result, SpinnerReader, };...
code_fim
hard
{ "lang": "rust", "repo": "gmadrid/itools", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let files_to_hash = filter_files_in_cache(&files, &cache); let num_files = files_to_hash.len() as u64; let (hasher, agg_rx) = Hasher::run(files_to_hash); let pb = bool_to_option(config.show_progress, || new_counter(num_files)); cache.run(config.cache_file, agg_rx, pb); hasher.jo...
code_fim
hard
{ "lang": "rust", "repo": "gmadrid/itools", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: c000/vban-autogain path: /src/main.rs #[macro_use] extern crate clap; use clap::{App, Arg}; use std::net::ToSocketAddrs; use std::str::FromStr; use vban_autogain::app; fn main() { let socket_addrs_validator = |s: String| match s.to_socket_addrs() { Ok(_) => core::result::Result::Ok...
code_fim
hard
{ "lang": "rust", "repo": "c000/vban-autogain", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let gain_db = f32::from_str(matches.value_of("gain").unwrap()).unwrap(); let gain = 10.0_f32.powf(gain_db / 20.0_f32); let gain_max = f32::from_str(matches.value_of("gain_max").unwrap()).unwrap(); app::main(rx_addr, tx_addrs.as_ref(), gain, gain_max).unwrap(); }<|fim_prefix|>// repo: c00...
code_fim
hard
{ "lang": "rust", "repo": "c000/vban-autogain", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let rx_addr = matches.value_of("listen").unwrap(); let tx_addrs = matches .values_of("remote") .unwrap_or(clap::Values::default()) .collect::<std::boxed::Box<[_]>>(); let gain_db = f32::from_str(matches.value_of("gain").unwrap()).unwrap(); let gain = 10.0_f32.powf(...
code_fim
hard
{ "lang": "rust", "repo": "c000/vban-autogain", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-command/src/example_test.rs #[cfg(test)] use nu_protocol::engine::Command; #[cfg(test)] pub fn test_examples(cmd: impl Command + 'static) { test_examples::test_examples(cmd); } #[cfg(test)] mod test_examples { use super::super::{ Ansi, Date, Enu...
code_fim
hard
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/src/example_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let delta = { // Base functions that are needed for testing // Try to keep this working set small to keep tests running as fast as possible let mut working_set = StateWorkingSet::new(&engine_state); working_set.add_decl(Box::new(Ansi)); w...
code_fim
hard
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/src/example_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> prog_state: &ProgState, basket_name: String, remaining_accounts: &'a [AccountInfo<'a>], mut start_idx: usize, token_program_id: &Pubkey, spl_account: &AccountInfo<'a>, caller_account: &AccountInfo<'a>, rent_amount: u64, ) -> InvokeBasketResult { msg!("MALLOC LOG: INVOKI...
code_fim
hard
{ "lang": "rust", "repo": "Lev-Stambler/malloc-protocol", "path": "/program/src/processor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lev-Stambler/malloc-protocol path: /program/src/processor.rs //! Program state processor use crate::instruction::{ Basket, BasketEntry, ProgInstruction, ProgState, WCall, WCallEntry, WCallInputEntry, }; use solana_program::{ account_info::{next_account_info, AccountInfo}, entrypoint:...
code_fim
hard
{ "lang": "rust", "repo": "Lev-Stambler/malloc-protocol", "path": "/program/src/processor.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match instruction { ProgInstruction::NewCall { call_name: name, wcall_enum: wcall, } => { // not sure if its right let associated_accounts = &accounts[2..]; process_new_call( &mut prog_state, &n...
code_fim
hard
{ "lang": "rust", "repo": "Lev-Stambler/malloc-protocol", "path": "/program/src/processor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whoiscc/hulunbuir path: /src/slot.rs //! //! First of all, the "slot" below is not the same as the slot I mentioned in main module. //! Theoretically, instances of any type which implements `Keep` trait could be inserted //! into the slots of a collector, and the `Slot<T>` type provided by this ...
code_fim
hard
{ "lang": "rust", "repo": "whoiscc/hulunbuir", "path": "/src/slot.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match &self.0 { SlotPriv::Free(value) => value.with_keep(f), SlotPriv::Busy { keep, .. } => { for address in keep { f(address); } } } } } /// The result of trying to take an object out. pub enum Ta...
code_fim
hard
{ "lang": "rust", "repo": "whoiscc/hulunbuir", "path": "/src/slot.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::{ token::{Literal, Token, TokenKind}, Expr, }; #[test] fn test_ast_printer() { assert_eq!( "(* (- 123) (group 45.67))", Expr::Binary( Token::new(TokenKind::Star, "*".to_owned(), None, 1, 3),...
code_fim
hard
{ "lang": "rust", "repo": "owayss/rlox", "path": "/src/lox/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: owayss/rlox path: /src/lox/expr.rs use super::token; use std::fmt; #[derive(Debug, PartialEq, Clone)] pub enum Expr { Literal(token::Literal), Unary(token::Token, Box<Expr>), Binary(token::Token, Box<Expr>, Box<Expr>), Logical(token::Token, Box<Expr>, Box<Expr>), Grouping(Bo...
code_fim
hard
{ "lang": "rust", "repo": "owayss/rlox", "path": "/src/lox/expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(ss: &str) -> Result<Self, Self::Err> { lazy_static! { static ref RE: Regex = Regex::new(r"(\d+)\s+(\d+)\s+(\d+)\s+(\d+)").unwrap(); } match RE.captures(ss) { Some(caps) => { Ok(Instruction { opcode: Opcode...
code_fim
hard
{ "lang": "rust", "repo": "BafDyce/adventofcode", "path": "/2018/rust/snippets/snippets.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BafDyce/adventofcode path: /2018/rust/snippets/snippets.rs // ================================================================================================ // 2d array // ================================================================================================ // Read input into 2 dime...
code_fim
hard
{ "lang": "rust", "repo": "BafDyce/adventofcode", "path": "/2018/rust/snippets/snippets.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Coder-256/ruffle path: /core/src/avm2/events.rs //! Core event structure use crate::avm2::object::{Object, TObject}; use crate::avm2::string::AvmString; use gc_arena::Collect; use std::collections::{BTreeMap, HashMap}; use std::hash::{Hash, Hasher}; /// Which phase of event dispatch is current...
code_fim
hard
{ "lang": "rust", "repo": "Coder-256/ruffle", "path": "/core/src/avm2/events.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_target(&mut self, target: Object<'gc>) { self.target = Some(target) } pub fn current_target(&self) -> Option<Object<'gc>> { self.current_target } pub fn set_current_target(&mut self, current_target: Object<'gc>) { self.current_target = Some(current_...
code_fim
hard
{ "lang": "rust", "repo": "Coder-256/ruffle", "path": "/core/src/avm2/events.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Each metric has labels... we need to clone labels_map let has_lables = labels_map.len() > 0; let mut out = String::new(); let _total = msg.metrics.bucket.map.len(); for (_key, metric) in msg.metrics.bucket.map.iter_mut() { let key = vec![name.clone(...
code_fim
hard
{ "lang": "rust", "repo": "charlescerisier/tempest", "path": "/tempest/src/metric/backend/log.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charlescerisier/tempest path: /tempest/src/metric/backend/log.rs use crate::metric::backend::prelude::*; /// The backend for writing metrics /// to a Log using a configured log level #[allow(dead_code)] pub(crate) struct Log { prefix: Option<String>, log_level: log::Level, target: M...
code_fim
hard
{ "lang": "rust", "repo": "charlescerisier/tempest", "path": "/tempest/src/metric/backend/log.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut out = String::new(); let _total = msg.metrics.bucket.map.len(); for (_key, metric) in msg.metrics.bucket.map.iter_mut() { let key = vec![name.clone(), metric.names.join(&self.name_delimiter)] .join(&self.name_delimiter); out.push_st...
code_fim
hard
{ "lang": "rust", "repo": "charlescerisier/tempest", "path": "/tempest/src/metric/backend/log.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Just holds a [`RendererViewportBackend`]. pub(crate) struct RendererViewportContext { pub(crate) backend: Box<dyn RendererViewportBackend>, } impl RendererViewportContext { pub(crate) fn dummy() -> Self { Self { backend: Box::new(DummyRendererViewportBackend {}), }...
code_fim
hard
{ "lang": "rust", "repo": "burtonageo/imgui-rs", "path": "/imgui/src/platform_io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }