text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>#[cfg(feature = "tokio")] fn _expanded_main_tokio() { tokio::runtime::Builder::new() .basic_scheduler() .threaded_scheduler() .enable_all() .build() .unwrap() .block_on(async { { tokio::time::delay_for(DELAY).await; ...
code_fim
hard
{ "lang": "rust", "repo": "faern/leakruntime", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.bearer.lifetime() } } impl FromResponse for Token { fn from_response(json: &Value) -> Result<Self, ParseError> { let bearer = Bearer::from_response(json)?; let id_token = Self::id_token(json)?; Ok(Self { bearer, id_token }) } fn from_response_inherit(...
code_fim
hard
{ "lang": "rust", "repo": "jlindsey/oidc-reqwest", "path": "/src/token.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jlindsey/oidc-reqwest path: /src/token.rs use base64; use biscuit::{CompactJson, Empty, SingleOrMultiple}; use inth_oauth2::client::response::{FromResponse, ParseError}; use inth_oauth2::token::{self, Bearer, Expiring}; use reqwest::Url; use serde::{Deserialize, Serialize}; use serde_json::Value...
code_fim
hard
{ "lang": "rust", "repo": "jlindsey/oidc-reqwest", "path": "/src/token.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Payload containing diagnostics data, if the payload exists, else None. pub payload: Option<Value>, /// Schema version. pub version: i64, } impl JsonInspectSchema { pub fn new( moniker: String, inspect_hierarchy: Option<NodeHierarchy>, timestamp: Time, ...
code_fim
hard
{ "lang": "rust", "repo": "china-liweihong/fuchsia", "path": "/src/diagnostics/archivist/src/formatter/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: china-liweihong/fuchsia path: /src/diagnostics/archivist/src/formatter/mod.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { fuchsia_inspect_node_hierarchy::{ s...
code_fim
hard
{ "lang": "rust", "repo": "china-liweihong/fuchsia", "path": "/src/diagnostics/archivist/src/formatter/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let expected_json = json!({ "moniker": "a/b/c/d", "version": 1, "data_source": "Inspect", "payload": null, "metadata": { "timestamp": 123456, "errors": ["too much fun being had."], "filename": "test_file_plz_igno...
code_fim
hard
{ "lang": "rust", "repo": "china-liweihong/fuchsia", "path": "/src/diagnostics/archivist/src/formatter/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GabrielRavier/doukutsu-rs path: /src/sound/mod.rs self.prev_song_id = self.current_song_id; self.current_song_id = 0; self.tx.send(PlaybackMessage::SaveState)?; self.tx.send(PlaybackMessage::Stop)?; } else if let Some(song_name) = constants.music_ta...
code_fim
hard
{ "lang": "rust", "repo": "GabrielRavier/doukutsu-rs", "path": "/src/sound/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> state = PlaybackState::PlayingOgg; } Ok(PlaybackMessage::PlaySample(id)) => { pixtone.play_sfx(id); } Ok(PlaybackMessage::LoopSample(id)) => { pixtone.lo...
code_fim
hard
{ "lang": "rust", "repo": "GabrielRavier/doukutsu-rs", "path": "/src/sound/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn next_string<T: FromStr, R: io::Read>(reader: &mut Lines<BufReader<R>>) -> GameResult<T> { loop { if let Some(Ok(str)) = reader.next() { let str = str.trim(); if str == "" || str.starts_with("#") { contin...
code_fim
hard
{ "lang": "rust", "repo": "GabrielRavier/doukutsu-rs", "path": "/src/sound/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> assert!(header.magic == *b"NCCH"); header.size = input.read_u32::<LittleEndian>()? as u64 * 0x200; header.partition_id = input.read_u64::<LittleEndian>()?; input.read_exact(&mut header.maker_code)?; input.read_exact(&mut header.version)?; input.read_exact(&...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/ctr-rs", "path": "/src/ncch.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/ctr-rs path: /src/ncch.rs use super::romfs::RomFS; use super::read::Reader; use super::read::VirtualFile; use std::io::Read; use byteorder::ReadBytesExt; use byteorder::LittleEndian; #[derive(Debug)] pub struct NCCH<'a> { file: Reader<'a>, header: Header, } impl<'a> NCCH<'a> { ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/ctr-rs", "path": "/src/ncch.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //let square = engine.objects.get_mut(square_id).unwrap(); //square.no_stretch_update(&mut engine.renderer, engine.window.inner_size()).unwrap(); font.draw("Hello_World", (-100, 50), &mut engine).unwrap(); let radius = 2f32; let start = std::time::SystemTime::now(); let mut rotat...
code_fim
hard
{ "lang": "rust", "repo": "anti-h3r0/BlueEngine", "path": "/examples/dev/dev.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anti-h3r0/BlueEngine path: /examples/dev/dev.rs use blue_engine::{ header::{uniform_type::Matrix, Engine, RotateAxis, WindowDescriptor}, objects::two_dimensions::{square, triangle}, utils::text::Text, }; fn main() { let mut engine = Engine::new(WindowDescriptor { width: ...
code_fim
medium
{ "lang": "rust", "repo": "anti-h3r0/BlueEngine", "path": "/examples/dev/dev.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> engine .update_loop(move |renderer, window, objects, events, camera| { let camx = glm::sin(start.elapsed().unwrap().as_secs_f32()) * radius; let camz = glm::cos(start.elapsed().unwrap().as_secs_f32()) * radius; //camera.set_eye([camx, 0.0, camz]); ...
code_fim
hard
{ "lang": "rust", "repo": "anti-h3r0/BlueEngine", "path": "/examples/dev/dev.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ta[..split], &data[split..]); memmem::rfind_iter(haystack, needle).count(); });<|fim_prefix|>// repo: BurntSushi/memchr path: /fuzz/fuzz_targets/memrmem.rs #![no_main] use libfuzzer_sys::fuzz_target; use memchr::memmem; fuzz_target!(|data: &[u8]| { if data.len() < 2 { return; } ...
code_fim
medium
{ "lang": "rust", "repo": "BurntSushi/memchr", "path": "/fuzz/fuzz_targets/memrmem.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/memchr path: /fuzz/fuzz_targets/memrmem.rs #![no_main] use libfuzzer_sys::fuzz_target; use memchr::memmem; fuzz_target!(|da<|fim_suffix|>ta[..split], &data[split..]); memmem::rfind_iter(haystack, needle).count(); });<|fim_middle|>ta: &[u8]| { if data.len() < 2 { retu...
code_fim
medium
{ "lang": "rust", "repo": "BurntSushi/memchr", "path": "/fuzz/fuzz_targets/memrmem.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let mut data = String::new(); try!(file.read_to_string(&mut data)); toml::from_str::<toml::Value>(&data[..]).map_err(|e| Error::TOML(path, e)) } /// Loads the bot's environment. /// /// This checks two environment variables to determine the paths to load /// configuration files from, `MIAU_C...
code_fim
hard
{ "lang": "rust", "repo": "aji/miau", "path": "/src/environment.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aji/miau path: /src/environment.rs //! Environment and configuration management. //! //! "Environment" is just another word for configuration, but the idea is that //! everything that could affect the way the bot makes configuration-based //! decisions should be encapsulated in the structures fo...
code_fim
hard
{ "lang": "rust", "repo": "aji/miau", "path": "/src/environment.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// The main `struct` for accessing the bot's environment, including /// configuration loaded from files, the command line, and environment /// variables. Any static user configuration should be retrieved from an /// instance of this struct. pub struct EnvInner { config: toml::Value, overlay: t...
code_fim
hard
{ "lang": "rust", "repo": "aji/miau", "path": "/src/environment.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexandermccormick/ecc_auth path: /native/src/keyring.rs use std::fs::{create_dir_all, write as write_file, File}; use std::io::Read; use std::path::PathBuf; use sodiumoxide::crypto::sign; use sodiumoxide::crypto::sign::ed25519::PublicKey; use sodiumoxide::crypto::sign::ed25519::SecretKey; pub...
code_fim
hard
{ "lang": "rust", "repo": "alexandermccormick/ecc_auth", "path": "/native/src/keyring.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> keyring_path_buf.push("secret.key"); write_file(&keyring_path_buf, secret_key).ok(); keyring_path_buf.pop(); } // TODO: check for keys in dir first fn read_keys(keyring_path_buf: &mut PathBuf) -> Keyring { match Keyring::contains_keys(keyring_path_buf) { true => { let ...
code_fim
hard
{ "lang": "rust", "repo": "alexandermccormick/ecc_auth", "path": "/native/src/keyring.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: check for keys in dir first fn read_keys(keyring_path_buf: &mut PathBuf) -> Keyring { match Keyring::contains_keys(keyring_path_buf) { true => { let public_key = Keyring::load_pub_key(keyring_path_buf); let secret_key = Keyring::load_secret_key(keyring_path_buf); ...
code_fim
hard
{ "lang": "rust", "repo": "alexandermccormick/ecc_auth", "path": "/native/src/keyring.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tubbz-alt/fe path: /compiler/src/yul/mappers/functions.rs use crate::errors::CompileError; use crate::yul::mappers::expressions::spanned_expression; use crate::yul::mappers::{ assignments, declarations, expressions, types, }; use crate::yul::namespace::scopes::{ ContractDef, ...
code_fim
hard
{ "lang": "rust", "repo": "Tubbz-alt/fe", "path": "/compiler/src/yul/mappers/functions.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> scope: Shared<FunctionScope>, arg: &Spanned<fe::FuncDefArg>, ) -> Result<(yul::Identifier, FixedSize), CompileError> { let name = arg.node.name.node.to_string(); let typ = types::type_desc_fixed_size(Scope::Function(Rc::clone(&scope)), &arg.node.typ)?; match typ.clone() { Fixe...
code_fim
hard
{ "lang": "rust", "repo": "Tubbz-alt/fe", "path": "/compiler/src/yul/mappers/functions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cbrewster/advent_of_code_2018 path: /day03/src/main.rs use std::collections::{HashMap, HashSet}; #[derive(Debug, Eq, PartialEq)] struct Claim { id: usize, position: (usize, usize), size: (usize, usize), } impl Claim { fn to_sections(&self) -> Vec<(usize, usize)> { let m...
code_fim
hard
{ "lang": "rust", "repo": "cbrewster/advent_of_code_2018", "path": "/day03/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (position, size) = split(rest, ':')?; let (x, y) = split(position.trim(), ',')?; let x = x.trim().parse::<usize>().expect("Failed x"); let y = y.trim().parse::<usize>().expect("Failed y"); let (width, height) = split(size.trim(), 'x')?; let width = width.trim().parse::<usize>(...
code_fim
hard
{ "lang": "rust", "repo": "cbrewster/advent_of_code_2018", "path": "/day03/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //build enumeration f.write_all( quote! { pub enum Method<T> { Bang(B<T>), Float(F<T>), Symbol(S<T>), List(SelList<T>), AnyThing(SelList<T>), Sel(CString, B<T>), SelVarArg(CString, SelList<T>), ...
code_fim
hard
{ "lang": "rust", "repo": "x37v/puredata-rust", "path": "/external/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: x37v/puredata-rust path: /external/build.rs // build.rs use quote::quote; use std::env; use std::fs::File; use std::io::Write; use std::path::Path; #[derive(Clone, Copy, Debug)] enum Arg { Float, Symbol, } impl Arg { pub fn to_string(&self) -> String { match self { ...
code_fim
hard
{ "lang": "rust", "repo": "x37v/puredata-rust", "path": "/external/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(ctx, &decoded); } roundtrip_frame(&Vec::new()); roundtrip_frame(&vec![(vec![1, 2, 3], vec![4, 5, 6])]); } #[test] fn roundtrip_tag() { fn roundtrip_frame(tag: &Tag) { let mut w = new_write(); let _ = codec::encode_tag(&mut w, &tag).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "gperetin/rust-mux", "path": "/tests/packet_roundtrip.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // note that this will fail for precision below 1 ms roundtrip_frame(MessageFrame::Tlease(Tlease{ duration: Duration::new(123, 1_000_000) })); } #[test] fn roundtrip_dtab() { fn roundtrip_frame(table: &Dtab) { let mut w = new_write(); let _ = codec::encode_dtab(&mut w, table)....
code_fim
hard
{ "lang": "rust", "repo": "gperetin/rust-mux", "path": "/tests/packet_roundtrip.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gperetin/rust-mux path: /tests/packet_roundtrip.rs extern crate mux; use mux::*; use std::io; static TDISPATCH_BUF: &'static [u8] = &[ 0, 0, 0, 65, // frame size 2, // TDISPATCH 4, 7, 9, // tag // contexts: 0, 2, // 2 contexts // context 0 key 0, 4, // length ...
code_fim
hard
{ "lang": "rust", "repo": "gperetin/rust-mux", "path": "/tests/packet_roundtrip.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-sundsk/findsatoshi path: /contracts/nft/src/custom.rs use crate::*; #[near_bindgen] impl Contract { pub fn batch_transfer_miners(&mut self, receiver_id: ValidAccountId, token_ids: Vec<TokenId>,) { let sender_id = env::predecessor_account_id(); for token_id in token_id...
code_fim
hard
{ "lang": "rust", "repo": "marco-sundsk/findsatoshi", "path": "/contracts/nft/src/custom.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// list all miner types created in this contract pub fn list_miner_types(&self, from_index: u64, limit: u64 ) ->HashMap<TokenMetadataId, TokenMetadata> { let keys = self.token_metadata_by_id.keys_as_vector(); (from_index..std::cmp::min(from_index + limit, keys.len())).map( ...
code_fim
hard
{ "lang": "rust", "repo": "marco-sundsk/findsatoshi", "path": "/contracts/nft/src/custom.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: standardgalactic/terminusdb-store path: /src/layer/layer.rs yer containing dictionary entries and triples. /// /// A layer can be queried. To answer queries, layers will check their /// own data structures, and if they have a parent, the parent is /// queried as well. pub trait Layer: Send + Syn...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/terminusdb-store", "path": "/src/layer/layer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let triples: Vec<_> = child .triples() .map(|t| child.id_triple_to_string(&t).unwrap()) .collect(); assert_eq!( vec![StringTriple::new_value("cow", "says", "sniff")], triples ); } #[tokio::test] async fn find...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/terminusdb-store", "path": "/src/layer/layer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: standardgalactic/terminusdb-store path: /src/layer/layer.rs to this layer. /// This also counts entries in the parent. fn node_and_value_count(&self) -> usize; /// The amount of predicates known to this layer. /// This also counts entries in the parent. fn predicate_count(&s...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/terminusdb-store", "path": "/src/layer/layer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Outcome { pub(crate) fn log(&self) { match self { Outcome::StackOverflow => { log::error!("the program has overflowed its stack"); } Outcome::HardFault => { log::error!("the program panicked"); } O...
code_fim
hard
{ "lang": "rust", "repo": "numero-744/probe-run", "path": "/src/backtrace/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: numero-744/probe-run path: /src/backtrace/mod.rs use std::path::Path; use probe_rs::{config::RamRegion, Core}; use signal_hook::consts::signal; use crate::elf::Elf; mod pp; mod symbolicate; mod unwind; #[derive(PartialEq, Eq)] pub(crate) enum BacktraceOptions { Auto, Never, Alway...
code_fim
hard
{ "lang": "rust", "repo": "numero-744/probe-run", "path": "/src/backtrace/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/vrcp28sd.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vrcp28sd_1() { run_tes...
code_fim
medium
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vrcp28sd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn vrcp28sd_4() { run_test(&Instruction { mnemonic: Mnemonic::VRCP28SD, operand1: Some(Direct(XMM15)), operand2: Some(Direct(XMM25)), operand3: Some(IndirectDisplaced(RDX, 234583014, 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/vrcp28sd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: watmough/fuzz_survey path: /src/main.rs // generate a bunch of deviation surveys by permuting various // lists of options. #[macro_use] extern crate itertools; mod kop; // kick-off point mod method; // survey computation method mod north; // north refer...
code_fim
hard
{ "lang": "rust", "repo": "watmough/fuzz_survey", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} fn main() { // this should really be specified on the command-line let uwi = "test well"; // get vecs of survey computation methods and north reference methods let methods = ComputationMethod::values(); let references = NorthReference::values(); // KOP at surface makes a 2pt s...
code_fim
medium
{ "lang": "rust", "repo": "watmough/fuzz_survey", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// provide a short name from enums trait SurveyMnemonic { fn mnemonic(&self) -> String; } fn main() { // this should really be specified on the command-line let uwi = "test well"; // get vecs of survey computation methods and north reference methods let methods = ComputationMethod::v...
code_fim
medium
{ "lang": "rust", "repo": "watmough/fuzz_survey", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: renorram/ll_parser path: /src/token.rs use crate::grammar::Grammar; pub const EPSILON: &str = "£"; pub const DOLLAR_SIGN: &str = "$"; #[derive(Debug, Eq, PartialEq, Hash, Clone)] pub enum Token { Variable(char), Terminal(String), Epsilon, DollarSign, Placeholder(char), } i...
code_fim
hard
{ "lang": "rust", "repo": "renorram/ll_parser", "path": "/src/token.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut tokens: Vec<Token> = vec![]; let mut buffer = String::new(); for ch in input.chars() { buffer.push(ch); if buffer.as_str().eq(EPSILON) { tokens.push(Token::Epsilon); buffer.clear() } else if self.grammar.i...
code_fim
hard
{ "lang": "rust", "repo": "renorram/ll_parser", "path": "/src/token.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Get a reference list of chapters pub fn get_documents(&self) -> &Vec<Document> { return &self.scenes; } /// Get a mutable reference to a chapter to work with it pub fn get_document_mut(&mut self, name: String) -> Option<&mut Document> { return self.scenes.iter_mut(...
code_fim
hard
{ "lang": "rust", "repo": "killercup/novelist", "path": "/src/state/data/chapter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: killercup/novelist path: /src/state/data/chapter.rs use super::super::io::{self, chapter::ChapterData, FileContainer}; use super::document::Document; use std::io::Error as IoError; /// A chapter is a collection of scenes #[derive(Debug)] pub(crate) struct Chapter { name: String, descrip...
code_fim
hard
{ "lang": "rust", "repo": "killercup/novelist", "path": "/src/state/data/chapter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ilian98/extended-array path: /src/main.rs 3.to_string(), 2.to_string(), String::from("e") ], &mut exrays, String::from("extract") ) .err(), Some(CommandError::ExrayError(E...
code_fim
hard
{ "lang": "rust", "repo": "ilian98/extended-array", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let index = match words[3].parse::<usize>() { Err(_) => { return Err(CommandError::InsertExrayError(String::from( "Index cannot be parsed as usize", ))) } Ok(num) => num, }; let mut exray_source = exrays.remove(&words[1]).unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "ilian98/extended-array", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ilian98/extended-array path: /src/main.rs t("clone").unwrap().to_vec(), vec![&3, &4, &5, &6, &7] ); assert_match!( extract_or_clone_segment( &[ String::from("1"), String::from("test"), ...
code_fim
hard
{ "lang": "rust", "repo": "ilian98/extended-array", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lorenzoditucci/calyx path: /calyx/src/passes/sharing_components.rs use crate::{ analysis::{GraphColoring, ScheduleConflicts}, ir, }; use ir::{ traversal::{Action, VisResult, Visitor}, CloneName, RRC, }; use itertools::Itertools; use std::{collections::HashMap, rc::Rc}; /// A tra...
code_fim
hard
{ "lang": "rust", "repo": "lorenzoditucci/calyx", "path": "/calyx/src/passes/sharing_components.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn start_if( &mut self, s: &mut ir::If, _comp: &mut ir::Component, _sigs: &ir::LibrarySignatures, ) -> VisResult { let cond_port = &s.port; // XXX(sam), is just having a single cell -> cell map for // rewrites sufficient. or do you need cell...
code_fim
hard
{ "lang": "rust", "repo": "lorenzoditucci/calyx", "path": "/calyx/src/passes/sharing_components.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn deref(&self) -> &Self::Target { &self.0 } } impl Codecs { pub fn to_map(&self) -> BTreeMap<i32, Codec> { self.0 .iter() .map(|codec| (codec.payload().unwrap(), codec.clone())) .collect() } pub fn from_map(codecs: &BTreeMap<i32, C...
code_fim
hard
{ "lang": "rust", "repo": "sdroege/gst-plugin-rs", "path": "/net/webrtc/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sdroege/gst-plugin-rs path: /net/webrtc/src/utils.rs (()) } /// Wrapper around `gst::ElementFactory::make` with a better error /// message pub fn make_element(element: &str, name: Option<&str>) -> Result<gst::Element, Error> { let mut builder = gst::ElementFactory::make(element); if let...
code_fim
hard
{ "lang": "rust", "repo": "sdroege/gst-plugin-rs", "path": "/net/webrtc/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sdroege/gst-plugin-rs path: /net/webrtc/src/utils.rs n) => { if n.is_u64() { Some(n.as_u64().unwrap().to_send_value()) } else if n.is_i64() { Some(n.as_i64().unwrap().to_send_value()) } else if n.is_f64() { Some(...
code_fim
hard
{ "lang": "rust", "repo": "sdroege/gst-plugin-rs", "path": "/net/webrtc/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oussama/libheif-rs path: /src/test.rs #[cfg(test)] mod tests { use crate::*; #[test] fn it_works() -> Result<(), failure::Error> { let mut ctx = Context::new()?; println!("ctx created"); ctx.read_from_file("./data/test.HEIC")?; println!("file created...
code_fim
hard
{ "lang": "rust", "repo": "oussama/libheif-rs", "path": "/src/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for y in 0..img.height() { let mut bytes = Vec::with_capacity((img.width() as usize) * 3); for x in 0..(img.width() as usize) { let offset_y = (y * stride_y) as usize; bytes.push(bytes_y[offset_y + x]); let offset_u = ((y / 2)...
code_fim
hard
{ "lang": "rust", "repo": "oussama/libheif-rs", "path": "/src/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (bytes_v, stride_v) = img.get_plane(Channel::Cr); let mut compress = mozjpeg::Compress::new(mozjpeg::ColorSpace::JCS_YCbCr); compress.set_scan_optimization_mode(mozjpeg::ScanMode::AllComponentsTogether); compress.set_size(img.width() as _, img.height() as _); c...
code_fim
hard
{ "lang": "rust", "repo": "oussama/libheif-rs", "path": "/src/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> collection.push(7); collection.push(2); collection.push(10); println!("Average {}", collection.average()); }<|fim_prefix|>// repo: calebfletcher/LearningRust path: /averaged_collection/src/main.rs use averaged_collection::AveragedCollection; <|fim_middle|>fn main() { let mut collect...
code_fim
medium
{ "lang": "rust", "repo": "calebfletcher/LearningRust", "path": "/averaged_collection/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: calebfletcher/LearningRust path: /averaged_collection/src/main.rs use averaged_collection::AveragedCollection; fn main() { <|fim_suffix|> collection.push(7); collection.push(2); collection.push(10); println!("Average {}", collection.average()); }<|fim_middle|> let mut collect...
code_fim
easy
{ "lang": "rust", "repo": "calebfletcher/LearningRust", "path": "/averaged_collection/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Average {}", collection.average()); }<|fim_prefix|>// repo: calebfletcher/LearningRust path: /averaged_collection/src/main.rs use averaged_collection::AveragedCollection; <|fim_middle|>fn main() { let mut collection = AveragedCollection::new(); collection.push(7); collection.p...
code_fim
medium
{ "lang": "rust", "repo": "calebfletcher/LearningRust", "path": "/averaged_collection/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/src/diagnostics/cpu/constants.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. <|fim_suffix|>lazy_static! { pub static ref ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/src/diagnostics/cpu/constants.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub const CPU_SAMPLE_PERIOD: Duration = Duration::from_secs(60); pub const COMPONENT_CPU_MAX_SAMPLES: usize = 60; pub const MAX_DEAD_TASKS: usize = 90; lazy_static! { pub static ref MEASUREMENT_EPSILON: Duration = CPU_SAMPLE_PERIOD / 6; }<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/compone...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/src/diagnostics/cpu/constants.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>lazy_static! { pub static ref MEASUREMENT_EPSILON: Duration = CPU_SAMPLE_PERIOD / 6; }<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/src/diagnostics/cpu/constants.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-s...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/src/diagnostics/cpu/constants.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub mod attestation_store; pub mod connection; pub mod customization; pub mod firmware_protection; pub mod key_store; pub mod upgrade_storage; pub mod user_presence;<|fim_prefix|>// repo: betrusted-io/xous-core path: /apps/vault/src/api/mod.rs // Copyright 2022 Google LLC // // Licensed under the Apache ...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/apps/vault/src/api/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betrusted-io/xous-core path: /apps/vault/src/api/mod.rs // Copyright 2022 Google LLC // // 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.o...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/apps/vault/src/api/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuhuaer/merlin path: /src/constants.rs /// Domain separation label to initialize the STROBE context. /// /// This should be consist<|fim_suffix|>MERLIN_PROTOCOL_LABEL: &[u8] = b"Merlin v1.0";<|fim_middle|>ent with the crate's semver string. pub const
code_fim
easy
{ "lang": "rust", "repo": "yuhuaer/merlin", "path": "/src/constants.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>MERLIN_PROTOCOL_LABEL: &[u8] = b"Merlin v1.0";<|fim_prefix|>// repo: yuhuaer/merlin path: /src/constants.rs /// Domain separation label to initialize the <|fim_middle|>STROBE context. /// /// This should be consistent with the crate's semver string. pub const
code_fim
medium
{ "lang": "rust", "repo": "yuhuaer/merlin", "path": "/src/constants.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>ent with the crate's semver string. pub const MERLIN_PROTOCOL_LABEL: &[u8] = b"Merlin v1.0";<|fim_prefix|>// repo: yuhuaer/merlin path: /src/constants.rs /// Domain separation label to initialize the <|fim_middle|>STROBE context. /// /// This should be consist
code_fim
easy
{ "lang": "rust", "repo": "yuhuaer/merlin", "path": "/src/constants.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> i in 1..=num{ //当前的数右移一位,此数在状态转移中记录了1的个数, //再看这个数最后一位是否是1 dp[i] = dp[i >> 1] + ((i as i32)%2); } dp } }<|fim_prefix|>// repo: lock19960613/SCL path: /Daily/Rust/Leetcode338-比特位计数.rs impl Solution { pub fn count_bits(num: i32) -> Vec<i32> { ...
code_fim
medium
{ "lang": "rust", "repo": "lock19960613/SCL", "path": "/Daily/Rust/Leetcode338-比特位计数.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lock19960613/SCL path: /Daily/Rust/Leetcode338-比特位计数.rs impl Solution { pub fn count_bits(num: i32) -> Vec<i32> { let num = num as usize; //前i位有多少1 let mut dp = vec![0;num +1]; for<|fim_suffix|>是1 dp[i] = dp[i >> 1] + ((i as i32)%2); } ...
code_fim
medium
{ "lang": "rust", "repo": "lock19960613/SCL", "path": "/Daily/Rust/Leetcode338-比特位计数.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return Ok(Status::Accept); } // ctx.api.add_header("X-Archived", "asdsadadad")?; // print_macros(&ctx.api)?; Ok(Status::Continue) } #[on_close(close_callback)] fn handle_close(ctx: Context<()>) -> milter::Result<Status> { println!("CLOSE"); // print_macros(&ctx.api)?; Ok(Status::Accept) }<|...
code_fim
hard
{ "lang": "rust", "repo": "mmelyp/postfix-milter", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if name.eq("X-Processed-Filter-Id") { println!("HEADER OF INTEREST"); return Ok(Status::Accept); } // ctx.api.add_header("X-Archived", "asdsadadad")?; // print_macros(&ctx.api)?; Ok(Status::Continue) } #[on_close(close_callback)] fn handle_close(ctx: Context<()>) -> milter::Result<Status> { ...
code_fim
hard
{ "lang": "rust", "repo": "mmelyp/postfix-milter", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmelyp/postfix-milter path: /src/main.rs mod models; mod error; use milter::{ on_abort, on_body, on_close, on_connect, on_data, on_eoh, on_eom, on_header, on_helo, on_mail, on_negotiate, on_rcpt, Milter, Context, Actions, MacroValue, ProtocolOpts, Stage, Status, }; use lazy_static::*; use sqlx...
code_fim
hard
{ "lang": "rust", "repo": "mmelyp/postfix-milter", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JustinRyanH/Gush path: /src/lib.rs #[macro_use] extern crate gfx; extern crate gfx_core; extern crate glutin; extern crate gfx_window_glutin; extern crate gfx_device_gl; <|fim_suffix|>pub mod error; pub mod context; pub mod vfs; pub mod texture; pub mod graphics; pub mod camera; pub mod state;<...
code_fim
medium
{ "lang": "rust", "repo": "JustinRyanH/Gush", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod error; pub mod context; pub mod vfs; pub mod texture; pub mod graphics; pub mod camera; pub mod state;<|fim_prefix|>// repo: JustinRyanH/Gush path: /src/lib.rs #[macro_use] extern crate gfx; extern crate gfx_core; extern crate glutin; extern crate gfx_window_glutin; extern crate gfx_device_gl; <...
code_fim
medium
{ "lang": "rust", "repo": "JustinRyanH/Gush", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: katyo/literium path: /rust/backend/src/auth/scope.rs use super::{do_user_auth, get_server_data}; use warp::{self, Filter, Reply}; pub fn auth_scope<S>(state: S) -> imp<|fim_suffix|>data) .or(warp::post2().and_then(do_user_auth)); }<|fim_middle|>l Filter { warp::get2() .and_t...
code_fim
easy
{ "lang": "rust", "repo": "katyo/literium", "path": "/rust/backend/src/auth/scope.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>data) .or(warp::post2().and_then(do_user_auth)); }<|fim_prefix|>// repo: katyo/literium path: /rust/backend/src/auth/scope.rs use super::{do_user_auth, get_server_data}; use warp::{se<|fim_middle|>lf, Filter, Reply}; pub fn auth_scope<S>(state: S) -> impl Filter { warp::get2() .and_t...
code_fim
medium
{ "lang": "rust", "repo": "katyo/literium", "path": "/rust/backend/src/auth/scope.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// An iterator over the columns in a row #[derive(Debug)] pub struct RowIterator(pub *mut _CassIterator); // The underlying C type has no thread-local state, but does not support access // from multiple threads: https://datastax.github.io/cpp-driver/topics/#thread-safety unsafe impl Send for RowIterator...
code_fim
hard
{ "lang": "rust", "repo": "Metaswitch/cassandra-rs", "path": "/src/cassandra/row.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Metaswitch/cassandra-rs path: /src/cassandra/row.rs use crate::cassandra::error::*; use crate::cassandra::inet::Inet; use crate::cassandra::iterator::{MapIterator, SetIterator, UserTypeIterator}; use crate::cassandra::result::CassResult; use crate::cassandra::util::{Protected, ProtectedInner}; ...
code_fim
hard
{ "lang": "rust", "repo": "Metaswitch/cassandra-rs", "path": "/src/cassandra/row.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GraphiteEditor/Graphite path: /libraries/bezier-rs/src/subpath/transform.rs path was open, two open Subpaths will be returned. /// <iframe frameBorder="0" width="100%" height="350px" src="https://graphite.rs/libraries/bezier-rs#subpath/split/solo" title="Split Demo"></iframe> pub fn split(&sel...
code_fim
hard
{ "lang": "rust", "repo": "GraphiteEditor/Graphite", "path": "/libraries/bezier-rs/src/subpath/transform.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn split_at_start_of_a_closed_subpath() { let subpath = set_up_closed_subpath(); let location = subpath.evaluate(SubpathTValue::GlobalParametric(0.)); let (first, second) = subpath.split(SubpathTValue::GlobalParametric(0.)); assert!(second.is_none()); assert_eq!(first.manipulator_group...
code_fim
hard
{ "lang": "rust", "repo": "GraphiteEditor/Graphite", "path": "/libraries/bezier-rs/src/subpath/transform.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let subpath = set_up_closed_subpath(); let location = subpath.evaluate(SubpathTValue::GlobalParametric(0.)); let (first, second) = subpath.split(SubpathTValue::GlobalParametric(0.)); assert!(second.is_none()); assert_eq!(first.manipulator_groups[0].anchor, location); assert_eq!(first.manipulat...
code_fim
hard
{ "lang": "rust", "repo": "GraphiteEditor/Graphite", "path": "/libraries/bezier-rs/src/subpath/transform.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MindFlavor/azure-sdk-for-rust path: /services/mgmt/sql/src/package_composite_v4/operations.rs nError)?; req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret())); } url.query_pairs_mut().append_pair("api-version...
code_fim
hard
{ "lang": "rust", "repo": "MindFlavor/azure-sdk-for-rust", "path": "/services/mgmt/sql/src/package_composite_v4/operations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rosoft.Sql/servers/{}/jobAgents/{}", operation_config.base_path(), subscription_id, resource_group_name, server_name, job_agent_name ); let mut url = url::Url::parse(url_str).map_err(update::Error::ParseUrlError)?; let mut...
code_fim
hard
{ "lang": "rust", "repo": "MindFlavor/azure-sdk-for-rust", "path": "/services/mgmt/sql/src/package_composite_v4/operations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MindFlavor/azure-sdk-for-rust path: /services/mgmt/sql/src/package_composite_v4/operations.rs est URL: {0}")] ParseUrlError(url::ParseError), #[error("Failed to build request: {0}")] BuildRequestError(http::Error), #[error("Failed to execute reques...
code_fim
hard
{ "lang": "rust", "repo": "MindFlavor/azure-sdk-for-rust", "path": "/services/mgmt/sql/src/package_composite_v4/operations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe trait AdapterType: ComWrapper + Clone { /// Try to cast this adapter to a different adapter type fn try_cast<A: AdapterType>(&self) -> Option<A> { unsafe { let ptr = self.clone().into_ptr(); Some(ComWrapper::from_ptr(ptr.cast().ok()?)) } } }<|...
code_fim
medium
{ "lang": "rust", "repo": "ennis/dxgi-rs", "path": "/src/adapter/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ennis/dxgi-rs path: /src/adapter/mod.rs use com_wrapper::ComWrapper; pub use self::adapter::{Adapter, IAdapter}; pub use self::adapter1::{Adapter1, IAdapter1}; pub use self::adapter2::{Adapter2, IAdapter2}; pub use self::adapter3::{Adapter3, IAdapter3}; pub use self::adapter4::{Adapter4, IAdapt...
code_fim
medium
{ "lang": "rust", "repo": "ennis/dxgi-rs", "path": "/src/adapter/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut g = vec![vec![]; n + m]; for i in 0..n { for &x in &s[i] { g[i].push(n + x); g[n + x].push(i); } } let d = bfs(n + m, n + 0, &g); let ans = d[n + (m - 1)]; if ans == INF { println!("-1"); } else { assert!(ans >= 2)...
code_fim
hard
{ "lang": "rust", "repo": "ia7ck/competitive-programming", "path": "/AtCoder/abc302/src/bin/f/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc302/src/bin/f/main.rs use std::collections::VecDeque; use proconio::{input, marker::Usize1}; const INF: usize = std::usize::MAX / 2; fn bfs(n: usize, s: usize, g: &Vec<Vec<usize>>) -> Vec<usize> { let mut d = vec![INF; n]; let mut que = V...
code_fim
medium
{ "lang": "rust", "repo": "ia7ck/competitive-programming", "path": "/AtCoder/abc302/src/bin/f/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { use std::io::BufRead; let input = std::io::stdin(); let input = input.lock(); let input = std::io::BufReader::new(input); let mut lines = input.lines(); let mut constraints = vec![Con::default(); 300]; let mut pin_constraints = vec![None; 300]; while let Some(line) = lines.next() { ...
code_fim
hard
{ "lang": "rust", "repo": "perfectblue/ctf-writeups", "path": "/2020/HITCON/100pins/solver/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> eprintln!("rank = {}", solver.rank); //solver.matrix.show("m"); let state = solver.a_solution(); let nullspace = solver.nullspace(); for guess in 0..1<<nullspace.len() { let mut sol = state; for (i, basis) in nullspace.iter().enumerate() { if guess>>i&1 != 0 { sol ^= basis; } } //e...
code_fim
hard
{ "lang": "rust", "repo": "perfectblue/ctf-writeups", "path": "/2020/HITCON/100pins/solver/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: perfectblue/ctf-writeups path: /2020/HITCON/100pins/solver/src/main.rs struct Mat { row: [u128; 128], } impl Mat { fn show(&self, t: &str) { eprintln!("--"); for i in 0..128 { eprintln!("{} {:0128b}", t, self.row[i]); } } fn zero() -> Self { Mat { row: [0; 128], } } fn m...
code_fim
hard
{ "lang": "rust", "repo": "perfectblue/ctf-writeups", "path": "/2020/HITCON/100pins/solver/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn recover_uncommon_plaintext(jammed: &str) -> String { recover_plaintext_by(jammed, |counts| { match counts.into_iter().min_by_key(|&(_, i)| i) { Some((ch, _)) => ch, None => '?', } }) } pub fn recover_common_plaintext(jammed: &str) -> String { rec...
code_fim
medium
{ "lang": "rust", "repo": "iwillspeak/advent-2016", "path": "/src/day6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn example_is_decoded_correctly() { assert_eq!("easter", recover_common_plaintext(EXAMPLE_INPUT)); } #[test] fn example_less_common_decoded() { assert_eq!("advent", recover_uncommon_plaintext(EXAMPLE_INPUT)); } }<|fim_prefix|>// repo: iwillspeak/advent-2016...
code_fim
hard
{ "lang": "rust", "repo": "iwillspeak/advent-2016", "path": "/src/day6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iwillspeak/advent-2016 path: /src/day6.rs //! Character frequencies use std::collections::HashMap; pub fn recover_plaintext_by<F>(jammed: &str, char_chooser: F) -> String where F: Fn(HashMap<char, usize>) -> char { let mut chars = jammed.lines() .fold(HashMap::new(), |mut count...
code_fim
hard
{ "lang": "rust", "repo": "iwillspeak/advent-2016", "path": "/src/day6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamespettigrew/rstext path: /src/file.rs use std::fs::File; use std::io; use std::io::prelude::{Read, Write}; use std::path::Path; <|fim_suffix|> Ok(file_contents) } pub fn save(path: &Path, content: String) -> io::Result<()> { let file = &mut File::create(path)?; Ok(for c in conten...
code_fim
hard
{ "lang": "rust", "repo": "jamespettigrew/rstext", "path": "/src/file.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(file_contents) } pub fn save(path: &Path, content: String) -> io::Result<()> { let file = &mut File::create(path)?; Ok(for c in content.chars() { let buf = &mut [0u8; 4]; let subslice = c.encode_utf8(buf); file.write(subslice.as_bytes())?; }) }<|fim_prefix|>// r...
code_fim
hard
{ "lang": "rust", "repo": "jamespettigrew/rstext", "path": "/src/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn save(path: &Path, content: String) -> io::Result<()> { let file = &mut File::create(path)?; Ok(for c in content.chars() { let buf = &mut [0u8; 4]; let subslice = c.encode_utf8(buf); file.write(subslice.as_bytes())?; }) }<|fim_prefix|>// repo: jamespettigrew/rstex...
code_fim
medium
{ "lang": "rust", "repo": "jamespettigrew/rstext", "path": "/src/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// let pid = unsafe { nc::getpid() }; /// assert_eq!(ret, Ok(pid)); /// ``` pub unsafe fn setsid() -> Result<pid_t, Errno> { syscall0(SYS_SETSID).map(|ret| ret as pid_t) }<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/setsid.rs /// Create a new session if the calling process is not a process gr...
code_fim
medium
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/setsid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }