text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> quote! { #ident {#entries} , } } /// Enum match discriminator and dispatch code. pub fn dispatch_discriminator(&self) -> TokenStream { let ident = &self.ident; let enum_ident = to_pascal_case(ident); // Build match and call argument lists. let mut entr...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/remoc", "path": "/remoc_macro/src/method.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for claim in claims { for (x, y) in resolve_occupancy(claim) { let position = grid.entry((x, y)).or_insert(0); *position += 1; } } grid } #[aoc_generator(day3)] pub fn input_claims(input: &str) -> Vec<Claim> { let re = Regex::new(r"^#(\d+) @ (\d+),...
code_fim
hard
{ "lang": "rust", "repo": "arosspope/advent-of-code", "path": "/aoc_2018/src/day3.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arosspope/advent-of-code path: /aoc_2018/src/day3.rs //Day 3: No Matter How You Slice It // use regex::Regex; use std::collections::HashMap; #[derive(Debug, PartialEq)] pub struct Claim { id: usize, x: usize, y: usize, w: usize, h: usize, } // For a specific claim, find the...
code_fim
hard
{ "lang": "rust", "repo": "arosspope/advent-of-code", "path": "/aoc_2018/src/day3.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[aoc_generator(day3)] pub fn input_claims(input: &str) -> Vec<Claim> { let re = Regex::new(r"^#(\d+) @ (\d+),(\d+): (\d+)x(\d+)$").unwrap(); input .lines() .map(|l| { let caps: Vec<&str> = re .captures(l) .unwrap() .iter...
code_fim
hard
{ "lang": "rust", "repo": "arosspope/advent-of-code", "path": "/aoc_2018/src/day3.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut seen_decrease = false; let mut prevchar: Option<char> = None; for c in data.chars() { if let Some(pc) = prevchar { if c < pc { seen_decrease = true; break; } } prevchar = Some(c); } return !seen_dec...
code_fim
medium
{ "lang": "rust", "repo": "dkull/aoc2019", "path": "/day4/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn count_passwords(f: &i32, t: &i32) -> (i32, i32) { let mut p1_count = 0; let mut p2_count = 0; for i in *f..*t { let repr = format!("{}", i); let (repeats_p1, repeats_p2) = check_repeat(&repr); let no_decrease = check_no_decrease(&repr); if repeats_p1 && no_de...
code_fim
hard
{ "lang": "rust", "repo": "dkull/aoc2019", "path": "/day4/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dkull/aoc2019 path: /day4/src/main.rs use std::fs::File; use std::io::prelude::*; fn check_repeat(data: &str) -> (bool, bool) { let mut running_repeat_count = 0; let mut seen_p1_repeat = false; let mut seen_p2_repeat = false; let mut prevchar: Option<char> = None; for c in d...
code_fim
hard
{ "lang": "rust", "repo": "dkull/aoc2019", "path": "/day4/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> tree.put(Item2 { key: 7, value: 2 }, &mut nodes); assert_valid_tree(&nodes, 7); assert_valid_tree_node(&vec![0], 1, 2, &vec![4], false, &nodes); assert_valid_tree_node(&vec![0, 0], 1, 2, &vec![2], true, &nodes); assert_valid_tree_node(&vec![0, 1], 1, 2, &vec![6], true, &nodes); ass...
code_fim
hard
{ "lang": "rust", "repo": "bradyjoestar/merklebtree", "path": "/tests/test_put.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bradyjoestar/merklebtree path: /tests/test_put.rs key: 10, value: String::from("j"), }, &mut nodes, ); tree.put( Item { key: 6, value: String::from("f"), }, &mut nodes, ); tree.put( Item { ...
code_fim
hard
{ "lang": "rust", "repo": "bradyjoestar/merklebtree", "path": "/tests/test_put.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> tree.put(Item2 { key: 20, value: 1 }, &mut nodes); assert_valid_tree(&nodes, 2); assert_valid_tree_node(&vec![0], 2, 0, &vec![10, 20], false, &nodes); assert_eq!( nodes.merkleroot(), nodes.recalculate_merkleroot().merkleroot() ); tree.put(Item2 { key: 30, value: 2 ...
code_fim
hard
{ "lang": "rust", "repo": "bradyjoestar/merklebtree", "path": "/tests/test_put.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eycorsican/leaf path: /leaf/src/app/outbound/plugin.rs use std::collections::HashMap; use std::ffi::OsStr; use std::io; use std::sync::Arc; use async_ffi::BorrowingFfiFuture; use async_trait::async_trait; use libloading::Library; use crate::{proxy::*, session::Session}; pub struct PluginSpec ...
code_fim
hard
{ "lang": "rust", "repo": "eycorsican/leaf", "path": "/leaf/src/app/outbound/plugin.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &'a self, sess: &'a Session, stream: Option<AnyStream>, ) -> BorrowingFfiFuture<'a, io::Result<AnyStream>> { self.handler.handle(sess, stream) } } pub struct OutboundDatagramHandlerProxy { handler: AnyExternalOutboundDatagramHandler, _lib: Arc<Library>, } ...
code_fim
hard
{ "lang": "rust", "repo": "eycorsican/leaf", "path": "/leaf/src/app/outbound/plugin.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &'a self, sess: &'a Session, transport: Option<AnyOutboundTransport>, ) -> BorrowingFfiFuture<'a, io::Result<AnyOutboundDatagram>>; } struct PluginRegistrarImpl { stream_handlers: HashMap<String, OutboundStreamHandlerProxy>, datagram_handlers: HashMap<String, OutboundD...
code_fim
hard
{ "lang": "rust", "repo": "eycorsican/leaf", "path": "/leaf/src/app/outbound/plugin.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> = r.1.iter().sum(); w += total as i64; i += 1; } println!("i = {}", i); println!("w = {}", w); Ok(()) }<|fim_prefix|>// repo: thomashk0/wave path: /wavetk/examples/state_simulation.rs use wavetk::simulation::StateSimulation; pub fn main() -> Result<(), Box<dyn std::error...
code_fim
hard
{ "lang": "rust", "repo": "thomashk0/wave", "path": "/wavetk/examples/state_simulation.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomashk0/wave path: /wavetk/examples/state_simulation.rs use wavetk::simulation::StateSimulation; pub fn main() -> Result<(), Box<dyn std::error::Error>> { let input = std::env::args().nt<|fim_suffix|> let mut w: i64 = 0; let mut i = 0; while !s.done() { let r = s.next_cyc...
code_fim
medium
{ "lang": "rust", "repo": "thomashk0/wave", "path": "/wavetk/examples/state_simulation.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl PieceWork { /// Build a new work piece. /// /// # Arguments /// /// * `index` - The piece index. /// * `hash` - The piece hash. /// * `length` - The piece length. /// pub fn new(index: u32, hash: Vec<u8>, length: u32) -> PieceWork { PieceWork { ...
code_fim
hard
{ "lang": "rust", "repo": "zenoxygen/xerus", "path": "/src/piece.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zenoxygen/xerus path: /src/piece.rs // Copyright (c) 2020 zenoxygen // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limita...
code_fim
hard
{ "lang": "rust", "repo": "zenoxygen/xerus", "path": "/src/piece.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pikajude/rs-store path: /src/store/cached/mod.rs use super::ByteStream; use crate::{ archive::PathFilter, path::Path as StorePath, path_info::{PathInfo, ValidPathInfo}, Store, }; use anyhow::Result; use disk::{CacheEntry, DiskCache}; use futures::lock::Mutex; use lru_cache::LruCache; use...
code_fim
hard
{ "lang": "rust", "repo": "pikajude/rs-store", "path": "/src/store/cached/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.store.get_uri() } async fn get_path_info(&self, path: &StorePath) -> Result<Option<Arc<dyn PathInfo>>> { let mut cache = self.cache.lock().await; let path_key = self.print_store_path(path); let hash_part = path.hash.to_string(); // two layers of options, None means cache mis...
code_fim
hard
{ "lang": "rust", "repo": "pikajude/rs-store", "path": "/src/store/cached/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anlumo/qr-signing path: /src/app.rs Msg::SetKeyPair(public_key, private_key) => { self.key = AppKey::Pair(public_key, private_key); self.update_hash_and_qr(); } Msg::SetPublicKey(public_key) => { self.key = AppKey::Public(p...
code_fim
hard
{ "lang": "rust", "repo": "anlumo/qr-signing", "path": "/src/app.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let AppKey::Pair(_, private_key) = &self.key { if let Some(files) = element.files() { if let Some(file) = files.get(0) { let private_key = private_key.clone(); wasm_bindgen_futures::spawn...
code_fim
hard
{ "lang": "rust", "repo": "anlumo/qr-signing", "path": "/src/app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anlumo/qr-signing path: /src/app.rs &public_key), crypto::export_key(&subtle, &private_key) ); let public_key = public_key.unwrap(); let private_key = private_key.unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "anlumo/qr-signing", "path": "/src/app.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Drawable { fn get_ptr(&self) -> u64; } // FIXME thread safety pub struct Window<'a> { pub(crate) ptr: x11_h::Window, pub(crate) display: &'a mut Display, } pub struct Screen<'a> { pub(crate) id: i32, pub(crate) display: &'a mut Display, } impl<'a> Drawable for Window<'a> { ...
code_fim
medium
{ "lang": "rust", "repo": "n3f4s/yalteir", "path": "/src/x11/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n3f4s/yalteir path: /src/x11/types.rs use x11::x11_h; use x11::x11_util_h; // FIXME placeholder pub type Pixmap = x11_h::Pixmap; pub type XSizeHints = x11_util_h::XSizeHints; pub type XGCValues = x11_h::XGCValues; pub type XEvent = x11_h::XEvent; <|fim_suffix|>impl<'a> Drawable for Window<'a>...
code_fim
hard
{ "lang": "rust", "repo": "n3f4s/yalteir", "path": "/src/x11/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_target_list(target_list : &mut Vec<String>, disp_file_path : &str, label_prefix : &str) -> bool { // read disp file let mut contents = String::new(); if !read_file(&mut contents, disp_file_path) { println!("[PRJ_INFO] List file read fail!"); } ...
code_fim
hard
{ "lang": "rust", "repo": "Hyuntae-Lee/build_all_target", "path": "/src/prj_info.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // get model list // - make string to a list of words let iter_ws = contents.split_whitespace(); // - filter let iter_len = iter_ws.filter(|w| w.chars().count() > label_prefix.len()); let iter_pfx = iter_len.filter(|w| w.to_string().split_at(label_prefix.len()).0 == label_prefix); ...
code_fim
hard
{ "lang": "rust", "repo": "Hyuntae-Lee/build_all_target", "path": "/src/prj_info.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hyuntae-Lee/build_all_target path: /src/prj_info.rs use file_hdl::read_file; pub fn get_version(ver_file_path : &str, label_ver_a : &str, label_ver_b : &str, label_ver_c : &str, label_ver_d : &str) -> String { // read disp file let mut contents = String::new(); if...
code_fim
hard
{ "lang": "rust", "repo": "Hyuntae-Lee/build_all_target", "path": "/src/prj_info.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ethankhall/toolup path: /src/commands/remote/mod.rs mod add; mod delete; mod list; mod update; use crate::cli::RemoteSubCommand; use crate::commands::SubCommandExec; use crate::util::GlobalFolders; use add::AddRemoteError; use delete::DeleteRemoteError; use list::ListRemoteError; use thiserror:...
code_fim
hard
{ "lang": "rust", "repo": "ethankhall/toolup", "path": "/src/commands/remote/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn handle_remote( remote_args: RemoteSubCommand, global_folder: &GlobalFolders, ) -> Result<(), RemoteError> { debug!("Remote command: {:?}", remote_args); match remote_args { RemoteSubCommand::Add(args) => args.execute(global_folder).await?, RemoteSubCommand::Del...
code_fim
hard
{ "lang": "rust", "repo": "ethankhall/toolup", "path": "/src/commands/remote/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dimkar3000/exercism path: /rust/binary-search/src/lib.rs pub fn find(input:&[i32],key:i32)->Option<usize> { if input.len() == 0 { return None; } if key < input[0] || key > input[(input.len()-1)]{ return None; } let mut index = input.len()-1; loop{ ...
code_fim
medium
{ "lang": "rust", "repo": "Dimkar3000/exercism", "path": "/rust/binary-search/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> continue; }else if input[index] == key{ return Some(index); } else { return None; } } }<|fim_prefix|>// repo: Dimkar3000/exercism path: /rust/binary-search/src/lib.rs pub fn find(input:&[i32],key:i32)->Option<usize> { if input.len() ...
code_fim
medium
{ "lang": "rust", "repo": "Dimkar3000/exercism", "path": "/rust/binary-search/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //for 403 pub fn forbidden_403_with_status_code_in_result<T>(message: String) -> status::Custom<Result<T, Json<StatusMessage>>> { StatusMessage::custom_with_status_code_in_result( message, Status::Forbidden, ...
code_fim
hard
{ "lang": "rust", "repo": "sagarnayak/e_com", "path": "/src/model/status_message.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sagarnayak/e_com path: /src/model/status_message.rs use rocket::http::Status; use rocket::response::status; use rocket::serde::json::Json; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct StatusMessage { pub code: u1...
code_fim
hard
{ "lang": "rust", "repo": "sagarnayak/e_com", "path": "/src/model/status_message.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // for 200 // pub fn ok_200_in_result<T>(message: String) -> Result<StatusMessage, T> { // Ok( // StatusMessage::custom( // message, // Status::Ok, // ) // ) // } // pub fn ok_200_with_status_code(message: String) ...
code_fim
hard
{ "lang": "rust", "repo": "sagarnayak/e_com", "path": "/src/model/status_message.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn expect_type_def(&'static self, (namespace, type_name): (&str, &str)) -> TypeDef { if let Some(types) = self.types.get(namespace) { if let Some(TypeRow::TypeDef(row)) = types.get(type_name) { return TypeDef { reader: self, ...
code_fim
hard
{ "lang": "rust", "repo": "fghzxm/windows-rs", "path": "/crates/gen/src/winmd/type_reader.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fghzxm/windows-rs path: /crates/gen/src/winmd/type_reader.rs use super::*; use std::cmp::Ordering; use std::collections::BTreeMap; use std::path::PathBuf; /// A reader of type information from Windows Metadata pub struct TypeReader { // TODO: fields should be private /// The parsed Wind...
code_fim
hard
{ "lang": "rust", "repo": "fghzxm/windows-rs", "path": "/crates/gen/src/winmd/type_reader.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut files: Vec<File> = files.into_iter().map(|file| File::new(file)).collect(); if files.is_empty() { files.push(File::from_bytes( include_bytes!("../../default/Windows.Win32.winmd").to_vec(), )); files.push(File::from_bytes( ...
code_fim
hard
{ "lang": "rust", "repo": "fghzxm/windows-rs", "path": "/crates/gen/src/winmd/type_reader.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod clippy; pub mod diff; pub mod lint_report; pub mod mend_github; pub mod review_comment;<|fim_prefix|>// repo: phansch/mend-rs path: /src/lib.rs #![feature(uniform_paths)] <|fim_middle|>pub use log::{error, info};
code_fim
easy
{ "lang": "rust", "repo": "phansch/mend-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phansch/mend-rs path: /src/lib.rs #![feature(uniform_paths)] <|fim_suffix|>pub mod clippy; pub mod diff; pub mod lint_report; pub mod mend_github; pub mod review_comment;<|fim_middle|>pub use log::{error, info};
code_fim
easy
{ "lang": "rust", "repo": "phansch/mend-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match value { serde_yaml::Value::String(s) => Ok(s), _ => Err(()), } } fn yobject_into_map(value: serde_yaml::Value) -> Result<serde_yaml::Mapping, ()> { match value { serde_yaml::Value::Mapping(o) => Ok(o), _ => Err(()), } } fn transpose<T, E>(value: Opti...
code_fim
hard
{ "lang": "rust", "repo": "EXTREMEGABEL/sbz-switch", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn yobject_into_map(value: serde_yaml::Value) -> Result<serde_yaml::Mapping, ()> { match value { serde_yaml::Value::Mapping(o) => Ok(o), _ => Err(()), } } fn transpose<T, E>(value: Option<Result<T, E>>) -> Result<Option<T>, E> { match value { Some(Ok(value)) => Ok(Some...
code_fim
hard
{ "lang": "rust", "repo": "EXTREMEGABEL/sbz-switch", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EXTREMEGABEL/sbz-switch path: /src/main.rs FormatError::ExpectedObject(name) => write!(f, "expected {} to be an object", name), } } } impl Error for FormatError { fn cause(&self) -> Option<&dyn Error> { match &self { FormatError::TomlRead(error) => Some(er...
code_fim
hard
{ "lang": "rust", "repo": "EXTREMEGABEL/sbz-switch", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DuoSRX/puce path: /src/cpu.rs extern crate rand; #[cfg(test)] #[path = "./cpu_test.rs"] mod cpu_test; use rand::Rng; lazy_static! { static ref FONTS: Vec<u8> = vec![ 0xF0, 0x90, 0x90, 0x90, 0xF0, 0x20, 0x60, 0x20, 0x20, 0x70, 0xF0, 0x10, 0xF0, 0x80, 0xF0, 0...
code_fim
hard
{ "lang": "rust", "repo": "DuoSRX/puce", "path": "/src/cpu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for line_y in 0..height { let pixel = self.mem[(line_y + self.i) as usize]; for line_x in 0..8 { if pixel & (0x80 >> line_x) != 0 { let x_offset = (x + line_x) % 64; let...
code_fim
hard
{ "lang": "rust", "repo": "DuoSRX/puce", "path": "/src/cpu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.gfx[offset] == 1 { self.regs[0xF] = 1 } // collision self.gfx[offset] ^= 1; } } } }, 0xE => { match nn { 0x9E => { ...
code_fim
hard
{ "lang": "rust", "repo": "DuoSRX/puce", "path": "/src/cpu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dansgithubuser/dlal path: /components/adsr/src/lib.rs use dlal_component_base::{component, serde_json, CmdResult}; enum Stage { A, D, S, R, } impl Default for Stage { fn default() -> Self { Stage::R } } component!( {"in": ["midi"], "out": ["audio"]}, [ ...
code_fim
hard
{ "lang": "rust", "repo": "dansgithubuser/dlal", "path": "/components/adsr/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let audio = match &self.output { Some(output) => output.audio(self.run_size).unwrap(), None => return, }; for i in audio { match self.stage { Stage::A => { self.vol += self.a; if self.vol > ...
code_fim
hard
{ "lang": "rust", "repo": "dansgithubuser/dlal", "path": "/components/adsr/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } fn lda(&mut self, mode: &AddressingMode) { let addr = self.get_operand_address(&mode); let value = self.mem_read(addr); self.register_a = value; self.update_zero_and_negative_flags(self.register_a); } fn sta(&mut self, mode: &AddressingMode) { l...
code_fim
hard
{ "lang": "rust", "repo": "yangruihan/nes_ebook", "path": "/code/ch3.2/src/cpu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yangruihan/nes_ebook path: /code/ch3.2/src/cpu.rs use std::collections::HashMap; use crate::opcodes; pub struct CPU { pub register_a: u8, pub register_x: u8, pub register_y: u8, pub status: u8, pub program_counter: u16, memory: [u8; 0xFFFF] } #[derive(Debug)] #[allow(no...
code_fim
hard
{ "lang": "rust", "repo": "yangruihan/nes_ebook", "path": "/code/ch3.2/src/cpu.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* STA */ 0x85 | 0x95 | 0x8d | 0x9d | 0x99 | 0x81 | 0x91 => { self.sta(&opcode.mode); } 0xAA => self.tax(), 0xe8 => self.inx(), 0x00 => return, _ => todo!(),...
code_fim
hard
{ "lang": "rust", "repo": "yangruihan/nes_ebook", "path": "/code/ch3.2/src/cpu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hedgar2017/dhcp path: /protocol/src/lib.rs //! DHCP message serializing, deserializing and validating. <|fim_suffix|>mod v4; pub use self::v4::{ constants::*, options::{MessageType, OptionTag, Options, Overload}, HardwareType, Message, OperationCode, }; pub const DHCP_PORT...
code_fim
medium
{ "lang": "rust", "repo": "hedgar2017/dhcp", "path": "/protocol/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub const DHCP_PORT_SERVER: u16 = 67; pub const DHCP_PORT_CLIENT: u16 = 68;<|fim_prefix|>// repo: hedgar2017/dhcp path: /protocol/src/lib.rs //! DHCP message serializing, deserializing and validating. extern crate bytes; extern crate eui48; #[macro_use] extern crate failure; mod v4; <|fim_middle|>pub ...
code_fim
medium
{ "lang": "rust", "repo": "hedgar2017/dhcp", "path": "/protocol/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* let mut term_mode = Arc::new(TERM_MODE::RECEIVE); let mut term_c = term_mode.clone(); thread::spawn(move || { loop { let term = Term::stdout(); let in_key = term.read_char().unwrap(); println!("key: {}", in_key); match in_key { ...
code_fim
hard
{ "lang": "rust", "repo": "g3rrit/rs_client", "path": "/cli/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut buffer : [u8; 512] = [0; 512]; let mut is_running = true; while is_running { let rbytes = { client.lock().unwrap().read(&mut buffer) }; match rbytes { None => thread::sleep(time::Duration::from_millis(2000)), Some(bytes) => { con...
code_fim
hard
{ "lang": "rust", "repo": "g3rrit/rs_client", "path": "/cli/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: g3rrit/rs_client path: /cli/src/main.rs extern crate console; use console::Term; extern crate client; use client::Client; use std::{thread, time}; use std::sync::{Mutex, Arc}; use std::string::String; mod console_chat; use console_chat::Console_chat; fn main() { let mut console = Arc::n...
code_fim
hard
{ "lang": "rust", "repo": "g3rrit/rs_client", "path": "/cli/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn wall_kick_table(&self, template: &BlockTemplateRef, new_template: &BlockTemplateRef) -> &[(i32, i32); 5] { assert!(template.order != new_template.order); let index = match template.order { 0 => match new_template.order { 1 => 0, 3 => ...
code_fim
hard
{ "lang": "rust", "repo": "coeuvre/retris", "path": "/src/block.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coeuvre/retris path: /src/block.rs b color: RGBA, } macro_rules! block_iter { ($block:expr) => { $block.data .iter() .enumerate() .filter(|&(_, cell)| cell.is_some()) .map(|(i, cell)| { (i % $block.width, i / $block.wid...
code_fim
hard
{ "lang": "rust", "repo": "coeuvre/retris", "path": "/src/block.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> wall_kick_table: [ // J, L, S, T, Z wall kick data [ // 0 -> 1 [(0, 0), (-1, 0), (-1, 1), (0, -2), (-1, -2)], // 1 -> 0 [(0, 0), (1, 0), (1, -1), (0, 2), (1, 2)], ...
code_fim
hard
{ "lang": "rust", "repo": "coeuvre/retris", "path": "/src/block.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gamache/advent2017 path: /advent13/src/main.rs use std::io::Error; use std::fs::File; use std::io::prelude::*; use std::collections::HashMap; fn read_input(filename: &str) -> Result<String, Error> { let mut input = String::new(); File::open(filename)?.read_to_string(&mut input)?; return O...
code_fim
hard
{ "lang": "rust", "repo": "gamache/advent2017", "path": "/advent13/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let pairs: Vec<Vec<usize>> = input .lines() .map(|line| line.split(": ").flat_map(|n| n.parse::<usize>()).collect()) .collect(); for pair in pairs { let depth = pair[0]; let range = pair[1]; ranges.insert(depth, range); scanners.insert(depth, 0); sc...
code_fim
hard
{ "lang": "rust", "repo": "gamache/advent2017", "path": "/advent13/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let x5c = Some(x5c); let header = Header { x5c, ..Default::default() }; assert!(header.x5c_der().is_err()); }<|fim_prefix|>// repo: Keats/jsonwebtoken path: /tests/header/mod.rs use base64::{engine::general_purpose::STANDARD, Engine}; use jsonwebtoken::Header; static CERT_CHAIN: [&str; 3] =...
code_fim
hard
{ "lang": "rust", "repo": "Keats/jsonwebtoken", "path": "/tests/header/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Keats/jsonwebtoken path: /tests/header/mod.rs use base64::{engine::general_purpose::STANDARD, Engine}; use jsonwebtoken::Header; static CERT_CHAIN: [&str; 3] = include!("cert_chain.json"); #[test] fn x5c_der_empty_chain() { let header = Header { x5c: None, ..Default::default() }; asser...
code_fim
medium
{ "lang": "rust", "repo": "Keats/jsonwebtoken", "path": "/tests/header/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let der_chain: Vec<Vec<u8>> = CERT_CHAIN.iter().map(|x| STANDARD.decode(x)).collect::<Result<_, _>>().unwrap(); let x5c = Some(CERT_CHAIN.iter().map(ToString::to_string).collect()); let header = Header { x5c, ..Default::default() }; assert_eq!(header.x5c_der().unwrap(), Some(der_...
code_fim
hard
{ "lang": "rust", "repo": "Keats/jsonwebtoken", "path": "/tests/header/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wbthomason/rustKernelTimer path: /kernelTimer.rs //Wil Thomason extern mod extra; use extra::{time}; use std::{libc}; extern { #[fast_ffi] pub fn signal(sig: i32, func: extern fn() -> i32) -> i32; } struct timeval { tv_sec : i64, tv_usec : i64 } <|fim_suffix|> if counter >= 10000 { s...
code_fim
hard
{ "lang": "rust", "repo": "wbthomason/rustKernelTimer", "path": "/kernelTimer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if counter >= 10000 { setitimer(0, 0 as *itimerval, 0 as *itimerval); let newTime : u64 = time::precise_time_ns(); let difference = newTime - firstTime; let delta = (difference as f64)/(counter as f64); let mut secs : f64 = (delta) / (1000000000 as f64); secs = (1.0/secs) ; let s = "Approx...
code_fim
hard
{ "lang": "rust", "repo": "wbthomason/rustKernelTimer", "path": "/kernelTimer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut around_chars: Vec<String> = Vec::new(); if h != 0 { around_chars.push(lines.get(h - 1).unwrap().to_string().chars().nth(w).unwrap().to_string()); } if w != 0 { around_chars.push(lines.get(h).unwrap().to_string().chars(...
code_fim
hard
{ "lang": "rust", "repo": "jz4o/codingames", "path": "/rust/practice/classic_puzzle/easy/detective-pikaptcha-ep1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jz4o/codingames path: /rust/practice/classic_puzzle/easy/detective-pikaptcha-ep1.rs use std::io; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } /** * Auto-generated code below aims at helping you parse * the standard input according to the problem ...
code_fim
hard
{ "lang": "rust", "repo": "jz4o/codingames", "path": "/rust/practice/classic_puzzle/easy/detective-pikaptcha-ep1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[post("/", data="<newimage>")] pub fn create_image(newimage: Json<NewImage>, conn: DbConn) -> QueryResult<Json<Image>> { diesel::insert_into(images::table) .values(&newimage.into_inner()) .get_result(&*conn) .map(|x| Json(x)) }<|fim_prefix|>// repo: FIL1994/rocket_diesel...
code_fim
hard
{ "lang": "rust", "repo": "FIL1994/rocket_diesel_postgres_react", "path": "/src/routes/routes_images.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FIL1994/rocket_diesel_postgres_react path: /src/routes/routes_images.rs use diesel; use rocket_contrib::Json; use diesel::prelude::*; <|fim_suffix|>#[get("/")] pub fn get_images(conn: DbConn) -> QueryResult<Json<Vec<Image>>> { images.order(id.desc()) .load::<Image>(&*conn) ...
code_fim
medium
{ "lang": "rust", "repo": "FIL1994/rocket_diesel_postgres_react", "path": "/src/routes/routes_images.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/* * Uh oh, the new SpaceXDragon doesn't implement the RocketShip interface. We * need to create an adapter that does. */ /* * Adapter to adapt anything that implements SpaceXShip to the RocketShip trait */ struct SpaceXAdapter { ship: SpaceXDragon } /* * SpaceX Adapter that adds RocketShip tr...
code_fim
hard
{ "lang": "rust", "repo": "jdavis/rust-design-patterns", "path": "/patterns/adapter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jdavis/rust-design-patterns path: /patterns/adapter.rs /* * Adapter Design Pattern * http://joshldavis.com/rust-design-patterns/adapter/ */ /* * Core Trait that defines a basic Rocket Ship */ trait RocketShip { fn turn_on(&self); fn turn_off(&self); fn blast_off(&self); fn ...
code_fim
hard
{ "lang": "rust", "repo": "jdavis/rust-design-patterns", "path": "/patterns/adapter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piotr-cla/ockam path: /implementations/rust/ockam/ockam_node/src/executor.rs // use crate::message::BaseMessage; use crate::{relay::RelayMessage, Context, Node, NodeMessage, NodeReply}; use ockam_core::{Address, Result}; use std::{collections::BTreeMap, future::Future, sync::Arc}; use tokio::r...
code_fim
hard
{ "lang": "rust", "repo": "piotr-cla/ockam", "path": "/implementations/rust/ockam/ockam_node/src/executor.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rethab/monkey-rs path: /src/vm/frame.rs use super::code; use super::object::Closure; use std::fmt; pub struct Frame { pub cl: Closure, pub ip: i32, pub base_pointer: usize, // value of ip before calling function } impl Frame { pub fn new(cl: Closure, base_pointer: usize) -> Sel...
code_fim
hard
{ "lang": "rust", "repo": "rethab/monkey-rs", "path": "/src/vm/frame.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> writeln!(f, "ip={}, base_pointer={}", self.ip, self.base_pointer)?; writeln!( f, "instructions=\n{}", code::display_flat_instructions(self.cl.func.instructions.to_vec(), Some(self.ip)) ) } }<|fim_prefix|>// repo: rethab/monkey-rs path: /src/...
code_fim
hard
{ "lang": "rust", "repo": "rethab/monkey-rs", "path": "/src/vm/frame.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: probe-rs/probe-rs path: /probe-rs/src/architecture/arm/sequences/nrf.rs //! Sequences for the nRF devices. use super::ArmDebugSequence; use crate::architecture::arm::ap::MemoryAp; use crate::architecture::arm::memory::adi_v5_memory_interface::ArmProbe; use crate::architecture::arm::sequences::A...
code_fim
hard
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/probe-rs/src/architecture/arm/sequences/nrf.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>const APPLICATION_RESET_S_NETWORK_FORCEOFF_REGISTER: u32 = 0x50005614; const RELEASE_FORCEOFF: u32 = 0; /// Unlocks the core by performing an erase all procedure. /// The `ap_address` must be of the ctrl ap of the core. fn unlock_core( arm_interface: &mut ArmCommunicationInterface<Initialized>, a...
code_fim
hard
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/probe-rs/src/architecture/arm/sequences/nrf.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if !self.is_core_unlocked( interface.get_arm_communication_interface()?, core_ahb_ap_address, core_ctrl_ap_address, )? { return Err(ArmDebugSequenceError::custom(format!( "Could not unlock core {cor...
code_fim
hard
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/probe-rs/src/architecture/arm/sequences/nrf.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noeddl/rustfst path: /rustfst/src/tests_openfst/io/vector_fst_text_serialization.rs use failure::Fallible; use tempfile::tempdir; use crate::fst_impls::VectorFst; use crate::fst_traits::{ExpandedFst, TextParser}; use crate::semirings::Semiring; use crate::tests_openfst::FstTestData; <|fim_suff...
code_fim
medium
{ "lang": "rust", "repo": "noeddl/rustfst", "path": "/rustfst/src/tests_openfst/io/vector_fst_text_serialization.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let path_fst_serialized = dir.path().join("raw.txt"); test_data.raw.write_text(&path_fst_serialized)?; let deserialized_fst = VectorFst::<W>::read_text(&path_fst_serialized)?; assert_eq!( test_data.raw, deserialized_fst, "{}", error_message_fst!(test_data....
code_fim
medium
{ "lang": "rust", "repo": "noeddl/rustfst", "path": "/rustfst/src/tests_openfst/io/vector_fst_text_serialization.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eranfu/ray_tracing path: /src/texture.rs use std::ops::Deref; use image::*; use crate::*; pub trait Texture: Sync + Send { fn value(&self, u: f32, v: f32, position: &Vector3) -> Vector3; } #[derive(Clone)] pub struct ConstantTexture { color: Vector3, } impl ConstantTexture { pub...
code_fim
hard
{ "lang": "rust", "repo": "eranfu/ray_tracing", "path": "/src/texture.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (width, height) = self.0.dimensions(); let x = (u * width as f32) as i32; let y = ((1.0 - v) * height as f32 - 0.001) as i32; let x = (x.max(0) as u32).min(width - 1); let y = (y.max(0) as u32).min(height - 1); let pixel = self.get_pixel(x, y); V...
code_fim
hard
{ "lang": "rust", "repo": "eranfu/ray_tracing", "path": "/src/texture.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Val::Var(var) => Val::Var(*var), Val::Resolved(r) => Val::Resolved(r.clone()), } } } impl<T: PartialEq + Debug> PartialEq for Val<T> { fn eq(&self, other: &Val<T>) -> bool { match (self, other) { (Resolved(s), Resolved(other...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/canrun_rs", "path": "/canrun/src/value.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atul9/canrun_rs path: /canrun/src/value.rs //! Contain individual resolved values or variables that can be bound through //! [unification](crate::UnifyIn). //! //! Values are parameterized with the type they can contain. This ensures that //! they can only be unified with values of the same type...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/canrun_rs", "path": "/canrun/src/value.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/vpminuq.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vpminuq_1() { run_test(...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vpminuq.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn vpminuq_15() { run_test(&Instruction { mnemonic: Mnemonic::VPMINUQ, operand1: Some(Direct(ZMM3)), operand2: Some(Direct(ZMM2)), operand3: Some(IndirectScaledIndexed(EDI, EBX, Eight, Some(OperandSize::Qword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero)...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vpminuq.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn vpminuq_17() { run_test(&Instruction { mnemonic: Mnemonic::VPMINUQ, operand1: Some(Direct(ZMM12)), operand2: Some(Direct(ZMM16)), operand3: Some(IndirectDisplaced(RSI, 1404742689, Some(OperandSize::Zmmword), None)), operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero)...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vpminuq.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] pub async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { let make_svc = make_service_fn(|_conn| { async { Ok::<_, Infallible>(service_fn(hello)) } }); let addr = ([127, 0, 0, 1], 8000).into(); let server = Server::bind(&addr).serve(make_svc); println!("Listening ...
code_fim
hard
{ "lang": "rust", "repo": "blockspacer/cpv-framework", "path": "/benchmarks/targets/hyper/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blockspacer/cpv-framework path: /benchmarks/targets/hyper/src/main.rs use std::convert::Infallible; use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Request, Response, Server, Method, StatusCode, header}; <|fim_suffix|>#[tokio::main] pub async fn main() -> Result<(), Box<dyn...
code_fim
hard
{ "lang": "rust", "repo": "blockspacer/cpv-framework", "path": "/benchmarks/targets/hyper/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slpdex/slpdexdb path: /slpdexdb_db/src/data.rs use cashcontracts::Address; use slpdexdb_base::SLPAmount; #[derive(Clone, Debug)] pub struct Utxo { pub tx_hash: [u8; 32], pub vout: i32, pub value_satoshis: u64, pub value_token: SLPAmount, pub token_hash: Option<[u8; 32]>, } ...
code_fim
hard
{ "lang": "rust", "repo": "slpdex/slpdexdb", "path": "/slpdexdb_db/src/data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug)] pub enum NewUtxo { Address { tx_hash: [u8; 32], vout: i32, address: Address, }, TradeOffer { tx_hash: [u8; 32], vout: i32, }, } #[derive(Clone, Debug)] pub enum TradeOfferFilter { TokenHash([u8; 32]), ReceivingAddress...
code_fim
medium
{ "lang": "rust", "repo": "slpdex/slpdexdb", "path": "/slpdexdb_db/src/data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let fp1_val = FpRev1CompX::from(register_value); if fp1_val.replace() == 0b01 { Ok(fp1_val.comp() << 2) } else if fp1_val.replace() == 0b10 { Ok((fp1_val.comp() << 2) | 0x2) } else { Err(Error::Probe(DebugProbeError::Other(anyhow::anyhow!...
code_fim
hard
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/probe-rs/src/architecture/arm/core/armv7m.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<u32> for Demcr { fn from(value: u32) -> Self { Self(value) } } impl From<Demcr> for u32 { fn from(value: Demcr) -> Self { value.0 } } impl MemoryMappedRegister<u32> for Demcr { const ADDRESS_OFFSET: u64 = 0xe000_edfc; const NAME: &'static str = "DEMCR"; ...
code_fim
hard
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/probe-rs/src/architecture/arm/core/armv7m.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: probe-rs/probe-rs path: /probe-rs/src/architecture/arm/core/armv7m.rs half word }; reg.set_replace(replace_val); reg.set_comp(comp_val); reg.set_enable(true); Ok(reg) } } bitfield! { /// The FP_COMPn register bit assignments for FPB Version 2 wh...
code_fim
hard
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/probe-rs/src/architecture/arm/core/armv7m.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let text = text_of_str(&mut heap, "aaaaa-aa"); let principal = blob_of_principal(&mut heap, text); assert_eq!(text_compare(principal, text_of_str(&mut heap, ""),), 0); let text = text_of_str(&mut heap, "bfozs-kwa73-7nadi"); assert_eq!( text_compare( blob_of_princip...
code_fim
hard
{ "lang": "rust", "repo": "dfinity/motoko", "path": "/rts/motoko-rts-tests/src/principal_id.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dfinity/motoko path: /rts/motoko-rts-tests/src/principal_id.rs use crate::memory::TestMemory; use motoko_rts::principal_id::{blob_of_principal, principal_of_blob}; use motoko_rts::text::{text_compare, text_of_ptr_size, text_of_str}; use motoko_rts::types::{Bytes, Words}; pub unsafe fn test() {...
code_fim
hard
{ "lang": "rust", "repo": "dfinity/motoko", "path": "/rts/motoko-rts-tests/src/principal_id.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> let recipient = NetworkAddress::new(); let origin = NetworkAddress::new(); VersionPayload { version: 70015, services: 0, timestamp: since_epoch as i64, addr_recv: recipient, addr_from: origin, nonce, ...
code_fim
hard
{ "lang": "rust", "repo": "DanielSidhion/kaliko", "path": "/src/network/version.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn length() -> usize { 86 } pub fn new(nonce: u64) -> VersionPayload { let time = SystemTime::now(); let since_epoch = time.duration_since(UNIX_EPOCH).unwrap().as_secs(); let recipient = NetworkAddress::new(); let origin = NetworkAddress::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "DanielSidhion/kaliko", "path": "/src/network/version.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielSidhion/kaliko path: /src/network/version.rs use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use std::io::{Read, Write}; use std::time::{SystemTime, UNIX_EPOCH}; use network::NetworkError; use network::networkaddress::NetworkAddress; use network::varstring::VarString; #[deriv...
code_fim
hard
{ "lang": "rust", "repo": "DanielSidhion/kaliko", "path": "/src/network/version.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/winapi/v0_3/crate/src/um/objidl.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...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/objidl.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pszFileName: LPCOLESTR, fRemember: BOOL, ) -> HRESULT, fn SaveCompleted( pszFileName: LPCOLESTR, ) -> HRESULT, fn GetCurFile( ppszFileName: *mut LPOLESTR, ) -> HRESULT, }} STRUCT!{struct DVTARGETDEVICE { tdSize: DWORD, tdDriverNameOffset: WORD, ...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/objidl.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }