text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: emseibert/RustCompletion path: /rust_src/libarena/lib.rs y arena uses arrays is really deeply awful. The arrays are // allocated, and have capacities reserved, but the fill for the array // will always stay at 0. #[deriving(Clone, Eq)] struct Chunk { data: Rc<RefCell<Vec<u8> >>, fill: Ce...
code_fim
hard
{ "lang": "rust", "repo": "emseibert/RustCompletion", "path": "/rust_src/libarena/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let this: *TypedArenaChunk<T> = self; unsafe { cast::transmute(round_up(this.offset(1) as uint, mem::min_align_of::<T>())) } } // Returns a pointer to the end of the allocated space. #[inline] fn end(&self) -> *u8 { unsafe { let size...
code_fim
hard
{ "lang": "rust", "repo": "emseibert/RustCompletion", "path": "/rust_src/libarena/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emseibert/RustCompletion path: /rust_src/libarena/lib.rs c, get_tydesc}; use std::intrinsics; // The way arena uses arrays is really deeply awful. The arrays are // allocated, and have capacities reserved, but the fill for the array // will always stay at 0. #[deriving(Clone, Eq)] struct Chunk ...
code_fim
hard
{ "lang": "rust", "repo": "emseibert/RustCompletion", "path": "/rust_src/libarena/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wjsassi/rose-tools path: /rose-lib/src/files/zon.rs //! ROSE Online Zone use std::convert::TryFrom; use std::io::SeekFrom; use std::iter; use failure::Error; use serde::{Deserialize, Serialize}; use crate::io::{ReadRoseExt, RoseFile, WriteRoseExt}; use crate::utils::{Vector2, Vector3}; /// Zo...
code_fim
hard
{ "lang": "rust", "repo": "wjsassi/rose-tools", "path": "/rose-lib/src/files/zon.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn write<W: WriteRoseExt>(&mut self, _writer: &mut W) -> Result<(), Error> { unimplemented!(); } } /// Zone Type #[derive(Debug, Serialize, Deserialize, PartialEq)] pub enum ZoneType { Grass = 0, Mountain = 1, MountainVillage = 2, BoatVillage = 3, ...
code_fim
hard
{ "lang": "rust", "repo": "wjsassi/rose-tools", "path": "/rose-lib/src/files/zon.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match value { 0 => Ok(ZoneBlockType::BasicInfo), 1 => Ok(ZoneBlockType::EventPoints), 2 => Ok(ZoneBlockType::Textures), 3 => Ok(ZoneBlockType::Tiles), 4 => Ok(ZoneBlockType::Economy), _ => { bail!("Invalid Zone...
code_fim
hard
{ "lang": "rust", "repo": "wjsassi/rose-tools", "path": "/rose-lib/src/files/zon.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vedangj044/drogue-cloud path: /websocket-integration/src/main.rs mod auth; mod messages; mod route; mod service; mod wshandler; use dotenv::dotenv; use actix::Actor; use actix_web::{web, App, HttpServer}; use drogue_cloud_service_common::{ config::ConfigFromEnv, health::HealthServer, open...
code_fim
hard
{ "lang": "rust", "repo": "vedangj044/drogue-cloud", "path": "/websocket-integration/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> log::info!("Starting WebSocket integration service endpoint"); log::info!("Authentication enabled: {}", enable_auth); log::info!("Kafka servers: {}", config.kafka.bootstrap_servers); // set up security let (authenticator, user_auth) = if enable_auth { let client = reqwest::Cl...
code_fim
hard
{ "lang": "rust", "repo": "vedangj044/drogue-cloud", "path": "/websocket-integration/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iovxw/pixiu path: /src/token.rs use std::time::{Duration, Instant}; use rand::{self, Rng}; pub struct UnverifiedTokenCache { timeout: Duration, cache: Vec<UnverifiedToken>, } impl UnverifiedTokenCache { pub fn new(timeout: Duration) -> UnverifiedTokenCache { UnverifiedToke...
code_fim
hard
{ "lang": "rust", "repo": "iovxw/pixiu", "path": "/src/token.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>impl UnverifiedToken { fn new(user: u64, username: String) -> UnverifiedToken { UnverifiedToken { created: Instant::now(), user: user, username: username, value: rand::thread_rng().gen(), } } } impl ::std::ops::Deref for UnverifiedTo...
code_fim
hard
{ "lang": "rust", "repo": "iovxw/pixiu", "path": "/src/token.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gcapell/aoc2019 path: /aoc15/src/main.rs mod interpreter; mod prog; <|fim_suffix|> let mut i = interpreter::new_channel(prog::PROG); i.send(1); i.send(1); i.send(1); i.send(1); i.send(1); i.send(1); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "gcapell/aoc2019", "path": "/aoc15/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut i = interpreter::new_channel(prog::PROG); i.send(1); i.send(1); i.send(1); i.send(1); i.send(1); i.send(1); }<|fim_prefix|>// repo: gcapell/aoc2019 path: /aoc15/src/main.rs mod interpreter; mod prog; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "gcapell/aoc2019", "path": "/aoc15/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>byond_fn!(fn redis_connect_rq(addr) { connect(addr).err().map(|e| e.to_string()) }); byond_fn!( fn redis_disconnect_rq() { disconnect(); Some("") } ); byond_fn!(fn redis_lpush(key, elements) { #[allow(clippy::needless_return)] return match serde_json::from_str(element...
code_fim
hard
{ "lang": "rust", "repo": "tigercat2000/rust-g", "path": "/src/redis_reliablequeue.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tigercat2000/rust-g path: /src/redis_reliablequeue.rs use redis::{Client, Commands, RedisError}; use std::cell::RefCell; use std::num::NonZeroUsize; use std::time::Duration; thread_local! { static REDIS_CLIENT: RefCell<Option<Client>> = RefCell::new(None); } fn connect(addr: &str) -> Resul...
code_fim
hard
{ "lang": "rust", "repo": "tigercat2000/rust-g", "path": "/src/redis_reliablequeue.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hppRC/RustAtCoder path: /abc167/src/bin/d.rs #![allow(non_snake_case)] use competitive_hpp::prelude::*; #[fastout] fn main() { input! { N: usize, mut K: usize, A: [Usize1; N], } let mut visited = vec![false; N]; let mut from = 0; let mut to_cycle = 0; le...
code_fim
medium
{ "lang": "rust", "repo": "hppRC/RustAtCoder", "path": "/abc167/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut cycle_size = 0; let cycle_start = from; for _ in 0..K { cycle_size += 1; from = A[from]; if from == cycle_start { break; } } K -= to_cycle; K %= cycle_size; for _ in 0..K { from = A[from]; } println!("{}", ...
code_fim
medium
{ "lang": "rust", "repo": "hppRC/RustAtCoder", "path": "/abc167/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<EK, ER> ProposalRouter<EK::Snapshot> for VioletaBftRouter<EK, ER> where EK: CausetEngine, ER: VioletaBftEngine, { #[inline] fn lightlike( &self, cmd: VioletaBftCommand<EK::Snapshot>, ) -> std::result::Result<(), TrylightlikeError<VioletaBftCommand<EK::Snapshot>>> {...
code_fim
hard
{ "lang": "rust", "repo": "whtcorpsinc/einsteindb-prod", "path": "/violetabftstore/src/store/transport.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<EK, ER> StoreRouter<EK> for VioletaBftRouter<EK, ER> where EK: CausetEngine, ER: VioletaBftEngine, { #[inline] fn lightlike(&self, msg: StoreMsg<EK>) -> Result<()> { match self.lightlike_control(msg) { Ok(()) => Ok(()), Err(TrylightlikeError::Full(_)) =...
code_fim
hard
{ "lang": "rust", "repo": "whtcorpsinc/einsteindb-prod", "path": "/violetabftstore/src/store/transport.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whtcorpsinc/einsteindb-prod path: /violetabftstore/src/store/transport.rs // Copyright 2020 WHTCORPS INC. Licensed under Apache-2.0. use crate::store::{CasualMessage, PeerMsg, VioletaBftCommand, VioletaBftRouter, StoreMsg}; use crate::{DiscardReason, Error, Result}; use crossbeam::TrylightlikeE...
code_fim
hard
{ "lang": "rust", "repo": "whtcorpsinc/einsteindb-prod", "path": "/violetabftstore/src/store/transport.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: firecracker-microvm/firecracker path: /src/vmm/src/cpuid/template/intel/t2.rs // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use kvm_bindings::{kvm_cpuid_entry2, CpuId}; use crate::cpuid::bit_helper::BitHelper; use crate::cpuid...
code_fim
hard
{ "lang": "rust", "repo": "firecracker-microvm/firecracker", "path": "/src/vmm/src/cpuid/template/intel/t2.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn update_extended_feature_info_entry( entry: &mut kvm_cpuid_entry2, _vm_spec: &VmSpec, ) -> Result<(), Error> { use crate::cpuid::cpu_leaf::leaf_0x80000001::*; entry .ecx .write_bit(ecx::PREFETCH_BITINDEX, false) .write_bit(ecx::MWAIT_EXTENDED_BITINDEX,...
code_fim
hard
{ "lang": "rust", "repo": "firecracker-microvm/firecracker", "path": "/src/vmm/src/cpuid/template/intel/t2.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn write_to(&self, buf: &mut Vec<u8>) { buf.extend(&self.name.to_le_bytes()); buf.extend(&self.info.to_le_bytes()); buf.extend(&self.other.to_le_bytes()); buf.extend(&self.section_index.to_le_bytes()); buf.extend(&self.value.to_le_bytes()); buf.exten...
code_fim
hard
{ "lang": "rust", "repo": "project-ela/elfen", "path": "/src/symbol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: project-ela/elfen path: /src/symbol.rs pub mod binding; pub mod index_typ; pub mod typ; pub mod visibility; use crate::*; #[repr(C)] #[derive(Default, Copy, Clone, Debug, PartialEq, Eq)] pub struct Symbol { pub name: ElfWord, pub info: u8, pub other: u8, pub section_index: ElfS...
code_fim
hard
{ "lang": "rust", "repo": "project-ela/elfen", "path": "/src/symbol.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_visibility(&self) -> Visibility { Visibility::from(self.other) } pub fn set_visibility(&mut self, visibility: Visibility) { let byte: u8 = visibility.into(); self.other |= byte; } pub fn get_index_type(&self) -> IndexType { IndexType::from(s...
code_fim
hard
{ "lang": "rust", "repo": "project-ela/elfen", "path": "/src/symbol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonathanKingston/self-development path: /languages/Rust/csp/src/tokenizer.rs //use std::borrow::Cow; const TOKEN: &'static str = ";"; const SPACE: &'static str = " "; #[derive(Debug, PartialEq)] pub struct TokenizerToken<'h> { token_str: &'h str } impl<'a> TokenizerToken <'a> { fn new...
code_fim
hard
{ "lang": "rust", "repo": "jonathanKingston/self-development", "path": "/languages/Rust/csp/src/tokenizer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Tokenizer; impl Tokenizer { fn get_tokens(policy: &str) -> TokenizerDirectives { let mut output: TokenizerDirectives = TokenizerDirectives::new(); let policy_tokens: Vec<&str> = policy.split(TOKEN).collect(); for part in policy_tokens { let mut p = Toke...
code_fim
hard
{ "lang": "rust", "repo": "jonathanKingston/self-development", "path": "/languages/Rust/csp/src/tokenizer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xcpu/herocrab path: /src/windows/analysis.rs xt, GetCurrentThread}; use winapi::um::minwinbase::EXCEPTION_BREAKPOINT; use winapi::um::sysinfoapi::{GetSystemInfo, SYSTEM_INFO}; use winapi::um::memoryapi::{VirtualAlloc, VirtualFree, VirtualProtect}; use winapi::vc::excpt::{EXCEPTION_CONTINUE_SEAR...
code_fim
hard
{ "lang": "rust", "repo": "0xcpu/herocrab", "path": "/src/windows/analysis.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn does_thread_hide_fail() -> Result<bool, DWORD> { let nt_status: NTSTATUS = unsafe { NtSetInformationThread( GetCurrentThread(), ThreadHideFromDebugger, NULL as *mut _, 0) }; if nt_status == STATUS_SUCCESS { let mut is_thre...
code_fim
hard
{ "lang": "rust", "repo": "0xcpu/herocrab", "path": "/src/windows/analysis.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xcpu/herocrab path: /src/windows/analysis.rs VirtualFree, VirtualProtect}; use winapi::vc::excpt::{EXCEPTION_CONTINUE_SEARCH, EXCEPTION_CONTINUE_EXECUTION}; use winapi::um::psapi::{GetModuleInformation, MODULEINFO}; use winapi::um::libloaderapi::{LoadLibraryW, GetProcAddress}; use ntapi::{ ...
code_fim
hard
{ "lang": "rust", "repo": "0xcpu/herocrab", "path": "/src/windows/analysis.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sifton/dyon path: /src/intrinsics/meta.rs use std::sync::Arc; use std::io::{self, Read}; use std::fs::File; use std::error::Error; use piston_meta::*; use Variable; fn io_error(action: &str, file: &str, err: &io::Error) -> String { format!("IO Error when attempting to {} `{}`: {}\n{}", act...
code_fim
hard
{ "lang": "rust", "repo": "sifton/dyon", "path": "/src/intrinsics/meta.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Loads an url using a meta file as syntax. pub fn load_meta_url(meta: &str, url: &str) -> Result<Vec<Variable>, String> { let mut syntax_file = try!(File::open(meta).map_err(|err| io_error("open", meta, &err))); let mut s = String::new(); try!(syntax_file.read_to_string(&mut s).map_err(|err...
code_fim
hard
{ "lang": "rust", "repo": "sifton/dyon", "path": "/src/intrinsics/meta.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: divvun/pahkat-client-sdk-swift path: /crate/pahkat-types/src/payload/mod.rs pub mod macos; pub mod tarball; pub mod windows; use std::collections::BTreeSet; use std::convert::TryFrom; use std::str::FromStr; use crate::DependencyMap; use serde::{Deserialize, Serialize}; use typed_builder::Typed...
code_fim
hard
{ "lang": "rust", "repo": "divvun/pahkat-client-sdk-swift", "path": "/crate/pahkat-types/src/payload/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl TryFrom<Payload> for windows::Executable { type Error = Payload; fn try_from(value: Payload) -> Result<Self, Self::Error> { match value { Payload::WindowsExecutable(v) => Ok(v), x => Err(x), } } } impl<'a> TryFrom<&'a Payload> for &'a windows::Exe...
code_fim
hard
{ "lang": "rust", "repo": "divvun/pahkat-client-sdk-swift", "path": "/crate/pahkat-types/src/payload/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn try_from(value: Payload) -> Result<Self, Self::Error> { match value { Payload::MacOSPackage(v) => Ok(v), x => Err(x), } } } impl<'a> TryFrom<&'a Payload> for &'a macos::Package { type Error = &'a Payload; fn try_from(value: &'a Payload) -> Resul...
code_fim
hard
{ "lang": "rust", "repo": "divvun/pahkat-client-sdk-swift", "path": "/crate/pahkat-types/src/payload/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>& mut tmp ) 3 ) ; assert_eq ! ( tmp [ 0 . . 3 ] [ 0 1 2 ] ) ; assert_eq ! ( prod0 . push_slice ( & [ 3 4 5 ] ) 3 ) ; match cons0 . write_into ( & mut prod1 None ) { Ok ( n ) = > assert_eq ! ( n 2 ) other = > panic ! ( " { : ? } " other ) } assert_eq ! ( cons1 . pop_slice ( & mut tmp ) 2 ) ; assert_eq ! ( ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/ringbuf/src/tests/read_write.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>let buf1 = RingBuffer : : < u8 > : : new ( 4 ) ; let ( mut prod0 mut cons0 ) = buf0 . split ( ) ; let ( mut prod1 mut cons1 ) = buf1 . split ( ) ; let mut tmp = [ 0 ; 5 ] ; assert_eq ! ( prod0 . push_slice ( & [ 0 1 2 3 ] ) 4 ) ; match prod1 . read_from ( & mut cons0 Some ( 3 ) ) { Ok ( n ) = > assert_eq ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/ringbuf/src/tests/read_write.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/ringbuf/src/tests/read_write.rs use std : : io ; use crate : : RingBuffer ; # [ test ] fn from ( ) { let buf0 = RingBuffer : : < u8 > : : new ( 4 ) ; let buf1 = RingBuffer : : < u8 > : : new ( 4 ) ; let ( mut prod0 mut cons0 ) = buf0 . split ( ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/ringbuf/src/tests/read_write.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs // compile-flags: -Ztrait-solver=next // check-pass // (should not pass, should be turned into a coherence-only test) <|fim_suffix|>impl Foo<u16, i8> for () { type Assoc = u8; } impl Foo<u16, ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn incomplete<T>() where (): Foo<u16, T>, { // `<() as Foo<u16, STOP>>::Assoc == <() as Foo<_, STOP>>::Assoc` let _: <() as Foo<u16, T>>::Assoc = output::<_, T>(); // let _: <() as Foo<u16, T>>::Assoc = output::<u8, T>(); // OK // let _: <() as Foo<u16, T>>::Assoc = output::<u16, T>()...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // let _: <() as Foo<u16, T>>::Assoc = output::<u8, T>(); // OK // let _: <() as Foo<u16, T>>::Assoc = output::<u16, T>(); // OK } fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs // compile-flags: -Ztrait-solver=...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hboutou/rust-redis-playground path: /src/main.rs #![allow(unused)] use std::{error::Error, time::Duration}; use tokio::time::sleep; use redis::{ from_redis_value, streams::{StreamRangeReply, StreamReadOptions, StreamReadReply}, AsyncCommands, Client, }; #[tokio::main] pub async fn...
code_fim
medium
{ "lang": "rust", "repo": "hboutou/rust-redis-playground", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 4) xrevrange the read stream let result : Option<StreamRangeReply> = con.xrevrange_count( "my-stream", "+", "-", 10 ).await?; if let Some(reply) = result { for stream_id in reply.ids { println!("xrevrang stream message {}", stream_id....
code_fim
hard
{ "lang": "rust", "repo": "hboutou/rust-redis-playground", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> "" } fn type_info() -> Type { Type::Primitive(Primitive::U32) } } #[allow(unused)] struct A<T> { a: B<T, bool>, b: B<B<T, T>, bool>, } impl<T> TypeInfo for A<T> where T: TypeInfo + 'static { fn path() -> &'static str { "A" } fn params() -> Vec<Me...
code_fim
hard
{ "lang": "rust", "repo": "Robbepop/scale-info-generics", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl TypeInfo for bool { fn path() -> &'static str { "" } fn type_info() -> Type { Type::Primitive(Primitive::Bool) } } impl TypeInfo for u32 { fn path() -> &'static str { "" } fn type_info() -> Type { Type::Primitive(Primitive::U32) } ...
code_fim
hard
{ "lang": "rust", "repo": "Robbepop/scale-info-generics", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Robbepop/scale-info-generics path: /src/main.rs pub fn of<T>() -> Self where T: 'static + ?Sized + TypeInfo { MetaType::Concrete(MetaTypeConcrete::new::<T>()) } pub fn parameter<T, P>(name: &'static str) -> Self where ...
code_fim
hard
{ "lang": "rust", "repo": "Robbepop/scale-info-generics", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>d `TDINIT1`"] pub struct TDINIT1_W<'a> { w: &'a mut W, } impl<'a> TDINIT1_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !(0xff << 19)) | (((value as u32) & 0xff) << 19); sel...
code_fim
hard
{ "lang": "rust", "repo": "Yatekii/stm32mp1-pac", "path": "/src/ddrphyc/ddrphyc_ptr1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fff) as u32) } #[doc = "Bits 19:26 - TDINIT1"] #[inline(always)] pub fn tdinit1(&self) -> TDINIT1_R { TDINIT1_R::new(((self.bits >> 19) & 0xff) as u8) } } impl W { #[doc = "Bits 0:18 - TDINIT0"] #[inline(always)] pub fn tdinit0(&mut self) -> TDINIT0_W { TDIN...
code_fim
hard
{ "lang": "rust", "repo": "Yatekii/stm32mp1-pac", "path": "/src/ddrphyc/ddrphyc_ptr1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yatekii/stm32mp1-pac path: /src/ddrphyc/ddrphyc_ptr1.rs #[doc = "Reader of register DDRPHYC_PTR1"] pub type R = crate::R<u32, super::DDRPHYC_PTR1>; #[doc = "Writer for register DDRPHYC_PTR1"] pub type W = crate::W<u32, super::DDRPHYC_PTR1>; #[doc = "Register DDRPHYC_PTR1 `reset()`'s with value 0...
code_fim
hard
{ "lang": "rust", "repo": "Yatekii/stm32mp1-pac", "path": "/src/ddrphyc/ddrphyc_ptr1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Queryable, Serialize, Deserialize, Debug)] pub struct Member { pub id: i32, pub name: String, } #[derive(Insertable, Deserialize, Debug, PartialEq)] #[table_name = "members"] pub struct NewMember { pub name: String, }<|fim_prefix|>// repo: bobcats/mob path: /server/src/models.rs use...
code_fim
medium
{ "lang": "rust", "repo": "bobcats/mob", "path": "/server/src/models.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bobcats/mob path: /server/src/models.rs use schema::*; #[derive(Queryable, Serialize, Debug)] pub struct Team { pub id: i32, pub driver_id: i32, pub time: f64, } <|fim_suffix|>#[derive(Queryable, Serialize, Deserialize, Debug)] pub struct Member { pub id: i32, pub name: Str...
code_fim
medium
{ "lang": "rust", "repo": "bobcats/mob", "path": "/server/src/models.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PSeitz/tantivy path: /src/fieldnorm/reader.rs use std::sync::Arc; use super::{fieldnorm_to_id, id_to_fieldnorm}; use crate::directory::{CompositeFile, FileSlice, OwnedBytes}; use crate::schema::Field; use crate::space_usage::PerFieldSpaceUsage; use crate::DocId; /// Reader for the fieldnorm (f...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/tantivy", "path": "/src/fieldnorm/reader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> FieldNormReader(reader_enum) } } #[derive(Clone)] enum ReaderImplEnum { FromData(OwnedBytes), Const { num_docs: u32, fieldnorm_id: u8, fieldnorm: u32, }, } impl FieldNormReader { /// Creates a `FieldNormReader` with a constant fieldnorm. /// //...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/tantivy", "path": "/src/fieldnorm/reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the number of documents in this segment. pub fn num_docs(&self) -> u32 { match &self.0 { ReaderImplEnum::FromData(data) => data.len() as u32, ReaderImplEnum::Const { num_docs, .. } => *num_docs, } } /// Returns the `fieldnorm` associated...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/tantivy", "path": "/src/fieldnorm/reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input_file = File::open("input.txt").unwrap(); let tape = load_tape(input_file); println!("Part 1:"); execute_intcode(&tape, &mut StdInput, &mut StdOutput); }<|fim_prefix|>// repo: RoBaaaT/advent-of-code-2019 path: /day5/main.rs use std::fs::File; use intcode::*; <|fim_middle|>fn ma...
code_fim
easy
{ "lang": "rust", "repo": "RoBaaaT/advent-of-code-2019", "path": "/day5/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RoBaaaT/advent-of-code-2019 path: /day5/main.rs use std::fs::File; use intcode::*; <|fim_suffix|> let input_file = File::open("input.txt").unwrap(); let tape = load_tape(input_file); println!("Part 1:"); execute_intcode(&tape, &mut StdInput, &mut StdOutput); }<|fim_middle|>fn ma...
code_fim
easy
{ "lang": "rust", "repo": "RoBaaaT/advent-of-code-2019", "path": "/day5/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wotsushi/competitive-programming path: /arc/090/c.rs #![allow(non_snake_case)] #![allow(unused_variables)] #![allow(dead_code)] fn main() { <|fim_suffix|> let (_, ans) = (1..N).fold( (A[0][0], A[0][0] + A[1][0]), |(u, d), i| (u + A[0][i], std::cmp::max(u + A[0][i], d) + A[1][...
code_fim
hard
{ "lang": "rust", "repo": "wotsushi/competitive-programming", "path": "/arc/090/c.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (_, ans) = (1..N).fold( (A[0][0], A[0][0] + A[1][0]), |(u, d), i| (u + A[0][i], std::cmp::max(u + A[0][i], d) + A[1][i]) ); println!("{}", ans); }<|fim_prefix|>// repo: wotsushi/competitive-programming path: /arc/090/c.rs #![allow(non_snake_case)] #![allow(unused_variable...
code_fim
hard
{ "lang": "rust", "repo": "wotsushi/competitive-programming", "path": "/arc/090/c.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if config.debug { index.printsizes(); } let debug = config.debug; let (tx_req, mut rx_req) = mpsc::channel::<MarkovRequestMessage>(100); let _responder = tokio::spawn(async move { while let Some(work) = rx_req.recv().await { let (req, tx_resp): MarkovReque...
code_fim
hard
{ "lang": "rust", "repo": "jgdavey/fake", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(port) = config.port { // POST / {"seed": "Sean", "target": 20} let endpoint = warp::post() .and(warp::body::json()) .and(warp::any().map(move || tx_req.clone())) .and_then(respond) .and_then(to_json); if config.debug ...
code_fim
hard
{ "lang": "rust", "repo": "jgdavey/fake", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgdavey/fake path: /src/main.rs use std::convert::Infallible; use std::io::prelude::*; use std::io::{self, BufRead, Error, ErrorKind}; use std::path::PathBuf; use serde::{Deserialize, Serialize}; use structopt::StructOpt; use tokio::sync::mpsc; use warp::Filter; mod markov; fn read_line(promp...
code_fim
hard
{ "lang": "rust", "repo": "jgdavey/fake", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let addr = (LOCAL_IP, LOCAL_PORT).to_socket_addrs()?.next().unwrap(); let socket = UdpSocket::bind(addr)?; println!("listen on: {}", socket.local_addr().unwrap()); let mut buf = [0u8; 1024]; loop { match socket.recv_from(&mut buf) { Ok((size, addr)) => { ...
code_fim
medium
{ "lang": "rust", "repo": "rcore-os/arceos", "path": "/apps/net/udpserver/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcore-os/arceos path: /apps/net/udpserver/src/main.rs #![cfg_attr(feature = "axstd", no_std)] #![cfg_attr(feature = "axstd", no_main)] #[macro_use] #[cfg(feature = "axstd")] extern crate axstd as std; <|fim_suffix|> let addr = (LOCAL_IP, LOCAL_PORT).to_socket_addrs()?.next().unwrap(); l...
code_fim
medium
{ "lang": "rust", "repo": "rcore-os/arceos", "path": "/apps/net/udpserver/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn receive_loop() -> io::Result<()> { let addr = (LOCAL_IP, LOCAL_PORT).to_socket_addrs()?.next().unwrap(); let socket = UdpSocket::bind(addr)?; println!("listen on: {}", socket.local_addr().unwrap()); let mut buf = [0u8; 1024]; loop { match socket.recv_from(&mut buf) { ...
code_fim
medium
{ "lang": "rust", "repo": "rcore-os/arceos", "path": "/apps/net/udpserver/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn fst_top_sort(ptr: *mut CFst) -> RUSTFST_FFI_RESULT { wrap(|| { let fst = get_mut!(CFst, ptr); let vec_fst = as_mut_fst!(VectorFst<TropicalWeight>, fst); top_sort(vec_fst)?; Ok(()) }) }<|fim_prefix|>// repo: Garvys/rustfst path: /rustf...
code_fim
medium
{ "lang": "rust", "repo": "Garvys/rustfst", "path": "/rustfst-ffi/src/algorithms/top_sort.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Garvys/rustfst path: /rustfst-ffi/src/algorithms/top_sort.rs use anyhow::anyhow; use crate::fst::as_mut_fst; use crate::fst::CFst; use crate::{get_mut, wrap, RUSTFST_FFI_RESULT}; <|fim_suffix|>#[no_mangle] pub extern "C" fn fst_top_sort(ptr: *mut CFst) -> RUSTFST_FFI_RESULT { wrap(|| { ...
code_fim
medium
{ "lang": "rust", "repo": "Garvys/rustfst", "path": "/rustfst-ffi/src/algorithms/top_sort.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ixre/jsa path: /src/http/console/mod.rs use std::collections::HashMap; use std::io::Read; use rocket::data::FromData; use rocket::data::Outcome; use rocket::data::Transform; use rocket::data::Transformed; use rocket::http::Status; use rocket::outcome::Outcome::Failure; use rocket::outcome::Outc...
code_fim
hard
{ "lang": "rust", "repo": "ixre/jsa", "path": "/src/http/console/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut stream = data.open().take(NAME_LIMIT); let mut string = String::with_capacity((NAME_LIMIT / 2) as usize); let outcome = match stream.read_to_string(&mut string) { Ok(_) => Success(string), Err(_e) => Failure((Status::InternalServerError, ())), ...
code_fim
hard
{ "lang": "rust", "repo": "ixre/jsa", "path": "/src/http/console/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if std::ptr::null() == rect { panic!("lollib_backend BackendPixelRect not correctly initialized!"); } Self { rect } } pub fn get_hight(&self) -> u32 { unsafe { lollib_backend_pixelRect_getHight(self.rect) } } pub fn get_width(&self) -> u32 { ...
code_fim
hard
{ "lang": "rust", "repo": "kgrzywocz/league_of_steel", "path": "/game-lib/backend/interface/src/backend.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kgrzywocz/league_of_steel path: /game-lib/backend/interface/src/backend.rs use crate::bindings::*; pub struct AnalyzerHolder<'a> { pub pixel_rect_analyzer: &'a mut dyn PixelRectAnalyzer, } pub trait PixelRectAnalyzer { fn analyze_function(&mut self, rect: &PixelRect); } pub struct Bac...
code_fim
hard
{ "lang": "rust", "repo": "kgrzywocz/league_of_steel", "path": "/game-lib/backend/interface/src/backend.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nxnfufunezn/vsop87-rs path: /src/vsop87a/mod.rs and the ecliptic plane as reference ```z = 0```. /// /// # Examples /// /// ``` /// use vsop87::vsop87a; /// /// let (x, y, z) = vsop87a::mercury(2415020.0); /// /// assert!(x > -0.3897246932 && x < -0.3897246930); /// assert!(y > -0.1502242200 &&...
code_fim
hard
{ "lang": "rust", "repo": "nxnfufunezn/vsop87-rs", "path": "/src/vsop87a/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let x = x0 + x1 * t + x2 * t * t + x3 * t.powi(3) + x4 * t.powi(4) + x5 * t.powi(5); let y = y0 + y1 * t + y2 * t * t + y3 * t.powi(3) + y4 * t.powi(4) + y5 * t.powi(5); let z = z0 + z1 * t + z2 * t * t + z3 * t.powi(3) + z4 * t.powi(4); (x, y, z) } /// Calculates VSOP87A solution for Ur...
code_fim
hard
{ "lang": "rust", "repo": "nxnfufunezn/vsop87-rs", "path": "/src/vsop87a/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let z0 = calculate_var(t, &saturn::Z0); let z1 = calculate_var(t, &saturn::Z1); let z2 = calculate_var(t, &saturn::Z2); let z3 = calculate_var(t, &saturn::Z3); let z4 = calculate_var(t, &saturn::Z4); let x = x0 + x1 * t + x2 * t * t + x3 * t.powi(3) + x4 * t.powi(4) + x5 * t.powi(...
code_fim
hard
{ "lang": "rust", "repo": "nxnfufunezn/vsop87-rs", "path": "/src/vsop87a/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kristofvdj88/IOTA-SmartContracts-HelloWorld-Rust path: /iota_sc_utils/src/params.rs use wasmlib::*; // -------------------------------------------------------------------------------------------------------------------- // // Feel free to add any functions related to params here. Don't forget ...
code_fim
hard
{ "lang": "rust", "repo": "kristofvdj88/IOTA-SmartContracts-HelloWorld-Rust", "path": "/iota_sc_utils/src/params.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Tries to get i64 parameter. Returns empty &str if it can't find it. pub fn get_i64<TContext : ScBaseContext>(param_name : &str, ctx: &TContext) -> i64 { let param = ctx.params().get_int(param_name); if param.exists() { return param.value(); } return 0; }<|fim_prefix|>// repo: ...
code_fim
hard
{ "lang": "rust", "repo": "kristofvdj88/IOTA-SmartContracts-HelloWorld-Rust", "path": "/iota_sc_utils/src/params.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /types/src/api_error.rs alizing. EarlyEndOfStream, /// Formatting error while deserializing. Formatting, /// Not all input bytes were consumed in [`deserialize`](crate::bytesrepr::deserialize). LeftOverBytes, /// Out of memory erro...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/types/src/api_error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { ApiError::User(value) => write!(f, "User error: {}", value), ApiError::ContractHeader(value) => write!(f, "Contract header error: {}", value), ApiError::Mint(value) => write!(f, "Mint error: {}", value), ApiError::HandlePayment(value) =>...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/types/src/api_error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match value { 1 => ApiError::None, 2 => ApiError::MissingArgument, 3 => ApiError::InvalidArgument, 4 => ApiError::Deserialize, 5 => ApiError::Read, 6 => ApiError::ValueNotFound, 7 => ApiError::ContractNotFound, ...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/types/src/api_error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>-#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd"))] +#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "solaris", target_os = "illumos"))] extern "C" { pub(crate) fn sigsetjmp( env: *mut crate::sigjmp_buf, savemask:...
code_fim
hard
{ "lang": "rust", "repo": "NetBSD/pkgsrc", "path": "/databases/postgresql-promscale_extension/patches/patch-pgx_pgx-pg-sys_src_submodules_mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NetBSD/pkgsrc path: /databases/postgresql-promscale_extension/patches/patch-pgx_pgx-pg-sys_src_submodules_mod.rs $NetBSD: patch-pgx_pgx-pg-sys_src_submodules_mod.rs,v 1.6 2023/01/11 03:33:46 tnn Exp $ NetBSD, SunOS support <|fim_suffix|>-#[cfg(any(target_os = "macos", target_os = "freebsd", ta...
code_fim
hard
{ "lang": "rust", "repo": "NetBSD/pkgsrc", "path": "/databases/postgresql-promscale_extension/patches/patch-pgx_pgx-pg-sys_src_submodules_mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let progress_fut = async move { let pb = ProgressBar::new(total_len); let mut cur_len = 0; while cur_len < total_len { if let Some(delta) = rx.try_next()? { pb.inc(delta as u64); cur_len += delta as u64; } } ...
code_fim
hard
{ "lang": "rust", "repo": "drozdziak1/progress-download", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drozdziak1/progress-download path: /src/main.rs use futures::{ channel::mpsc, stream::{StreamExt, TryStreamExt}, }; use indicatif::ProgressBar; use async_std::sync::{Arc, Mutex}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let resp = reqwest:...
code_fim
medium
{ "lang": "rust", "repo": "drozdziak1/progress-download", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let t: Vec<_> = (0..100) .into_iter() .map(|i| { spawn(move || { let v: Vec<_> = (0..100) .into_iter() .map(|_| spawn(move || STR_POOL.intern(i.to_string(), Arc::from))) ...
code_fim
hard
{ "lang": "rust", "repo": "volight/pstr", "path": "/src/pool.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_same() { let h1 = STR_POOL.intern("asd", Arc::from); let h2 = STR_POOL.intern("asd", Arc::from); assert_eq!(h1, h2); assert_eq!(h1.get(), "asd"); assert_eq!(h2.get(), "asd"); } #[test] fn test_not_same() { let h1 = STR_PO...
code_fim
hard
{ "lang": "rust", "repo": "volight/pstr", "path": "/src/pool.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: volight/pstr path: /src/pool.rs //! The Intern Pool use std::{ borrow::Borrow, ffi::OsStr, hash::Hash, ops::Deref, sync::{Arc, RwLock}, }; use dashmap::DashSet; use once_cell::sync::Lazy; /// The String Intern Pool pub static STR_POOL: Lazy<Pool<str>> = Lazy::new(|| Po...
code_fim
hard
{ "lang": "rust", "repo": "volight/pstr", "path": "/src/pool.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tayspen72/msp432p401r-pac path: /src/dio/pads.rs #[doc = "Register `PADS` reader"] pub struct R(crate::R<PADS_SPEC>); impl core::ops::Deref for R { type Target = crate::R<PADS_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<PADS_...
code_fim
hard
{ "lang": "rust", "repo": "tayspen72/msp432p401r-pac", "path": "/src/dio/pads.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `P1DS` reader - Port 1 Drive Strength"] pub struct P1DS_R(crate::FieldReader<u8, u8>); impl P1DS_R { pub(crate) fn new(bits: u8) -> Self { P1DS_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for P1DS_R { type Target = crate::FieldRea...
code_fim
hard
{ "lang": "rust", "repo": "tayspen72/msp432p401r-pac", "path": "/src/dio/pads.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Solution { pub fn di_string_match(s: String) -> Vec<i32> { let mut result: Vec<i32> = vec![0; s.len() + 1]; let mut left = 0; let mut right = s.len() as i32; for (i, ch) in s.chars().enumerate() { match ch { 'I' => { ...
code_fim
medium
{ "lang": "rust", "repo": "accierro/leetcode-solutions", "path": "/easy/string/DI_string_matc/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: accierro/leetcode-solutions path: /easy/string/DI_string_matc/src/main.rs // Given a string S that only contains "I" (increase) or "D" (decrease), let N = S.length. // Return any permutation A of [0, 1, ..., N] such that for all i = 0, ..., N-1: <|fim_suffix|>// Note: // 1 <= S.length <= 1000...
code_fim
hard
{ "lang": "rust", "repo": "accierro/leetcode-solutions", "path": "/easy/string/DI_string_matc/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sarsko/CreuSAT path: /tests/test_parser.rs use std::fs::read_dir; use sat::parser::parse_cnf; <|fim_suffix|> let mut paths = read_dir("tests/cnf/sat").unwrap(); for path in paths { let tmp = path.unwrap().path(); let path = tmp.to_str().unwrap(); let _res = parse...
code_fim
easy
{ "lang": "rust", "repo": "sarsko/CreuSAT", "path": "/tests/test_parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut paths = read_dir("tests/cnf/sat").unwrap(); for path in paths { let tmp = path.unwrap().path(); let path = tmp.to_str().unwrap(); let _res = parse_cnf(path); } paths = read_dir("tests/cnf/unsat").unwrap(); for path in paths { let tmp = path.unwra...
code_fim
easy
{ "lang": "rust", "repo": "sarsko/CreuSAT", "path": "/tests/test_parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //trim: removes unwanted spaces. { let my_string = String::from(" My name is Muk "); println!("After trim",my_string.trim()) } //chars { let my_string = String::from("The weather is nice"); match my_string.chars().nth(4){ Some(c) => p...
code_fim
hard
{ "lang": "rust", "repo": "MukundhBhushan/rust-tots", "path": "/strings/moreonstrings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MukundhBhushan/rust-tots path: /strings/moreonstrings.rs fn main(){ //replace { //represents code block not needed everytime let my_string = String::from("Rust is fantastic"); println!("After replace {}",my_string.replace("fantastic", "great")); } <|fim_suffix|> /...
code_fim
hard
{ "lang": "rust", "repo": "MukundhBhushan/rust-tots", "path": "/strings/moreonstrings.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //chars { let my_string = String::from("The weather is nice"); match my_string.chars().nth(4){ Some(c) => println!("{}",c), None => println!("No char at index") } } //slice { let my_string = String::from("Mukundh"); let s...
code_fim
medium
{ "lang": "rust", "repo": "MukundhBhushan/rust-tots", "path": "/strings/moreonstrings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // repeatedly encode this many bytes bencher.bytes = bytes.len() as u64; bencher.iter(|| { bytes = vec![]; unsafe { encode(&record, &mut bytes).unwrap(); } unsafe { decode::<T>(&mut bytes) }.is_some() }); } fn _bench_cln<T: Abomonation+Clone>(bencher: &mut Bencher,...
code_fim
medium
{ "lang": "rust", "repo": "erdos-project/abomonation", "path": "/benches/clone.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erdos-project/abomonation path: /benches/clone.rs #![feature(test)] extern crate abomonation; extern crate test; use abomonation::*; use test::Bencher; #[bench] fn empty_e_d(bencher: &mut Bencher) { _bench_e_d(bencher, vec![(); 1024]); } #[bench] fn empty_cln(bencher: &mut Bencher) { _bench_c...
code_fim
medium
{ "lang": "rust", "repo": "erdos-project/abomonation", "path": "/benches/clone.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xumarcus/othello_multimcts path: /src/board/mod.rs mod r#impl; mod display; mod fromiterator; mod fromstr; mod internals; pub mod moves; use crate::*; use std::fmt; use std::iter::{FromIterator, IntoIterator, Iterator, ExactSizeIterator}; use std::str::FromStr; #[derive(Clone, Copy, Debug, De...
code_fim
medium
{ "lang": "rust", "repo": "xumarcus/othello_multimcts", "path": "/src/board/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[getset(get = "pub")] side: Side, #[derivative(Default(value = "Moves(0x0000_1020_0408_0000)"))] #[getset(get = "pub")] moves: Moves, }<|fim_prefix|>// repo: xumarcus/othello_multimcts path: /src/board/mod.rs mod r#impl; mod display; mod fromiterator; mod fromstr; mod internals; pub...
code_fim
hard
{ "lang": "rust", "repo": "xumarcus/othello_multimcts", "path": "/src/board/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[derivative(Default(value = "0x0000_0010_0800_0000"))] #[getset(get = "pub with_prefix")] // wasm_bindgen op: u64, #[getset(get = "pub")] side: Side, #[derivative(Default(value = "Moves(0x0000_1020_0408_0000)"))] #[getset(get = "pub")] moves: Moves, }<|fim_prefix|>// rep...
code_fim
hard
{ "lang": "rust", "repo": "xumarcus/othello_multimcts", "path": "/src/board/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (idx, &elem) in vec.iter().rev().enumerate() { assert_eq!(elem, neg_vec[-(idx as i32 + 1)]); } } #[test] fn test_positive_indices() { let vec = test_vector(); let neg_vec = NegIdxVec::<u32>::from(vec.clone()); for (idx, &elem) in vec.it...
code_fim
hard
{ "lang": "rust", "repo": "afnanenayet/diffsitter", "path": "/src/neg_idx_vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: afnanenayet/diffsitter path: /src/neg_idx_vec.rs //! Negative index vector //! //! A Python-style negative index vector. use std::ops::{Index, IndexMut}; /// A vector that can be indexed with a negative index, like with Python. /// /// ```rust /// use libdiffsitter::neg_idx_vec::NegIdxVec; ///...
code_fim
hard
{ "lang": "rust", "repo": "afnanenayet/diffsitter", "path": "/src/neg_idx_vec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }