text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: PhilDK1/rustmplotlib path: /src/plots/plot.rs // use crate::addition_objs::colormap::Colormap; // use crate::addition_objs::markerstyle::MarkerStyle; // use crate::addition_objs::normalize::Normalize; use ndarray::prelude::*; use ndarray::Array1; use numpy::{Element, PyArray}; use pyo3::prelude:...
code_fim
hard
{ "lang": "rust", "repo": "PhilDK1/rustmplotlib", "path": "/src/plots/plot.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaLei666/rust_example path: /src/main0718.rs // @author : MaLei // @datetime : 2019-07-18 16:21 // @file : main.py // @software : PyCharm //fn main() { // let condition = true; // // let number = if condition { // 5 // } else { // 6 // }; // // println!("The value o...
code_fim
hard
{ "lang": "rust", "repo": "MaLei666/rust_example", "path": "/src/main0718.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>er == 10 { // break counter * 2; // } // }; // // assert_eq!(result, 20); //} // //fn main() { // let mut number = 3; // // while number != 0 { // println!("{}!", number); // // number = number - 1; // } // // println!("LIFT xOFF!!!"); //} //fn main() { /...
code_fim
hard
{ "lang": "rust", "repo": "MaLei666/rust_example", "path": "/src/main0718.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod code_point_table; pub mod constants; pub mod derived_core_properties; pub mod non_bmp; pub mod spaces; pub mod special_casing; pub mod table; pub mod types;<|fim_prefix|>// repo: jswalden/unicode-info path: /src/lib.rs //! A crate that parses, slices, and dices Unicode code point description file...
code_fim
medium
{ "lang": "rust", "repo": "jswalden/unicode-info", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod non_bmp; pub mod spaces; pub mod special_casing; pub mod table; pub mod types;<|fim_prefix|>// repo: jswalden/unicode-info path: /src/lib.rs //! A crate that parses, slices, and dices Unicode code point description files //<|fim_middle|>! into convenient structured representations. pub mod bmp; pub ...
code_fim
medium
{ "lang": "rust", "repo": "jswalden/unicode-info", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jswalden/unicode-info path: /src/lib.rs //! A crate that parses, slices, and dices Unicode code point description files //<|fim_suffix|>mod non_bmp; pub mod spaces; pub mod special_casing; pub mod table; pub mod types;<|fim_middle|>! into convenient structured representations. pub mod bmp; pub ...
code_fim
medium
{ "lang": "rust", "repo": "jswalden/unicode-info", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MartinKavik/stremio-seed-poc path: /src/page/addons/addon_details_modal.rs use crate::{PageId, Urls as RootUrls, Context}; use seed::{prelude::*, *}; use seed_styles::{pc, rem, em}; use seed_styles::*; use crate::styles::{self, themes::{Color, Breakpoint}, global}; use seed_hooks::{*, topo::nest...
code_fim
hard
{ "lang": "rust", "repo": "MartinKavik/stremio-seed-poc", "path": "/src/page/addons/addon_details_modal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> div![ C!["cancel-button", "action-button", "button-container"], s() .background_color(Color::Transparent) .margin_right(rem(1)) .align_items(CssAlignItems::Center) .display(CssDisplay::Flex) .flex("1") .flex_direct...
code_fim
hard
{ "lang": "rust", "repo": "MartinKavik/stremio-seed-poc", "path": "/src/page/addons/addon_details_modal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kevindrosendahl/ProtoDB path: /clients/rust/src/index.rs use super::generated::protodb; use super::{Client, ClientError}; use futures::Future; use tower_grpc::Request; impl Client { pub fn create_index( &mut self, database: String, collection: String, field:...
code_fim
hard
{ "lang": "rust", "repo": "kevindrosendahl/ProtoDB", "path": "/clients/rust/src/index.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn list_indexes( &mut self, database: String, collection: String, ) -> Result<protodb::index::ListIndexesResponse, ClientError> { let request = self .client .list_indexes(Request::new(protodb::index::ListIndexesRequest { d...
code_fim
hard
{ "lang": "rust", "repo": "kevindrosendahl/ProtoDB", "path": "/clients/rust/src/index.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nobuoka/qt-mover path: /src/lib.rs use std::fs; use std::fs::File; use std::io::Write; use std::path::PathBuf; use serde::{Deserialize, Serialize}; <|fim_suffix|> let mut output_path: PathBuf = [".", "output", "articles"].iter().collect(); output_path.push(path.file_name().unwra...
code_fim
hard
{ "lang": "rust", "repo": "nobuoka/qt-mover", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let article_markdown = convert_article_json(&article_json)?; let mut output_path: PathBuf = [".", "output", "articles"].iter().collect(); output_path.push(path.file_name().unwrap()); output_path.set_extension("md"); let mut file = File::create(output_path)?; ...
code_fim
hard
{ "lang": "rust", "repo": "nobuoka/qt-mover", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl<T> Is for T { type Type = T; fn identity(self) -> Self::Type { self } }<|fim_prefix|>// repo: casey/x-serialization-format path: /src/is.rs // all credit to: https://github.com/clintonmead/is_type /// This trait is implemented for types which are the same as Self::Type. /// /// It is u...
code_fim
medium
{ "lang": "rust", "repo": "casey/x-serialization-format", "path": "/src/is.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: casey/x-serialization-format path: /src/is.rs // all credit to: https://github.com/clintonmead/is_type /// This trait is implemented for types which are the same as Self::Type. /// /// It is useful in where clauses, since equality constraints like the following /// are not yet supported: /// ///...
code_fim
medium
{ "lang": "rust", "repo": "casey/x-serialization-format", "path": "/src/is.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ma1ko/rayon-adaptive path: /src/traits.rs //! This module contains all traits enabling us to express some parallelism. use std; use std::iter::{empty, Empty}; use std::ops::Range; use std::ptr; use crate::chunks::Chunks; use crate::policy::ParametrizedInput; use crate::Policy; // markers for s...
code_fim
hard
{ "lang": "rust", "repo": "ma1ko/rayon-adaptive", "path": "/src/traits.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.split_at_mut(index) } } impl<'a, T: 'a + Sync + Send> DivisibleAtIndex for &'a mut [T] {} //TODO: be more generic but it seems complex impl Divisible for Range<usize> { type Power = IndexedPower; fn base_length(&self) -> usize { self.len() } fn divide(self) -> (S...
code_fim
hard
{ "lang": "rust", "repo": "ma1ko/rayon-adaptive", "path": "/src/traits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn get_available_resolutions() -> Vec<DisplayMode> { unsafe { let mut resolutions = vec![]; let mut idx = 0; let mut stats = DEVMODEW { dmSize: mem::size_of::<DEVMODEW>() as u16, .. mem::uninitialized() }; while user32::EnumDisplaySetti...
code_fim
medium
{ "lang": "rust", "repo": "Gankra/winres-test", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gankra/winres-test path: /src/main.rs extern crate winapi; extern crate user32; use winapi::wingdi::DEVMODEW; use std::{ptr, mem}; #[derive(PartialEq, Eq, PartialOrd, Ord)] struct DisplayMode { freq: u32, width: u32, height: u32, } <|fim_suffix|> for res in get_available_resol...
code_fim
medium
{ "lang": "rust", "repo": "Gankra/winres-test", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rshaler; pub use target::TargetMarshaler;<|fim_prefix|>// repo: divvun/pahkat-client-sdk-swift path: /crate/pahkat-client-core/src/ffi/marshal/mod.rs mod json; mod package_key; mod target; <|fim_middle|>pub use json::{JsonMarshaler, JsonRefMarshaler}; pub use package_key::PackageKeyMa
code_fim
medium
{ "lang": "rust", "repo": "divvun/pahkat-client-sdk-swift", "path": "/crate/pahkat-client-core/src/ffi/marshal/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: divvun/pahkat-client-sdk-swift path: /crate/pahkat-client-core/src/ffi/marshal/mod.rs mod json; mod package_key; mod target; <|fim_suffix|>haler}; pub use package_key::PackageKeyMarshaler; pub use target::TargetMarshaler;<|fim_middle|>pub use json::{JsonMarshaler, JsonRefMars
code_fim
easy
{ "lang": "rust", "repo": "divvun/pahkat-client-sdk-swift", "path": "/crate/pahkat-client-core/src/ffi/marshal/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl InherentError { /// Try to create an instance ouf of the given identifier and data. #[cfg(feature = "std")] pub fn try_from(id: &InherentIdentifier, mut data: &[u8]) -> Option<Self> { if id == &INHERENT_IDENTIFIER { <InherentError as codec::Decode>::decode(&mut data).ok() } else { None ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/primitives/timestamp/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Into<u64> + Copy> core::cmp::PartialOrd<T> for Timestamp { fn partial_cmp(&self, other: &T) -> Option<core::cmp::Ordering> { self.0.partial_cmp(&(*other).into()) } } #[cfg(feature = "std")] impl std::fmt::Display for Timestamp { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Res...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/primitives/timestamp/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/substrate path: /primitives/timestamp/src/lib.rs // This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complia...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/primitives/timestamp/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elidupree/minesweeper path: /src/board_iter.rs use std::cmp::min; pub struct BoardIter { x: usize, y: usize, min_y: usize, max_x: usize, max_y: usize, cur_x: usize, cur_y: usize, } impl Iterator for BoardIter { type Item = (usize, usize); fn next(&mut self) ...
code_fim
hard
{ "lang": "rust", "repo": "elidupree/minesweeper", "path": "/src/board_iter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Compute next one. self.cur_y += 1; if self.cur_x == self.x && self.cur_y == self.y { // Skip over the starting element. self.cur_y += 1 } if self.cur_y >= self.max_y { self.cur_y = self.min_y; ...
code_fim
medium
{ "lang": "rust", "repo": "elidupree/minesweeper", "path": "/src/board_iter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timothyjrogers/tjr-advent-of-code-solutions path: /2020/DAY15/part1/src/main.rs use std::fs::File; use std::io::{BufReader, BufRead}; use std::collections::HashMap; fn main() { let fname = "../data/input.txt"; let f = File::open(fname).expect("Unable to open data file"); let reader ...
code_fim
hard
{ "lang": "rust", "repo": "timothyjrogers/tjr-advent-of-code-solutions", "path": "/2020/DAY15/part1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while turn < 30000000 { let new; match latest_turns.get(&latest) { Some(x) => { new = turn - x; }, None => { new = 0; } } latest_turns.insert(latest, turn); latest = new; tur...
code_fim
hard
{ "lang": "rust", "repo": "timothyjrogers/tjr-advent-of-code-solutions", "path": "/2020/DAY15/part1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JADSN/typed-sql path: /src/types/time.rs use super::Primitive; use time::{Date, OffsetDateTime, PrimitiveDateTime, Time}; <|fim_suffix|>impl Primitive for Date { fn write_primative(&self, sql: &mut String) { sql.push('\''); sql.push_str(&self.to_string()); sql.push('...
code_fim
hard
{ "lang": "rust", "repo": "JADSN/typed-sql", "path": "/src/types/time.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Primitive for OffsetDateTime { fn write_primative(&self, sql: &mut String) { sql.push('\''); sql.push_str(&self.to_string()); sql.push('\''); } } impl Primitive for Date { fn write_primative(&self, sql: &mut String) { sql.push('\''); sql.push_str(&...
code_fim
medium
{ "lang": "rust", "repo": "JADSN/typed-sql", "path": "/src/types/time.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> sql.push('\''); sql.push_str(&self.to_string()); sql.push('\''); } } impl Primitive for Date { fn write_primative(&self, sql: &mut String) { sql.push('\''); sql.push_str(&self.to_string()); sql.push('\''); } } impl Primitive for Time { fn wr...
code_fim
medium
{ "lang": "rust", "repo": "JADSN/typed-sql", "path": "/src/types/time.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> 'inner: loop { match chars[i] { b'm' => { end = true; break 'inner; } b';' => { skip += 1; i += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "chronium/osdev", "path": "/lib-kern/src/ansi.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chronium/osdev path: /lib-kern/src/ansi.rs use alloc::{string::String, vec::Vec}; pub enum AnsiEscape { Foreground(u8), Background(u8), Reset, } pub struct AnsiAdapter; impl AnsiAdapter { pub fn parse(chars: &[u8]) -> (Vec<Option<AnsiEscape>>, usize) { let mut i = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "chronium/osdev", "path": "/lib-kern/src/ansi.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nguyendoanh99/emerald-vault-node path: /packages/native/native/src/admin.rs use neon::prelude::{FunctionContext, JsArray, JsResult, JsNumber}; use access::{MigrationConfig, VaultConfig}; <|fim_suffix|>pub fn autofix(mut cx: FunctionContext) -> JsResult<JsNumber> { let cfg = VaultConfig::ge...
code_fim
hard
{ "lang": "rust", "repo": "nguyendoanh99/emerald-vault-node", "path": "/packages/native/native/src/admin.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> //TODO let result = JsArray::new(&mut cx, 0 as u32); Ok(result) } pub fn autofix(mut cx: FunctionContext) -> JsResult<JsNumber> { let cfg = VaultConfig::get_config(&mut cx); let storage = cfg.get_storage(); let recovered = match storage.revert_backups() { Ok(count) => coun...
code_fim
medium
{ "lang": "rust", "repo": "nguyendoanh99/emerald-vault-node", "path": "/packages/native/native/src/admin.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, MessageType: Message> AppendRequest<MessageType> { pub async fn send(&self, server: &str) -> tide::Result<AppendResponse> { append(server, &self).await } }<|fim_prefix|>// repo: jbr/yari path: /yari-lib/src/rpc/append.rs use crate::{ log::LogEntry, raft::{Index, Message, ...
code_fim
hard
{ "lang": "rust", "repo": "jbr/yari", "path": "/yari-lib/src/rpc/append.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbr/yari path: /yari-lib/src/rpc/append.rs use crate::{ log::LogEntry, raft::{Index, Message, Term}, Okay, }; use serde::{Deserialize, Serialize}; use surf::{Body, Client}; use url::Url; <|fim_suffix|>pub async fn append<MT: Message>( server: &str, append_request: &AppendRe...
code_fim
hard
{ "lang": "rust", "repo": "jbr/yari", "path": "/yari-lib/src/rpc/append.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Anders429/shield path: /src/system/reset_shield_use.rs use crate::{components, events::Events, system::movement, World}; use itertools::izip; pub(crate) fn reset_shield_use<const ENTITY_COUNT: usize>( world: &mut World<ENTITY_COUNT>, ) -> Events { let mut events = Events::default(); ...
code_fim
hard
{ "lang": "rust", "repo": "Anders429/shield", "path": "/src/system/reset_shield_use.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rection::Down, components::Direction::Right => components::Direction::Left, components::Direction::Down => components::Direction::Up, components::Direction::Left => components::Direction::Right, }, 1, )...
code_fim
hard
{ "lang": "rust", "repo": "Anders429/shield", "path": "/src/system/reset_shield_use.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn id(&self) -> ID { self.id } } impl DeltaSerializable for Entity { fn delta_serialize(&self, previous:&Self, write:&mut dyn std::io::Write) -> std::io::Result<usize> { todo!() } fn delta_deserialize(previous:&Self, read:&mut dyn std::io::Read) -> std::io::Result<Se...
code_fim
hard
{ "lang": "rust", "repo": "horup/zombiedodgeball", "path": "/src/world/entity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn delta_deserialize(previous:&Self, read:&mut dyn std::io::Read) -> std::io::Result<Self> where Self : Sized { todo!() } }<|fim_prefix|>// repo: horup/zombiedodgeball path: /src/world/entity.rs use cgmath::{Point2, Vector2}; use gamestate::{DeltaSerializable, ID}; use crate::components:...
code_fim
hard
{ "lang": "rust", "repo": "horup/zombiedodgeball", "path": "/src/world/entity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: horup/zombiedodgeball path: /src/world/entity.rs use cgmath::{Point2, Vector2}; use gamestate::{DeltaSerializable, ID}; use crate::components::{Collision, Missile, Player, Shooter, Sprite}; #[derive(Copy, Clone, PartialEq)] pub struct Entity { pub id:ID, pub pos:Point2<f32>, pub v...
code_fim
medium
{ "lang": "rust", "repo": "horup/zombiedodgeball", "path": "/src/world/entity.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for update in console { match update { Special(Enter) => { break 'outer; } Special(Backspace) => { buffer.pop_char(); } Character(x) => { buffer....
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/termbox_console", "path": "/examples/text_input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut console = TermboxConsole::new(); let mut buffer = String::new(); 'outer: loop { console.clear(); console.draw(0, 0, buffer.as_slice()); console.draw(5, 5, "press [enter] to quit"); console.present(); for update in console { match up...
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/termbox_console", "path": "/examples/text_input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TyOverby/termbox_console path: /examples/text_input.rs extern crate termbox_console; extern crate console_draw; use console_draw::{ ConsoleCanvas, Character, Special, Enter, Backspace }; use termbox_console::TermboxConsole; fn main() { <|fim_suffix|> for update in co...
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/termbox_console", "path": "/examples/text_input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn step(&mut self, samples: &mut Iterator<Item=S>) { self.stopwatch.lap(); self.cache.clear(); for sample in samples.take(self.minibatch_sz) { self.cache.push(sample); } assert_eq!(self.minibatch_sz, self.cache.len()); self.stopwatch.lap(); println!("DEBUG: sg: step...
code_fim
hard
{ "lang": "rust", "repo": "peterhj/liboperator", "path": "/src/opt/stochastic.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peterhj/liboperator path: /src/opt/stochastic.rs use prelude::*; use densearray::prelude::*; use rng::xorshift::{Xorshiftplus128Rng}; use rand::{Rng}; use std::cell::{RefCell}; use std::cmp::{min}; use std::marker::{PhantomData}; use std::num::{Zero}; use std::rc::{Rc}; pub trait GradUpdate<T...
code_fim
hard
{ "lang": "rust", "repo": "peterhj/liboperator", "path": "/src/opt/stochastic.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn x_rel_to_abs(&self,x_rel:u16,panel: Panel) -> u16{ match panel { Panel::Menu => x_rel + 1, Panel::Main => x_rel + self.menu_w + 1 } } pub fn y_rel_to_abs(&self,y_rel:u16,panel: Panel) -> u16{ match panel { Panel::Menu => y_rel...
code_fim
hard
{ "lang": "rust", "repo": "nicooffee/map-app", "path": "/map-app/src/engine/window/screen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nicooffee/map-app path: /map-app/src/engine/window/screen.rs extern crate termion_ext; use termion_ext::AdvWrite; use crate::engine::traits::printable; use std::io::{ Write, Error }; use termion::{ screen::AlternateScreen, terminal_size, color, cursor, clear }; pub ...
code_fim
hard
{ "lang": "rust", "repo": "nicooffee/map-app", "path": "/map-app/src/engine/window/screen.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn coord_menu(&self,text_line: TextLine) -> (u16,u16) { match text_line { TextLine::TITLE => (1,1), TextLine::CHAR_POS => (2,1) } } } impl<W: Write> Write for Screen<W> { fn write(&mut self,buf: &[u8]) -> Result<usize,Error> { self.window...
code_fim
hard
{ "lang": "rust", "repo": "nicooffee/map-app", "path": "/map-app/src/engine/window/screen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nymtech/nym path: /sdk/rust/nym-sdk/examples/surb-reply.rs use nym_sdk::mixnet::{ AnonymousSenderTag, MixnetClientBuilder, MixnetMessageSender, ReconstructedMessage, StoragePaths, }; use std::path::PathBuf; #[tokio::main] async fn main() { nym_bin_common::logging::setup_logging(); ...
code_fim
hard
{ "lang": "rust", "repo": "nymtech/nym", "path": "/sdk/rust/nym-sdk/examples/surb-reply.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut parsed = String::new(); if let Some(r) = message.first() { parsed = String::from_utf8(r.message.clone()).unwrap(); } // parse sender_tag: we will use this to reply to sender without needing their Nym address let return_recipient: AnonymousSenderTag = message[0].sender_t...
code_fim
hard
{ "lang": "rust", "repo": "nymtech/nym", "path": "/sdk/rust/nym-sdk/examples/surb-reply.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winding-lines/weaver path: /lib-server/src/server.rs use crate::analyses::load_analyses; use crate::app_state::ApiState; use crate::asset_map::AssetMap; use crate::handlers; use crate::pages; use crate::template_engine::TemplateEngine; use actix_web::middleware::Logger; use actix_web::{server, A...
code_fim
hard
{ "lang": "rust", "repo": "winding-lines/weaver", "path": "/lib-server/src/server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut s = server::new(apps_factory); s = s.bind(format!("{}:{}", address, http_port))?; #[cfg(any(feature = "tls", feature = "rust-tls"))] { match config_tls() { Ok(config) => { ::log::info!("Initializing TLS on port {}", ht...
code_fim
hard
{ "lang": "rust", "repo": "winding-lines/weaver", "path": "/lib-server/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> : : Only ( x ) = > x } } } impl < I : Iterator > Iterator for WithPosition < I > { type Item = Position < I : : Item > ; fn next ( & mut self ) - > Option < Self : : Item > { match self . peekable . next ( ) { Some ( item ) = > { if ! self . handled_first { self . handled_first = true ; match self . peek...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/itertools/src/with_position.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/itertools/src/with_position.rs use std : : iter : : { Fuse Peekable FusedIterator } ; # [ must_use = " iterator adaptors are lazy and do nothing unless consumed " ] pub struct WithPosition < I > where I : Iterator { handled...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/itertools/src/with_position.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>em ) ) } } else { match self . peekable . peek ( ) { Some ( _ ) = > Some ( Position : : Middle ( item ) ) None = > Some ( Position : : Last ( item ) ) } } } None = > None } } fn size_hint ( & self ) - > ( usize Option < usize > ) { self . peekable . size_hint ( ) } } impl < I > ExactSizeIterator for WithP...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/itertools/src/with_position.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iAmao/30-days-of-rust path: /src/lib/day_five.rs #![allow(non_snake_case)] use std; struct Person { age: i32 } impl Person { fn new(initialAge: i32) -> Person { // Add some more code to run some checks on initialAge if initialAge < 1 { println!("Age is not v...
code_fim
medium
{ "lang": "rust", "repo": "iAmao/30-days-of-rust", "path": "/src/lib/day_five.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> p.amIOld(); println!(""); } } fn read_line() -> String { let mut input = String::new(); std::io::stdin().read_line(&mut input).expect("Could not read stdin!"); return input; }<|fim_prefix|>// repo: iAmao/30-days-of-rust path: /src/lib/day_five.rs #![allow(non_snake_case)...
code_fim
hard
{ "lang": "rust", "repo": "iAmao/30-days-of-rust", "path": "/src/lib/day_five.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cossonleo/trans_driver path: /src/api.rs use async_trait::async_trait; #[async_trait] pub trait Api { async fn tr<|fim_suffix|>ext: &str) -> anyhow::Result<String>; }<|fim_middle|>anslate(&self, from: &str, to: &str, t
code_fim
easy
{ "lang": "rust", "repo": "cossonleo/trans_driver", "path": "/src/api.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ext: &str) -> anyhow::Result<String>; }<|fim_prefix|>// repo: cossonleo/trans_driver path: /src/api.rs use async_trait::async_trait; #[async<|fim_middle|>_trait] pub trait Api { async fn translate(&self, from: &str, to: &str, t
code_fim
medium
{ "lang": "rust", "repo": "cossonleo/trans_driver", "path": "/src/api.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // title top-right with all borders test_case( Alignment::Right, Borders::ALL, Buffer::with_lines(vec![" ┌──────Title┐ ", " └───────────┘ "]), ); // title top-right without top border test_case( Alignment::Right, Borders::LEFT | Borders::BOTTOM ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/tui-0.16.0/tests/widgets_block.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/tui-0.16.0/tests/widgets_block.rs use tui::{ backend::TestBackend, buffer::Buffer, layout::{Alignment, Rect}, style::{Color, Style}, text::Span, widgets::{Block, Borders}, Terminal, }; #[test] fn widgets_block_re...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/tui-0.16.0/tests/widgets_block.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[aoc_generator(day4)] pub fn input_generator(input: &str) -> Vec<i32> { input .split('-') .map(|x| x.parse::<i32>().unwrap()) .collect::<Vec<i32>>() } #[aoc(day4, part1)] pub fn solve_part1(input: &[i32]) -> usize { let low = input.get(0).unwrap(); let high = input.ge...
code_fim
hard
{ "lang": "rust", "repo": "jjcomer/advent2019", "path": "/src/day4.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jjcomer/advent2019 path: /src/day4.rs fn split_number(password: i32) -> Vec<i8> { let str_number = format!("{}", password); str_number .chars() .map(|c| c.to_digit(10).unwrap() as i8) .collect() } fn pair_test(password: &[i8], (i1, i2): &(usize, usize)) -> bool {...
code_fim
hard
{ "lang": "rust", "repo": "jjcomer/advent2019", "path": "/src/day4.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>// command implementation pub fn execute(args: &ArgMatches) -> anyhow::Result<()> { //---------------------------- // Args //---------------------------- let mut writer = writer(args.get_one::<String>("outfile").unwrap()); let is_count = args.get_flag("count"); let mut names: Vec<...
code_fim
hard
{ "lang": "rust", "repo": "wang-q/intspan", "path": "/src/cmd_fasr/name.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wang-q/intspan path: /src/cmd_fasr/name.rs use clap::*; use intspan::*; use std::collections::BTreeMap; // Create clap subcommand arguments pub fn make_subcommand() -> Command { Command::new("name") .about("Output all species names") .after_help( r###" * <infiles...
code_fim
hard
{ "lang": "rust", "repo": "wang-q/intspan", "path": "/src/cmd_fasr/name.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let client = builder .connect(addr, 0) .map_err(|e| eprintln!("Read Error: {:?}", e)) .map(move |c| c) .and_then(move |c| { println!("version:{}", c.server_version); c.send_request(stock_request); c.send_request(forex_request); ...
code_fim
hard
{ "lang": "rust", "repo": "hussein-aitlahcen/async_ib", "path": "/examples/ib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hussein-aitlahcen/async_ib path: /examples/ib.rs extern crate async_ib; extern crate bytes; extern crate chrono; extern crate failure; extern crate futures; extern crate tokio; extern crate tokio_codec; extern crate tokio_io; use async_ib::domain; use async_ib::message::request::*; use async_ib...
code_fim
hard
{ "lang": "rust", "repo": "hussein-aitlahcen/async_ib", "path": "/examples/ib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let colormap = map!{0 => Rgba { data: [46, 204, 113, 255] }, 81 => Rgba { data: [230, 126, 34, 255] }, 73 => Rgba { data: [142, 68, 173, 255] }, 89 => Rgba { data: [142, 68, 173, 255] }, 80 => Rgba { data:...
code_fim
hard
{ "lang": "rust", "repo": "reasv/wfc-tiled-amethyst", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reasv/wfc-tiled-amethyst path: /src/main.rs extern crate image; extern crate wfc; extern crate direction; extern crate rand; extern crate coord_2d; extern crate ron; use std::num::NonZeroU32; use std::collections::HashSet; use std::collections::HashMap; use std::fs::File; use direction::{Cardi...
code_fim
hard
{ "lang": "rust", "repo": "reasv/wfc-tiled-amethyst", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the size of the blob in bytes. pub fn len(&self) -> usize { unsafe { sys::hb_blob_get_length(self.raw) as usize } } /// Returns true if the length is zero. pub fn is_empty(&self) -> bool { self.len() == 0 } /// Make this blob immutable. pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/harfbuzz/src/blob.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winksaville/fuchsia path: /third_party/rust_crates/vendor/harfbuzz/src/blob.rs // Copyright 2018 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.o...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/harfbuzz/src/blob.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub unsafe fn enable_nxe_x86_64() { let mut efer = Efer::read(); efer.set(EferFlags::NO_EXECUTE_ENABLE, true); Efer::write(efer); } pub unsafe fn enable_write_protect_x86_64() { let mut cr0 = Cr0::read(); cr0.set(Cr0Flags::WRITE_PROTECT, true); ...
code_fim
hard
{ "lang": "rust", "repo": "Teln0/SysControl", "path": "/rust/src/utils/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Teln0/SysControl path: /rust/src/utils/mod.rs pub fn ceil_div_usize(a: usize, b: usize) -> usize { (a + b - 1) / b } pub fn mem_regions_overlap(a_start: usize, a_end: usize, b_start: usize, b_end: usize) -> bool { a_start.max(b_start) <= a_end.min(b_end) } pub mod reg_read { pub un...
code_fim
medium
{ "lang": "rust", "repo": "Teln0/SysControl", "path": "/rust/src/utils/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: panicbit/advent_of_code_20 path: /day06_2/src/main.rs #[macro_use] extern crate aoc; use std::collections::BTreeSet; use itertools::Itertools; <|fim_suffix|> input .split("\n\n") .map(|group| group .lines() .map(|answers| answers .chars() .col...
code_fim
medium
{ "lang": "rust", "repo": "panicbit/advent_of_code_20", "path": "/day06_2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input .split("\n\n") .map(|group| group .lines() .map(|answers| answers .chars() .collect::<BTreeSet<_>>() ) .fold1(|answers1, answers2| answers1 .intersection(&answers2) .copied() .collect() ) ...
code_fim
medium
{ "lang": "rust", "repo": "panicbit/advent_of_code_20", "path": "/day06_2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: baxtersa/decepticon path: /src/nn/network.rs use super::neuron; use super::neuron::{Neuron, NeuronBase}; use std::iter; #[derive(Debug, PartialEq)] pub struct Network { hidden_layer: Vec<neuron::HiddenNeuron>, outputs: Vec<neuron::OutputNeuron>, } impl Network { const LEARN_RATE: f...
code_fim
hard
{ "lang": "rust", "repo": "baxtersa/decepticon", "path": "/src/nn/network.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let network = Network { hidden_layer: vec![ neuron::HiddenNeuron::new(vec![1.0, 1.0], 0.0), neuron::HiddenNeuron::new(vec![1.0, 1.0], 0.0), ], outputs: vec![neuron::OutputNeuron::new(vec![1.0, 1.0], 0.0)], }; assert_eq!(vec![0.5236951740839997],...
code_fim
hard
{ "lang": "rust", "repo": "baxtersa/decepticon", "path": "/src/nn/network.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) use self::memory::IonPool; pub use crate::shell::{ binary::MAN_ION, flags, pipe_exec::job_control::JobControl, status, Binary, Capture, Fork, IonError, IonResult, Shell, ShellBuilder, }; pub fn version() -> &'static str { include!(concat!(env!("OUT_DIR"), "/version_string")) }<|fim_pre...
code_fim
medium
{ "lang": "rust", "repo": "huntdog1541/ion", "path": "/src/lib/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: huntdog1541/ion path: /src/lib/lib.rs #![allow(unknown_lints)] #[macro_use] extern crate bitflags; #[macro_use] extern crate err_derive; extern crate ion_braces as braces; extern crate ion_lexers as lexers; extern crate ion_ranges as ranges; extern crate ion_sys as sys; <|fim_suffix|>pub fn ve...
code_fim
hard
{ "lang": "rust", "repo": "huntdog1541/ion", "path": "/src/lib/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ruggeri/nedbase path: /src/node/interior_node/traversal.rs use super::InteriorNode; use node::{util::search_sorted_strings_for_str, TraversalDirection}; // These methods are all ways to move from an InteriorNode to a child. impl InteriorNode { pub fn child_identifier_by_idx(&self, idx: usize)...
code_fim
hard
{ "lang": "rust", "repo": "ruggeri/nedbase", "path": "/src/node/interior_node/traversal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (left_sibbling_identifier, right_sibbling_identifier) } pub fn traverse_toward(&self, key: &str) -> TraversalDirection<&str> { if !self.max_value.is_ge_to(key) { let next_node_identifier = self .next_node_identifier .as_ref() .expect("node with definite max value...
code_fim
hard
{ "lang": "rust", "repo": "ruggeri/nedbase", "path": "/src/node/interior_node/traversal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tokio-rs/axum path: /axum/src/routing/path_router.rs use crate::extract::Request; use axum_core::response::IntoResponse; use matchit::MatchError; use std::{borrow::Cow, collections::HashMap, convert::Infallible, fmt, sync::Arc}; use tower_layer::Layer; use tower_service::Service; use super::{ ...
code_fim
hard
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum/src/routing/path_router.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> PathRouter { routes, node: self.node, prev_route_id: self.prev_route_id, } } pub(super) fn call_with_state( &mut self, mut req: Request, state: S, ) -> Result<RouteFuture<Infallible>, (Request, S)> { #[cfg(fea...
code_fim
hard
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum/src/routing/path_router.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let path = req.uri().path().to_owned(); match self.node.at(&path) { Ok(match_) => { let id = *match_.value; if !IS_FALLBACK { #[cfg(feature = "matched-path")] crate::extract::matched_path::set_matched_pat...
code_fim
hard
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum/src/routing/path_router.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tpoliaw/bluez-rs path: /src/socket.rs use std::os::raw::c_ushort; use std::u16; use async_std::io::{self}; use async_std::os::unix::io::{FromRawFd, RawFd}; use async_std::os::unix::net::UnixStream; use bytes::buf::BufExt; use bytes::*; use futures::io::{AsyncReadExt, AsyncWriteExt, BufReader, R...
code_fim
hard
{ "lang": "rust", "repo": "tpoliaw/bluez-rs", "path": "/src/socket.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return Err(err); } let stream = unsafe { UnixStream::from_raw_fd(fd) }; let (read_stream, write_stream) = stream.split(); Ok(ManagementSocket { reader: BufReader::new(read_stream), writer: write_stream, }) } /// Returns...
code_fim
hard
{ "lang": "rust", "repo": "tpoliaw/bluez-rs", "path": "/src/socket.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: czyczk/LeetCode path: /rust/lc-600/src/main.rs mod solution; use solution::Solution; <|fim_suffix|> assert_eq!(5, Solution::find_integers(5)); assert_eq!(2, Solution::find_integers(1)); assert_eq!(3, Solution::find_integers(2)); assert_eq!(2178309, Solution::find_integers(100000...
code_fim
easy
{ "lang": "rust", "repo": "czyczk/LeetCode", "path": "/rust/lc-600/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(5, Solution::find_integers(5)); assert_eq!(2, Solution::find_integers(1)); assert_eq!(3, Solution::find_integers(2)); assert_eq!(2178309, Solution::find_integers(1000000000)); }<|fim_prefix|>// repo: czyczk/LeetCode path: /rust/lc-600/src/main.rs mod solution; use solution::So...
code_fim
easy
{ "lang": "rust", "repo": "czyczk/LeetCode", "path": "/rust/lc-600/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>{ let deserialized = statement::serialize_row(&statement)?; let mut cursor = cursor::Cursor::table_find(table, statement.id())?; cursor.serialize_row_add(deserialized) } fn execute_select_statement(context: &mut context::Context, table: &mut table::Table) -> Result<(), String> { let mut c...
code_fim
hard
{ "lang": "rust", "repo": "ashishnegi/learndb", "path": "/src/sqliters/sqlcommands.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while !cursor.end_of_table() { { let serialized = cursor.cursor_value()?; context.select_out(&statement::deserialize_row(serialized.to_vec())?); } cursor.advance_cursor()? } Ok(()) }<|fim_prefix|>// repo: ashishnegi/learndb path: /src/sqliters/...
code_fim
hard
{ "lang": "rust", "repo": "ashishnegi/learndb", "path": "/src/sqliters/sqlcommands.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ashishnegi/learndb path: /src/sqliters/sqlcommands.rs use sqliters::{statement, table, cursor, context}; pub fn process_sql_command(context: &mut context::Context, table: &mut table::Table, command : &str) -> Result<(), String> { let result = statement::prepare_statement(command); match...
code_fim
hard
{ "lang": "rust", "repo": "ashishnegi/learndb", "path": "/src/sqliters/sqlcommands.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: creativcoder/forest path: /node/clock/src/lib.rs // Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT const _ISO_FORMAT: &str = "%FT%X.%.9F"; <|fim_suffix|>/// Const used within the VM to denote an unset `ChainEpoch` pub const EPOCH_UNDEFINED: ChainEpoch = -1;<|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/node/clock/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Epoch number of a chain. This acts as a proxt for time within the VM. pub type ChainEpoch = i64; /// Const used within the VM to denote an unset `ChainEpoch` pub const EPOCH_UNDEFINED: ChainEpoch = -1;<|fim_prefix|>// repo: creativcoder/forest path: /node/clock/src/lib.rs // Copyright 2020 ChainSafe...
code_fim
medium
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/node/clock/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Response: Sized { fn from_apdu(res: apdu::Response) -> Result<Self>; } impl Response for () { fn from_apdu(_res: apdu::Response) -> Result<Self> { Ok(()) } }<|fim_prefix|>// repo: eiritana/cardinal path: /src/cmd.rs use crate::apdu; use crate::errors::Result; pub trait Req...
code_fim
hard
{ "lang": "rust", "repo": "eiritana/cardinal", "path": "/src/cmd.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eiritana/cardinal path: /src/cmd.rs use crate::apdu; use crate::errors::Result; pub trait Request { type Returns: Response; // Returns the class byte; this is typically always 0x00 unless your command // requires specific bits to be set, as context-sensitive bits will be set on ...
code_fim
medium
{ "lang": "rust", "repo": "eiritana/cardinal", "path": "/src/cmd.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut particle = 0; let mut min_acceleration = usize::max_value(); for (i, p) in particles.iter().enumerate() { let a = (p.acceleration.0.abs() + p.acceleration.1.abs() + p.acceleration.2.abs()).abs() as usize; if a < min_acceleration { min_accelerati...
code_fim
hard
{ "lang": "rust", "repo": "jasilven/aoc-2017-rust", "path": "/src/bin/day20.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jasilven/aoc-2017-rust path: /src/bin/day20.rs use failure::Error; use std::collections::HashSet; use std::fs; use std::io::{BufRead, BufReader}; type Result<T> = std::result::Result<T, Error>; #[derive(Debug, PartialEq, Ord, PartialOrd, Eq, Hash, Clone)] struct Particle { position: (i64, ...
code_fim
hard
{ "lang": "rust", "repo": "jasilven/aoc-2017-rust", "path": "/src/bin/day20.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> particles.sort_by(|a, b| a.position.cmp(&b.position)); let mut duplicates = HashSet::new(); for i in 1..particles.len() { if particles[i - 1].position == particles[i].position { duplicates.insert(particles[i - 1].clone()); duplicates.in...
code_fim
hard
{ "lang": "rust", "repo": "jasilven/aoc-2017-rust", "path": "/src/bin/day20.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eatmymalware/serenitylol path: /src/model/guild/system_channel.rs use bitflags::__impl_bitflags; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use crate::internal::prelude::StdResult; use crate::model::utils::U64Visitor; /// Describes a system channel flags. #[derive(Copy, Par...
code_fim
hard
{ "lang": "rust", "repo": "eatmymalware/serenitylol", "path": "/src/model/guild/system_channel.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }