text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: w1r2p1/RustUniswapSimulator path: /src/main.rs struct Token { name: String, symbol: String, decimals: u8, } struct UniswapPool { token1: Token, token2: Token, token1_amount: u128, token2_amount: u128, k: u128, } impl UniswapPool { fn new(token1: Token, token...
code_fim
hard
{ "lang": "rust", "repo": "w1r2p1/RustUniswapSimulator", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plops/cl-rust-generator path: /examples/03_glium/rs03_glium/src/main.rs #[macro_use] extern crate glium; fn main() { #[allow(unused_imports)] use glium::{glutin, Surface}; let event_loop = glium::glutin::event_loop::EventLoop::new(); let wb = glium::glutin::window::WindowBuilder:...
code_fim
hard
{ "lang": "rust", "repo": "plops/cl-rust-generator", "path": "/examples/03_glium/rs03_glium/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> color = vec4(1.0,0.0,0.0,1.0); } "##; let program = glium::Program::from_source(&display, vertex_shader_source, fragment_shader_source, None) .unwrap(); let mut time: f32 = (-0.50); event_loop.run(move |event, _, control_flow| { let next_frame_time = (...
code_fim
hard
{ "lang": "rust", "repo": "plops/cl-rust-generator", "path": "/examples/03_glium/rs03_glium/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.handler .struct_warn("with statement") .set_span(stmt.span) .emit(); } }<|fim_prefix|>// repo: JasperDeSutter/swc path: /ecmascript/lints/src/with.rs use swc_common::{errors::Handler, Visit}; use swc_ecma_ast::*; pub struct With<'a> { pub handler:...
code_fim
medium
{ "lang": "rust", "repo": "JasperDeSutter/swc", "path": "/ecmascript/lints/src/with.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JasperDeSutter/swc path: /ecmascript/lints/src/with.rs use swc_common::{errors::Handler, Visit}; use swc_ecma_ast::*; <|fim_suffix|> self.handler .struct_warn("with statement") .set_span(stmt.span) .emit(); } }<|fim_middle|>pub struct With<'a> { ...
code_fim
medium
{ "lang": "rust", "repo": "JasperDeSutter/swc", "path": "/ecmascript/lints/src/with.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_ray_misses_translated_shape() { let r = Ray { origin: point(0.0, 0.0, -5.0), direction: vector(0.0, 0.0, 1.0), }; let s = Arc::new(Shape { parent: None, intersectable: Intersectable::sphere(), trans...
code_fim
hard
{ "lang": "rust", "repo": "jcmorrow/ray_tracer", "path": "/src/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcmorrow/ray_tracer path: /src/ray.rs use intersection::Intersection; use matrix::Matrix4; use point::Point; use shape::Shape; use std::cell::RefCell; use std::sync::Arc; use world::World; thread_local!(static ray_count: RefCell<i64> = RefCell::new(0)); pub struct Ray { pub origin: Point, ...
code_fim
hard
{ "lang": "rust", "repo": "jcmorrow/ray_tracer", "path": "/src/ray.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_ray_transform() { let r = Ray { origin: point(1.0, 2.0, 3.0), direction: vector(0.0, 1.0, 0.0), }; let m = Matrix4::translation(3.0, 4.0, 5.0); let r2 = r.transform(m); assert!(r2.origin.equal(&point(4.0, 6.0, 8.0)));...
code_fim
hard
{ "lang": "rust", "repo": "jcmorrow/ray_tracer", "path": "/src/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Houkime/ruma path: /crates/ruma-identifiers/src/room_name.rs //! Matrix room name. <|fim_suffix|>opaque_identifier_validated! { /// The name of a room. /// /// It can't exceed 255 bytes or be empty. pub type RoomName [ validate ]; }<|fim_middle|>use ruma_identifiers_validation::...
code_fim
easy
{ "lang": "rust", "repo": "Houkime/ruma", "path": "/crates/ruma-identifiers/src/room_name.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>opaque_identifier_validated! { /// The name of a room. /// /// It can't exceed 255 bytes or be empty. pub type RoomName [ validate ]; }<|fim_prefix|>// repo: Houkime/ruma path: /crates/ruma-identifiers/src/room_name.rs //! Matrix room name. <|fim_middle|>use ruma_identifiers_validation::...
code_fim
easy
{ "lang": "rust", "repo": "Houkime/ruma", "path": "/crates/ruma-identifiers/src/room_name.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> From<&std::task::Context<'a>> for Context<'a> { fn from(cx: &std::task::Context<'a>) -> Self { Self::from_waker(cx.waker()) } } impl<'a> From<&mut std::task::Context<'a>> for Context<'a> { fn from(cx: &mut std::task::Context<'a>) -> Self { Self::from_waker(cx.waker())...
code_fim
medium
{ "lang": "rust", "repo": "woubuc/postage-rs", "path": "/src/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: woubuc/postage-rs path: /src/context.rs use std::task::Waker; /// The `Context` of an asynchronous task. /// /// Unlike std::task::Context, this context *optionally* contains a waker. /// /// This is necessary because try_send and try_recv need to poll, /// but the task waker should not be saved...
code_fim
medium
{ "lang": "rust", "repo": "woubuc/postage-rs", "path": "/src/context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self::from_waker(cx.waker()) } } impl<'a> From<&mut std::task::Context<'a>> for Context<'a> { fn from(cx: &mut std::task::Context<'a>) -> Self { Self::from_waker(cx.waker()) } } impl<'a> Context<'a> { /// Create a new `Context` from a `&Waker`. pub fn from_waker(waker...
code_fim
medium
{ "lang": "rust", "repo": "woubuc/postage-rs", "path": "/src/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: killercup/file-sniffer path: /src/error.rs extern crate regex; extern crate colored; <|fim_suffix|>pub fn check_regex(re: &str) -> Regex { if let Ok(r) = Regex::new(re) { r } else if let Err(x) = Regex::new(re) { println!("{}: Invalid regex:\n {}",...
code_fim
easy
{ "lang": "rust", "repo": "killercup/file-sniffer", "path": "/src/error.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub fn check_regex(re: &str) -> Regex { if let Ok(r) = Regex::new(re) { r } else if let Err(x) = Regex::new(re) { println!("{}: Invalid regex:\n {}", "Error".red(), x); process::exit(0x0f01) } else { process::exit(0x0f0...
code_fim
easy
{ "lang": "rust", "repo": "killercup/file-sniffer", "path": "/src/error.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ryan1729/rote path: /libs/rope_pos/src/rope_pos.rs use editor_types::{Position, Cursor}; use macros::CheckedSub; use panic_safe_rope::*; pub use panic_safe_rope::is_linebreak_char; use std::borrow::Borrow; mod absolute_char_offset_range { use super::*; #[derive(Copy, Clone, Debug, Ha...
code_fim
hard
{ "lang": "rust", "repo": "Ryan1729/rote", "path": "/libs/rope_pos/src/rope_pos.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let second_last = get_char_before_len!(); if second_last == '\r' { len -= 1; return_if_0!(); } } else if is_linebreak_char(last) { len -= 1; return_if_0!(); } len } fn get_line_char_iterator<R: std::ops::RangeBounds<CharOff...
code_fim
hard
{ "lang": "rust", "repo": "Ryan1729/rote", "path": "/libs/rope_pos/src/rope_pos.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[must_use] /// Returns `None` iff the position is not valid for the given rope. #[perf_viz::record] pub fn pos_to_char_offset(rope: &Rope, position: &Position) -> Option<AbsoluteCharOffset> { let line_index = LineIndex(position.line); let line_start = rope.line_to_char(line_index)?; let line...
code_fim
hard
{ "lang": "rust", "repo": "Ryan1729/rote", "path": "/libs/rope_pos/src/rope_pos.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tuanir/fantoch path: /fantoch/src/metrics/float.rs use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::fmt; #[derive(PartialOrd, Deserialize, Serialize, Clone, Copy)] pub struct F64(f64); impl F64 { pub fn new(x: f64) -> Self { Self(x) } pub fn zero() -> ...
code_fim
hard
{ "lang": "rust", "repo": "tuanir/fantoch", "path": "/fantoch/src/metrics/float.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn add(self, other: Self) -> Self { Self(self.0 + other.0) } } impl std::ops::AddAssign for F64 { fn add_assign(&mut self, other: Self) { *self = Self(self.0 + other.0); } } impl std::ops::Sub for F64 { type Output = Self; fn sub(self, other: Self) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "tuanir/fantoch", "path": "/fantoch/src/metrics/float.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use utils::write_saved; pub use filters::filter_all; pub use anagrams::{AsStr, SimpleAdapter, Store, Adapter, Tester, AsciiTester, MemoryStore, EditDistance, process_item, check_item}; pub use mdbm::Mdbm;<|fim_prefix|>// repo: cmyr/amanga-rs path: /src/lib.rs extern crate gnip_twitter_stream; extern ...
code_fim
medium
{ "lang": "rust", "repo": "cmyr/amanga-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cmyr/amanga-rs path: /src/lib.rs extern crate gnip_twitter_stream; extern crate serde_json; extern crate serde; extern crate chrono; extern crate flate2; extern crate gnudbm; extern crate lru_cache; #[cfg(test)] extern crate tempdir; <|fim_suffix|>pub use utils::write_saved; pub use filters::fi...
code_fim
medium
{ "lang": "rust", "repo": "cmyr/amanga-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>the referenced transaction has already been received/spent Received, /// For a send block, the balance sent must be nonzero ZeroSend, /// For a send block, the balance sent must be less than or equal to the account balance OverSend, /// A block this transact...
code_fim
hard
{ "lang": "rust", "repo": "exrook/crypto", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>tion references is missing Missing, /// This transaction is structurally invalid, e.x. an Open block that references a receive /// block or a change block as its source Invalid, /// This error should not happen, if it does there is a bug Unreachable, } }...
code_fim
hard
{ "lang": "rust", "repo": "exrook/crypto", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: exrook/crypto path: /src/lib.rs #![feature(i128_type, never_type, try_from)] extern crate blake2; extern crate byteorder; extern crate ed25519_dalek; extern crate rand; #[cfg(test)] mod tests; mod genesis; mod transaction; mod types; mod blockstorage; mod work; mod errors { #[derive(Debug, ...
code_fim
hard
{ "lang": "rust", "repo": "exrook/crypto", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dnsl48/base91 path: /src/iter/encode.rs use core::iter::Iterator; use core::marker::PhantomData; use crate::codemap::Encoding; pub struct EncodeGenericIterator<E, I> where E: Encoding, I: Iterator<Item = u8>, { buf: u8, rem: u32, shift: u32, data: I, codemap: Phanto...
code_fim
hard
{ "lang": "rust", "repo": "dnsl48/base91", "path": "/src/iter/encode.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.shift > 13 { let mut key: u32 = self.rem & 8191; if key > 88 { self.rem >>= 13; self.shift -= 13; } else { key = self.rem & 16383; ...
code_fim
hard
{ "lang": "rust", "repo": "dnsl48/base91", "path": "/src/iter/encode.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hajime-san/d3d12-tutorial path: /hello_triangle/src/win.rs use bindings::{ windows::win32::system_services::{ CreateEventW, GetModuleHandleW, SetEvent, WaitForSingleObject, CS_HREDRAW, CS_VREDRAW, IDI_APPLICATION, IDC_ARROW, ...
code_fim
hard
{ "lang": "rust", "repo": "Hajime-san/d3d12-tutorial", "path": "/hello_triangle/src/win.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match msg as i32 { WM_DESTROY => unsafe { PostQuitMessage(0); LRESULT(0) }, _ => unsafe { DefWindowProcW(hwnd, msg, w_param, l_param) }, } } pub fn creat_message() -> M...
code_fim
hard
{ "lang": "rust", "repo": "Hajime-san/d3d12-tutorial", "path": "/hello_triangle/src/win.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub extern "system" fn window_procedure(hwnd: HWND, msg: u32, w_param: WPARAM, l_param: LPARAM) -> LRESULT { match msg as i32 { WM_DESTROY => unsafe { PostQuitMessage(0); LRESULT(0) }, _ => unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "Hajime-san/d3d12-tutorial", "path": "/hello_triangle/src/win.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rimutaka/ld-lambdas path: /src/main.rs use log::debug; use simple_logger; use tokio; use tokio_postgres::Error; use uuid::Uuid; //use dynamodb_data; mod structures_ddb; mod structures_pg; mod utils; #[tokio::main] // By default, tokio_postgres uses the tokio crate as its runtime. async fn main...
code_fim
hard
{ "lang": "rust", "repo": "rimutaka/ld-lambdas", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // check if updated successfully assert!(list_updated.is_ok()); let list_updated = list_updated.unwrap(); assert!(list_updated.is_some()); let list_updated = list_updated.unwrap(); assert!(list_updated.description.is_some()); assert_eq!(list_updated.description.unwrap(), new_de...
code_fim
hard
{ "lang": "rust", "repo": "rimutaka/ld-lambdas", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn wait_with_empty() { let mut scheduler = Scheduler::with_time_source(Duration::seconds(1), MockTimeSourceWait::new()); assert_eq!(scheduler.wait(), Err(WaitError::Empty)); scheduler.after(Duration::seconds(0), 0); assert_eq!(scheduler.wait(), Ok(vec![0]))...
code_fim
hard
{ "lang": "rust", "repo": "jpastuszek/token_scheduler", "path": "/src/scheduler/wait.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(scheduler.try(), Some(Ok(vec![0]))); assert_eq!(scheduler.try(), None); assert_eq!(scheduler.try(), None); scheduler.fast_forward(Duration::seconds(1)); assert_eq!(scheduler.try(), Some(Ok(vec![1]))); assert_eq!(scheduler.try(), None); s...
code_fim
hard
{ "lang": "rust", "repo": "jpastuszek/token_scheduler", "path": "/src/scheduler/wait.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jpastuszek/token_scheduler path: /src/scheduler/wait.rs use std::fmt; use std::error::Error; use std::any::Any; use time::Duration; use time_source::*; use scheduler::*; pub enum WaitError<Token> { Empty, Overrun(Vec<Token>) } impl<Token> PartialEq for WaitError<Token> where Token: Pa...
code_fim
hard
{ "lang": "rust", "repo": "jpastuszek/token_scheduler", "path": "/src/scheduler/wait.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aiuto/starlark-rust path: /starlark/src/eval/fragment/expr.rs CENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * Se...
code_fim
hard
{ "lang": "rust", "repo": "aiuto/starlark-rust", "path": "/starlark/src/eval/fragment/expr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn unpack_string_literal(&self) -> Option<&str> { match self { Expr::Literal(AstLiteral::StringLiteral(i)) => Some(&i.node), _ => None, } } // Does an entire sequence of additions reduce to a string literal fn reduces_to_string<'a>( mut op: ...
code_fim
hard
{ "lang": "rust", "repo": "aiuto/starlark-rust", "path": "/starlark/src/eval/fragment/expr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let v = exprs.into_map(|(k, v)| (self.expr(k), self.expr(v))); expr!(|eval| { let mut r = SmallMap::with_capacity(v.len()); for (k, v) in v.iter() { let k = k(eval)?; if r.insert_hashed(...
code_fim
hard
{ "lang": "rust", "repo": "aiuto/starlark-rust", "path": "/starlark/src/eval/fragment/expr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); let conn = &mut PgConnection::establish(&database_url) .unwrap_or_else(|e| panic!("Error connecting to {}: {}", database_url, e)); let _ = diesel::insert_into(translations::table) .values(&Tra...
code_fim
medium
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/examples/postgres/custom_types/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diesel-rs/diesel path: /examples/postgres/custom_types/src/main.rs use self::schema::translations; use diesel::prelude::*; mod model; mod schema; #[derive(Debug, Queryable, Insertable)] #[diesel(table_name = translations)] pub struct Translation { word_id: i32, translation_id: i32, ...
code_fim
medium
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/examples/postgres/custom_types/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let _ = diesel::insert_into(translations::table) .values(&Translation { word_id: 1, translation_id: 1, language: model::Language::En, }) .execute(conn); let t = translations::table .select(( translations::word_id, ...
code_fim
hard
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/examples/postgres/custom_types/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: baka233/parser path: /src/token.rs use std::cmp::{Ord, PartialOrd}; #[derive<|fim_suffix|>rd, Hash)] pub enum Token { Epsilon, Character(char), Identifier(char), }<|fim_middle|>(Clone, Debug, Eq, PartialEq, Ord, PartialO
code_fim
easy
{ "lang": "rust", "repo": "baka233/parser", "path": "/src/token.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Character(char), Identifier(char), }<|fim_prefix|>// repo: baka233/parser path: /src/token.rs use std::cmp::{Ord, PartialOrd}; #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialO<|fim_middle|>rd, Hash)] pub enum Token { Epsilon,
code_fim
easy
{ "lang": "rust", "repo": "baka233/parser", "path": "/src/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rd, Hash)] pub enum Token { Epsilon, Character(char), Identifier(char), }<|fim_prefix|>// repo: baka233/parser path: /src/token.rs use std::cmp::{Ord, PartialOrd}; #[derive<|fim_middle|>(Clone, Debug, Eq, PartialEq, Ord, PartialO
code_fim
easy
{ "lang": "rust", "repo": "baka233/parser", "path": "/src/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn exec(_env: &dyn Environment, opts: ToolchainInstall) -> DfxResult { for s in opts.toolchains { let toolchain = s.parse::<Toolchain>()?; toolchain.update()?; } Ok(()) }<|fim_prefix|>// repo: jplevyak/sdk path: /src/dfx/src/commands/toolchain/install.rs use crate::lib::en...
code_fim
hard
{ "lang": "rust", "repo": "jplevyak/sdk", "path": "/src/dfx/src/commands/toolchain/install.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jplevyak/sdk path: /src/dfx/src/commands/toolchain/install.rs use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::toolchain::Toolchain; use clap::Clap; <|fim_suffix|>pub fn exec(_env: &dyn Environment, opts: ToolchainInstall) -> DfxResult { for s in ...
code_fim
hard
{ "lang": "rust", "repo": "jplevyak/sdk", "path": "/src/dfx/src/commands/toolchain/install.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: udoprog/fixed-map path: /benches/complex.rs use criterion::{Bencher, BenchmarkId, Criterion}; use std::mem; macro_rules! benches { ( $({ $len:expr, ($($member:ident),* $(,)?), insert = [$($insert:ident),* $(,)?], get => $get:ident, entry => [$($entry:iden...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/fixed-map", "path": "/benches/complex.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> group.bench_with_input(BenchmarkId::new("array", $len), &$len, |b: &mut Bencher, _| { let mut it = 1u32..; let mut map = [None; $len]; $(map[Key::$insert as usize] = Some(it.next().unwrap());)* b.iter(|| { let...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/fixed-map", "path": "/benches/complex.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> group.bench_with_input(BenchmarkId::new("fixed", $len), &$len, |b: &mut Bencher, _| { let mut it = 1u32..; let mut map = fixed_map::Map::new(); $(map.insert(Key::$insert, it.next().unwrap());)* b.iter(|| { let...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/fixed-map", "path": "/benches/complex.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match ev { WatchEvent::Added(o) => { let name = Meta::name(&o); let containers = o .spec .unwrap() .containers .into_iter() .map(|c| c.name) .collect::<Vec<_>>(); ...
code_fim
hard
{ "lang": "rust", "repo": "JonnyWalker81/kube-rs", "path": "/kube/examples/pod_informer.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JonnyWalker81/kube-rs path: /kube/examples/pod_informer.rs #[macro_use] extern crate log; use futures::{StreamExt, TryStreamExt}; use k8s_openapi::api::core::v1::Pod; use kube::{ api::{Api, ListParams, Meta, WatchEvent}, runtime::Informer, Client, }; use std::env; #[tokio::main] asy...
code_fim
hard
{ "lang": "rust", "repo": "JonnyWalker81/kube-rs", "path": "/kube/examples/pod_informer.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(event) = pods.try_next().await? { handle_pod(event)?; } } } // This function lets the app handle an event from kube fn handle_pod(ev: WatchEvent<Pod>) -> anyhow::Result<()> { match ev { WatchEvent::Added(o) => { let name = Meta::name(...
code_fim
hard
{ "lang": "rust", "repo": "JonnyWalker81/kube-rs", "path": "/kube/examples/pod_informer.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LinAGKar/advent-of-code-2015-rust path: /day23b/src/main.rs use std::io::Read; enum Instr { HLF(usize), TPL(usize), INC(usize), JMP(isize), JIE(usize, isize), JIO(usize, isize), } fn main() { let mut input = String::new(); std::io::stdin().read_to_string(&mut in...
code_fim
hard
{ "lang": "rust", "repo": "LinAGKar/advent-of-code-2015-rust", "path": "/day23b/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(instruction) = instructions.get(pc as usize) { pc += 1; match *instruction { Instr::HLF(reg) => { regs[reg] /= 2; }, Instr::TPL(reg) => { regs[reg] *= 3; }, Instr::INC(reg) => { regs[reg] += 1; }, Instr::JMP(offset) => { p...
code_fim
hard
{ "lang": "rust", "repo": "LinAGKar/advent-of-code-2015-rust", "path": "/day23b/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> types::to_from_string::test(); }<|fim_prefix|>// repo: knknkn1162/sutramaking-rustbyexample path: /src/main.rs //mod hello; //mod primitives; //mod custom_type; //mod flow_control; //mod destructuring; //mod std_lib; //mod modules; //mod attributes; //mod generics; //mod scoping; //mod traits; //mod ...
code_fim
easy
{ "lang": "rust", "repo": "knknkn1162/sutramaking-rustbyexample", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: knknkn1162/sutramaking-rustbyexample path: /src/main.rs //mod hello; //mod primitives; //mod custom_type; //mod flow_control; //mod destructuring; //mod std_lib; //mod modules; //mod attributes; //mod generics; //mod scoping; //mod traits; //mod macro_rules; //mod error_handling; //mod std_type;...
code_fim
easy
{ "lang": "rust", "repo": "knknkn1162/sutramaking-rustbyexample", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; #[test] fn test_ch9() { assert_eq!( pkcs_7_padding(b"YELLOW SUBMARINE", 20), b"YELLOW SUBMARINE\x04\x04\x04\x04", ) } #[test] fn test_ch10() { let data = load_base64_file(PathBuf::from( ...
code_fim
hard
{ "lang": "rust", "repo": "nmiculinic/rust-exp", "path": "/src/sets2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nmiculinic/rust-exp path: /src/sets2.rs extern crate base64; extern crate hex; extern crate pretty_hex; use pretty_hex::*; use super::io::*; use openssl::symm::{decrypt, encrypt, Cipher}; use rand::prelude::*; use std::path::PathBuf; pub fn pkcs_7_padding(data: &[u8], padding_size: usize) -> V...
code_fim
hard
{ "lang": "rust", "repo": "nmiculinic/rust-exp", "path": "/src/sets2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let data = load_base64_file(PathBuf::from( env!("CARGO_MANIFEST_DIR").to_owned() + "/data/12.in", )) .unwrap(); println!("plaintext size: {}", data.len()); let mut rng = rand::thread_rng(); let mut key: [u8; 16] = [0; 16]; rng.fill_bytes...
code_fim
hard
{ "lang": "rust", "repo": "nmiculinic/rust-exp", "path": "/src/sets2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: funmaker/Project39-ar path: /src/application/vr/tracked_camera/mod.rs use ::openvr_sys as sys; use openvr::{Context, TrackedDeviceIndex}; mod error; mod utils; pub use error::*; pub use utils::*; #[derive(Copy, Clone)] pub struct TrackedCamera(FnTable); impl TrackedCamera { pub fn new(...
code_fim
hard
{ "lang": "rust", "repo": "funmaker/Project39-ar", "path": "/src/application/vr/tracked_camera/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } pub unsafe fn get_video_stream_frame_buffer(&self, handle: TrackedCameraHandle, frame_type: FrameType, buffer: &mut [u8]) -> Result<CameraVideoStreamFrameHeader, TrackedCameraError> { let mut header = CameraVideoStreamFrameHeader { eFrameType: frame_type.into(), nWidth: 0, ...
code_fim
hard
{ "lang": "rust", "repo": "funmaker/Project39-ar", "path": "/src/application/vr/tracked_camera/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>lazy_static! { pub static ref DB_KEY_PREFIX: &'static str = match option_env!("DB_KEY_PREFIX") { Some(prefix) => prefix, None => "", }; } lazy_static! { pub static ref SAFE_ETH_ADDRESS: EthAddress = EthAddress::from_slice(&hex::decode(SAFE_ETH_ADDRESS_HEX).unwrap()); }<|fim_pr...
code_fim
hard
{ "lang": "rust", "repo": "wilfra/ptokens-core", "path": "/src/constants.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wilfra/ptokens-core path: /src/constants.rs use ethereum_types::Address as EthAddress; #[cfg(feature="debug")] pub const DEBUG_MODE: bool = true; #[cfg(not(feature="debug"))] pub const DEBUG_MODE: bool = false; #[cfg(feature="non-validating")] pub const CORE_IS_VALIDATING: bool = false; <|fi...
code_fim
medium
{ "lang": "rust", "repo": "wilfra/ptokens-core", "path": "/src/constants.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: orin220444/echocli path: /src/main.rs use rand::prelude::*; use std::cmp::Ordering; use std::io; fn main() { loop { println!("type something"); let mut user_typings = String::new(); io::stdin() .read_line(&mut user_typings) .expect("Failed to r...
code_fim
hard
{ "lang": "rust", "repo": "orin220444/echocli", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>r_number.trim().parse().expect("Please type a number!"); match user_number.cmp(&secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); break...
code_fim
hard
{ "lang": "rust", "repo": "orin220444/echocli", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tari-project/tari path: /base_layer/wallet/src/connectivity_service/service.rs // Copyright 2021, The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions ...
code_fim
hard
{ "lang": "rust", "repo": "tari-project/tari", "path": "/base_layer/wallet/src/connectivity_service/service.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl WalletConnectivityService { pub(super) fn new( config: BaseNodeServiceConfig, request_receiver: mpsc::Receiver<WalletConnectivityRequest>, base_node_watch: watch::Receiver<Option<Peer>>, online_status_watch: Watch<OnlineStatus>, connectivity: ConnectivityRe...
code_fim
hard
{ "lang": "rust", "repo": "tari-project/tari", "path": "/base_layer/wallet/src/connectivity_service/service.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> async fn try_dial_peer(&mut self, peer: NodeId) -> Result<Option<PeerConnection>, WalletConnectivityError> { tokio::select! { biased; _ = self.base_node_watch.changed() => { Ok(None) } result = self.connectivity.dial_peer(peer) =...
code_fim
hard
{ "lang": "rust", "repo": "tari-project/tari", "path": "/base_layer/wallet/src/connectivity_service/service.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn refresh(&mut self) { let uptime = self.uptime(); self.refresh_ui(uptime); } fn uptime(&mut self) -> Duration { let ms: embedded_time::duration::units::Milliseconds = self.rtc_mono.now().into(); core::time::Duration::from_millis(ms.integer().into()) } ...
code_fim
hard
{ "lang": "rust", "repo": "Nitrokey/nitrokey-3-firmware", "path": "/runners/embedded/src/soc_nrf52840/trussed_ui.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let start_time = self.uptime().as_millis(); let timeout_at = start_time + 1_000u128; let mut next_check = start_time + 25u128; self.set_status(ui::Status::WaitingForUserPresence); UserPresenceStatus::set_waiting(true); loop { let cur_time = sel...
code_fim
hard
{ "lang": "rust", "repo": "Nitrokey/nitrokey-3-firmware", "path": "/runners/embedded/src/soc_nrf52840/trussed_ui.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nitrokey/nitrokey-3-firmware path: /runners/embedded/src/soc_nrf52840/trussed_ui.rs //! Implementation of `trussed::Platform` for the board, //! using the specific implementation of our `crate::traits`. use core::time::Duration; use crate::traits::{ buttons::{Button, Press}, rgb_led::R...
code_fim
hard
{ "lang": "rust", "repo": "Nitrokey/nitrokey-3-firmware", "path": "/runners/embedded/src/soc_nrf52840/trussed_ui.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/tracing-attributes/tests/names.rs use tracing : : subscriber : : with_default ; use tracing_attributes : : instrument ; use tracing_mock : : * ; # [ instrument ] fn default_name ( ) { } # [ instrument ( name = " my_name " )...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/tracing-attributes/tests/names.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ( subscriber handle ) = subscriber : : mock ( ) . new_span ( span : : mock ( ) . named ( " my_other_name " ) ) . enter ( span : : mock ( ) . named ( " my_other_name " ) ) . exit ( span : : mock ( ) . named ( " my_other_name " ) ) . done ( ) . run_with_handle ( ) ; with_default ( subscriber | | { cust...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/tracing-attributes/tests/names.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbiason/random path: /mapoptiontest/src/main.rs use std::env; use std::path::PathBuf; fn split(line: &str) -> Option<(String, Vec<String>)> { let mut split = line.split(' '); let root = split.next()?; let arguments = split.map(|x| x.to_string()).collect(); Some((root.to_string()...
code_fim
medium
{ "lang": "rust", "repo": "jbiason/random", "path": "/mapoptiontest/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> env::split_paths(&env::var_os("PATH")?).find_map(|dir| { let full_path = dir.join(command); if full_path.exists() { Some(full_path) } else { None } }) } fn main() { let commands = ["ls -la", "ls", "exa", "not"]; let result = commands...
code_fim
medium
{ "lang": "rust", "repo": "jbiason/random", "path": "/mapoptiontest/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //XXX: Custom DNS server, get default from host? request.send_to(&socket, "8.8.8.8:53"); socket.set_read_timeout(Some(Duration::new(5, 0)))?; let response = DnsResponse::recv_from(&socket)?; for record in &response.records { println!("{}", record); } Ok(response) }<|fi...
code_fim
medium
{ "lang": "rust", "repo": "sjbaker47/rust-nslookup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sjbaker47/rust-nslookup path: /src/main.rs extern crate rand; extern crate byteorder; mod protocol; use std::env; use std::process; use std::error::Error; use std::time::Duration; use std::net::UdpSocket; use protocol::{DnsQuery, DnsResponse}; <|fim_suffix|> let hostname = env::args().nth(...
code_fim
medium
{ "lang": "rust", "repo": "sjbaker47/rust-nslookup", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { for i in 1..101 { let result = fizzbuzz(i); println!("{}", result); } }<|fim_prefix|>// repo: your-diary/FizzBuzz_with_50_languages path: /007_Rust/fizzbuzz.rs // This is a comment. fn fizzbuzz(i: i32) -> String { <|fim_middle|> //defines lambda functions let i...
code_fim
hard
{ "lang": "rust", "repo": "your-diary/FizzBuzz_with_50_languages", "path": "/007_Rust/fizzbuzz.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: your-diary/FizzBuzz_with_50_languages path: /007_Rust/fizzbuzz.rs // This is a comment. fn fizzbuzz(i: i32) -> String { //defines lambda functions let is_fizz = |i| i % 3 == 0; let is_buzz = |i| i % 5 == 0; <|fim_suffix|>fn main() { for i in 1..101 { let result = fizzbu...
code_fim
hard
{ "lang": "rust", "repo": "your-diary/FizzBuzz_with_50_languages", "path": "/007_Rust/fizzbuzz.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /tools/component_id_index/src/main.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use anyhow::{anyhow, Context, Result}; use component_id_index::*; use...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/tools/component_id_index/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // write out the depfile fs::write( &opts.depfile, format!( "{}: {}\n{}: {}\n", opts.output_index_json.to_str().unwrap(), input_files.join(" "), opts.output_index_fidl.to_str().unwrap(), input_files.join(" ") ), ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/tools/component_id_index/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let opts = CommandLineOpts::from_args(); run(opts) } #[cfg(test)] mod tests { use super::*; use moniker::{AbsoluteMoniker, AbsoluteMonikerBase}; use pretty_assertions::assert_eq; use regex; use std::io::Write; use tempfile; fn gen_index(num_instances: u32) -> Index { ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/tools/component_id_index/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theCarlG/fivem-wasm path: /bindings/core/src/wasm_impl/invoker.rs use crate::invoker::RETVAL_BUFFER; <|fim_suffix|> vec.as_ptr() }) }<|fim_middle|>#[no_mangle] pub extern "C" fn __cfx_extend_retval_buffer(new_size: usize) -> *const u8 { RETVAL_BUFFER.with(|retval| { let m...
code_fim
hard
{ "lang": "rust", "repo": "theCarlG/fivem-wasm", "path": "/bindings/core/src/wasm_impl/invoker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> vec.as_ptr() }) }<|fim_prefix|>// repo: theCarlG/fivem-wasm path: /bindings/core/src/wasm_impl/invoker.rs use crate::invoker::RETVAL_BUFFER; <|fim_middle|>#[no_mangle] pub extern "C" fn __cfx_extend_retval_buffer(new_size: usize) -> *const u8 { RETVAL_BUFFER.with(|retval| { let m...
code_fim
hard
{ "lang": "rust", "repo": "theCarlG/fivem-wasm", "path": "/bindings/core/src/wasm_impl/invoker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if options.path.len () > 0 { for directory in options.path { if options.remove_parent { for parent in directory.ancestors () { errno = errno | remove_directory (parent); if errno != 0 { break; } } } else { errno = errno | remove_directory (&directory); ...
code_fim
hard
{ "lang": "rust", "repo": "alexandruradovici/harbour", "path": "/src/rmdir.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexandruradovici/harbour path: /src/rmdir.rs use std::path::PathBuf; use std::path::Path; use std::fs; use std::io; use super::command; command! ("rmdir", "Remove directory(s) if they are empty", execute, (short = "p", long="parents", help = "Include empty parents") remove_parent: bool, <...
code_fim
hard
{ "lang": "rust", "repo": "alexandruradovici/harbour", "path": "/src/rmdir.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>{ let mut errno = 0; if let Err (err) = fs::remove_dir (&directory) { errno = errno | match err.raw_os_error () { Some (e) => e, None => 1 }; eprintln! ("rmdir: {}: {}", directory.to_str().unwrap_or (""), err); } errno } pub fn execute (options: Options) -> Result<(), io::Error> { let mu...
code_fim
medium
{ "lang": "rust", "repo": "alexandruradovici/harbour", "path": "/src/rmdir.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timglabisch/cqueue path: /src/service/queue_msg_service.rs use cdrs::query::QueryBuilder; use cdrs::types::IntoRustByName; use cdrs::types::rows::Row; use driver::Pool; use dto::Partition; pub trait QueueMsgService { fn push_queue_msg(&self, partition: &Partition, offset: u32, content: &s...
code_fim
hard
{ "lang": "rust", "repo": "timglabisch/cqueue", "path": "/src/service/queue_msg_service.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let body = raw_query_result .get_body() .or_else(|_| { Err("[get_queue_msg] could not get body") })?; let rows = body .into_rows() .ok_or_else(|| "[get_queue_msg] could not parse rows".to_string())?; if rows.len() == 0 { ...
code_fim
hard
{ "lang": "rust", "repo": "timglabisch/cqueue", "path": "/src/service/queue_msg_service.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rphmeier/mio path: /src/sys/unix/net.rs use {io}; use sys::unix::{nix, Io}; use std::os::unix::io::{AsRawFd, RawFd, FromRawFd}; pub use net::tcp::Shutdown; pub fn socket(family: nix::AddressFamily, ty: nix::SockType, nonblock: bool) -> io::Result<RawFd> { let opts = if nonblock { ni...
code_fim
medium
{ "lang": "rust", "repo": "rphmeier/mio", "path": "/src/sys/unix/net.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn connect(io: &Io, addr: &nix::SockAddr) -> io::Result<bool> { match nix::connect(io.as_raw_fd(), addr) { Ok(_) => Ok(true), Err(e) => { match e { nix::Error::Sys(nix::EINPROGRESS) => Ok(false), _ => Err(super::from_nix_error(e)) ...
code_fim
medium
{ "lang": "rust", "repo": "rphmeier/mio", "path": "/src/sys/unix/net.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] pub fn dup(io: &Io) -> io::Result<Io> { nix::dup(io.as_raw_fd()) .map_err(super::from_nix_error) .map(|fd| unsafe { Io::from_raw_fd(fd) }) }<|fim_prefix|>// repo: rphmeier/mio path: /src/sys/unix/net.rs use {io}; use sys::unix::{nix, Io}; use std::os::unix::io::{AsRawFd, Raw...
code_fim
hard
{ "lang": "rust", "repo": "rphmeier/mio", "path": "/src/sys/unix/net.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DrJackilD/cidrcalc path: /src/cidr.rs use anyhow::Result; use std::convert::{Into, TryFrom}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::ops::RangeInclusive; /// Structure, which represent subnet as an address and subnet mask #[derive(Debug)] pub struct CIDRNotation { pub addr: IpA...
code_fim
hard
{ "lang": "rust", "repo": "DrJackilD/cidrcalc", "path": "/src/cidr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn parse_cidr_notation() { let input = String::from("192.168.0.1/24"); let cidr: CIDRNotation = input.try_into().unwrap(); assert_eq!(cidr.addr, IpAddr::V4(Ipv4Addr::new(192, 168, 0, 0))); assert_eq!(cidr.net_mask, IpAddr::V4(Ipv4Addr::new(255, 255, 255, 0))...
code_fim
hard
{ "lang": "rust", "repo": "DrJackilD/cidrcalc", "path": "/src/cidr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test() { assert_eq!( runner().err( "a {\ \n b: {\ \n @error test;\ \n c: d;\ \n }\ \n}\n" ), "Error: test\ \n ,\ \n3 | @error test;\ \n | ^^^^^^^...
code_fim
medium
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass/error_directive_nested/inline.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( runner().err( "a {\ \n b: {\ \n @error test;\ \n c: d;\ \n }\ \n}\n" ), "Error: test\ \n ,\ \n3 | @error test;\ \n | ^^^^^^^^^^^\ \n \...
code_fim
medium
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass/error_directive_nested/inline.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/libsass/error_directive_nested/inline.rs //! Tests auto-converted from "sass-spec/spec/libsass/error-directive-nested/inline.hrx" <|fim_suffix|> super::runner().with_cwd("inline") } #[test] fn test() { assert_eq!( runner().err( "a {\...
code_fim
medium
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass/error_directive_nested/inline.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OhadRau/rust-os path: /kern/src/vm/pagetable.rs use core::iter::Chain; use core::ops::{Deref, DerefMut}; use core::slice::Iter; use alloc::boxed::Box; use alloc::fmt; use core::alloc::{GlobalAlloc, Layout}; use crate::allocator; use crate::param::*; use crate::vm::{PhysicalAddr, VirtualAddr}; ...
code_fim
hard
{ "lang": "rust", "repo": "OhadRau/rust-os", "path": "/kern/src/vm/pagetable.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Implement `fmt::Debug` as you need. impl fmt::Debug for UserPageTable { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "UserPageTable {{")?; for (idx, page) in self.0.into_iter().enumerate() { if !page.is_valid() { continue } let va = id...
code_fim
hard
{ "lang": "rust", "repo": "OhadRau/rust-os", "path": "/kern/src/vm/pagetable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmmries/bayesic_rs path: /benches/training.rs #[macro_use] extern crate bencher; use bencher::Bencher; use bayesic::Bayesic; use lazy_static::lazy_static; use regex::Regex; use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; lazy_static! {...
code_fim
medium
{ "lang": "rust", "repo": "mmmries/bayesic_rs", "path": "/benches/training.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }