text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: ToonSpin/advent-of-code-2017-rust path: /src/bin/day08.rs use std::io; use std::io::prelude::*; use std::collections::HashMap; use nom::{ branch::alt, bytes::complete::tag, character::complete::{alpha1, digit1}, combinator::{map, map_res, opt, recognize}, multi::separated_l...
code_fim
hard
{ "lang": "rust", "repo": "ToonSpin/advent-of-code-2017-rust", "path": "/src/bin/day08.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> io::Result<()> { let mut input = String::new(); io::stdin().lock().read_to_string(&mut input).unwrap(); let input = &input[..]; let (_rest, instructions) = parse_instructions(input).unwrap(); let mut registers: HashMap<&str, i32> = HashMap::new(); let mut max_reg_val ...
code_fim
hard
{ "lang": "rust", "repo": "ToonSpin/advent-of-code-2017-rust", "path": "/src/bin/day08.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> xs.sort_by_key(|x| match x { Item::Type(_) => 0, Item::Struct(_) => 1, Item::Const(_) => 2, Item::Fn(_) => 3, Item::Enum(_) => 4, Item::Union(_) => 5, Item::Static(_) => 6, Item::Trait(_) => 7, ...
code_fim
hard
{ "lang": "rust", "repo": "quantapix/qnarre", "path": "/tools/bindgen/src/codegen/post.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> visit_items(&mut x.items); visit_file_mut(self, x) } fn visit_item_mod_mut(&mut self, x: &mut ItemMod) { if let Some((_, ref mut xs)) = x.content { visit_items(xs); } visit_item_mod_mut(self, x) } } ...
code_fim
hard
{ "lang": "rust", "repo": "quantapix/qnarre", "path": "/tools/bindgen/src/codegen/post.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quantapix/qnarre path: /tools/bindgen/src/codegen/post.rs use crate::Opts; use proc_macro2::TokenStream; use quote::ToTokens; use syn::{parse2, File}; mod merge { use syn::{ visit_mut::{visit_file_mut, visit_item_mod_mut, VisitMut}, File, Item, ItemForeignMod, ItemMod, }...
code_fim
hard
{ "lang": "rust", "repo": "quantapix/qnarre", "path": "/tools/bindgen/src/codegen/post.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let rsp = client.describe_regions().send().await?; for region in rsp.regions.unwrap_or_default() { println!("region: {:#?}", region.region_name.unwrap()); } Ok(()) }<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/examples/ec2/src/bin/ec2-helloworld.rs /* * Copyright Amazon...
code_fim
medium
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/examples/ec2/src/bin/ec2-helloworld.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/examples/ec2/src/bin/ec2-helloworld.rs /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ <|fim_suffix|>#[tokio::main] async fn main() -> Result<(), aws_sdk_ec2::Error> { let shared_config = aws...
code_fim
medium
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/examples/ec2/src/bin/ec2-helloworld.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialicons/maps/icon_car_repair.rs pub struct IconCarRepair { props: crate::Props, } impl yew::Component for IconCarRepair { type Properties = crate::Props; type Message = (); fn create(props: Self::Properties, _: yew::prelude::Compon...
code_fim
medium
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialicons/maps/icon_car_repair.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // dbg!(x, y); let (x, y) = trans.latlon_to_pixels(40.0, 85.0, 1.7); dbg!(x, y); let (x1, y1) = trans.latlon_to_pixels(-4.0, 155.0, 1.7); dbg!(x1 - x, y - y1); }<|fim_prefix|>// repo: oldtree2008/met-io-rs path: /bin/mercatortrans.rs use met_io_rs::mercator_trans::*; fn main() { <|fim...
code_fim
medium
{ "lang": "rust", "repo": "oldtree2008/met-io-rs", "path": "/bin/mercatortrans.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oldtree2008/met-io-rs path: /bin/mercatortrans.rs use met_io_rs::mercator_trans::*; fn main() { <|fim_suffix|> // dbg!(x, y); let (x, y) = trans.latlon_to_pixels(40.0, 85.0, 1.7); dbg!(x, y); let (x1, y1) = trans.latlon_to_pixels(-4.0, 155.0, 1.7); dbg!(x1 - x, y - y1); }<|fim...
code_fim
medium
{ "lang": "rust", "repo": "oldtree2008/met-io-rs", "path": "/bin/mercatortrans.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Swipe let swipe = gtk::GestureSwipe::new(&stack.stack); swipe.connect_swipe(move |_swipe, swipe_x, _swipe_y| { match swipe_x < 0f64 { true => {stack.next_window()}, false => {stack.prev_window()}, }; }); window.show_all(); gtk::main(); }...
code_fim
medium
{ "lang": "rust", "repo": "zzeroo/gtk-stack-swipe", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zzeroo/gtk-stack-swipe path: /src/main.rs // Diese Includes sind alle nötig extern crate gdk; extern crate gtk; use gdk::enums::*; use gtk::prelude::*; mod stack; use stack::Stack; fn main() { <|fim_suffix|> // Construct the StackSwitcher for i in &["Sensor 1", "Sensor 2", "Sensor 3", "Ei...
code_fim
hard
{ "lang": "rust", "repo": "zzeroo/gtk-stack-swipe", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let box_main = gtk::Box::new(gtk::Orientation::Horizontal, 0); let mut stack = Stack::new(); box_main.pack_start(&stack.stack, true, true, 0); // Construct the StackSwitcher for i in &["Sensor 1", "Sensor 2", "Sensor 3", "Einstellungen"] { stack.create_windows(&i.to_string());...
code_fim
hard
{ "lang": "rust", "repo": "zzeroo/gtk-stack-swipe", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match args.subcommand() { ("read", _) => { let mut m = pzem004t::Measurement::default(); match pzem.read(&mut m, timeout) { Err(e) => die!("Could not read PZEM004T: {}", e), Ok(()) => { println!("Voltage: {:.1} V", m.v...
code_fim
hard
{ "lang": "rust", "repo": "iostapyshyn/pzem-cli", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let uart = args.value_of("PORT").unwrap(); // Calling .unwrap() is safe here because "PORT" is required let uart = Uart { port: serialport::open(uart).unwrap_or_else(|e| die!("Cannot open `{}`: {}.", uart, e)), }; let mut pzem = pzem004t::Pzem::new(uart, addr).unwrap_or_el...
code_fim
hard
{ "lang": "rust", "repo": "iostapyshyn/pzem-cli", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iostapyshyn/pzem-cli path: /src/main.rs extern crate clap; extern crate pzem004t; mod hal_impl; use hal_impl::*; use clap::Arg; use clap::SubCommand; macro_rules! die { ($fmt:expr) => ({ eprintln!($fmt); std::process::exit(-1) }); ($fmt:expr, $($arg:tt)*) => ({ eprintln!($fmt, $($arg)...
code_fim
hard
{ "lang": "rust", "repo": "iostapyshyn/pzem-cli", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(parse("iiisdoso"), vec![8, 64]); assert_eq!(parse("iiisdosodddddiso"), vec![8, 64, 3600]); }<|fim_prefix|>// repo: boybird/codewarust path: /src/make_the_deadfish_swim.rs fn parse(code: &str) -> Vec<i32> { let mut r = vec![]; let mut sum = 0; for i in code.c...
code_fim
easy
{ "lang": "rust", "repo": "boybird/codewarust", "path": "/src/make_the_deadfish_swim.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boybird/codewarust path: /src/make_the_deadfish_swim.rs fn parse(code: &str) -> Vec<i32> { let mut r = vec![]; let mut sum = 0; for i in code.chars() { match i { 'i' => {sum=sum+1;}, 'd' => {sum=sum-1;}, 's' => {sum=sum*sum}, 'o...
code_fim
easy
{ "lang": "rust", "repo": "boybird/codewarust", "path": "/src/make_the_deadfish_swim.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lrlex_mod!("lib/compiler/som.l"); lrpar_mod!("lib/compiler/som.y"); type StorageT = u32; /// Compile a class. Should only be called by the `VM`. pub fn compile(vm: &VM, path: &Path) -> Class { let bytes = fs::read(path).unwrap_or_else(|_| panic!("Can't read {}.", path.to_str().unwrap())); let tx...
code_fim
medium
{ "lang": "rust", "repo": "ummarikar/yksom", "path": "/src/lib/compiler/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let lexerdef = som_l::lexerdef(); let lexer = lexerdef.lexer(&txt); let (astopt, errs) = som_y::parse(&lexer); for e in &errs { eprintln!("{}", e.pp(&lexer, &som_y::token_epp)); } match astopt { Some(Ok(astcls)) => { let cls = ast_to_instrs::Compiler::co...
code_fim
hard
{ "lang": "rust", "repo": "ummarikar/yksom", "path": "/src/lib/compiler/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ummarikar/yksom path: /src/lib/compiler/mod.rs //! A SOM compiler. This is currently fairly simplistic, particularly in terms of code generation //! (though it does at least use [lrpar](https://crates.io/crates/lrpar), so one gets decent error //! messages). The interchange format between the co...
code_fim
medium
{ "lang": "rust", "repo": "ummarikar/yksom", "path": "/src/lib/compiler/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.capnp_as_ref().fmt(f) } } impl fmt::Display for RequestVoteResRef<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "voteRes({:} granted={:?})", self.term().0, self.vote_granted()) } } impl fmt::Debug for RequestVoteResShared { fn fmt(&se...
code_fim
hard
{ "lang": "rust", "repo": "danhhz/rast", "path": "/src/serde.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danhhz/rast path: /src/serde.rs // Copyright 2020 Daniel Harrison. All Rights Reserved. use std::fmt; use std::ops::Add; /// A Raft term. #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Term(pub u64); /// A Raft index. #[derive(Debug, Copy, Clone, PartialEq, Eq,...
code_fim
hard
{ "lang": "rust", "repo": "danhhz/rast", "path": "/src/serde.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jneem/bibtex-rs path: /bst/src/lexer.rs use std::io; use common::Input; #[derive(Debug, PartialEq)] pub enum LexClass { Illegal, WhiteSpace, SepChar, Numeric, Alpha, Other, } // TODO: record the position (line/col) #[derive(Debug, PartialEq)] pub enum LexError { Il...
code_fim
hard
{ "lang": "rust", "repo": "jneem/bibtex-rs", "path": "/bst/src/lexer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Ok(-34), input.scan_integer()); input.skip_white_space(); assert_eq!(Ok(46), input.scan_integer()); input.skip_white_space(); assert_eq!(Err(LexError::IllegalStartOfIntLiteral(b' ')), input.scan_integer()); input.skip_white_space(); assert...
code_fim
hard
{ "lang": "rust", "repo": "jneem/bibtex-rs", "path": "/bst/src/lexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn scan_string(&mut self) -> Result<Vec<u8>, LexError> { debug_assert!(self.current() == b'"'); self.advance(); let len = self.count(|c| c != b'"'); if len >= self.buffer().len() { // If the string is unterminated, skip the rest of the line. sel...
code_fim
hard
{ "lang": "rust", "repo": "jneem/bibtex-rs", "path": "/bst/src/lexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jascha-N/rduino path: /rduino/src/time.rs //! Timing related functions. //! //! **Note**: Many of these functions do not work properly when interrupts are disabled, which is //! generally the case inside of interrupt service routines, when a mutex lock is held or inside //! of a panic hook. use...
code_fim
hard
{ "lang": "rust", "repo": "Jascha-N/rduino", "path": "/rduino/src/time.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Wait until the given amount of milliseconds have passed. /// /// **Warning**: This function might cause a deadlock when interrupts are disabled. pub fn sleep_millisecs(ms: u32) { unsafe { ffi::rduino_delay(ms); } } /// Wait until the given amount of microseconds have passed. pub fn sl...
code_fim
hard
{ "lang": "rust", "repo": "Jascha-N/rduino", "path": "/rduino/src/time.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stevej/rust-abt path: /src/view.rs pub trait Into<V, O, A> { fn into(self) -> A; <|fim_suffix|>#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub enum View<V, O, A> { Var(V), Abs(V, A), App(O, Vec<A>), }<|fim_middle|>} pub trait From<V, O>: Eq where View<V, O, Self>: In...
code_fim
medium
{ "lang": "rust", "repo": "stevej/rust-abt", "path": "/src/view.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub enum View<V, O, A> { Var(V), Abs(V, A), App(O, Vec<A>), }<|fim_prefix|>// repo: stevej/rust-abt path: /src/view.rs pub trait Into<V, O, A> { fn into(self) -> A; } <|fim_middle|>pub trait From<V, O>: Eq where View<V, O, Self>: In...
code_fim
medium
{ "lang": "rust", "repo": "stevej/rust-abt", "path": "/src/view.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self.0 } unsafe fn edge_call(&mut self) { let edge_mem = self.edge_mem(); let mut edge_stream = QemuEdgeStream(crate::arch::x86_vm::qemu::SERIAL_EDGE.lock()); // write request edge_mem.serialize(&mut edge_stream); // read result edge_me...
code_fim
hard
{ "lang": "rust", "repo": "kingkongtree/new-tee-os", "path": "/hal/src/sys/x86_vm/edge.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kingkongtree/new-tee-os path: /hal/src/sys/x86_vm/edge.rs use spin::{Mutex, MutexGuard}; use uart_16550::SerialPort; use crate::edge::{EdgeCallerHolder, EdgeMemory, EdgeStream, GlobalEdgeCaller}; pub struct QemuGlobalEdgeCaller(Mutex<EdgeMemory>); pub struct QemuEdgeCallerHolder<'l>(MutexGuard...
code_fim
medium
{ "lang": "rust", "repo": "kingkongtree/new-tee-os", "path": "/hal/src/sys/x86_vm/edge.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl EdgeStream for QemuEdgeStream<'_> { fn read(&mut self) -> u8 { self.0.receive() } fn write(&mut self, ch: u8) { self.0.send_binary(ch); } }<|fim_prefix|>// repo: kingkongtree/new-tee-os path: /hal/src/sys/x86_vm/edge.rs use spin::{Mutex, MutexGuard}; use uart_16550::...
code_fim
hard
{ "lang": "rust", "repo": "kingkongtree/new-tee-os", "path": "/hal/src/sys/x86_vm/edge.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn measure_text(text: &str, scale: u32) -> (u32, u32) { let mut cursor_x = 0; for glyph in text.chars().map(Glyph::find_by_char) { cursor_x += glyph.0 as u32 * scale; } cursor_x -= GLYPH_SPACING * scale; (cursor_x, GLYPH_HEIGHT as u32 * scale) } pub fn line_spacing(scale:...
code_fim
hard
{ "lang": "rust", "repo": "bluecube/planetjump", "path": "/src/client/font.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bluecube/planetjump path: /src/client/font.rs extern crate sdl2; use font_data::*; impl Glyph { fn draw(self, renderer: &mut sdl2::render::Renderer, x: i32, y: i32, scale: u32) { for (i, bits) in self.1.into_iter().enumerate() { for j in 0..8 { ...
code_fim
hard
{ "lang": "rust", "repo": "bluecube/planetjump", "path": "/src/client/font.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return GLYPHS[index]; } } pub fn draw_text(text: &str, renderer: &mut sdl2::render::Renderer, x: i32, y: i32, scale: u32) { let mut cursor_x = x; for glyph in text.chars().map(Glyph::find_by_char) { glyph.draw(renderer, cursor_x, y, scale); ...
code_fim
hard
{ "lang": "rust", "repo": "bluecube/planetjump", "path": "/src/client/font.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl ICU4XTime { /// Creates a new [`ICU4XTime`] given field values #[diplomat::rust_link(icu::calendar::types::Time, Struct)] pub fn create( hour: u8, minute: u8, second: u8, nanosecond: u32, ) -> Result<Box<ICU4XTime>, I...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/icu_capi/src/time.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/icu_capi/src/time.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 ). #[diplomat::bridge] pub mod ff...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/icu_capi/src/time.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sile/gp path: /src/kernels.rs use crate::vector::Vector; pub trait Kernel<X> { fn call(&self, x0: &X, x1: &X) -> f64; } <|fim_suffix|> let a = (x0 - x1).powi(2); let b = self.length_scale.powi(2); (-a / b).exp() } } impl Kernel<Vector> for GaussianKernel { fn...
code_fim
hard
{ "lang": "rust", "repo": "sile/gp", "path": "/src/kernels.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let a = x0 .iter() .zip(x1.iter()) .map(|(x0, x1)| (x0 - x1).powi(2)) .sum::<f64>(); let b = self.length_scale.powi(2); (-a / b).exp() } }<|fim_prefix|>// repo: sile/gp path: /src/kernels.rs use crate::vector::Vector; pub trait ...
code_fim
hard
{ "lang": "rust", "repo": "sile/gp", "path": "/src/kernels.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mun-lang/mun path: /crates/mun_abi/src/type_lut.rs use std::ffi::CStr; use std::os::raw::c_char; use std::{ffi, slice, str}; use itertools::izip; use crate::type_id::TypeId; /// Represents a lookup table for type information. This is used for runtime linking. /// /// Type IDs and handles are ...
code_fim
hard
{ "lang": "rust", "repo": "mun-lang/mun", "path": "/crates/mun_abi/src/type_lut.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let type_name = CString::new(FAKE_TYPE_NAME).expect("Invalid fake type name."); let prototype = &[FAKE_TYPE_ID]; let type_ptrs = &mut [ptr::null()]; let type_names = &[type_name.as_ptr()]; let type_lut = fake_type_lut(prototype, type_ptrs, type_names); ass...
code_fim
hard
{ "lang": "rust", "repo": "mun-lang/mun", "path": "/crates/mun_abi/src/type_lut.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn purge(&self); } struct Filter<M> where M: Send { accept: Box<dyn Fn(&M) -> bool>, sender: Sender<M>, } pub struct PubSub<M = Message> where M: Send { filters: Vec<Filter<M>>, } pub trait Outbox<M = Message> { fn post(&self, message: M); } pub trait Whiteboard<M = Message> where M: Send + Clone...
code_fim
hard
{ "lang": "rust", "repo": "destenson/itadinanta--rust-oids", "path": "/src/backend/messagebus/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: destenson/itadinanta--rust-oids path: /src/backend/messagebus/mod.rs use app::Event; use backend::world::alert::Alert; use backend::world::particle::Emitter; use std::sync::mpsc; use std::sync::mpsc::{Receiver, Sender}; #[derive(Clone)] pub enum Message { Alert(Alert), Event(Event), NewEmitt...
code_fim
hard
{ "lang": "rust", "repo": "destenson/itadinanta--rust-oids", "path": "/src/backend/messagebus/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Honey-Be/fireplace path: /fireplace_lib/src/handlers/workspaces/modes/floating.rs use handlers::geometry::UsableScreenGeometry; use handlers::store::{Store, StoreKey}; use handlers::workspaces::modes::Mode; use slog; use slog_scope; use std::cmp; use wlc::{Button, ButtonState, Callback, Geomet...
code_fim
hard
{ "lang": "rust", "repo": "Honey-Be/fireplace", "path": "/fireplace_lib/src/handlers/workspaces/modes/floating.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn pointer_button(&mut self, _view: Option<&View>, _time: u32, _modifiers: Modifiers, button: Button, state: ButtonState, _origin: Point) -> bool { if let Some(ref view) = self.active_view { view.run(|view| if state == ButtonState::Releas...
code_fim
hard
{ "lang": "rust", "repo": "Honey-Be/fireplace", "path": "/fireplace_lib/src/handlers/workspaces/modes/floating.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match state { x if x.contains(ViewState::Moving) && !toggle => view.set_state(ViewState::Moving, false), x if x.contains(ViewState::Moving) && toggle => info!(self.logger, "Moving true?"), x if x.contains(ViewState::Resizing) && !toggle => view.set_state(ViewSta...
code_fim
hard
{ "lang": "rust", "repo": "Honey-Be/fireplace", "path": "/fireplace_lib/src/handlers/workspaces/modes/floating.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/mir-opt/building/custom/as_cast.rs #![feature(custom_mir, core_intrinsics)] extern crate core; use core::intrinsics::mir::*; // EMIT_MIR as_cast.int_to_int.built.after.mir #[custom_mir(dialect = "built")] fn int_to_int(x: u32) -> i32 { mir!( { ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/mir-opt/building/custom/as_cast.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> mir!( { RET = x as i32; Return() } ) } // EMIT_MIR as_cast.int_to_ptr.built.after.mir #[custom_mir(dialect = "built")] fn int_to_ptr(x: usize) -> *const i32 { mir!( { RET = x as *const i32; Return() } ) } fn ...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/mir-opt/building/custom/as_cast.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(int_to_int(5), 5); assert_eq!(float_to_int(5.), 5); assert_eq!(int_to_ptr(0), std::ptr::null()); }<|fim_prefix|>// repo: rust-lang/rust path: /tests/mir-opt/building/custom/as_cast.rs #![feature(custom_mir, core_intrinsics)] extern crate core; use core::intrinsics::mir::*; // EMI...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/mir-opt/building/custom/as_cast.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Maps winit's mouse button to conrod's mouse button. pub fn map_mouse(mouse_button: MouseButton) -> input::MouseButton { use input::MouseButton; match mouse_button { winit::event::MouseButton::Left => MouseButton::Left, winit::event::MouseButton::Right => MouseButton::Right, ...
code_fim
hard
{ "lang": "rust", "repo": "fschlee/eco_sim", "path": "/gui/src/ui/conrod_winit_helper.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fschlee/eco_sim path: /gui/src/ui/conrod_winit_helper.rs use conrod_core::{cursor, event::Input, input, Scalar}; use conrod_winit::WinitWindow; use winit::{ dpi::{LogicalPosition, LogicalSize}, event::{ ElementState, Event, MouseButton, MouseScrollDelta, Touch, TouchPhase, Virtua...
code_fim
hard
{ "lang": "rust", "repo": "fschlee/eco_sim", "path": "/gui/src/ui/conrod_winit_helper.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match keycode { VirtualKeyCode::Key0 => Key::D0, VirtualKeyCode::Key1 => Key::D1, VirtualKeyCode::Key2 => Key::D2, VirtualKeyCode::Key3 => Key::D3, VirtualKeyCode::Key4 => Key::D4, VirtualKeyCode::Key5 => Key::D5, VirtualKeyCode::Key6 => Key::D6,...
code_fim
hard
{ "lang": "rust", "repo": "fschlee/eco_sim", "path": "/gui/src/ui/conrod_winit_helper.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// 401 Unauthorized pub fn unauthorized(mut error: &str) -> HttpResponse { if error.len() == 0 { error = "AU0000" } HttpResponse::Unauthorized().json(ErrorResBody { error: error.to_string() }) } /// 500 Internal Server Error pub fn internal_server_error() -> HttpResponse { HttpRe...
code_fim
hard
{ "lang": "rust", "repo": "lynlab/lynlab-auth-rust", "path": "/src/helpers/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lynlab/lynlab-auth-rust path: /src/helpers/api.rs use actix_web::HttpResponse; #[derive(Debug, Serialize)] struct ErrorResBody { error: String, } <|fim_suffix|>/// 500 Internal Server Error pub fn internal_server_error() -> HttpResponse { HttpResponse::InternalServerError().finish() }...
code_fim
hard
{ "lang": "rust", "repo": "lynlab/lynlab-auth-rust", "path": "/src/helpers/api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gregparsons/actor_actix_crossbeam path: /src/main.rs mod heartbeat_actor; mod actor_tools; mod logger_actor;/* Learning Actix actors. Ref: https://actix.rs/book/actix/sec-2-actor.html 9/23/2020 */ use actix::{Actor}; use actor_tools::MsgEnum; use logger_actor::LoggerActor; use heartbeat_ac...
code_fim
medium
{ "lang": "rust", "repo": "gregparsons/actor_actix_crossbeam", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // let cnt_addr = SyncArbiter::start(1,move || // CounterActor{ // name:String::from("counter001"), // printer_actor:printer_addr.clone(), // } // ); // let _ = cnt_addr.send(MsgEnum::StartCounter).await; }<|fim_prefix|>// repo: gregparsons/actor_actix_crossbeam path: /src/main.rs mod heart...
code_fim
hard
{ "lang": "rust", "repo": "gregparsons/actor_actix_crossbeam", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut opts = OpenOptions::readwrite(); let opts = opts.nonblocking().capacity(1).max_msg_len(10).create_new(); let mq_a = opts.open("/mio_a").unwrap(); let mq_b = opts.open("/mio_b").unwrap(); let _ = remove_queue("/mio_a"); let _ = remove_queue("/mio_b"); poll.registry().re...
code_fim
hard
{ "lang": "rust", "repo": "tormol/posixmq", "path": "/tests/fd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use std::io::ErrorKind; use posixmq::OpenOptions; use mio_07::{Events, Poll, Interest, Token}; // Start the poll before creating masseage queues so that the syscalls are // easier to separate when debugging. let mut events = Events::with_capacity(8); let mut poll = Poll::new()...
code_fim
hard
{ "lang": "rust", "repo": "tormol/posixmq", "path": "/tests/fd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tormol/posixmq path: /tests/fd.rs //! Tests of file descriptor based features. extern crate posixmq; use posixmq::{PosixMq, remove_queue}; use std::io::ErrorKind; #[test] fn is_cloexec() { let mq = PosixMq::create("/is_cloexec").unwrap(); let _ = remove_queue("/is_cloexec"); if cf...
code_fim
hard
{ "lang": "rust", "repo": "tormol/posixmq", "path": "/tests/fd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elitecodegroovy/thinking-in-rust path: /app11/src/lib.rs #![warn(clippy::all)] pub use handle_errors; use tokio::sync::{oneshot, oneshot::Sender}; use tracing_subscriber::fmt::format::FmtSpan; use warp::{http::Method, Filter, Reply}; pub mod config; mod profanity; mod routes; mod store; pub m...
code_fim
hard
{ "lang": "rust", "repo": "elitecodegroovy/thinking-in-rust", "path": "/app11/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn run(config: config::Config, store: store::Store) { let routes = build_routes(store).await; warp::serve(routes).run(([0, 0, 0, 0], config.port)).await; } pub async fn oneshot(store: store::Store) -> OneshotHandler { let routes = build_routes(store).await; let (tx, rx) = onesho...
code_fim
hard
{ "lang": "rust", "repo": "elitecodegroovy/thinking-in-rust", "path": "/app11/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> get_questions .or(update_question) .or(add_question) .or(delete_question) .or(add_answer) .or(registration) .or(login) .with(cors) .with(warp::trace::request()) .recover(handle_errors::return_error) } pub async fn setup_store(con...
code_fim
hard
{ "lang": "rust", "repo": "elitecodegroovy/thinking-in-rust", "path": "/app11/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// An enum representing the different kind of Errors that can be returned within the library #[derive(Debug)] pub enum Error { /// An error resulting from an underlying call to reqwest ReqwestError(reqwest::Error), /// An error resulting from an underlying call to serde SerdeError(serde_j...
code_fim
hard
{ "lang": "rust", "repo": "luke-moss-dev/datamuse-api-wrapper", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luke-moss-dev/datamuse-api-wrapper path: /src/lib.rs #![deny( //These lint options are copied from https://pascalhertleif.de/artikel/good-practices-for-writing-rust-libraries/ missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_nu...
code_fim
hard
{ "lang": "rust", "repo": "luke-moss-dev/datamuse-api-wrapper", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl DatamuseClient { /// Returns a new DatamuseClient struct pub fn new() -> Self { DatamuseClient { client: reqwest::Client::new(), } } /// Returns a new [RequestBuilder](request::RequestBuilder) struct with which requests can be created /// and later sen...
code_fim
hard
{ "lang": "rust", "repo": "luke-moss-dev/datamuse-api-wrapper", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jasperav/cdrs-tokio path: /tests/collection_types.rs sts")] use cdrs_tokio::types::blob::Blob; #[cfg(feature = "e2e-tests")] use cdrs_tokio::types::list::List; #[cfg(feature = "e2e-tests")] use cdrs_tokio::types::map::Map; #[cfg(feature = "e2e-tests")] use cdrs_tokio::types::AsRust; #[cfg(featur...
code_fim
hard
{ "lang": "rust", "repo": "Jasperav/cdrs-tokio", "path": "/tests/collection_types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(rows.len(), 1); for row in rows { let my_text_set_row: Vec<String> = row .r_by_name::<List>("my_text_set") .expect("my_text_set") .as_r_rust() .expect("my_text_set as rust"); let my_nested_set_outer_row: Vec<List> = row ...
code_fim
hard
{ "lang": "rust", "repo": "Jasperav/cdrs-tokio", "path": "/tests/collection_types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::test] #[cfg(feature = "e2e-tests")] async fn map() { let cql = "CREATE TABLE IF NOT EXISTS cdrs_test.test_maps \ (my_text_map frozen<map<text, text>> PRIMARY KEY, \ my_nested_map map<uuid, frozen<map<bigint, blob>>>)"; let session = setup(cql).await.expect("s...
code_fim
hard
{ "lang": "rust", "repo": "Jasperav/cdrs-tokio", "path": "/tests/collection_types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adeboyed/Parliament path: /MemberOfParliament/src/main.rs /* Parliament - A distributed general-purpose cluster-computing framework for OCaml Copyright (c) 2018-2019 [Name REDACTED] [Email REDACTED] */ extern crate beanstalkd; extern crate byteorder; extern crate clap; extern crate core;...
code_fim
hard
{ "lang": "rust", "repo": "adeboyed/Parliament", "path": "/MemberOfParliament/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (@arg CONFIG: -c --config +takes_value "Sets a custom config file") (@arg SINGLE_RUN_MODE: -s --oneshot +takes_value "Only processes one job before finishing") (@arg TIMEOUT: -t --timeout +takes_value "No. of seconds to termination after no message received from master") ...
code_fim
hard
{ "lang": "rust", "repo": "adeboyed/Parliament", "path": "/MemberOfParliament/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Load in worker config let matches = clap_app!(member_of_parliament => (version: "0.3") (author: "[NAME REDACTED] [EMAIL REDACTED]") (about: "Worker implementation for a Parliament cluster") (@arg CONFIG: -c --config +takes_value "Sets a custom config file") ...
code_fim
hard
{ "lang": "rust", "repo": "adeboyed/Parliament", "path": "/MemberOfParliament/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ymtdzzz/deno-ls-init path: /src/lib.rs extern crate directories; extern crate pathdiff; #[macro_use] extern crate serde_json; use anyhow::{Result}; use directories::BaseDirs; use pathdiff::diff_paths; use serde_json::Value; use std::env::current_dir; #[derive(Debug)] pub struct ConfigInfo { ...
code_fim
hard
{ "lang": "rust", "repo": "ymtdzzz/deno-ls-init", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn mix() { let config = config_gen(); let test_str = r#" { "compilerOptions": { "baseUrl": ".", "paths": { "pathA": "/path/to/path/A", "pathB": "/path/to/path/B" }, "plugins": [ { "name": "plugin-A" }, { "name"...
code_fim
hard
{ "lang": "rust", "repo": "ymtdzzz/deno-ls-init", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[fail(display = "rdata field {} with type {} isn't valid: {}", _1, _0, _2)] InvalidRdataString(&'static str, &'static str, String), #[fail( display = "label seqences in concat_all, the last is absolute and others are not absolute" )] InvalidLabelSequnceConcatParam, }<|fim_pre...
code_fim
hard
{ "lang": "rust", "repo": "zdnscloud/r53", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zdnscloud/r53 path: /src/error.rs use failure::Fail; #[derive(Debug, Fail)] pub enum DNSError { #[fail(display = "wire data is incomplete")] InCompleteWire, #[fail(display = "name is too long")] TooLongName, #[fail(display = "label is too long")] TooLongLabel, <|fim_s...
code_fim
hard
{ "lang": "rust", "repo": "zdnscloud/r53", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[fail(display = "name isn't complete")] InCompleteName, #[fail(display = "length of rdata isn't correct")] RdataLenIsNotCorrect, #[fail(display = "invalid ipv4 address")] InvalidIPv4Address, #[fail(display = "invalid ipv6 address")] InvalidIPv6Address, #[fail(displ...
code_fim
hard
{ "lang": "rust", "repo": "zdnscloud/r53", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32l1/src/stm32l100/opamp/otr.rs #[doc = "Reader of register OTR"] pub type R = crate::R<u32, super::OTR>; #[doc = "Writer for register OTR"] pub type W = crate::W<u32, super::OTR>; #[doc = "Register OTR `reset()`'s with value 0"] impl crate::ResetValue ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32l1/src/stm32l100/opamp/otr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[doc = "Bits 0:9 - OPAMP1, 10-bit offset trim value for normal mode"] #[inline(always)] pub fn ao1_opt_offset_trim(&self) -> AO1_OPT_OFFSET_TRIM_R { AO1_OPT_OFFSET_TRIM_R::new((self.bits & 0x03ff) as u16) } } impl W { #[doc = "Bit 31 - Select user or factory trimming value"] #...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32l1/src/stm32l100/opamp/otr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.checked_sub(&other).ok_or(OverflowError) } } /// Dedicated error that indicates that some math has encountered unexpected arithmetic overflow. /// /// A dedicated error type for arithmetic overflow not only better represents intended meaning, /// but allows us to use the full power of ru...
code_fim
hard
{ "lang": "rust", "repo": "DuckLogic/DuckCommons", "path": "/src/math/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DuckLogic/DuckCommons path: /src/math/mod.rs pub mod counter; use num_traits::PrimInt; /// Trait for performing checked arithmetic with overflow checking via `OverflowError`. /// /// This isn't just useful for checking the arithmetic , /// but is also useful for wrapper indexes like `Instructi...
code_fim
hard
{ "lang": "rust", "repo": "DuckLogic/DuckCommons", "path": "/src/math/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ker ( ) . wake_by_ref ( ) ; Poll : : Pending } else { self . yield_amt + = 1 ; Poll : : Ready ( self . iter . next ( ) ) } } fn size_hint ( & self ) - > ( usize Option < usize > ) { self . iter . size_hint ( ) } }<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/r...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/tokio-stream/src/iter.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/tokio-stream/src/iter.rs use crate : : Stream ; use core : : pin : : Pin ; use core : : task : : { Context Poll } ; # [ derive ( Debug ) ] # [ must_use = " streams do nothing unless polled " ] pub struct Iter < I > { iter :...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/tokio-stream/src/iter.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yijie37/DaQiao path: /bridge/parity-ethereum/ethcore/snapshot/src/block.rs // Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Parity Ethereum. // Parity Ethereum is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public Lic...
code_fim
hard
{ "lang": "rust", "repo": "yijie37/DaQiao", "path": "/bridge/parity-ethereum/ethcore/snapshot/src/block.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::AbridgedBlock; use bytes::Bytes; use ethereum_types::{H256, U256, Address}; use common_types::{ transaction::{Action, Transaction}, block::Block, view, views::BlockView, }; fn encode_block(b: &Block) -> Bytes { b.rlp_bytes() } #[test] fn empty_bloc...
code_fim
hard
{ "lang": "rust", "repo": "yijie37/DaQiao", "path": "/bridge/parity-ethereum/ethcore/snapshot/src/block.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> use super::itfs; #[com_class( clsid = None, Interface1, Interface2)] #[derive(Debug)] pub struct NoGuid { test: String } #[com_impl] impl itfs::Interface1 for NoGuid {} #[com_impl] impl itfs::Interface2 for NoGuid {} }<|fim_prefix|>// repo: adrianwithah/i...
code_fim
hard
{ "lang": "rust", "repo": "adrianwithah/intercom-example", "path": "/intercom-common/tests/single_file_lib/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[com_class( clsid = None, Interface1, Interface2)] #[derive(Debug)] pub struct NoGuid { test: String } #[com_impl] impl itfs::Interface1 for NoGuid {} #[com_impl] impl itfs::Interface2 for NoGuid {} }<|fim_prefix|>// repo: adrianwithah/intercom-example path:...
code_fim
hard
{ "lang": "rust", "repo": "adrianwithah/intercom-example", "path": "/intercom-common/tests/single_file_lib/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adrianwithah/intercom-example path: /intercom-common/tests/single_file_lib/src/lib.rs use cls1::Class1; use cls2::Class2; #[com_library( libid = "00000001-0000-0000-0000-000000000000", Class1, Class2 )] mod itfs { #[com_interface( com_iid = "00000002-0000-0000-0000-000000000000")] tr...
code_fim
medium
{ "lang": "rust", "repo": "adrianwithah/intercom-example", "path": "/intercom-common/tests/single_file_lib/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plotters-rs/plotters path: /plotters/src/element/pie.rs use crate::{ element::{Drawable, PointCollection}, style::{IntoFont, RGBColor, TextStyle, BLACK}, }; use plotters_backend::{BackendCoord, DrawingBackend, DrawingErrorKind}; use std::{error::Error, f64::consts::PI, fmt::Display}; #[...
code_fim
hard
{ "lang": "rust", "repo": "plotters-rs/plotters", "path": "/plotters/src/element/pie.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Enables creating a donut chart with a hole of the specified radius. /// /// The passed value must be greater than zero and lower than the chart overall radius, otherwise it'll be ignored. pub fn donut_hole(&mut self, hole_radius: f64) { if hole_radius > 0.0 && hole_radius < *se...
code_fim
hard
{ "lang": "rust", "repo": "plotters-rs/plotters", "path": "/plotters/src/element/pie.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fogti/libnar path: /src/de.rs use std::cell::{Cell, RefCell}; use std::fmt::{self, Debug, Formatter}; use std::fs::{self, OpenOptions}; use std::future::Future; use std::io::{self, Error, ErrorKind, Read, Write}; use std::marker::PhantomData; use std::os::unix::fs::OpenOptionsExt; use std::path:...
code_fim
hard
{ "lang": "rust", "repo": "fogti/libnar", "path": "/src/de.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if archive.read_utf8_padded()? != ")" { return Err(Error::new(ErrorKind::Other, "Missing nested close tag")); } } ")" => break, _ => return Err(Error::new(ErrorKind::Othe...
code_fim
hard
{ "lang": "rust", "repo": "fogti/libnar", "path": "/src/de.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if archive.read_utf8_padded()? != ")" { return Err(Error::new(ErrorKind::Other, "Missing symlink close tag")); } co.yield_(Ok(Entry::new(path, EntryKind::Symlink { target }, archive))) .await; } "directory" => { ...
code_fim
hard
{ "lang": "rust", "repo": "fogti/libnar", "path": "/src/de.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", deck.draw_card().unwrap()); let game = table::Table::new(); println!("{}", game) }<|fim_prefix|>// repo: biddellns/poker.rs path: /engine/src/lib.rs use crate::cards::Deck; mod cards; mod state; mod table; <|fim_middle|>pub fn testme() { let mut deck = Deck::new(); /...
code_fim
medium
{ "lang": "rust", "repo": "biddellns/poker.rs", "path": "/engine/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: biddellns/poker.rs path: /engine/src/lib.rs use crate::cards::Deck; mod cards; mod state; mod table; <|fim_suffix|> let game = table::Table::new(); println!("{}", game) }<|fim_middle|>pub fn testme() { let mut deck = Deck::new(); // // println!("{:?}", deck); // deck.shu...
code_fim
medium
{ "lang": "rust", "repo": "biddellns/poker.rs", "path": "/engine/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let game = table::Table::new(); println!("{}", game) }<|fim_prefix|>// repo: biddellns/poker.rs path: /engine/src/lib.rs use crate::cards::Deck; mod cards; mod state; mod table; <|fim_middle|>pub fn testme() { let mut deck = Deck::new(); // // println!("{:?}", deck); // deck.shu...
code_fim
medium
{ "lang": "rust", "repo": "biddellns/poker.rs", "path": "/engine/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> serde_json::to_writer(&mut file, &json_value).map_err(|err| Error::Io(err.to_string()))?; Ok(filepath) } // Joins filename with the key directory unless it is already absolute. fn join_path<P: AsRef<Path>>(&self, filename: P) -> PathBuf { if filename.as_ref().is_absolu...
code_fim
hard
{ "lang": "rust", "repo": "nervosnetwork/ckb-cli", "path": "/ckb-signer/src/keystore/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Eq, PartialEq, Debug)] pub struct DerivedKeySet { pub external: Vec<(DerivationPath, H160)>, pub change: Vec<(DerivationPath, H160)>, } impl DerivedKeySet { pub fn get_path(&self, hash160: &H160) -> Option<(KeyChain, DerivationPath)> { for (path, pubkey_hash) in &self.externa...
code_fim
hard
{ "lang": "rust", "repo": "nervosnetwork/ckb-cli", "path": "/ckb-signer/src/keystore/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nervosnetwork/ckb-cli path: /ckb-signer/src/keystore/mod.rs y>, } impl Clone for KeyStore { fn clone(&self) -> KeyStore { KeyStore { keys_dir: self.keys_dir.clone(), storage: self.storage.clone(), files: self.files.clone(), ckb_roots: ...
code_fim
hard
{ "lang": "rust", "repo": "nervosnetwork/ckb-cli", "path": "/ckb-signer/src/keystore/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KristianWahlroos/interledger-rs path: /crates/interledger-service/src/lib.rs rn a result. Every component uses the same interface so that //! services can be reused and combined into different bundles of functionality. //! //! The Interledger service traits use requests that contain ILP Prepare ...
code_fim
hard
{ "lang": "rust", "repo": "KristianWahlroos/interledger-rs", "path": "/crates/interledger-service/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }