text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> /// Removes a nibble from the vector at the given index, converting it to a high-order nibble. pub fn remove<T: u4>(&mut self, index: usize) -> T { let ret = get_nib(self.inner.as_slice(), index); self.discard_at(index); ret } /// Removes a nibble from the vector, ...
code_fim
hard
{ "lang": "rust", "repo": "clarfonthey/nibble", "path": "/src/vec.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Add a new input port to this component. pub fn add_input( &mut self, portdef: impl Into<ast::Portdef>, ) -> Result<()> { let portdef = portdef.into(); if !self.signature.has_input(portdef.name.as_ref()) { self.structure.insert_input_port(&portdef...
code_fim
hard
{ "lang": "rust", "repo": "cgyurgyik/futil", "path": "/calyx/src/lang/component.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cgyurgyik/futil path: /calyx/src/lang/component.rs use super::ast; use crate::errors::{Error, Result}; use crate::frontend::pretty_print::PrettyPrint; use crate::lang::structure::StructureGraph; use pretty::{termcolor::ColorSpec, RcDoc}; use std::collections::HashMap; /// In memory representati...
code_fim
hard
{ "lang": "rust", "repo": "cgyurgyik/futil", "path": "/calyx/src/lang/component.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl LolEsportStreamNotificationsLiveMatch { pub fn new() -> LolEsportStreamNotificationsLiveMatch { LolEsportStreamNotificationsLiveMatch { id: None, stream_group: None, teams: None, title: None, tournament_description: None, ...
code_fim
hard
{ "lang": "rust", "repo": "Potato-Gaming/crystal", "path": "/league-client/src/models/lol_esport_stream_notifications_live_match.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> for person in people.iter() { teams.get_mut(&team_keys[index]).expect("Failed to get team from key").push(person.to_owned()); index += 1; if index == num_teams as usize { index = 0; } } let mut output = String::fr...
code_fim
hard
{ "lang": "rust", "repo": "Nuri-G/Grouping-Bot", "path": "/src/commands/manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let team_keys: Vec<String> = teams.keys().map(|k| k.to_owned()).collect(); let num_teams = team_keys.len(); for person in people.iter() { teams.get_mut(&team_keys[index]).expect("Failed to get team from key").push(person.to_owned()); index += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "Nuri-G/Grouping-Bot", "path": "/src/commands/manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nuri-G/Grouping-Bot path: /src/commands/manager.rs use linked_hash_map::LinkedHashMap; use serenity::{Error, client::Context, model::{channel::{GuildChannel, PermissionOverwrite}, guild::Role, id::{ChannelId, GuildId}}}; // A manager should make interacting with a discord server easier. pub str...
code_fim
hard
{ "lang": "rust", "repo": "Nuri-G/Grouping-Bot", "path": "/src/commands/manager.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cognivore/icfpc2004-tbd path: /src/magic_examples.rs /* # Usage Functions that directly or indirectly call ant IO (like move, sense) should return AntResult<T> instead of T. So AntResult is kind of like AntIO monad. Such functions should always be invoked using call!() macro, and not directly....
code_fim
hard
{ "lang": "rust", "repo": "cognivore/icfpc2004-tbd", "path": "/src/magic_examples.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { call!(drop()); } } // ENTRY_POINT pub fn magic_example() { eprintln!("looping ant"); let brain = compile(looping_ant); brain.save_to_file("outputs/looping.ant"); eprintln!("{:?}", brain); eprintln!(); eprintln!("spiral ant"); let brain = compile(spiral_...
code_fim
hard
{ "lang": "rust", "repo": "cognivore/icfpc2004-tbd", "path": "/src/magic_examples.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mailslurp/mailslurp-client-rust path: /src/models/create_alias_options.rs /* * MailSlurp API * * MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templa...
code_fim
hard
{ "lang": "rust", "repo": "mailslurp/mailslurp-client-rust", "path": "/src/models/create_alias_options.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAliasOptions { /// Email address to be hidden behind alias. Emails sent to the alias email address will be forwarded to this address. If you want to enable replies set useThreads true and the reply-to for the email will allo...
code_fim
hard
{ "lang": "rust", "repo": "mailslurp/mailslurp-client-rust", "path": "/src/models/create_alias_options.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Check if each ship is inside any landing area. // We don't really care if one ship shares it with another. let won = (&d.positions, &d.ships) .join() .all(|(ship_pos, _)| { positions .iter() .any(|la...
code_fim
hard
{ "lang": "rust", "repo": "vorner/thrust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *world.fetch_mut::<GameState>() = GameState::Started; } async fn inner(window: Window, gfx: Graphics, mut ev: EventStream) -> Result<(), QError> { let font_renderer = VectorFont::load("Ubuntu_Mono/UbuntuMono-Regular.ttf") .await? .to_renderer(&gfx, 24.0)?; // XXX: Setup to it...
code_fim
hard
{ "lang": "rust", "repo": "vorner/thrust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vorner/thrust path: /src/main.rs , temp_dec: f32, } #[derive(Copy, Clone, Component, Debug)] #[storage(HashMapStorage)] struct Rotation(f32); #[derive(Copy, Clone, Component, Debug)] #[storage(HashMapStorage)] struct RotationSpeed(f32); #[derive(Copy, Clone, Debug)] struct Thruster { ...
code_fim
hard
{ "lang": "rust", "repo": "vorner/thrust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darkwisebear/dorkfs path: /src/fuse.rs ug; use failure::Error; use time::{get_time, Timespec}; use chrono::{DateTime, TimeZone, Timelike}; use fuse_mt::*; use libc; use lazy_static::lazy_static; use log::{error, warn, info}; use crate::overlay::{self, *}; use crate::types; use crate::utility::...
code_fim
hard
{ "lang": "rust", "repo": "darkwisebear/dorkfs", "path": "/src/fuse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> init_logging(); let tempdir = tempdir().expect("Unable to create temporary dir!"); let tempdir_path = tempdir.path(); let overlay_dir = tempdir_path.join("overlay"); let git_dir = tempdir_path.join("git"); let cache_dir = tempdir_pa...
code_fim
hard
{ "lang": "rust", "repo": "darkwisebear/dorkfs", "path": "/src/fuse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darkwisebear/dorkfs path: /src/fuse.rs ype::Directory } ]; } fn to_timespec<Tz: TimeZone>(time: &DateTime<Tz>) -> Timespec { let sec = time.timestamp(); let nsec = time.nanosecond() as i32; Timespec::new(sec, nsec) } #[derive(Debug)] enum OpenObject<O> where O: Overlay+...
code_fim
hard
{ "lang": "rust", "repo": "darkwisebear/dorkfs", "path": "/src/fuse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pandaman64/sion-rs path: /src/value/mod.rs pub mod de; pub mod ser; use sequence::{Array, Map}; #[derive(Debug, PartialEq)] pub enum Value { Nil, Bool(bool), Int(i64), Double(f64), String(String), Data(Vec<u8>), Date(f64), Array(Array), Map(Map), } #[cfg(tes...
code_fim
hard
{ "lang": "rust", "repo": "pandaman64/sion-rs", "path": "/src/value/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(from_str::<Value>("nil").unwrap(), Nil); assert_eq!(from_str::<Value>("true").unwrap(), Bool(true)); assert_eq!(from_str::<Value>("false").unwrap(), Bool(false)); assert_eq!(from_str::<Value>("42").unwrap(), Int(42)); assert_eq!(from_str::<Value>("3.1415"...
code_fim
hard
{ "lang": "rust", "repo": "pandaman64/sion-rs", "path": "/src/value/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: standardgalactic/programming-examples path: /rust/typeid/src/main.rs use std::any::{Any, TypeId}; #[derive(Debug)] struct One { name: String, uid: u32, } <|fim_suffix|>fn main() { let o1 = One { name: "One".into(), uid: 1, }; let o2 = One { name: "Tw...
code_fim
medium
{ "lang": "rust", "repo": "standardgalactic/programming-examples", "path": "/rust/typeid/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> TypeId::of::<T>() } fn main() { let o1 = One { name: "One".into(), uid: 1, }; let o2 = One { name: "Two".into(), uid: 2, }; let o3 = One { name: "For".into(), uid: 4, }; let t1 = Two { name: "One".into() }; let t2 = Two {...
code_fim
medium
{ "lang": "rust", "repo": "standardgalactic/programming-examples", "path": "/rust/typeid/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e(collections)] extern crate serialize; extern crate collections; pub mod server;<|fim_prefix|>// repo: shrink0r/hbmon-rust path: /src/lib.rs #![feature(rustc_private)] #![feature(co<|fim_middle|>re)] #![feature(debug_builders)] #![featur
code_fim
easy
{ "lang": "rust", "repo": "shrink0r/hbmon-rust", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shrink0r/hbmon-rust path: /src/lib.rs #![feature(rustc_private)] #![feature(co<|fim_suffix|>e(collections)] extern crate serialize; extern crate collections; pub mod server;<|fim_middle|>re)] #![feature(debug_builders)] #![featur
code_fim
easy
{ "lang": "rust", "repo": "shrink0r/hbmon-rust", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EQt/hdf5-rs path: /libhdf5-sys/src/h5p.rs EATE_g: id_t; static H5P_LST_OBJECT_COPY_g: id_t; static H5P_LST_LINK_CREATE_g: id_t; static H5P_LST_LINK_ACCESS_g: id_t; } pub static H5P_CLS_ROOT: &'static id_t = &H5P_CLS_ROOT_g; pub static H5P_CLS_OBJECT_CREATE: &...
code_fim
hard
{ "lang": "rust", "repo": "EQt/hdf5-rs", "path": "/libhdf5-sys/src/h5p.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EQt/hdf5-rs path: /libhdf5-sys/src/h5p.rs ECT_CREATE: &'static id_t = &H5P_CLS_OBJECT_CREATE_ID_g; pub static H5P_CLS_FILE_CREATE: &'static id_t = &H5P_CLS_FILE_CREATE_ID_g; pub static H5P_CLS_FILE_ACCESS: &'static id_t = &H5P_CLS_FILE_ACCESS_ID_g; pub static H5P_CLS_DATASET_CREATE: ...
code_fim
hard
{ "lang": "rust", "repo": "EQt/hdf5-rs", "path": "/libhdf5-sys/src/h5p.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>cache(dapl_id: hid_t, rdcc_nslots: *mut size_t, rdcc_nbytes: *mut size_t, rdcc_w0: *mut c_double) -> herr_t; pub fn H5Pset_data_transform(plist_id: hid_t, expression: *const c_char) -> herr_t; pub fn H5Pget_data_transform(plist_id: hid_t, expression: *mut c_char, size...
code_fim
hard
{ "lang": "rust", "repo": "EQt/hdf5-rs", "path": "/libhdf5-sys/src/h5p.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KilianVounckx/truster path: /src/lib.rs //! A ray tracing library based on the book //! [The Ray Tracer Challenge](https://pragprog.com/titles/jbtracer/the-ray-tracer-challenge/), //! by Jamis Buck. pub mod camera; <|fim_suffix|>b mod matrix; pub mod ray; pub mod shape; pub mod texture; pub mod...
code_fim
medium
{ "lang": "rust", "repo": "KilianVounckx/truster", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod canvas; pub mod color; pub mod intersection; pub mod light; pub mod material; pub mod matrix; pub mod ray; pub mod shape; pub mod texture; pub mod tuple; pub mod world;<|fim_prefix|>// repo: KilianVounckx/truster path: /src/lib.rs //! A ray tracing library based on the book //! [The Ray Tracer Ch...
code_fim
medium
{ "lang": "rust", "repo": "KilianVounckx/truster", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl phy::TxToken for IXGBETxToken { fn consume<R, F>(self, _timestamp: Instant, len: usize, f: F) -> Result<R> where F: FnOnce(&mut [u8]) -> Result<R>, { let _ = FlagsGuard::no_irq_region(); let mut buffer = [0u8; ixgbe::IXGBE::<Provider>::get_mtu()]; let resul...
code_fim
hard
{ "lang": "rust", "repo": "jiegec/rcore_plus", "path": "/kernel/src/drivers/net/ixgbe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jiegec/rcore_plus path: /kernel/src/drivers/net/ixgbe.rs //! Intel 10Gb Network Adapter 82599 i.e. ixgbe network driver //! Datasheet: https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/82599-10-gbe-controller-datasheet.pdf use alloc::string::String; use alloc::sync::Arc; u...
code_fim
hard
{ "lang": "rust", "repo": "jiegec/rcore_plus", "path": "/kernel/src/drivers/net/ixgbe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Drops-of-Diamond/diamond_drops path: /node/src/modules/collation/header.rs use ethereum_types; use modules::primitives::{ ShardIdHash, ChunkRootHash, ChunkPeriodHash, ProposerAddress, CollationHeaderHash, //ParentCollationHeaderHash, //ProposerBidHash, //Proposer...
code_fim
hard
{ "lang": "rust", "repo": "Drops-of-Diamond/diamond_drops", "path": "/node/src/modules/collation/header.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> // Calculate the expected hash let mut sha3 = tiny_keccak::Keccak::new_sha3_256(); sha3.update(&shard_id_bytes[..]); //sha3.update(&SAMPLE_COLLATION_PARENT_HASH_BYTES[..]); sha3.update(&SAMPLE_COLLATION_CHUNK_ROOT_BYTES[..]); sha3.update(&period_bytes[..]); ...
code_fim
hard
{ "lang": "rust", "repo": "Drops-of-Diamond/diamond_drops", "path": "/node/src/modules/collation/header.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let header = create_sample_collation_header(); // Calculate its generated hash let header_hash: CollationHeaderHash = header.hash(); let shard_id_bytes = u256_to_bytes32(header.shard_id); let period_bytes = u256_to_bytes32(header.period); // Calculate the ...
code_fim
hard
{ "lang": "rust", "repo": "Drops-of-Diamond/diamond_drops", "path": "/node/src/modules/collation/header.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rofrol/ProjectEulerRust path: /src/prob0035.rs #![crate_id = "prob0035"] #![crate_id = "prob0035"] #![crate_type = "rlib"] #![crate_type = "rlib"] extern crate math; <|fim_suffix|> let ds = numconv::to_digits(n, 10).collect::<~[uint]>(); let mut buf = ds.clone(); for i in range(1, ...
code_fim
medium
{ "lang": "rust", "repo": "rofrol/ProjectEulerRust", "path": "/src/prob0035.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn solve() -> ~str { let prime = Prime::new(); return prime.iter() .take_while(|&p| p < 1000000) .count(|n| is_circular_prime(&prime, n)) .to_str(); }<|fim_prefix|>// repo: rofrol/ProjectEulerRust path: /src/prob0035.rs #![crate_id = "prob0035"] #![crate_id = "prob0035...
code_fim
hard
{ "lang": "rust", "repo": "rofrol/ProjectEulerRust", "path": "/src/prob0035.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in range(1, ds.len()) { for j in range(0, buf.len()) { buf[j] = ds[(i + j) % ds.len()]; } if !prime.contains(numconv::from_digits(buf, 10)) { return false; } } true } pub fn solve() -> ~str { let prime = Prime::new(); return prime.iter() ...
code_fim
hard
{ "lang": "rust", "repo": "rofrol/ProjectEulerRust", "path": "/src/prob0035.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> super::runner().with_cwd("variables") } #[test] fn test() { assert_eq!( runner().ok("foo {\ \n $var: 2;\ \n $another-var: 4;\ \n a: $var;\ \n b: $var + $another-var;}\n"), "foo {\ \n a: 2;\ \n b: 6;\ ...
code_fim
easy
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/non_conformant/scss/variables.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/non_conformant/scss/variables.rs //! Tests auto-converted from "sass-spec/spec/non_conformant/scss/variables.hrx" <|fim_suffix|> assert_eq!( runner().ok("foo {\ \n $var: 2;\ \n $another-var: 4;\ \n a: $var;\ ...
code_fim
medium
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/non_conformant/scss/variables.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test() { assert_eq!( runner().ok("foo {\ \n $var: 2;\ \n $another-var: 4;\ \n a: $var;\ \n b: $var + $another-var;}\n"), "foo {\ \n a: 2;\ \n b: 6;\ \n}\n" ); }<|fim_prefix|>// repo: kaj...
code_fim
easy
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/non_conformant/scss/variables.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl IdentityCompressor { pub fn new(w: Box<Cryptor>) -> Self { IdentityCompressor { inner: w } } } impl io::Write for IdentityCompressor { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.inner.write(buf) } fn flush(&mut self) -> io::Result<()> { s...
code_fim
medium
{ "lang": "rust", "repo": "abrodersen/backupmanager", "path": "/src/compression/identity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abrodersen/backupmanager path: /src/compression/identity.rs use std::io; use crate::encryption::Cryptor; use anyhow::Error; pub struct IdentityCompressor { inner: Box<Cryptor>, } <|fim_suffix|> self.inner.write(buf) } fn flush(&mut self) -> io::Result<()> { self....
code_fim
hard
{ "lang": "rust", "repo": "abrodersen/backupmanager", "path": "/src/compression/identity.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.partial_snowflake += time.fixed_seconds() * SNOWFLAKE_RATE * level.bounding_box().width(); while self.partial_snowflake >= 1.0 { if self.snowflake_count as f32 >= MAX_SNOWFLAKE_COUNT as f32 / 10_000.0 * level.bounding_box().w...
code_fim
hard
{ "lang": "rust", "repo": "ISibboI/WinterAmethystPlayground", "path": "/src/systems/snowflakes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ISibboI/WinterAmethystPlayground path: /src/systems/snowflakes.rs use amethyst::{ core::{Time, Transform}, ecs::{Entities, Join, LazyUpdate, Read, ReadStorage, System}, renderer::{SpriteRender, Transparent}, }; use rand::distributions::{Distribution, Uniform}; use components::{Gravi...
code_fim
hard
{ "lang": "rust", "repo": "ISibboI/WinterAmethystPlayground", "path": "/src/systems/snowflakes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(target_os = "windows")] pub fn username() -> String { use std::ptr; use winapi::um::winbase::GetUserNameW; unsafe { let mut size = 0; GetUserNameW(ptr::null_mut(), &mut size); if size == 0 { return "".to_owned() } let mut username =...
code_fim
medium
{ "lang": "rust", "repo": "alexkehayias/cross", "path": "/src/id.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexkehayias/cross path: /src/id.rs #[cfg(not(target_os = "windows"))] use libc; #[cfg(not(target_os = "windows"))] use std::ffi::CStr; #[cfg(target_os = "windows")] pub fn group() -> u32 { 1000 } #[cfg(not(target_os = "windows"))] pub fn group() -> u32 { unsafe { libc::getgid() } } <...
code_fim
hard
{ "lang": "rust", "repo": "alexkehayias/cross", "path": "/src/id.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if GetUserNameW(username.as_mut_ptr(), &mut size) == 0 { return "".to_owned(); } // Remove null terminator. username.set_len((size - 1) as usize); String::from_utf16(&username).unwrap() } } #[cfg(not(target_os = "windows"))] pub fn username() -> S...
code_fim
medium
{ "lang": "rust", "repo": "alexkehayias/cross", "path": "/src/id.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: algesten/interceptor path: /src/report/sender/sender_test.rs use super::*; use crate::mock::mock_stream::MockStream; use crate::mock::mock_time::MockTime; use bytes::Bytes; use chrono::prelude::*; use rtp::extension::abs_send_time_extension::unix2ntp; use std::future::Future; use std::pin::Pin; ...
code_fim
hard
{ "lang": "rust", "repo": "algesten/interceptor", "path": "/src/report/sender/sender_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> stream.close().await?; Ok(()) } #[tokio::test] async fn test_sender_interceptor_after_rtp_packets_overflow() -> Result<()> { let mt = Arc::new(MockTime::default()); let mt2 = Arc::clone(&mt); let time_gen = Arc::new( move || -> Pin<Box<dyn Future<Output = SystemTime> + Send +...
code_fim
hard
{ "lang": "rust", "repo": "algesten/interceptor", "path": "/src/report/sender/sender_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: x87-va/sputnik path: /src/models/mod.rs use std::ops::DerefMut; use crate::db::Pool; use async_graphql::*; use serde::{Deserialize, Serialize}; use sqlx::{self, postgres::PgRow, Row}; use strum_macros::{Display, EnumString}; pub struct QueryRoot; <|fim_suffix|>#[ComplexObject] impl Character {...
code_fim
hard
{ "lang": "rust", "repo": "x87-va/sputnik", "path": "/src/models/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> async fn characters(&self, ctx: &Context<'_>) -> FieldResult<Vec<Character>> { let pool = ctx.data::<Pool>().unwrap(); let query_str = format!("SELECT id, name, kind FROM starwars.characters"); let result = sqlx::query(query_str.as_str()) .map(|row: PgRow| Character { id: row.get("id"), ...
code_fim
hard
{ "lang": "rust", "repo": "x87-va/sputnik", "path": "/src/models/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn validate_field<T>(&mut self, name: &str, val: FieldResult<T>) { if let Err(FieldError::Invalid(msg)) = val { self.validation_errors .push(format!("{:?} is invalid: {}", name, msg)); } } pub fn require_option<T>(&mut self, name: &str, val: Opt...
code_fim
hard
{ "lang": "rust", "repo": "hoodie/yaml-pathfinder", "path": "/src/validator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ValidationResult { validation_errors, missing_fields, } } } /// Result of validating part of a project. /// /// We have to differentiate between incomplete data (missing values) and wrong data (invalid values). /// Wrong data should always be a hard error - the...
code_fim
hard
{ "lang": "rust", "repo": "hoodie/yaml-pathfinder", "path": "/src/validator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hoodie/yaml-pathfinder path: /src/validator.rs use yaml_rust::Yaml; pub use crate::path::*; use crate::{error::*, PathFinder}; pub trait Rule: Send + Sync + 'static { type Res: Invalidatable + Send + 'static; fn call(&self, data: &Yaml) -> Self::Res; } impl<F: Send + Sync + 'static, R...
code_fim
hard
{ "lang": "rust", "repo": "hoodie/yaml-pathfinder", "path": "/src/validator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: achimcc/rust-analyzer-project-json path: /crates/rust-analyzer/src/cli/create_json.rs use std::{path::Path, sync::Arc}; use std::fs; use anyhow::Result; use crossbeam_channel::{unbounded, Receiver}; use hir::db::DefDatabase; use ide::{AnalysisHost, FileId}; use project_model::{CargoConfig, Carg...
code_fim
hard
{ "lang": "rust", "repo": "achimcc/rust-analyzer-project-json", "path": "/crates/rust-analyzer/src/cli/create_json.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let files = load_files( &mut vfs, &receiver); Ok(files) } fn load_files( vfs: &mut vfs::Vfs, receiver: &Receiver<vfs::loader::Message>, ) -> Vec<(FileId, Option<Arc<String>>)> { let lru_cap = std::env::var("RA_LRU_CAP").ok().and_then(|it| it.parse::<usize>().ok()); let m...
code_fim
hard
{ "lang": "rust", "repo": "achimcc/rust-analyzer-project-json", "path": "/crates/rust-analyzer/src/cli/create_json.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut nodes = Vec::with_capacity(end - start); for (idx, item) in self[start..end].iter().enumerate() { nodes.push(( base64::encode((idx as u32).to_be_bytes()), EmptyEdgeFields, item, )); } Ok(Connec...
code_fim
hard
{ "lang": "rust", "repo": "yjhmelody/async-graphql", "path": "/src/types/connection/slice.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yjhmelody/async-graphql path: /src/types/connection/slice.rs use crate::types::connection::{EmptyEdgeFields, QueryOperation}; use crate::{Connection, DataSource, FieldResult}; use byteorder::{ReadBytesExt, BE}; #[async_trait::async_trait] impl<'a, T: Sync> DataSource for &'a [T] { type Elem...
code_fim
hard
{ "lang": "rust", "repo": "yjhmelody/async-graphql", "path": "/src/types/connection/slice.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: miker1423/atsamv71q21 path: /src/acc/isr.rs #[doc = "Register `ISR` reader"] pub struct R(crate::R<ISR_SPEC>); impl core::ops::Deref for R { type Target = crate::R<ISR_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl core::convert::From<crate::...
code_fim
hard
{ "lang": "rust", "repo": "miker1423/atsamv71q21", "path": "/src/acc/isr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `SCO` reader - Synchronized Comparator Output"] pub struct SCO_R(crate::FieldReader<bool, bool>); impl SCO_R { pub(crate) fn new(bits: bool) -> Self { SCO_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for SCO_R { type Target = crate::...
code_fim
hard
{ "lang": "rust", "repo": "miker1423/atsamv71q21", "path": "/src/acc/isr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `MASK` reader - Flag Mask"] pub struct MASK_R(crate::FieldReader<bool, bool>); impl MASK_R { pub(crate) fn new(bits: bool) -> Self { MASK_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for MASK_R { type Target = crate::FieldReader<bool...
code_fim
hard
{ "lang": "rust", "repo": "miker1423/atsamv71q21", "path": "/src/acc/isr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.distance == other.distance } } impl<F: RealNumber> Eq for KNNPoint<F> {} #[cfg(test)] mod tests { use super::*; use crate::math::distance::Distances; #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] struct SimpleDistance {} ...
code_fim
hard
{ "lang": "rust", "repo": "z1queue/smartcore", "path": "/src/algorithm/neighbour/linear_search.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: z1queue/smartcore path: /src/algorithm/neighbour/linear_search.rs //! # Brute Force Linear Search //! //! see [KNN algorithms](../index.html) //! ``` //! use smartcore::algorithm::neighbour::linear_search::*; //! use smartcore::math::distance::Distance; //! //! #[derive(Clone)] //! struct Simple...
code_fim
hard
{ "lang": "rust", "repo": "z1queue/smartcore", "path": "/src/algorithm/neighbour/linear_search.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Game<'a> { pub fn new(display: &Display) -> Game { let texture = Texture::load("gold_ore", display); let shader = shader::load_shader("Basic", display); Game { camera: Camera::new(), display, tick: 0.0, shader, texture } } pub fn update(&mut s...
code_fim
medium
{ "lang": "rust", "repo": "heypoom/Lumina", "path": "/src/render/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heypoom/Lumina path: /src/render/game.rs extern crate glium; use glium::{Display, Program}; use super::shader; use super::camera::Camera; use super::texture::Texture; use super::renderer::Renderer; pub struct Game<'a> { pub camera: Camera, pub display: &'a Display, pub tick: f32, pub ...
code_fim
hard
{ "lang": "rust", "repo": "heypoom/Lumina", "path": "/src/render/game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update(&mut self) { self.tick += 0.0002; if self.tick > 0.5 { self.tick = -0.5; } self.render(); } }<|fim_prefix|>// repo: heypoom/Lumina path: /src/render/game.rs extern crate glium; use glium::{Display, Program}; use super::shader; use super::camera::Camera; use sup...
code_fim
hard
{ "lang": "rust", "repo": "heypoom/Lumina", "path": "/src/render/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/mio/src/event/events.rs use crate::event::Event; use crate::sys; use std::fmt; #[cfg_attr(feature = "os-poll", doc = "```")] #[cfg_attr(not(feature = "os-poll"), doc = "```ignore")] pub struct Events {...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/mio/src/event/events.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub fn clear(&mut self) { self.inner.clear(); } pub(crate) fn sys(&mut self) -> &mut sys::Events { &mut self.inner } } impl<'a> IntoIterator for &'a Events { type Item = &'a Event; type IntoIter = Iter<'a>; fn...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/mio/src/event/events.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub fn capacity(&self) -> usize { self.inner.capacity() } pub fn is_empty(&self) -> bool { self.inner.is_empty() } #[cfg_attr(feature = "os-poll", doc = "```")] #[cfg_attr(not(feature ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/mio/src/event/events.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> #[instrument(skip_all, fields(task = ?self.id()))] fn add_requests(&mut self, rpc: &mut RpcManager, now: Instant) -> bool { trace!("Invoke PING request"); if self.done { return true; } let txn_id = rpc.new_txn(); let mut buf = Vec::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "95th/btrs", "path": "/dht-proto/src/server/task/ping.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 95th/btrs path: /dht-proto/src/server/task/ping.rs use crate::contact::Contact; use crate::id::NodeId; use crate::msg::recv::Response; use crate::msg::send::Ping; use crate::server::task::{DhtNode, Status}; use crate::server::RpcManager; use crate::table::RoutingTable; use ben::Encode; use std::...
code_fim
hard
{ "lang": "rust", "repo": "95th/btrs", "path": "/dht-proto/src/server/task/ping.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as _ } } #[doc = "Reader of field `VPS_SEL`"] pub type VPS_SEL_R = crate::R<u8, VPS_SEL_A>; impl VPS_SEL_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> crate::Variant<u8, VPS_SEL_A> { use crate::Variant::*; match sel...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32f3/src/stm32f302/opamp/opamp2_csr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as _ } } #[doc = "Reader of field `CALSEL`"] pub type CALSEL_R = crate::R<u8, CALSEL_A>; impl CALSEL_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> CALSEL_A { match self.bits { 0 => CALSEL_A::PERCENT3_3, ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32f3/src/stm32f302/opamp/opamp2_csr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32f3/src/stm32f302/opamp/opamp2_csr.rs nt"] #[inline(always)] pub fn variant(&self) -> VMS_SEL_A { match self.bits { false => VMS_SEL_A::PC5, true => VMS_SEL_A::PA5, } } #[doc = "Checks if the valu...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32f3/src/stm32f302/opamp/opamp2_csr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'r> FromParam<'r> for PhoneParam<'r> { type Error = &'r RawStr; fn from_param(param: &'r RawStr) -> Result<Self, Self::Error> { if param.len() != 10 || !param.chars().all(|c| c >= '0' && c <= '9') { return Err(param); } Ok(PhoneParam { phone_n...
code_fim
medium
{ "lang": "rust", "repo": "briankung/callrouter_rs", "path": "/src/phone_param/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if param.len() != 10 || !param.chars().all(|c| c >= '0' && c <= '9') { return Err(param); } Ok(PhoneParam { phone_number: param, }) } }<|fim_prefix|>// repo: briankung/callrouter_rs path: /src/phone_param/mod.rs use rocket::http::RawStr; use ro...
code_fim
medium
{ "lang": "rust", "repo": "briankung/callrouter_rs", "path": "/src/phone_param/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: briankung/callrouter_rs path: /src/phone_param/mod.rs use rocket::http::RawStr; use rocket::request::FromParam; <|fim_suffix|> fn from_param(param: &'r RawStr) -> Result<Self, Self::Error> { if param.len() != 10 || !param.chars().all(|c| c >= '0' && c <= '9') { return Err...
code_fim
medium
{ "lang": "rust", "repo": "briankung/callrouter_rs", "path": "/src/phone_param/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while depth < stop_at { if forest.has_tree(depth * step.0, depth * step.1) { tree_count += 1; } depth += 1; } tree_counts.push(tree_count) } println!("{:?}", tree_counts) } #[derive(Debug)] struct Forest { trees: Ve...
code_fim
medium
{ "lang": "rust", "repo": "scott-ad-riley/advent-of-code", "path": "/2020/day-3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_row(row: &str) -> Option<Vec<bool>> { if !row.contains("#") || !row.contains(".") { return None; } Some( row.chars() .map(|char| match char { '#' => true, '.' => false, _ => panic!("unknown character"), ...
code_fim
hard
{ "lang": "rust", "repo": "scott-ad-riley/advent-of-code", "path": "/2020/day-3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scott-ad-riley/advent-of-code path: /2020/day-3/src/main.rs use std::fs; fn main() { let filename = "input.txt"; let contents = fs::read_to_string(filename).expect("Something went wrong reading the file"); let trees: Vec<Vec<bool>> = contents .split("\n") .map(|row|...
code_fim
hard
{ "lang": "rust", "repo": "scott-ad-riley/advent-of-code", "path": "/2020/day-3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcls/svd2rust-example path: /lpc408x/src/syscon/rstcon0.rs pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the fiel...
code_fim
hard
{ "lang": "rust", "repo": "rcls/svd2rust-example", "path": "/lpc408x/src/syscon/rstcon0.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcls/svd2rust-example path: /lpc408x/src/syscon/rstcon0.rs oc = "Field `RSTTIM0` writer - Timer/Counter 0 reset control bit."] pub struct RSTTIM0_W<'a> { w: &'a mut W, } impl<'a> RSTTIM0_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { ...
code_fim
hard
{ "lang": "rust", "repo": "rcls/svd2rust-example", "path": "/lpc408x/src/syscon/rstcon0.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `RSTI2C2` writer - I2C interface 2 reset control bit."] pub struct RSTI2C2_W<'a> { w: &'a mut W, } impl<'a> RSTI2C2_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r...
code_fim
hard
{ "lang": "rust", "repo": "rcls/svd2rust-example", "path": "/lpc408x/src/syscon/rstcon0.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let req = TestRequest::default() .insert_header(( header::FORWARDED, "for=192.0.2.60; proto=https; by=203.0.113.43; host=rust-lang.org", )) .to_http_request(); let info = req.connection_info(); assert_eq!(info.sch...
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-web", "path": "/actix-web/src/info.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: actix/actix-web path: /actix-web/src/info.rs use std::{convert::Infallible, net::SocketAddr}; use actix_utils::future::{err, ok, Ready}; use derive_more::{Display, Error}; use crate::{ dev::{AppConfig, Payload, RequestHead}, http::{ header::{self, HeaderName}, uri::{Aut...
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-web", "path": "/actix-web/src/info.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tezedge/tezedge_redux path: /src/state.rs use redux_rs::ActionId; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::net::SocketAddr; use ::storage::persistent::BincodeEncoded; <|fim_suffix|>impl State { pub fn new(config: Config) -> Self { Self { ...
code_fim
hard
{ "lang": "rust", "repo": "tezedge/tezedge_redux", "path": "/src/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug, Clone)] pub struct State { pub config: Config, pub peers: BTreeMap<SocketAddr, Peer>, pub peers_dns_lookup: Option<PeersDnsLookupState>, pub peer_connection_incoming_accept: PeerConnectionIncomingAcceptState, pub storage: StorageState, pub la...
code_fim
hard
{ "lang": "rust", "repo": "tezedge/tezedge_redux", "path": "/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> 18319, 18319, 18320, 18320, 18321, 18321, 18322, 18322, 18323, 18323, 18324, 18324, 18325, 18325, 18326, 18326, 18327, 18327, 18328, 18328, 18329, 18329, 18330, 18330, 18331, 18331, 18332, 18332, 18333, 18333, 18334, 18334, 18335, 18335, 18336, 18336, 18337, 1833...
code_fim
hard
{ "lang": "rust", "repo": "ackintosh/sandbox", "path": "/rust/leetcode/src/maximum_xor_for_each_query.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ackintosh/sandbox path: /rust/leetcode/src/maximum_xor_for_each_query.rs , 23728, 23729, 23729, 23730, 23730, 23731, 23731, 23732, 23732, 23733, 23733, 23734, 23734, 23735, 23735, 23736, 23736, 23737, 23737, 23738, 23738, 23739, 23739, 23740, 23740, 23741, 23741, 23742, 2...
code_fim
hard
{ "lang": "rust", "repo": "ackintosh/sandbox", "path": "/rust/leetcode/src/maximum_xor_for_each_query.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ackintosh/sandbox path: /rust/leetcode/src/maximum_xor_for_each_query.rs 15045, 15046, 15046, 15047, 15047, 15048, 15048, 15049, 15049, 15050, 15050, 15051, 15051, 15052, 15052, 15053, 15053, 15054, 15054, 15055, 15055, 15056, 15056, 15057, 15057, 15058, 15058, 15059, 150...
code_fim
hard
{ "lang": "rust", "repo": "ackintosh/sandbox", "path": "/rust/leetcode/src/maximum_xor_for_each_query.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: puhtaytow/sampler path: /src/dynamic.rs use audio; use instrument; use map; use sampler; /// An alias for a dynamic `Mode` type. pub type Mode = instrument::mode::Dynamic; <|fim_suffix|>impl<A> Sampler<A> where A: audio::Audio, { /// Construct a dynamic `Sampler`. pub fn dynamic(m...
code_fim
hard
{ "lang": "rust", "repo": "puhtaytow/sampler", "path": "/src/dynamic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Construct a dynamic `Sampler` initialised with a `Mono::Legato` playback mode. pub fn dynamic_legato(map: map::Map<A>) -> Self { Self::dynamic(instrument::mode::Dynamic::legato(), map) } /// Construct a dynamic `Sampler` initialised with a `Mono::Retrigger` playback mode. ...
code_fim
hard
{ "lang": "rust", "repo": "puhtaytow/sampler", "path": "/src/dynamic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn scan(&self, key_min: &String, key_max: &String) -> DbEngine{ let mut newDb = DbEngine::new(); for (k,v) in self.database.range(key_min.clone()..key_max.clone()){ println!("Find ({}----{})",k,v); newDb.database.insert(k.to_string(),v.to_string()); ...
code_fim
hard
{ "lang": "rust", "repo": "stupidboy666/kvserver_week2", "path": "/src/dbengine/dbengine.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut file = File::create("log.txt")?; for (key, value) in database.iter() { file.write_all(key.as_bytes())?; file.write_all(b"\n")?; file.write_all(value.as_bytes())?; file.write_all(b"\n")?; } Ok(()) } fn load(database: &mut BTreeMap<String, String>) ->...
code_fim
hard
{ "lang": "rust", "repo": "stupidboy666/kvserver_week2", "path": "/src/dbengine/dbengine.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stupidboy666/kvserver_week2 path: /src/dbengine/dbengine.rs use std::collections::BTreeMap; use std::fs::File; use std::io::prelude::*; use std::fs; use std::io::BufReader; #[derive(Clone)] pub struct DbEngine{ pub database: BTreeMap<String,String>, } impl DbEngine{ pub fn new() -> Se...
code_fim
hard
{ "lang": "rust", "repo": "stupidboy666/kvserver_week2", "path": "/src/dbengine/dbengine.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cnutshell/rust-ucx path: /workspace/ucx/src/tagged_messages/IoVecMessage.rs // This file is part of ucx. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/ucx/master/COPYRIGHT. No part...
code_fim
medium
{ "lang": "rust", "repo": "cnutshell/rust-ucx", "path": "/workspace/ucx/src/tagged_messages/IoVecMessage.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Rounds number_of_items up (normal integer division rounds down). (length_in_bytes + (element_size + 1)) / element_size } } impl<'a> IoVecMessage<'a> { /// Creates new instance. #[inline(always)] pub fn new(array: &'a mut [IoVec]) -> Self { Self { array, } } #[inline(always)] fn ...
code_fim
hard
{ "lang": "rust", "repo": "cnutshell/rust-ucx", "path": "/workspace/ucx/src/tagged_messages/IoVecMessage.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// The protocol is in an inconsistent state. Inconsistent, /// Index out of bounds. IndexOutOfBounds, /// UTF-8 decoding error (most probably ASCII error). Utf8(std::str::Utf8Error), /// Unknown server key. UnknownKey, /// Message received/sent on unopened channel....
code_fim
hard
{ "lang": "rust", "repo": "pijul-scm/thrussh", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pijul-scm/thrussh path: /src/lib.rs ind { match *self { HandlerError::Error(ref e) => e.kind(), _ => std::io::ErrorKind::Other } } } use std::error::Error as StdError; impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) ->...
code_fim
hard
{ "lang": "rust", "repo": "pijul-scm/thrussh", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pijul-scm/thrussh path: /src/lib.rs e", key).and_then(|connection| { //! //! connection.channel_open_session().and_then(move |(mut connection, chan)| { //! //! connection.data(chan, None, b"First test").and_then(move |(connection, _)| { //! ...
code_fim
hard
{ "lang": "rust", "repo": "pijul-scm/thrussh", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fisherdarling/nfamatch-rs path: /dfa-optimizer/src/row.rs use log::*; use std::fmt; use std::ops::{Index, IndexMut}; use std::str::FromStr; #[derive(Default, Debug, Clone)] pub struct Row { accepting_state: bool, pub id: usize, transitions: Vec<Option<usize>>, } impl Row { pub ...
code_fim
hard
{ "lang": "rust", "repo": "fisherdarling/nfamatch-rs", "path": "/dfa-optimizer/src/row.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }