text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/weave/tests/weave_ip_forward/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::{format_err, Context as _, Error...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/weave/tests/weave_ip_forward/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ales-tsurko/koto path: /libs/geometry/src/rect.rs use { crate::Vec2, koto_runtime::prelude::*, std::{fmt, ops::Deref}, }; type Inner = nannou_core::geom::Rect<f64>; fn make_rect_meta_map() -> PtrMut<MetaMap> { use {BinaryOp::*, UnaryOp::*, Value::*}; MetaMapBuilder::<Rect>...
code_fim
hard
{ "lang": "rust", "repo": "ales-tsurko/koto", "path": "/libs/geometry/src/rect.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<(f64, f64, f64, f64)> for Rect { fn from((x, y, w, h): (f64, f64, f64, f64)) -> Self { Self::from_x_y_w_h(x, y, w, h) } } impl From<Rect> for Value { fn from(point: Rect) -> Self { let meta = RECT_META.with(|meta| meta.clone()); External::with_shared_meta_map...
code_fim
hard
{ "lang": "rust", "repo": "ales-tsurko/koto", "path": "/libs/geometry/src/rect.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self::from_x_y_w_h(x, y, w, h) } } impl From<Rect> for Value { fn from(point: Rect) -> Self { let meta = RECT_META.with(|meta| meta.clone()); External::with_shared_meta_map(point, meta).into() } } impl fmt::Display for Rect { fn fmt(&self, f: &mut fmt::Formatter<'...
code_fim
hard
{ "lang": "rust", "repo": "ales-tsurko/koto", "path": "/libs/geometry/src/rect.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aQaTL/idsr path: /src/main.rs #![windows_subsystem = "windows"] #[macro_use] extern crate nuklear; extern crate nuklear_backend_gdi; extern crate winapi; extern crate regex; #[macro_use] extern crate lazy_static; use nuklear::{Color, Context, Flags}; use nuklear as nk; use nuklear_backend_gdi::...
code_fim
hard
{ "lang": "rust", "repo": "aQaTL/idsr", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn calc_marks_average(input: &str, skip_corrected: bool) -> Option<f64> { let mut nums: Vec<f64> = Vec::new(); lazy_static! { static ref RE: Regex = Regex::new(r"(\d+)([+,-])?/?(\d+)?([+,-])?").unwrap(); } for capture in RE.captures_iter(input) { let num = capture.get(1); let sign = capture.ge...
code_fim
hard
{ "lang": "rust", "repo": "aQaTL/idsr", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mathieupoirier/rust_dos path: /src/main.rs #![no_std] #![no_main] <|fim_suffix|>entry!(main); fn main() { println!("Hello, World!"); // println!("Hit any Key, please."); // dpkey::keymap(); }<|fim_middle|>use rust_dos::*;
code_fim
easy
{ "lang": "rust", "repo": "mathieupoirier/rust_dos", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mathieupoirier/rust_dos path: /src/main.rs #![no_std] #![no_main] use rust_dos::*; <|fim_suffix|> println!("Hello, World!"); // println!("Hit any Key, please."); // dpkey::keymap(); }<|fim_middle|>entry!(main); fn main() {
code_fim
easy
{ "lang": "rust", "repo": "mathieupoirier/rust_dos", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { println!("Hello, World!"); // println!("Hit any Key, please."); // dpkey::keymap(); }<|fim_prefix|>// repo: mathieupoirier/rust_dos path: /src/main.rs #![no_std] #![no_main] <|fim_middle|>use rust_dos::*; entry!(main);
code_fim
easy
{ "lang": "rust", "repo": "mathieupoirier/rust_dos", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(actual, expected); } #[test] fn test_mantle_build() { test_mantle_interface("types", "TestService"); } #[test] fn test_default_fn() { test_mantle_interface("default_fn", "DefaultFnService"); }<|fim_prefix|>// repo: khoazany/mantle path: /tests/idl_gen/src/lib.rs #![cfg(test)] us...
code_fim
hard
{ "lang": "rust", "repo": "khoazany/mantle", "path": "/tests/idl_gen/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: khoazany/mantle path: /tests/idl_gen/src/lib.rs #![cfg(test)] use std::io::Read as _; fn test_mantle_interface(bin_name: &str, service_name: &str) { let mut wasm_path = std::path::PathBuf::from(concat!( env!("CARGO_MANIFEST_DIR"), "/target/wasm32-wasi/debug" )); was...
code_fim
hard
{ "lang": "rust", "repo": "khoazany/mantle", "path": "/tests/idl_gen/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marcaddeo/rs-hank path: /src/errors.rs error_chain! { foreign_links { IrcError(::irc::error::Error); RegexError(::regex::Error); EnvVarError(::std::env::VarError); StringUtf8Error(:<|fim_suffix|>seError(::url::ParseError); IoError(::std::io::Error); ...
code_fim
medium
{ "lang": "rust", "repo": "marcaddeo/rs-hank", "path": "/src/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> InvalidDuration { description("Could not find a valid ISO 8601 duration."), display("Could not find a valid ISO 8601 duration."), } } }<|fim_prefix|>// repo: marcaddeo/rs-hank path: /src/errors.rs error_chain! { foreign_links { IrcError(::irc::error:...
code_fim
hard
{ "lang": "rust", "repo": "marcaddeo/rs-hank", "path": "/src/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cleonty/programming-rust path: /unsafe-code/src/main.rs #![allow(dead_code)] #[test] fn test_raw_pointers() { let mut x = 10; let ptr_x = &mut x as *mut i32; let y = Box::new(20); let ptr_y = &*y as *const i32; unsafe { *ptr_x += *ptr_y; } assert_eq!(x, 30) } #[test] fn tes...
code_fim
hard
{ "lang": "rust", "repo": "cleonty/programming-rust", "path": "/unsafe-code/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_gap() { use gap::gap::GapBuffer; let mut buf = GapBuffer::new(); buf.insert_iter("Lord of the Rings".chars()); buf.set_position(12); } use std::ffi::CStr; use std::os::raw::c_char; extern "C" { fn strlen(s: *const c_char) -> usize; static environ: *mut *mut c_char; } #[test]...
code_fim
hard
{ "lang": "rust", "repo": "cleonty/programming-rust", "path": "/unsafe-code/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/tinystr/src/databake.rs use crate : : TinyAsciiStr ; use databake : : * ; impl < const N : usize > Bake for TinyAsciiStr < N<|fim_suffix|>( ) { test_bake ! ( TinyAsciiStr < 10 > const : crate : : tinystr ! ( 10usize " foo "...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/tinystr/src/databake.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>= self . as_str ( ) ; quote ! { : : tinystr : : tinystr ! ( # N # string ) } } } # [ test ] fn test ( ) { test_bake ! ( TinyAsciiStr < 10 > const : crate : : tinystr ! ( 10usize " foo " ) tinystr ) ; }<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/tinystr/...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/tinystr/src/databake.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> self.0.append_metadata(testcase)?; self.1.append_metadata_all(testcase) } fn discard_metadata_all(&mut self, input: &I) -> Result<(), Error> { self.0.discard_metadata(input)?; self.1.discard_metadata_all(input) } } /// Is a crash feedback #[derive(Serialize, D...
code_fim
hard
{ "lang": "rust", "repo": "chenju2k6/LibAFL", "path": "/libafl/src/feedbacks/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenju2k6/LibAFL path: /libafl/src/feedbacks/mod.rs //! The feedbacks reduce observer state after each run to a single `is_interesting`-value. //! If a testcase is interesting, it may be added to a Corpus. pub mod map; pub use map::*; use serde::{Deserialize, Serialize}; use crate::{ bolt...
code_fim
hard
{ "lang": "rust", "repo": "chenju2k6/LibAFL", "path": "/libafl/src/feedbacks/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let new_stock_transaction = NewStockTransaction { user_uuid, stock_uuid: stock.uuid, quantity: request.quantity, price_of_stock_at_time_of_trading: current_price, record_time: Utc::now().naive_utc(), }; // Record that the stock was purchased for the use...
code_fim
hard
{ "lang": "rust", "repo": "hgzimmerman/SWEN344-web-project", "path": "/backend/server/src/api/market.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hgzimmerman/SWEN344-web-project path: /backend/server/src/api/market.rs //! Responsible for hosting routes that deal with stock market data. use crate::state::State; use warp::{path, Filter, Reply}; use crate::{ error::Error, server_auth::user_filter, util::{self, json_body_filter},...
code_fim
hard
{ "lang": "rust", "repo": "hgzimmerman/SWEN344-web-project", "path": "/backend/server/src/api/market.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>p-sockets #[derive(Debug, Clone, PartialEq, Eq)] pub enum Family { Ipv4, Ipv6, }<|fim_prefix|>// repo: LinkTed/dbus-server-address-parser path: /src/family.rs /// This represents a socket family for [`tcp:`] and [`nonce-tcp:`]. /// /// [`tcp:`]: <|fim_middle|>https://dbus.freedesktop.org/doc/dbus...
code_fim
medium
{ "lang": "rust", "repo": "LinkTed/dbus-server-address-parser", "path": "/src/family.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LinkTed/dbus-server-address-parser path: /src/family.rs /// This represents a socket family for [`tcp:`] and [`nonce-tcp:`]. /// /// [`tcp:`]: https://dbus.freedesktop.org/doc/dbus-specification.html#transports-tcp-sockets /// [`no<|fim_suffix|>p-sockets #[derive(Debug, Clone, PartialEq, Eq)] pu...
code_fim
medium
{ "lang": "rust", "repo": "LinkTed/dbus-server-address-parser", "path": "/src/family.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>nce-tcp:`]: https://dbus.freedesktop.org/doc/dbus-specification.html#transports-nonce-tcp-sockets #[derive(Debug, Clone, PartialEq, Eq)] pub enum Family { Ipv4, Ipv6, }<|fim_prefix|>// repo: LinkTed/dbus-server-address-parser path: /src/family.rs /// This represents a socket family for [`tcp:`] a...
code_fim
medium
{ "lang": "rust", "repo": "LinkTed/dbus-server-address-parser", "path": "/src/family.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.stack.push(Object::Symbol('[')); for symbol in string.chars() { self.stack.push(Object::Symbol(symbol)); } self.stack.push(Object::Symbol(']')); } pub fn run_symbol(&mut self, s: Symbol) -> Result<(), String> { self.current_interpreter.get_a...
code_fim
hard
{ "lang": "rust", "repo": "hermetique/eso", "path": "/ruscarpone/src/interpreter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hermetique/eso path: /ruscarpone/src/interpreter.rs use ::std::collections::HashMap; use ::std::rc::Rc; use ::std::io::{self, Read, Write}; use ::std::mem; pub fn fmt_to_string<T: ::std::fmt::Display>(t: T) -> String { format!("{}", t) } type Symbol = char; enum Object<'a, R, W> { Sym...
code_fim
hard
{ "lang": "rust", "repo": "hermetique/eso", "path": "/ruscarpone/src/interpreter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vasblock/libra path: /testsuite/cluster-test/src/effects/stop_container.rs use crate::{effects::Effect, instance::Instance}; use failure; use std::fmt; pub struct StopContainer { instance: Instance, } impl StopContainer { pub fn new(instance: Instance) -> Self { Self { instance...
code_fim
medium
{ "lang": "rust", "repo": "vasblock/libra", "path": "/testsuite/cluster-test/src/effects/stop_container.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.instance .run_cmd(vec!["sudo /usr/sbin/service docker stop"]) } fn deactivate(&self) -> failure::Result<()> { self.instance.run_cmd(vec![ "sudo /usr/sbin/service docker start && sudo /usr/sbin/service ecs start", ]) } } impl fmt::Display f...
code_fim
medium
{ "lang": "rust", "repo": "vasblock/libra", "path": "/testsuite/cluster-test/src/effects/stop_container.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn delete_book( &mut self, _ctx: ::grpcio::RpcContext, _req: DeleteBookRequest, _sink: UnarySink<DeleteBookReply> ) { println!("delete_book request"); let mut resp = DeleteBookReply::default(); let id = _req.get_id(); let result = db:...
code_fim
hard
{ "lang": "rust", "repo": "gashev/rust-grpc-example", "path": "/src/server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gashev/rust-grpc-example path: /src/server/src/main.rs use futures::Future; use grpcio::{ Environment, RpcStatus, RpcStatusCode, ServerBuilder, UnarySink, }; use std::{thread, time}; use std::sync::Arc; #[path = "./../../../books.rs"] mod books; #[path = "./../../../books_g...
code_fim
hard
{ "lang": "rust", "repo": "gashev/rust-grpc-example", "path": "/src/server/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PumpkinSeed/adventure-of-rust path: /functions/src/main.rs // the main function is the // entry point of the rust program fn main() { print_number(12) } // waits to variable both int32 // prints the sum of them fn print_sum(x: i32, y: i32) { <|fim_suffix|>// Rust has some special syntax fo...
code_fim
hard
{ "lang": "rust", "repo": "PumpkinSeed/adventure-of-rust", "path": "/functions/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// We can also create variable bindings which point to functions // f is a variable binding which points to a function that takes // an i32 as an argument and returns an i32. For example // Without type inference: let f: fn(i32) -> i32 = plus_one; // With type inference: let f = plus_one;<|fim_prefix|>...
code_fim
hard
{ "lang": "rust", "repo": "PumpkinSeed/adventure-of-rust", "path": "/functions/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sharksforarms/deku path: /src/impls/option.rs use crate::{DekuError, DekuRead, DekuWrite}; use bitvec::prelude::*; impl<'a, T: DekuRead<'a, Ctx>, Ctx: Copy> DekuRead<'a, Ctx> for Option<T> { /// Read a T from input and store as Some(T) /// * `inner_ctx` - The context required by `T`. It...
code_fim
hard
{ "lang": "rust", "repo": "sharksforarms/deku", "path": "/src/impls/option.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: DekuWrite<Ctx>, Ctx: Copy> DekuWrite<Ctx> for Option<T> { /// Write T if Some /// * **inner_ctx** - The context required by `T`. /// # Examples /// ```rust /// # use deku::{ctx::Endian, DekuWrite}; /// # use deku::bitvec::{bitvec, Msb0}; /// let data = Some(1u8); //...
code_fim
hard
{ "lang": "rust", "repo": "sharksforarms/deku", "path": "/src/impls/option.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reinismu/HonZoomHack-Rust path: /src/main.rs mod linux_process; use failure::{bail, Error}; use goblin::elf::sym::Sym; use proc_maps::Pid; use std::collections::HashMap; #[derive(Debug)] struct Test { meh: String, } const ZOOM_OUT: &str = "_ZN7CPlayer7ZoomOutEv"; const PREPARE_CLIENT_STATE...
code_fim
hard
{ "lang": "rust", "repo": "reinismu/HonZoomHack-Rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //SetupCamera + 0x5df (jbe short loc_C97702 ) -> (jmp short loc_C97702) linux_process::write_process_memory( pid, setup_camera_offset + module_offset + 0x5df, vec![0xEB], )?; // Don't send current zoom to server! // Nop from from 0x9b till 0xd8 (0x90) ...
code_fim
hard
{ "lang": "rust", "repo": "reinismu/HonZoomHack-Rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: youth7/read_elf path: /src/section/section_entry.rs use crate::util::get_fixed_length_string; use std::{convert::TryInto, usize}; pub struct SectionEntry { pub sh_name: u32, pub sh_type: u32, pub sh_flags: u64, pub sh_addr: u64, pub sh_offset: u64, pub sh_size: u64, ...
code_fim
hard
{ "lang": "rust", "repo": "youth7/read_elf", "path": "/src/section/section_entry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let flags = match self.sh_flags { 0x1 => "SHF_WRITE".to_string(), 0x2 => "SHF_ALLOC".to_string(), 0x4 => "SHF_EXECINSTR".to_string(), 0x10 => "SHF_MERGE".to_string(), 0x20 => "SHF_STRINGS".to_string(), 0x40 => "SHF_INFO_LINK"....
code_fim
hard
{ "lang": "rust", "repo": "youth7/read_elf", "path": "/src/section/section_entry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl DirReader for FsReader { fn read_dir(&self, path: &str) -> Result<Vec<File>, ReadError> { let mut vec = vec!(); let meta = fs::metadata(path); match meta { Ok(ref m) if !m.is_dir() => { let file_result = FsReader::get_line(Path::new(path)); ...
code_fim
hard
{ "lang": "rust", "repo": "benbrunton/les", "path": "/src/fs/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benbrunton/les path: /src/fs/mod.rs use std::fs; use std::path::Path; pub trait DirReader { fn read_dir(&self, path: &str) -> Result<Vec<File>, ReadError>; } pub struct FsReader; impl FsReader{ pub fn get_line(path: &Path) -> Option<File> { let meta_result = path.metadata(...
code_fim
hard
{ "lang": "rust", "repo": "benbrunton/les", "path": "/src/fs/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if is_eq_or_uneq( &data[i]) { __is_op = true; continue; } } }, _ => {} } data.clone() } } pub mod optimize_helpers { pub fn is_eq_or_uneq(data: &String) -> bool { retur...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/gretea", "path": "/src/optimize.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/gretea path: /src/optimize.rs // MIT License // // Copyright (c) 2021 Ferhat Geçdoğan All Rights Reserved. // Distributed under the terms of the MIT License. // // pub enum OptimizeBlocks { StatementBool } pub mod optimizer { use crate::optimize::{ OptimizeBlocks, ...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/gretea", "path": "/src/optimize.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VoidPtr74/RayTracingTheNextWeek path: /src/camera.rs use crate::ray::Ray; use crate::rng::Random; use crate::vec3::*; use std::f32; #[derive(Copy, Clone)] pub struct Camera { pub origin: Vec3, pub lower_left_corner: Vec3, pub horizontal: Vec3, pub vertical: Vec3, u: Vec3, ...
code_fim
hard
{ "lang": "rust", "repo": "VoidPtr74/RayTracingTheNextWeek", "path": "/src/camera.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_ray(&self, s: f32, t: f32, rnd: &mut Random) -> Ray { let rd = &random_in_unit_disk(rnd) * self.lens_radius; let offset = &self.u * *rd.x() + &self.v * *rd.y(); let time = self.time_open + rnd.gen() * (self.time_close - self.time_open); Ray { orig...
code_fim
hard
{ "lang": "rust", "repo": "VoidPtr74/RayTracingTheNextWeek", "path": "/src/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vibes-INS/rust-study path: /ownership/src/main.rs fn main() { let s1 = String::from("hello"); let (s2, len) = calculate_length(s1); <|fim_suffix|> let len = str.len(); (str, len) }<|fim_middle|> println!("String: \"{}\", length: {}", s2, len); } fn calculate_length(str: Stri...
code_fim
medium
{ "lang": "rust", "repo": "Vibes-INS/rust-study", "path": "/ownership/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let len = str.len(); (str, len) }<|fim_prefix|>// repo: Vibes-INS/rust-study path: /ownership/src/main.rs fn main() { let s1 = String::from("hello"); let (s2, len) = calculate_length(s1); <|fim_middle|> println!("String: \"{}\", length: {}", s2, len); } fn calculate_length(str: Stri...
code_fim
medium
{ "lang": "rust", "repo": "Vibes-INS/rust-study", "path": "/ownership/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Siteimprove/unicase path: /src/utils.rs // Compare two iterators to check if the needle is contained in the haystack. // Because iteration has to be restarted, the caller must provide two factory // functions that can skip to the provided offset. pub fn contains_kmp<I: Iterator<Item=char> + Clon...
code_fim
hard
{ "lang": "rust", "repo": "Siteimprove/unicase", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if y == x { continue; } // We need to resume iteration at the relevant starting point. Haystack // from the first starting character we saw or its current point, and // needle from the 2nd character in the string. lef...
code_fim
hard
{ "lang": "rust", "repo": "Siteimprove/unicase", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Compare two iterators, returning true if they are equivalent or // the value of `if_right_empty` when the end of the right iterator is reached. #[inline] pub fn compare_iters<I1: Iterator<Item=char>, I2: Iterator<Item=char>>(left: &mut I1, right: &mut I2, if_right_empty: bool) -> bool { loop { ...
code_fim
hard
{ "lang": "rust", "repo": "Siteimprove/unicase", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wycats/argon path: /crates/argon/src/ir/annotated/types.rs use crate::prelude::*; use codespan::ByteSpan; use crate::ir::{Span, Spanned, SpannedItem}; use crate::{MathType, Type}; #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct RawTypeVar { crate var: usize, } pub ...
code_fim
hard
{ "lang": "rust", "repo": "wycats/argon", "path": "/crates/argon/src/ir/annotated/types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> crate fn integer<T: PartialEq + Debug>(span: &Spanned<T>) -> InferType { InferType::Constrained(ConstrainedType::Integer.copy_span(span)) } crate fn float<T: PartialEq + Debug>(span: &Spanned<T>) -> InferType { InferType::Constrained(ConstrainedType::Float.copy_span(span)) ...
code_fim
hard
{ "lang": "rust", "repo": "wycats/argon", "path": "/crates/argon/src/ir/annotated/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (output_buffer, output_buffer_length) } #[cfg(test)] mod tests { use super::*; use core::ops::Range; #[derive(Debug)] struct TestVector<const N: usize, const M: usize> { unencoded_data: [u8; N], encoded_data: [u8; M], } impl<const N: usize, const M: usize> Te...
code_fim
hard
{ "lang": "rust", "repo": "xieren58/cobs-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xieren58/cobs-rs path: /src/lib.rs . In fact, this crate will automatically the //! marker byte at the end of any encoded buffer. //! //! ## Features //! //! The *cobs-rs* crate only provides two specific functions. Namely, the //! [`stuff`] and the [`unstuff`] function, which encode and decode ...
code_fim
hard
{ "lang": "rust", "repo": "xieren58/cobs-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xieren58/cobs-rs path: /src/lib.rs g.org/2021/02/26/const-generics-mvp-beta). This //! may make usage a bit counter-intuitive for people unfamiliar with this feature //! at first. //! //! Something to take into account here is that the COBS algorithm will __at most__ //! add `2 + (size of input ...
code_fim
hard
{ "lang": "rust", "repo": "xieren58/cobs-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[ cfg_attr ( feature = "vonuvoli_inline", inline ) ] pub fn any_rc_clone (&self) -> (StdRc<StdBox<StdAny>>) { StdRc::clone (&self.0) } #[ cfg_attr ( feature = "vonuvoli_inline", inline ) ] pub fn any_as_ref (&self) -> (&StdAny) { StdBox::deref (StdRc::deref (&self.0)) } #[ cfg_attr ( featu...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/vonuvoli-scheme", "path": "/sources/values_opaque.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Happy-Ferret/vonuvoli-scheme path: /sources/values_opaque.rs use super::runtime::exports::*; use super::prelude::*; pub mod exports { pub use super::Opaque; pub use super::{opaque_new}; } #[ derive (Clone) ] pub struct Opaque ( StdRc<StdBox<StdAny>> ); impl Opaque { #[ cfg_attr...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/vonuvoli-scheme", "path": "/sources/values_opaque.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hossein-Noroozpour/vulkust path: /vulkust/src/render/texture/mod.rs use super::super::core::object::Object as CoreObject; use super::image::View as ImageView; use super::sampler::Sampler; use std::sync::Arc; <|fim_suffix|>pub use self::cube::Cube; pub use self::manager::Manager; pub use self::t...
code_fim
medium
{ "lang": "rust", "repo": "Hossein-Noroozpour/vulkust", "path": "/vulkust/src/render/texture/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub trait Loadable: Sized { fn new_with_gltf(gltf: &gltf::Texture, engine: &Engine, data: &[u8]) -> Self; fn new_with_gx3d(engine: &Engine, reader: &mut Gx3DReader, id: Id) -> Self; }<|fim_prefix|>// repo: Hossein-Noroozpour/vulkust path: /vulkust/src/render/texture/mod.rs use super::super::co...
code_fim
medium
{ "lang": "rust", "repo": "Hossein-Noroozpour/vulkust", "path": "/vulkust/src/render/texture/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while input > 9 { needle.push(input % 10); input /= 10; } needle.push(input); needle.reverse(); needle }; let mut ptr = 0; loop { let cur = recipe.make(); while ptr + needle.len() < cur { if needle ...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/rust-advent-of-code-2018", "path": "/src/bin/day14.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: udoprog/rust-advent-of-code-2018 path: /src/bin/day14.rs use aoc2018::*; struct Recipe { pub data: Vec<usize>, a: usize, b: usize, } impl Recipe { fn new() -> Self { let mut data = Vec::new(); data.push(3); data.push(7); Recipe { data, a: 0, b: ...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/rust-advent-of-code-2018", "path": "/src/bin/day14.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<F> ProgressIO<Cursor<Vec<u8>>, F> where F: Fn(usize, usize) -> (), { pub fn reader_from(slice: Vec<u8>, notify: F) -> Self { Self::reader(slice.len(), Cursor::new(slice), notify) } }<|fim_prefix|>// repo: sinopiaolive/package-manager path: /client/src/io.rs use std::io::{Cursor, ...
code_fim
hard
{ "lang": "rust", "repo": "sinopiaolive/package-manager", "path": "/client/src/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sinopiaolive/package-manager path: /client/src/io.rs use std::io::{Cursor, Read, Result}; pub struct ProgressIO<IO, F> { io: IO, total: usize, current: usize, notify: F, } <|fim_suffix|>impl<F> ProgressIO<Cursor<Vec<u8>>, F> where F: Fn(usize, usize) -> (), { pub fn rea...
code_fim
hard
{ "lang": "rust", "repo": "sinopiaolive/package-manager", "path": "/client/src/io.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<R, F> Read for ProgressIO<R, F> where R: Read, F: Fn(usize, usize) -> (), { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { match self.io.read(buf) { Ok(size) => { self.current += size; (self.notify)(self.current, self.total); ...
code_fim
hard
{ "lang": "rust", "repo": "sinopiaolive/package-manager", "path": "/client/src/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>射集,按Key排列 //! - HashSet<T> 无序集合 //! - BTreeSet<T> 基于B树的有序集合 fn nothing() {}<|fim_prefix|>// repo: ityy/rust_study path: /src/book_study_notes/book01_the_tao_of_programming/src/c08_string_and_collections/t8_2_0_collection.rs //! # 集合类型 //! Rust标准库提供了以下集合类型: //! - Vec<T> 动态可增长数组 //...
code_fim
medium
{ "lang": "rust", "repo": "ityy/rust_study", "path": "/src/book_study_notes/book01_the_tao_of_programming/src/c08_string_and_collections/t8_2_0_collection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>队列 //! - HashMap<K,V> 基于哈希表的无序Key-Value映射集 //! - BTreeMap<K,V> 基于B树的有序Key-Value映射集,按Key排列 //! - HashSet<T> 无序集合 //! - BTreeSet<T> 基于B树的有序集合 fn nothing() {}<|fim_prefix|>// repo: ityy/rust_study path: /src/book_study_notes/book01_the_tao_of_programming/src/c08_string_and_collections...
code_fim
medium
{ "lang": "rust", "repo": "ityy/rust_study", "path": "/src/book_study_notes/book01_the_tao_of_programming/src/c08_string_and_collections/t8_2_0_collection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toad-sage/Rust-Examples path: /actix/actix-mongo/src/models/response.rs use serde::{Deserialize, Serialize}; <|fim_suffix|>#[derive(Serialize, Deserialize, Debug)] pub struct Response { pub message: String, pub status: bool, }<|fim_middle|>#[derive(Serialize, Deserialize, Debug)] pub st...
code_fim
medium
{ "lang": "rust", "repo": "toad-sage/Rust-Examples", "path": "/actix/actix-mongo/src/models/response.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)] pub struct Response { pub message: String, pub status: bool, }<|fim_prefix|>// repo: toad-sage/Rust-Examples path: /actix/actix-mongo/src/models/response.rs use serde::{Deserialize, Serialize}; <|fim_middle|>#[derive(Serialize, Deserialize, Debug)] pub st...
code_fim
medium
{ "lang": "rust", "repo": "toad-sage/Rust-Examples", "path": "/actix/actix-mongo/src/models/response.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmaahs2017/comfy-table path: /tests/presets_test.rs use pretty_assertions::assert_eq; use comfy_table::presets::*; use comfy_table::*; fn get_preset_table() -> Table { let mut table = Table::new(); table.set_header(&vec!["Header1", "Header2", "Header3"]); table.add_row(&vec!["One O...
code_fim
hard
{ "lang": "rust", "repo": "dmaahs2017/comfy-table", "path": "/tests/presets_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn utf8_horizontal_borders_only() { let mut table = get_preset_table(); table.load_preset(UTF8_HORIZONTAL_BORDERS_ONLY); let expected = " ─────────────────────────────── Header1 Header2 Header3 ═══════════════════════════════ One One One Two One Three ────────────────────────...
code_fim
hard
{ "lang": "rust", "repo": "dmaahs2017/comfy-table", "path": "/tests/presets_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JasterV/chat-rooms-actix path: /src/messages/session/wsmessage.rs use actix::Message as ActixMessage; use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; use std::convert::Into; #[derive(Serialize, Deserialize, ActixMessage)] #[rtype(result = "()")] pub struct WsMessage { pu...
code_fim
medium
{ "lang": "rust", "repo": "JasterV/chat-rooms-actix", "path": "/src/messages/session/wsmessage.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Into<String> for WsMessage { fn into(self) -> String { serde_json::to_string(&self).unwrap() } }<|fim_prefix|>// repo: JasterV/chat-rooms-actix path: /src/messages/session/wsmessage.rs use actix::Message as ActixMessage; use serde::{Deserialize, Serialize}; use serde_json::{Value, js...
code_fim
medium
{ "lang": "rust", "repo": "JasterV/chat-rooms-actix", "path": "/src/messages/session/wsmessage.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/third-party-api-clients path: /okta/src/identity_providers.rs f.client .put( &url, crate::Message { body: Some(reqwest::Body::from(serde_json::to_vec(body)?)), content_type: None, },...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/okta/src/identity_providers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>>> { let url = self.client.url( &format!( "/api/v1/idps/{}/lifecycle/deactivate", crate::progenitor_support::encode_path(idp_id), ), None, ); self.client .post( &url, cra...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/okta/src/identity_providers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> * Activates an inactive IdP. * * **Parameters:** * * * `idp_id: &str` */ pub async fn activate( &self, idp_id: &str, ) -> ClientResult<crate::Response<crate::types::IdentityProvider>> { let url = self.client.url( &format!( ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/okta/src/identity_providers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/schema/src/output_types.rs use super::*; use fmt::Debug; use once_cell::sync::Lazy; use prisma_models::ast::ModelId; use std::{borrow::Cow, fmt}; #[derive(Debug, Clone)] pub struct OutputType<'a> { is_list: bool, pub inner: InnerOutputType<'a>, ...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/schema/src/output_types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_object(&self) -> bool { matches!(self.inner, InnerOutputType::Object(_)) } pub fn is_scalar(&self) -> bool { matches!(self.inner, InnerOutputType::Scalar(_)) } pub fn is_enum(&self) -> bool { matches!(self.inner, InnerOutputType::Enum(_)) } ...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/schema/src/output_types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn field_type(&self) -> &OutputType<'a> { &self.field_type } pub fn is_find_unique(&self) -> bool { matches!( self.query_tag(), Some(&QueryTag::FindUnique | QueryTag::FindUniqueOrThrow) ) } /// Relevant for resolving top level queri...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/schema/src/output_types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quilt/lighthouse path: /eth2/utils/ssz/fuzz/fuzz_targets/fuzz_target_address_encode.rs #![no_main] #[macro_use] extern crate libfuzzer_sys; extern crate ethereum_types; extern crate ssz; <|fim_suffix|> assert_eq!(data[..20], ssz[..20]); assert_eq!(ssz.len(), 20); } });<|fim_m...
code_fim
hard
{ "lang": "rust", "repo": "quilt/lighthouse", "path": "/eth2/utils/ssz/fuzz/fuzz_targets/fuzz_target_address_encode.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(data[..20], ssz[..20]); assert_eq!(ssz.len(), 20); } });<|fim_prefix|>// repo: quilt/lighthouse path: /eth2/utils/ssz/fuzz/fuzz_targets/fuzz_target_address_encode.rs #![no_main] #[macro_use] extern crate libfuzzer_sys; extern crate ethereum_types; extern crate ssz; use eth...
code_fim
hard
{ "lang": "rust", "repo": "quilt/lighthouse", "path": "/eth2/utils/ssz/fuzz/fuzz_targets/fuzz_target_address_encode.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wujunze/tikv path: /src/bin/tikv-ctl.rs conflicts_with("key") .short("r") .takes_value(true) .help("Set the region id"), ) .arg( ...
code_fim
hard
{ "lang": "rust", "repo": "wujunze/tikv", "path": "/src/bin/tikv-ctl.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn compact( &self, address: Option<&str>, db: DBType, cf: &str, from: Option<Vec<u8>>, to: Option<Vec<u8>>, threads: u32, bottommost: BottommostLevelCompaction, ) { let from = from.unwrap_or_default(); let to = to.unwr...
code_fim
hard
{ "lang": "rust", "repo": "wujunze/tikv", "path": "/src/bin/tikv-ctl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>limiter(true) .require_delimiter(true) .value_delimiter(",") .help("Only for these regions"), ) .arg( Arg::with_name("all-regions") ...
code_fim
hard
{ "lang": "rust", "repo": "wujunze/tikv", "path": "/src/bin/tikv-ctl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brace-rs/brace path: /crates/brace/tests/cli.rs #![cfg(feature = "cli")] use std::error::Error; use std::process::Command; use assert_cmd::prelude::*; use predicates::prelude::*; <|fim_suffix|> cmd.arg("--version"); cmd.assert() .success() .stdout(predicate::str::contai...
code_fim
medium
{ "lang": "rust", "repo": "brace-rs/brace", "path": "/crates/brace/tests/cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_cli() -> Result<(), Box<dyn Error>> { let mut cmd = Command::cargo_bin("brace")?; cmd.arg("--version"); cmd.assert() .success() .stdout(predicate::str::contains("brace")); Ok(()) }<|fim_prefix|>// repo: brace-rs/brace path: /crates/brace/tests/cli.rs #![c...
code_fim
easy
{ "lang": "rust", "repo": "brace-rs/brace", "path": "/crates/brace/tests/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Horizontal Rule if line.starts_with("----") { ret.push(HRule.into()); continue; } // Multiline-enabled block plugin if !config.disable_multiline_plugin { if let Some(res) = regex!(r"^#[^{]+(\{\{+)\s*$").captures(line) { ...
code_fim
hard
{ "lang": "rust", "repo": "TonalidadeHidrica/taiko-wiki-data-analysis", "path": "/src/pukiwiki_parser/block.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TonalidadeHidrica/taiko-wiki-data-analysis path: /src/pukiwiki_parser/block.rs // As a result, this execution of Factory_Inline always results in a call to Inline(). // The first ' ' as a result of replacement is trimmed in the Inline constructor. Inline::new(text,...
code_fim
hard
{ "lang": "rust", "repo": "TonalidadeHidrica/taiko-wiki-data-analysis", "path": "/src/pukiwiki_parser/block.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TonalidadeHidrica/taiko-wiki-data-analysis path: /src/pukiwiki_parser/block.rs g: Option<&'a str>, #[getset(get = "pub")] text: FactoryInlineRet<'a>, } #[derive(Clone, Copy, Debug)] pub enum HeadingLevel { H2, H3, H4, } impl<'a> Heading<'a> { /// # panics /// If text ...
code_fim
hard
{ "lang": "rust", "repo": "TonalidadeHidrica/taiko-wiki-data-analysis", "path": "/src/pukiwiki_parser/block.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(all(feature = "std", target_endian = "big"))] #[test] fn byte_order() { eprintln!("BIG ENDIAN"); }<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/memchr/v2/crate/src/tests/mod.rs mod memchr; // For debugging, particularly in CI, print out the byte order of the current // targe...
code_fim
easy
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/memchr/v2/crate/src/tests/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/memchr/v2/crate/src/tests/mod.rs mod memchr; // For debugging, particularly in CI, print out the byte order of the current // target. #[cfg(all(feature = "std", target_endian = "little"))] #[test] fn byte_order() { <|fim_suffix|>#[cfg(all(feature = "std...
code_fim
easy
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/memchr/v2/crate/src/tests/mod.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zireael-N/node-weakauras-parser path: /native/src/lib_serialize/deserialization/reader.rs use std::borrow::Cow; pub(crate) struct SliceReader<'s> { buffer: &'s [u8], index: usize, } #[allow(dead_code)] impl<'s> SliceReader<'s> { pub(crate) fn new(buffer: &'s [u8]) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "Zireael-N/node-weakauras-parser", "path": "/native/src/lib_serialize/deserialization/reader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn read_string(&mut self, len: usize) -> Option<Cow<'s, str>> { if self.index + len - 1 < self.buffer.len() { let s = String::from_utf8_lossy(&self.buffer[self.index..self.index + len]); self.index += len; Some(s) } else { Non...
code_fim
hard
{ "lang": "rust", "repo": "Zireael-N/node-weakauras-parser", "path": "/native/src/lib_serialize/deserialization/reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>from_bytes!(f32); from_bytes!(f64); pub fn read_to<T: FromBytes>(data: &[u8], offset: &mut usize) -> T { // implementation should be change to not use &[u8] since that requires constructing it from raw let size = std::mem::size_of::<T>(); let value = T::from_bytes(&data[*offset..], size...
code_fim
hard
{ "lang": "rust", "repo": "AndrewBregger/auburn", "path": "/oxide/src/mem.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndrewBregger/auburn path: /oxide/src/mem.rs use std::convert::TryInto; pub trait FromBytes { fn from_bytes(bytes: &[u8], len: usize) -> Self; <|fim_suffix|> Self::from_be_bytes( (&bytes[0..len]) .try_into() ...
code_fim
medium
{ "lang": "rust", "repo": "AndrewBregger/auburn", "path": "/oxide/src/mem.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn read_to<T: FromBytes>(data: &[u8], offset: &mut usize) -> T { // implementation should be change to not use &[u8] since that requires constructing it from raw let size = std::mem::size_of::<T>(); let value = T::from_bytes(&data[*offset..], size); *offset += size; value }<|...
code_fim
hard
{ "lang": "rust", "repo": "AndrewBregger/auburn", "path": "/oxide/src/mem.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn next_on_or_after(&self, minute: u32) -> (bool, u32) { (true, self.minute) } }<|fim_prefix|>// repo: Ygg01/cron path: /src/schedule/minute.rs pub struct MinuteSchedule { minute: u32 } impl MinuteSchedule { // TODO: Use a Result to propagate error explanations pub fn from_minute(minu...
code_fim
medium
{ "lang": "rust", "repo": "Ygg01/cron", "path": "/src/schedule/minute.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ygg01/cron path: /src/schedule/minute.rs pub struct MinuteSchedule { minute: u32 } impl MinuteSchedule { // TODO: Use a Result to propagate error explanations pub fn from_minute(minute: u32) -> Option<MinuteSchedule> { if minute > 59 { return None; } let minute_schedule ...
code_fim
medium
{ "lang": "rust", "repo": "Ygg01/cron", "path": "/src/schedule/minute.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub fn main() -> () { let game_state = &mut *GAME_STATE.borrow_mut(); game_state.init(); }<|fim_prefix|>// repo: richardanaya/pong path: /src/lib.rs use web_dom::*; mod game; use crate::game::*; use ref_thread_local::RefThreadLocal; #[macro_use] extern crate ref_thread_local; <|fim_...
code_fim
hard
{ "lang": "rust", "repo": "richardanaya/pong", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: richardanaya/pong path: /src/lib.rs use web_dom::*; mod game; use crate::game::*; use ref_thread_local::RefThreadLocal; #[macro_use] extern crate ref_thread_local; ref_thread_local! { static managed GAME_STATE: GameState = GameState::new(); } <|fim_suffix|>#[no_mangle] pub fn main() -> () ...
code_fim
medium
{ "lang": "rust", "repo": "richardanaya/pong", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub fn callback(listener: EventListener, event: Event) { let game_state = &mut *GAME_STATE.borrow_mut(); game_state.route_event(listener, event); } #[no_mangle] pub fn main() -> () { let game_state = &mut *GAME_STATE.borrow_mut(); game_state.init(); }<|fim_prefix|>// repo: ri...
code_fim
medium
{ "lang": "rust", "repo": "richardanaya/pong", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raymundovr/exercism-rust path: /acronym/src/lib.rs pub fn abbreviate(phrase: &str) -> String { let words = phrase .split(|c| c == ' ' || c == '-') .filter(|word| !word.i<|fim_suffix|> for (i, c) in w.iter().enumerate() { if c.is_alphabetic() && (...
code_fim
medium
{ "lang": "rust", "repo": "raymundovr/exercism-rust", "path": "/acronym/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }