text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> // Set up pins with appropriate modes. setup_pins(); // Set up I2C for the TI ADS1115 ADC. let i2c = I2c::new(dp.I2C1, I2cDevice::One, 100_000, &clock_cfg); // todo: Once on new QFN MCU: Gain 0, 1, 2 -> PA6, PA7, PB0 // Set up pins used to control the gain-resistor-selecting mult...
code_fim
hard
{ "lang": "rust", "repo": "Kaikallon/stm32-hal", "path": "/examples/conductivity_module/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aebm/rd path: /src/scheduler.rs //! Overview of rd scheduling: //! //! rd honours priorities set by setpriority(2) --- even in situations where the //! kernel doesn't, e.g. when a non-privileged task tries to increase its //! priority. Normally rd honors priorities strictly by scheduling the hig...
code_fim
hard
{ "lang": "rust", "repo": "aebm/rd", "path": "/src/scheduler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Like most task schedulers, there are conflicting goals to balance. Lower /// max-ticks generally makes the application more "interactive", generally /// speaking lower latency. (And wrt catching bugs, this setting generally /// creates more opportunity for bugs to arise in multi-threaded/process /// a...
code_fim
hard
{ "lang": "rust", "repo": "aebm/rd", "path": "/src/scheduler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sagudev/rust-chromaprint path: /src/chroma.rs pub struct Chroma { note_range: NoteRange, } impl Chroma { pub fn new(min_freq: u32, max_freq: u32, frame_size: u32, sample_rate: u32) -> Chroma { Chroma { note_range: NoteRange::new(min_freq, max_freq, frame_size, sample...
code_fim
hard
{ "lang": "rust", "repo": "sagudev/rust-chromaprint", "path": "/src/chroma.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_notes_freq() { const MIN_FREQ: u32 = 28; const MAX_FREQ: u32 = 3520; const DEFAULT_SAMPLE_RATE: u32 = 11025; const FRAME_SIZE: u32 = 4096; let note_range = NoteRange::new(MIN_FREQ, MAX_FREQ, FRAME_SIZE, DEFAULT_SAMPLE_RATE); assert_e...
code_fim
hard
{ "lang": "rust", "repo": "sagudev/rust-chromaprint", "path": "/src/chroma.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let fft_frames = test_data::get_fft_frames(); const MIN_FREQ: u32 = 28; const MAX_FREQ: u32 = 3520; const FRAME_SIZE: u32 = 4096; const TARGET_SAMPLE_RATE: u32 = 11025; let expected = test_data::get_chroma_features(); let chroma = Chroma::new(MIN_FR...
code_fim
hard
{ "lang": "rust", "repo": "sagudev/rust-chromaprint", "path": "/src/chroma.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub struct Test { pub description: String, pub skip_reason: Option<String>, pub use_multiple_mongoses: Option<bool>, #[serde( default, deserialize_with = "deserialize_uri_options_to_uri_string_option", rename...
code_fim
hard
{ "lang": "rust", "repo": "PhotonQuantum/mongo-rust-driver", "path": "/src/test/spec/v2_runner/test_file.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PhotonQuantum/mongo-rust-driver path: /src/test/spec/v2_runner/test_file.rs use std::collections::HashMap; use bson::{doc, from_document}; use futures::TryStreamExt; use semver::VersionReq; use serde::{Deserialize, Deserializer}; use crate::{ bson::Document, options::{FindOptions, Read...
code_fim
hard
{ "lang": "rust", "repo": "PhotonQuantum/mongo-rust-driver", "path": "/src/test/spec/v2_runner/test_file.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn check_update(&mut self){ match File::open(self.path.as_str()){ Result::Ok(file) => { let time = file.metadata().unwrap().modified().unwrap(); let now = SystemTime::now(); if now.duration_since(time).unwrap().as_secs() == 0 && s...
code_fim
hard
{ "lang": "rust", "repo": "derek-mallon/rust-experiment", "path": "/src/hotswap.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: derek-mallon/rust-experiment path: /src/hotswap.rs /// Allows for hotswaping in variables during run time with a file /// Not for release only as a dev tool. use std::time::SystemTime; use std::io::prelude::*; use std::fs::File; <|fim_suffix|> pub fn check_update(&mut self){ match F...
code_fim
hard
{ "lang": "rust", "repo": "derek-mallon/rust-experiment", "path": "/src/hotswap.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dawidovsky/IIUWr path: /Rust/L2/zad1/src/main.rs fn main() {} fn get_count(string: &str) -> usize { let mut vowels_count: usize = 0; string.chars().for_each(|c| { if vec!['a', 'e', 'i', 'o', 'u'].contains(&c) {vowels_count += 1} }); vowels_count } #[test] fn test1() { assert_eq!(...
code_fim
hard
{ "lang": "rust", "repo": "dawidovsky/IIUWr", "path": "/Rust/L2/zad1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(get_count("oops"), 2); } #[test] fn test7() { assert_eq!(get_count("teear"), 3); } #[test] fn test8() { assert_eq!(get_count("aaaa"), 4); } #[test] fn test9() { assert_eq!(get_count("aieou"), 5); } #[test] fn test10() { assert_eq!(get_count(""), 0); }<|fim_prefix|>// repo: dawidov...
code_fim
hard
{ "lang": "rust", "repo": "dawidovsky/IIUWr", "path": "/Rust/L2/zad1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(ImageRecord{ offset: offset, length: length, uncompressed_length: uncompressed_length, invert_offset: invert_offset, width: width, height: height, image_type:image_type, flags: flags, bit...
code_fim
hard
{ "lang": "rust", "repo": "lclarkmichalek/rust-sg3", "path": "/src/sg/image.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lclarkmichalek/rust-sg3 path: /src/sg/image.rs use std::io::{Read, Seek, SeekFrom}; use util::*; use sg::error::{Result, Error}; #[derive(Debug)] pub struct ImageRecord { pub offset: u32, pub length: u32, pub uncompressed_length: u32, pub invert_offset: i32, pub width: i16,...
code_fim
hard
{ "lang": "rust", "repo": "lclarkmichalek/rust-sg3", "path": "/src/sg/image.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for output in output_buf.chunks_mut(4) { if skip == 0 && read == 0 { let c = match input.next() { None => return Err(Error::MalformedImage()), Some(b) => *b, }; if c == 255 { skip = match input.next() { ...
code_fim
hard
{ "lang": "rust", "repo": "lclarkmichalek/rust-sg3", "path": "/src/sg/image.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let modifier = try!(keys::keymod_from_names(&[modifier.as_str()])); keys::register_mouse_modifier(modifier); Ok(()) } /// Registers a command keybinding. fn register_command_key(mods: String, command: String, _repeat: bool) -> Result<(), String> { if let Ok(press) = keypress_from_string(&...
code_fim
hard
{ "lang": "rust", "repo": "Meyermagic/way-cooler", "path": "/src/lua/rust_interop.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Meyermagic/way-cooler path: /src/lua/rust_interop.rs //! Rust code which is called from lua in the init file #![deny(dead_code)] use std::ops::Deref; use hlua::{self, Lua, LuaTable}; use hlua::any::AnyLuaValue; use registry::{self, RegistryError, AccessFlags}; use commands; use keys::{self, K...
code_fim
hard
{ "lang": "rust", "repo": "Meyermagic/way-cooler", "path": "/src/lua/rust_interop.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_traverse() { let result: Result<i32, String> = Err("Error".to_string()); assert_eq!(result.traverse(|i| Some(i)), Some(Err("Error".to_string()))); let result: Result<i32, String> = Err("Error".to_string()); assert_eq!( result.traverse(|_|...
code_fim
hard
{ "lang": "rust", "repo": "DarinM223/rarrow", "path": "/src/result.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DarinM223/rarrow path: /src/result.rs use crate::classes::*; use crate::mirror::{Hkt1, Hkt2, Mirror1, Mirror2}; use core::marker::PhantomData; use std::fmt::Debug; impl<A, E> Mirror1 for Result<A, E> { type T = A; type Family = ResultFamily1<E>; } impl<A, B> Mirror2 for Result<A, B> { ...
code_fim
hard
{ "lang": "rust", "repo": "DarinM223/rarrow", "path": "/src/result.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let alien: Alien = Alien::new("x", 12); // let alien: Alien = Alien { name: "x", damage: 32 }; alien.attack(); println!("{:?}", alien); }<|fim_prefix|>// repo: alextanhongpin/rust-essentials path: /05-hoc-and-parameterization/07-traits.rs #[derive(Debug)] struct Alien { name: &'static str, da...
code_fim
hard
{ "lang": "rust", "repo": "alextanhongpin/rust-essentials", "path": "/05-hoc-and-parameterization/07-traits.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alextanhongpin/rust-essentials path: /05-hoc-and-parameterization/07-traits.rs #[derive(Debug)] struct Alien { name: &'static str, damage: u32 } trait Monster { fn new(&'static str, u32) -> Self; fn attack(&self); } <|fim_suffix|> return Alien {name: n, damage: d } } fn attack(...
code_fim
medium
{ "lang": "rust", "repo": "alextanhongpin/rust-essentials", "path": "/05-hoc-and-parameterization/07-traits.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(c) = state.create("cart-1".to_string()) { if let Cart::Empty { id } = c { assert_eq!(id, "cart-1"); } else { assert!(false); } } else { assert!(false); } } #[test] fn add_item_t...
code_fim
hard
{ "lang": "rust", "repo": "fits/try_samples", "path": "/rust/shopping_cart/sample2/src/cart.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let item = Product { catalog_id: "item-1".to_string(), unit_price: 1000 }; let state = Cart::NonEmpty { id: "cart-1".to_string(), items: vec![CartItem { item: item.clone(), qty: 2 }] }; if let Some(c) = state.add_item(item, 1) { if let Cart::NonEmpty { id: _, items } =...
code_fim
hard
{ "lang": "rust", "repo": "fits/try_samples", "path": "/rust/shopping_cart/sample2/src/cart.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fits/try_samples path: /rust/shopping_cart/sample2/src/cart.rs use std::cmp; pub type CartId = String; pub type CatalogId = String; pub type PromotionId = String; pub type Quantity = u32; pub type Amount = i32; #[derive(Debug, Clone)] pub struct Product { pub catalog_id: CatalogId, pu...
code_fim
hard
{ "lang": "rust", "repo": "fits/try_samples", "path": "/rust/shopping_cart/sample2/src/cart.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: domain-independent-dp/didp-rs path: /didp-yaml/src/heuristic_search_solver/solution.rs use dypdl::variable_type::{Continuous, Element, Integer, Numeric, OrderedContinuous}; use dypdl::Transition; use dypdl_heuristic_search::Solution; use serde::Serialize; use std::collections::BTreeMap; use std:...
code_fim
hard
{ "lang": "rust", "repo": "domain-independent-dp/didp-rs", "path": "/didp-yaml/src/heuristic_search_solver/solution.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn cost_to_dump_from_integer() { assert_eq!(CostToDump::from(10), CostToDump::Integer(10)); } #[test] fn cost_to_dump_from_ordered_continuous() { assert_eq!( CostToDump::from(OrderedContinuous::from(10.5))...
code_fim
hard
{ "lang": "rust", "repo": "domain-independent-dp/didp-rs", "path": "/didp-yaml/src/heuristic_search_solver/solution.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from(row: &Row) -> Result<Person> { Ok(Person::new( row.get(0)?, row.get(1)?, row.get(2).unwrap_or("".to_string()), row.get(3)?, row.get(4)?, row.get(5).unwrap_or("".to_string()), row.get(6)?, ...
code_fim
hard
{ "lang": "rust", "repo": "dangreco/rust-apple-photos", "path": "/src/person.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dangreco/rust-apple-photos path: /src/person.rs use crate::apple_photos::Fromable; use rusqlite::{Result, Row}; #[derive(Debug)] pub struct Person { pub model_id: i32, pub uuid: String, pub name: String, pub cloud_library_state: i32, pub has_been_synced: i32, pub cloud_i...
code_fim
hard
{ "lang": "rust", "repo": "dangreco/rust-apple-photos", "path": "/src/person.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> device: &wgpu::Device, resource_container: &mut crate::resources::bindingresourcecontainer::BindingResourceContainer, ) { let shadow_sampler = device.create_sampler(&wgpu::SamplerDescriptor { label: Some("shadow"), address_mode_u: wgpu::AddressMode::Clam...
code_fim
hard
{ "lang": "rust", "repo": "happydpc/Horizon", "path": "/src/renderer/bindgroups/uniforms.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: happydpc/Horizon path: /src/renderer/bindgroups/uniforms.rs use super::HorizonBindGroup; use crate::renderer::{ bindgroups::BindGroupContainer, primitives::uniforms::Globals, state::State, }; use specs::*; #[derive(Component, Default)] #[storage(NullStorage)] pub struct UniformBindGroup; i...
code_fim
hard
{ "lang": "rust", "repo": "happydpc/Horizon", "path": "/src/renderer/bindgroups/uniforms.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Questionable-Content-Extensions/server path: /src/controllers/api/comic/navigation_data.rs use crate::models::{ComicId, ItemNavigationData, NavigationData}; use actix_web::{error, Result}; use database::models::Item as DatabaseItem; use database::DbPoolConnection; use std::convert::TryInto; #[a...
code_fim
hard
{ "lang": "rust", "repo": "Questionable-Content-Extensions/server", "path": "/src/controllers/api/comic/navigation_data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(first_last_counts .into_iter() .map(|flc| ItemNavigationData { id: flc.id.into(), navigation_data: NavigationData { first: flc .first .map(TryInto::try_into) .transpose() ...
code_fim
hard
{ "lang": "rust", "repo": "Questionable-Content-Extensions/server", "path": "/src/controllers/api/comic/navigation_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> String::from("A DOG says BARF") } fn eat(&self) -> String { String::from("and eats ANYTHING") } } impl Animal for Cat { fn do_noise(&self) -> String { String::from("A CAT says MIAOU") } fn eat(&self) -> String { String::from("and eats FISH") } }...
code_fim
medium
{ "lang": "rust", "repo": "eskombro/rust_train", "path": "/trait_test_v1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eskombro/rust_train path: /trait_test_v1/src/main.rs trait Animal { fn do_noise(&self) -> String; fn eat(&self) -> String; } struct Horse; struct Dog; struct Cat; impl Animal for Horse { fn do_noise(&self) -> String { String::from("A HORSE says BAHAHA") } fn eat(&se...
code_fim
medium
{ "lang": "rust", "repo": "eskombro/rust_train", "path": "/trait_test_v1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Animal for Cat { fn do_noise(&self) -> String { String::from("A CAT says MIAOU") } fn eat(&self) -> String { String::from("and eats FISH") } } fn main() { let h = Horse; let d = Dog; let c = Cat; println!("{} {}", h.do_noise(), h.eat()); println!(...
code_fim
medium
{ "lang": "rust", "repo": "eskombro/rust_train", "path": "/trait_test_v1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: septimochen/rust-algs path: /src/dynamic_programming/how_sum.rs use std::collections::HashMap; #[allow(dead_code)] pub struct HowSum; #[allow(dead_code)] impl HowSum { pub fn how_sum(target_sum: i32, numbers: &Vec<i32>) -> Option<Vec<i32>> { let mut memo: HashMap<i32, Option<Vec<i32...
code_fim
hard
{ "lang": "rust", "repo": "septimochen/rust-algs", "path": "/src/dynamic_programming/how_sum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let a = HowSum::how_sum_2(7, &vec![5, 3, 4, 7]); println!("{:?}", a); let b = HowSum::how_sum_2(7, &vec![2, 3]); println!("{:?}", b); let c = HowSum::how_sum_2(8, &vec![5, 2, 3]); println!("{:?}", c); let d = HowSum::how_sum_2(300, &vec![7, 14]); ...
code_fim
hard
{ "lang": "rust", "repo": "septimochen/rust-algs", "path": "/src/dynamic_programming/how_sum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/em-refactor path: /em-refactor-examples/box_named_field/struct_pattern_field_binding_1_after.rs struct S { field: Box<i32> } fn main() { match (S {field: Box::new(0)}) { S {field: a} => { let _: i32 = (*<|fim_suffix|>ra S {field: _} => {}, // Wildcard ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/em-refactor", "path": "/em-refactor-examples/box_named_field/struct_pattern_field_binding_1_after.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ra S {field: _} => {}, // Wildcard _ => {} } }<|fim_prefix|>// repo: isgasho/em-refactor path: /em-refactor-examples/box_named_field/struct_pattern_field_binding_1_after.rs struct S { field: Box<i32> } fn main() { match (S {field: Box<|fim_middle|>::new(0)}) { S {field: a}...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/em-refactor", "path": "/em-refactor-examples/box_named_field/struct_pattern_field_binding_1_after.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vogon/yolo-sansa path: /main.rs use core::libc::{c_void, size_t}; use lua51::*; extern fn lua_alloc(_ud: *c_void, p: *c_void, _osize: size_t, nsize: size_t) -> *c_void { unsafe { use core::libc::{realloc, free}; ...
code_fim
hard
{ "lang": "rust", "repo": "vogon/yolo-sansa", "path": "/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> state.call(2, SomeResults(1)); println(fmt!("Result: %?", state.tointeger(-1))); }<|fim_prefix|>// repo: vogon/yolo-sansa path: /main.rs use core::libc::{c_void, size_t}; use lua51::*; extern fn lua_alloc(_ud: *c_void, p: *c_void, _osize: size_t, ...
code_fim
medium
{ "lang": "rust", "repo": "vogon/yolo-sansa", "path": "/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avitex/rust-dnscat path: /dnscat/src/transport/dns/mod.rs #[cfg(feature = "client")] mod client; mod endpoint; mod name; #[cfg(feature = "trust-dns-resolver")] mod resolver; #[cfg(feature = "client")] pub use self::client::*; pub use self::endpoint::*; pub use self::name::*; use failure::Fail;...
code_fim
hard
{ "lang": "rust", "repo": "avitex/rust-dnscat", "path": "/dnscat/src/transport/dns/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Fail)] pub enum DnsTransportError<D: Fail> { #[fail(display = "DNS protocol error: {}", _0)] Proto(ProtoError), #[fail(display = "Datagram error: {}", _0)] Datagram(DatagramError<D>), #[fail(display = "DNS endpoint error: {}", _0)] Endpoint(DnsEndpointError), #[...
code_fim
hard
{ "lang": "rust", "repo": "avitex/rust-dnscat", "path": "/dnscat/src/transport/dns/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> BaseFontDict<'a> { pub fn from_dict(dict: &mut Dictionary<'a>, resolver: &mut dyn Resolve<'a>) -> PdfResult<Self> { let name = dict.get_name("Name", resolver)?; let first_char = dict.get_unsigned_integer("FirstChar", resolver)?; let last_char = dict.get_unsigned_intege...
code_fim
hard
{ "lang": "rust", "repo": "jungle-bits/pdf", "path": "/src/font/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jungle-bits/pdf path: /src/font/mod.rs use type0::Type0Font; use crate::{error::PdfResult, objects::Dictionary, pdf_enum, Resolve}; pub use self::{ descriptor::FontDescriptor, glyph::Glyph, true_type::TrueTypeFont, type1::{MmType1Font, Type1Font}, type3::Type3Font, }; mod ...
code_fim
hard
{ "lang": "rust", "repo": "jungle-bits/pdf", "path": "/src/font/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn videoSetModeSub(mode: u32) { unsafe { *REG_DSPCNT_SUB = mode; } }<|fim_prefix|>// repo: rrohrer/rs-nds path: /src/lib.rs #![no_std] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(warnings)] #[cfg(feature = "use-bindgen")] inclu...
code_fim
hard
{ "lang": "rust", "repo": "rrohrer/rs-nds", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rrohrer/rs-nds path: /src/lib.rs #![no_std] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(warnings)] #[cfg(feature = "use-bindgen")] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); <|fim_suffix|>pub fn videoSetModeSub(mode: u32) { ...
code_fim
hard
{ "lang": "rust", "repo": "rrohrer/rs-nds", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SamJBarney/vm path: /src/machine/memory.rs use std::sync::Arc; use std::sync::RwLock; use super::word::Type as WordType; use crate::shared_arc::SharedArc; pub struct Memory { mem: Box<[WordType]>, } pub type SharedMemory = SharedArc<Memory>; <|fim_suffix|> pub fn get_range(&...
code_fim
hard
{ "lang": "rust", "repo": "SamJBarney/vm", "path": "/src/machine/memory.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_range(&mut self, pos: WordType, range: &[WordType]) -> Result<(), MemoryErr> { if (pos as usize + range.len()) <= self.mem.len() { self.mem[(pos as usize)..range.len()].clone_from_slice(range); Ok(()) } else { Err(MemoryErr::PointerRangeOverflow(self.len() as Wo...
code_fim
hard
{ "lang": "rust", "repo": "SamJBarney/vm", "path": "/src/machine/memory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fwcd/bassbox path: /core/src/graph.rs use dsp::Node; use std::sync::Arc; use parking_lot::Mutex; use crate::audioformat::StandardFrame; use crate::util::empty::Empty; <|fim_suffix|>/// The audio graph which is shared between /// an engine and possibly control threads /// (such as RPC-mechanisms...
code_fim
medium
{ "lang": "rust", "repo": "fwcd/bassbox", "path": "/core/src/graph.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Creates a new, shared atomically reference-counted /// audio graph with a single, empty master node. pub fn new_shared_graph<N>() -> SharedAudioGraph<N> where N: Empty + Node<StandardFrame> { let mut graph = AudioGraph::new(); let master = graph.add_node(N::empty()); graph.set_master(Some(master));...
code_fim
hard
{ "lang": "rust", "repo": "fwcd/bassbox", "path": "/core/src/graph.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> module .register_async_method("eth_protocolVersion", |_, context| async move { let context = context.read().await; logic::protocol_verion(&context) .map_err(|err| jsonrpsee_core::Error::Custom(err.to_string())) }) .unwrap(); module ...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/jormungandr", "path": "/jormungandr/src/jrpc/eth_chain_info/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> module .register_async_method("eth_syncing", |_, context| async move { let context = context.read().await; logic::syncing(&context) .await .map_err(|err| jsonrpsee_core::Error::Custom(err.to_string())) }) .unwrap(); m...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/jormungandr", "path": "/jormungandr/src/jrpc/eth_chain_info/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: input-output-hk/jormungandr path: /jormungandr/src/jrpc/eth_chain_info/mod.rs use crate::context::ContextLock; use jsonrpsee_http_server::RpcModule; mod logic; pub fn eth_chain_info_module(context: ContextLock) -> RpcModule<ContextLock> { let mut module = RpcModule::new(context); modu...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/jormungandr", "path": "/jormungandr/src/jrpc/eth_chain_info/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VenmoTools/libarch path: /src/arch/intel/x64/descriptor/flags.rs use bitflags::bitflags; bitflags! { /// GDT 描述符标志位 /// 代码段描述符标志位 /// 位43 42 41 40 描述符类型 说明 /// 1 0 0 0 代码 仅执行 /// 1 0 0 1 代码 仅执行,已访问 /// 1 0 1 0 代码 执行/可读 /// 1 0 1...
code_fim
hard
{ "lang": "rust", "repo": "VenmoTools/libarch", "path": "/src/arch/intel/x64/descriptor/flags.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>bitflags! { pub struct IdtFlags: u16 { const PRESENT = 1 << 7; const RING_0 = 0 << 5; const RING_1 = 1 << 5; const RING_2 = 2 << 5; const RING_3 = 3 << 5; const SS = 1 << 4; const INTERRUPT = 0xE; const TRAP = 0xF; } }<|fim_prefix|>//...
code_fim
medium
{ "lang": "rust", "repo": "VenmoTools/libarch", "path": "/src/arch/intel/x64/descriptor/flags.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> } } bitflags! { pub struct GdtFlags: u8{ const PAGE_SIZE = 1 << 7; const PROTECTED_MODE = 1 << 6; const LONG_MODE = 1 << 5; } } bitflags! { pub struct IdtFlags: u16 { const PRESENT = 1 << 7; const RING_0 = 0 << 5; const RING_1 = 1 << 5; ...
code_fim
hard
{ "lang": "rust", "repo": "VenmoTools/libarch", "path": "/src/arch/intel/x64/descriptor/flags.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: markbt/streampager path: /src/ruler.rs //! The Ruler use std::cmp::{max, min}; use std::fmt::Write; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::Arc; use std::time::Instant; use termwiz::surface::change::Change; use unicode_width::UnicodeWidthStr; use crate::bar:...
code_fim
hard
{ "lang": "rust", "repo": "markbt/streampager", "path": "/src/ruler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let top = self.top.load(Ordering::SeqCst); let left = self.left.load(Ordering::SeqCst); let bottom = self.bottom.load(Ordering::SeqCst); let line_wrapping = self.line_wrapping.load(Ordering::SeqCst); let word_wrapping = self.word_wrapping.load(Ordering::SeqCst); ...
code_fim
hard
{ "lang": "rust", "repo": "markbt/streampager", "path": "/src/ruler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(2, Solution::climb_stairs(2)); } }<|fim_prefix|>// repo: chux0519/leetcode-rust path: /archived/q070_climbing_stairs.rs struct Solution; impl Solution { pub fn climb_stairs(n: i32) -> i32 { // f(n) = f(n - 1) + f( n - 2 ) let mut t = vec![0; n as usize + 1]; ...
code_fim
medium
{ "lang": "rust", "repo": "chux0519/leetcode-rust", "path": "/archived/q070_climbing_stairs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chux0519/leetcode-rust path: /archived/q070_climbing_stairs.rs struct Solution; impl Solution { pub fn climb_stairs(n: i32) -> i32 { // f(n) = f(n - 1) + f( n - 2 ) let mut t = vec![0; n as usize + 1]; t[0] = 1; t[1] = 1; for i in 2..=n as usize { ...
code_fim
medium
{ "lang": "rust", "repo": "chux0519/leetcode-rust", "path": "/archived/q070_climbing_stairs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JayKickliter/erlang-tc path: /native/ciphertext.rs use rustler::{Env, ResourceArc}; use threshold_crypto::Ciphertext; <|fim_suffix|>pub type CiphertextArc = ResourceArc<CiphertextRes>; pub fn load(env: Env) -> bool { rustler::resource!(CiphertextRes, env); true } #[rustler::nif(name =...
code_fim
medium
{ "lang": "rust", "repo": "JayKickliter/erlang-tc", "path": "/native/ciphertext.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[rustler::nif(name = "ciphertext_verify")] fn ciphertext_verify(cipher_arc: CiphertextArc) -> bool { cipher_arc.cipher.verify() } #[rustler::nif(name = "ciphertext_cmp")] fn ciphertext_cmp(c1a: CiphertextArc, c2a: CiphertextArc) -> bool { c1a.cipher == c2a.cipher }<|fim_prefix|>// repo: JayKickl...
code_fim
medium
{ "lang": "rust", "repo": "JayKickliter/erlang-tc", "path": "/native/ciphertext.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[rustler::nif(name = "ciphertext_cmp")] fn ciphertext_cmp(c1a: CiphertextArc, c2a: CiphertextArc) -> bool { c1a.cipher == c2a.cipher }<|fim_prefix|>// repo: JayKickliter/erlang-tc path: /native/ciphertext.rs use rustler::{Env, ResourceArc}; use threshold_crypto::Ciphertext; <|fim_middle|>/// Struct...
code_fim
hard
{ "lang": "rust", "repo": "JayKickliter/erlang-tc", "path": "/native/ciphertext.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> [ doop(start1), doop(start2), doop(end1), doop(start2), doop(end1), doop(end2), doop(end), doop(end11), doop(end22), ] } #[inline(always)] pub fn add(&mut self, start: P...
code_fim
hard
{ "lang": "rust", "repo": "ColRad/egaku2d", "path": "/egaku2d_core/src/shapes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ColRad/egaku2d path: /egaku2d_core/src/shapes.rs use super::*; //pub use self::circle_program::Vertex; pub struct SquareSave { _ns: NotSend, buffer: vbo::StaticBuffer<circle_program::Vertex>, } impl SquareSave { pub fn uniforms<'a>(&'a self, sys: &'a mut SimpleCanvas, radius: f32) ...
code_fim
hard
{ "lang": "rust", "repo": "ColRad/egaku2d", "path": "/egaku2d_core/src/shapes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Runners { pub fn init(link: ComponentLink<App>) -> Self { let callback_wasi = link.callback(|res| Msg::TestResult(res)); let callback_stdweb = link.callback(|res| Msg::TestResult(res)); let callback_embedded = link.callback(|res| Msg::TestResult(res)); // spawns an...
code_fim
medium
{ "lang": "rust", "repo": "dunnock/wabench", "path": "/crates/web/src/runners.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dunnock/wabench path: /crates/web/src/runners.rs use super::app::{App, Msg}; use super::data::{Request, RunnerImpl}; use super::runner::*; use super::{EmbeddedWorker, StdwebWorker, WasiWorker}; use yew::agent::Bridged; use yew::{Bridge, ComponentLink}; <|fim_suffix|>impl Runners { pub fn in...
code_fim
medium
{ "lang": "rust", "repo": "dunnock/wabench", "path": "/crates/web/src/runners.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alex6323/Ictarus path: /ictarus/tests/common/mod.rs use std::sync::{Arc, RwLock}; use ictarus::config::*; <|fim_suffix|>// Helper function to quickly create local nodes pub fn get_config(port: u16, neighbors: Vec<u16>) -> SharedConfig { let mut builder = ConfigBuilder::default().port(port)...
code_fim
medium
{ "lang": "rust", "repo": "Alex6323/Ictarus", "path": "/ictarus/tests/common/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// Helper function to quickly create local nodes pub fn get_config(port: u16, neighbors: Vec<u16>) -> SharedConfig { let mut builder = ConfigBuilder::default().port(port); for port in neighbors { builder = builder.neighbor(&format!("127.0.0.1:{}", port)); } Arc::new(RwLock::new(bui...
code_fim
medium
{ "lang": "rust", "repo": "Alex6323/Ictarus", "path": "/ictarus/tests/common/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>iven with respect to the vertex of M1 conic surface pub fn vertex_origin(&self) -> [f64; 3] { match self { Self::Center => [0., 0., 0.938 - 0.572], Self::Outer => [ 8.848320 - 0.951 * ALPHA.to_radians().sin(), 0., 0.478522...
code_fim
hard
{ "lang": "rust", "repo": "rconan/optical-path-mask", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>., 0.478522 + 0.951 * ALPHA.to_radians().cos(), ], } } /// Segment tilt angle [rd] pub fn tilt(&self) -> f64 { match self { Self::Center => 0_f64, Self::Outer => ALPHA.to_radians(), } } }<|fim_prefix|>// repo: rcon...
code_fim
hard
{ "lang": "rust", "repo": "rconan/optical-path-mask", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rconan/optical-path-mask path: /src/lib.rs const ALPHA: f64 = 13.522; /// Optical path mask specifications #[allow(dead_code)] pub enum OpticalPathMaskSpecs { Center, Outer, } impl OpticalPathMaskSpecs { /// Clear aperture diameter [m] pub fn clear_diameter(&self) -> f64 { ...
code_fim
hard
{ "lang": "rust", "repo": "rconan/optical-path-mask", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neuroradiology/drdns path: /src/buffer.rs //! `buffer.rs`: Buffered I/O //! //! This should probably be replaced eventually with e.g. the bytes crate use byte; use errno::{errno, Errno}; use libc; pub type Op = unsafe fn(i32, *const u8, u32) -> i32; #[derive(Copy)] #[repr(C)] pub struct Buffe...
code_fim
hard
{ "lang": "rust", "repo": "neuroradiology/drdns", "path": "/src/buffer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn unixwrite(fd: i32, buf: *const u8, len: u32) -> i32 { libc::write(fd, buf as (*const libc::c_void), len as (usize)) as (i32) } unsafe fn allwrite(maybe_op: Option<Op>, fd: i32, mut buf: *const u8, mut len: u32) -> i32 { let op = maybe_op.expect("allwrite with None op"); let curr...
code_fim
hard
{ "lang": "rust", "repo": "neuroradiology/drdns", "path": "/src/buffer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if matches.opt_present("h") { print_usage(args[0].as_ref(), opts); return; } if matches.opt_present("m") { let cargs: Vec<String> = args.iter().cloned().skip(2).collect(); let s: String = morse::morse_to_ascii(cargs.join(" ")); println!("{}", s); ...
code_fim
medium
{ "lang": "rust", "repo": "psyomn/programming-exercise-solutions", "path": "/archive/challenge-0007/morse-rs/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let matches = match opts.parse(&fake_args[0..]) { Ok(m) => { m }, Err(f) => { panic!("{}", f) }, }; if matches.opt_present("h") { print_usage(args[0].as_ref(), opts); return; } if matches.opt_present("m") { let cargs: Vec<String> = args.iter()....
code_fim
hard
{ "lang": "rust", "repo": "psyomn/programming-exercise-solutions", "path": "/archive/challenge-0007/morse-rs/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: psyomn/programming-exercise-solutions path: /archive/challenge-0007/morse-rs/src/main.rs extern crate morse; extern crate getopts; use std::convert::AsRef; use std::collections::HashMap; use getopts::Options; use std::env; use morse::{make_morse_hash, make_alpha_hash}; fn print_usage(program:...
code_fim
hard
{ "lang": "rust", "repo": "psyomn/programming-exercise-solutions", "path": "/archive/challenge-0007/morse-rs/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> 0x02, 0x0e, 0x03, 0x12, 0x03, 0x3b, 0x24, 0x26, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x08, 0x02, 0x0f, 0x12, 0x03, 0x3c, 0x08, 0x27, 0x0a, 0x0d, 0x0a, 0x05, 0x04, 0x08, 0x02, 0x0f, 0x04, 0x12, 0x04, 0x3c, 0x08, 0x3b, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x08, 0x02, 0x0f, 0x05, 0x12, 0x03, 0x3c, 0x08,...
code_fim
hard
{ "lang": "rust", "repo": "sifton/pgors-protobuf", "path": "/src/POGOProtos_Data_Player.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sifton/pgors-protobuf path: /src/POGOProtos_Data_Player.rs 72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x50, 0x4f, 0x47, 0x4f, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65,...
code_fim
hard
{ "lang": "rust", "repo": "sifton/pgors-protobuf", "path": "/src/POGOProtos_Data_Player.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sifton/pgors-protobuf path: /src/POGOProtos_Data_Player.rs data: &'static [u8] = &[ 0x0a, 0x1c, 0x50, 0x4f, 0x47, 0x4f, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x50, 0x...
code_fim
hard
{ "lang": "rust", "repo": "sifton/pgors-protobuf", "path": "/src/POGOProtos_Data_Player.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jespino/jsondiff-rs path: /src/lib/mod.rs //! A Json (LCS based) difference library //! //! This library is an implementation in Rust of the LCS (Longuest Common //! Subsequence) algorithm for finding differences between json data. //! //! This implementation is based on the Python [jsondiff] li...
code_fim
hard
{ "lang": "rust", "repo": "jespino/jsondiff-rs", "path": "/src/lib/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Value::U64(2), diff(&Value::U64(1), &Value::U64(2))); assert_eq!(Value::Bool(false), diff(&Value::Bool(true), &Value::Bool(false))); assert_eq!(Value::String("def".to_string()), diff(&Value::String("abc".to_string()), &Value::String("def".to_string()))); assert_e...
code_fim
hard
{ "lang": "rust", "repo": "jespino/jsondiff-rs", "path": "/src/lib/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod test { use super::*; #[test] fn p1_e2e() { let subject: FishSchool = include_str!("../../inputs/6.example.txt").into(); assert_eq!(subject.len_after(80), 5934); } #[test] fn p2_e2e() { let subject: FishSchool = include_str!("../../inputs/6.example.txt"...
code_fim
hard
{ "lang": "rust", "repo": "while1malloc0/advent-of-code", "path": "/2021/rust/src/bin/day6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn p1_e2e() { let subject: FishSchool = include_str!("../../inputs/6.example.txt").into(); assert_eq!(subject.len_after(80), 5934); } #[test] fn p2_e2e() { let subject: FishSchool = include_str!("../../inputs/6.example.txt").into(); assert_eq!(s...
code_fim
hard
{ "lang": "rust", "repo": "while1malloc0/advent-of-code", "path": "/2021/rust/src/bin/day6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: while1malloc0/advent-of-code path: /2021/rust/src/bin/day6.rs use std::collections::HashMap; fn main() { let p1_subject: FishSchool = include_str!("../../inputs/6.txt").into(); let p1_answer = p1_subject.len_after(80); println!("Part 1: {}", p1_answer); let p2_subject: FishScho...
code_fim
hard
{ "lang": "rust", "repo": "while1malloc0/advent-of-code", "path": "/2021/rust/src/bin/day6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sga001/mpir path: /src/pbc/replication.rs use super::BatchCode; use super::Tuple; use serde::Serialize; use std::collections::HashMap; use std::ops::{BitXor, BitXorAssign}; use std::{cmp, hash}; <|fim_suffix|> fn decode(&self, results: &[Tuple<K, V>]) -> Tuple<K, V> { assert_eq!(resu...
code_fim
hard
{ "lang": "rust", "repo": "sga001/mpir", "path": "/src/pbc/replication.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (i, key) in keys.iter().enumerate() { schedule.insert(key.clone(), vec![i]); } Some(schedule) } fn decode(&self, results: &[Tuple<K, V>]) -> Tuple<K, V> { assert_eq!(results.len(), 1); results[0].clone() } }<|fim_prefix|>// repo: sga001...
code_fim
medium
{ "lang": "rust", "repo": "sga001/mpir", "path": "/src/pbc/replication.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vaheqelyan/capchat path: /src/output.rs use std::str::FromStr; use color_eyre::eyre::Result; use itertools::Itertools; use tracing::debug; pub use map::text_with_map; pub use text::text; mod map; mod text; #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct Out { pub message: String,...
code_fim
hard
{ "lang": "rust", "repo": "vaheqelyan/capchat", "path": "/src/output.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let max = if len - max_len < min_len { min_len } else { max_len }; debug!(%max, "splitting message along whitespace"); let mut text = out.message.split(' ').peekable(); let mut n = 0; let first = text .peeking_take_while(|frag| { n += frag.chars().count() + 1; n < max }) .join(" "...
code_fim
hard
{ "lang": "rust", "repo": "vaheqelyan/capchat", "path": "/src/output.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kb10uy/shaardb-rs path: /src/entity.rs use crate::schema::BookmarkVisibility; use chrono::prelude::*; use serde_json::Value as JsonValue; use sqlx::prelude::*; /// Query options given from `GET /bookmarks/show`. #[derive(Debug, Clone, PartialEq, Eq)] pub enum BookmarkUniqueQuery { ByHash {...
code_fim
medium
{ "lang": "rust", "repo": "kb10uy/shaardb-rs", "path": "/src/entity.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// The entity form of a new bookmark. #[derive(Debug, Clone, PartialEq, Eq, FromRow)] pub struct UnregisteredBookmark { pub hash: String, pub url: String, pub title: String, pub description: String, pub thumbnail: Option<String>, pub sticky: bool, pub private: bool, pub ex...
code_fim
medium
{ "lang": "rust", "repo": "kb10uy/shaardb-rs", "path": "/src/entity.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /** * This function performs a `POST` to the `/logout` endpoint. */ pub async fn logout(&self) -> Result<()> { let url = "/logout".to_string(); self.client.post(&url, None).await } /** * Fetch the user associated with the current session. * * This ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/oxide.rs-old", "path": "/oxide/src/hidden.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/oxide.rs-old path: /oxide/src/hidden.rs use anyhow::Result; use crate::Client; pub struct Hidden { pub client: Client, } impl Hidden { #[doc(hidden)] pub fn new(client: Client) -> Self { Hidden { client } } /** * Start an OAuth 2.0 Device Author...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/oxide.rs-old", "path": "/oxide/src/hidden.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Copy, Clone)] pub enum Keyboard { Up, Down, Left, Right, // Space, // Esc, Unknown, }<|fim_prefix|>// repo: RainerBlessing/sdl-snake path: /src/constants.rs #[derive(Copy, Clone)] pub enum Type { Empty, Wall, Snake, Apple, } #[derive(Copy, Clone)] pub s...
code_fim
medium
{ "lang": "rust", "repo": "RainerBlessing/sdl-snake", "path": "/src/constants.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RainerBlessing/sdl-snake path: /src/constants.rs #[derive(Copy, Clone)] pub enum Type { Empty, Wall, Snake, Apple, } #[derive(Copy, Clone)] pub struct PlayField { pub field_type: Type, pub x: u32, pub y: u32, } <|fim_suffix|>#[derive(Copy, Clone)] pub enum Keyboard...
code_fim
medium
{ "lang": "rust", "repo": "RainerBlessing/sdl-snake", "path": "/src/constants.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xunilrj/sandbox path: /sources/rust/columnar-db/vold/db/src/filemanager.rs use std::path::Path; use crate::channel::*; use crate::threadpool::*; use crossbeam_channel::*; pub enum FileManagerRequests { ReadAll { file: String, sender: Sender<Message>, }, } pub struct Re...
code_fim
hard
{ "lang": "rust", "repo": "xunilrj/sandbox", "path": "/sources/rust/columnar-db/vold/db/src/filemanager.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Drop for FileManager<'a> { fn drop(&mut self) { if self.epoll > 0 { unsafe { libc::close(self.epoll) }; } } } #[cfg(test)] mod tests { use crate::threadpool::Threadpool; use crossbeam_channel::*; #[test] fn read_all() { let file = ...
code_fim
hard
{ "lang": "rust", "repo": "xunilrj/sandbox", "path": "/sources/rust/columnar-db/vold/db/src/filemanager.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut offset = 0; loop { let mut buffer = Buffer::all_zero(4 * 1024); buffer.size = unsafe { let r = libc::pread( fd, buffer.data.as_mut_ptr() as *mut libc::c_void, buffer.size, offset, ); ...
code_fim
hard
{ "lang": "rust", "repo": "xunilrj/sandbox", "path": "/sources/rust/columnar-db/vold/db/src/filemanager.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod traits { pub use super::haccel::user_Haccel; pub use super::hcursor::user_Hcursor; pub use super::hdc::user_Hdc; pub use super::hdesk::user_Hdesk; pub use super::hdwp::user_Hdwp; pub use super::hhook::user_Hhook; pub use super::hicon::user_Hicon; pub use super::hinstance::user_Hins...
code_fim
medium
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/user/handles/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }