text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: ccqpein/Arithmetic-Exercises path: /Matrix-Block-Sum/MBS.rs use std::collections::HashMap; pub fn matrix_block_sum(mat: Vec<Vec<i32>>, k: i32) -> Vec<Vec<i32>> { let xx = mat.len() as i32; let yy = mat.get(0).unwrap_or(&vec![]).len() as i32; <|fim_suffix|>// for r in y - k..=y ...
code_fim
hard
{ "lang": "rust", "repo": "ccqpein/Arithmetic-Exercises", "path": "/Matrix-Block-Sum/MBS.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let ek_rsa = ek::create_ek_object( &mut context, AsymmetricAlgorithmSelection::Rsa(RsaKeyBits::Rsa2048), None, ) .unwrap(); let ak_auth = Auth::try_from(vec![0x1, 0x2, 0x42]).unwrap(); // Without customization, no st clear let att_key_without = ak::create_ak...
code_fim
hard
{ "lang": "rust", "repo": "parallaxsecond/rust-tss-esapi", "path": "/tss-esapi/tests/integration_tests/abstraction_tests/ak_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: parallaxsecond/rust-tss-esapi path: /tss-esapi/tests/integration_tests/abstraction_tests/ak_tests.rs // Copyright 2020 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 use std::convert::{TryFrom, TryInto}; use tss_esapi::{ abstraction::{ak, ek, AsymmetricAlgorithm...
code_fim
hard
{ "lang": "rust", "repo": "parallaxsecond/rust-tss-esapi", "path": "/tss-esapi/tests/integration_tests/abstraction_tests/ak_tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ssavvides/rust-s3 path: /s3/src/lib.rs //! Simple access to Amazon Web Service's (AWS) Simple Storage Service (S3) #![forbid(unsafe_code)] #[macro_use] extern crate serde_derive; pub use awscreds as creds; pub use awsregion as region; <|fim_suffix|>const LONG_DATE: &str = "%Y%m%dT%H%M%SZ"; co...
code_fim
hard
{ "lang": "rust", "repo": "ssavvides/rust-s3", "path": "/s3/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "sync")] pub mod blocking; pub mod bucket; pub mod bucket_ops; pub mod command; pub mod deserializer; #[cfg(feature = "with-tokio")] pub mod request; pub mod serde_types; pub mod signing; #[cfg(feature = "with-async-std")] pub mod surf_request; pub mod request_trait; pub mod utils; const...
code_fim
medium
{ "lang": "rust", "repo": "ssavvides/rust-s3", "path": "/s3/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: radekvit/turn path: /turn_utils/src/regex/builtin.rs use crate::matchers::CharacterCategory; use std::collections::HashMap; pub fn builtin_categories() -> HashMap<&'static str, CharacterCategory> { let mut categories = HashMap::new(); categories.insert("lower", CharacterCategory::Utf8Lo...
code_fim
hard
{ "lang": "rust", "repo": "radekvit/turn", "path": "/turn_utils/src/regex/builtin.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>umeric); categories.insert("0b", CharacterCategory::ASCIIBinaryDigit); categories.insert("0-9", CharacterCategory::ASCIIDigit); categories.insert("0x", CharacterCategory::ASCIIHexDigit); categories.insert(" ", CharacterCategory::ASCIIWhitespace); categories }<|fim_prefix|>// repo: rade...
code_fim
hard
{ "lang": "rust", "repo": "radekvit/turn", "path": "/turn_utils/src/regex/builtin.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: square/sudo_pair path: /sudo_plugin-sys/src/lib.rs // Copyright 2018 Square 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.org/lic...
code_fim
hard
{ "lang": "rust", "repo": "square/sudo_pair", "path": "/sudo_plugin-sys/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> open: None, close: None, show_version: None, log_ttyin: None, log_ttyout: None, log_stdin: None, log_stdout: None, log_stderr: None, register_hooks: None, deregister...
code_fim
hard
{ "lang": "rust", "repo": "square/sudo_pair", "path": "/sudo_plugin-sys/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn score(normalized_probability: f64, outcome: game::Outcome) -> (i64, i64) { let dist = 1.8 * normalized_probability + 0.27; let home_goals = Poisson::new(dist); let away_goals = Poisson::new(dist); let mut h_score: i64 = 0; let mut a_score: i64 = 0; let mut rng = thread_rng(); ...
code_fim
hard
{ "lang": "rust", "repo": "simpajj/football-simulator", "path": "/src/engine/simulation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simpajj/football-simulator path: /src/engine/simulation.rs use rand::distributions::Poisson; use rand::distributions::WeightedIndex; use rand::prelude::*; use crate::model::game; use crate::model::team::Team; const MATCH_IMPORTANCE: f64 = 5.0; enum ResultPoints { Win, Draw, Defeat...
code_fim
hard
{ "lang": "rust", "repo": "simpajj/football-simulator", "path": "/src/engine/simulation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn draw_probability(p_home: f64, p_away: f64) -> f64 { let normalized_p: f64 = p_home / (p_home + p_away); return (1.0 / 3.0) * std::f64::consts::E .powf(-f64::powf(normalized_p - 0.5, 2.0) / (2.0 * f64::powf(0.28, 2.0))); } fn choose_outcome(p_home: f64, p_away: f64, p_draw: ...
code_fim
hard
{ "lang": "rust", "repo": "simpajj/football-simulator", "path": "/src/engine/simulation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cpluscoder/fuchsia path: /src/fonts/tests/integration/src/lib.rs // Copyright 2018 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|>pub const MANIFEST_ALIASES: &str = "/testdata/aliase...
code_fim
medium
{ "lang": "rust", "repo": "cpluscoder/fuchsia", "path": "/src/fonts/tests/integration/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub const MANIFEST_ALIASES: &str = "/testdata/aliases.font_manifest.json"; pub const MANIFEST_EPHEMERAL: &str = "/testdata/ephemeral.font_manifest.json"; pub const MANIFEST_TEST_FONTS_SMALL: &str = "/config/data/test_fonts_small.font_manifest.json"; pub const MANIFEST_TEST_FONTS_MEDIUM: &str = "/config/da...
code_fim
medium
{ "lang": "rust", "repo": "cpluscoder/fuchsia", "path": "/src/fonts/tests/integration/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl From<PathBuf> for Bang { fn from(path: PathBuf) -> Bang { Bang::FilePath(path.to_string_lossy().into_owned()) } } impl <'a> From<&'a Path> for Bang { fn from(path: &Path) -> Bang { Bang::FilePath(path.to_string_lossy().into_owned()) } }<|fim_prefix|>// repo: stephanew...
code_fim
hard
{ "lang": "rust", "repo": "stephaneworkspace/seiri", "path": "/seiri-lib/src/bangs/bangs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stephaneworkspace/seiri path: /seiri-lib/src/bangs/bangs.rs extern crate itertools; use katatsuki::TrackFileType; use crate::error::{Result}; use super::lexer::{lex_query}; use super::parser::{parse_token_stream}; use std::path::{Path, PathBuf}; #[derive(Debug)] pub enum Bang { All, Ti...
code_fim
medium
{ "lang": "rust", "repo": "stephaneworkspace/seiri", "path": "/seiri-lib/src/bangs/bangs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vadixidav/mli path: /mli-relu/src/relu.rs use float_ord::FloatOrd; use mli::*; #[derive(Copy, Clone, Debug)] pub struct Relu; <|fim_suffix|> &self, &input: &f32, _: &(), &output_delta: &f32, ) -> (Self::InputDelta, Self::TrainDelta) { (heaviside(input...
code_fim
hard
{ "lang": "rust", "repo": "vadixidav/mli", "path": "/mli-relu/src/relu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ((), relu(input)) } } impl Backward for Relu { type OutputDelta = f32; type InputDelta = f32; type TrainDelta = (); fn backward( &self, &input: &f32, _: &(), &output_delta: &f32, ) -> (Self::InputDelta, Self::TrainDelta) { (heavisid...
code_fim
medium
{ "lang": "rust", "repo": "vadixidav/mli", "path": "/mli-relu/src/relu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hargoniX/irssi-wire path: /src/irssi/bindgen_output.rs xMatchFlags, error: *mut *mut GError, ) -> *mut gchar; } extern "C" { pub fn g_regex_replace_eval( regex: *const GRegex, string: *const gchar, string_len: gssize, start_position: gint, ...
code_fim
hard
{ "lang": "rust", "repo": "hargoniX/irssi-wire", "path": "/src/irssi/bindgen_output.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hargoniX/irssi-wire path: /src/irssi/bindgen_output.rs r)>, pub get: ::std::option::Option< unsafe extern "C" fn( cb_data: gpointer, source: *mut GSource, func: *mut GSourceFunc, data: *mut gpointer, ), >, } #[test] fn bindg...
code_fim
hard
{ "lang": "rust", "repo": "hargoniX/irssi-wire", "path": "/src/irssi/bindgen_output.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>d::os::raw::c_int, >, ) -> ::std::os::raw::c_int; } extern "C" { pub fn alphasort(__e1: *mut *const dirent, __e2: *mut *const dirent) -> ::std::os::raw::c_int; } extern "C" { pub fn getdirentries( __fd: ::std::os::raw::c_int, __buf: *mut ::std::os::raw::c_char, ...
code_fim
hard
{ "lang": "rust", "repo": "hargoniX/irssi-wire", "path": "/src/irssi/bindgen_output.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "ball", "balm", "balm", "balmi", "balsam", "balsamum", "balth", "balthasar", "balthazar", "bame", "ban", "banburi", "band", "bandi", "band", "bandit", "banditti", "banditto", "band", "bandi", "bandi", "bane", "ban...
code_fim
hard
{ "lang": "rust", "repo": "lgrz/polystem", "path": "/src/fixture_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lgrz/polystem path: /src/fixture_test.rs va", "vacancy", "vacant", "vacation", "vade", "vagabond", "vagabonds", "vagram", "vagrom", "vail", "vailed", "vailing", "vaillant", "vain", "vainer", "vainglory", "vainly", "vainness", ...
code_fim
hard
{ "lang": "rust", "repo": "lgrz/polystem", "path": "/src/fixture_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>, "capon", "capp", "cappadocia", "capriccio", "caprici", "cap", "capt", "captain", "captain", "captainship", "captiou", "captiv", "captiv", "captiv", "captiv", "captiv", "captiv", "captum", "capuciu", "capulet", "capulet",...
code_fim
hard
{ "lang": "rust", "repo": "lgrz/polystem", "path": "/src/fixture_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Frodo45127/cryptopals path: /src/set_1/mod.rs pub mod challenge_1; pub mod challenge_2; pub mod challenge_3; pub mod challenge_4;<|fim_suffix|> pub mod challenge_7; pub mod challenge_8;<|fim_middle|> pub mod challenge_5; pub mod challenge_6;
code_fim
easy
{ "lang": "rust", "repo": "Frodo45127/cryptopals", "path": "/src/set_1/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub mod challenge_5; pub mod challenge_6; pub mod challenge_7; pub mod challenge_8;<|fim_prefix|>// repo: Frodo45127/cryptopals path: /src/set_1/mod.rs pub mod challenge_1; pub mod challenge_2;<|fim_middle|> pub mod challenge_3; pub mod challenge_4;
code_fim
easy
{ "lang": "rust", "repo": "Frodo45127/cryptopals", "path": "/src/set_1/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub mod challenge_7; pub mod challenge_8;<|fim_prefix|>// repo: Frodo45127/cryptopals path: /src/set_1/mod.rs pub mod challenge_1; pub mod challenge_2; pub mod challenge_3; pub mod challenge_4;<|fim_middle|> pub mod challenge_5; pub mod challenge_6;
code_fim
easy
{ "lang": "rust", "repo": "Frodo45127/cryptopals", "path": "/src/set_1/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mraware/img2brs path: /src/lib.rs mod utils; mod convert; use wasm_bindgen::prelude::*; // use wasm_bindgen::JsCast; // use wasm_bindgen_futures::JsFuture; use js_sys::ArrayBuffer; use js_sys::Uint8Array; use js_sys::Array; use web_sys::File; use convert::structs::*; // When the ...
code_fim
medium
{ "lang": "rust", "repo": "mraware/img2brs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut brs_vec: Vec<u8> = vec![]; let convert_data = convert::convert(&img, &mut brs_vec, options); let uint_array = Uint8Array::new(&JsValue::from_serde(&brs_vec).unwrap()); let array_buffer = uint_array.buffer(); let array = Array::new(); array.push(&JsValue::from(&...
code_fim
hard
{ "lang": "rust", "repo": "mraware/img2brs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let image_uint8 = Uint8Array::new(&JsValue::from(&image_str)); let mut image_uint8_vec: Vec<u8> = vec![0; image_uint8.length() as usize]; image_uint8.copy_to(&mut image_uint8_vec); let result = image::load_from_memory(&image_uint8_vec); let img = match result { Ok(im...
code_fim
medium
{ "lang": "rust", "repo": "mraware/img2brs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tokio::spawn(async move { let token = secrets::api_token(); let session = environment.client.open_session(&token); match event { SlackPushEvent::UrlVerification(_) => {} SlackPushEvent::EventCallback(ec) => match ec.event { SlackEventCal...
code_fim
hard
{ "lang": "rust", "repo": "tkzwhr/tsukedaicho", "path": "/slack-api/src/server/handler/event.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let slack_users_req = SlackApiUsersListRequest::new(); let slack_users_res = session.users_list(&slack_users_req).await; if let Err(err) = slack_users_res.as_ref() { error!("[Slack API] Failed to fetch users. Err={:#?}", err); return; } let tsukes = data_res.unwrap().i...
code_fim
hard
{ "lang": "rust", "repo": "tkzwhr/tsukedaicho", "path": "/slack-api/src/server/handler/event.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tkzwhr/tsukedaicho path: /slack-api/src/server/handler/event.rs use std::sync::Arc; use axum::Extension; use axum::response::Response; use http::header::CONTENT_TYPE; use hyper::Body; use log::*; use slack_morphism::api::SlackApiViewsPublishRequest; use slack_morphism::prelude::*; use crate::{...
code_fim
hard
{ "lang": "rust", "repo": "tkzwhr/tsukedaicho", "path": "/slack-api/src/server/handler/event.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: putuwaw/tlx-toki-answer path: /05. Percabangan/E. If Then Case/e_if_then_case.rs fn main() { let mut reader = String::new(); std::io::stdin().read_line(&mut reader).expect(""); <|fim_suffix|> else if n > 999{ println!("ribuan"); } else if n > 99{ println!("ra...
code_fim
medium
{ "lang": "rust", "repo": "putuwaw/tlx-toki-answer", "path": "/05. Percabangan/E. If Then Case/e_if_then_case.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } else if n > 9{ println!("puluhan"); } else{ println!("satuan"); } }<|fim_prefix|>// repo: putuwaw/tlx-toki-answer path: /05. Percabangan/E. If Then Case/e_if_then_case.rs fn main() { let mut reader = String::new(); std::io::stdin().read_line(&mut reader).expe...
code_fim
medium
{ "lang": "rust", "repo": "putuwaw/tlx-toki-answer", "path": "/05. Percabangan/E. If Then Case/e_if_then_case.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut stdin = std::io::stdin(); let mut stdout = std::io::stdout(); let mut tty_eof = false; let mut events = Events::with_capacity(8); while !tty_eof && (listener.is_some() || connection.is_some()) { poll.poll(&mut events, None).expect("mio poll call failed"); for ...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/chat-mio", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jimblandy/chat-mio path: /src/main.rs extern crate mio; use mio::{Events, Poll, PollOpt, Ready, Token}; use mio::tcp::{TcpListener, TcpStream}; use mio::unix::EventedFd; use std::io::{Read, Write}; use std::net::{SocketAddr, ToSocketAddrs}; const USAGE: &'static str = "Usage: chat-mio [--serve...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/chat-mio", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn bench_mpc() { println!( "\nBenching mpc hashing ({} nodes, {} probes, {} items)", NODES, HASH_COUNT, ITEMS, ); let mut rng = XorShiftRng::new_unseeded(); let mut occ_map = HashMap::new(); let mut nodes = Vec::new(); let mut ring = mpc::Ring::new(HASH_COUNT); ...
code_fim
hard
{ "lang": "rust", "repo": "tuplecats/hash-rings-rs", "path": "/src/bin/bench.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tuplecats/hash-rings-rs path: /src/bin/bench.rs use hash_rings::{carp, consistent, jump, maglev, mpc, rendezvous, weighted_rendezvous}; use rand::{Rng, XorShiftRng}; use std::collections::HashMap; use std::time::{Duration, Instant}; const HASH_COUNT: u64 = 21; const REPLICAS: u64 = 1611; const ...
code_fim
hard
{ "lang": "rust", "repo": "tuplecats/hash-rings-rs", "path": "/src/bin/bench.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut occ_map = HashMap::new(); let ring = jump::Ring::new(NODES as u32); for i in 0..NODES as u32 { occ_map.insert(i, 0f64); } let start = Instant::now(); for _ in 0..ITEMS { let id = ring.get_node(&rng.next_u64()); *occ_map.get_mut(&id).unwrap() += 1.0...
code_fim
hard
{ "lang": "rust", "repo": "tuplecats/hash-rings-rs", "path": "/src/bin/bench.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wycats/genawaiter path: /src/testing.rs use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; pub struct DummyFuture; impl Future for DummyFuture { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> { Poll::Pending...
code_fim
medium
{ "lang": "rust", "repo": "wycats/genawaiter", "path": "/src/testing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let this = unsafe { self.get_unchecked_mut() }; this.countdown -= 1; if this.countdown == 0 { Poll::Ready(()) } else { cx.waker().wake_by_ref(); Poll::Pending } } }<|fim_prefix|>// repo: wycats/genawaiter path: /src/testing.r...
code_fim
medium
{ "lang": "rust", "repo": "wycats/genawaiter", "path": "/src/testing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PlatinumTeam/MBExtender path: /MBExtender/rust/mbx/src/con_/command.rs use super::SimObject; use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::ptr; use std::slice; /// Type for the argv pointer passed to console functions. pub type Argv = *const *const c_char; pub type BoolFn =...
code_fim
hard
{ "lang": "rust", "repo": "PlatinumTeam/MBExtender", "path": "/MBExtender/rust/mbx/src/con_/command.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn tge_add_command_ns_bool(ns_name: *const c_char, name: *const c_char, cb: BoolFn, usage: *const c_char, min_args: i32, max_args: i32) = tge_addr!(0x40243c, 0x3c5e0); pub fn tge_add_command_ns_float(ns_name: *const c_char, name: *const c_char, cb: FloatFn, usage: *const c_char, min_args: i32,...
code_fim
hard
{ "lang": "rust", "repo": "PlatinumTeam/MBExtender", "path": "/MBExtender/rust/mbx/src/con_/command.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bxlkm1/Rust-Algorithm path: /rust-algorithm/rbtree/src/rbtree/create.rs use std::rc::{Rc,Weak}; use std::cell::RefCell; use std::fmt::Debug; pub (super) type ChildNodePointer<K:Debug + Clone + PartialOrd,V:Debug + Clone> = Rc<RefCell<RBNode<K,V>>>; pub (super) type ChildNode<K:Debug + Clone + Pa...
code_fim
hard
{ "lang": "rust", "repo": "bxlkm1/Rust-Algorithm", "path": "/rust-algorithm/rbtree/src/rbtree/create.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<K,V> RBTree<K,V> where K: Debug + Clone + PartialOrd, V: Debug + Clone, { pub fn new(key:K,value:V) -> RBTree<K,V> { return RBTree { root:Some(Rc::new(RefCell::new(RBNode::new(key,value,NodeColor::Black)))), } } }<|fim_prefix|>// repo: bxlkm1/R...
code_fim
hard
{ "lang": "rust", "repo": "bxlkm1/Rust-Algorithm", "path": "/rust-algorithm/rbtree/src/rbtree/create.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub unsafe fn sse_convert_with_truncation_f32_to_i32(x: f32) -> i32 { let x = x.trunc(); if x >= -2147483648.0 && x < 2147483648.0 { return x as i64 as i32; } else { // TODO: Signal return -0x80000000; }; } #[no_mangle] pub unsafe fn sse_convert_f32...
code_fim
hard
{ "lang": "rust", "repo": "copy/v86", "path": "/src/rust/cpu/sse_instr.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: copy/v86 path: /src/rust/cpu/sse_instr.rs use cpu::cpu::*; use cpu::global_pointers::mxcsr; pub unsafe fn mov_r_m64(addr: i32, r: i32) { // mov* m64, mm let data = read_mmx64s(r); return_on_pagefault!(safe_write64(addr, data)); transition_fpu_to_mmx(); } pub unsafe fn movl_r128_...
code_fim
hard
{ "lang": "rust", "repo": "copy/v86", "path": "/src/rust/cpu/sse_instr.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // Terminate the component if we are unable to find a TPM20. let tpm_device_proxy = match find_tpm20().await { Ok(proxy) => proxy, Err(e) => { tracing::warn!("Unable to find tpm20: {:?}", e); component::health().set_unhealthy("No TPM20 found"); r...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/security/bin/tpm_agent/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/security/bin/tpm_agent/src/main.rs // Copyright 2022 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. mod discovery; use crate::discovery::find_tpm20; use anyhow::{anyho...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/security/bin/tpm_agent/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> service_fs .dir("svc") .add_fidl_service(IncomingRequest::Command) .add_fidl_service(IncomingRequest::Provision) .add_fidl_service(IncomingRequest::Deprovision); service_fs.take_and_serve_directory_handle().context("Failed to serve outgoing namespace")?; compon...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/security/bin/tpm_agent/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn get_device_extensions() -> Vec<*const i8> { vec![Swapchain::name().as_ptr()] } pub fn get_usable_gpu(instance: &Arc<renderer::Instance>, surface: &RVSurface) -> (PhysicalDevice, u32) { let p_devices: Vec<PhysicalDevice> = instance.enumerate_physical_devices().expect("Physical device error"); ...
code_fim
hard
{ "lang": "rust", "repo": "JoelWaterworth/rust_game_engine", "path": "/src/renderer/device/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.allocate_memory(&allocate_info, None).unwrap() }} pub fn get_memory_type(&self, memory_req: &vk::MemoryRequirements, properties: vk::MemoryPropertyFlags) -> Option<u32> { let mut memory_type_bits = memory_req.memory_type_bits; for (i, ref memory_type) in self.memory_p...
code_fim
hard
{ "lang": "rust", "repo": "JoelWaterworth/rust_game_engine", "path": "/src/renderer/device/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoelWaterworth/rust_game_engine path: /src/renderer/device/mod.rs use ash; use ash::vk; use ash::vk::*; use std::default::Default; use std::ptr; use ash::version::{InstanceV1_0, DeviceV1_0, V1_0}; use ash::extensions::{Swapchain, DebugReport}; use std::ops::Drop; use std::sync::Arc; use rende...
code_fim
hard
{ "lang": "rust", "repo": "JoelWaterworth/rust_game_engine", "path": "/src/renderer/device/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use rand::RngCore; let mut rng = get_rng(); b.iter(|| { let a = BigInt::from(rng.next_u64()); let b = BigInt::from(rng.next_u64()); BigRational::new(a, b) }); } #[bench] fn alloc_ratio_u64_bench(b: &mut Bencher) { use rand::RngCore; let mut rng = get_rng();...
code_fim
medium
{ "lang": "rust", "repo": "rust-num/num-rational", "path": "/ci/benchmarks/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-num/num-rational path: /ci/benchmarks/src/main.rs #![feature(test)] extern crate test; use num_bigint::BigInt; use num_rational::{BigRational, Ratio}; use test::Bencher; <|fim_suffix|> use rand::RngCore; let mut rng = get_rng(); b.iter(|| { let a = BigInt::from(rng.nex...
code_fim
medium
{ "lang": "rust", "repo": "rust-num/num-rational", "path": "/ci/benchmarks/src/main.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, PartialEq)] pub enum DecompressionError { InvalidLength(usize), NearPointerOffsetOutOfBounds { decompressed_length: usize, offset: u8, word_count: u8 }, FarPointerOffsetOutOfBounds { decompressed_length: usize, offset: u16, wo...
code_fim
hard
{ "lang": "rust", "repo": "Xiyng/gamemaps-parser-rust", "path": "/src/gamemaps_parser/compression/carmack/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xiyng/gamemaps-parser-rust path: /src/gamemaps_parser/compression/carmack/mod.rs #[cfg(test)] mod tests; extern crate byteorder; use std::fmt; use self::byteorder::*; const NEAR_SIGNAL: u8 = 0xa7; const FAR_SIGNAL: u8 = 0xa8; pub fn decompress(data: &Vec<u8>, start_offset: usize) -> Result<V...
code_fim
hard
{ "lang": "rust", "repo": "Xiyng/gamemaps-parser-rust", "path": "/src/gamemaps_parser/compression/carmack/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>Vec<HValue>| { vec![42.to_hvalue()] }).unwrap(); }) }<|fim_prefix|>// repo: tempbottle/holmes path: /tests/func_basic.rs use common::*; use holmes::client::*; use holmes::native_types::*; #[test] pub fn reg_func() { server_single(&|client : &mut Client| { f<|fim_middle|>unc!(c...
code_fim
medium
{ "lang": "rust", "repo": "tempbottle/holmes", "path": "/tests/func_basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tempbottle/holmes path: /tests/func_basic.rs use common::*; use holmes::client::*; use holmes::native_types::*; #[t<|fim_suffix|>unc!(client, let test_func : [uint64] -> [uint64] = |_v : Vec<HValue>| { vec![42.to_hvalue()] }).unwrap(); }) }<|fim_middle|>est] p...
code_fim
medium
{ "lang": "rust", "repo": "tempbottle/holmes", "path": "/tests/func_basic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NicolasLagaillardie/mpst_rust_github path: /src/transport/http/choose.rs //! This module contains the macros //! for creating choose functions //! for an HTTP connection, for at least two participants. //! //! *This module is available only if MultiCrusty is built with //! the `"transport"` feat...
code_fim
hard
{ "lang": "rust", "repo": "NicolasLagaillardie/mpst_rust_github", "path": "/src/transport/http/choose.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>(s)?; /// client_recurs(s, xs, index + 1) /// } /// Option::None => { /// let s = choose_mpst_multi_http_to_all!( /// s, /// CBranchesAtoC::End, /// CBranchesBtoC::End, => /// RoleA, /// RoleB, => /// RoleD, /// ...
code_fim
hard
{ "lang": "rust", "repo": "NicolasLagaillardie/mpst_rust_github", "path": "/src/transport/http/choose.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GTrunSec/nix-vulnerability-scanner path: /src/web/views/result.rs use actix_web::dev::AsyncResult; use actix_web::{HttpRequest, HttpResponse, Responder}; // Custom Result type that allows us to implement at Responder that uses `into` for the types // The default implementation doesn't allow dif...
code_fim
medium
{ "lang": "rust", "repo": "GTrunSec/nix-vulnerability-scanner", "path": "/src/web/views/result.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self, req: &HttpRequest<S>, ) -> actix_web::Result<AsyncResult<HttpResponse>, actix_web::Error> { // unwrap each of the fields and convert the inner values // it is a bit sad that there doesn't seem to be a nicer way to write this. match self { HttpR...
code_fim
medium
{ "lang": "rust", "repo": "GTrunSec/nix-vulnerability-scanner", "path": "/src/web/views/result.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jkcomment/rust-libp2p path: /protocols/mdns/src/lib.rs // Copyright 2018 Parity Technologies (UK) 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 Software without re...
code_fim
hard
{ "lang": "rust", "repo": "jkcomment/rust-libp2p", "path": "/protocols/mdns/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>lazy_static! { pub static ref IPV4_MDNS_MULTICAST_ADDRESS: Ipv4Addr = Ipv4Addr::new(224, 0, 0, 251); pub static ref IPV6_MDNS_MULTICAST_ADDRESS: Ipv6Addr = Ipv6Addr::new(0xFF02, 0, 0, 0, 0, 0, 0, 0xFB); } /// Configuration for mDNS. #[derive(Debug, Clone)] pub struct MdnsConfig { /// ...
code_fim
hard
{ "lang": "rust", "repo": "jkcomment/rust-libp2p", "path": "/protocols/mdns/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harikrishnanm/script path: /src/asset/mod.rs pub mod asset; pub mod models; use actix_web::{ post, web, web::{Data, Path, ReqData}, HttpResponse, }; <|fim_suffix|>use crate::asset::models::*; use crate::error::ScriptError; use crate::rbac::models::Identity; use crate::AppData; #[post("/...
code_fim
medium
{ "lang": "rust", "repo": "harikrishnanm/script", "path": "/src/asset/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[post("/site/{site_name}/collection/{collection_name}/asset")] async fn save( identity: ReqData<Identity>, data: Data<AppData>, new_asset: web::Json<NewAsset>, Path((site_name, coll_name)): Path<(String, String)>, ) -> Result<HttpResponse, ScriptError> { debug!("Creating asset under {}/{}", sit...
code_fim
medium
{ "lang": "rust", "repo": "harikrishnanm/script", "path": "/src/asset/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: etaoins/arret path: /lsp-server/capabilities.rs pub fn server_capabilities() -> lsp_types::ServerCapabilities { lsp_types::ServerCapabilities { text_document_sync: Some(lsp_types::TextDocumentSyncCapability::Options( lsp_ty<|fim_suffix|> )), workspace: Some...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/lsp-server/capabilities.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>change_notifications: Some( lsp_types::WorkspaceFolderCapabilityChangeNotifications::Bool(true), ), }), }), ..Default::default() } }<|fim_prefix|>// repo: etaoins/arret path: /lsp-server/capabilities.rs pub fn server_capabilities() -> ls...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/lsp-server/capabilities.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> std::io::Result<()> { let file = File::open("input.txt")?; let reader = BufReader::new(file); let mut claims: Vec<Claim> = Vec::new(); let mut grid = [[false; 1000]; 1000]; let mut overlaps: HashSet<(usize, usize)> = HashSet::new(); // read into memory for line in...
code_fim
hard
{ "lang": "rust", "repo": "mumblez/adventofcode2018-rust", "path": "/day-03-p1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mumblez/adventofcode2018-rust path: /day-03-p1/src/main.rs use std::collections::HashSet; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; #[derive(Debug, Copy, Clone)] struct Claim { x: usize, y: usize, width: usize, height: usize, } fn parse(line: &str) -> ...
code_fim
hard
{ "lang": "rust", "repo": "mumblez/adventofcode2018-rust", "path": "/day-03-p1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Drop for Texture { fn drop(&mut self) { self.context .allocator() .destroy_image(self.image, &self.allocation) .expect("Failed to destroy image!"); } } pub struct CubemapFaces { pub right: String, pub left: String, pub top: String, ...
code_fim
hard
{ "lang": "rust", "repo": "jsyszh/dragonglass", "path": "/src/renderer/backend/vulkan/src/resource/texture.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jsyszh/dragonglass path: /src/renderer/backend/vulkan/src/resource/texture.rs (); let regions = [region]; let buffer = Buffer::new_mapped_basic( self.context.clone(), self.allocation_info().get_size() as _, vk::BufferUsageFlags::TRANSFER_SRC, ...
code_fim
hard
{ "lang": "rust", "repo": "jsyszh/dragonglass", "path": "/src/renderer/backend/vulkan/src/resource/texture.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> command_pool.transition_image_layout( &barriers, vk::PipelineStageFlags::TOP_OF_PIPE, vk::PipelineStageFlags::TRANSFER, ); command_pool.copy_buffer_to_image( self.context.graphics_queue(), buffer.buffer(), sel...
code_fim
hard
{ "lang": "rust", "repo": "jsyszh/dragonglass", "path": "/src/renderer/backend/vulkan/src/resource/texture.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if lines[y].chars().nth(x).unwrap() == '#' { counter += 1; } } println!("There are {} trees", counter); }<|fim_prefix|>// repo: wyattlake/advent-of-code-2020 path: /src/day_3/puzzle_1.rs use std::fs::File; use std::io::{BufRead, BufReader}; pub fn solution() { let fil...
code_fim
medium
{ "lang": "rust", "repo": "wyattlake/advent-of-code-2020", "path": "/src/day_3/puzzle_1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>let mut counter = 0; for y in 0..lines.len() { let x = (y * 3) % lines[0].len(); println!("x: {}, y: {}", x, y); if lines[y].chars().nth(x).unwrap() == '#' { counter += 1; } } println!("There are {} trees", counter); }<|fim_prefix|>// repo: wyattlake...
code_fim
medium
{ "lang": "rust", "repo": "wyattlake/advent-of-code-2020", "path": "/src/day_3/puzzle_1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wyattlake/advent-of-code-2020 path: /src/day_3/puzzle_1.rs use std::fs::File; use std::io::{BufRead, BufReader}; pub fn solution() { let file = File::open("src/day_3/map.txt").expect("Could not open file"); let file = BufReader::new(file); let lines: Vec<String> = file.lines().map(|...
code_fim
medium
{ "lang": "rust", "repo": "wyattlake/advent-of-code-2020", "path": "/src/day_3/puzzle_1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let now = Instant::now(); let (noun, verb) = puzzle2::find_pair_for(&mut op_code_list, expected_result); println!("Puzzle2 executed in {} ms => Result is: {}", now.elapsed().as_millis(), puzzle2_solution(noun, verb) ); }<|fim_prefix|>// repo: mcctor/Advent_of_Code...
code_fim
hard
{ "lang": "rust", "repo": "mcctor/Advent_of_Code_2019", "path": "/day2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mcctor/Advent_of_Code_2019 path: /day2/src/main.rs use std::time::Instant; mod puzzle1; mod puzzle2; fn main() { puzzle_1(); puzzle_2(); } <|fim_suffix|> let expected_result = 19690720; let puzzle2_solution = |noun, verb| (100 * noun) + verb; let mut op_code_list = puzzle1:...
code_fim
hard
{ "lang": "rust", "repo": "mcctor/Advent_of_Code_2019", "path": "/day2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yeslogic/allsorts-tools path: /src/subset.rs use std::borrow::Borrow; use std::fs::File; use std::io::Write; use std::str; use allsorts::binary::read::ReadScope; use allsorts::font::read_cmap_subtable; use allsorts::font_data::FontData; use allsorts::gsub::{GlyphOrigin, RawGlyph}; use allsorts:...
code_fim
hard
{ "lang": "rust", "repo": "yeslogic/allsorts-tools", "path": "/src/subset.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut glyphs: Vec<RawGlyph<()>> = glyphs.into_iter().flatten().collect(); glyphs.sort_by(|a, b| a.glyph_index.cmp(&b.glyph_index)); let mut glyph_ids = glyphs .iter() .map(|glyph| glyph.glyph_index) .collect::<Vec<_>>(); glyph_ids.dedup(); if glyph_ids.is_empt...
code_fim
hard
{ "lang": "rust", "repo": "yeslogic/allsorts-tools", "path": "/src/subset.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hkbudb/slimchain path: /slimchain-chain/src/access_map/acc_rev_access_map.rs use super::BlockHeightList; use serde::{Deserialize, Serialize}; use slimchain_common::{ basic::{BlockHeight, StateKey}, rw_set::{AccountReadSet, AccountWriteData}, }; pub trait RevAccessItem { fn nonce_con...
code_fim
hard
{ "lang": "rust", "repo": "hkbudb/slimchain", "path": "/slimchain-chain/src/access_map/acc_rev_access_map.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn add_code(&mut self, block_height: BlockHeight) { self.code.add_block_height(block_height); } pub fn add_value(&mut self, key: StateKey, block_height: BlockHeight) { self.values .entry(key) .or_default() .add_block_height(block_height)...
code_fim
hard
{ "lang": "rust", "repo": "hkbudb/slimchain", "path": "/slimchain-chain/src/access_map/acc_rev_access_map.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: argmin-rs/argmin path: /argmin/examples/brentopt.rs // Copyright 2018-2020 argmin developers // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your optio...
code_fim
medium
{ "lang": "rust", "repo": "argmin-rs/argmin", "path": "/argmin/examples/brentopt.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Test function: `f(x) = exp(-x) - exp(5-x/2)` /// xmin == 2 log(2 exp(-5)) /// xmin ~= -8.6137056388801093812 /// f(xmin) == -exp(10)/4 /// f(xmin) ~= -5506.6164487016791292 struct TestFunc {} impl CostFunction for TestFunc { // one dimensional problem, no vector needed type Param = f64; t...
code_fim
medium
{ "lang": "rust", "repo": "argmin-rs/argmin", "path": "/argmin/examples/brentopt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hacker-DOM/rust-playground path: /playground/src/main.rs // mod types; // mod graph; // mod concurrency; // mod trait_objects; <|fim_suffix|> // types::run(); // graph::run(); // concurrency::run(); // trait_objects::run(); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "hacker-DOM/rust-playground", "path": "/playground/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // types::run(); // graph::run(); // concurrency::run(); // trait_objects::run(); }<|fim_prefix|>// repo: hacker-DOM/rust-playground path: /playground/src/main.rs // mod types; // mod graph; // mod concurrency; // mod trait_objects; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "hacker-DOM/rust-playground", "path": "/playground/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn vprold_9() { run_test( &Instruction { mnemonic: Mnemonic::VPROLD, operand1: Some(Direct(YMM7)), operand2: Some(IndirectScaledIndexedDisplaced( EDX, ECX, Two, 784313649, ...
code_fim
hard
{ "lang": "rust", "repo": "ftilde/rust-x86asm", "path": "/src/test/instruction_tests/instr_vprold.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ftilde/rust-x86asm path: /src/test/instruction_tests/instr_vprold.rs use instruction_def::*; use test::run_test; use Operand::*; use Reg::*; use RegScale::*; use RegType::*; use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; #[test] fn vprold_1() { ...
code_fim
hard
{ "lang": "rust", "repo": "ftilde/rust-x86asm", "path": "/src/test/instruction_tests/instr_vprold.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joao-conde/advents-of-code path: /2020/src/bin/day25.rs use std::fs; fn main() { let pub_keys = fs::read_to_string("input/day25").expect("failure opening input file"); let pub_door = pub_keys.lines().next().unwrap().parse::<usize>().unwrap(); let pub_card = pub_keys.lines().nth(1).u...
code_fim
medium
{ "lang": "rust", "repo": "joao-conde/advents-of-code", "path": "/2020/src/bin/day25.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let p1 = (0..loop_size).fold(1, |x, _| x * pub_door % 20201227); println!("Part1: {}", p1); println!("Part2: free 🌟!"); }<|fim_prefix|>// repo: joao-conde/advents-of-code path: /2020/src/bin/day25.rs use std::fs; fn main() { let pub_keys = fs::read_to_string("input/day25").expect("failu...
code_fim
medium
{ "lang": "rust", "repo": "joao-conde/advents-of-code", "path": "/2020/src/bin/day25.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Default)] pub(crate) struct AstEnumSrc { pub(crate) doc: Vec<String>, pub(crate) name: String, pub(crate) traits: Vec<String>, pub(crate) variants: Vec<String>, }<|fim_prefix|>// repo: pnoken/tools path: /crates/syntax_codegen/src/ast_src.rs #[derive(Default, Debug)] pub(crate) struct...
code_fim
hard
{ "lang": "rust", "repo": "pnoken/tools", "path": "/crates/syntax_codegen/src/ast_src.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pnoken/tools path: /crates/syntax_codegen/src/ast_src.rs #[derive(Default, Debug)] pub(crate) struct AstSrc { pub(crate) tokens: Vec<String>, pub(crate) nodes: Vec<AstNodeSrc>, pub(crate) enums: Vec<AstEnumSrc>, } <|fim_suffix|>#[derive(Debug, Default)] pub(crate) struct AstEnumSrc { pub(cr...
code_fim
hard
{ "lang": "rust", "repo": "pnoken/tools", "path": "/crates/syntax_codegen/src/ast_src.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xyuan/fuchsia path: /src/connectivity/overnet/lib/core/src/fidl_tests/channel.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. #![cfg(test)] use super::{Fixture, Target}; use f...
code_fim
hard
{ "lang": "rust", "repo": "xyuan/fuchsia", "path": "/src/connectivity/overnet/lib/core/src/fidl_tests/channel.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn fidl_channel_tests_all_to_b() { channel::run(ChanFixture::new(|_| Target::B)) } #[test] fn fidl_channel_tests_b_then_c() { channel::run(ChanFixture::new(|purpose| match purpose { channel::CreateHandlePurpose::PrimaryTestChannel => Target::B, channel::CreateHandlePurpose...
code_fim
hard
{ "lang": "rust", "repo": "xyuan/fuchsia", "path": "/src/connectivity/overnet/lib/core/src/fidl_tests/channel.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> channel::run(ChanFixture::new(|_| Target::B)) } #[test] fn fidl_channel_tests_b_then_c() { channel::run(ChanFixture::new(|purpose| match purpose { channel::CreateHandlePurpose::PrimaryTestChannel => Target::B, channel::CreateHandlePurpose::PayloadChannel => Target::C, })) }<|f...
code_fim
hard
{ "lang": "rust", "repo": "xyuan/fuchsia", "path": "/src/connectivity/overnet/lib/core/src/fidl_tests/channel.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl<C, T: CborLen<C>> CborLen<C> for core::ops::Range<T> { fn cbor_len(&self, ctx: &mut C) -> usize { 1 + self.start.cbor_len(ctx) + self.end.cbor_len(ctx) } } impl<C, T: Encode<C>> Encode<C> for core::ops::RangeFrom<T> { fn encode<W: Write>(&self, e: &mut Encoder<W>, ctx: &mut C) ->...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/minicbor/src/encode.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/vendor/minicbor/src/encode.rs C) -> usize { 1 } } impl<C> CborLen<C> for char { fn cbor_len(&self, ctx: &mut C) -> usize { (*self as u32).cbor_len(ctx) } } impl<C> CborLen<C> for u8 { fn cbor_len(&self, _: &mut C)...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/minicbor/src/encode.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>impl<C> CborLen<C> for f64 { fn cbor_len(&self, _: &mut C) -> usize { 9 } } macro_rules! encode_nonzero { ($($t:ty)*) => { $( impl<C> Encode<C> for $t { fn encode<W: Write>(&self, e: &mut Encoder<W>, ctx: &mut C) -> Result<(), Error<W::Error>> { ...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/minicbor/src/encode.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }