text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>register_module!(mut ctx, { register_address_module(&mut ctx)?; register_hd_wallet_module(&mut ctx)?; register_key_pair_module(&mut ctx)?; register_transfer_transaction_module(&mut ctx)?; Ok(()) });<|fim_prefix|>// repo: calvinaco/cro-nodelib path: /native/src/lib.rs use neon::regist...
code_fim
medium
{ "lang": "rust", "repo": "calvinaco/cro-nodelib", "path": "/native/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.parts > 1 { write!(output, "=ypart begin={} end={}\r\n", self.begin, self.end)?; } rdr.seek(SeekFrom::Start(self.begin - 1))?; let mut remainder = (self.end - self.begin + 1) as usize; while remainder > 0 { let buf_slice = if remain...
code_fim
hard
{ "lang": "rust", "repo": "aswaving/yenc", "path": "/src/encode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { active, entity, vert_len, mesh_buffer, max_voxel_capacity, transform_bind_group, transform_buffer, last_transform: *transform, last_updated: 0, } } fn update( ...
code_fim
hard
{ "lang": "rust", "repo": "ericrobolson/Archived_Tremor", "path": "/v0/src/gfx/voxels/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> verts.append(&mut cube); } } } } MeshingStrategy::RunLength => { for z in 0..z_size { let zf32 = z as f32; for y in 0..y_size { ...
code_fim
hard
{ "lang": "rust", "repo": "ericrobolson/Archived_Tremor", "path": "/v0/src/gfx/voxels/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Creating our own scheme mapper with the default ports fn db_scheme_type_mapper(scheme: &str) -> SchemeType { match scheme { "postgres" => SchemeType::Relative(5432), "mysql" => SchemeType::Relative(3306), _ => SchemeType::NonRelative, } } /// Returns a driver instance d...
code_fim
hard
{ "lang": "rust", "repo": "ramn/dbmigrate", "path": "/src/drivers/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boa-dev/boa path: /boa_engine/src/vm/opcode/iteration/loop_ops.rs use crate::JsNativeError; use crate::{ vm::{opcode::Operation, CompletionType}, Context, JsResult, }; /// `IncrementLoopIteration` implements the Opcode Operation for `Opcode::IncrementLoopIteration`. /// /// Operation: /...
code_fim
hard
{ "lang": "rust", "repo": "boa-dev/boa", "path": "/boa_engine/src/vm/opcode/iteration/loop_ops.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let max = context.vm.runtime_limits.loop_iteration_limit(); if previous_iteration_count > max { return Err(JsNativeError::runtime_limit() .with_message(format!("Maximum loop iteration limit {max} exceeded")) .into()); } context.v...
code_fim
medium
{ "lang": "rust", "repo": "boa-dev/boa", "path": "/boa_engine/src/vm/opcode/iteration/loop_ops.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for match_event in &result.details.as_ref().unwrap().events { match match_event { MatchEvent::MatchPlayed(player_id, is_start_squad, minutes_played) => { let mut player = data.player_mut(*player_id).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "BeastNeedsMoreTorque/football-simulator", "path": "/src/core/src/country/result.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ut tx = $create(); result = tx.send($($arg),*); } result }}; }<|fim_prefix|>// repo: brayniac/rips path: /src/macros.rs #[macro_export] /// Macro for sending on a Tx until it does not return an `TxError::InvalidTx`. macro_rules! tx_send { ($create:expr; $($arg:expr),*)...
code_fim
medium
{ "lang": "rust", "repo": "brayniac/rips", "path": "/src/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.blocks.last_mut().unwrap() } unsafe fn new_block(&mut self, layout: Layout) -> Result<&mut OwnedArenaBlock, AllocErr> { let new_capacity = cmp::max(self.blocks.last().unwrap().vec.cap() * 2, layout.size() + layout.align()); self.bloc...
code_fim
hard
{ "lang": "rust", "repo": "nathdobson/thread_local_arena", "path": "/src/owned_arena.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nathdobson/thread_local_arena path: /src/owned_arena.rs use std::cell::UnsafeCell; use alloc::raw_vec::RawVec; use std::mem; use std::cmp; use std::ptr::null_mut; use std::isize; use alloc::allocator::Alloc; use alloc::allocator::Layout; use alloc::allocator::AllocErr; use alloc::allocator::Exce...
code_fim
hard
{ "lang": "rust", "repo": "nathdobson/thread_local_arena", "path": "/src/owned_arena.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// This function returns the version of the provided definition. pub fn version(&self) -> i32 { self.version } /// This function returns a mutable reference to the list of fields in the definition. pub fn fields_mut(&mut self) -> &mut Vec<FieldV4> { &mut self.fields ...
code_fim
hard
{ "lang": "rust", "repo": "Frodo45127/rpfm", "path": "/rpfm_lib/src/schema/v4.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(chksum) } #[cfg(test)] mod tests { use super::*; use hex_literal::hex; use rstest::*; #[rstest(input, expected, case::calculate(&hex!("45000073000040004011 0000 c0a80001c0a800c7"), 0xB861), case::validate(&hex!("45000073000040004011 B861 c0a80001c0a800c7"), 0x0000)...
code_fim
hard
{ "lang": "rust", "repo": "sharksforarms/rust-packet", "path": "/src/layer/ip/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Returns the size of each chunk of the blob. pub fn get_blob_info(ctx: &impl ScViewClientContext) -> GetBlobInfoCall { let mut f = GetBlobInfoCall { func: ScView::new(ctx, HSC_NAME, HVIEW_GET_BLOB_INFO), params: MutableGetBlobInfoParams { proxy: Proxy::nil() }...
code_fim
hard
{ "lang": "rust", "repo": "iotaledger/wasp", "path": "/packages/wasmvm/wasmlib/src/coreblob/contract.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn your_render_function(&self) { self.span.set_inner_html(&format!("Counter: {}", self.counter)); } }<|fim_prefix|>// repo: tuzz/game-loop path: /examples/using_wasm/src/main.rs use wasm_bindgen::prelude::*; use game_loop::game_loop; #[wasm_bindgen(start)] pub fn main() { let gam...
code_fim
hard
{ "lang": "rust", "repo": "tuzz/game-loop", "path": "/examples/using_wasm/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<P: Params> Hash for DetachedWindow<P> { /// Only use the [`DetachedWindow`]'s label to represent its hash. fn hash<H: Hasher>(&self, state: &mut H) { self.label.hash(state) } } impl<P: Params> Eq for DetachedWindow<P> {} impl<P: Params> PartialEq for DetachedWindow<P> { /// Only use the ...
code_fim
hard
{ "lang": "rust", "repo": "gabcoh/tauri", "path": "/core/tauri-runtime/src/window.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Create a new MMIO address constraint object. pub fn mmio_with_constraints(size: u64, range: Option<(u64, u64)>, align: u64) -> Self { ResourceConstraint::MmioAddress { range, align, size } } /// Create a new legacy IRQ constraint object. /// /// Allocating the pre-allo...
code_fim
hard
{ "lang": "rust", "repo": "rust-vmm/vm-device", "path": "/src/resources.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>&self) -> CMDRSP2_R { CMDRSP2_R::new((self.bits & 0xffff_ffff) as u32) } }<|fim_prefix|>// repo: thorhs/mk66f18 path: /src/sdhc/cmdrsp2.rs #[doc = "Reader of register CMDRSP2"] pub type R = crate::R<u32, super::CMDRSP2>; #[d<|fim_middle|>oc = "Reader of field `CMDRSP2`"] pub type CMDRSP2_R = ...
code_fim
medium
{ "lang": "rust", "repo": "thorhs/mk66f18", "path": "/src/sdhc/cmdrsp2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trembel/ambiq-apollo3p-pac path: /src/gpio/int1set.rs 25)) | (((value as u32) & 0x01) << 25); self.w } } #[doc = "Reader of field `GPIO56`"] pub type GPIO56_R = crate::R<bool, bool>; #[doc = "Write proxy for field `GPIO56`"] pub struct GPIO56_W<'a> { w: &'a mut W, } impl<'a> GPI...
code_fim
hard
{ "lang": "rust", "repo": "trembel/ambiq-apollo3p-pac", "path": "/src/gpio/int1set.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> 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 field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a...
code_fim
hard
{ "lang": "rust", "repo": "trembel/ambiq-apollo3p-pac", "path": "/src/gpio/int1set.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>n gpio40(&self) -> GPIO40_R { GPIO40_R::new(((self.bits >> 8) & 0x01) != 0) } #[doc = "Bit 7 - GPIO39 interrupt."] #[inline(always)] pub fn gpio39(&self) -> GPIO39_R { GPIO39_R::new(((self.bits >> 7) & 0x01) != 0) } #[doc = "Bit 6 - GPIO38 interrupt."] #[inline(...
code_fim
hard
{ "lang": "rust", "repo": "trembel/ambiq-apollo3p-pac", "path": "/src/gpio/int1set.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Geraet/kompositum-rs path: /src/tests.rs // Copyright(c) 2021 René Hansen. // Distributed under the MIT License (http://opensource.org/licenses/MIT) #[cfg(test)] mod tests { use crate::{builder, printer::Printer, IDType}; use multimap::MultiMap; const TREE_MAP_DEF: &[(IDType, IDTyp...
code_fim
medium
{ "lang": "rust", "repo": "Geraet/kompositum-rs", "path": "/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_component_debug_print() { let tree_map: MultiMap<IDType, IDType> = TREE_MAP_DEF.iter().cloned().collect(); let root = builder::build_composite(1, &tree_map); println!("{:?}", &root); } }<|fim_prefix|>// repo: Geraet/kompositum-rs path: /src/tests.rs //...
code_fim
medium
{ "lang": "rust", "repo": "Geraet/kompositum-rs", "path": "/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let stats_handle = thread::spawn(move || { stats::stats_loop( stats_rx, ((image_width as f32 * image_height as f32 * 11.3) as usize + 24) as usize, ) }); let render_handle = thread::spawn(move || render::render_loop(&outfile, render_rx)); let color_...
code_fim
hard
{ "lang": "rust", "repo": "DivineStride/Another-Simple-Ray-Tracer", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: torhovland/fyrstikker path: /benches/my_benchmark.rs use criterion::{criterion_group, criterion_main, Criterion, SamplingMode}; use fyrstikker::fyrstikk_tal_kombinasjonar; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; fn criterion_benchmark(c: &mut Criterion) { <|...
code_fim
hard
{ "lang": "rust", "repo": "torhovland/fyrstikker", "path": "/benches/my_benchmark.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>criterion_group!(benches, criterion_benchmark); criterion_main!(benches);<|fim_prefix|>// repo: torhovland/fyrstikker path: /benches/my_benchmark.rs use criterion::{criterion_group, criterion_main, Criterion, SamplingMode}; use fyrstikker::fyrstikk_tal_kombinasjonar; <|fim_middle|>#[global_allocator] st...
code_fim
hard
{ "lang": "rust", "repo": "torhovland/fyrstikker", "path": "/benches/my_benchmark.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[error("git retreive {url:?} (rev: {rev:?}) into folder {dst:?}")] GitRetrieve { dst: PathBuf, url: String, rev: Option<String>, source: GitError, msg: Box<String>, }, #[error("try to find git config '{key:?}'")] GitFindConfig { key: String, sou...
code_fim
hard
{ "lang": "rust", "repo": "ffizer/ffizer", "path": "/src/error.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> h5call!(H5Sget_simple_extent_ndims(self.id())).unwrap_or(0) as _ } fn dims(&self) -> Vec<Ix> { let ndim = self.ndim(); if ndim > 0 { let mut dims: Vec<hsize_t> = Vec::with_capacity(ndim); unsafe { dims.set_len(ndim); } ...
code_fim
hard
{ "lang": "rust", "repo": "balintbalazs/hdf5-rust", "path": "/src/hl/space.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn package_url(mirror_url: Url, version: &Version) -> Url { debug!("pakage url"); Url::parse(&format!( "{}/{}/{}", mirror_url.as_str().trim_end_matches('/'), match version { Version::Semver(version) => format!("{}.{}", version.major, version.minor), ...
code_fim
hard
{ "lang": "rust", "repo": "kenoss/frum", "path": "/src/commands/install.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(clippy::unnecessary_wraps)] fn openssl_dir() -> Result<String, FrumError> { #[cfg(target_os = "macos")] return Ok(String::from_utf8_lossy( &Command::new("brew") .arg("--prefix") .arg("openssl") .output() .map_err(FrumError::IoError)? ...
code_fim
hard
{ "lang": "rust", "repo": "kenoss/frum", "path": "/src/commands/install.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[tauri::command] pub fn force_reset() -> Result<(), ()> { let mut configurator = Configurator::new(); configurator.force_reset(); Ok(()) } #[tauri::command] pub fn get_home() -> Result<String, ()> { match dirs::home_dir() { None => Ok(String::new()), Some(path) => Ok(path...
code_fim
hard
{ "lang": "rust", "repo": "projectacrn/acrn-hypervisor", "path": "/misc/config_tools/configurator/packages/configurator/src-tauri/src/configurator.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[tauri::command] pub fn get_home() -> Result<String, ()> { match dirs::home_dir() { None => Ok(String::new()), Some(path) => Ok(path.to_str().unwrap().to_string()), } } #[derive(Serialize)] pub struct DirEntry { path: String, children: Option<Vec<DirEntry>>, } #[tauri::c...
code_fim
hard
{ "lang": "rust", "repo": "projectacrn/acrn-hypervisor", "path": "/misc/config_tools/configurator/packages/configurator/src-tauri/src/configurator.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_data_type() { let input = to_chars("s32"); let ret = data_type().parse(&input).expect("must be parsed"); println!("{:#?}", ret); assert_eq!(ret, DataType::S32); } #[test] fn test_invalid_data_type() { let input = to_chars("x32");...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/restq", "path": "/src/data_type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if exit_success { symbol.set_style(color_success.bold()); } else { symbol.set_style(color_failure.bold()); }; Some(module) }<|fim_prefix|>// repo: baitcenter/starship path: /src/modules/character.rs use super::{Context, Module}; use ansi_term::Color; /// Creates a module...
code_fim
hard
{ "lang": "rust", "repo": "baitcenter/starship", "path": "/src/modules/character.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> resource_container.textures.insert( String::from(stringify!(pos_diffuse_normal_texture)), pos_diffuse_normal_texture, ); resource_container .textures .insert(String::from(stringify!(albedo_texture)), albedo_texture); resource...
code_fim
hard
{ "lang": "rust", "repo": "happydpc/Horizon", "path": "/src/renderer/bindgroups/gbuffer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/thanks path: /src/main.rs unwrap_or_else(|| panic!("no email for {}", sig)); Author { name: name.to_string(), email: email.to_string(), } } } #[derive(Clone)] pub struct AuthorMap { // author -> [commits] map: HashMap<Author, HashSe...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/thanks", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let to_author = |list: &str| -> Result<Vec<Author>, ErrorContext> { list.trim_end_matches('.') .split(|c| c == ',' || c == '+') .map(|r| r.trim_start_matches('@')) .map(|r| r.trim_end_matches('`')) .map(|r| r.trim()) .filter(|r| !r.is...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/thanks", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/thanks path: /src/main.rs ), } } fn add(&mut self, author: Author, commit: Oid) { self.map .entry(author) .or_insert_with(HashSet::new) .insert(commit); } fn iter(&self) -> impl Iterator<Item = (&Author, usize)> { ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/thanks", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> html! { <div class="d-flex flex-grow-1 align-items-center justify-content-center"> <div class="text-center"> { self.props.children.clone() } </div> </div> } } }<|fim_prefix|>// repo: rillrate-fossil/rillrate p...
code_fim
medium
{ "lang": "rust", "repo": "rillrate-fossil/rillrate", "path": "/pkg-dashboard/rate-ui/src/common/middler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: songlinshu/registry-rs path: /examples/private-hive.rs use registry::{Hive, Security}; use winapi::{shared::ntdef::LUID, um::{processthreadsapi::OpenProcessToken, securitybaseapi::AdjustTokenPrivileges, winbase::LookupPrivilegeValueW, winnt::LUID_AND_ATTRIBUTES, winnt::{HANDLE, SE_BACKUP_NAME, S...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/registry-rs", "path": "/examples/private-hive.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", keys); Ok(()) } fn set_privilege(handle: HANDLE, name: &str) -> Result<(), std::io::Error> { let mut luid: LUID = LUID { LowPart: 0, HighPart: 0, }; let name: U16CString = name.try_into().unwrap(); let r = unsafe {LookupPrivilegeValueW(std::ptr::nu...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/registry-rs", "path": "/examples/private-hive.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let r = unsafe { AdjustTokenPrivileges(handle, false as i32, &mut privilege, std::mem::size_of::<TOKEN_PRIVILEGES>() as u32, std::ptr::null_mut(), std::ptr::null_mut()) }; if r == 0 { return Err(std::io::Error::last_os_error()); } Ok(()) }<|fim_prefix|>// repo: songlin...
code_fim
medium
{ "lang": "rust", "repo": "songlinshu/registry-rs", "path": "/examples/private-hive.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>async fn run_completions(shell: ShellCompletion) -> Result<()> { info!(version=%env!("CARGO_PKG_VERSION"), "constructing completions"); fn generate(generator: impl Generator) { let mut cmd = Args::command(); clap_complete::generate(generator, &mut cmd, "watchexec", &mut std::io::stdout()); } mat...
code_fim
hard
{ "lang": "rust", "repo": "watchexec/watchexec", "path": "/crates/cli/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let database_pool_size_str = env::var("DATABASE_POOL_SIZE").unwrap_or_else(|_| "10".to_string()); let database_pool_size: usize = database_pool_size_str.parse().unwrap(); database_pool_size }) } fn pool() -> &'static Pool<ConnectionManager<PgConnection>> { POO...
code_fim
hard
{ "lang": "rust", "repo": "Godofh3ell/el_monitorro-1", "path": "/src/db.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// # Arguments /// * segment_number - 1-indexed segment number pub fn segment_header(&self, segment_number: u16) -> Result<NESegmentEntry, ParseError> { assert!(segment_number != 0 || segment_number <= self.header.num_segments, format!("segment number {} is out of range", segment_number)); let off...
code_fim
hard
{ "lang": "rust", "repo": "csnover/deoptloader", "path": "/src/neexe.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if switch1.is_held() { info!("Button held!"); *LED_IS_ON = false; } if switch1.is_double() { info!("Button pressed twice!"); *LED_IS_ON = true; } if *LED_IS_ON { ctx.resources.seed_led.set_high().unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "Spstolar/libdaisy-rust-quickstart", "path": "/examples/switch.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Use OS's keep-alive (usually quite long) let _two = HttpServer::new(app).keep_alive(KeepAlive::Os); // Disable keep-alive let _three = HttpServer::new(app).keep_alive(None); Ok(()) } // </keep-alive><|fim_prefix|>// repo: actix/actix-website path: /examples/server/src/keep_alive....
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-website", "path": "/examples/server/src/keep_alive.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn aligner() { assert_eq!(align_address(4 as *const u8, 4), 0); assert_eq!(align_address(5 as *const u8, 4), 3); assert_eq!(align_address(17 as *const u8, 1), 0); } #[test] fn block() { let mut b = Block::new(16); assert!(b.has_room(16, ...
code_fim
hard
{ "lang": "rust", "repo": "Twinklebear/light_arena", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sdleffler/type-level-logic-rs path: /src/strong/mod.rs //! "Strongly" enforced (non-SFINAE-style) type operators. Here, "strong" means that if you use //! a type operator from this module, Rust will complain if <|fim_suffix|>ound in a `where` clause. pub mod boolean; pub mod ternary; pub mod ba...
code_fim
medium
{ "lang": "rust", "repo": "sdleffler/type-level-logic-rs", "path": "/src/strong/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ound in a `where` clause. pub mod boolean; pub mod ternary; pub mod balanced;<|fim_prefix|>// repo: sdleffler/type-level-logic-rs path: /src/strong/mod.rs //! "Strongly" enforced (non-SFINAE-style) type operators. Here, "strong" mean<|fim_middle|>s that if you use //! a type operator from this module, R...
code_fim
medium
{ "lang": "rust", "repo": "sdleffler/type-level-logic-rs", "path": "/src/strong/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> proptest::num::u16::ANY.prop_filter_map("Invalid UI locale code", |code| { let ui_locale = Locale(code); if ui_locale.to_string().is_ascii() { Some(ui_locale) } else { None } }) } #[test] fn from_s...
code_fim
hard
{ "lang": "rust", "repo": "makers-for-life/makair-telemetry", "path": "/src/locale.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn from_str_empty() { assert!(Locale::try_from("").is_err()) } #[test] fn from_str_too_long() { assert!(Locale::try_from("fra").is_err()) } #[test] fn to_str() { assert_eq!(Locale(FR).to_string().as_str(), "fr") } proptest! { ...
code_fim
hard
{ "lang": "rust", "repo": "makers-for-life/makair-telemetry", "path": "/src/locale.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> // これは、主体の駒の手筋にならない☆(^~^)抜けて続行するぜ☆(^~^) continue 'sequence_thread; } if !self.match_object_piece( rack, ...
code_fim
hard
{ "lang": "rust", "repo": "muzudho/rust-kifuwarabe-wcsc29-lib", "path": "/src/live/best_move_picker.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: muzudho/rust-kifuwarabe-wcsc29-lib path: /src/live/best_move_picker.rs ck::*; use human::human_interface::*; use instrument::piece_etc::*; use instrument::position::*; use live::base_performer::*; use live::ohashi_performer::OHASHI_NOTE_LEN; use musician::best_move::BestMove; use musician::best_...
code_fim
hard
{ "lang": "rust", "repo": "muzudho/rust-kifuwarabe-wcsc29-lib", "path": "/src/live/best_move_picker.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // この手は、タッチはできるみたいだな☆(^~^) // ベストムーブを作ろうぜ☆(^~^) let best_move = if let Some(best_move) = rmove.to_best_move( rack, Slot::Training, ...
code_fim
hard
{ "lang": "rust", "repo": "muzudho/rust-kifuwarabe-wcsc29-lib", "path": "/src/live/best_move_picker.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> server = if let Some(l) = listenfd.take_tcp_listener(0).unwrap() { server.listen(l)? } else { server.bind("localhost:8000")? }; server.run().await } #[get("")] async fn index(_req: HttpRequest) -> impl Responder { HttpResponse::Ok().json("Catalog API root") } async f...
code_fim
hard
{ "lang": "rust", "repo": "japarado/appliance-catalog-api", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Visits a serializable body. /// /// The default implementation returns an error. fn visit_serializable<'de, D>(self, deserializer: D) -> Result<Self::Output, Error> where D: Deserializer<'de>, D::Error: Into<Box<dyn error::Error + Sync + Send>>, { let _ ...
code_fim
hard
{ "lang": "rust", "repo": "svc-excavator-bot-org/conjure-rust", "path": "/conjure-http/src/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the endpoint's parameters. #[inline] pub const fn parameters(&self) -> &'static [Parameter] { self.parameters } /// Returns if the endpoint is deprecated. #[inline] pub const fn deprecated(&self) -> bool { self.deprecated } } /// A synchronous ...
code_fim
hard
{ "lang": "rust", "repo": "svc-excavator-bot-org/conjure-rust", "path": "/conjure-http/src/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ja1den/research-project path: /scenarios/1/rs/src/main.rs // Import use std::{env, fs, io}; // Main Function fn main() { // Resolve Directories let root = env::current_dir() .unwrap() .join("..") .canonicalize() .unwrap(); let i_path = root.join("data/input").canonicalize().unwrap()...
code_fim
medium
{ "lang": "rust", "repo": "ja1den/research-project", "path": "/scenarios/1/rs/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Parse and Sort Numbers let mut numbers: Vec<u64> = read.lines().map(|s| s.parse::<u64>().unwrap()).collect(); numbers.sort(); // Stringify Numbers let data: Vec<String> = numbers.iter().map(|n| format!("{:0>8}", n)).collect(); // Create File fs::write(o_path.join(name.file_name().unwrap...
code_fim
medium
{ "lang": "rust", "repo": "ja1den/research-project", "path": "/scenarios/1/rs/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gyng/rcue path: /src/parser.rs ext_file = Some(path); } Ok(Command::Flags(flags)) => { if last_track(&mut cue).is_some() { last_track(&mut cue).unwrap().flags = flags; } else { ...
code_fim
hard
{ "lang": "rust", "repo": "gyng/rcue", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let cue = parse_from_file("test/fixtures/bad_index.cue", true); assert!(cue.is_err()); } #[test] fn test_bad_index_timestamp_lenient() { let cue = parse_from_file("test/fixtures/bad_index_timestamp.cue", false).unwrap(); assert_eq!(cue.files[0].tracks[0].indice...
code_fim
hard
{ "lang": "rust", "repo": "gyng/rcue", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gyng/rcue path: /src/parser.rs let comment = (field, value); if last_track(&mut cue).is_some() { last_track(&mut cue).unwrap().comments.push(comment); } else if last_file(&mut cue).is_some() { last...
code_fim
hard
{ "lang": "rust", "repo": "gyng/rcue", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-fuzz/cargo-fuzz path: /tests/tests/main.rs ::str::contains("File exists (os error 17)").and( predicates::str::contains(format!( "failed to create directory {}", project.fuzz_dir().display() )), )) .failure(); } #[test]...
code_fim
hard
{ "lang": "rust", "repo": "rust-fuzz/cargo-fuzz", "path": "/tests/tests/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-fuzz/cargo-fuzz path: /tests/tests/main.rs ifacts/yes_crash/crash-" )) .and(predicate::str::contains( "Minimize test case with:\n\ \n\ \tcargo fuzz tmin yes_crash fuzz/artifacts/yes_crash/crash-" ...
code_fim
hard
{ "lang": "rust", "repo": "rust-fuzz/cargo-fuzz", "path": "/tests/tests/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let project = project("run_one_input") .with_fuzz() .fuzz_target( "run_one", r#" #![no_main] use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { #[cfg(fuzzing_repro)] ...
code_fim
hard
{ "lang": "rust", "repo": "rust-fuzz/cargo-fuzz", "path": "/tests/tests/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns a mem_reader for the offset/value field pub fn r(&self, byte_order: ByteOrder) -> SmartReader<io::Cursor<Vec<u8>>> { SmartReader::wrap( io::Cursor::new(self.offset.to_vec()), byte_order ) } // Refactor this to remove the dependency on dec...
code_fim
hard
{ "lang": "rust", "repo": "performance/image", "path": "/src/tiff/ifd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Entry { pub fn new(type_: Type, count: u32, offset: [u8; 4] ) -> Entry { Entry { type_: type_, count: count, offset: offset, } } /// Returns a mem_reader for the offset/value field pub fn r(&self, byte_order: ByteOrder) -> SmartRead...
code_fim
hard
{ "lang": "rust", "repo": "performance/image", "path": "/src/tiff/ifd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] pub(crate) mod client_tests { use super::*; use std::io::BufRead; use std::io::Write; /// Server for handling HTTP client requests with a stock response. pub struct HttpServer { address: std::net::SocketAddr, handler: std::thread::JoinHandle<()>, shutdown: std::sync::Arc<std::sync...
code_fim
hard
{ "lang": "rust", "repo": "TheBlueMatt/rust-lightning", "path": "/lightning-block-sync/src/http.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheBlueMatt/rust-lightning path: /lightning-block-sync/src/http.rs an HTTP request message and reads the response, returning its body. async fn send_request(&mut self, request: &str) -> std::io::Result<Vec<u8>> { self.write_request(request).await?; self.read_response().await } /// Write...
code_fim
hard
{ "lang": "rust", "repo": "TheBlueMatt/rust-lightning", "path": "/lightning-block-sync/src/http.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheBlueMatt/rust-lightning path: /lightning-block-sync/src/http.rs M_TIMEOUT))?; #[cfg(feature = "tokio")] let stream = { stream.set_nonblocking(true)?; TcpStream::from_std(stream)? }; Ok(Self { address, stream }) } /// Sends a `GET` request for a resource identified by `uri` ...
code_fim
hard
{ "lang": "rust", "repo": "TheBlueMatt/rust-lightning", "path": "/lightning-block-sync/src/http.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn scalar_inversion() { // we have to test against this grin secp because that's the one that exposes it use secp256k1zkp::key::SecretKey; let secp = secp256k1zkp::Secp256k1::new(); let bytes = rand_32_bytes(); let mut sk = SecretKey::from_slice(&sec...
code_fim
hard
{ "lang": "rust", "repo": "comit-network/secp256kfun", "path": "/secp256kfun/tests/against_c_lib.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> robot.delay.delay_ms(70 as u16); */ /* if let Ok(byte) = pc_rx.read() { reader.step(byte); } if let Some(trame) = reader.pop_trame() { if let Some(sent) = handle_trame(trame) { let (arr, size): ([u8; 15], usize) = sent.into();...
code_fim
hard
{ "lang": "rust", "repo": "ClubRobotInsat/elec", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for b in m1 { block!(robot.servo_tx.write(b)).unwrap(); } } fn main() -> ! { let mut robot = init_peripherals( stm32f446::Peripherals::take().unwrap(), cortex_m::Peripherals::take().unwrap(), ); init_servo(&mut robot); let mut reader = TrameReader::new();...
code_fim
hard
{ "lang": "rust", "repo": "ClubRobotInsat/elec", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn print(buffer: [u8; 32], size: usize) { let _ = system_call(SystemCall::Print { request: (buffer, size) }); } #[cfg(feature="kernel_debug")] pub fn debug_cpool_list() { system_call(SystemCall::DebugCPoolList); } #[cfg(feature="kernel_debug")] pub fn debug_test_succeed() { s...
code_fim
hard
{ "lang": "rust", "repo": "zhangpf/rux", "path": "/system/src/call.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn run() { let mut rrrdb = build_crean_database(); rrrdb .execute("test_db", "CREATE TABLE users (id integer, name varchar)") .unwrap(); rrrdb .execute("test_db", "INSERT INTO users VALUES (1, 'Alice')") .unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "yukibtc/rrrdb", "path": "/src/rrrdb.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn de_l(raw: f32, even: bool) -> i32 { if even && raw < 0.0 { (raw.ceil() - 1.0) as i32 } else { raw.floor() as i32 } } fn de_timeline(raw: TimelineRaw, even: bool) -> game::Timeline { let mut res = game::Timeline::new( de_l(raw.index, even), raw.width, ...
code_fim
hard
{ "lang": "rust", "repo": "arbanhossain/5dchess-tools", "path": "/lib/parse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(memory.store_byte(0, 0, 42).is_ok()); assert!(memory.store_bytes(0, &[]).is_ok()); } #[test] pub fn test_memory_load_bytes() { let mut rng = thread_rng(); assert_memory_load_bytes_all(&mut rng, RISCV_MAX_MEMORY, 1024 * 5, 0); assert_memory_load_bytes_all(&mut rng, RISCV_MAX_M...
code_fim
hard
{ "lang": "rust", "repo": "libraries/ckb-vm", "path": "/tests/test_misc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Reader of field `L1RESUME`"] pub type L1RESUME_R = crate::pac::generic::R<bool, L1RESUME_A>; impl L1RESUME_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> crate::pac::generic::Variant<bool, L1RESUME_A> { ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-usbd", "path": "/src/pac/usb/cntr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-usbd path: /src/pac/usb/cntr.rs { match self.bits { false => FRES_A::NORESET, true => FRES_A::RESET, } } #[doc = "Checks if the value of the field is `NORESET`"] #[inline(always)] pub fn is_no_reset(&self) -> bool { ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-usbd", "path": "/src/pac/usb/cntr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Reader of field `RESETM`"] pub type RESETM_R = crate::pac::generic::R<bool, RESETM_A>; impl RESETM_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> RESETM_A { match self.bits { false => RESE...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-usbd", "path": "/src/pac/usb/cntr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateInstance.html>"] /// /// # Safety /// In order for the created [`Instance`] to be valid for the duration of its /// usage, the [`Entry`](Self) this was called on must be dropped later than the /...
code_fim
hard
{ "lang": "rust", "repo": "dev-chee/ash", "path": "/ash/src/entry.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Error for InstanceError {} impl vk::StaticFn { pub fn load_checked<F>(mut _f: F) -> Result<Self, MissingEntryPoint> where F: FnMut(&::std::ffi::CStr) -> *const c_void, { // TODO: Make this a &'static CStr once CStr::from_bytes_with_nul_unchecked is const static EN...
code_fim
hard
{ "lang": "rust", "repo": "dev-chee/ash", "path": "/ash/src/entry.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_text_by_id(&self, id: &str) -> Vec<TextChunk> { unsafe { FromGlibPtrContainer::from_glib_full(gepub_sys::gepub_doc_get_text_by_id(self.to_glib_none().0, id.to_glib_none().0)) } } //pub fn get_toc(&self) -> /*Ignored*/Vec<NavPoint> { // unsafe { TO...
code_fim
hard
{ "lang": "rust", "repo": "antoyo/libgepub-rs", "path": "/src/auto/doc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mejk/grafen path: /src/bin/main.rs //! Create graphene and other substrates for use in molecular dynamics simulations. extern crate colored; extern crate dialoguer; extern crate serde; extern crate serde_json; extern crate structopt; #[macro_use] extern crate structopt_derive; extern crate gra...
code_fim
hard
{ "lang": "rust", "repo": "mejk/grafen", "path": "/src/bin/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let current_dir = current_dir().unwrap_or(PathBuf::new()); let entries = configurations .iter() .map(|conf| ReadConf { conf: None, path: current_dir.join(&conf.path), backup_conf: None, description: conf.description.clone(), ...
code_fim
hard
{ "lang": "rust", "repo": "mejk/grafen", "path": "/src/bin/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kubo/rosy path: /src/prelude.rs //! Types and traits that are commonly used within this library. //! //! This module is intended to be glob imported via `use rosy::prelude::*` when //! primarily working with Rosy types. This allows for having access to _almost_ //! everything one may need. //! /...
code_fim
hard
{ "lang": "rust", "repo": "kubo/rosy", "path": "/src/prelude.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>e when imported as-is into the same module. //! //! [rb]: string/struct.String.html //! [rs]: https://doc.rust-lang.org/std/string/struct.String.html // This should match the import in `lib.rs` verbatim (literally copy + paste) #[doc(no_inline)] pub use crate::{ array::Array, exception::{AnyExcep...
code_fim
hard
{ "lang": "rust", "repo": "kubo/rosy", "path": "/src/prelude.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut radiotap = Radiotap { header: iterator.header.clone(), ..Default::default() }; for result in &iterator { let (field_kind, data) = result?; match field_kind { Kind::TSFT => radiotap.tsft = from_bytes_some(data...
code_fim
hard
{ "lang": "rust", "repo": "Xudong-Huang/radiotap", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/tokio/src/util/slab/shard.rs use crate::util::slab::{page, Address, Entry, MAX_PAGES}; use std::fmt; // ┌─────────────┐ ┌────────┐ // │ page 1 │ │ │ // ├─────────────┤ ┌───▶│ next──┼─┐ // │ page 2 │ │ ├──────...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/tokio/src/util/slab/shard.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(super) fn alloc(&self) -> Option<Address> { // Can we fit the value into an existing page? for (page_idx, page) in self.shared.iter().enumerate() { let local = self.local(page_idx); if let Some(page_offset) = page.alloc(local) { return Some(...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/tokio/src/util/slab/shard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if page_idx > self.shared.len() { return None; } self.shared[page_idx].get(addr) } /// Remove an item on the shard's local thread. pub(super) fn remove_local(&self, addr: Address) { let page_idx = addr.page(); if let Some(page) = self.shar...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/tokio/src/util/slab/shard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl From<Mat3> for Similarity2<f32> { fn from(mat3: Mat3) -> Similarity2<f32> { crate::convert_unchecked(Matrix3::from(mat3)) } } impl From<Mat4> for Similarity3<f32> { fn from(mat4: Mat4) -> Similarity3<f32> { crate::convert_unchecked(Matrix4:...
code_fim
hard
{ "lang": "rust", "repo": "hopkings2008/nalgebra", "path": "/src/third_party/glam/glam_similarity.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the number of bits in `Self`. fn bit_len() -> usize { mem::size_of::<Self>() * 8 } /// Returns a `Self` instance constructed from an array of bytes. fn from_hash<T: AsRef<[u8]>>(hash: T) -> Self; } /// Converts a string into debug format of `????????...????????` w...
code_fim
hard
{ "lang": "rust", "repo": "madadam/xor-name", "path": "/src/xorable.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn cmp_distance() { assert_eq!(Ordering::Equal, 42u8.cmp_distance(&13, &13)); assert_eq!(Ordering::Less, 42u8.cmp_distance(&44, &45)); assert_eq!(Ordering::Greater, 42u8.cmp_distance(&45, &44)); } #[test] fn cmp_distance_array() { assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "madadam/xor-name", "path": "/src/xorable.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "[")?; for (idx, block) in self.blocks.iter().enumerate() { let block = block.to_block().map_err(|_| fmt::Error)?; if idx == 0 { write!(f, "{}", block)?; } else { write!(f, ",{}", block)?; } }...
code_fim
hard
{ "lang": "rust", "repo": "menski/foobar", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn header(&self) -> Result<protocol::Header> { Ok(protocol::HeaderBuilder::default().version(1).build()?) } pub fn run(&self) -> Result<()> { println!("{}", self.header()?); println!("["); loop { println!("{},", self); sleep(self.ref...
code_fim
hard
{ "lang": "rust", "repo": "menski/foobar", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn eval(&self, val: Value) -> Value { if val.borrow().computed { return val; } let mut curr = val.clone(); loop { let new = self.eval_core(curr.clone()); if Rc::ptr_eq(&new, &curr) { let value = new.borrow().val.cl...
code_fim
hard
{ "lang": "rust", "repo": "coffeecup-winner/icfpc2020", "path": "/src/eval.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn eval_core(&self, val: Value) -> Value { // println!("eval_value: {:?}", val); if val.borrow().computed { return val; } let value = val.borrow().val.clone(); match &value { Value_::Var(v) => self.vars.get(&v).unwrap().clone(), ...
code_fim
hard
{ "lang": "rust", "repo": "coffeecup-winner/icfpc2020", "path": "/src/eval.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn add_and_slot_device(&mut self, device: UsbDevice, port: UsbPort) { let span = span!(Level::TRACE, "fn add_and_slot_device", device = %device, port = %port); let _enter = span.enter(); self.add_port(port.clone()); self.add_device(device.clone()); for (i,...
code_fim
hard
{ "lang": "rust", "repo": "kbknapp/usbwatch-rs", "path": "/src/state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }