text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: Ben-Wormald/advent-of-code-2020 path: /src/solutions/day_15.rs use std::collections::HashMap; // just under a minute to brute force pt 2 with the same solution... const TURNS: usize = 30000000; <|fim_suffix|> let mut previous_number: Option<usize> = None; for t in 0..initial_numbers.le...
code_fim
medium
{ "lang": "rust", "repo": "Ben-Wormald/advent-of-code-2020", "path": "/src/solutions/day_15.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theduke/rust-crates-index path: /src/lib.rs // Copyright 2015 Corey Farwell // Copyright 2015 Contributors of github.com/huonw/crates.io-graph // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obta...
code_fim
hard
{ "lang": "rust", "repo": "theduke/rust-crates-index", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let glob_pattern = format!("{}/*/*/*", path.to_str().unwrap()); let index_paths1 = glob::glob_with(&glob_pattern, &match_options).unwrap(); let glob_pattern = format!("{}/[12]/*", path.to_str().unwrap()); let index_paths2 = glob::glob_with(&glob_pattern, &match_options).un...
code_fim
hard
{ "lang": "rust", "repo": "theduke/rust-crates-index", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn thumbnail_url(url: &String) -> String { lazy_static! { static ref RE: Regex = Regex::new(r"/embed/(.+?)(?:\?rel=0|$)").unwrap(); } let mut options: [String; 6] = [String::default(), String::default(), String::default(), String::default(), String::default(), String::default()]; ...
code_fim
hard
{ "lang": "rust", "repo": "KorvinSzanto/nasa-apod-bg", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Loop over each option until we have one that isn't 1097 bytes. This rules out default thumbnails for option in options.iter() { let response: Response = client.get(&option.to_string()).send().unwrap(); // If content length is exactly 1097 it means we have the default thumbnail ...
code_fim
hard
{ "lang": "rust", "repo": "KorvinSzanto/nasa-apod-bg", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KorvinSzanto/nasa-apod-bg path: /src/main.rs extern crate wallpaper; extern crate chrono; extern crate regex; #[macro_use] extern crate lazy_static; use colored::*; use chrono::{Date, Local, Duration}; use std::collections::HashMap; use regex::Regex; use reqwest::blocking::{Client, Response}; ...
code_fim
hard
{ "lang": "rust", "repo": "KorvinSzanto/nasa-apod-bg", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>s register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor inf...
code_fim
hard
{ "lang": "rust", "repo": "ajbt200128/e310x", "path": "/src/common/qspi0.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajbt200128/e310x path: /src/common/qspi0.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Serial Clock Divisor Register"] pub sckdiv: SCKDIV, #[doc = "0x04 - Serial Clock Mode Register"] pub sckmode: SCKMODE, _reserved2: [u8; 8usize], #[...
code_fim
hard
{ "lang": "rust", "repo": "ajbt200128/e310x", "path": "/src/common/qspi0.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_error() -> Result<(), GlError> { let mut error = GlError::NO_ERROR; loop { let next_error = unsafe { gl::GetError() }; if next_error == gl::NO_ERROR { break; } else { error.bits |= next_error; } } if error == GlError::NO_ER...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/lemon-1", "path": "/src/gl/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/lemon-1 path: /src/gl/error.rs use super::*; bitflags! { pub struct GlError: GLenum { const NO_ERROR = gl::NO_ERROR; const INVALID_ENUM = gl::INVALID_ENUM; const INVALID_VALUE = gl::INVALID_VALUE; ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/lemon-1", "path": "/src/gl/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use crate::utilities::Infinitable; type Graph<'a> = &'a [&'a [(usize, u32)]]; type States<'a> = &'a [(Infinitable<u32>, usize)]; #[test] fn test_dijkstra() { let test_cases: [((Graph, usize), States); 4] = [ ( (&super::FIGU...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/Introduction-to-Algorithms", "path": "/src/chapter_24_single_source_shortest_paths/section_24_3_dijkstra_s_algorithm/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bennyboer/worklog path: /ui/src/widget/day_view/day_view.rs use crate::state::work_item::{UiWorkItem, UiWorkItemStatus}; use crate::state::{DayViewState, SelectedWorkItemLens}; use crate::util::icon; use crate::widget::button::UiButton; use crate::widget::day_view::controller; use crate::widget:...
code_fim
hard
{ "lang": "rust", "repo": "bennyboer/worklog", "path": "/ui/src/widget/day_view/day_view.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn build_detail_view_title() -> impl Widget<UiWorkItem> { let title_edit_id = WidgetId::next(); let non_editing_widget = Label::new(|data: &UiWorkItem, _: &Env| data.description.to_owned()) .with_line_break_mode(LineBreaking::WordWrap) .with_text_size(20.0) .padding(2.0) ...
code_fim
hard
{ "lang": "rust", "repo": "bennyboer/worklog", "path": "/ui/src/widget/day_view/day_view.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Flex::row() .cross_axis_alignment(CrossAxisAlignment::Center) .with_child( Label::new("Status: ") .with_text_size(18.0) .with_text_color(Color::rgb8(120, 120, 120)), ) .with_child( Label::new(|data: &UiWorkItem, _:...
code_fim
hard
{ "lang": "rust", "repo": "bennyboer/worklog", "path": "/ui/src/widget/day_view/day_view.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>c ref REQUEST: reqwest::Client = reqwest::Client::new(); }<|fim_prefix|>// repo: SaltyAom/twitr path: /master/src/services/constants.rs use std::env; use redis; use reqwest; lazy_static! { <|fim_middle|> pub static ref REDIS: redis::Client = redis::Client::open(env::var("REDIS_URL").unwrap()).unwrap...
code_fim
medium
{ "lang": "rust", "repo": "SaltyAom/twitr", "path": "/master/src/services/constants.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SaltyAom/twitr path: /master/src/services/constants.rs use std::env; use redis; use reqwest; lazy_static! { <|fim_suffix|>c ref REQUEST: reqwest::Client = reqwest::Client::new(); }<|fim_middle|> pub static ref REDIS: redis::Client = redis::Client::open(env::var("REDIS_URL").unwrap()).unwrap...
code_fim
medium
{ "lang": "rust", "repo": "SaltyAom/twitr", "path": "/master/src/services/constants.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, switch_stmt: &swc_ecmascript::ast::SwitchStmt, _parent: &dyn Node, ) { if let swc_ecmascript::ast::Expr::Ident(ident) = &*switch_stmt.discriminant { if is_nan_identifier(&ident) { self.context.add_diagnostic( switch_stmt.span, CODE, ...
code_fim
hard
{ "lang": "rust", "repo": "brandly/deno_lint", "path": "/src/rules/use_isnan.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>Because `NaN` is unique in JavaScript by not being equal to anything, including itself, the results of comparisons to `NaN` are confusing: - `NaN === NaN` or `NaN == NaN` evaluate to false - `NaN !== NaN` or `NaN != NaN` evaluate to true Therefore, this rule makes you use the `isNaN()` or `Number.isNaN(...
code_fim
hard
{ "lang": "rust", "repo": "brandly/deno_lint", "path": "/src/rules/use_isnan.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brandly/deno_lint path: /src/rules/use_isnan.rs // Copyright 2020-2021 the Deno authors. All rights reserved. MIT license. use super::{Context, LintRule, ProgramRef, DUMMY_NODE}; use derive_more::Display; use swc_ecmascript::visit::noop_visit_type; use swc_ecmascript::visit::Node; use swc_ecmasc...
code_fim
hard
{ "lang": "rust", "repo": "brandly/deno_lint", "path": "/src/rules/use_isnan.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mistodon/jambrush path: /examples/capturing.rs fn main() { use winit::{ dpi::LogicalSize, event::{ElementState, VirtualKeyCode}, event_loop::EventLoop, window::WindowBuilder, }; let event_loop = EventLoop::new(); let window_builder = WindowBuilder...
code_fim
hard
{ "lang": "rust", "repo": "mistodon/jambrush", "path": "/examples/capturing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> IoErrorDetail::Io { kind, message: String::new() } } } impl From<std::fmt::Error> for IoErrorDetail { fn from(_: std::fmt::Error) -> Self { IoErrorDetail::Fmt } } pub trait ResultExt<T> { /// Add additional information to underlining `std::...
code_fim
hard
{ "lang": "rust", "repo": "kodegenix/kg-diag", "path": "/kg-diag/src/io/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kodegenix/kg-diag path: /kg-diag/src/io/error.rs use super::*; use std::path::PathBuf; #[derive(Debug, Eq, PartialEq, Clone)] pub enum IoErrorDetail { Io { kind: std::io::ErrorKind, message: String, }, IoPath { kind: std::io::ErrorKind, op_type: OpT...
code_fim
hard
{ "lang": "rust", "repo": "kodegenix/kg-diag", "path": "/kg-diag/src/io/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let a = self.x * n; let b = self.y * n; (a, b) } } fn main() { let p = Point {x: 10, y: 20}; p.print(); println!("{:?}", p.mult(3)); }<|fim_prefix|>// repo: Tsuyoshi-Iwanaga/learning_rust path: /006/method.rs //構造体を定義 struct Point { x: i32, y: i32, } impl Point { //output fn...
code_fim
medium
{ "lang": "rust", "repo": "Tsuyoshi-Iwanaga/learning_rust", "path": "/006/method.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tsuyoshi-Iwanaga/learning_rust path: /006/method.rs //構造体を定義 struct Point { x: i32, y: i32, } <|fim_suffix|>fn main() { let p = Point {x: 10, y: 20}; p.print(); println!("{:?}", p.mult(3)); }<|fim_middle|>impl Point { //output fn print(&self) { println!("({}, {})", self.x, sel...
code_fim
hard
{ "lang": "rust", "repo": "Tsuyoshi-Iwanaga/learning_rust", "path": "/006/method.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sval-rs/sval path: /src/data/seq.rs use crate::{tags, Index, Result, Stream, Value}; impl<T: Value> Value for [T] { fn stream<'a, S: Stream<'a> + ?Sized>(&'a self, stream: &mut S) -> Result { stream.seq_begin(Some(self.len()))?; for elem in self { stream.seq_val...
code_fim
hard
{ "lang": "rust", "repo": "sval-rs/sval", "path": "/src/data/seq.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> stream.tuple_end(None, None, None) } } )+ } } tuple! { 1 => ( self.0: T0, ), 2 => ( self.0: T0, self.1: T1, ), 3 => ( self.0: T0, self.1: T1, self.2: T2, ), 4 => ( ...
code_fim
hard
{ "lang": "rust", "repo": "sval-rs/sval", "path": "/src/data/seq.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> stream.tuple_begin(None, None, None, Some($len))?; $( stream.tuple_value_begin(None, &Index::new($i).with_tag(&tags::VALUE_OFFSET))?; stream.value(&self.$i)?; stream.tuple_value_end(None, &Inde...
code_fim
hard
{ "lang": "rust", "repo": "sval-rs/sval", "path": "/src/data/seq.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gamsb/nettu-scheduler path: /scheduler/crates/infra/src/repos/mod.rs mod account; mod account_integrations; mod calendar; mod calendar_synced; mod event; // mod kv; mod reservation; mod schedule; mod service; mod service_user; mod service_user_busy_calendars; mod shared; pub(crate) mod user; mod...
code_fim
hard
{ "lang": "rust", "repo": "gamsb/nettu-scheduler", "path": "/scheduler/crates/infra/src/repos/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Repos { pub async fn create_postgres( connection_string: &str, ) -> Result<Self, Box<dyn std::error::Error>> { info!("DB CHECKING CONNECTION ..."); let pool = PgPoolOptions::new() .max_connections(5) .connect(connection_string) .awai...
code_fim
hard
{ "lang": "rust", "repo": "gamsb/nettu-scheduler", "path": "/scheduler/crates/infra/src/repos/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> info!("DB CHECKING CONNECTION ... [done]"); Ok(Self { accounts: Arc::new(PostgresAccountRepo::new(pool.clone())), account_integrations: Arc::new(PostgresAccountIntegrationRepo::new(pool.clone())), calendars: Arc::new(PostgresCalendarRepo::new(pool.clone(...
code_fim
hard
{ "lang": "rust", "repo": "gamsb/nettu-scheduler", "path": "/scheduler/crates/infra/src/repos/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DemiMarie/rusty_scheme path: /src/symbol.rs use value; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::cell::{UnsafeCell, Cell}; use std::rc::Rc; pub type StackElement = usize; /// This struct stores a symbol. /// /// Symbols are never allocated on the GC heap. ...
code_fim
hard
{ "lang": "rust", "repo": "DemiMarie/rusty_scheme", "path": "/src/symbol.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// A symbol table. /// /// The symbol table consists of raw pointers to the strings, /// which are stored on the GC heap. /// /// WARNING: keep this in sync with the GC! This code does manual relocation /// of heap pointers! #[derive(Debug)] pub struct SymbolTable { pub contents: HashMap<Rc<String>,...
code_fim
hard
{ "lang": "rust", "repo": "DemiMarie/rusty_scheme", "path": "/src/symbol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ELD/rusty-monkey path: /src/eval/mod.rs expected: false, }, TestDataSimple { input: "1 > 1", expected: false, }, TestDataSimple { input: "1 == 1", expected: true, }, ...
code_fim
hard
{ "lang": "rust", "repo": "ELD/rusty-monkey", "path": "/src/eval/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn eval_hash_index_expr(&self, left: Object, index: Object) -> Object { if let Object::Hash(hash) = left { return match hash.get(&index) { Some(o) => o.clone(), None => Object::Null, }; } Object::Null } fn eval_h...
code_fim
hard
{ "lang": "rust", "repo": "ELD/rusty-monkey", "path": "/src/eval/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ELD/rusty-monkey path: /src/eval/mod.rs &Literal) -> Object { match lit { Literal::Int(i) => Object::Integer(*i), Literal::Bool(b) => Object::Boolean(*b), Literal::String(s) => Object::String(s.clone()), } } fn eval_prefix_expr(&self,...
code_fim
hard
{ "lang": "rust", "repo": "ELD/rusty-monkey", "path": "/src/eval/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl AsRef<Path> for Target { fn as_ref(&self) -> &Path { &self.0 } } impl Deref for Target { type Target = PathBuf; fn deref(&self) -> &Self::Target { &self.0 } } impl DerefMut for Target { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }...
code_fim
medium
{ "lang": "rust", "repo": "jbhannah/lodge", "path": "/src/target.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbhannah/lodge path: /src/target.rs use crate::{link, source::Source}; use std::io; use std::ops::{Deref, DerefMut}; use std::path::{Path, PathBuf}; #[derive(Debug)] pub enum Error { Target(String), Io(io::Error), } <|fim_suffix|>impl DerefMut for Target { fn deref_mut(&mut self) -...
code_fim
hard
{ "lang": "rust", "repo": "jbhannah/lodge", "path": "/src/target.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn build_link(&self, src: &Source) -> Result<link::Link, link::Error> { let mut dst = self.clone(); dst.extend(src.components_iter()); link::Link::new(src, dst) } }<|fim_prefix|>// repo: jbhannah/lodge path: /src/target.rs use crate::{link, source::Source}; use std::io...
code_fim
hard
{ "lang": "rust", "repo": "jbhannah/lodge", "path": "/src/target.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abhisharm/rustbook-in-code path: /ch5/methods/src/main.rs #[derive(Debug)] struct Rectangle { height: u32, width: u32, } impl Rectangle { // note we add the '&' before self, because methods can take ownership of self in rust fn area(&self) -> u32 { self.width * self.heig...
code_fim
hard
{ "lang": "rust", "repo": "abhisharm/rustbook-in-code", "path": "/ch5/methods/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.height > other.height { dh2 = (self.height - other.height).pow(2); } else { dh2 = (other.height - self.height).pow(2); } if self.width > other.width { dw2 = (self.width - other.width).pow(2); } else { dw2 = (o...
code_fim
hard
{ "lang": "rust", "repo": "abhisharm/rustbook-in-code", "path": "/ch5/methods/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!( "the 'distance' between rect2 and rect3 is: {}/{}", rect2.distance(&rect3), rect3.distance(&rect2)); let square = Rectangle::square(10); println!( "The area of a square of size {} is {}", 10, square.area()); let rect0 = Rectangle { ...
code_fim
hard
{ "lang": "rust", "repo": "abhisharm/rustbook-in-code", "path": "/ch5/methods/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // past event if res.status() == StatusCode::BAD_REQUEST { return HttpResponse::BadRequest().json(data::Default { msg: String::from("past event"), }); } // event does not exist if res.status() == StatusCode::FORBIDDEN { return HttpResponse::Forbidde...
code_fim
hard
{ "lang": "rust", "repo": "x4m3/api.epi.today", "path": "/src/v1/custom_planning/event_unregister.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: x4m3/api.epi.today path: /src/v1/custom_planning/event_unregister.rs use crate::intra::{autologin, client}; use crate::v1::data; use actix_web::{delete, http::StatusCode, web, HttpRequest, HttpResponse, Responder}; #[delete("/event")] pub async fn event_unregister( req: HttpRequest, inp...
code_fim
hard
{ "lang": "rust", "repo": "x4m3/api.epi.today", "path": "/src/v1/custom_planning/event_unregister.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Provider { priority: i32, pub n_provided: Cell<i32>, pub extractor: Rc<dyn Extractor>, } impl PartialEq<Provider> for Provider { fn eq(&self, other: &Self) -> bool { self.priority == other.priority } } impl Eq for Provider {} impl PartialOrd<Provider> for Provider { fn pa...
code_fim
hard
{ "lang": "rust", "repo": "cyb0124/OCRemote", "path": "/server/RustImpl/src/storage/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Ord for Provider { fn cmp(&self, other: &Self) -> Ordering { self.priority.cmp(&other.priority) } } mod chest; mod drawer; mod me; pub use chest::*; pub use drawer::*; pub use me::*;<|fim_prefix|>// repo: cyb0124/OCRemote path: /server/RustImpl/src/storage/mod.rs use super::factory::Factory; us...
code_fim
hard
{ "lang": "rust", "repo": "cyb0124/OCRemote", "path": "/server/RustImpl/src/storage/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cyb0124/OCRemote path: /server/RustImpl/src/storage/mod.rs use super::factory::Factory; use super::item::{Item, ItemStack}; use abort_on_drop::ChildTask; use flexstr::LocalStr; use std::{ cell::{Cell, RefCell}, cmp::Ordering, rc::{Rc, Weak}, }; pub struct DepositResult { pub n_d...
code_fim
hard
{ "lang": "rust", "repo": "cyb0124/OCRemote", "path": "/server/RustImpl/src/storage/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnieto/cl-cache path: /src/cl/mod.rs pub mod device; pub mod program; pub mod context; pub mod platform; pub mod command_queue; pub mod kernel; pub mod buffer; pub mod cl_root; <|fim_suffix|> match self.error_code { None => write!(f, "{}", self.human_error), Some(err_code) => write!(f, "...
code_fim
hard
{ "lang": "rust", "repo": "gnieto/cl-cache", "path": "/src/cl/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct OpenClError { human_error: String, error_code: Option<i32>, } impl OpenClError { pub fn new(human_error: String, error_code: cl_int) -> OpenClError { OpenClError { human_error: human_error, error_code: Some(error_code as i32), } } pub fn from_string(human_error...
code_fim
medium
{ "lang": "rust", "repo": "gnieto/cl-cache", "path": "/src/cl/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Error::$variant(err) } } } } impl_simple_from!(DieselError, Diesel); impl_simple_from!(ConnectionError, Connection); impl_simple_from!(RunMigrationsError, Migration); impl_simple_from!(VarError, Environment); impl_simple_from!(IoError, Io);<|fim_prefix|>// repo: By...
code_fim
hard
{ "lang": "rust", "repo": "ByteHeathen/libbookmarks", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ByteHeathen/libbookmarks path: /src/error.rs use diesel::result::Error as DieselError; use diesel::result::ConnectionError; use diesel_migrations::RunMigrationsError; use std::env::VarError; use std::io::Error as IoError; /// Error used by libbookmarks. #[derive(Debug)] pub enum Error { In...
code_fim
hard
{ "lang": "rust", "repo": "ByteHeathen/libbookmarks", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pimox/proxmox path: /proxmox/src/tools/byte_buffer.rs //! ByteBuffer //! //! a simple buffer for u8 with a practical api for reading and appending //! and consuming from the front //! Example: //! ``` //! # use std::io::Read; //! # use proxmox::tools::byte_buffer::ByteBuffer; //! fn code<T: Read...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox", "path": "/proxmox/src/tools/byte_buffer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn deref(&self) -> &Self::Target { &self.buf[..self.data_size] } } impl std::ops::DerefMut for ByteBuffer { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.buf[..self.data_size] } } #[cfg(test)] mod test { use crate::tools::byte_buffer::ByteBuffer; #[tes...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox", "path": "/proxmox/src/tools/byte_buffer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neandrake/wordplay path: /src/main.rs use anyhow::Result; use itertools::Itertools; use std::io::{self, Write}; use std::iter::once; use std::process; use structopt::StructOpt; use crate::args::{Arguments, Command}; use crate::words::WORDS_BY_LETTERS_USED; mod args; mod words; trait App { ...
code_fim
hard
{ "lang": "rust", "repo": "neandrake/wordplay", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Builds a word from the given list of indices. The returned word will /// include the queen letter, and the word will have its letters ordered. fn build_word(&self, subset: &Vec<usize>) -> String { let bytes = self.workers.as_bytes(); once(self.queen) .chain(subs...
code_fim
hard
{ "lang": "rust", "repo": "neandrake/wordplay", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: recursive-bloom/cmd-ethkey-bloom path: /src/commands/contract_cmd.rs use crate::commands::account_cmd; use ethereum_types::{H160, U256, H256}; use hex; use structopt::StructOpt; use std::fs::File; use std::io::Read; use std::str::FromStr; // !!! Necessary for H160::from_str(address).expect("..."...
code_fim
hard
{ "lang": "rust", "repo": "recursive-bloom/cmd-ethkey-bloom", "path": "/src/commands/contract_cmd.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ContractCmd { pub fn run(&self, mut backend: &str) { match &self.cmd { Command::Deploy {from,value,gas,gas_price,code,code_file} => { let from = H160::from_str(from).expect("From should be a valid address"); let value = U256::from_dec_str(value...
code_fim
hard
{ "lang": "rust", "repo": "recursive-bloom/cmd-ethkey-bloom", "path": "/src/commands/contract_cmd.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stefan-blair/ForthRust path: /src/operations/string_operations.rs use super::*; pub fn get_char(state: &mut ForthState) -> ForthResult { let c = state.input_stream.next_char()?; state.stack.push(c as generic_numbers::Byte); Ok(()) } pub fn read_string_to_memory(state: &...
code_fim
hard
{ "lang": "rust", "repo": "stefan-blair/ForthRust", "path": "/src/operations/string_operations.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut copied_characters = Bytes::zero(); while copied_characters < count { let current_char = state.input_stream.next_char()?; if current_char == '\n' { break; } state.write(address.plus(copied_characters), current_char as generic_num...
code_fim
hard
{ "lang": "rust", "repo": "stefan-blair/ForthRust", "path": "/src/operations/string_operations.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sergiineodnichyk/rpi4-rust-workspace path: /bcm2711/src/spi0.rs //! SPI0 use crate::MMIO_BASE; use core::marker::PhantomData; use core::ops::{Deref, DerefMut}; pub const PADDR: usize = MMIO_BASE + 0x20_4000; register! { /// Master Control and Status Register ControlStatus, u32, ...
code_fim
hard
{ "lang": "rust", "repo": "sergiineodnichyk/rpi4-rust-workspace", "path": "/bcm2711/src/spi0.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[repr(C)] pub struct RegisterBlock { pub cs: ControlStatus::Register, // 0x00 pub fifo: Fifo::Register, // 0x04 pub clock: ClockDivider::Register, // 0x08 pub data_len: DataLength::Register, // 0x0C pub ltoh: LossiToh::Register, // 0x10 pub dc: DmaControl::Regi...
code_fim
hard
{ "lang": "rust", "repo": "sergiineodnichyk/rpi4-rust-workspace", "path": "/bcm2711/src/spi0.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VictorKeil/Animations path: /svgr/src/main.rs mod types; mod tag; mod parse; <|fim_suffix|> println!("fill: {:?}", rect); }<|fim_middle|>use tag::{Tag, attributes, attributes::Rectangle, attributes::RectangleDelta, attributes::RectangleDeltaPart}; fn main() { let svg = parse::load_svg("...
code_fim
hard
{ "lang": "rust", "repo": "VictorKeil/Animations", "path": "/svgr/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VictorKeil/Animations path: /svgr/src/main.rs mod types; mod tag; mod parse; use tag::{Tag, attributes, attributes::Rectangle, attributes::RectangleDelta, attributes::RectangleDeltaPart}; fn main() { let svg = parse::load_svg("../volume-icon.svg"); <|fim_suffix|> println!("fill: {:?}",...
code_fim
medium
{ "lang": "rust", "repo": "VictorKeil/Animations", "path": "/svgr/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let svg = parse::load_svg("../volume-icon.svg"); let mut rect = Rectangle::new(); rect.x = Some(20.0); println!("fill: {:?}", rect); }<|fim_prefix|>// repo: VictorKeil/Animations path: /svgr/src/main.rs mod types; mod tag; mod parse; use tag::{Tag, attributes, attributes::Rectangle, at...
code_fim
easy
{ "lang": "rust", "repo": "VictorKeil/Animations", "path": "/svgr/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(dm.get_distance(String::from("raccoon"), String::from("bear")), Some(26.000002)); assert_eq!(dm.get_distance(String::from("raccoon"), String::from("dog")), Some(45.507133)); println!("{}", dm.to_csv()); } #[test] fn test_to_distance_matrix_medium_nested() { ...
code_fim
hard
{ "lang": "rust", "repo": "StephanHeijl/global-supertrees", "path": "/src/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StephanHeijl/global-supertrees path: /src/tests.rs #[cfg(test)] mod tests { use ndarray::prelude::*; use rayon::prelude::*; use crate::graph_tree as tree; use crate::tree_distance_matrix; use crate::tree_distance_matrix::TreeDistanceMatrix; use crate::neighbour_joining::...
code_fim
hard
{ "lang": "rust", "repo": "StephanHeijl/global-supertrees", "path": "/src/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nabijaczleweli/dishub path: /tests/ops/feed/mod.rs use dishub::ops::Feed; mod write; mod read; <|fim_suffix|> assert_eq!(Feed::new("nabijaczleweli".to_string(), 105, 1056), Feed { subject: "nabijaczleweli".to_string(), server: 105, ...
code_fim
easy
{ "lang": "rust", "repo": "nabijaczleweli/dishub", "path": "/tests/ops/feed/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Feed::new("nabijaczleweli".to_string(), 105, 1056), Feed { subject: "nabijaczleweli".to_string(), server: 105, channel: 1056, e_tag: None, latest: None, next_min:...
code_fim
easy
{ "lang": "rust", "repo": "nabijaczleweli/dishub", "path": "/tests/ops/feed/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jfrsmith/advent-2018 path: /day_6/src/main.rs type Point = (usize, usize); type Grid = Vec<Point>; fn dist(a : &Point, b: &Point) -> usize { ((b.0 as i32 - a.0 as i32).abs() + (b.1 as i32 - a.1 as i32).abs()) as usize } fn total_dist(p: &Point, points: &Grid) -> usize { points.iter().m...
code_fim
hard
{ "lang": "rust", "repo": "jfrsmith/advent-2018", "path": "/day_6/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn part_2_solve(input_str: &str, max_dist: usize) -> usize { let points = get_points(input_str); let min_y = points.iter().min_by_key(|(_,y)| y).unwrap().1; let min_x = points.iter().min_by_key(|(x,_)| x).unwrap().0; let max_y = points.iter().max_by_key(|(_,y)| y).unwrap().1; let max_x...
code_fim
hard
{ "lang": "rust", "repo": "jfrsmith/advent-2018", "path": "/day_6/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { let fut = self.inner.accept(); let fut = pin!(fut); let (stream, _) = ready!(fut.poll(cx))?; Poll::Ready(Some(Ok(stream))) } } impl AsRawFd for TcpListener { fn as_raw_fd(&se...
code_fim
hard
{ "lang": "rust", "repo": "cssivision/awak", "path": "/src/net/tcp/listener.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Stream for Incoming<'a> { type Item = io::Result<TcpStream>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { let fut = self.inner.accept(); let fut = pin!(fut); let (stream, _) = ready!(fut.poll(cx))?; Poll::Ready(Som...
code_fim
hard
{ "lang": "rust", "repo": "cssivision/awak", "path": "/src/net/tcp/listener.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cssivision/awak path: /src/net/tcp/listener.rs use std::future::Future; use std::io; use std::net::{self, SocketAddr, ToSocketAddrs}; use std::os::unix::io::{AsRawFd, RawFd}; use std::pin::{pin, Pin}; use std::task::{ready, Context, Poll}; use futures_core::stream::Stream; use super::stream::T...
code_fim
hard
{ "lang": "rust", "repo": "cssivision/awak", "path": "/src/net/tcp/listener.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for erdos_msg in erdos_msg_vec.into_iter() { tracing::trace!( "{}: Received and Converted {:?}", config_clone.get_name(), erdos_msg, ); // Sends converted mes...
code_fim
hard
{ "lang": "rust", "repo": "erdos-project/erdos", "path": "/erdos/src/dataflow/operators/ros/from_ros_operator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: rosrust::Message, U> Source<U> for FromRosOperator<T, U> where U: Data + for<'a> Deserialize<'a>, { fn run(&mut self, config: &OperatorConfig, write_stream: &mut WriteStream<U>) { let from_ros_msg = self.from_ros_msg.clone(); let config_clone = config.clone(); let w...
code_fim
hard
{ "lang": "rust", "repo": "erdos-project/erdos", "path": "/erdos/src/dataflow/operators/ros/from_ros_operator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erdos-project/erdos path: /erdos/src/dataflow/operators/ros/from_ros_operator.rs use crate::dataflow::{ operator::{OperatorConfig, Source}, operators::ros::*, stream::{WriteStream, WriteStreamT}, Data, Message, }; use serde::Deserialize; use std::sync::{Arc, Mutex}; /// Subscrib...
code_fim
hard
{ "lang": "rust", "repo": "erdos-project/erdos", "path": "/erdos/src/dataflow/operators/ros/from_ros_operator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twr14152/rust_stuff path: /ch3_3_functions.rs // Functions fn main() { println!("This is the main function"); secondary_func(); let a = <|fim_suffix|> println!("{} + {} = {}", a, b, a + b); } // if you put a ';' after x*y it changes from expr to statement and wont compile // return ...
code_fim
medium
{ "lang": "rust", "repo": "twr14152/rust_stuff", "path": "/ch3_3_functions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>nt and wont compile // return is identified by '->' fn return_func(x: i32, y: i32) -> i32 { x * y }<|fim_prefix|>// repo: twr14152/rust_stuff path: /ch3_3_functions.rs // Functions fn main() { println!("This is the main function"); secondary_func(); let a = <|fim_middle|>return_func(6909...
code_fim
hard
{ "lang": "rust", "repo": "twr14152/rust_stuff", "path": "/ch3_3_functions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl QueueManager { pub async fn new( options: RsmqOptions, pool_options: PoolOptions, qname: String, ) -> anyhow::Result<Self> { let rsmq = PooledRsmq::new(options, pool_options).await?; Ok(Self { rsmq, qname }) } pub async fn enqueue<T>(mut self, m...
code_fim
medium
{ "lang": "rust", "repo": "jcoletaylor/tasker-rust", "path": "/src/queue/manager.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcoletaylor/tasker-rust path: /src/queue/manager.rs use anyhow; use rsmq_async::{PoolOptions, PooledRsmq, RsmqConnection, RsmqOptions}; use serde::de::DeserializeOwned; use serde::Serialize; use serde_json; use tide::log; <|fim_suffix|>impl QueueManager { pub async fn new( options:...
code_fim
medium
{ "lang": "rust", "repo": "jcoletaylor/tasker-rust", "path": "/src/queue/manager.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn plus_one(x: i32) ->i32 { x +1 // 不带分号是表达式 }<|fim_prefix|>// repo: little7777/learn-rust path: /function/src/main.rs fn main() { let x =5; let y = { let x = 3; // it is a 声明 x + 1 }; let condition = true; let number = if condition { 5 } else { 6 ...
code_fim
easy
{ "lang": "rust", "repo": "little7777/learn-rust", "path": "/function/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: little7777/learn-rust path: /function/src/main.rs fn main() { let x =5; let y = { let x = 3; // it is a 声明 x + 1 }; let condition = true; let number = if condition { 5 } else { 6 }; println!("the value of numberr is: {}", number); let z = p...
code_fim
easy
{ "lang": "rust", "repo": "little7777/learn-rust", "path": "/function/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sogapalag/contest path: /comm/datastr/BIT.rs /// Binary Indexed Tree (Fenwick Tree). Holds an array of type T. /// T is a commutative monoid. Indices are 1 .. n. /// Verified by yukicoder No.404 (http://yukicoder.me/submissions/155373) struct BIT<T> { n: usize, ary: Vec<T>, e: T, } ...
code_fim
medium
{ "lang": "rust", "repo": "sogapalag/contest", "path": "/comm/datastr/BIT.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where T: std::ops::Sub<Output = T> { self.accum(idx) - self.accum(idx - 1) } } /// This implementation of AddAssign is useful when you want to make a 2D BIT. impl<T: Clone, U: Clone> std::ops::AddAssign<(usize, U)> for BIT<T> where T: std::ops::AddAssign<U>, T: std::ops::...
code_fim
hard
{ "lang": "rust", "repo": "sogapalag/contest", "path": "/comm/datastr/BIT.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MathiasPius/yaml-validator path: /yaml-validator/src/modifiers/one_of.rs use crate::errors::{SchemaError, SchemaErrorKind}; use crate::errors::{ValidationError, ValidationErrorKind}; use crate::utils::{CondenseErrors, YamlUtils}; use crate::{Context, PropertyType, Validate}; use std::convert::Tr...
code_fim
hard
{ "lang": "rust", "repo": "MathiasPius/yaml-validator", "path": "/yaml-validator/src/modifiers/one_of.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( SchemaOneOf::try_from(&load_simple( r#" oneOff: - type: integer "#, )) .unwrap_err(), SchemaErrorKind::Multiple { errors: vec![ SchemaErrorK...
code_fim
hard
{ "lang": "rust", "repo": "MathiasPius/yaml-validator", "path": "/yaml-validator/src/modifiers/one_of.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: j-browne/advent-of-code path: /2022/src/bin/day_06_01.rs use aoc_2022::datastream::Datastream; fn main() { println!("{}", run(include_str!("input/day_06.txt"))); } <|fim_suffix|> assert_eq!(super::run(include_str!("input/day_06_test_04.txt")), 10); } #[test] fn day_06_0...
code_fim
hard
{ "lang": "rust", "repo": "j-browne/advent-of-code", "path": "/2022/src/bin/day_06_01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(super::run(include_str!("input/day_06_test_04.txt")), 10); } #[test] fn day_06_01_test_05() { assert_eq!(super::run(include_str!("input/day_06_test_05.txt")), 11); } #[test] fn day_06_01() { assert_eq!(super::run(include_str!("input/day_06.txt")...
code_fim
hard
{ "lang": "rust", "repo": "j-browne/advent-of-code", "path": "/2022/src/bin/day_06_01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nlfiedler/magick-rust path: /src/wand/drawing.rs /* * Copyright 2016 Mattis Marjak * * 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.apache.org...
code_fim
hard
{ "lang": "rust", "repo": "nlfiedler/magick-rust", "path": "/src/wand/drawing.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn draw_circle(&mut self, ox: f64, oy: f64, px: f64, py: f64) { unsafe { bindings::DrawCircle(self.wand, ox, oy, px, py); } } pub fn draw_rectangle( &mut self, upper_left_x: f64, upper_left_y: f64, lower_right_x: f64, low...
code_fim
hard
{ "lang": "rust", "repo": "nlfiedler/magick-rust", "path": "/src/wand/drawing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn draw_rectangle( &mut self, upper_left_x: f64, upper_left_y: f64, lower_right_x: f64, lower_right_y: f64, ) { unsafe { bindings::DrawRectangle( self.wand, upper_left_x, upper_left_y, ...
code_fim
hard
{ "lang": "rust", "repo": "nlfiedler/magick-rust", "path": "/src/wand/drawing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FlatBartender/screeps-game-api path: /src/game/market.rs //! See [https://docs.screeps.com/api/#Game-market] //! //! [https://docs.screeps.com/api/#Game-market]: https://docs.screeps.com/api/#Game-market use std::{borrow::Cow, collections::HashMap, str::FromStr}; use parse_display::FromStr; use...
code_fim
hard
{ "lang": "rust", "repo": "FlatBartender/screeps-game-api", "path": "/src/game/market.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn calc_transaction_cost(amount: u32, room1: &Room, room2: &Room) -> f64 { js_unwrap!(Game.market.calcTransactionCost(@{amount}, @{room1.name()}, @{room2.name()})) } pub fn cancel_order(order_id: &str) -> ReturnCode { js_unwrap!(Game.market.cancelOrder(@{order_id})) } pub fn change_order_pri...
code_fim
hard
{ "lang": "rust", "repo": "FlatBartender/screeps-game-api", "path": "/src/game/market.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Azure/iotedge path: /edgelet/iotedge/src/logs.rs // Copyright (c) Microsoft. All rights reserved. use std::io::stdout; use anyhow::Context; use edgelet_core::{LogOptions, ModuleRuntime}; use support_bundle::write_logs; use crate::error::Error; <|fim_suffix|>impl<M> Logs<M> where M: Modu...
code_fim
hard
{ "lang": "rust", "repo": "Azure/iotedge", "path": "/edgelet/iotedge/src/logs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<M> Logs<M> where M: ModuleRuntime, { pub async fn execute(self) -> anyhow::Result<()> { let id = self.id.clone(); write_logs(&self.runtime, &id, &self.options, &mut stdout()) .await .context(Error::ModuleRuntime)?; Ok(()) } }<|fim_prefix|>/...
code_fim
hard
{ "lang": "rust", "repo": "Azure/iotedge", "path": "/edgelet/iotedge/src/logs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PistonDevelopers/input path: /src/mouse.rs //! Back-end agnostic mouse buttons. use num::{ FromPrimitive, ToPrimitive }; /// Represent a mouse button. #[derive(Copy, Clone, RustcDecodable, RustcEncodable, PartialEq, Eq, Ord, PartialOrd, Hash, Debug)] pub enum MouseButton { /// Unknown...
code_fim
hard
{ "lang": "rust", "repo": "PistonDevelopers/input", "path": "/src/mouse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_mouse_button_primitives() { use num::{ FromPrimitive, ToPrimitive }; for i in 0u64..9 { let button: MouseButton = FromPrimitive::from_u64(i).unwrap(); let j = ToPrimitive::to_u64(&button).unwrap(); assert_eq!(i, j); } ...
code_fim
hard
{ "lang": "rust", "repo": "PistonDevelopers/input", "path": "/src/mouse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_new_job(creep: &Creep) -> Option<CreepJob> { if creep.store().get_free_capacity(Some(ResourceType::Energy)) == 0 { let spawn: Structure = creep .room() .unwrap() .find(MY_SPAWNS, None) .pop() .unwrap() .into(); ...
code_fim
medium
{ "lang": "rust", "repo": "Cyloci/screeps", "path": "/src/creep/roles/hauler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cyloci/screeps path: /src/creep/roles/hauler.rs use rand::seq::SliceRandom; use screeps::{ find::{DROPPED_RESOURCES, MY_SPAWNS}, Creep, HasTypedId, ResourceType, Structure, }; <|fim_suffix|>pub fn get_new_job(creep: &Creep) -> Option<CreepJob> { if creep.store().get_free_capacity(So...
code_fim
medium
{ "lang": "rust", "repo": "Cyloci/screeps", "path": "/src/creep/roles/hauler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsoutlined/image/icon_timer_10.rs pub struct IconTimer10 { props: crate::Props, } impl yew::Component for IconTimer10 { type Properties = crate::Props; type Message = (); fn create(props: Self::Properties, _: yew::prelude::Com...
code_fim
medium
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialiconsoutlined/image/icon_timer_10.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VaranTavers/parrot_hat_follow path: /src/ui/step.rs use std::time::{SystemTime, UNIX_EPOCH}; use std::{thread}; use std::sync::mpsc::Sender; use std::thread::JoinHandle; use iced::{button, text_input, Element, Column}; use rust_drone_follow::traits::Controller; use rust_drone_follow::models::H...
code_fim
hard
{ "lang": "rust", "repo": "VaranTavers/parrot_hat_follow", "path": "/src/ui/step.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }