text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let mut canvas = Canvas::new(10, 10, 0); let fg = 0x00000001; canvas.set_fg_color(fg); canvas.set_offset(2, 2); canvas.fill_square(2, 2, 2, 2); let result = "0000000000 0000000000 0000000000 0000000000 0000110000 0000110000 0000000000 0000000000 0000000000 0000000000" .to_str...
code_fim
hard
{ "lang": "rust", "repo": "nordsoyv/rust-mono", "path": "/canvas/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nordsoyv/rust-mono path: /canvas/src/lib.rs use std::convert::TryFrom; mod vector; const BACKGROUND_COLOR: u32 = 0x00000000; const FOREGROUND_COLOR: u32 = 0x00ffffff; pub struct Canvas { width: i32, height: i32, x_offset: i32, y_offset: i32, bg_color: u32, fg_color: u32, margin:...
code_fim
hard
{ "lang": "rust", "repo": "nordsoyv/rust-mono", "path": "/canvas/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn can_use_offset_with_fill_square() { let mut canvas = Canvas::new(10, 10, 0); let fg = 0x00000001; canvas.set_fg_color(fg); canvas.set_offset(2, 2); canvas.fill_square(2, 2, 2, 2); let result = "0000000000 0000000000 0000000000 0000000000 0000110000 0000110000 0000000...
code_fim
hard
{ "lang": "rust", "repo": "nordsoyv/rust-mono", "path": "/canvas/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn end_render(&self, old_viewport: Vec<i32>) { unsafe { gl::Viewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]); gl::BindFramebuffer(gl::FRAMEBUFFER, 0); } } } impl Drop for Framebuffer { fn drop(&mut self) { unsafe { if self.depth_buffer {...
code_fim
hard
{ "lang": "rust", "repo": "kirbyk/gui-rs", "path": "/src/framebuffer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kirbyk/gui-rs path: /src/framebuffer.rs use std::iter::*; use opengl::*; use texture::*; pub struct Framebuffer { pub id: GLuint, pub tex: Texture, pub depth_buffer: bool, pub depth_id: GLuint, } impl Framebuffer { pub fn new(width: i32, height: i32, internal_format: u32, depth_buff...
code_fim
hard
{ "lang": "rust", "repo": "kirbyk/gui-rs", "path": "/src/framebuffer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Ugly hack to get around Rust's borrow checker pub fn begin_render(&self) -> Vec<i32> { unsafe {gl::BindFramebuffer(gl::FRAMEBUFFER, self.id);} let mut old_viewport: Vec<_> = repeat(0).take(4).collect();//Vec::from_elem(4, 0); unsafe { gl::GetIntegerv(gl::VIEWPORT, old_viewport.as_...
code_fim
hard
{ "lang": "rust", "repo": "kirbyk/gui-rs", "path": "/src/framebuffer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0136.rs //! @ The |new_null_box| function returns a pointer to an |hlist_node| in //! which all subfields have the values corresponding to `\.{\\hbox\{\}}'. //! (The |subtype| field is set to |min_quarterword|, for historic reasons //! that are...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0136.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>rate::section_0115::pointer; use crate::section_0125::get_node; use crate::section_0133::r#type; use crate::section_0133::subtype; use crate::section_0135::box_node_size; use crate::section_0135::depth; use crate::section_0135::glue_order; use crate::section_0135::glue_set; use crate::section_0135::glue_s...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0136.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sshestopalov/monkey-rust path: /interpreter/src/ast/mod.rs pub mod program; pub mod statement; pub mod identifier; pub mod expression; pub mod int; pub mod string; pub mod array; pub mod boolean; pub mod prefix; pub mod infix; pub mod if_expression; pub mod index_expression; pub mod function; pu...
code_fim
medium
{ "lang": "rust", "repo": "sshestopalov/monkey-rust", "path": "/interpreter/src/ast/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn node_type(&self) -> NodeType; } #[derive(Debug)] pub enum NodeType<'a> { Statement(&'a statement::Statement), Expression(&'a expression::Expression), Identifier(&'a identifier::Identifier), Program(&'a program::Program), Function(&'a function::FunctionLiteral), Call(&'a call::Call...
code_fim
medium
{ "lang": "rust", "repo": "sshestopalov/monkey-rust", "path": "/interpreter/src/ast/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liuchengyiu/hy-mesh path: /src/sl_mesh/mqtt/net_test.rs use std::{ collections::HashMap, sync::{Arc, Mutex}, string::String as String, sync::mpsc::*, thread, time::Duration }; use crate::mqtts::{ mqtt_h::TXTOPIC, init::publish_message, mqtt_h::MeshMessage }; u...
code_fim
hard
{ "lang": "rust", "repo": "liuchengyiu/hy-mesh", "path": "/src/sl_mesh/mqtt/net_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> new_thread(Arc::clone(&receiver)); NetTest {test: Test {flag: false, res: HashMap::new(), send: HashMap::new(), interval: 0, duration: 0}, tx: sender} } pub fn get_test(&self) -> String{ let decoded: String = json::encode(&self....
code_fim
hard
{ "lang": "rust", "repo": "liuchengyiu/hy-mesh", "path": "/src/sl_mesh/mqtt/net_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: skyneticist/rusty_api path: /src/main.rs use futures::executor::block_on; use std::fs::File; use std::io::{BufWriter, Write}; use structopt::StructOpt; #[derive(StructOpt, Debug)] struct Cli { #[structopt(short, long)] debug: bool, #[structopt(short, long, default_value = "https://a...
code_fim
hard
{ "lang": "rust", "repo": "skyneticist/rusty_api", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let file_name: String = "megabits".to_string(); let borrowed_file_name: String = file_name.clone(); let data: String = "rust in peace".to_string(); write_to_file(&file_name, &data); let result = match std::fs::read_to_string(borrowed_file_name) { Ok(k...
code_fim
hard
{ "lang": "rust", "repo": "skyneticist/rusty_api", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atsamd-rs/atsamd path: /pac/atsamd51g/src/adc0/dseqctrl.rs #[doc = "Register `DSEQCTRL` reader"] pub struct R(crate::R<DSEQCTRL_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DSEQCTRL_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } im...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/pac/atsamd51g/src/adc0/dseqctrl.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `AUTOSTART` writer - ADC Auto-Start Conversion"] pub struct AUTOSTART_W<'a> { w: &'a mut W, } impl<'a> AUTOSTART_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Cl...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/pac/atsamd51g/src/adc0/dseqctrl.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jiegec/rcore_plus path: /modules/hello_rust/src/main/mod.rs extern crate rcore; extern crate alloc; use rcore::lkm::api::lkm_api<|fim_suffix|>"C" fn init_module(){ lkm_api_pong(); let mut v: Vec<u8>=Vec::new(); v.push(10); v.push(20); hello::hello_again(); }<|fim_middle|>_pon...
code_fim
medium
{ "lang": "rust", "repo": "jiegec/rcore_plus", "path": "/modules/hello_rust/src/main/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>::new(); v.push(10); v.push(20); hello::hello_again(); }<|fim_prefix|>// repo: jiegec/rcore_plus path: /modules/hello_rust/src/main/mod.rs extern crate rcore; extern crate alloc; use rcore::lkm::api::lkm_api_pong; use alloc::vec::Vec; pub mod hello; #[no_mangle] pub extern <|fim_middle|>"C" ...
code_fim
medium
{ "lang": "rust", "repo": "jiegec/rcore_plus", "path": "/modules/hello_rust/src/main/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>"C" fn init_module(){ lkm_api_pong(); let mut v: Vec<u8>=Vec::new(); v.push(10); v.push(20); hello::hello_again(); }<|fim_prefix|>// repo: jiegec/rcore_plus path: /modules/hello_rust/src/main/mod.rs extern crate rcore; extern crate alloc; use rcore::lkm::api::lkm_api<|fim_middle|>_pon...
code_fim
medium
{ "lang": "rust", "repo": "jiegec/rcore_plus", "path": "/modules/hello_rust/src/main/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_empty(&self) -> bool { self.targets_and_outputs.is_empty() } pub fn iter(&'a self) -> std::collections::hash_map::Iter<'a, Label, Cow<'a, Path>> { self.targets_and_outputs.iter() } } impl<'a> IntoIterator for TargetsAndOutputs<'a> { type IntoIter = <HashMap<...
code_fim
hard
{ "lang": "rust", "repo": "facebookincubator/antlir", "path": "/antlir/buck/targets_and_outputs/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> IntoIterator for TargetsAndOutputs<'a> { type IntoIter = <HashMap<Label, Cow<'a, Path>> as IntoIterator>::IntoIter; type Item = (Label, Cow<'a, Path>); fn into_iter(self) -> Self::IntoIter { self.targets_and_outputs.into_iter() } }<|fim_prefix|>// repo: facebookincubator/...
code_fim
hard
{ "lang": "rust", "repo": "facebookincubator/antlir", "path": "/antlir/buck/targets_and_outputs/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebookincubator/antlir path: /antlir/buck/targets_and_outputs/src/lib.rs /* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use std::borrow::Cow; use std:...
code_fim
hard
{ "lang": "rust", "repo": "facebookincubator/antlir", "path": "/antlir/buck/targets_and_outputs/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn parse_options(&mut self) -> () { match self.get_flag("options") { Some(value) => { let mut options = value.chars(); for _i in 0..value.len() { match options.next() { Some(option) => { self.options.push(option); } None => { } } } }, ...
code_fim
hard
{ "lang": "rust", "repo": "amerelo/Npuzzle", "path": "/src/config_module/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amerelo/Npuzzle path: /src/config_module/config.rs use std::collections::HashMap; trait StringUtils { fn substring(&self, start: usize, len: usize) -> Self; } impl StringUtils for String { fn substring(&self, start: usize, len: usize) -> Self { self.chars().skip(start).take(len...
code_fim
hard
{ "lang": "rust", "repo": "amerelo/Npuzzle", "path": "/src/config_module/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new(args: Vec<String>) -> (Config) { let mut object = Config { argv: args, flags: HashMap::new(), options: vec![] }; object.parse_args(); object.parse_options(); return object; } }<|fim_prefix|>// repo: amerelo/Npuzzle path: /src/config_module/config.rs use std::collections::HashMap; t...
code_fim
hard
{ "lang": "rust", "repo": "amerelo/Npuzzle", "path": "/src/config_module/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gpestana/proof-systems path: /dlog/tests/poseidon_vesta_15_wires.rs use ark_ff::{UniformRand, Zero}; use ark_poly::{univariate::DensePolynomial, UVPolynomial}; use array_init::array_init; use colored::Colorize; use commitment_dlog::{ commitment::{b_poly_coefficients, ceil_log2, CommitmentCur...
code_fim
hard
{ "lang": "rust", "repo": "gpestana/proof-systems", "path": "/dlog/tests/poseidon_vesta_15_wires.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // debug println!("{}{:?}", "Circuit size: ".yellow(), max_size); println!("{}{:?}", "Polycommitment chunk size: ".yellow(), max_size); println!( "{}{:?}", "Number oh Poseidon hashes in the circuit: ".yellow(), NUM_POS ); println!( "{}{:?}", ...
code_fim
hard
{ "lang": "rust", "repo": "gpestana/proof-systems", "path": "/dlog/tests/poseidon_vesta_15_wires.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Berrysoft/rlibc path: /src/math.rs macro_rules! no_mangle { ($(fn $fun:ident($($iid:ident : $ity:ty),+) -> $oty:ty;)+) => { $( #[no_mangle] pub unsafe extern "C" fn $fun($($iid: $ity),+) -> $oty { libm::$fun($($iid),+) } )+ ...
code_fim
hard
{ "lang": "rust", "repo": "Berrysoft/rlibc", "path": "/src/math.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn ldexp(f: f64, n: i32) -> f64; fn ldexpf(f: f32, n: i32) -> f32; fn lgamma(x: f64) -> f64; fn lgammaf(x: f32) -> f32; fn log(x: f64) -> f64; fn log1p(x: f64) -> f64; fn log1pf(n: f32) -> f32; fn log2(x: f64) -> f64; fn log2f(x: f32) -> f32; fn log10(x: f64) -> ...
code_fim
hard
{ "lang": "rust", "repo": "Berrysoft/rlibc", "path": "/src/math.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn collator_submit_task(_signer: [u8; 20]) -> Result<(), Error> { /* CollatorSubmitTask, Dep: 0 Global Config Cell Dep: 1 Sidechain Config Cell Code Cell -> Code Cell Sidechain State Cell -> Sidechain State Cell S...
code_fim
hard
{ "lang": "rust", "repo": "YHM404/axon", "path": "/axon-ckb-contracts/contracts/code-cell/src/entry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YHM404/axon path: /axon-ckb-contracts/contracts/code-cell/src/entry.rs sidechain_state::SidechainStateCellTypeArgs, sudt_token::SudtTokenData, task::{TaskCellData, TaskCellMode}, }, pattern::Pattern, witness::{ admin_create_sidechain::AdminCreateSidechainWitn...
code_fim
hard
{ "lang": "rust", "repo": "YHM404/axon", "path": "/axon-ckb-contracts/contracts/code-cell/src/entry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn admin_create_sidechain(_signer: [u8; 20]) -> Result<(), Error> { /* AdminCreateSidechain, Dep: 0 Global Config Cell Code Cell -> Code Cell CKB Cell -> Sidechain Config Cell Null -> ...
code_fim
hard
{ "lang": "rust", "repo": "YHM404/axon", "path": "/axon-ckb-contracts/contracts/code-cell/src/entry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: orium/rustybit path: /src/comm.rs pub struct DuplexChannel<S,R> { pub sender : SyncSender<S>, pub receiver : Receiver<R> } pub fn sync_duplex_channel<T : Send,U : Send>(buff_cap : <|fim_suffix|>f_cap); let dup_a : DuplexChannel<T,U> = DuplexChannel { sender: send_a, ...
code_fim
hard
{ "lang": "rust", "repo": "orium/rustybit", "path": "/src/comm.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>t dup_b : DuplexChannel<U,T> = DuplexChannel { sender: send_b, receiver: recv_b}; (dup_a, dup_b) }<|fim_prefix|>// repo: orium/rustybit path: /src/comm.rs pub struct DuplexChannel<S,R> { pub sender : SyncSender<S>, pub receiver : Recei...
code_fim
hard
{ "lang": "rust", "repo": "orium/rustybit", "path": "/src/comm.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ramtej/mochi-graph-algorithms path: /src/graph/data_structures/radix_heap.rs pub fn bsr32(x: u32) -> usize { if x == 0 { 0 } else { 31 - x.leading_zeros() as usize } } pub fn bsr64(x: u64) -> usize { if x == 0 { 0 } else { 63 - x.leading_zeros() as usize } } pub struct RadixHea...
code_fim
hard
{ "lang": "rust", "repo": "ramtej/mochi-graph-algorithms", "path": "/src/graph/data_structures/radix_heap.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn size(&self) -> usize { self.size } } pub struct RadixHeap64<T> { v: Vec<Vec<(u64, T)>>, last: u64, size: usize, } impl<T> RadixHeap64<T> { pub fn new() -> Self { let mut temp = Vec::new(); for _ in 0..65 { temp.push(Vec::new()); } RadixHeap64 { v: temp...
code_fim
hard
{ "lang": "rust", "repo": "ramtej/mochi-graph-algorithms", "path": "/src/graph/data_structures/radix_heap.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sirkibsirkib/reo_rs_outdated path: /graveyard4/token_eg.rs mod tokens { pub struct U; pub struct V; } use tokens::{U, V}; fn fib(x: u32) -> u32 { <|fim_suffix|>pub fn put(u: U, datum: u32) -> V { cvt!(u) } pub fn get(v: V) -> (U, u32) { (cvt!(v), fib(32)) }<|fim_middle|> match x { 0 => 0,...
code_fim
medium
{ "lang": "rust", "repo": "sirkibsirkib/reo_rs_outdated", "path": "/graveyard4/token_eg.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match x { 0 => 0, 1 => 1, n => fib(n+1) + fib(n+2), } } macro_rules! cvt { ($x:expr) => {{ unsafe{std::mem::transmute($x)} }} } pub fn put(u: U, datum: u32) -> V { cvt!(u) } pub fn get(v: V) -> (U, u32) { (cvt!(v), fib(32)) }<|fim_prefix|>// repo: sirkibsirkib/reo_rs_outdated path: /grave...
code_fim
easy
{ "lang": "rust", "repo": "sirkibsirkib/reo_rs_outdated", "path": "/graveyard4/token_eg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn put(u: U, datum: u32) -> V { cvt!(u) } pub fn get(v: V) -> (U, u32) { (cvt!(v), fib(32)) }<|fim_prefix|>// repo: sirkibsirkib/reo_rs_outdated path: /graveyard4/token_eg.rs mod tokens { pub struct U; pub struct V; } use tokens::{U, V}; <|fim_middle|>fn fib(x: u32) -> u32 { match x { 0 => 0,...
code_fim
medium
{ "lang": "rust", "repo": "sirkibsirkib/reo_rs_outdated", "path": "/graveyard4/token_eg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let entry = gtk::Entry::new().unwrap(); entry.set_has_frame(true); entry.set_halign(gtk::Align::Center); entry.set_valign(gtk::Align::Start); container.pack_start(&entry, true, true, 0); container.show_all(); container } }<|fim_prefix|>// repo:...
code_fim
hard
{ "lang": "rust", "repo": "swiboe/swiboe", "path": "/gtk_gui/src/completion_widget.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swiboe/swiboe path: /gtk_gui/src/completion_widget.rs // Copyright (c) The Swiboe development team. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE.txt // in the project root for license information. use gtk::signal; use gtk::traits::*; use gtk; pub struct C...
code_fim
hard
{ "lang": "rust", "repo": "swiboe/swiboe", "path": "/gtk_gui/src/completion_widget.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let container = gtk::Box::new(gtk::Orientation::Vertical, 0).unwrap(); container.set_border_width(10); // container.set_default_size((widget.get_allocated_width() as f32 * 0.8).round() as i32, 200); // let listview = gtk::Listview(); let entry = gtk::Entry::new()....
code_fim
medium
{ "lang": "rust", "repo": "swiboe/swiboe", "path": "/gtk_gui/src/completion_widget.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samrg472/metrics path: /metrics-runtime/src/observers.rs //! Commonly used observers. //! //! Observers define the format of the metric output: text, JSON, etc. #[cfg(feature = "metrics-observer-text")] pub use metrics_observer_text::TextBuilder; <|fim_suffix|>#[cfg(feature = "metrics-observer-...
code_fim
medium
{ "lang": "rust", "repo": "samrg472/metrics", "path": "/metrics-runtime/src/observers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "metrics-observer-prometheus")] pub use metrics_observer_prometheus::PrometheusBuilder;<|fim_prefix|>// repo: samrg472/metrics path: /metrics-runtime/src/observers.rs //! Commonly used observers. //! //! Observers define the format of the metric output: text, JSON, etc. #[cfg(feature = "m...
code_fim
medium
{ "lang": "rust", "repo": "samrg472/metrics", "path": "/metrics-runtime/src/observers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avl/aoc2019 path: /aoc2019_day1/src/main.rs use std::convert::TryFrom; const module_masses_str : &str = " 129192 58561 57267 95382 84995 127372 93598 97264 138550 79327 135661 139468 108860 149642 72123 128333 69002 98450 86267 70171 101333 79822 142539 142743 51371 111381 62073 72210 125168 13...
code_fim
hard
{ "lang": "rust", "repo": "avl/aoc2019", "path": "/aoc2019_day1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] pub fn precondition1() { assert_eq!(fuel_for_module(12),2); assert_eq!(fuel_for_module(14),2); assert_eq!(fuel_for_module(1969),654); assert_eq!(fuel_for_module(100756),33583); } #[test] pub fn precondition2() { assert_eq!(fuel_for_module_and_fuel(14),2); assert_eq!(fuel_...
code_fim
hard
{ "lang": "rust", "repo": "avl/aoc2019", "path": "/aoc2019_day1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Filter for Noise { fn apply(&self, i: &mut Image) { let mut rng = thread_rng(); for y in 0..i.height() { for x in 0..i.width() { if rng.gen::<f32>() <= self.prob { i.put_pixel(x, y, Pixl::black()); } } ...
code_fim
medium
{ "lang": "rust", "repo": "daniel-e/captcha", "path": "/src/filters/noise.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: daniel-e/captcha path: /src/filters/noise.rs use rand::{thread_rng, Rng}; use filters::Filter; use images::{Image, Pixl}; pub struct Noise { prob: f32, } <|fim_suffix|>impl Filter for Noise { fn apply(&self, i: &mut Image) { let mut rng = thread_rng(); for y in 0..i.he...
code_fim
medium
{ "lang": "rust", "repo": "daniel-e/captcha", "path": "/src/filters/noise.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pauni/GNOMEConnect-desktop path: /src/tests.rs extern crate serde_derive; // extern crate serde; extern crate serde_json; pub mod events; <|fim_suffix|> let data: Vec<events::Event> = serde_json::from_str(json_raw).unwrap(); match data[0] { events::Event::B...
code_fim
hard
{ "lang": "rust", "repo": "pauni/GNOMEConnect-desktop", "path": "/src/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match data[0] { events::Event::BatteryStatus{level, charging} => { assert_eq!(level, 86); assert_eq!(charging, false); }, _ => panic!("whut?") } eprintln!("{:#?}", data); } }<|fim_prefix|>// repo: pauni/GNOME...
code_fim
hard
{ "lang": "rust", "repo": "pauni/GNOMEConnect-desktop", "path": "/src/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let data: Vec<events::Event> = serde_json::from_str(json_raw).unwrap(); match data[0] { events::Event::BatteryStatus{level, charging} => { assert_eq!(level, 86); assert_eq!(charging, false); }, _ => panic!("whut?") ...
code_fim
hard
{ "lang": "rust", "repo": "pauni/GNOMEConnect-desktop", "path": "/src/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Operation not completed, thus parse errno to find out what happened. _ => { let errno: libc::c_int = unsafe { *libc::__errno_location() }; // Operation in progress. if errno == libc::EINPROGRESS || errno == libc::EALREADY { ...
code_fim
hard
{ "lang": "rust", "repo": "jthelin/demikernel", "path": "/src/rust/catcollar/futures/connect.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Operation in progress. if errno == libc::EINPROGRESS || errno == libc::EALREADY { trace!("connect in progress ({:?})", errno); ctx.waker().wake_by_ref(); return Poll::Pending; } /...
code_fim
hard
{ "lang": "rust", "repo": "jthelin/demikernel", "path": "/src/rust/catcollar/futures/connect.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jthelin/demikernel path: /src/rust/catcollar/futures/connect.rs // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. //============================================================================== // Imports //==============================================================...
code_fim
hard
{ "lang": "rust", "repo": "jthelin/demikernel", "path": "/src/rust/catcollar/futures/connect.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ylxdzsw/RedisAlchemy.rs path: /src/map.rs use crate::*; use std::borrow::Borrow; use std::collections::VecDeque; use std::ops::{RangeBounds, Bound}; /// Maps associate fields with values pub struct Map<A, C, K, F, V> { client: C, key: K, field_serializer: fn(x: &F) -> Box<[u8]>, ...
code_fim
hard
{ "lang": "rust", "repo": "ylxdzsw/RedisAlchemy.rs", "path": "/src/map.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { if self.buf.is_empty() { // try to get a batch if self.done { return None } let mut res = self.map.initiate(b"hscan") .arg(&self.cursor) .fetch().expect("Error during ...
code_fim
hard
{ "lang": "rust", "repo": "ylxdzsw/RedisAlchemy.rs", "path": "/src/map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut current_field = None; // the buf is interleaved with fields and values for x in buf.into_iter() { if let Some(field) = current_field { let value = (self.map.value_deserializer)(&x.bytes()); self.buf.push_back((field, v...
code_fim
hard
{ "lang": "rust", "repo": "ylxdzsw/RedisAlchemy.rs", "path": "/src/map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let v =&mut [1, 10, 2, 20, 3, 40, 50, 50, 100, 0]; println!("before {:?}", v); quicksort(&mut v[..]); println!("after {:?}", v); }<|fim_prefix|>// repo: kobi-ca/rust-quicksort path: /src/main.rs #[cfg(test)] mod tests { use super::*; #[test] fn test_basic() { let mut...
code_fim
hard
{ "lang": "rust", "repo": "kobi-ca/rust-quicksort", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kobi-ca/rust-quicksort path: /src/main.rs #[cfg(test)] mod tests { use super::*; #[test] fn test_basic() { let mut v = vec![10, 9, 8, 7, 6, 5, 4, 3, 2, 1]; println!("before {:?}", v); quicksort(&mut v); println!("after {:?}", v); assert!(is_s...
code_fim
hard
{ "lang": "rust", "repo": "kobi-ca/rust-quicksort", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn sort_array(v: &mut [i32]) -> usize { let lowest = 0; let highest = v.len() - 1; let pivot = v[highest]; let mut lowest_idx = lowest; let mut lowest_running = lowest; while lowest_running < highest { if v[lowest_running] <= pivot { v.swap(lowest_running, lowes...
code_fim
medium
{ "lang": "rust", "repo": "kobi-ca/rust-quicksort", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BenjaminHinchliff/rust-opengl-basics path: /src/gl_render/data.rs #[derive(Copy, Clone, Debug)] #[repr(C, packed)] pub struct vec2 { pub x: f32, pub y: f32, } impl vec2 { pub fn new(x: f32, y: f32) -> vec2 { vec2 { x, y } } pub unsafe fn vertex_attrib_pointer( ...
code_fim
hard
{ "lang": "rust", "repo": "BenjaminHinchliff/rust-opengl-basics", "path": "/src/gl_render/data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Copy, Clone, Debug)] #[repr(C, packed)] pub struct U2U10U10U10RevFloat { pub inner: vec_2_10_10_10::Vector, } impl U2U10U10U10RevFloat { pub unsafe fn vertex_attrib_pointer( gl: &gl::Gl, stride: usize, location: usize, offset: usize, ) { gl.Ena...
code_fim
hard
{ "lang": "rust", "repo": "BenjaminHinchliff/rust-opengl-basics", "path": "/src/gl_render/data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HeroicKatora/pundoc path: /src/gen/latex/complex/image.rs use std::io::{Result, Write}; use std::borrow::Cow; use pulldown_cmark::{Tag, Event}; use crate::gen::{State, States, Generator, Document}; #[derive(Debug)] pub struct Image<'a> { dst: Cow<'a, str>, title: Cow<'a, str>, cap...
code_fim
hard
{ "lang": "rust", "repo": "HeroicKatora/pundoc", "path": "/src/gen/latex/complex/image.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let out = gen.get_out(); let (dst, title) = match tag { Tag::Image(dst, title) => (dst, title), _ => unreachable!(), }; writeln!(out, "\\begin{{figure}}")?; writeln!(out, "\\includegraphics{{{}}}", dst)?; Ok(Image { dst,...
code_fim
hard
{ "lang": "rust", "repo": "HeroicKatora/pundoc", "path": "/src/gen/latex/complex/image.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> State<'a> for Image<'a> { fn new(tag: Tag<'a>, gen: &mut Generator<'a, impl Document<'a>, impl Write>) -> Result<Self> { let out = gen.get_out(); let (dst, title) = match tag { Tag::Image(dst, title) => (dst, title), _ => unreachable!(), }; ...
code_fim
medium
{ "lang": "rust", "repo": "HeroicKatora/pundoc", "path": "/src/gen/latex/complex/image.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hangwoo/rust_code_wars path: /string_ends_with/src/main.rs #[cfg(test)] mod tests { use crate::*; #[test] fn returns_expected() { assert_eq!(true, solution("abc", "c")); assert_eq!(false, solution("strawberry", "banana")); assert_eq!(false, solution("banana",...
code_fim
hard
{ "lang": "rust", "repo": "hangwoo/rust_code_wars", "path": "/string_ends_with/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &word[word.len() - ending.len() ..] == ending } pub fn solution3(word: &str, ending: &str) -> bool { word.ends_with(ending) } fn main() { }<|fim_prefix|>// repo: hangwoo/rust_code_wars path: /string_ends_with/src/main.rs #[cfg(test)] mod tests { use crate::*; #[test] fn returns_exp...
code_fim
hard
{ "lang": "rust", "repo": "hangwoo/rust_code_wars", "path": "/string_ends_with/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// impl FakeRequest { // fn with_req(req: reqwest::Response) -> Self { // FakeRequest { // req, // move_by_secs: AtomicUsize::new(0), // } // } // } // impl Request for FakeRequest { // fn get(&self, url: &str) ->...
code_fim
hard
{ "lang": "rust", "repo": "infinite-Joy/smart-open", "path": "/examples/dependency_injection.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: infinite-Joy/smart-open path: /examples/dependency_injection.rs extern crate reqwest; // inspiration https://github.com/cyplo/rust-dependency-injection/blob/master/src/main.rs use reqwest::Error; use std::io::Result; use std::result::Result as StdRes; use std::str; trait Request { fn get(...
code_fim
hard
{ "lang": "rust", "repo": "infinite-Joy/smart-open", "path": "/examples/dependency_injection.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/spi/din_mode.rs #[doc = "Reader of register DIN_MODE"] pub type R = crate::R<u32, super::DIN_MODE>; #[doc = "Writer for register DIN_MODE"] pub type W = crate::W<u32, super::DIN_MODE>; #[doc = "Register DIN_MODE `reset()`'s with value 0"] impl crate::ResetV...
code_fim
hard
{ "lang": "rust", "repo": "ForsakenHarmony/esp32c3-pac", "path": "/src/spi/din_mode.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>_MODE_R { DIN2_MODE_R::new(((self.bits >> 4) & 0x03) as u8) } #[doc = "Bits 2:3"] #[inline(always)] pub fn din1_mode(&self) -> DIN1_MODE_R { DIN1_MODE_R::new(((self.bits >> 2) & 0x03) as u8) } #[doc = "Bits 0:1"] #[inline(always)] pub fn din0_mode(&self) -> ...
code_fim
hard
{ "lang": "rust", "repo": "ForsakenHarmony/esp32c3-pac", "path": "/src/spi/din_mode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: setval/rufy path: /rufy_core/src/error.rs use std::fmt; use std::result::Result as IResult; use std::fmt::{Formatter, Debug}; use std::io; #[derive(Debug, Clone)] pub enum Error { IOError(String), LuaError(String), } pub type Result<T, Error> = IResult<T, Error>; <|fim_suffix|>impl Fr...
code_fim
hard
{ "lang": "rust", "repo": "setval/rufy", "path": "/rufy_core/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Error::IOError(err.to_string()) } } impl From<rlua::Error> for Error { fn from(err: rlua::Error) -> Self { Error::LuaError(err.to_string()) } }<|fim_prefix|>// repo: setval/rufy path: /rufy_core/src/error.rs use std::fmt; use std::result::Result as IResult; use std::fmt::{For...
code_fim
hard
{ "lang": "rust", "repo": "setval/rufy", "path": "/rufy_core/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn into_iter(self) -> Self::IntoIter { (self.tl.y..=self.br.y) .flat_map(|y| (self.tl.x..=self.br.x).map(move |x| ScaledPosition::<N>::new(x, y))) .collect::<Vec<_>>() .into_iter() } } #[cfg(test)] mod test { use super::*; use crate::*; #[t...
code_fim
hard
{ "lang": "rust", "repo": "Bytekeeper/rsbwapi", "path": "/src/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bytekeeper/rsbwapi path: /src/types.rs use bwapi_wrapper::prelude::{Error, ScaledPosition, TilePosition, WalkPosition}; use derive_more::{Add, AddAssign, Sub, SubAssign}; use num_derive::FromPrimitive; use std::ffi::CStr; use std::os::raw::c_char; /// Many functions produce error code. BWAPI us...
code_fim
hard
{ "lang": "rust", "repo": "Bytekeeper/rsbwapi", "path": "/src/types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rdigua/practive path: /rust/100/src/r003-2.rs //The water flower number. fn main() { let keymul = |x: u32| { (x / 100 as u32) * (x / 100 as u32) * (x / 100 as u32) + ((((x / 10) as u32) % 10) as u32) * ((((x / 10) as u32) % 10) as u32) * ((...
code_fim
medium
{ "lang": "rust", "repo": "rdigua/practive", "path": "/rust/100/src/r003-2.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for num in 100..1000 { mul1 = keymul(num); if mul1 == num { print!("{} ", num) } } print!("\n"); }<|fim_prefix|>// repo: rdigua/practive path: /rust/100/src/r003-2.rs //The water flower number. fn main() { let keymul = |x: u32| { (x / 100 as u32) ...
code_fim
medium
{ "lang": "rust", "repo": "rdigua/practive", "path": "/rust/100/src/r003-2.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn get_name(&self) -> &String { return &self.name; } fn display(&mut self) { self.device.set_full_color(self.color.r, self.color.g, self.color.b); } }<|fim_prefix|>// repo: FrankvdStam/rustic_light path: /src/sk621.rs use cooler_master_sdk::CoolerMasterDevice; use ...
code_fim
hard
{ "lang": "rust", "repo": "FrankvdStam/rustic_light", "path": "/src/sk621.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FrankvdStam/rustic_light path: /src/sk621.rs use cooler_master_sdk::CoolerMasterDevice; use cooler_master_sdk::ffi::DeviceIndex; use crate::color::{Color, RgbDevice, RgbMode, RgbSpeed, RgbBrightness}; use std::thread::sleep; use std::time::Duration; <|fim_suffix|> fn get_name(&self) -> &Str...
code_fim
hard
{ "lang": "rust", "repo": "FrankvdStam/rustic_light", "path": "/src/sk621.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut object = self.repo.insert(RepoKey::Stage); object.serialize(&self.id_table)?; drop(object); self.repo.copy(&RepoKey::Stage, RepoKey::IdTable); Ok(()) } /// Create a new `ObjectKey` for the given `object_id`. fn new_id(&self, key_id: KeyId) -> O...
code_fim
hard
{ "lang": "rust", "repo": "maikelwever/acid-store", "path": "/src/repo/state/repository.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maikelwever/acid-store path: /src/repo/state/repository.rs /* * Copyright 2019-2021 Wren Powell * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://w...
code_fim
hard
{ "lang": "rust", "repo": "maikelwever/acid-store", "path": "/src/repo/state/repository.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.write_state()?; self.repo.commit() } fn rollback(&mut self) -> crate::Result<()> { // Create a savepoint on the backing repository so that we can undo rolling back the backing // repository if necessary. This is necessary to uphold the contract that if this me...
code_fim
hard
{ "lang": "rust", "repo": "maikelwever/acid-store", "path": "/src/repo/state/repository.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match lexer.current.clone() { Token::White(_) | Token::Blank => { lexer.next_token()?; if lexer.is_match(stop) { return Ok((lhs, prec)) } return self.parse_binary(lexer, lhs, prec, stop) }, Token::Eol => { let mut nlines = 1; 'outer: loop { lexer.next_token()?; mat...
code_fim
hard
{ "lang": "rust", "repo": "cmann3/stax", "path": "/src/compiler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cmann3/stax path: /src/compiler.rs /* compiler.rs * ----------- */ use crate::code::{Opcode, ConstCode, GenOp, MathOp}; use crate::expr::{Expr, walk_expr, walk_expr_assign}; use crate::lexer::{Lexer, Prec, Token, sprint_token}; use crate::words::{BoolResult}; type ParseResult = Result<Expr, S...
code_fim
hard
{ "lang": "rust", "repo": "cmann3/stax", "path": "/src/compiler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _ => { return Err(format!("Token not recognized for parsing!")) } } return self.ending(lexer, exp, stop) } pub fn parse_until(&mut self, lexer: &mut Lexer, stop: &Vec<Token>) -> Result<Vec<Opcode>, String> { let mut results = Vec::new(); 'outer: while !lexer.is_match(stop) { lexer.skipWhi...
code_fim
hard
{ "lang": "rust", "repo": "cmann3/stax", "path": "/src/compiler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: martell/yuubind path: /smtp-message/fuzz/fuzz_targets/fuzz_data_parser.rs #![no_main] use libfuzzer_sys::fuzz_target; fu<|fim_suffix|>, Vec<usize>)| { smtp_message::fuzz::escaping_then_unescaping(inp.0, inp.1, inp.2, inp.3); });<|fim_middle|>zz_target!(|inp: (Vec<Vec<Vec<u8>>>, usize, usiz...
code_fim
easy
{ "lang": "rust", "repo": "martell/yuubind", "path": "/smtp-message/fuzz/fuzz_targets/fuzz_data_parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>_then_unescaping(inp.0, inp.1, inp.2, inp.3); });<|fim_prefix|>// repo: martell/yuubind path: /smtp-message/fuzz/fuzz_targets/fuzz_data_parser.rs #![no_main] use libfuzzer_sys::fuzz_target; fu<|fim_middle|>zz_target!(|inp: (Vec<Vec<Vec<u8>>>, usize, usize, Vec<usize>)| { smtp_message::fuzz::escapin...
code_fim
medium
{ "lang": "rust", "repo": "martell/yuubind", "path": "/smtp-message/fuzz/fuzz_targets/fuzz_data_parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>, Vec<usize>)| { smtp_message::fuzz::escaping_then_unescaping(inp.0, inp.1, inp.2, inp.3); });<|fim_prefix|>// repo: martell/yuubind path: /smtp-message/fuzz/fuzz_targets/fuzz_data_parser.rs #![no_main] use libfuzzer_sys::fuzz_target; fu<|fim_middle|>zz_target!(|inp: (Vec<Vec<Vec<u8>>>, usize, usiz...
code_fim
easy
{ "lang": "rust", "repo": "martell/yuubind", "path": "/smtp-message/fuzz/fuzz_targets/fuzz_data_parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PacktPublishing/Rust-Programming-Cookbook path: /Chapter06/parameter-ranges/src/lib.rs #![allow(unused_macros)] macro_rules! set { ( $( $item:expr ),* ) => { { let mut s = HashSet::new(); $( s.insert($item); )* s ...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Rust-Programming-Cookbook", "path": "/Chapter06/parameter-ranges/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dto!(Sensordata, value => f32, timestamp => u64); let s = Sensordata::new(1.23f32, 123456); assert_eq!(s.value, 1.23f32); assert_eq!(s.timestamp, 123456); } }<|fim_prefix|>// repo: PacktPublishing/Rust-Programming-Cookbook path: /Chapter06/parameter-ranges/src/...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Rust-Programming-Cookbook", "path": "/Chapter06/parameter-ranges/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_dto() { dto!(Sensordata, value => f32, timestamp => u64); let s = Sensordata::new(1.23f32, 123456); assert_eq!(s.value, 1.23f32); assert_eq!(s.timestamp, 123456); } }<|fim_prefix|>// repo: PacktPublishing/Rust-Programming-Cookbook path: ...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Rust-Programming-Cookbook", "path": "/Chapter06/parameter-ranges/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>//pub fn write_json<T: rustc_serialize::Encodable>( path: &Path, data: &T ) { // let mut file = File::create( path ).unwrap(); // println!("Encoding file {}", path.to_str().unwrap() ); // // let string = json::encode( data ).unwrap(); // let bytes : &[u8] = string.as_bytes(); // // println!("Writing file ...
code_fim
hard
{ "lang": "rust", "repo": "austinjones/elitetrader", "path": "/src/data/trader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: austinjones/elitetrader path: /src/data/trader.rs use serde::Deserialize; use serde::Serialize; use spatial::octree::Index; use std::str::FromStr; pub trait Identified<K> { fn to_id(&self) -> K; } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct System { pub system_id: u32, ...
code_fim
hard
{ "lang": "rust", "repo": "austinjones/elitetrader", "path": "/src/data/trader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vinnyhoward/til path: /rust/toy-problems/strings/reversed_strings.rs // Reversed Strings // Complete the solution so that it reverses the string passed into it. <|fim_suffix|>fn main() { fn solution(phrase: &str) -> String { phrase.chars().rev().collect() } println!("{}",...
code_fim
easy
{ "lang": "rust", "repo": "vinnyhoward/til", "path": "/rust/toy-problems/strings/reversed_strings.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> phrase.chars().rev().collect() } println!("{}", solution("hello world")); // alt solution // fn solution(phrase: &str) -> String { // return phrase.chars().rev().collect::<String>(); // } }<|fim_prefix|>// repo: vinnyhoward/til path: /rust/toy-problems/strings/revers...
code_fim
easy
{ "lang": "rust", "repo": "vinnyhoward/til", "path": "/rust/toy-problems/strings/reversed_strings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn function_with_multiple_params(x: i32, y: i32) { println!("The value of x in function_with_multiple_params is: {}", x); println!("The value of y in function_with_multiple_params is: {}", y); } // function with return value fn five() -> i32 { 5 } fn plus_one(x: i32) -> i32 { x + 1 }<|...
code_fim
hard
{ "lang": "rust", "repo": "darnosls/rust-code-examples", "path": "/functions/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darnosls/rust-code-examples path: /functions/src/main.rs fn main() { println!("Hello, world!"); another_function(5); function_with_multiple_params(4,3); let x = 5; let y = { let x = 3; x + 1 }; <|fim_suffix|> println!("The value of x is: {}", x); } ...
code_fim
hard
{ "lang": "rust", "repo": "darnosls/rust-code-examples", "path": "/functions/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if remove { return contents.split_off(contents.len() - size); } contents .iter() .skip(contents.len() - size) .cloned() .collect::<Vec<u8>>() } } struct Prefix; impl Capture for Prefix { fn capture(&self, content...
code_fim
hard
{ "lang": "rust", "repo": "moppius/quilkin", "path": "/src/filters/extensions/capture_bytes.rs", "mode": "spm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moppius/quilkin path: /src/filters/extensions/capture_bytes.rs /* * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www...
code_fim
hard
{ "lang": "rust", "repo": "moppius/quilkin", "path": "/src/filters/extensions/capture_bytes.rs", "mode": "psm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn capture_bytes(config: Config) -> CaptureBytes { CaptureBytes::new( &logger(), config, Metrics::new(&Registry::default()).unwrap(), ) } #[test] fn convert_proto_config() { let test_cases = vec![ ( "s...
code_fim
hard
{ "lang": "rust", "repo": "moppius/quilkin", "path": "/src/filters/extensions/capture_bytes.rs", "mode": "spm", "license": "MPL-2.0", "source": "the-stack-v2" }