text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: shaneutt/lumen path: /compiler/term/src/encoding/arch_64_nanboxed.rs rchitectures used by the term ///! implementation. ///! ///! Currently, both 32-bit and 64-bit architectures rely on a minimum of 8 byte ///! alignment for all terms, as this provides 3 bits for a primary tag in the low ///! en...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/compiler/term/src/encoding/arch_64_nanboxed.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: public/googapis path: /googapis/genproto/google.cloud.oslogin.v1beta.rs ready().await.map_err(|e| { tonic::Status::new( tonic::Code::Unknown, format!("Service was not ready: {}", e.into()), ) })?; let...
code_fim
hard
{ "lang": "rust", "repo": "public/googapis", "path": "/googapis/genproto/google.cloud.oslogin.v1beta.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, request: tonic::Request<super::DeleteSshPublicKeyRequest>, ) -> Self::Future { let inner = self.0.clone(); let fut = async move { inner.delete_ssh_public_key(r...
code_fim
hard
{ "lang": "rust", "repo": "public/googapis", "path": "/googapis/genproto/google.cloud.oslogin.v1beta.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: public/googapis path: /googapis/genproto/google.cloud.oslogin.v1beta.rs } #[doc = " Adds an SSH public key and returns the profile information. Default POSIX"] #[doc = " account information is set when no username and UID exist as part of the"] #[doc = " login profile."] ...
code_fim
hard
{ "lang": "rust", "repo": "public/googapis", "path": "/googapis/genproto/google.cloud.oslogin.v1beta.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some((ref n, ref e)) = self.ether { let mut ethernets = Hash::new(); let mut eth = Hash::new(); match e { Ether::Static { address, gateway, dns1, dns2, ...
code_fim
hard
{ "lang": "rust", "repo": "saturn-xiv/peony", "path": "/src/sys/network/ubuntu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Interface { pub fn mac(&self) -> Result<String> { let name = if let Some((ref n, _)) = self.ether { Some(n) } else if let Some((ref n, _)) = self.wifi { Some(n) } else { None }; if let Some(name) = name { let ...
code_fim
hard
{ "lang": "rust", "repo": "saturn-xiv/peony", "path": "/src/sys/network/ubuntu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saturn-xiv/peony path: /src/sys/network/ubuntu.rs /// https://wiki.debian.org/NetworkConfiguration /// https://wiki.debian.org/WiFi/HowToUse /// http://jorisvr.nl/wpapsk.html /// http://manpages.ubuntu.com/manpages/disco/man5/wpa_supplicant.conf.5.html /// https://netplan.io/examples /// Detail...
code_fim
hard
{ "lang": "rust", "repo": "saturn-xiv/peony", "path": "/src/sys/network/ubuntu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: widojansen/rage path: /src/cli_common.rs //! Common helpers for CLI binaries. use dialoguer::PasswordInput; use rand::{ distributions::{Distribution, Uniform}, rngs::OsRng, }; use secrecy::{ExposeSecret, SecretString}; use std::fs::File; use std::io::{self, BufReader}; use std::path::Pa...
code_fim
hard
{ "lang": "rust", "repo": "widojansen/rage", "path": "/src/cli_common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Reads a secret from stdin. If `confirm.is_some()` then an empty secret is allowed. pub fn read_secret(prompt: &str, confirm: Option<&str>) -> io::Result<SecretString> { let mut input = PasswordInput::new(); input.with_prompt(prompt); if let Some(confirm_prompt) = confirm { input ...
code_fim
hard
{ "lang": "rust", "repo": "widojansen/rage", "path": "/src/cli_common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_origin_completions( &self, current_specifier: &str, range: &lsp::Range, ) -> Option<lsp::CompletionList> { let items = self .origins .keys() .filter_map(|k| { let mut origin = k.to_string(); if origin.ends_with('/') { origin.pop();...
code_fim
hard
{ "lang": "rust", "repo": "denoland/deno", "path": "/cli/lsp/registries.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn get_documentation( &self, url: &str, ) -> Option<lsp::Documentation> { let specifier = Url::parse(url).ok()?; let file = self .file_fetcher .fetch(&specifier, PermissionsContainer::allow_all()) .await .ok()?; serde_json::from_str(&file.source).o...
code_fim
hard
{ "lang": "rust", "repo": "denoland/deno", "path": "/cli/lsp/registries.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: denoland/deno path: /cli/lsp/registries.rs le@:version/:path*".to_string(), variables: vec![ RegistryConfigurationVariable { key: "module".to_string(), documentation: None, url: "https://api.deno.land/modules?short".to_string(), }, ...
code_fim
hard
{ "lang": "rust", "repo": "denoland/deno", "path": "/cli/lsp/registries.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let dst = array_mut_ref![dst, 0, Event::LEN]; let (is_initialized_dst, initializer_pubkey_dst, max_tickets_dst) = mut_array_refs![dst, 1, 32, 8]; let Event { is_initialized, initializer_pubkey, max_tickets, } = self; ...
code_fim
hard
{ "lang": "rust", "repo": "samuelvanderwaal/ticket_meister", "path": "/bpf_rust/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> is_initialized_dst[0] = *is_initialized as u8; initializer_pubkey_dst.copy_from_slice(initializer_pubkey.as_ref()); *max_tickets_dst = max_tickets.to_le_bytes(); } }<|fim_prefix|>// repo: samuelvanderwaal/ticket_meister path: /bpf_rust/src/state.rs use solana_program::{ pr...
code_fim
hard
{ "lang": "rust", "repo": "samuelvanderwaal/ticket_meister", "path": "/bpf_rust/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samuelvanderwaal/ticket_meister path: /bpf_rust/src/state.rs use solana_program::{ program_error::ProgramError, program_pack::{IsInitialized, Pack, Sealed}, pubkey::Pubkey, }; use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs}; pub struct Event { pub is_initia...
code_fim
hard
{ "lang": "rust", "repo": "samuelvanderwaal/ticket_meister", "path": "/bpf_rust/src/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tryone144/greetly path: /src/tui/components/form.rs // This file is part auf the greetly package. // // (c) 2020 Bernd Busse // // For the full copyright and license information, please view the README.md file // that was distributed with this source code. // use nix::sys::utsname::uname; use s...
code_fim
hard
{ "lang": "rust", "repo": "tryone144/greetly", "path": "/src/tui/components/form.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> KeyboardInput::<T>::cursor_start(match self.focus { FormElement::Prompt => &mut self.prompt_input, }); } fn cursor_end(&mut self) { KeyboardInput::<T>::cursor_end(match self.focus { FormElement::Prompt => &mut self.prompt_input, }); } } ...
code_fim
hard
{ "lang": "rust", "repo": "tryone144/greetly", "path": "/src/tui/components/form.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn cursor_start(&mut self) { KeyboardInput::<T>::cursor_start(match self.focus { FormElement::Prompt => &mut self.prompt_input, }); } fn cursor_end(&mut self) { KeyboardInput::<T>::cursor_end(match self.focus { FormElement::Prompt => &mut self.p...
code_fim
hard
{ "lang": "rust", "repo": "tryone144/greetly", "path": "/src/tui/components/form.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the number of days in the month represented by this date #[diplomat::rust_link(icu::calendar::Date::days_in_month, FnInStruct)] pub fn days_in_month(&self) -> u8 { self.0.date.days_in_month() } /// Returns the number of days in the year repr...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/icu_capi/src/datetime.rs", "mode": "spm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/icu_capi/src/datetime.rs DateTime object capable of containing a ISO-8601 date and time. #[diplomat::rust_link(icu::calendar::DateTime, Struct)] pub struct ICU4XIsoDateTime(pub DateTime<Iso>); impl ICU4XIsoDateTime { /// Creates a ne...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/icu_capi/src/datetime.rs", "mode": "psm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/icu_capi/src/datetime.rs e icu_calendar::types::Time; use icu_calendar::AnyCalendar; use icu_calendar::{DateTime, Iso}; use tinystr::TinyAsciiStr; use crate::calendar::ffi::ICU4XCalendar; use crate::date::ffi::{ICU4XDate, ICU4XIsoDat...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/icu_capi/src/datetime.rs", "mode": "psm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_suffix|> let assets = Value::from_bytes( Vec::from_hex("821a011cd498b82f581c4fd307695d244431ca93599be34d9aea403f24cf30f2eadcd7a178e2a1487377616e6b70696501581c50000001f7d74d2f95f82c4cfeb13f4119c350c2f91090fd69757fbda34f43617264616e6f526f6e696e313130014f43617264616e6f526f6e696e323732014f436172646...
code_fim
hard
{ "lang": "rust", "repo": "MartinSchere/cardano-serialization-lib", "path": "/rust/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match &self.multiasset { Some(multiasset) => { serializer.write_array(cbor_event::Len::Len(2))?; self.coin.serialize(serializer)?; multiasset.serialize(serializer) }, None => self.coin.serialize(serializer) ...
code_fim
hard
{ "lang": "rust", "repo": "MartinSchere/cardano-serialization-lib", "path": "/rust/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MartinSchere/cardano-serialization-lib path: /rust/src/utils.rs ); let assets = Value { coin: BigNum(1444443), multiasset: Some(token_bundle), }; assert_eq!( min_ada_required(&assets, &BigNum(MINIMUM_UTXO_VAL)).0, 1...
code_fim
hard
{ "lang": "rust", "repo": "MartinSchere/cardano-serialization-lib", "path": "/rust/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/mediaconvert/src/json_ser.rs bject.key("languageDescription").string(var_688); } Ok(()) } pub fn serialize_structure_crate_model_output_settings( object: &mut aws_smithy_json::serialize::JsonObjectWriter, input: &crate::model::OutputSettings, ) -...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/mediaconvert/src/json_ser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/mediaconvert/src/json_ser.rs object: &mut aws_smithy_json::serialize::JsonObjectWriter, input: &crate::model::AacSettings, ) -> Result<(), aws_smithy_http::operation::SerializationError> { if let Some(var_691) = &input.audio_description_broadcaster_mix...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/mediaconvert/src/json_ser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn serialize_structure_crate_model_timed_metadata_insertion( object: &mut aws_smithy_json::serialize::JsonObjectWriter, input: &crate::model::TimedMetadataInsertion, ) -> Result<(), aws_smithy_http::operation::SerializationError> { if let Some(var_255) = &input.id3_insertions { let...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/mediaconvert/src/json_ser.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fabura/icu4x path: /tools/datagen/src/bin/datagen.rs // This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use anyhow::Context; use clap::{App, Arg...
code_fim
hard
{ "lang": "rust", "repo": "fabura/icu4x", "path": "/tools/datagen/src/bin/datagen.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn get_blob_exporter(matches: &ArgMatches) -> anyhow::Result<BlobExporter<'static>> { if matches.value_of("SYNTAX") == Some("json") { anyhow::bail!("Cannot use --format=blob with --syntax=json"); } let output_path: Option<PathBuf> = if matches.is_present("OUTPUT_TESTDATA") { S...
code_fim
hard
{ "lang": "rust", "repo": "fabura/icu4x", "path": "/tools/datagen/src/bin/datagen.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simensgreen/bevy path: /crates/bevy_render/src/render_graph/command.rs use crate::{ renderer::{BufferId, RenderContext, TextureId}, texture::Extent3d, }; use parking_lot::Mutex; use std::sync::Arc; #[derive(Clone, Debug)] pub enum Command { CopyBufferToBuffer { source_buffer...
code_fim
hard
{ "lang": "rust", "repo": "simensgreen/bevy", "path": "/crates/bevy_render/src/render_graph/command.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> self.queue.lock().push(command); } pub fn copy_buffer_to_buffer( &mut self, source_buffer: BufferId, source_offset: u64, destination_buffer: BufferId, destination_offset: u64, size: u64, ) { self.push(Command::CopyBufferToBuffer ...
code_fim
hard
{ "lang": "rust", "repo": "simensgreen/bevy", "path": "/crates/bevy_render/src/render_graph/command.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub fn execute(&self, render_context: &mut dyn RenderContext) { for command in self.queue.lock().drain(..) { match command { Command::CopyBufferToBuffer { source_buffer, source_offset, destination_buffer, ...
code_fim
hard
{ "lang": "rust", "repo": "simensgreen/bevy", "path": "/crates/bevy_render/src/render_graph/command.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bnjjj/apollo-rs path: /crates/apollo-encoder/src/object_def.rs use std::fmt; use crate::Field; /// Object types represent concrete instantiations of sets of fields. /// /// The introspection types (e.g. `__Type`, `__Field`, etc) are examples of /// objects. /// /// *ObjectTypeDefinition*: /// ...
code_fim
hard
{ "lang": "rust", "repo": "bnjjj/apollo-rs", "path": "/crates/apollo-encoder/src/object_def.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut object_def = ObjectDef::new("PetStoreTrip".to_string()); object_def.field(field); object_def.description(Some("What to get at Fressnapf?".to_string())); assert_eq!( object_def.to_string(), indoc! { r#" """What to get at Fress...
code_fim
hard
{ "lang": "rust", "repo": "bnjjj/apollo-rs", "path": "/crates/apollo-encoder/src/object_def.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn new( stream: mio::net::TcpStream, direction: Direction, key: usize, ) -> std::io::Result<(Context, Handle)> { let reader_stream = stream.try_clone()?; let writer_stream = stream.try_clone()?; let addr = stream.peer_addr()?; let bufreader = std::io::BufReader::new(reader_...
code_fim
hard
{ "lang": "rust", "repo": "ShawnLi-25/Bitcoin-Client-Rust", "path": "/src/network/peer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ShawnLi-25/Bitcoin-Client-Rust path: /src/network/peer.rs use super::message; use log::{trace, warn}; use mio; use mio_extras::channel; use std::convert::TryInto; use std::io::{Read, Write}; use std::sync::mpsc; enum DecodeState { Length, Payload, } pub enum ReadResult { Continue, ...
code_fim
hard
{ "lang": "rust", "repo": "ShawnLi-25/Bitcoin-Client-Rust", "path": "/src/network/peer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nemo157/rustdoc-features-example path: /src/a.rs //! A public module that is always included in the crate. /// A public struct that is always included in the crate. #[cfg_attr(feature = "copy", derive(Copy))] pub struct A { /// A public field that is always included in the crate. pub a:...
code_fim
hard
{ "lang": "rust", "repo": "Nemo157/rustdoc-features-example", "path": "/src/a.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(all(feature = "foo", feature = "bar"))] /// A trait impl that is only included in the crate with features `foo` and `bar`. impl FooBarTrait for A { /// A trait method impl that is always included in the crate. /// (if the parent trait is) fn foo(&self) { } /// A trait method imp...
code_fim
hard
{ "lang": "rust", "repo": "Nemo157/rustdoc-features-example", "path": "/src/a.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> BasicBlock { name: "".to_string(), instructions: vec![], } } } impl BasicBlock {}<|fim_prefix|>// repo: i5possible/datum path: /dc_mir/src/basic_block.rs use crate::instruction::ExprKind; /// which is [basic block](https://en.wikipedia.org/wiki/Basic_block) #...
code_fim
easy
{ "lang": "rust", "repo": "i5possible/datum", "path": "/dc_mir/src/basic_block.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: i5possible/datum path: /dc_mir/src/basic_block.rs use crate::instruction::ExprKind; /// which is [basic block](https://en.wikipedia.org/wiki/Basic_block) #[derive(Clone, Debug)] pub struct BasicBlock { pub name: String, // todo: ConditionKind ? pub instructions: Vec<ExprKind>, } <...
code_fim
easy
{ "lang": "rust", "repo": "i5possible/datum", "path": "/dc_mir/src/basic_block.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koooge/leetcode path: /693/rust_693/src/lib.rs pub struct Solution {} impl Solution { pub fn has_alternating_bits(n: i32) -> bool { let bin = format!("{:b}", n); let mut ret = true; for i in 0..bin.len() { if bin.chars().nth(i) == bin.chars().nth(i+1) { ...
code_fim
medium
{ "lang": "rust", "repo": "koooge/leetcode", "path": "/693/rust_693/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Solution::has_alternating_bits(5), true); assert_eq!(Solution::has_alternating_bits(7), false); assert_eq!(Solution::has_alternating_bits(11), false); } }<|fim_prefix|>// repo: koooge/leetcode path: /693/rust_693/src/lib.rs pub struct Solution {} impl Solution { ...
code_fim
medium
{ "lang": "rust", "repo": "koooge/leetcode", "path": "/693/rust_693/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> env_logger::init().unwrap(); match env::var("GITHUB_TOKEN").ok() { Some(token) => { let client = Client::new(); let github = Github::new(format!("hubcaps/{}", env!("CARGO_PKG_VERSION")), &client, ...
code_fim
hard
{ "lang": "rust", "repo": "carols10cents/hubcaps", "path": "/examples/gists.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carols10cents/hubcaps path: /examples/gists.rs extern crate env_logger; extern crate hyper; extern crate hubcaps; use hyper::Client; use hubcaps::{Credentials, GistOptions, Github}; use std::collections::HashMap; use std::env; <|fim_suffix|> env_logger::init().unwrap(); match env::var("...
code_fim
hard
{ "lang": "rust", "repo": "carols10cents/hubcaps", "path": "/examples/gists.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Anthuang/issuers path: /src/config.rs use std::{env, fs}; use crate::repo::Repo; use color_eyre::eyre::Result; use toml::Value; /// Load repository information from the config file. pub fn get_repos_from_config() -> Result<Vec<Repo>> { let mut result_vec = Vec::new(); let home = env::v...
code_fim
hard
{ "lang": "rust", "repo": "Anthuang/issuers", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pect("Repo must exist in repo config") .to_string(), k.1["tag"] .as_str() .expect("Repo must exist in repo config") .to_string(), ); result_vec.push(repo); } Ok(result_vec) }<|fim_prefix|>// repo: Anthuang/...
code_fim
hard
{ "lang": "rust", "repo": "Anthuang/issuers", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: input-output-hk/jormungandr path: /testing/hersir/src/controller/interactive/args/explorer.rs use crate::controller::{Error, UserInteractionController}; use jormungandr_automation::jormungandr::explorer::configuration::ExplorerParams; use jortestkit::prelude::InteractiveCommandError; use structo...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/jormungandr", "path": "/testing/hersir/src/controller/interactive/args/explorer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Explorer { pub fn exec(&self, controller: &mut UserInteractionController) -> Result<(), Error> { match self { Explorer::Tip(tip) => tip.exec(controller), } } } #[derive(StructOpt, Debug)] pub struct ExplorerTip { #[structopt(short = "a", long = "alias")] p...
code_fim
medium
{ "lang": "rust", "repo": "input-output-hk/jormungandr", "path": "/testing/hersir/src/controller/interactive/args/explorer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: woshilapin/advent-calendar path: /2020/04_passeport-processing/src/main.rs use std::{ env, fs::File, io::{BufRead, BufReader}, }; type Year = usize; type Color = String; #[derive(Debug)] enum Unit { Centimeter, Inch, None, } impl std::default::Default for Unit { fn d...
code_fim
hard
{ "lang": "rust", "repo": "woshilapin/advent-calendar", "path": "/2020/04_passeport-processing/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn invalid_passeports() { let passeports = r#"eyr:1972 cid:100 hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926 iyr:2019 hcl:#602927 eyr:1967 hgt:170cm ecl:grn pid:012533040 byr:1946 hcl:dab227 iyr:2012 ecl:brn hgt:182cm pid:021572410 eyr:2020 byr:1992 cid:277 hgt:59cm ec...
code_fim
hard
{ "lang": "rust", "repo": "woshilapin/advent-calendar", "path": "/2020/04_passeport-processing/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>hgt:59cm ecl:zzz eyr:2038 hcl:74454a iyr:2023 pid:3556412378 byr:2007"#; let properties = Properties::new(passeports.split('\n').map(std::borrow::ToOwned::to_owned)); let passeports = Passeports::new(properties); assert_eq!(0, passeports.filter(Passeport::check).count()...
code_fim
hard
{ "lang": "rust", "repo": "woshilapin/advent-calendar", "path": "/2020/04_passeport-processing/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct HelloService { tx: Sender<String>, rx: Receiver<String> } impl HelloService { pub fn new(tx: Sender<String>, rx: Receiver<String>) -> Self { HelloService { tx, rx } } pub async fn start_listening(&self) { let rx_cloned = self.rx.clone(); ...
code_fim
hard
{ "lang": "rust", "repo": "wuminzhe/service-hub-example", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wuminzhe/service-hub-example path: /src/lib.rs use std::time::Duration; use flume::{Sender, Receiver}; #[macro_use] extern crate async_trait; struct AbcService { tx: Sender<String>, rx: Receiver<String> } impl AbcService { pub fn new(tx: Sender<String>, rx: Receiver<String>) -> Se...
code_fim
hard
{ "lang": "rust", "repo": "wuminzhe/service-hub-example", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in (0.. 100) { tx.send_async(format!("msg - {}", i)).await.unwrap(); async_std::task::sleep(Duration::from_secs(1)).await; } }<|fim_prefix|>// repo: wuminzhe/service-hub-example path: /src/lib.rs use std::time::Duration; use flume::{Sender, Receiver}; #[macro_use] extern cr...
code_fim
hard
{ "lang": "rust", "repo": "wuminzhe/service-hub-example", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Add new tiles let mut ent_list: Vec<Entity> = Vec::new(); for (z, layer) in room.map.layers.iter().enumerate() { if z == Layers::Monsters as usize { break; }; // Monster Layer, don't draw. for (x, row) in layer.tiles.iter().rev().enume...
code_fim
hard
{ "lang": "rust", "repo": "heinrichsmythe/realm.one", "path": "/src/systems/client/map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'s> System<'s> for MapSystem{ type SystemData = ( Read <'s, EventChannel<MapEvent>>, WriteStorage<'s, Transform>, WriteStorage<'s, SpriteRender>, WriteStorage<'s, TilePosition>, Write<'s, Room>, Read<'s, SpritesContainer>, Entities<'s>, ...
code_fim
hard
{ "lang": "rust", "repo": "heinrichsmythe/realm.one", "path": "/src/systems/client/map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heinrichsmythe/realm.one path: /src/systems/client/map.rs use amethyst::{ core::{SystemDesc, bundle::SystemBundle, Transform}, derive::SystemDesc, ecs::{Write, World, Read, System, SystemData, DispatcherBuilder, WriteStorage, Entity, Entities}, renderer::SpriteRender, shrev::...
code_fim
hard
{ "lang": "rust", "repo": "heinrichsmythe/realm.one", "path": "/src/systems/client/map.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: k0kubun/xremap path: /src/event_handler.rs MultiPurposeKeyState { held, alone, alone_timeout_at: Some(Instant::now() + alone_timeout), }, ); ...
code_fim
hard
{ "lang": "rust", "repo": "k0kubun/xremap", "path": "/src/event_handler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if value == PRESS { self.modifiers.insert(key); } else if value == RELEASE { self.modifiers.remove(&key); } } } fn is_remap(actions: &Vec<KeymapAction>) -> bool { actions.iter().all(|x| match x { KeymapAction::Remap(..) => true, _ =>...
code_fim
hard
{ "lang": "rust", "repo": "k0kubun/xremap", "path": "/src/event_handler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: k0kubun/xremap path: /src/event_handler.rs le RelativeEvent . // Mouse movement events need to be sent all at once because they would otherwise be separated by a synchronization event¹, // which the OS handles differently from two unseparated mouse moveme...
code_fim
hard
{ "lang": "rust", "repo": "k0kubun/xremap", "path": "/src/event_handler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Dead {}", self.simple_string()); } } fn main() { let mut u = User { name: "James".to_string(), age: 38, height: 90, admin: true, }; println!("User is {}", u.simple_string()); u.grow(20); println!("User is {}", u.simple_string()); ...
code_fim
medium
{ "lang": "rust", "repo": "alvarotolentino/learning_rust", "path": "/structs/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn grow(&mut self, h: i32) { self.height += h } fn die(self) { println!("Dead {}", self.simple_string()); } } fn main() { let mut u = User { name: "James".to_string(), age: 38, height: 90, admin: true, }; println!("User is {}",...
code_fim
medium
{ "lang": "rust", "repo": "alvarotolentino/learning_rust", "path": "/structs/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alvarotolentino/learning_rust path: /structs/src/main.rs #[derive(Debug)] struct User { name: String, age: i32, height: i32, admin: bool, } impl User { fn simple_string(&self) -> String { <|fim_suffix|> println!("Dead {}", self.simple_string()); } } fn main() { ...
code_fim
hard
{ "lang": "rust", "repo": "alvarotolentino/learning_rust", "path": "/structs/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexCouch/graviton path: /backend/src/vm/mod.rs k.pop() { if let Some(Value::Number(a)) = self.stack.pop() { self.stack.push(Value::Number(a / b)); } else { ret...
code_fim
hard
{ "lang": "rust", "repo": "AlexCouch/graviton", "path": "/backend/src/vm/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn var_in_scopes_mut( scope_stack: &'a mut Vec<Scope>, id: u16, ) -> Option<&'a mut (bool, Value)> { for s in scope_stack.iter_mut().rev() { match s.variables.get_mut(&id) { Some(var) => return Some(var), None => continue, ...
code_fim
hard
{ "lang": "rust", "repo": "AlexCouch/graviton", "path": "/backend/src/vm/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexCouch/graviton path: /backend/src/vm/mod.rs r::new( "Returns may only be present within blocks".to_string(), &ast, )); } ast::Ast::Block(exprs) => { bc.emit(&ast, ByteOp::ScopeOpen); let mut idx: usize = 1; ...
code_fim
hard
{ "lang": "rust", "repo": "AlexCouch/graviton", "path": "/backend/src/vm/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danshiovitz/adventofcode path: /2022/day24/src/main.rs use std::collections::{HashMap, HashSet}; extern crate common; use common::framework::{parse_grid, run_day, BaseDay, InputReader}; use common::grid::{four_neighbors, print_grid, Coord, Grid}; use common::solver::{cost_minimizing_bfs, Solve...
code_fim
hard
{ "lang": "rust", "repo": "danshiovitz/adventofcode", "path": "/2022/day24/src/main.rs", "mode": "psm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_suffix|>fn blizzard_ch(pos: &Coord, round: i32, map: &Map, fast: bool) -> char { // note the positions are 1..10, not 0..9, so we have to adjust when doing the mod let height = map.main_height as i32; let width = map.main_width as i32; let mut ch = '.'; let mut cnt = 0; if let Some(bs) = m...
code_fim
hard
{ "lang": "rust", "repo": "danshiovitz/adventofcode", "path": "/2022/day24/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", state); } fn print_path(&self, path: &Vec<State>) { for st in path { println!("Round {}", st.round); print_map(st, self); println!(); } } // returns a list of (cost, new state) pairs fn gen_possible_moves(&s...
code_fim
hard
{ "lang": "rust", "repo": "danshiovitz/adventofcode", "path": "/2022/day24/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dantepippi/bacup path: /src/config.rs use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::path::Path; use std::string::String; use std::fmt; use std::fs; use toml; #[derive(Serialize, Deserialize)] pub struct GitConfig { pub host: String, pub port: u16, pu...
code_fim
hard
{ "lang": "rust", "repo": "dantepippi/bacup", "path": "/src/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize)] pub struct Config { // remotes pub aws: Option<HashMap<String, AWSConfig>>, pub gcloud: Option<HashMap<String, GCloudConfig>>, pub ssh: Option<HashMap<String, SSHConfig>>, pub git: Option<HashMap<String, GitConfig>>, // services pub folders: Op...
code_fim
hard
{ "lang": "rust", "repo": "dantepippi/bacup", "path": "/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Error::Open(error) } } impl From<toml::de::Error> for Error { fn from(error: toml::de::Error) -> Self { Error::Parse(error) } } impl Config { pub fn new(path: &Path) -> Result<Config, Error> { let txt = fs::read_to_string(path)?; let config: Config = toml:...
code_fim
hard
{ "lang": "rust", "repo": "dantepippi/bacup", "path": "/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rusticata/pcap-analyzer path: /pcap-rewrite/src/pcap.rs use crate::traits::Writer; use libpcap_tools::Packet; use log::debug; use pcap_parser::ToVec; use pcap_parser::{LegacyPcapBlock, Linktype, PcapBlockOwned}; use std::io::{self, Error, ErrorKind, Write}; /// Writer for the legacy pcap format...
code_fim
hard
{ "lang": "rust", "repo": "rusticata/pcap-analyzer", "path": "/pcap-rewrite/src/pcap.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn write_block(&mut self, block: &PcapBlockOwned) -> Result<usize, io::Error> { match block { PcapBlockOwned::LegacyHeader(_) => Err(Error::new( ErrorKind::Other, "PcapWriter::write_block called twice for header", )), PcapBloc...
code_fim
hard
{ "lang": "rust", "repo": "rusticata/pcap-analyzer", "path": "/pcap-rewrite/src/pcap.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // hard-coding config name here to not rely on the crate we're building, if DEFAULT_CONFIG_NAME // ever changes, this will need to be updated let config_file = config_dir.join("ferox-config.toml"); if !config_file.exists() { // config file doesn't exist, add it to the config direc...
code_fim
hard
{ "lang": "rust", "repo": "shashankhacker730/feroxbuster", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shashankhacker730/feroxbuster path: /build.rs use std::fs::{copy, create_dir_all, OpenOptions}; use std::io::{Read, Seek, SeekFrom, Write}; extern crate clap; extern crate dirs; use clap::Shell; include!("src/parser.rs"); fn main() { println!("cargo:rerun-if-env-changed=src/parser.rs"); ...
code_fim
hard
{ "lang": "rust", "repo": "shashankhacker730/feroxbuster", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: happydpc/pretend_cad path: /src/components/mod.rs use amethyst::renderer::{debug_drawing::DebugLinesComponent, palette::Srgba}; use rand::prelude::*; use specs::prelude::*; use nalgebra::geometry::Point as nPoint; use crate::common::GenerationID; use crate::resources::Layer; use crate::resour...
code_fim
hard
{ "lang": "rust", "repo": "happydpc/pretend_cad", "path": "/src/components/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Component for Drawable { type Storage = VecStorage<Self>; } #[derive(Clone, Copy, Debug, PartialEq)] pub struct Point { pub x: f32, pub y: f32, } #[derive(Copy, Clone, Debug, PartialEq)] pub struct Line { start: Point, end: Point, layer: GenerationID<Layer>, color: Color...
code_fim
hard
{ "lang": "rust", "repo": "happydpc/pretend_cad", "path": "/src/components/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: museun/readchat2 path: /src/ui.rs use std::sync::atomic::{AtomicUsize, Ordering}; use cursive::{ direction::Orientation, traits::{Nameable, Scrollable, View}, view::{Margins, ScrollStrategy}, views::*, }; pub fn build_ui() -> impl View { fn list_view() -> BoxedView { ...
code_fim
hard
{ "lang": "rust", "repo": "museun/readchat2", "path": "/src/ui.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn next_unique_name() -> String { const PREFIX: &str = env!("CARGO_PKG_NAME"); thread_local! { static COUNTER: AtomicUsize = AtomicUsize::new(0); } let n = std::thread::LocalKey::with(&COUNTER, move |c| c.fetch_add(1, Ordering::SeqCst)); format!("{}_view_{}", PREFIX, n) } trait...
code_fim
hard
{ "lang": "rust", "repo": "museun/readchat2", "path": "/src/ui.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>mod main_screen; pub(crate) use main_screen::*; mod messages_view; pub use messages_view::MessagesView; mod links_view; pub(crate) use links_view::*; mod highlights_view; pub(crate) use highlights_view::*; mod tab_bar; pub(crate) use tab_bar::*; mod status_view; pub(crate) use status_view::*; mod li...
code_fim
hard
{ "lang": "rust", "repo": "museun/readchat2", "path": "/src/ui.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> /// Set BandScale for left axis. pub fn set_axis_left_band(mut self, scale: BandScale) -> Self { self.y_axis_left = Some(Axis::new( &scale, AxisPosition::Left, self.view_width(), self.view_height(), )); self } /// Set...
code_fim
hard
{ "lang": "rust", "repo": "limpidchart/lc-render", "path": "/src/chart.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: limpidchart/lc-render path: /src/chart.rs use crate::render::svg::*; use crate::shape::axis::{Axis, AxisPosition}; use crate::view::View; use crate::{BandScale, Error, LinearScale}; use std::path::Path; use svg::Node; const DEFAULT_MARGIN_TOP: i32 = 90; const DEFAULT_MARGIN_BOTTOM: i32 = 50; co...
code_fim
hard
{ "lang": "rust", "repo": "limpidchart/lc-render", "path": "/src/chart.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Set LinearScale for bottom axis. pub fn set_axis_bottom_linear(mut self, scale: LinearScale) -> Self { self.x_axis_bottom = Some(Axis::new( &scale, AxisPosition::Bottom, self.view_width(), self.view_height(), )); self ...
code_fim
hard
{ "lang": "rust", "repo": "limpidchart/lc-render", "path": "/src/chart.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> COLLECTOR_REGISTRATION_CHANNEL .0 .send(CollectorRegistrationMsg::Unregister { id: self.id }) .ok(); } }<|fim_prefix|>// repo: liyiheng/tikv path: /components/resource_metering/src/cpu/collector/linux.rs // Copyright 2021 TiKV Project Authors. Licensed unde...
code_fim
hard
{ "lang": "rust", "repo": "liyiheng/tikv", "path": "/components/resource_metering/src/cpu/collector/linux.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct CollectorHandle { id: CollectorId, } impl Drop for CollectorHandle { fn drop(&mut self) { COLLECTOR_REGISTRATION_CHANNEL .0 .send(CollectorRegistrationMsg::Unregister { id: self.id }) .ok(); } }<|fim_prefix|>// repo: liyiheng/tikv path: /...
code_fim
hard
{ "lang": "rust", "repo": "liyiheng/tikv", "path": "/components/resource_metering/src/cpu/collector/linux.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liyiheng/tikv path: /components/resource_metering/src/cpu/collector/linux.rs // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use crate::cpu::collector::{Collector, CollectorId}; use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering::Relaxed; use crossbeam::chann...
code_fim
hard
{ "lang": "rust", "repo": "liyiheng/tikv", "path": "/components/resource_metering/src/cpu/collector/linux.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LOFI/excertberk path: /src/main.rs extern crate ggez; use ggez::conf; use ggez::event; use ggez::{GameResult, Context}; use ggez::graphics; use ggez::graphics::{DrawMode, Point}; use std::time::Duration; const SPEED: f32 = 250.0; const SIZE: f32 = 50.0; struct InputState { up: bool, d...
code_fim
hard
{ "lang": "rust", "repo": "LOFI/excertberk", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let window = ctx.gfx_context.get_window(); let (width, height) = window.size(); let float_duration = dt.as_secs() as f64 + dt.subsec_nanos() as f64 * 1e-9; if self.input_state.up { let temp_up = self.y - (SPEED * float_duration as f32); if temp_up -...
code_fim
hard
{ "lang": "rust", "repo": "LOFI/excertberk", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ziwon/learning-rust path: /rust-lang-book/collections/src/main.rs fn main() { let v1: Vec<i32> = Vec::new(); let v2 = vec![1, 2, 3]; let mut v = Vec::new(); v.push(5); v.push(6); v.push(7); v.push(8); for i in &v { println!("{}", i) } { ...
code_fim
hard
{ "lang": "rust", "repo": "ziwon/learning-rust", "path": "/rust-lang-book/collections/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for b in "नमस्ते".bytes() { println!("{}", b); } use std::collections::HashMap; let mut scores = HashMap::new(); scores.insert(String::from("Blue"), 10); scores.insert(String::from("Yellow"), 50); println!("{:?}", scores); let teams = vec![String::from("Blue"), S...
code_fim
hard
{ "lang": "rust", "repo": "ziwon/learning-rust", "path": "/rust-lang-book/collections/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vincenthouyi/LakeOS path: /lib/rustyl4api/src/syscall.rs use core::arch::asm; use core::convert::{From, TryFrom}; use crate::error::{SysErrno, SysError, SysResult}; use crate::ipc::IpcMessageType; use num_traits::FromPrimitive; #[repr(C)] #[derive(Clone, Copy, Debug, Eq, PartialEq, FromPrimiti...
code_fim
hard
{ "lang": "rust", "repo": "vincenthouyi/LakeOS", "path": "/lib/rustyl4api/src/syscall.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// MsgInfo layout /// ----------------------------------------------- /// |type|msglen|C|R|B| errno | | /// | 2 | 4 |1|1|1| 6 | | /// ----------------------------------------------- /// C: Cap transfer /// R: Need Reply /// B: Badged /// impl From<RespInfo> for...
code_fim
hard
{ "lang": "rust", "repo": "vincenthouyi/LakeOS", "path": "/lib/rustyl4api/src/syscall.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub const fn new_fault_resp(length: usize, badge: bool) -> Self { Self { msgtype: IpcMessageType::Fault, msglen: length, cap_transfer: false, need_reply: true, badged: badge, errno: SysErrno::OK, } } pub c...
code_fim
hard
{ "lang": "rust", "repo": "vincenthouyi/LakeOS", "path": "/lib/rustyl4api/src/syscall.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Safe because the worst that can happen is memory gets leaked. /// /// Lifetime of the memory tied to the lifetime of the arena. fn alloc(&mut self, layout: Layout) -> Result<Mem<A>, Self::Error>; } impl<A> Alloc<A> for ! { type Error = !; fn alloc(&mut self, _: Layout) -> Res...
code_fim
medium
{ "lang": "rust", "repo": "gianlucamazza/proofmarshal", "path": "/proofmarshal-core/src/ptr/mem.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gianlucamazza/proofmarshal path: /proofmarshal-core/src/ptr/mem.rs /// In-memory arena pub trait Arena { /// Default allocator. type Allocator : Alloc<Self>; <|fim_suffix|> /// Safe because the worst that can happen is memory gets leaked. /// /// Lifetime of the memory tied t...
code_fim
medium
{ "lang": "rust", "repo": "gianlucamazza/proofmarshal", "path": "/proofmarshal-core/src/ptr/mem.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} impl<A> Alloc<A> for ! { type Error = !; fn alloc(&mut self, _: Layout) -> Result<Mem<A>, Self::Error> { match *self {} } }<|fim_prefix|>// repo: gianlucamazza/proofmarshal path: /proofmarshal-core/src/ptr/mem.rs /// In-memory arena pub trait Arena { /// Default allocator. ...
code_fim
hard
{ "lang": "rust", "repo": "gianlucamazza/proofmarshal", "path": "/proofmarshal-core/src/ptr/mem.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anglerud/sysinfo path: /tests/process.rs // // Sysinfo // // Copyright (c) 2018 Guillaume Gomez // use sysinfo::ProcessExt; use sysinfo::SystemExt; #[test] fn test_process() { let mut s = sysinfo::System::new(); assert_eq!(s.processes().len(), 0); s.refresh_processes(); if !sys...
code_fim
hard
{ "lang": "rust", "repo": "anglerud/sysinfo", "path": "/tests/process.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(p) = p { assert_eq!(p.pid(), pid); // FIXME: instead of ignoring the test on CI, try to find out what's wrong... if std::env::var("APPLE_CI").is_err() { assert!(p.environ().iter().any(|e| e == "FOO=BAR")); assert!(p.environ().iter().any(|e| e...
code_fim
hard
{ "lang": "rust", "repo": "anglerud/sysinfo", "path": "/tests/process.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut system = inner(); let mut p = system .process(get_current_pid().expect("Failed retrieving current pid.")) .expect("failed to get process"); if cfg!(any(target_os = "macos", target_os = "ios")) && p.disk_usage().total_written_bytes == 0 { // For whatever rea...
code_fim
hard
{ "lang": "rust", "repo": "anglerud/sysinfo", "path": "/tests/process.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }