text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: xujian121858/safetywechat path: /src/core/message/message.rs use serde::{ Serialize, Deserialize }; #[derive(Serialize, Deserialize, Debug)] pub enum Message { Text(Text), Image(Image), Voice(Voice), Video(Video), ShortVideo(Video), Location(Location), Link(Link), ...
code_fim
hard
{ "lang": "rust", "repo": "xujian121858/safetywechat", "path": "/src/core/message/message.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug, Clone)] pub struct Location { pub x: f64, pub y: f64, pub scale: u64, pub label: String, } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Music { pub title: String, pub description: String, pub url: String, pub hq_url: St...
code_fim
hard
{ "lang": "rust", "repo": "xujian121858/safetywechat", "path": "/src/core/message/message.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samiBendou/nbodies path: /src/keys.rs use piston::input::{Key, MouseButton}; pub static KEY_RESET: Key = Key::Backspace; // Config toggles pub static KEY_TOGGLE_TRANSLATE: Key = Key::J; pub static KEY_TOGGLE_TRAJECTORY: Key = Key::R; pub static KEY_TOGGLE_PAUSE: Key = Key::Space; pub static KE...
code_fim
hard
{ "lang": "rust", "repo": "samiBendou/nbodies", "path": "/src/keys.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>// Scaling pub static KEY_INCREASE_OVERSAMPLING: Key = Key::P; pub static KEY_DECREASE_OVERSAMPLING: Key = Key::O; pub static KEY_INCREASE_DISTANCE: Key = Key::I; pub static KEY_DECREASE_DISTANCE: Key = Key::U; pub static KEY_INCREASE_TIME: Key = Key::Comma; pub static KEY_DECREASE_TIME: Key = Key::M; ...
code_fim
hard
{ "lang": "rust", "repo": "samiBendou/nbodies", "path": "/src/keys.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> RTDDestroyBuilder { inner } } } #[doc(hidden)] pub struct RTDDestroyBuilder { inner: Destroy, } impl RTDDestroyBuilder { pub fn build(&self) -> Destroy { self.inner.clone() } } impl AsRef<Destroy> for Destroy { fn as_ref(&self) -> &Destroy { self } } imp...
code_fim
hard
{ "lang": "rust", "repo": "himlpplm/rust-tdlib", "path": "/src/types/destroy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: himlpplm/rust-tdlib path: /src/types/destroy.rs use crate::errors::*; use crate::types::*; use uuid::Uuid; /// Closes the TDLib instance, destroying all local data without a proper logout. The current user session will remain in the list of all active sessions. All local data will be destroyed....
code_fim
hard
{ "lang": "rust", "repo": "himlpplm/rust-tdlib", "path": "/src/types/destroy.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl AsRef<Destroy> for Destroy { fn as_ref(&self) -> &Destroy { self } } impl AsRef<Destroy> for RTDDestroyBuilder { fn as_ref(&self) -> &Destroy { &self.inner } }<|fim_prefix|>// repo: himlpplm/rust-tdlib path: /src/types/destroy.rs use crate::errors::*; use crate::type...
code_fim
hard
{ "lang": "rust", "repo": "himlpplm/rust-tdlib", "path": "/src/types/destroy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tids: Vec<_> = matches .values_of("TIDS") .unwrap() .map(|v| match v.parse::<u32>() { Ok(pid) => pid, Err(_) => { eprintln!("Invalid PID: {}", v); process::exit(1); } }) .collect(); let...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/linux-taskstats-rs", "path": "/src/bin/taskstats.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/linux-taskstats-rs path: /src/bin/taskstats.rs use clap::{App, Arg}; use linux_taskstats::cmd; use linux_taskstats::format::DefaultHeaderFormat; use std::process; <|fim_suffix|> let matches = App::new("A command line interface to Linux taskstats") .arg(Arg::with_name("verbo...
code_fim
medium
{ "lang": "rust", "repo": "doytsujin/linux-taskstats-rs", "path": "/src/bin/taskstats.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn xor_valid_result() { let source = &[0, 1, 2, 3]; let result = xor(source, &[34, 52]); expect!(result).to(be_equal_to([34, 53, 32, 55])); } #[test] fn xor_valid_result_with_one_byte() { let source = &[0, 1, 2, 3]; let result = xor(sour...
code_fim
hard
{ "lang": "rust", "repo": "zummenix/xor-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn xor_empty_key() { let source = &[0, 1, 2, 3]; let result = xor(source, &[]); expect!(result).to(be_equal_to(source)); } #[test] fn xor_empty_source() { let source = &[]; let result = xor(source, &[45, 32, 56]); expect!(result....
code_fim
hard
{ "lang": "rust", "repo": "zummenix/xor-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zummenix/xor-rs path: /src/lib.rs //! A repeating-key XOR functions. //! //! This functions might be useful to play with //! [the matasano crypto challenges](http://cryptopals.com). #[cfg(test)] #[macro_use(expect)] extern crate expectest; /// Returns result of a XOR operation applied to a `s...
code_fim
hard
{ "lang": "rust", "repo": "zummenix/xor-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jvanrhijn/mole path: /tests/hydrogen_molecular_ion_lcao.rs use metropolis::MetropolisBox; use mole::prelude::*; use ndarray::{array, Array1, Array2, Axis, Ix2}; use ndarray_linalg::Norm; use operator::{ ElectronicHamiltonian, ElectronicPotential, IonicPotential, KineticEnergy, OperatorValue,...
code_fim
hard
{ "lang": "rust", "repo": "Jvanrhijn/mole", "path": "/tests/hydrogen_molecular_ion_lcao.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone)] struct H2WF { r: Array2<f64>, phi: STO, } impl H2WF { pub fn new(r: f64, alpha: f64) -> Self { Self { r: array![[r, 0.0, 0.0]], phi: STO::new(alpha), } } } impl Function<f64> for H2WF { type D = Ix2; fn value(&self, x: &Ar...
code_fim
hard
{ "lang": "rust", "repo": "Jvanrhijn/mole", "path": "/tests/hydrogen_molecular_ion_lcao.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self } } /// A trait implemented by types that can manage TLS encryption for a stream. pub trait Handshake: 'static + Sync + Send { /// Performs a TLS handshake, returning a wrapped stream. fn handshake( self: Box<Self>, host: &str, stream: Stream, ) -> Box...
code_fim
hard
{ "lang": "rust", "repo": "jimso/rust-postgres", "path": "/tokio-postgres/src/tls/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jimso/rust-postgres path: /tokio-postgres/src/tls/mod.rs //! TLS support. use futures::Future; use std::error::Error; use tokio_io::{AsyncRead, AsyncWrite}; pub use stream::Stream; <|fim_suffix|> self } } /// A trait implemented by types that can manage TLS encryption for a stream...
code_fim
hard
{ "lang": "rust", "repo": "jimso/rust-postgres", "path": "/tokio-postgres/src/tls/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn get_mut(&mut self) -> &mut Stream { self } } /// A trait implemented by types that can manage TLS encryption for a stream. pub trait Handshake: 'static + Sync + Send { /// Performs a TLS handshake, returning a wrapped stream. fn handshake( self: Box<Self>, host:...
code_fim
hard
{ "lang": "rust", "repo": "jimso/rust-postgres", "path": "/tokio-postgres/src/tls/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redsnapper2006/leetcode-cn path: /L/2370-longest-ideal-subsequence/main.rs struct Solution {} impl Solution { pub fn longest_ideal_string(s: String, k: i32) -> i32 { let mut buf: Vec<[i32; 26]> = vec![[0; 26]; s.len()]; s.as_bytes() .iter() .enumerate() .for_each(|(...
code_fim
hard
{ "lang": "rust", "repo": "redsnapper2006/leetcode-cn", "path": "/L/2370-longest-ideal-subsequence/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>>= 0 && ad < 26 && buf[idx][offset as usize] < buf[idx - 1][ad as usize] + 1 { buf[idx][offset as usize] = buf[idx - 1][ad as usize] + 1; } }); } }); buf[s.len() - 1].to_vec().into_iter().max().unwrap() } }<|fim_prefix|>// repo: redsnapper2006/leetco...
code_fim
hard
{ "lang": "rust", "repo": "redsnapper2006/leetcode-cn", "path": "/L/2370-longest-ideal-subsequence/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>et - dis as i32; let ad = offset + dis as i32; if bd >= 0 && bd < 26 && buf[idx][offset as usize] < buf[idx - 1][bd as usize] + 1 { buf[idx][offset as usize] = buf[idx - 1][bd as usize] + 1; } if ad >= 0 && ad < 26 && buf[idx][offset as usize] ...
code_fim
hard
{ "lang": "rust", "repo": "redsnapper2006/leetcode-cn", "path": "/L/2370-longest-ideal-subsequence/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match input { Page::Home => 0, Page::AddTask => 1, Page::Tasks => 2, } } }<|fim_prefix|>// repo: GitDatz/todo_tui_app path: /src/types.rs use std::io; use thiserror::Error; #[derive(Error, Debug)] pub enum Error { #[error("error reading the DB ...
code_fim
medium
{ "lang": "rust", "repo": "GitDatz/todo_tui_app", "path": "/src/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<Page> for usize { fn from(input: Page) -> usize { match input { Page::Home => 0, Page::AddTask => 1, Page::Tasks => 2, } } }<|fim_prefix|>// repo: GitDatz/todo_tui_app path: /src/types.rs use std::io; use thiserror::Error; #[derive(Er...
code_fim
medium
{ "lang": "rust", "repo": "GitDatz/todo_tui_app", "path": "/src/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GitDatz/todo_tui_app path: /src/types.rs use std::io; use thiserror::Error; #[derive(Error, Debug)] pub enum Error { #[error("error reading the DB file: {0}")] ReadDBError(#[from] io::Error), #[error("error parsing the DB file: {0}")] ParseDBError(#[from] serde_json::Error), } ...
code_fim
medium
{ "lang": "rust", "repo": "GitDatz/todo_tui_app", "path": "/src/types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn get_coords(s : &str) -> (i32, i32) { let mut x = 0; let mut y = 0; let mut between = false; s.chars().for_each(|c| { match c { 'e' => { x += 1; between = false; }, 'w' => { if !between { ...
code_fim
hard
{ "lang": "rust", "repo": "jmarianer/adventofcode", "path": "/2020/src/day24.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jmarianer/adventofcode path: /2020/src/day24.rs use std::collections::HashMap; use std::collections::HashSet; use std::fs::File; use std::io::{BufRead, BufReader}; fn iterate_hex(pos : HashSet<(i32, i32)>) -> HashSet<(i32, i32)> { let mut adjacent : HashMap<(i32, i32), (u32, bool)> = HashMa...
code_fim
hard
{ "lang": "rust", "repo": "jmarianer/adventofcode", "path": "/2020/src/day24.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: psyto/bitcoinaddress path: /src/main.rs extern crate bitcoin_hashes; extern crate hex; extern crate secp256k1; use bitcoin_hashes::{ripemd160, sha256, Hash}; use secp256k1::{PublicKey, Secp256k1, SecretKey}; use std::str; fn main() { // https://en.bitcoin.it/wiki/Technical_background_of_v...
code_fim
hard
{ "lang": "rust", "repo": "psyto/bitcoinaddress", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 5. Add version byte in front of RIPEMD-160 hash (0x00 for Main Network). // 00f54a5851e9372b87810a8e60cdd2e7cfd80b6e31 let mut extended_ripmd160_sha256_public_key = [0u8; 1].to_vec(); extended_ripmd160_sha256_public_key.extend(&ripmd160_sha256_public_key); // 6. Perform SHA-256 has...
code_fim
hard
{ "lang": "rust", "repo": "psyto/bitcoinaddress", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn get_texture_path() -> PathBuf { let mut current_dir = std::env::current_dir().expect("Can't get current directory"); current_dir.push("data\\test_tex.ktx2"); current_dir }<|fim_prefix|>// repo: F3kilo/ktx2-reader path: /examples/async_load.rs use ktx2_reader::format::Format; use ktx2_reade...
code_fim
hard
{ "lang": "rust", "repo": "F3kilo/ktx2-reader", "path": "/examples/async_load.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: F3kilo/ktx2-reader path: /examples/async_load.rs use ktx2_reader::format::Format; use ktx2_reader::{Header, Reader, RegionDescription}; use std::path::PathBuf; #[tokio::main] async fn main() { let tex_path = get_texture_path(); let file = tokio::fs::read(tex_path).await.expect("Can't op...
code_fim
hard
{ "lang": "rust", "repo": "F3kilo/ktx2-reader", "path": "/examples/async_load.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HarryU/huOS path: /src/lib.rs #![feature(ptr_internals)] #![feature(panic_implementation)] #![feature(lang_items)] #![feature(const_fn)] #![feature(alloc)] #![feature(abi_x86_interrupt)] #![feature(asm)] #![feature(alloc_error_handler)] #![no_std] extern crate hole_list_allocator as allocator; ...
code_fim
hard
{ "lang": "rust", "repo": "HarryU/huOS", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn enable_write_protect_bit() { use x86_64::registers::control_regs::{cr0, cr0_write, Cr0}; unsafe { cr0_write(cr0() | Cr0::WRITE_PROTECT) }; } #[lang = "eh_personality"] extern "C" fn eh_personality() {} use core::panic::PanicInfo; #[panic_implementation] #[no_mangle] pub fn panic(panic_info:...
code_fim
hard
{ "lang": "rust", "repo": "HarryU/huOS", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { asm!("sti"); } println!("It did not crash!"); loop {} } fn enable_nxe_bit() { use x86_64::registers::msr::{rdmsr, wrmsr, IA32_EFER}; let nxe_bit = 1 << 11; unsafe { let efer = rdmsr(IA32_EFER); wrmsr(IA32_EFER, efer | nxe_bit); } } fn en...
code_fim
hard
{ "lang": "rust", "repo": "HarryU/huOS", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let val = root.as_ref().unwrap().borrow().val; let left = p.as_ref().unwrap().borrow().val; let right = q.as_ref().unwrap().borrow().val; if (left <= val && right >= val) || (right <= val && left >= val) { root } else if left < val && right < val { ...
code_fim
hard
{ "lang": "rust", "repo": "royswale/leetcode", "path": "/src/bin/lowest-common-ancestor-of-a-binary-search-tree.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Solution { /// 1.搜索二叉树 /// 2.节点值唯一 pub fn lowest_common_ancestor( root: Option<Rc<RefCell<TreeNode>>>, p: Option<Rc<RefCell<TreeNode>>>, q: Option<Rc<RefCell<TreeNode>>>, ) -> Option<Rc<RefCell<TreeNode>>> { if root.is_none() { return None; ...
code_fim
hard
{ "lang": "rust", "repo": "royswale/leetcode", "path": "/src/bin/lowest-common-ancestor-of-a-binary-search-tree.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: royswale/leetcode path: /src/bin/lowest-common-ancestor-of-a-binary-search-tree.rs fn main() {} struct Solution; // Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<R...
code_fim
hard
{ "lang": "rust", "repo": "royswale/leetcode", "path": "/src/bin/lowest-common-ancestor-of-a-binary-search-tree.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let local_id = config.clone().key.public().into_peer_id(); let remote_state = remote_context.state; // info!("Remote ID: {:?}", remote_state.clone().peer_id); // // info!("Local ID: {:?}", local_id.clone()); if remote_state.clone().public_key.into_peer_id() == local_id { ...
code_fim
hard
{ "lang": "rust", "repo": "NDNLink/NDNProtocol", "path": "/libp2p/protocols/plaintext/src/handshake/handshake_plaintext.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let remote_state = remote_context.state; // info!("Remote ID: {:?}", remote_state.clone().peer_id); // // info!("Local ID: {:?}", local_id.clone()); if remote_state.clone().public_key.into_peer_id() == local_id { return Err(PlaintextError::ConnectSelf); } let secure_...
code_fim
hard
{ "lang": "rust", "repo": "NDNLink/NDNProtocol", "path": "/libp2p/protocols/plaintext/src/handshake/handshake_plaintext.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NDNLink/NDNProtocol path: /libp2p/protocols/plaintext/src/handshake/handshake_plaintext.rs // Copyright 2020 Netwarps Ltd. // // 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...
code_fim
hard
{ "lang": "rust", "repo": "NDNLink/NDNProtocol", "path": "/libp2p/protocols/plaintext/src/handshake/handshake_plaintext.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Restioson/tag-vec path: /src/query.rs use crate::TagVec; use crate::BitField; use std::hash::Hash; /// Conveniences for creating expressions easily. /// The idea is to wildcard import this module in /// a confined scope, such that you get access to all the goodies /// within, but only for a sho...
code_fim
hard
{ "lang": "rust", "repo": "Restioson/tag-vec", "path": "/src/query.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> expr.to_commands(&mut tag_requests, &mut commands); // Get references to the data storing the things // the commands want let tag_data: Vec<_> = tag_requests.into_iter() .map(|request| vec.tag_fields.get(request).map(|v| v.data())).collect(); Query { tag_data, commands, bit_ctr: 0...
code_fim
hard
{ "lang": "rust", "repo": "Restioson/tag-vec", "path": "/src/query.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gustavorobertux/celo-bls-snark-rs path: /crates/epoch-snark/src/api/mod.rs mod prover; pub use prover::prove; mod setup; pub use setup::{trusted_setup, Parameters}; <|fim_suffix|>// Instantiate certain types to avoid confusion pub type BLSCurve = ark_bls12_377::Bls12_377; pub type BLSCurveG1 =...
code_fim
medium
{ "lang": "rust", "repo": "gustavorobertux/celo-bls-snark-rs", "path": "/crates/epoch-snark/src/api/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Instantiate certain types to avoid confusion pub type BLSCurve = ark_bls12_377::Bls12_377; pub type BLSCurveG1 = ark_bls12_377::G1Projective; pub type BLSCurveG2 = ark_bls12_377::G2Projective; pub type BWField = ark_bw6_761::Fr; pub type BWCurve = ark_bw6_761::BW6_761; pub type BWFrParams = ark_bw6_761...
code_fim
medium
{ "lang": "rust", "repo": "gustavorobertux/celo-bls-snark-rs", "path": "/crates/epoch-snark/src/api/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Eduardo-Silla/coreos-installer path: /src/s390x/zipl.rs // Copyright 2020 CoreOS, Inc. // // 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": "Eduardo-Silla/coreos-installer", "path": "/src/s390x/zipl.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn get_kernel_path<P: AsRef<Path>>(boot: P) -> Result<PathBuf> { find_file(boot.as_ref().join("ostree"), "vmlinuz") } fn get_initramfs_path<P: AsRef<Path>>(boot: P) -> Result<PathBuf> { find_file(boot.as_ref().join("ostree"), "initram") } fn get_boot_kargs<P: AsRef<Path>>(bls_config: P) -> Resul...
code_fim
hard
{ "lang": "rust", "repo": "Eduardo-Silla/coreos-installer", "path": "/src/s390x/zipl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let contents = read_to_string(&bls_config) .chain_err(|| format!("reading {}", bls_config.as_ref().display()))?; // read kargs from options line let pt = r"^options (?P<v>.+)$"; let opts = RegexBuilder::new(pt) .multi_line(true) .build() .unwrap() .c...
code_fim
hard
{ "lang": "rust", "repo": "Eduardo-Silla/coreos-installer", "path": "/src/s390x/zipl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> //iterate over all lines, checking for collision with trees for line in text.lines() { if line[index..].chars().next().unwrap() == '#' { n+=1; } index += 3; index %= line.len(); } println!("Encountered {} trees", n); Ok(()) }<|fim_prefix|>/...
code_fim
medium
{ "lang": "rust", "repo": "Duckfan77/AdventOfCode2020", "path": "/day3-1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Duckfan77/AdventOfCode2020 path: /day3-1/src/main.rs use std::fs::File; use std::io::prelude::*; fn main() -> std::io::Result<()>{ <|fim_suffix|> //iterate over all lines, checking for collision with trees for line in text.lines() { if line[index..].chars().next().unwrap() == '#'...
code_fim
medium
{ "lang": "rust", "repo": "Duckfan77/AdventOfCode2020", "path": "/day3-1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenguzhen87/deno path: /core/runtime/ops.rs // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use crate::ops::*; use crate::OpResult; use crate::PromiseId; use anyhow::Error; use futures::future::Either; use futures::future::Future; use futures::future::FutureExt; use f...
code_fim
hard
{ "lang": "rust", "repo": "chenguzhen87/deno", "path": "/core/runtime/ops.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[tokio::test(flavor = "current_thread")] pub async fn test_op_result_void() -> Result<(), Box<dyn std::error::Error>> { // Test the non-switching kinds run_test2( 10000, "op_test_result_void_err", "try { op_test_result_void_err(); assert(false) } catch (e) {}", )?; r...
code_fim
hard
{ "lang": "rust", "repo": "chenguzhen87/deno", "path": "/core/runtime/ops.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print!("Red: {}, Plum: {}, Pink: {}, Rose: {}, Green: {}, Orange: {}, Indigo: {}, Blue: {}, Medium Blue: {}", persian_colors.red, persian_colors.plum, persian_colors.pink, persian_colors.rose, persian_colors.green, persian_colors.orange, persian_colors.indigo, persian_colors.blue, persian_colo...
code_fim
hard
{ "lang": "rust", "repo": "amir-shiati/PersianColors", "path": "/persian-colors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let persian_colors = PersianColors { red: "#c81d11".to_string(), plum: "#701c1c".to_string(), pink: "#f77fbe".to_string(), rose: "#fe28a2".to_string(), green: "#00a693".to_string(), orange: "#d99058".to_string(), indigo: "#32127a".to_string(), ...
code_fim
medium
{ "lang": "rust", "repo": "amir-shiati/PersianColors", "path": "/persian-colors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amir-shiati/PersianColors path: /persian-colors.rs struct PersianColors { red: String, plum: String, pink: String, rose: String, green: String, orange: String, indigo: String, blue: String, medium_blue: String, } <|fim_suffix|> print!("Red: {}, Plum: {}, P...
code_fim
hard
{ "lang": "rust", "repo": "amir-shiati/PersianColors", "path": "/persian-colors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Div<[f32; 2]> for P2 { type Output = P2; fn div(self, pair: [f32; 2]) -> P2 { P2 { x: self.x / pair[0], y: self.y / pair[1], } } } impl AddAssign<V2> for P2 { fn add_assign(&mut self, rhs: V2) { self.x += rhs.x; self.y += rhs.y...
code_fim
hard
{ "lang": "rust", "repo": "Boyquotes/zeldalike-rs", "path": "/game2d/src/geom.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Add<V2> for V2 { type Output = V2; fn add(self, rhs: V2) -> V2 { V2 { x: self.x + rhs.x, y: self.y + rhs.y, } } } impl Sub<V2> for V2 { type Output = V2; fn sub(self, rhs: V2) -> V2 { V2 { x: self.x - rhs.x, ...
code_fim
hard
{ "lang": "rust", "repo": "Boyquotes/zeldalike-rs", "path": "/game2d/src/geom.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Boyquotes/zeldalike-rs path: /game2d/src/geom.rs //! Set of useful, geometry-related utility classes use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; /// A point in 2D space. /// /// Note: This struct is so small you should prefer passing it around by copy rather...
code_fim
hard
{ "lang": "rust", "repo": "Boyquotes/zeldalike-rs", "path": "/game2d/src/geom.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nopaniers/ming path: /src/user.rs //------------------------------------------------------------------------- // Ming Operating System //------------------------------------------------------------------------- // #![no_std] // #![feature(globs)] // #![feature(lang_items)] <|fim_suffix|>#[no_m...
code_fim
hard
{ "lang": "rust", "repo": "nopaniers/ming", "path": "/src/user.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>//------------------------------------------------------------------------------ // User mode functions //------------------------------------------------------------------------------ #[no_mangle] #[no_stack_check] pub fn user_mode_function() { writeln_serial(""); writeln_serial("Switched to user mo...
code_fim
medium
{ "lang": "rust", "repo": "nopaniers/ming", "path": "/src/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //------------------------------------------------------------------------------ // User mode functions //------------------------------------------------------------------------------ #[no_mangle] #[no_stack_check] pub fn user_mode_function() { writeln_serial(""); writeln_serial("Switched to user m...
code_fim
medium
{ "lang": "rust", "repo": "nopaniers/ming", "path": "/src/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: netvl/pub-rust-cargo-external-libs-example path: /src/main.rs extern crate libc; use std::c_str::CString; use libc::c_char; <|fim_suffix|>} fn main() { let cbuf = unsafe { CString::new(hello_msg(), false) }; println!("Hello, {}!", cbuf.as_str().unwrap()) }<|fim_middle|>#[link(name = ...
code_fim
medium
{ "lang": "rust", "repo": "netvl/pub-rust-cargo-external-libs-example", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} fn main() { let cbuf = unsafe { CString::new(hello_msg(), false) }; println!("Hello, {}!", cbuf.as_str().unwrap()) }<|fim_prefix|>// repo: netvl/pub-rust-cargo-external-libs-example path: /src/main.rs extern crate libc; use std::c_str::CString; <|fim_middle|>use libc::c_char; #[link(name = ...
code_fim
medium
{ "lang": "rust", "repo": "netvl/pub-rust-cargo-external-libs-example", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cbuf = unsafe { CString::new(hello_msg(), false) }; println!("Hello, {}!", cbuf.as_str().unwrap()) }<|fim_prefix|>// repo: netvl/pub-rust-cargo-external-libs-example path: /src/main.rs extern crate libc; use std::c_str::CString; <|fim_middle|>use libc::c_char; #[link(name = "foo")] extern ...
code_fim
medium
{ "lang": "rust", "repo": "netvl/pub-rust-cargo-external-libs-example", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solareclipse995/site path: /src/main.rs #[macro_use] extern crate tracing; use color_eyre::eyre::Result; use hyper::{header::CONTENT_TYPE, Body, Response}; use prometheus::{Encoder, TextEncoder}; use std::net::IpAddr; use std::str::FromStr; use std::sync::Arc; use tokio::net::UnixListener; use ...
code_fim
hard
{ "lang": "rust", "repo": "solareclipse995/site", "path": "/src/main.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> let static_pages = index .or(feeds.or(asset_links)) .or(resume.or(signalboost)) .or(patrons) .or(jsonfeed.or(atom.or(sitemap)).or(rss)) .or(favicon.or(robots).or(sw)) .or(contact.or(new_post)) .map(|reply| { warp::reply::with_header( ...
code_fim
hard
{ "lang": "rust", "repo": "solareclipse995/site", "path": "/src/main.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> let files = warp::path("static") .and(warp::fs::dir("./static")) .map(|reply| { warp::reply::with_header( reply, "Cache-Control", "public, max-age=86400, stale-if-error=60", ) }); let css = warp::path(...
code_fim
hard
{ "lang": "rust", "repo": "solareclipse995/site", "path": "/src/main.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ickshonpe/ggez path: /src/graphics/text.rs use super::{ gpu::text::{Extra, TextRenderer}, Canvas, Color, Draw, DrawParam, Drawable, GraphicsContext, Rect, }; use crate::{ context::{Has, HasMut}, filesystem::Filesystem, GameError, GameResult, }; use glyph_brush::{ab_glyph, Fon...
code_fim
hard
{ "lang": "rust", "repo": "ickshonpe/ggez", "path": "/src/graphics/text.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Text { /// Creates a `Text` from a `TextFragment`. /// /// ```rust /// # use ggez::graphics::Text; /// # fn main() { /// let text = Text::new("foo"); /// # } /// ``` pub fn new(fragment: impl Into<TextFragment>) -> Self { let mut text = Text::default(); ...
code_fim
hard
{ "lang": "rust", "repo": "ickshonpe/ggez", "path": "/src/graphics/text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Specifies the text's font scael for fragments that don't specify their own scale. pub fn set_scale(&mut self, scale: impl Into<PxScale>) -> &mut Self { self.scale = scale.into(); self } /// Returns the string that the text represents. pub fn contents(&self) -> Stri...
code_fim
hard
{ "lang": "rust", "repo": "ickshonpe/ggez", "path": "/src/graphics/text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn account_mut(&mut self) -> &mut Account { Arc::make_mut(&mut self.env).get_account_mut(&self.account) } pub fn input_tx(&self) -> &Transaction { self.env.get_tx(&self.input_tx) } pub fn to_dot<W: Write>(&self, w: &mut W) -> Result<(), io::Error> { write!...
code_fim
hard
{ "lang": "rust", "repo": "ethbmc/ethbmc", "path": "/esvm/src/se/symbolic_state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ConstraintSetSplitter { fn new() -> Self { let constraints = Vec::new(); let ut = UnificationTable::new(); let mapping = HashMap::new(); Self { constraints, ut, mapping, } } #[cfg(test)] fn with_capacity(size...
code_fim
hard
{ "lang": "rust", "repo": "ethbmc/ethbmc", "path": "/esvm/src/se/symbolic_state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ethbmc/ethbmc path: /esvm/src/se/symbolic_state.rs /// The counter for the call depth pub call_depth: usize, /// The Context of the current execution pub context: Arc<Context>, /// Memory from previous transactions pub old_memory: Arc<HashSet<MVal>>, /// Shortcut for t...
code_fim
hard
{ "lang": "rust", "repo": "ethbmc/ethbmc", "path": "/esvm/src/se/symbolic_state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Depending on the attack category, get the correct stats let (attack_mod, defense_mod) = match attack.category { AttackCategory::Physical => { (attacker.stats().attack, defender.stats().defense) } AttackCategory::Special => { (attacker.stats().spec...
code_fim
hard
{ "lang": "rust", "repo": "rwarnking/pir-task-fbecker-rwarnking", "path": "/sheet3/task2/poki.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rwarnking/pir-task-fbecker-rwarnking path: /sheet3/task2/poki.rs lue_pokemon.model().name, blue_pokemon.stats().hp); // For each turn for _ in 0..2 { let (attacker, defender, att) = match turn { 0 => { if red_pokemon.stats().speed >...
code_fim
hard
{ "lang": "rust", "repo": "rwarnking/pir-task-fbecker-rwarnking", "path": "/sheet3/task2/poki.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Stats { hp: hp, speed: stat_formula(base.speed, level), attack: stat_formula(base.attack, level), special_attack: stat_formula(base.special_attack, level), defense: stat_formula(base.defense, level), special_defense: stat_form...
code_fim
hard
{ "lang": "rust", "repo": "rwarnking/pir-task-fbecker-rwarnking", "path": "/sheet3/task2/poki.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Translate from a Cretonne `Reloc` to a raw object-file-format-specific /// relocation code. pub fn raw_relocation(reloc: Reloc, format: BinaryFormat) -> u32 { match format { BinaryFormat::Elf => { use goblin::elf; match reloc { Reloc::Abs4 => elf::re...
code_fim
medium
{ "lang": "rust", "repo": "brson/cretonne", "path": "/lib/faerie/src/container.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brson/cretonne path: /lib/faerie/src/container.rs //! Utilities for working with Faerie container formats. use cretonne_codegen::binemit::Reloc; use target_lexicon::BinaryFormat; <|fim_suffix|>/// Translate from a Cretonne `Reloc` to a raw object-file-format-specific /// relocation code. pub f...
code_fim
medium
{ "lang": "rust", "repo": "brson/cretonne", "path": "/lib/faerie/src/container.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 1Antz1/underscore path: /underscore_vm/src/op.rs macro_rules! op { ($($body:tt)*) => { op_inner! { #[derive(Clone, Copy, Debug)] pub enum OpCode { $($body)* } } } } <|fim_suffix|> self as u8 } } impl TryFr...
code_fim
hard
{ "lang": "rust", "repo": "1Antz1/underscore", "path": "/underscore_vm/src/op.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use self::OpCode::*; match original { 0 => Ok(Return), 1 => Ok(Constant8), 2 => Ok(Constant32), 3 => Ok(Constant64), 4 => Ok(Neg), 5 => Ok(Add), 6 => Ok(Subtract), 7 => Ok(Multiply), ...
code_fim
hard
{ "lang": "rust", "repo": "1Antz1/underscore", "path": "/underscore_vm/src/op.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reitermarkus/msp432p401r-pac path: /src/sysctl/sys_bootover_req.rs #[doc = "Reader of register SYS_BOOTOVER_REQ[%s]"] pub type R = crate::R<u32, super::SYS_BOOTOVER_REQ>; #[doc = "Writer for register SYS_BOOTOVER_REQ[%s]"] pub type W = crate::W<u32, super::SYS_BOOTOVER_REQ>; #[doc = "Register SY...
code_fim
hard
{ "lang": "rust", "repo": "reitermarkus/msp432p401r-pac", "path": "/src/sysctl/sys_bootover_req.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline(always)] pub fn regval(&self) -> REGVAL_R { REGVAL_R::new((self.bits & 0xffff_ffff) as u32) } } impl W { #[doc = "Bits 0:31 - Value set by debugger, read and clear by the CPU"] #[inline(always)] pub fn regval(&mut self) -> REGVAL_W { REGVAL_W { w: self } ...
code_fim
hard
{ "lang": "rust", "repo": "reitermarkus/msp432p401r-pac", "path": "/src/sysctl/sys_bootover_req.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u32) -> &'a mut W { self.w.bits = (self.w.bits & !0xffff_ffff) | ((value as u32) & 0xffff_ffff); self.w } } impl R { #[doc = "Bits 0:31 - Value set by debugger, read and clear by the CP...
code_fim
hard
{ "lang": "rust", "repo": "reitermarkus/msp432p401r-pac", "path": "/src/sysctl/sys_bootover_req.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut session = client.start_session(None).await.unwrap(); session.start_transaction(None).await.unwrap(); let coll = client .database(function_name!()) .collection(function_name!()); coll.insert_one_with_session(doc! { "x": 1 }, None, &mut session) .await ...
code_fim
hard
{ "lang": "rust", "repo": "PhotonQuantum/mongo-rust-driver", "path": "/src/test/spec/versioned_api.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PhotonQuantum/mongo-rust-driver path: /src/test/spec/versioned_api.rs use std::path::PathBuf; use tokio::sync::{RwLockReadGuard, RwLockWriteGuard}; use crate::{ bson::doc, options::{ServerApi, ServerApiVersion}, test::{ run_single_test, run_spec_test_with_path, ...
code_fim
hard
{ "lang": "rust", "repo": "PhotonQuantum/mongo-rust-driver", "path": "/src/test/spec/versioned_api.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> coll.insert_one_with_session(doc! { "y": 2 }, None, &mut session) .await .unwrap(); session.abort_transaction().await.unwrap(); session .abort_transaction() .await .expect_err("aborting twice should fail"); let events = client.get_all_command_starte...
code_fim
hard
{ "lang": "rust", "repo": "PhotonQuantum/mongo-rust-driver", "path": "/src/test/spec/versioned_api.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Amanita-muscaria/eecs753-project path: /src/task_man.rs use crate::tasks::{Task, TaskState}; use cortex_m::asm::bkpt; type TaskList<'a> = [&'a dyn Task; 3]; pub enum TaskID { Current, Next, ID(usize), } pub struct TaskMan<'a> { tasks: TaskList<'a>, times: [i32; 3], tic...
code_fim
hard
{ "lang": "rust", "repo": "Amanita-muscaria/eecs753-project", "path": "/src/task_man.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get(&self, id: TaskID) -> Option<&dyn Task> { match id { TaskID::Current => { if let Some(c) = self.get_current() { Some(self.tasks[c]) } else { None } } TaskID::N...
code_fim
hard
{ "lang": "rust", "repo": "Amanita-muscaria/eecs753-project", "path": "/src/task_man.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juliendoutre/crypto path: /src/padding.rs use std::{cmp, error::Error, fmt}; #[derive(Debug)] pub struct InvalidPaddingError; impl Error for InvalidPaddingError {} impl fmt::Display for InvalidPaddingError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Invalid...
code_fim
hard
{ "lang": "rust", "repo": "juliendoutre/crypto", "path": "/src/padding.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut padded_block = Vec::<u8>::with_capacity(padding_length); for i in 0..cmp::min(padding_length, block.len()) { padded_block.push(block[i]); } let missing_bytes = padding_length - padded_block.len(); if missing_bytes > 0 { for _ in 0.....
code_fim
medium
{ "lang": "rust", "repo": "juliendoutre/crypto", "path": "/src/padding.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if (block.len() as i32 - padding_byte as i32) < 0 { return Err(InvalidPaddingError {}); } for i in 2..(padding_byte + 1) as usize { if block[block.len() - i] != padding_byte { return Err(InvalidPaddingError {}); } } ...
code_fim
hard
{ "lang": "rust", "repo": "juliendoutre/crypto", "path": "/src/padding.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// METADATA for a buddy wich address 2 ^ 20 pages (ie: 4GB) /// multiply by 2 to get nb buddies /// divide by 4 because a buddy is 2 bytes const _METADATA_SIZE: usize = (1 << 20) * 2 / 4; #[cfg(test)] mod test { use super::*; use crate::math::random::srand; use crate::math::random::srand_ini...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/rust_kernel/src/memory/allocator/buddy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sclolus/Turbofish path: /rust_kernel/src/memory/allocator/buddy.rs order `order`. fn first_layer_index(&self, order: Order) -> usize { if order == self.max_order { return 0; } Self::nbr_buddies(self.depth_buddy_from_order(order) - 1) } pub fn meta...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/rust_kernel/src/memory/allocator/buddy.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Order(self.0 + rhs.0) } } impl Order { #[inline(always)] pub fn nbr_pages(self) -> NbrPages { Into::<NbrPages>::into(self) } #[inline(always)] pub fn nbr_bytes(self) -> usize { Into::<usize>::into(self) } } impl From<Order> for NbrPages { #[inline(...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/rust_kernel/src/memory/allocator/buddy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (public_key_0, private_key_0) = &RSA_KEYPAIR_0 as &(RSAPublicKey, RSAPrivateKey); let (public_key_1, private_key_1) = &RSA_KEYPAIR_1 as &(RSAPublicKey, RSAPrivateKey); let (public_key_2, private_key_2) = &RSA_KEYPAIR_2 as &(RSAPublicKey, RSAPrivateKey); let plaintext = thread_...
code_fim
hard
{ "lang": "rust", "repo": "alvaro-cuesta/rustopals", "path": "/tests/set5/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alvaro-cuesta/rustopals path: /tests/set5/mod.rs use rustopals::rsa::{RSAPrivateKey, RSAPublicKey}; // Implement Diffie-Hellman - https://cryptopals.com/sets/5/challenges/33 #[test] fn challenge33_implement_diffie_hellman() { use num_bigint::BigUint; use rustopals::key_exchange::DHOffer...
code_fim
hard
{ "lang": "rust", "repo": "alvaro-cuesta/rustopals", "path": "/tests/set5/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let c_0 = public_key_0.textbook_process(&plaintext).unwrap(); let c_1 = public_key_1.textbook_process(&plaintext).unwrap(); let c_2 = public_key_2.textbook_process(&plaintext).unwrap(); assert_eq!(&private_key_0.textbook_process(&c_0).unwrap(), &plaintext); assert_eq!(&private_key_1.t...
code_fim
hard
{ "lang": "rust", "repo": "alvaro-cuesta/rustopals", "path": "/tests/set5/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let ReturnCode::TpmResourceManager(actual_tpm_response_code) = actual_rc { assert!( matches!(actual_tpm_response_code, TpmResponseCode::FormatOne(_)), "TPM2_RC_ASYMMETRIC in the TPM RESMGR layer did not convert into the expected TpmResponseCode" ); } else...
code_fim
hard
{ "lang": "rust", "repo": "parallaxsecond/rust-tss-esapi", "path": "/tss-esapi/tests/integration_tests/error_tests/return_code_tests/resource_manager_tpm_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let expected_tss_rc = TSS2_RESMGR_TPM_RC_LAYER | TPM2_RC_SEQUENCE; let actual_rc = ReturnCode::try_from(expected_tss_rc) .expect("Failed to convert TPM2_RC_SEQUENCE in the TPM RESMGR layer to a ReturnCode."); if let ReturnCode::TpmResourceManager(actual_tpm_response_code) = actual_rc ...
code_fim
medium
{ "lang": "rust", "repo": "parallaxsecond/rust-tss-esapi", "path": "/tss-esapi/tests/integration_tests/error_tests/return_code_tests/resource_manager_tpm_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// After full validation `SignedBlock` can transform into `ValidBlock`. #[derive(Clone, Debug, Io, Encode, Decode)] pub struct ValidBlock { /// Header pub header: BlockHeader, /// array of transactions, which successfully passed validation and consensus step. pub transactions: Vec<ValidTr...
code_fim
hard
{ "lang": "rust", "repo": "vmarkushin/iroha", "path": "/iroha/src/block.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl BlockHeader { /// Calculate hash of the current block header. pub fn hash(&self) -> Hash { crypto::hash(self.into()) } } impl ChainedBlock { /// Sign block by the given key pair. pub fn sign( self, public_key: &PublicKey, private_key: &PrivateKey, ...
code_fim
hard
{ "lang": "rust", "repo": "vmarkushin/iroha", "path": "/iroha/src/block.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vmarkushin/iroha path: /iroha/src/block.rs //! This module contains `Block` structures for each state, it's transitions, implementations and related traits //! implementations. use crate::{crypto, prelude::*}; use iroha_derive::Io; use parity_scale_codec::{Decode, Encode}; use std::time::System...
code_fim
hard
{ "lang": "rust", "repo": "vmarkushin/iroha", "path": "/iroha/src/block.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: actix/actix-web path: /actix-web-codegen/tests/trybuild/route-malformed-path-fail.rs use actix_web_codegen::get; #[get("/{")] async fn zero() -> &'static str { "malformed resource def" } #[get("/{foo")] async fn one() -> &'static str { "malformed resource def" } #[get("/{}")] async fn...
code_fim
medium
{ "lang": "rust", "repo": "actix/actix-web", "path": "/actix-web-codegen/tests/trybuild/route-malformed-path-fail.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }