text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: creativcoder/forest path: /ipld/hamt/src/pointer.rs // Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT use super::node::Node; use super::{Error, Hash, HashAlgorithm, KeyValuePair, MAX_ARRAY_WIDTH}; use cid::Cid; use once_cell::unsync::OnceCell; use serde::de::Deseri...
code_fim
hard
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/ipld/hamt/src/pointer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<K, V, H> Default for Pointer<K, V, H> { fn default() -> Self { Pointer::Values(Vec::new()) } } impl<K, V, H> Pointer<K, V, H> where K: Serialize + DeserializeOwned + Hash + PartialOrd, V: Serialize + DeserializeOwned, H: HashAlgorithm, { pub(crate) fn from_key_value(k...
code_fim
hard
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/ipld/hamt/src/pointer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<K, V, H> Pointer<K, V, H> where K: Serialize + DeserializeOwned + Hash + PartialOrd, V: Serialize + DeserializeOwned, H: HashAlgorithm, { pub(crate) fn from_key_value(key: K, value: V) -> Self { Pointer::Values(vec![KeyValuePair::new(key, value)]) } /// Internal metho...
code_fim
hard
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/ipld/hamt/src/pointer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linkerd/linkerd2-proxy path: /linkerd/app/src/env.rs inbound::Config { allow_discovery: dst_profile_suffixes.into_iter().collect(), proxy: ProxyConfig { server, connect, max_in_flight_requests: inbound_max_in_flight? ...
code_fim
hard
{ "lang": "rust", "repo": "linkerd/linkerd2-proxy", "path": "/linkerd/app/src/env.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linkerd/linkerd2-proxy path: /linkerd/app/src/env.rs trings, ENV_INBOUND_PORTS_DISABLE_PROTOCOL_DETECTION, parse_port_range_set, )? // If the `INBOUND_PORTS_DISABLE_PROTOCOL_DETECTION` environment // variable is not set, then th...
code_fim
hard
{ "lang": "rust", "repo": "linkerd/linkerd2-proxy", "path": "/linkerd/app/src/env.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let cap = re.captures(s).ok_or(ParseError::NotADuration)?; let magnitude = parse_number(&cap[1])?; match cap.get(2).map(|m| m.as_str()) { None if magnitude == 0 => Ok(Duration::from_secs(0)), Some("ms") => Ok(Duration::from_millis(magnitude)), Some("s") => Ok(Duration:...
code_fim
hard
{ "lang": "rust", "repo": "linkerd/linkerd2-proxy", "path": "/linkerd/app/src/env.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: enarx/enarx path: /src/backend/kvm/builder.rs // SPDX-License-Identifier: Apache-2.0 use super::config::Config; use super::mem::Region; use super::KvmKeepPersonality; use std::convert::TryFrom; use std::mem::align_of; use std::sync::{Arc, RwLock}; use anyhow::{Context, Error, Result}; use kvm...
code_fim
hard
{ "lang": "rust", "repo": "enarx/enarx", "path": "/src/backend/kvm/builder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn kvm_builder_map( block_size: usize, sallyports: &mut Vec<Option<VirtAddr>>, vm_fd: &mut VmFd, pages: &mut Map<perms::ReadWrite>, to: usize, with: u32, slot: u32, ) -> anyhow::Result<kvm_userspace_memory_region> { if with & SALLYPORT != 0 { for start in (0..pa...
code_fim
hard
{ "lang": "rust", "repo": "enarx/enarx", "path": "/src/backend/kvm/builder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uu1t-sandbox/piyokvs path: /src/entry.rs use std::ptr::NonNull; pub trait Lazy { fn init(&mut self); } #[derive(Debug, PartialEq)] pub enum State<K> { Uninitialized, Unloaded, Fresh, Dirty, Stale(K), } #[derive(Debug)] pub struct Entry<K, V> { pub key: K, pub v...
code_fim
hard
{ "lang": "rust", "repo": "uu1t-sandbox/piyokvs", "path": "/src/entry.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self.state { State::Fresh | State::Dirty => {} _ => panic!("invalid state"), } self.state = State::Dirty; &mut self.value } } impl<K, V> Default for Entry<K, V> where K: Default, V: Default, { fn default() -> Entry<K, V> { ...
code_fim
hard
{ "lang": "rust", "repo": "uu1t-sandbox/piyokvs", "path": "/src/entry.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shota-f/proc_macro_demos path: /simple_attr/src/lib.rs extern crate proc_macro; use proc_macro::TokenStream; use quote::quote; use syn::parse_macro_input; use syn::{ Expr, ItemFn }; <|fim_suffix|> println!("Hello by attr"); #( #fn_body )* println!("By...
code_fim
hard
{ "lang": "rust", "repo": "shota-f/proc_macro_demos", "path": "/simple_attr/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[proc_macro_attribute] pub fn add_messages_2(attr: TokenStream, input: TokenStream) -> TokenStream { let expr = parse_macro_input!( attr as Expr ); let message = if let Expr::Lit(lit) = expr { lit } else { panic!("") }; let ast = parse_macro_input!( input as ItemFn );...
code_fim
medium
{ "lang": "rust", "repo": "shota-f/proc_macro_demos", "path": "/simple_attr/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *self & *rhs == 0 } #[inline] fn bit_subset(&self, rhs: &Self) -> bool { *self | *rhs == *rhs } #[inline] fn bit_superset(&self, rhs: &Self) -> bool { *self | *rhs == *self } #[inline] fn bit_or(&mut self, rhs: &Self) -> &mut Self { *self |= *rhs; self } ...
code_fim
hard
{ "lang": "rust", "repo": "CasualX/bitset-core", "path": "/src/uint.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> *self &= *rhs; self } #[inline] fn bit_andnot(&mut self, rhs: &Self) -> &mut Self { *self &= !*rhs; self } #[inline] fn bit_xor(&mut self, rhs: &Self) -> &mut Self { *self ^= *rhs; self } #[inline] fn bit_not(&mut self) -> &mut Self { *self = !*self; ...
code_fim
hard
{ "lang": "rust", "repo": "CasualX/bitset-core", "path": "/src/uint.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CasualX/bitset-core path: /src/uint.rs use super::BitSet; macro_rules! impl_bit_set_uint { ($ty:ty, $bits_per_word:literal) => { impl BitSet for $ty { #[inline] fn bit_len(&self) -> usize { $bits_per_word } #[inline] fn bit_init(&mut self, value: bool) -> &mut Self { *...
code_fim
hard
{ "lang": "rust", "repo": "CasualX/bitset-core", "path": "/src/uint.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Technolution/rustig path: /lib/panic_analysis/src/patterns/message_panic.rs // (C) COPYRIGHT 2018 TECHNOLUTION BV, GOUDA NL // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource...
code_fim
hard
{ "lang": "rust", "repo": "Technolution/rustig", "path": "/lib/panic_analysis/src/patterns/message_panic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let finder = MessagePatternFinder { message_pattern_mapping, }; let panic_collection = PanicCallsCollection { calls: vec![ PanicCall { backtrace: Vec::new(), pattern: RefCell::new(Unrecognized), ...
code_fim
hard
{ "lang": "rust", "repo": "Technolution/rustig", "path": "/lib/panic_analysis/src/patterns/message_panic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn clear_background(&self) { let gl = &self.webrender_gl; self.assert_gl_framebuffer_complete(); // Make framebuffer fully transparent. gl.clear_color(0.0, 0.0, 0.0, 0.0); gl.clear(gl::COLOR_BUFFER_BIT); self.assert_gl_framebuffer_complete(); /...
code_fim
hard
{ "lang": "rust", "repo": "Hankszhang/surfman-webrender-demo", "path": "/src/compositor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hankszhang/surfman-webrender-demo path: /src/compositor.rs use gleam::gl; use webrender::Renderer; use webrender::api::{ RenderApi, Transaction, FontInstanceKey, DocumentId, PipelineId, DisplayListBuilder, Epoch, units::LayoutSize }; use euclid::Scale; use crate::{ webrender_surfman...
code_fim
hard
{ "lang": "rust", "repo": "Hankszhang/surfman-webrender-demo", "path": "/src/compositor.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>'a mut W { self.variant(ERR_CODEW::TRUNCATED_EOP) } #[doc = "Sent/Received NAK"] #[inline] pub fn sent_received_nak(self) -> &'a mut W { self.variant(ERR_CODEW::SENT_RECEIVED_NAK) } #[doc = "Sent Stall"] #[inline] pub fn sent_stall(self) -> &'a mut W { ...
code_fim
hard
{ "lang": "rust", "repo": "ax-rwnd/rust-lpc1347", "path": "/src/usb/info/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ax-rwnd/rust-lpc1347 path: /src/usb/info/mod.rs #[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::INFO { #[doc = r" Modifies the contents of the register"] #[inline] pub fn...
code_fim
hard
{ "lang": "rust", "repo": "ax-rwnd/rust-lpc1347", "path": "/src/usb/info/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> event_loop.run(move |event, _, control_flow| { *control_flow = ControlFlow::Poll; // `ControlFlow::Wait` if only re-render on event match event { Event::WindowEvent { event, window_id } if window_id == window.id() => { match event { ...
code_fim
hard
{ "lang": "rust", "repo": "michaeljclark/piet-gpu", "path": "/piet-gpu/bin/winit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michaeljclark/piet-gpu path: /piet-gpu/bin/winit.rs use piet_gpu_hal::{Error, ImageLayout, Instance, Session, SubmittedCmdBuf}; use piet_gpu::{render_scene, PietGpuRenderContext, Renderer, HEIGHT, WIDTH}; use winit::{ event::{Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, ...
code_fim
hard
{ "lang": "rust", "repo": "michaeljclark/piet-gpu", "path": "/piet-gpu/bin/winit.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_decode_name_value_pair_41() { let mut block = Bytes::from_static(&[0x80u8,0,0,3, 3, 1,2,3, 6,5,4]); let (name, value, b) = decode_name_value_pair(block); assert_eq!(name, Bytes::from_static(&[1,2,3])); assert_eq!(value, Bytes::from_static(&[6,5,4])); } #[test] fn test_deco...
code_fim
hard
{ "lang": "rust", "repo": "fluffware/helvar_cgi", "path": "/src/fast_cgi/decode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fluffware/helvar_cgi path: /src/fast_cgi/decode.rs use bytes::Bytes; use bytes::Buf; use std::convert::TryInto; /// Read name-value pair /// Returns (name,value,remaining) pub fn decode_name_value_pair(mut block: Bytes) -> (Bytes, Bytes, Bytes) { let name_lengt...
code_fim
hard
{ "lang": "rust", "repo": "fluffware/helvar_cgi", "path": "/src/fast_cgi/decode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/gull path: /gull/src/generator.rs use anyhow::{Context, Result}; use colored::Colorize; use std::fs; use std::path::Path; pub fn write_generated<F>( absolute_path: &Path, new_source: &str, postprocess: Option<F>, ) -> Result<()> where F: FnOnce() -> Result<()>, { pri...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/gull", "path": "/gull/src/generator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if left == right { return None; } let lines = lines(left, right); result.push('\n'); for line in lines { match line { Result::Left(l) => { result.push_str(&format!("{} {}\n", "-".red(), &l.red())); } Result::Right(r) ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/gull", "path": "/gull/src/generator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fs::write(absolute_path, new_source)?; println!( "{} {}", "[WRITTEN]".yellow(), absolute_path.display().to_string().cyan() ); if let Some(postprocess) = postprocess { postprocess().context("Failed on postprocess step")?; } let postprocessed_new_so...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/gull", "path": "/gull/src/generator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WizKid/zwaver path: /src/serial/message/dataframe/response/serial_api_get_capabilities_response.rs use bitvec::prelude::*; use bytes::{ Bytes, Buf, BytesMut, BufMut }; #[derive(Debug, PartialEq, Clone)] pub struct SerialAPIGetCapabilitiesResponse { pub api_version_major: u8, pub a...
code_fim
hard
{ "lang": "rust", "repo": "WizKid/zwaver", "path": "/src/serial/message/dataframe/response/serial_api_get_capabilities_response.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn decode(src: &mut Bytes) -> SerialAPIGetCapabilitiesResponse { let api_version_major = src.get_u8(); let api_version_minor = src.get_u8(); let manufacturer_id = src.get_u16(); let product_type = src.get_u16(); let product_id = src.get_u16(); ...
code_fim
hard
{ "lang": "rust", "repo": "WizKid/zwaver", "path": "/src/serial/message/dataframe/response/serial_api_get_capabilities_response.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/export-fully-qualified.rs // In this test baz isn't resolved when called as foo.baz even though // it's called from inside foo. This is somewhat surprising and may // want to change eventually. <|fim_suffix|> fn baz() { } } fn main() { }<|f...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/export-fully-qualified.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn baz() { } } fn main() { }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/export-fully-qualified.rs // In this test baz isn't resolved when called as foo.baz even though // it's called from inside foo. This is somewhat surprising and may // want to change eventually. <|f...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/export-fully-qualified.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattswoon/eileen path: /src/main.rs pub mod agent; pub mod model; pub mod errors; pub mod change; use std::{ collections::HashMap, time::Instant }; use crate::{ agent::{Person, InfectionStatus}, model::{ Model, // step } }; <|fim_suffix|> let now = Insta...
code_fim
medium
{ "lang": "rust", "repo": "mattswoon/eileen", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> model.run(100).unwrap(); println!("Main completed in {}s", now.elapsed().as_secs()); }<|fim_prefix|>// repo: mattswoon/eileen path: /src/main.rs pub mod agent; pub mod model; pub mod errors; pub mod change; use std::{ collections::HashMap, time::Instant }; use crate::{ agent::{Pers...
code_fim
medium
{ "lang": "rust", "repo": "mattswoon/eileen", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andyyu2004/spark-rs path: /spark/src/lib.rs #![feature( arbitrary_self_types, async_closure, exact_size_is_empty, new_uninit, once_cell, result_cloned, trait_alias, try_blocks, type_name_of_val, unboxed_closures )] <|fim_suffix|>#[macro_use] extern crate ...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/spark-rs", "path": "/spark/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_use] extern crate eyre; #[macro_use] extern crate serde_closure; #[macro_use] extern crate tracing;<|fim_prefix|>// repo: andyyu2004/spark-rs path: /spark/src/lib.rs #![feature( arbitrary_self_types, async_closure, exact_size_is_empty, new_uninit, once_cell, result_clone...
code_fim
medium
{ "lang": "rust", "repo": "andyyu2004/spark-rs", "path": "/spark/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgreid/run_container path: /container/src/devices/device.rs extern crate libc; extern crate nix; use self::nix::mount::{MS_BIND, MS_REC}; use self::nix::sys::stat::{Mode, SFlag}; use std::io; use std::ffi::{CString, NulError}; use std::fs; use std::os::unix::ffi::OsStrExt; use std::path::{Strip...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/run_container", "path": "/container/src/devices/device.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.major.is_none() { return Err(Error::NoMajor); } if self.minor.is_none() { return Err(Error::NoMinor); } let parent_dir = dev_path.parent().ok_or(Error::InvalidDevicePath)?; fs::create_dir_all(parent_dir).map_err(Error::Create...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/run_container", "path": "/container/src/devices/device.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: H-M-H/rustyline path: /examples/input_multiline.rs use rustyline::validate::{ MatchingBracketValidator, ValidationContext, ValidationResult, Validator, }; use rustyline::{Editor, Result}; use rustyline_derive::{Completer, Helper, Highlighter, Hinter}; <|fim_suffix|> let h = InputValidato...
code_fim
hard
{ "lang": "rust", "repo": "H-M-H/rustyline", "path": "/examples/input_multiline.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input = rl.readline("> ")?; println!("Input: {}", input); Ok(()) }<|fim_prefix|>// repo: H-M-H/rustyline path: /examples/input_multiline.rs use rustyline::validate::{ MatchingBracketValidator, ValidationContext, ValidationResult, Validator, }; use rustyline::{Editor, Result}; use rus...
code_fim
medium
{ "lang": "rust", "repo": "H-M-H/rustyline", "path": "/examples/input_multiline.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lazytiger/pbrt-rs path: /src/samplers/random.rs use crate::{ core::{ geometry::{Point2f, Point2i}, rng::RNG, sampler::{BaseSampler, Sampler, SamplerDt, SamplerDtRw}, }, impl_base_sampler, }; use std::sync::{Arc, RwLock}; <|fim_suffix|>impl Sampler for RandomS...
code_fim
hard
{ "lang": "rust", "repo": "lazytiger/pbrt-rs", "path": "/src/samplers/random.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn start_pixel(&mut self, p: Point2i) { for i in 0..self.sample_array_1d().len() { for j in 0..self.sample_array_1d()[i].len() { self.sample_array_1d_mut()[i][j] = self.rng.uniform_float(); } } for i in 0..self.sample_array_2d().len() { ...
code_fim
hard
{ "lang": "rust", "repo": "lazytiger/pbrt-rs", "path": "/src/samplers/random.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn clone_sampler(&self, seed: usize) -> SamplerDtRw { let mut rs = Clone::clone(self); rs.rng.set_sequence(seed); Arc::new(RwLock::new(Box::new(rs))) } }<|fim_prefix|>// repo: lazytiger/pbrt-rs path: /src/samplers/random.rs use crate::{ core::{ geometry::{Point...
code_fim
medium
{ "lang": "rust", "repo": "lazytiger/pbrt-rs", "path": "/src/samplers/random.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn into_owned(self) -> Atom<'static> { match self { Null => Null, True => True, False => False, I64(v) => I64(v), U64(v) => U64(v), F64(v) => F64(v), OwnedString(s) => OwnedString(s), List(l) =>...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/cson-rust", "path": "/src/repr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steveklabnik/cson-rust path: /src/repr.rs // This is a part of CSON-rust. // Written by Kang Seonghoon. See README.md for details. //! An internal representation of CSON data. use std::str::MaybeOwned; use std::collections::TreeMap; use serialize::json; use serialize::json::ToJson; #[deriving...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/cson-rust", "path": "/src/repr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> ToJson for Atom<'a> { fn to_json(&self) -> json::Json { match *self { Null => json::Null, True => json::Boolean(true), False => json::Boolean(false), I64(v) => json::I64(v), U64(v) => json::U64(v), F64(v) => json:...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/cson-rust", "path": "/src/repr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: allyn-bottorff/basic-computer-games path: /00_Utilities/markdown_todo_rust/src/main.rs use std::ffi::OsStr; use std::{fs, io}; use std::fs::metadata; use std::path::{Path, PathBuf}; /** * todo list generator for this repository, coded in rust * * @author Anthony Rubick */ //DATA const ROOT_...
code_fim
hard
{ "lang": "rust", "repo": "allyn-bottorff/basic-computer-games", "path": "/00_Utilities/markdown_todo_rust/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> //return raw input return raw_input.trim().to_string(); } /** * gets a boolean from user */ fn get_yn_from_user(prompt:&str) -> bool { //DATA let input = get_str_from_user(prompt); //default in case of error if input.is_empty() {return false;} //get and parse input matc...
code_fim
hard
{ "lang": "rust", "repo": "allyn-bottorff/basic-computer-games", "path": "/00_Utilities/markdown_todo_rust/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunmeng90/rust-lang path: /examples/list18-26/src/main.rs fn main() { match_guard_added_to_pattern(); match_guard_added_to_pattern_to_test_an_outer_variable(); match_guard_with_or_pattern(); } // Extra Conditionals with Match Guards // A match guard is an additional if conditi...
code_fim
medium
{ "lang": "rust", "repo": "sunmeng90/rust-lang", "path": "/examples/list18-26/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("at the end: x = {:?}, y = {}", x, y); } // Combining multiple patterns with a match guard fn match_guard_with_or_pattern() { let x = 4; let y = false; // The match condition states that the arm only matches if the value of x is equal to 4, 5, or 6 and if y is true. match x...
code_fim
hard
{ "lang": "rust", "repo": "sunmeng90/rust-lang", "path": "/examples/list18-26/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: openqrnch/vboxhelper path: /src/strutils.rs #[derive(PartialEq, Eq)] pub(crate) enum EmptyLine { Keep, Ignore } pub(crate) fn buf_to_strlines(buf: &Vec<u8>, el: EmptyLine) -> Vec<String> { let sbuf = std::str::from_utf8(&buf).expect("Buffer not UTF-8"); <|fim_suffix|>// vim: set ft=rust ...
code_fim
medium
{ "lang": "rust", "repo": "openqrnch/vboxhelper", "path": "/src/strutils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jacobmischka/adventofcode-2015 path: /src/bin/18.rs use std::io::{self, BufRead}; const WIDTH: usize = 100; const STEPS: usize = 100; type Grid = [[bool; WIDTH]; WIDTH]; fn main() { let mut start: Grid = [[false; WIDTH]; WIDTH]; for (row, line) in io::stdin() .lock() ....
code_fim
hard
{ "lang": "rust", "repo": "jacobmischka/adventofcode-2015", "path": "/src/bin/18.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> grid[0][0] = true; grid[0][WIDTH - 1] = true; grid[WIDTH - 1][WIDTH - 1] = true; grid[WIDTH - 1][0] = true; grid } fn count_on(grid: &Grid) -> u32 { grid.iter().fold(0, |row_count, row| { row_count + row .iter() .fold(0, |acc, li...
code_fim
hard
{ "lang": "rust", "repo": "jacobmischka/adventofcode-2015", "path": "/src/bin/18.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn run_step(current: &Grid) -> Grid { let mut new = current.clone(); for x in 0..WIDTH { for y in 0..WIDTH { let neighbors = [ current.get(x + 1).and_then(|row| row.get(y)), current.get(x + 1).and_then(|row| row.get(y + 1)), curr...
code_fim
hard
{ "lang": "rust", "repo": "jacobmischka/adventofcode-2015", "path": "/src/bin/18.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let iter = UnitIter::new_byte(bytes, show_ascii); let (start, end) = take_head_tail(iter, width, true, HEAD_TAIL_HAS_MORE_COST).unwrap(); if start == end { if show_ascii { Visible::BytesAscii(&bytes[..]) } else { Visible::Bytes(&bytes[..]) } ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rust-dangerous", "path": "/src/display/section.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/rust-dangerous path: /src/display/section.rs ////////////////////////////////////////////////////////////////// /// Returns `Result<(length, remaining), ()>` fn take_head( iter: UnitIter<'_>, width: usize, space_separated: bool, ) -> Result<(usize, usize), ()> { take_sid...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rust-dangerous", "path": "/src/display/section.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_computed_visible_eq!(from_head, { input: &[b'a', b'b', b'c', b'd', b'e', BAD_UTF8], format: PreferredFormat::Str, visible: Visible::BytesAscii(b"abc"), display: r#"['a' 'b' 'c' ..]"#, }); } #[test] fn test_computed_head_st...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rust-dangerous", "path": "/src/display/section.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let row = create_weighting_row(1000); assert_eq!(row.len(), 1000); let check_values: Vec<&f64> = row.iter().filter(|x| **x < -0.5 && **x > 0.5).collect(); assert_eq!(check_values.len(), 0); } #[test] fn test_sigmoid() { let y = 0.8807970779778823; ...
code_fim
medium
{ "lang": "rust", "repo": "corka149/simple_neural_network", "path": "/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: corka149/simple_neural_network path: /src/util.rs use rand; use rand::Rng; use std::f64::consts::E; pub fn create_weighting_row(x: usize) -> Vec<f64> { let mut row: Vec<f64> = Vec::new(); for _number in 0..x { let min = rand::thread_rng().gen_range(-0.1, -0.01); let max...
code_fim
medium
{ "lang": "rust", "repo": "corka149/simple_neural_network", "path": "/src/util.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Norbytus/excel_worker path: /src/excel_msg.rs use excel::*; use serde_json::Value; // use std::thread; // use std::sync::Arc; // use std::sync::mpsc::channel; use std::path::PathBuf; use std::process::Command; #[derive(Serialize, Deserialize, Debug)] pub struct XlsxFiles { files: Vec<Xls...
code_fim
hard
{ "lang": "rust", "repo": "Norbytus/excel_worker", "path": "/src/excel_msg.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn save(&self) -> String { let mut workbook = Workbook::create(&self.file_name); for sheet in &self.sheets { sheet.add_sheet(&mut workbook); } workbook.close(); self.file_name.to_string() } } impl Sheet { fn add_sheet(&self, wb: &mut Workb...
code_fim
hard
{ "lang": "rust", "repo": "Norbytus/excel_worker", "path": "/src/excel_msg.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match event { WindowResizeMsg::ValueChanged(value) => self .model .msg_stream .emit(CircleDrawingMsg::Resize(value as u64)), WindowResizeMsg::Quit => { self.model.msg_stream.emit(CircleDrawingMsg::StopResize); ...
code_fim
hard
{ "lang": "rust", "repo": "antoyo/relm", "path": "/relm-examples/examples/7gui/6_circle_drawer/src/gui/window_resize.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: antoyo/relm path: /relm-examples/examples/7gui/6_circle_drawer/src/gui/window_resize.rs use crate::gui::circle_drawing::CircleDrawingMsg; use gtk::prelude::*; use gtk::Adjustment; use relm::{Relm, StreamHandle, Widget}; use relm_derive::{widget, Msg}; #[derive(Msg)] pub enum WindowResizeMsg { ...
code_fim
hard
{ "lang": "rust", "repo": "antoyo/relm", "path": "/relm-examples/examples/7gui/6_circle_drawer/src/gui/window_resize.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/icu_locid/src/extensions/unicode/mod.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 ). //! Unicode...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/icu_locid/src/extensions/unicode/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_suffix|>impl writeable::Writeable for Unicode { fn write_to<W: core::fmt::Write + ?Sized>(&self, sink: &mut W) -> core::fmt::Result { if self.is_empty() { return Ok(()); } sink.write_str("u")?; if !self.attributes.is_empty() { sink.write_char('-')?; ...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/icu_locid/src/extensions/unicode/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Debug)] struct EventData<'a> { fired_at: usize, event: Result<LiveEvent<'a>, (usize, usize)>, } open! {file: file}; open! {smf: [parse_bytemap] file}; //Holds data bytes for sysex expected events let mut sysex_bytes = Vec::new(); //Holds expected e...
code_fim
hard
{ "lang": "rust", "repo": "apps4uco/midly", "path": "/src/test.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apps4uco/midly path: /src/test.rs parse_collect::Smf::parse(&file).expect("failed to reparse midi file") }); assert_eq!( smf, clone_smf, "reparsed midi file is not identical to the original" ); } mod parse_collect { use super::*; #[cfg(feature = "alloc...
code_fim
hard
{ "lang": "rust", "repo": "apps4uco/midly", "path": "/src/test.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn beethoven() {"Beethoven.rmi"} #[test] fn sysex() {"SysExTest.mid"} } #[test] fn not_midi() { open! {file: "colorlist.txt"}; let result = parse_collect::Smf::parse(&file); match result { Ok(_) => panic!("parsed an...
code_fim
hard
{ "lang": "rust", "repo": "apps4uco/midly", "path": "/src/test.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> // Wait for the command buffer to be executed logical_device .queue_wait_idle(queue) .expect("Failed to wait for command buffer to be executed!"); // Free the command buffer logical_device.free_command_buffers(self.pool(), &c...
code_fim
hard
{ "lang": "rust", "repo": "jsyszh/dragonglass", "path": "/src/renderer/backend/vulkan/src/resource/command_pool.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jsyszh/dragonglass path: /src/renderer/backend/vulkan/src/resource/command_pool.rs // TODO: Make a type alias for the current device version (DeviceV1_0) use crate::{ core::VulkanContext, resource::Buffer, sync::{CurrentFrameSynchronization, Fence}, }; use ash::{version::DeviceV1_0, ...
code_fim
hard
{ "lang": "rust", "repo": "jsyszh/dragonglass", "path": "/src/renderer/backend/vulkan/src/resource/command_pool.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use about::About; pub use socials::Socials; pub use not_found::NotFound; pub use support::Support; pub use talks::Talks;<|fim_prefix|>// repo: nunomaduro/nunomaduro.com path: /application/src/http/routes/mod.rs pub mod api; pub mod posts; <|fim_middle|>mod about; mod socials; mod not_found; mod talk...
code_fim
medium
{ "lang": "rust", "repo": "nunomaduro/nunomaduro.com", "path": "/application/src/http/routes/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nunomaduro/nunomaduro.com path: /application/src/http/routes/mod.rs pub mod api; pub mod posts; <|fim_suffix|>pub use about::About; pub use socials::Socials; pub use not_found::NotFound; pub use support::Support; pub use talks::Talks;<|fim_middle|>mod about; mod socials; mod not_found; mod talk...
code_fim
medium
{ "lang": "rust", "repo": "nunomaduro/nunomaduro.com", "path": "/application/src/http/routes/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vzaa/advent_of_code_2020 path: /day23/src/main.rs #[derive(Debug)] struct Node { dat: i64, next: usize, prev: usize, } fn nth_fwd(buf: &[Node], id: usize, n: usize) -> usize { let mut cur = id; for _ in 0..n { cur = buf[cur].next; } cur } #[allow(dead_code)]...
code_fim
hard
{ "lang": "rust", "repo": "Vzaa/advent_of_code_2020", "path": "/day23/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main_loop(cups: &mut Vec<Node>, empty_slots: &mut Vec<usize>, iters: usize) -> usize { let mut cur = 0; for _ in 0..iters { let cup = cups[cur].dat; let a = nth_fwd(&cups, cur, 1); let b = nth_fwd(&cups, cur, 2); let c = nth_fwd(&cups, cur, 3); let hel...
code_fim
hard
{ "lang": "rust", "repo": "Vzaa/advent_of_code_2020", "path": "/day23/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn studio_command(&self) -> Result<Command> { let mut cmd = Command::new(&*HAB_CLI); if cfg!(not(windows)) { cmd.env_clear(); } debug!("HAB_CACHE_KEY_PATH: {:?}", self.workspace.key_path()); cmd.env("NO_ARTIFACT_PATH", "true"); // Disables artifact ...
code_fim
hard
{ "lang": "rust", "repo": "habitat-sh/builder", "path": "/components/builder-worker/src/runner/studio.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: habitat-sh/builder path: /components/builder-worker/src/runner/studio.rs use crate::{error::{Error, Result}, hab_core::{env::{self, Config}, fs, package::target::{self, ...
code_fim
hard
{ "lang": "rust", "repo": "habitat-sh/builder", "path": "/components/builder-worker/src/runner/studio.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zacharygolba/elastic path: /elastic/examples/bulk.rs extern crate elastic; use elastic::prelude::*; fn main() { // A HTTP client and request parameters let client = Client::new(RequestParams::default()).unwrap(); <|fim_suffix|> println!("Successful operations"); for op in bulk....
code_fim
hard
{ "lang": "rust", "repo": "zacharygolba/elastic", "path": "/elastic/examples/bulk.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn get_req() -> String { let mut bulk = String::new(); for i in 1..1000 { let header = format!("{{ \"index\" : {{ \"_index\" : \"test\", \"_type\" : \"ty\", \"_id\" : \"{}\" }} }}", i); let body = format!("{{ \"title\" : \"string value {}\" }}", i); bulk.push_str(&header);...
code_fim
medium
{ "lang": "rust", "repo": "zacharygolba/elastic", "path": "/elastic/examples/bulk.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> updater.update_slot_binding(slot, descriptor.slot_index as u32); continue 'outer_0; } } return Err(IncompatibleResources::MissingResource( ...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/pipeline/graphics/graphics_pipeline.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RSSchermer/web_glitz.rs path: /web_glitz/src/pipeline/graphics/graphics_pipeline.rs n used by the pipeline if the depth test is enabled, or /// `None` otherwise. /// /// See [DepthTest] for details. pub fn depth_test(&self) -> Option<&DepthTest> { self.depth_test.as_ref()...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/pipeline/graphics/graphics_pipeline.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RSSchermer/web_glitz.rs path: /web_glitz/src/pipeline/graphics/graphics_pipeline.rs ResourceBindingsLayoutDescriptor, }; use crate::runtime::state::{ContextUpdate, DynamicState, ProgramKey}; use crate::runtime::{Connection, CreateGraphicsPipelineError, RenderingContext}; use crate::task::{Contex...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/pipeline/graphics/graphics_pipeline.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut colleges = decode::Decoder::new(std::fs::File::open(&colleges)?)?; colleges::Clubs::from_file(&mut colleges) } fn load_years( data_dir: &Path, clubs: &Clubs, competition: Competition, ) -> Result<HashMap<String, CrewRecord>, Box<dyn Error>> { let raw = data_dir.join(forma...
code_fim
hard
{ "lang": "rust", "repo": "matthewelse/bumps-tools", "path": "/src/cmd_db.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matthewelse/bumps-tools path: /src/cmd_db.rs use std::collections::BTreeMap; use std::collections::HashMap; use std::convert::TryInto; use std::error::Error; use std::path::Path; use std::path::PathBuf; use clap::Parser; use diesel::insert_into; use diesel::prelude::*; use diesel::SqliteConnect...
code_fim
hard
{ "lang": "rust", "repo": "matthewelse/bumps-tools", "path": "/src/cmd_db.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sqlite_path = args.sqlite_path.clone().unwrap_or("bumps.db".into()); let mut conn = SqliteConnection::establish(&sqlite_path)?; let clubs = load_clubs(&args.data_dir)?; let mut all_entries = vec![]; for comp in [ Competition::Early, Competition::MenLents, ...
code_fim
hard
{ "lang": "rust", "repo": "matthewelse/bumps-tools", "path": "/src/cmd_db.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let db = env.open_db(None).unwrap(); let mut txn = env.begin_rw_txn().unwrap(); for i in 0..num_rows { txn.put(db, &get_key(i), &get_data(i), WriteFlags::empty()).unwrap(); } txn.commit().unwrap(); } (dir, env) }<|fim_prefix|>// repo: mozil...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/lmdb-rs", "path": "/benches/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mozilla/lmdb-rs path: /benches/utils.rs extern crate lmdb; extern crate tempdir; use self::tempdir::TempDir; use lmdb::{ Environment, Transaction, WriteFlags, }; pub fn get_key(n: u32) -> String { format!("key{}", n) } <|fim_suffix|>pub fn setup_bench_db(num_rows: u32) -> (Tem...
code_fim
medium
{ "lang": "rust", "repo": "mozilla/lmdb-rs", "path": "/benches/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>tions //! - aggregations on DataFrame level //! - aggregate to largelist //! - a lot of bugs fixed in optimizers //! - UDF's / closures in lazy dsl //! - DataFrame reverse operation //!<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-core/src/doc/changelog/v0_8.rs //! # Chan...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-core/src/doc/changelog/v0_8.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-core/src/doc/changelog/v0_8.rs //! # Changelog v0.8 //! //! * Upgrade to Arrow 2.0 //! * Add quantile aggregation to `ChunkedArray` //! * Option to stop reading CSV after n rows. //! * Read parquet file in a single batch reducing reading time. //! * Faster ker...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-core/src/doc/changelog/v0_8.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>d //! - Utf8Chunked::replace_all method //! * Temporal utilities //! - Utf8Chunked to dat32 / datetime //! * Lazy //! - fill_null expression //! - shift expression //! - Series aggregations //! - aggregations on DataFrame level //! - aggregate to largelist //! - a lot of bu...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-core/src/doc/changelog/v0_8.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let repo = repo("with-submodules-in-index")?; assert!( repo.open_modules_file()?.is_none(), ".gitmodules not available in worktree" ); let modules = repo.modules()?.expect("present as loaded from index"); assert_eq!( modules.names...
code_fim
hard
{ "lang": "rust", "repo": "Byron/gitoxide", "path": "/gix/tests/repository/submodule.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Byron/gitoxide path: /gix/tests/repository/submodule.rs mod modules_file { use crate::submodule::repo; #[test] fn none_if_not_present() -> crate::Result { let repo = repo("module1")?; assert!(repo.open_modules_file()?.is_none(), "it's OK to not have such a file"); ...
code_fim
hard
{ "lang": "rust", "repo": "Byron/gitoxide", "path": "/gix/tests/repository/submodule.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leejw51/RustTutorial path: /code/src/rc3.rs use std::cell::RefCell; use std::rc::Rc; use std::sync::Arc; struct Node { price: i32, } impl Node { fn print(&self) { println!("price={}", self.price); } fn set(&mut self, newvalue: i32) { self.price = newvalue; } }...
code_fim
easy
{ "lang": "rust", "repo": "leejw51/RustTutorial", "path": "/code/src/rc3.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut n = Rc::new(RefCell::new(Node { price: 20 })); let mut m = n.clone(); n.borrow_mut().set(200); n.borrow().print(); m.borrow().print(); }<|fim_prefix|>// repo: leejw51/RustTutorial path: /code/src/rc3.rs use std::cell::RefCell; use std::rc::Rc; use std::sync::Arc; struct Node {...
code_fim
easy
{ "lang": "rust", "repo": "leejw51/RustTutorial", "path": "/code/src/rc3.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/googapis path: /googapis/genproto/google.cloud.orgpolicy.v2.rs or configurations of Cloud Platform resources. #[derive(Clone, PartialEq, ::prost::Message)] pub struct Policy { /// Immutable. The resource name of the Policy. Must be one of the following /// forms, where constrai...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/googapis", "path": "/googapis/genproto/google.cloud.orgpolicy.v2.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error: Into<StdError> + Send + Sync, { OrgPolicyClient::new(InterceptedService::new(inner, interceptor)) } #[doc = r" Compress requests with `gzip`."] #[doc = r""] #[doc = r"...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/googapis", "path": "/googapis/genproto/google.cloud.orgpolicy.v2.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/googapis path: /googapis/genproto/google.cloud.orgpolicy.v2.rs loc::string::String>, } #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Kind { /// List of values to be used for this PolicyRule. This field can be set /// only in Polici...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/googapis", "path": "/googapis/genproto/google.cloud.orgpolicy.v2.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: grinnan/zeronsd path: /zerotier-one-api/src/models/status.rs /* * ZeroTierOne Service API * * <p> This API controls the ZeroTier service that runs in the background on your computer. This is how zerotier-cli, and the macOS and Windows apps control the service. </p> <p> API requests must be au...
code_fim
hard
{ "lang": "rust", "repo": "grinnan/zeronsd", "path": "/zerotier-one-api/src/models/status.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl Status { pub fn new() -> Status { Status { address: None, clock: None, config: None, online: None, planet_world_id: None, planet_world_timestamp: None, public_identity: None, tcp_fallback_activ...
code_fim
hard
{ "lang": "rust", "repo": "grinnan/zeronsd", "path": "/zerotier-one-api/src/models/status.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davidedelpapa/RustLearningMachine path: /src/ops.rs use std::f64; use std::iter::repeat; // TODO make a trait to use with num and big numbers /// Calculates the euclidean distance for two f64 vectors /// /// The Euclidean distance between two vectors is /// the square root of the sum of the po...
code_fim
medium
{ "lang": "rust", "repo": "davidedelpapa/RustLearningMachine", "path": "/src/ops.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(euclidean_distance(vec!(7.), vec!(2.)), 5.); } #[test] fn test_euclidean_distance_different_lenghts() { assert_eq!( euclidean_distance(vec!(3., 7., 7., 8., 2., 1.), vec!(2., 2., 14., 7.)), 9. ); } }<|fim_prefix|>// repo: davidedelp...
code_fim
medium
{ "lang": "rust", "repo": "davidedelpapa/RustLearningMachine", "path": "/src/ops.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }