text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> new_test_ext_raw_authorities(authorities).execute_with(|| { start_era(1); let authorities = Grandpa::grandpa_authorities(); let equivocation_authority_index = 0; let equivocation_key = &authorities[equivocation_authority_index].0; let equivocation_keyring = extract_keyring(equivocation_key); ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/grandpa/src/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // generate a key ownership proof at set id = 1 let key_owner_proof = Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap(); let set_id = Grandpa::current_set_id(); let assert_invalid_equivocation_proof = |equivocation_proof| { assert_err!( Grandpa::report_equ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/grandpa/src/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Default)] pub struct Executor { variables: Environment, } impl Executor { pub fn new() -> Executor { Executor { variables: Environment::default() } } pub fn execute(&mut self, code: &str) -> Result<String, String> { let lex...
code_fim
medium
{ "lang": "rust", "repo": "squiidz/plasma", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: squiidz/plasma path: /src/lib.rs #[macro_use] extern crate lazy_static; mod token; mod types; mod object; mod environment; mod evaluator; mod ast; mod lexer; mod parser; pub mod interpreter { use lexer::Lexer; use parser::Parser; use environment::Environment; use evaluator::eva...
code_fim
medium
{ "lang": "rust", "repo": "squiidz/plasma", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Handler to get the account info. Accounts are private only for now -- you can only /// view this page if you're logged in as the correct user. #[get("/accounts/<id>")] pub fn get( db: DB, id: RUuid, capabilities: auth::UnverifiedCapabilities, ) -> Result<Jso...
code_fim
hard
{ "lang": "rust", "repo": "AlterionX/benxu-dev", "path": "/server/src/urls/blog/accounts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlterionX/benxu-dev path: /server/src/urls/blog/accounts.rs //! Handlers and functions for account management. use rocket::{ http::{Cookies, Status}, State, }; use rocket_contrib::{json::Json, uuid::Uuid as RUuid}; use tap::*; use crate::{ cfg::TokenKeyFixture, util::{ ...
code_fim
hard
{ "lang": "rust", "repo": "AlterionX/benxu-dev", "path": "/server/src/urls/blog/accounts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Moxinilian/kira path: /kira/src/group/groups.rs use basedrop::Owned; use crate::{command::GroupCommand, static_container::index_map::StaticIndexMap}; use super::{Group, GroupId}; pub(crate) struct Groups { groups: StaticIndexMap<GroupId, Owned<Group>>, } <|fim_suffix|> pub fn run_command(&m...
code_fim
medium
{ "lang": "rust", "repo": "Moxinilian/kira", "path": "/kira/src/group/groups.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run_command(&mut self, command: GroupCommand) { match command { GroupCommand::AddGroup(id, group) => { self.groups.try_insert(id, group).ok(); } GroupCommand::RemoveGroup(id) => { self.groups.remove(&id); } } } }<|fim_prefix|>// repo: Moxinilian/kira path: /kira/src/group...
code_fim
medium
{ "lang": "rust", "repo": "Moxinilian/kira", "path": "/kira/src/group/groups.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn buf_to_string<T: Buf>(mut buf: T) -> Result<String, Error> { std::str::from_utf8(&buf.copy_to_bytes(buf.remaining())) .map(|x| { tracing::debug!("receive:{:?}", x.to_string()); x.to_string() }) .map_err(|_| Error::error("body invalid utf8 sequence."))...
code_fim
medium
{ "lang": "rust", "repo": "defvar/toy", "path": "/pkg/toy-api-http-common/src/codec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: defvar/toy path: /pkg/toy-api-http-common/src/codec.rs use crate::error::Error; use serde::de::DeserializeOwned; use serde::Serialize; use toy_api::common::Format; use toy_h::bytes::Buf; pub fn decode<B: Buf, T: DeserializeOwned>(buf: B, format: Option<Format>) -> Result<T, Error> { match f...
code_fim
hard
{ "lang": "rust", "repo": "defvar/toy", "path": "/pkg/toy-api-http-common/src/codec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hefeng0/ucore_os_plus path: /kernel/src/arch/aarch64/board/raspi3/serial.rs use bcm2837::mini_uart::MiniUart; use core::fmt; use spin::Mutex; use once::*; /// Struct to get a global SerialPort interface pub struct SerialPort { mu: Option<MiniUart>, } pub trait SerialRead { fn receive(&...
code_fim
hard
{ "lang": "rust", "repo": "hefeng0/ucore_os_plus", "path": "/kernel/src/arch/aarch64/board/raspi3/serial.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for byte in s.bytes() { match byte { // Backspace b'\x7f' => { self.write_byte(b'\x08'); self.write_byte(b' '); self.write_byte(b'\x08'); } // Return ...
code_fim
hard
{ "lang": "rust", "repo": "hefeng0/ucore_os_plus", "path": "/kernel/src/arch/aarch64/board/raspi3/serial.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: izzabelle/ulg path: /src/assets.rs use crate::config::Config; use ggez::graphics::{Font, Image}; use ggez::Context; use ggez::GameResult as Result; <|fim_suffix|>impl Assets { pub fn load(ctx: &mut Context, config: &Config) -> Result<Self> { let mut tiles: Vec<Image> = Vec::new(); ...
code_fim
medium
{ "lang": "rust", "repo": "izzabelle/ulg", "path": "/src/assets.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Assets { pub fn load(ctx: &mut Context, config: &Config) -> Result<Self> { let mut tiles: Vec<Image> = Vec::new(); for path in config.tile_assets.clone() { tiles.push(Image::new(ctx, &path)?); } let outline = Image::new(ctx, config.outline.clone())?; ...
code_fim
medium
{ "lang": "rust", "repo": "izzabelle/ulg", "path": "/src/assets.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: warp-tech/warpgate path: /warpgate-protocol-ssh/src/server/channel_writer.rs use russh::server::Handle; use russh::{ChannelId, CryptoVec}; use tokio::sync::mpsc; <|fim_suffix|> pub fn write(&self, handle: Handle, channel: ChannelId, data: CryptoVec) { let _ = self.tx.send((handle, ch...
code_fim
hard
{ "lang": "rust", "repo": "warp-tech/warpgate", "path": "/warpgate-protocol-ssh/src/server/channel_writer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl ChannelWriter { pub fn new() -> Self { let (tx, mut rx) = mpsc::unbounded_channel::<(Handle, ChannelId, CryptoVec)>(); tokio::spawn(async move { while let Some((handle, channel, data)) = rx.recv().await { let _ = handle.data(channel, data).await; ...
code_fim
medium
{ "lang": "rust", "repo": "warp-tech/warpgate", "path": "/warpgate-protocol-ssh/src/server/channel_writer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let bin = self.layout_to_bin(layout); self.used -= self.bin_size(bin); self.tag_used[tag as u8 as usize] -= self.bin_size(bin); // cast is safe because we only ever give out 8 byte aligned pointers // anyway. unsafe { self.bins[bin].push(ptr as *mut usize) ...
code_fim
hard
{ "lang": "rust", "repo": "Pear0/rustos", "path": "/kern/src/allocator/bin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl TaggingAlloc for Allocator { unsafe fn alloc_tag(&mut self, layout: Layout, tag: MemTag) -> *mut u8 { self.do_alloc(layout, tag).unwrap_or(0 as *mut u8) } unsafe fn dealloc_tag(&mut self, ptr: *mut u8, layout: Layout, tag: MemTag) { self.do_dealloc(ptr, layout, tag); ...
code_fim
hard
{ "lang": "rust", "repo": "Pear0/rustos", "path": "/kern/src/allocator/bin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pear0/rustos path: /kern/src/allocator/bin.rs use core::alloc::Layout; use crate::allocator::linked_list::LinkedList; use crate::allocator::{LocalAlloc, AllocStats}; use crate::allocator::tags::{TaggingAlloc, MemTag}; use super::util::align_up; use shim::io; use pi::atags::Atag::Mem; /// A si...
code_fim
hard
{ "lang": "rust", "repo": "Pear0/rustos", "path": "/kern/src/allocator/bin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tiqur/Rust-PathTracer path: /src/PathTracing/Classes/Material.rs use crate::Classes::Rgb::Rgb; use crate::PathTracing::Enums::MaterialEnum::MaterialEnum; use crate::PathTracing::Enums::TextureEnum::TextureEnum; use crate::Classes::Point2D::Point2D; <|fim_suffix|>impl Material { pub fn uv_pa...
code_fim
medium
{ "lang": "rust", "repo": "Tiqur/Rust-PathTracer", "path": "/src/PathTracing/Classes/Material.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Material { pub fn uv_pattern_at(&self, uv_point: Point2D) -> Rgb { match &self.texture { TextureEnum::Base(texture) => { return texture.color; } TextureEnum::Checkerboard(texture) => { return texture.uv_pattern_at(uv_poin...
code_fim
medium
{ "lang": "rust", "repo": "Tiqur/Rust-PathTracer", "path": "/src/PathTracing/Classes/Material.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match trade_side { list_account_trades::AccountTradeSide::MAKER => AccountTradeSide::Maker, list_account_trades::AccountTradeSide::TAKER => AccountTradeSide::Taker, list_account_trades::AccountTradeSide::NONE => AccountTradeSide::None, _ => panic!("U...
code_fim
hard
{ "lang": "rust", "repo": "Vorticity-Flux/nash-rust", "path": "/nash-protocol/src/protocol/list_account_trades/response.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vorticity-Flux/nash-rust path: /nash-protocol/src/protocol/list_account_trades/response.rs use super::types::ListAccountTradesResponse; use crate::errors::{ProtocolError, Result}; use crate::graphql::list_account_trades; use crate::types::{AccountTradeSide, BuyOrSell, Trade}; use chrono::{DateTi...
code_fim
hard
{ "lang": "rust", "repo": "Vorticity-Flux/nash-rust", "path": "/nash-protocol/src/protocol/list_account_trades/response.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvsrgc/rust_levenshtein path: /src/main.rs use std::cmp::{max, min}; #[macro_use] extern crate prettytable; use prettytable::{format, Cell, Row, Table}; fn main() { println!("Hello, world!"); } pub fn levenshtein( left: &str, top: &str, insert_cost: isize, del_cost: isize, ...
code_fim
hard
{ "lang": "rust", "repo": "mvsrgc/rust_levenshtein", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let left = "aggc"; let top = "agc"; let confusion_matrix_chars = vec!['a', 'c', 'g', 't']; let confusion_matrix: Vec<Vec<isize>> = vec![ vec![1, -1, -2, -1], vec![-1, 1, -3, -1], vec![-2, -3, 1, -2], vec![-1, -1, -2, 1], ...
code_fim
hard
{ "lang": "rust", "repo": "mvsrgc/rust_levenshtein", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl MeowApi { pub async fn fetch() -> RuskyResult<Self> { let res = reqwest::get(MEOW_API_URL).await?; let content = res.text().await?; Ok(serde_json::from_str(&content)?) } }<|fim_prefix|>// repo: TheRuskyTeam/Rusky.old path: /src/apis/meow.rs use serde::Deserialize; us...
code_fim
medium
{ "lang": "rust", "repo": "TheRuskyTeam/Rusky.old", "path": "/src/apis/meow.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheRuskyTeam/Rusky.old path: /src/apis/meow.rs use serde::Deserialize; use crate::{constants::MEOW_API_URL, RuskyResult}; <|fim_suffix|>impl MeowApi { pub async fn fetch() -> RuskyResult<Self> { let res = reqwest::get(MEOW_API_URL).await?; let content = res.text().await?; ...
code_fim
medium
{ "lang": "rust", "repo": "TheRuskyTeam/Rusky.old", "path": "/src/apis/meow.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: loicbourgois/gravitle path: /server/src/plan.rs (&(a, b)).unwrap(); link_id_to_part_ids.remove(link_id); link_plan.part_plans.push(PartLinkPlan { l: link_id, kind: part_plan.k, cr: part_plan.cr, cg: part_plan.cg, cb: par...
code_fim
hard
{ "lang": "rust", "repo": "loicbourgois/gravitle", "path": "/server/src/plan.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: loicbourgois/gravitle path: /server/src/plan.rs part_plans: Vec::new(), }; let mut link_id_to_part_ids = vec![(0, 1), (1, 0)]; let mut part_count = 2; for part_plan in &link_plan.part_plans { let link_id = part_plan.l; let (a, b) = link_id_to_part_ids[link_id...
code_fim
hard
{ "lang": "rust", "repo": "loicbourgois/gravitle", "path": "/server/src/plan.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn random_dna() -> Dna { let mut rng = rand::thread_rng(); let mut dna = [0; DNA_SIZE]; for gene in dna.iter_mut().take(DNA_SIZE) { *gene = rng.gen_range(0..=255); } dna } pub fn mutate_dna_inplace(dna: &mut Dna) { let mut rng = rand::thread_rng(); let toggler_id =...
code_fim
hard
{ "lang": "rust", "repo": "loicbourgois/gravitle", "path": "/server/src/plan.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:#?}", foo); println!("{:#?}", simple); }<|fim_prefix|>// repo: meowjesty/simple-struct path: /sample/src/main.rs use simple_struct::simple_struct; <|fim_middle|>#[simple_struct("SimpleFoo", a, b)] #[derive(Debug)] struct Foo { a: u32, b: u32, c: u32, } fn main() { le...
code_fim
hard
{ "lang": "rust", "repo": "meowjesty/simple-struct", "path": "/sample/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let foo = Foo { a: 0, b: 1, c: 2 }; let simple = SimpleFoo { a: 0, b: 1 }; println!("{:#?}", foo); println!("{:#?}", simple); }<|fim_prefix|>// repo: meowjesty/simple-struct path: /sample/src/main.rs use simple_struct::simple_struct; <|fim_middle|>#[simple_struct("SimpleFoo", a, b)] #[d...
code_fim
medium
{ "lang": "rust", "repo": "meowjesty/simple-struct", "path": "/sample/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meowjesty/simple-struct path: /sample/src/main.rs use simple_struct::simple_struct; #[simple_struct("SimpleFoo", a, b)] #[derive(Debug)] struct Foo { a: u32, b: u32, c: u32, } fn main() { <|fim_suffix|> println!("{:#?}", foo); println!("{:#?}", simple); }<|fim_middle|> le...
code_fim
medium
{ "lang": "rust", "repo": "meowjesty/simple-struct", "path": "/sample/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Carl-Foster/exchange-rs path: /src/exchange/matcher/mod.rs use serde_json; use std::fs::File; use std::io::Read; mod depth; mod order_match; mod orders; pub use self::depth::Depth; pub use self::order_match::OrderMatch; pub use self::orders::{DepthOrder, Direction, Order}; #[derive(Debug, Ser...
code_fim
hard
{ "lang": "rust", "repo": "Carl-Foster/exchange-rs", "path": "/src/exchange/matcher/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let order_matches = depth_to_match.match_order(&mut new_order); depth_to_match.flush_filled_orders(); if new_order.quantity > 0 { depth_to_add.add_order(new_order); } order_matches } pub fn get_orders(&self) -> &Vec<Order> { &self.orders } pub fn get_matches(&self) ...
code_fim
hard
{ "lang": "rust", "repo": "Carl-Foster/exchange-rs", "path": "/src/exchange/matcher/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marcusball/drink-list path: /src/error.rs use actix_web::error::ResponseError; use actix_web::Error as ActixError; use diesel::r2d2; use diesel::result::Error as DieselError; use futures::channel::oneshot::Canceled as FutureCanceled; use std::convert::From; pub type Result<T> = ::std::result::R...
code_fim
hard
{ "lang": "rust", "repo": "marcusball/drink-list", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Error::R2D2Error(e) } } impl From<FutureCanceled> for Error { fn from(e: FutureCanceled) -> Error { Error::FutureCanceled(e) } }<|fim_prefix|>// repo: marcusball/drink-list path: /src/error.rs use actix_web::error::ResponseError; use actix_web::Error as ActixError; use diesel...
code_fim
hard
{ "lang": "rust", "repo": "marcusball/drink-list", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> "array" } fn generate_schema() -> Schema { let mut schema = Schema { _type: Some(Self::type_().to_string()), format: None, nullable: None, extras: Default::default(), }; schema.extras.insert("items".to_string(), T::ge...
code_fim
hard
{ "lang": "rust", "repo": "Kilerd/gotcha", "path": "/gotcha_core/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kilerd/gotcha path: /gotcha_core/src/lib.rs use std::collections::BTreeMap; use actix_web::Either; use actix_web::web::{Data, Json, Path, Query}; use convert_case::{Case, Casing}; use http::Method; use oas::{MediaType, Operation, Parameter, ParameterIn, Referenceable, RequestBody, Response, Res...
code_fim
hard
{ "lang": "rust", "repo": "Kilerd/gotcha", "path": "/gotcha_core/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> bytes.iter().fold(0, |acc, &i| acc * 10 + i as usize) } fn phase(signal: &[u8]) -> Vec<u8> { (1..=signal.len()) .map(|step| { pattern(step) .zip(signal) .map(|(n, &m)| n as i16 * m as i16) .sum::<i16>() .abs() ...
code_fim
medium
{ "lang": "rust", "repo": "zookini/aoc-2019", "path": "/src/bin/q16-1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn pattern(step: usize) -> impl Iterator<Item = i8> { [0, 1, 0, -1] .iter() .cycle() .flat_map(move |i| std::iter::repeat(*i).take(step)) .skip(1) }<|fim_prefix|>// repo: zookini/aoc-2019 path: /src/bin/q16-1.rs use aoc::*; fn main() -> Result<()> { let mut signal...
code_fim
hard
{ "lang": "rust", "repo": "zookini/aoc-2019", "path": "/src/bin/q16-1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zookini/aoc-2019 path: /src/bin/q16-1.rs use aoc::*; fn main() -> Result<()> { let mut signal: Vec<_> = input("16.txt")?.bytes().map(|b| b - b'0').collect(); for _ in 0..100 { signal = phase(&signal); } <|fim_suffix|>fn extract(bytes: &[u8]) -> usize { bytes.iter().fol...
code_fim
medium
{ "lang": "rust", "repo": "zookini/aoc-2019", "path": "/src/bin/q16-1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> server::create_server("127.0.0.1:6767").unwrap(); println!("Running server!"); }<|fim_prefix|>// repo: seanpm2001/Rust-Community_UnderHanded-Submissions path: /2016/serejkaaa512/submission1/submission/src/main.rs #[macro_use] extern crate underhanded; use underhanded::server; <|fim_middle|>fn m...
code_fim
easy
{ "lang": "rust", "repo": "seanpm2001/Rust-Community_UnderHanded-Submissions", "path": "/2016/serejkaaa512/submission1/submission/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rukai/canon_collision path: /canon_collision_lib/src/entity_def/toriel.rs #[repr(u64)] #[derive(Clone, PartialEq, Debug, EnumString, IntoStaticStr, EnumIter, Serialize, Deserialize)] pub enum TorielAction { // Specials DspecialGroundStart, DspecialAirStart, <|fim_suffix|> // Thro...
code_fim
medium
{ "lang": "rust", "repo": "rukai/canon_collision", "path": "/canon_collision_lib/src/entity_def/toriel.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Throws Uthrow, Dthrow, Fthrow, Bthrow, }<|fim_prefix|>// repo: rukai/canon_collision path: /canon_collision_lib/src/entity_def/toriel.rs #[repr(u64)] #[derive(Clone, PartialEq, Debug, EnumString, IntoStaticStr, EnumIter, Serialize, Deserialize)] pub enum TorielAction { // Speci...
code_fim
medium
{ "lang": "rust", "repo": "rukai/canon_collision", "path": "/canon_collision_lib/src/entity_def/toriel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return Ok(()); } _ => {} }; } self.write_object(w, ctx, a)?; match *op { BinaryOpType::Add => write!(w, " + "), BinaryO...
code_fim
hard
{ "lang": "rust", "repo": "tmzt/isymtope", "path": "/isymtope-build/src/output/writers/js.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmzt/isymtope path: /isymtope-build/src/output/writers/js.rs write!(w, "{}", s)?; Ok(()) } Expression::RawPath(ref s, _) => { write!(w, "{}", s)?; Ok(()) } // Expression::Binding(ref b) => ...
code_fim
hard
{ "lang": "rust", "repo": "tmzt/isymtope", "path": "/isymtope-build/src/output/writers/js.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmzt/isymtope path: /isymtope-build/src/output/writers/js.rs : &EvaluateValue<ProcessedExpression>, ) -> DocumentProcessingResult<()> { let shape = match obj.0 { ExpressionValue::Binding(ref binding, _) => get_binding_shape(ctx, binding)?, _ => None };...
code_fim
hard
{ "lang": "rust", "repo": "tmzt/isymtope", "path": "/isymtope-build/src/output/writers/js.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Giovan/lumen path: /liblumen_alloc/src/erts/process/alloc/stack_primitives.rs use core::ops::DerefMut; use crate::erts::Term; pub trait StackPrimitives { /// Gets the number of terms currently allocated on the stack fn stack_size(&self) -> usize; /// Manually sets the stack size ...
code_fim
hard
{ "lang": "rust", "repo": "Giovan/lumen", "path": "/liblumen_alloc/src/erts/process/alloc/stack_primitives.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.deref_mut().stack_pointer() } #[inline] unsafe fn set_stack_pointer(&mut self, sp: *mut Term) { self.deref_mut().set_stack_pointer(sp); } #[inline] fn stack_used(&self) -> usize { self.deref().stack_used() } #[inline] fn stack_available(&...
code_fim
hard
{ "lang": "rust", "repo": "Giovan/lumen", "path": "/liblumen_alloc/src/erts/process/alloc/stack_primitives.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pimox/proxmox path: /proxmox/src/tools/tfa/totp.rs e std::time::{Duration, SystemTime}; use anyhow::{anyhow, bail, Error}; use openssl::hash::MessageDigest; use openssl::pkey::PKey; use openssl::sign::Signer; use percent_encoding::{percent_decode, percent_encode}; use serde::{Serialize, Seriali...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox", "path": "/proxmox/src/tools/tfa/totp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Convert a time stamp into a counter value. This makes it easier and cheaper to check a /// range of values. fn time_to_counter(&self, time: SystemTime) -> Result<u64, Error> { match time.duration_since(SystemTime::UNIX_EPOCH) { Ok(epoch) => Ok(epoch.as_secs() / (self.pe...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox", "path": "/proxmox/src/tools/tfa/totp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 1Crazymoney/wasmtime path: /cranelift/filetests/src/test_stack_maps.rs use crate::subtest::{run_filecheck, Context, SubTest}; use cranelift_codegen::binemit::{self, Addend, CodeOffset, CodeSink, Reloc, StackMap}; use cranelift_codegen::ir::*; use cranelift_codegen::isa::TargetIsa; use cranelift_...
code_fim
hard
{ "lang": "rust", "repo": "1Crazymoney/wasmtime", "path": "/cranelift/filetests/src/test_stack_maps.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> writeln!(&mut self.text, " - mapped words: {}", map.mapped_words()).unwrap(); write!(&mut self.text, " - live: [").unwrap(); let mut needs_comma_space = false; for i in 0..(map.mapped_words() as usize) { if map.get_bit(i) { if needs_comma_spac...
code_fim
hard
{ "lang": "rust", "repo": "1Crazymoney/wasmtime", "path": "/cranelift/filetests/src/test_stack_maps.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>pub fn into_range_bounds(i: (u64, u64)) -> (Bound<u64>, Bound<u64>) { (Bound::Included(i.0), Bound::Included(i.1)) } pub fn header2header<H1: Header, H2: Header>(i: H1) -> Result<impl Header, headers::Error> { let mut v = vec![]; i.encode(&mut v); H2::decode(&mut v.iter()) } pub trait Re...
code_fim
hard
{ "lang": "rust", "repo": "izderadicka/audioserve", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "shared-positions")] pub fn parse_cron<S: AsRef<str>>(exp: S) -> crate::error::Result<cron::Schedule> { let exp = format!("0 {} *", exp.as_ref()); exp.parse().map_err(crate::Error::from) }<|fim_prefix|>// repo: izderadicka/audioserve path: /src/util.rs use headers::{Header, Header...
code_fim
hard
{ "lang": "rust", "repo": "izderadicka/audioserve", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: izderadicka/audioserve path: /src/util.rs use headers::{Header, HeaderMapExt}; use hyper::http::response::Builder; use std::cmp::{max, min}; use std::{ ops::{Bound, RangeBounds}, path::Path, }; /// exists or is current dir pub fn parent_dir_exists<P: AsRef<Path>>(p: &P) -> bool { ma...
code_fim
hard
{ "lang": "rust", "repo": "izderadicka/audioserve", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let pos = moves .iter() .position(|m| m == &BitBoardMove::new(start as u16, end as u16, 0)) .unwrap(); bit_board.apply_move(&moves[pos]); bit_board.mirror_board(); //bit_board.change_side(); } } ...
code_fim
hard
{ "lang": "rust", "repo": "grant0417/chess-ai", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: grant0417/chess-ai path: /src/main.rs #![allow(dead_code, unused_imports)] use std::{error::Error, str::from_utf8}; use crate::interface::*; use crate::uci::{ResponseType, UCIDriver}; use bitboard::{generate_moves, perft, BitBoardMove, BitBoardState}; use board::{Board, Color}; use clap::{App,...
code_fim
hard
{ "lang": "rust", "repo": "grant0417/chess-ai", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Produces a `BitSlice` containing the entire vector. /// /// Equivalent to `&s[..]`. /// /// # Parameters /// /// - `&self` /// /// # Returns /// /// A `BitSlice` over the vector. /// /// # Examples /// /// ```rust /// use bitvec::prelude::*; /// /// let bv = bitvec![0, 1, 1, 0]; ///...
code_fim
hard
{ "lang": "rust", "repo": "pczarn/bitvec", "path": "/src/vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Moves all the elements of `other` into `self`, leaving `other` empty. /// /// # Parameters /// /// - `&mut self` /// - `other`: A `BitVec` of any order and storage type. Its bits are /// appended to `self`. /// /// # Panics /// /// Panics if the joined vector is too large. /// /// # Exa...
code_fim
hard
{ "lang": "rust", "repo": "pczarn/bitvec", "path": "/src/vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pczarn/bitvec path: /src/vec.rs nd include all bits in it. /// /// # Parameters /// /// - `elt`: The source element. /// /// # Returns /// /// A `BitVec` over the provided element. /// /// # Examples /// /// ```rust /// use bitvec::prelude::*; /// /// let bv = BitVec::<BigEndian, ...
code_fim
hard
{ "lang": "rust", "repo": "pczarn/bitvec", "path": "/src/vec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, method: Method, uri: &str, backend: &str, headers: Option<HashMap<String, String>>, body: Option<&str>, cache_override: Option<CacheOverride>, ) -> Result<Response<Body>, Error> { let t0 = Instant::now(); // let debug =...
code_fim
hard
{ "lang": "rust", "repo": "kpeters-cbsi/fastly-compute-at-edge-rust-poc", "path": "/src/spacex_tle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kpeters-cbsi/fastly-compute-at-edge-rust-poc path: /src/spacex_tle.rs use fastly::http::{HeaderValue, Method}; use fastly::request::CacheOverride; use fastly::{Body, Error, Request, RequestExt, Response}; use serde_json::value; use std::collections::HashMap; use std::time::Instant; const BACKEN...
code_fim
hard
{ "lang": "rust", "repo": "kpeters-cbsi/fastly-compute-at-edge-rust-poc", "path": "/src/spacex_tle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn get_tles_for_norad_ids(&mut self, norad_ids: &[i64]) -> Result<Vec<String>, Error> { let mut tles = Vec::new(); for norad_id in norad_ids { let path = format!("tle/{}", norad_id); let response = self.n2yo_request(&path)?; let tle_str = response.ge...
code_fim
hard
{ "lang": "rust", "repo": "kpeters-cbsi/fastly-compute-at-edge-rust-poc", "path": "/src/spacex_tle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ftsujikawa/rust-sample path: /ch13/code13-18/src/main.rs #[derive(Debug)] struct Person { id: i32, name: String, age: i32, addr: String, } fn main() { let p = Person {<|fim_suffix|>e: 50, addr: String::from("Tokyo"), }; dbg!(p); }<|fim_middle|> ...
code_fim
medium
{ "lang": "rust", "repo": "ftsujikawa/rust-sample", "path": "/ch13/code13-18/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e: 50, addr: String::from("Tokyo"), }; dbg!(p); }<|fim_prefix|>// repo: ftsujikawa/rust-sample path: /ch13/code13-18/src/main.rs #[derive(Debug)] struct Person { id: i32, name: String, <|fim_middle|> age: i32, addr: String, } fn main() { let p = Person { ...
code_fim
medium
{ "lang": "rust", "repo": "ftsujikawa/rust-sample", "path": "/ch13/code13-18/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn cargo(contents: &str) -> Result<usize> { let parsed = contents.parse::<Value>()?; let count = parsed.get("dependencies"); match count { Some(val) => Ok(val.as_table().unwrap().len()), None => Ok(0), } } fn go_modules(contents: &str) -> Result<usize> { let mut count...
code_fim
hard
{ "lang": "rust", "repo": "exoego/onefetch", "path": "/src/info/deps/package_manager.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: exoego/onefetch path: /src/info/deps/package_manager.rs use anyhow::Result; use regex::Regex; use std::collections::HashMap; use strum::EnumIter; use toml::Value; use yaml_rust::YamlLoader; macro_rules! define_package_managers { ($( { $name:ident, $display:literal, [$(($file:literal, $parse...
code_fim
hard
{ "lang": "rust", "repo": "exoego/onefetch", "path": "/src/info/deps/package_manager.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pingyu/tikv path: /components/external_storage/src/metrics.rs // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. <|fim_suffix|>lazy_static! { pub static ref EXT_STORAGE_CREATE_HISTOGRAM: HistogramVec = register_histogram_vec!( "tikv_external_storage_create_seconds", ...
code_fim
easy
{ "lang": "rust", "repo": "pingyu/tikv", "path": "/components/external_storage/src/metrics.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pco2699/algorithms path: /knapsack/src/main.rs use std::fs::File; use std::io::{BufRead, BufReader, Error}; use std::str::FromStr; use std::cmp; struct Item { weight: u32, value: u32 } type ItemList = Vec<Item>; fn main() { println!("{}", solve("knapsack1.txt")); } <|fim_suffix...
code_fim
hard
{ "lang": "rust", "repo": "pco2699/algorithms", "path": "/knapsack/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = File::open(file_name)?; let buffered = BufReader::new(input); let mut item_list: ItemList = vec![]; let mut knapsack_size: usize = 0; for(index, line) in buffered.lines().enumerate() { let unwraped_line = line.unwrap(); if index == 0 { let first...
code_fim
hard
{ "lang": "rust", "repo": "pco2699/algorithms", "path": "/knapsack/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 1..=n { let wi = item_list[i-1].weight as usize; let vi = item_list[i-1].value as usize; for x in 0..=w { dp_table[x][i] = cmp::max(dp_table[x][i-1], if x >= wi { dp_table[x-wi][i-1] + vi as u32} else { 0 }) } } dp_table[w][n] } fn read_fi...
code_fim
hard
{ "lang": "rust", "repo": "pco2699/algorithms", "path": "/knapsack/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { // Vector of Tcp connections let mut mux_connections: HashMap<usize, TcpStream> = HashMap::new(); let listener = TcpListener::bind("0.0.0.0:8080").unwrap(); let (mut mux_stream, addr) = listener.accept().unwrap(); println!("new client: {:?}", addr); loop { let...
code_fim
medium
{ "lang": "rust", "repo": "jabedude/mux", "path": "/src/daemon.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let listener = TcpListener::bind("0.0.0.0:8080").unwrap(); let (mut mux_stream, addr) = listener.accept().unwrap(); println!("new client: {:?}", addr); loop { let mut buf: Vec<u8> = vec![0u8; 8192]; let recv = mux_stream.read(&mut buf).unwrap(); let deserialized: M...
code_fim
medium
{ "lang": "rust", "repo": "jabedude/mux", "path": "/src/daemon.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jabedude/mux path: /src/daemon.rs use std::net::TcpListener; use std::net::TcpStream; use std::io::Write; use std::io::Read; use std::collections::HashMap; use std::str; <|fim_suffix|>fn main() { // Vector of Tcp connections let mut mux_connections: HashMap<usize, TcpStream> = HashMap::...
code_fim
medium
{ "lang": "rust", "repo": "jabedude/mux", "path": "/src/daemon.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rconan/gmt-controllers path: /wfc/ngao/src/lib.rs #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(improper_ctypes)] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); include!(concat!(env!("OUT_DIR"), "/controller.rs")); #[cfg(test)] mod t...
code_fim
hard
{ "lang": "rust", "repo": "rconan/gmt-controllers", "path": "/wfc/ngao/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let y_err = (ngao_imp_y .into_iter() .zip(&y) .map(|(sim_y, y)| sim_y - *y) .map(|x| x * x) .sum::<f64>() / n as f64) .sqrt(); assert!(dbg!(y_err) < 1e-6); } }<|fim_prefix|>// repo: rconan/gmt-controlle...
code_fim
hard
{ "lang": "rust", "repo": "rconan/gmt-controllers", "path": "/wfc/ngao/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tobyjsullivan/hlc-rs path: /src/data/store.rs use crate::data::AccountID; pub struct Store { ids: Box<IdMask>, } impl Store { pub fn new() -> Store { Store { ids: Box::new(IdMask::new()), } } pub fn mark_account(&mut self, acct_id: AccountID) { ...
code_fim
medium
{ "lang": "rust", "repo": "tobyjsullivan/hlc-rs", "path": "/src/data/store.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn new() -> Self { Self { entries: Vec::new(), } } fn mark(&mut self, acct_id: AccountID) { let (block, bit) = Self::locate(acct_id); while self.entries.len() <= block { self.entries.push(0); } let cur_block = self.entrie...
code_fim
medium
{ "lang": "rust", "repo": "tobyjsullivan/hlc-rs", "path": "/src/data/store.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { unsafe { for _x in 0..50 { let start = Instant::now(); bubble_sort(&mut SET2); let elapsed = start.elapsed(); println!("{:?}", elapsed); } } }<|fim_prefix|>// repo: pedrogemal/pgc-eda-2021-1 path: /rust/src/bubble_sort.rs...
code_fim
hard
{ "lang": "rust", "repo": "pedrogemal/pgc-eda-2021-1", "path": "/rust/src/bubble_sort.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { for _x in 0..50 { let start = Instant::now(); bubble_sort(&mut SET2); let elapsed = start.elapsed(); println!("{:?}", elapsed); } } }<|fim_prefix|>// repo: pedrogemal/pgc-eda-2021-1 path: /rust/src/bubble_sort.rs // Code ori...
code_fim
medium
{ "lang": "rust", "repo": "pedrogemal/pgc-eda-2021-1", "path": "/rust/src/bubble_sort.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pedrogemal/pgc-eda-2021-1 path: /rust/src/bubble_sort.rs // Code originally forked from https://github.com/diptangsu/Sorting-Algorithms/ include!("constants.rs"); use std::time::Instant; <|fim_suffix|> unsafe { for _x in 0..50 { let start = Instant::now(); bub...
code_fim
hard
{ "lang": "rust", "repo": "pedrogemal/pgc-eda-2021-1", "path": "/rust/src/bubble_sort.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { // Use custom formatting to avoid printing every single instruction // in a block or fork instruction. Self::Block(_) => f.write_str("Block(...)"), Self::Fork(_) => f.write_str("Fork(...)"), // Use debug formatting for all th...
code_fim
hard
{ "lang": "rust", "repo": "HactarCE/Metatape", "path": "/src/metatape/program.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // IOMode(IOMode), // Seek(String), Call(String), // Load(String), Fork(InstructionBlock), } impl fmt::Display for Instruction { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { // Use custom formatting to avoid printing every single inst...
code_fim
medium
{ "lang": "rust", "repo": "HactarCE/Metatape", "path": "/src/metatape/program.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HactarCE/Metatape path: /src/metatape/program.rs use std::collections::HashMap; use std::fmt; use std::rc::Rc; pub type InstructionSeq = Vec<(usize, Instruction)>; pub type InstructionBlock = Rc<InstructionSeq>; pub type Subroutines = HashMap<String, InstructionBlock>; #[derive(Debug)] pub str...
code_fim
medium
{ "lang": "rust", "repo": "HactarCE/Metatape", "path": "/src/metatape/program.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_1() { todo!(); // assert_eq!(Solution::function(), 0); } }<|fim_prefix|>// repo: y-usuzumi/survive-the-course path: /survive-the-course-rs/src/problems/leetcode_cn/_642_Design_Search_Autocomplete_System.rs // https://leetcode.cn/problems/design-search-autocompl...
code_fim
hard
{ "lang": "rust", "repo": "y-usuzumi/survive-the-course", "path": "/survive-the-course-rs/src/problems/leetcode_cn/_642_Design_Search_Autocomplete_System.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: y-usuzumi/survive-the-course path: /survive-the-course-rs/src/problems/leetcode_cn/_642_Design_Search_Autocomplete_System.rs // https://leetcode.cn/problems/design-search-autocomplete-system/ // TODO: uncompleted <|fim_suffix|>/** * Your AutocompleteSystem object will be instantiated and calle...
code_fim
hard
{ "lang": "rust", "repo": "y-usuzumi/survive-the-course", "path": "/survive-the-course-rs/src/problems/leetcode_cn/_642_Design_Search_Autocomplete_System.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl ClientboundPacket { pub fn new(packet_id: i32, data: BytesMut) -> ClientboundPacket { ClientboundPacket { packet_id, data } } pub fn packet_id(&self) -> i32 { self.packet_id } pub fn data(self) -> BytesMut { self.data } } pub trait FromPacket: Sized ...
code_fim
medium
{ "lang": "rust", "repo": "RobMor/server", "path": "/server/src/protocol/packets/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RobMor/server path: /server/src/protocol/packets/mod.rs use anyhow::Result; use bytes::BytesMut; pub mod handshake; pub mod login; pub mod play; pub mod status; pub struct ServerboundPacket { packet_id: i32, data: BytesMut, } <|fim_suffix|>pub trait FromPacket: Sized { fn from_pac...
code_fim
hard
{ "lang": "rust", "repo": "RobMor/server", "path": "/server/src/protocol/packets/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait FromPacket: Sized { fn from_packet(packet: ServerboundPacket) -> Result<Self>; } pub trait IntoPacket: Sized { fn into_packet(self) -> ClientboundPacket; }<|fim_prefix|>// repo: RobMor/server path: /server/src/protocol/packets/mod.rs use anyhow::Result; use bytes::BytesMut; pub mod ha...
code_fim
hard
{ "lang": "rust", "repo": "RobMor/server", "path": "/server/src/protocol/packets/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sigmaSd/libv4l-rs path: /src/format/field.rs use std::convert::TryFrom; use std::fmt; #[derive(Debug, Copy, Clone)] #[repr(u32)] /// Represents how fields are interlaced (if they are) pub enum FieldOrder { /// Progressive, Top, Bottom, or Interlaced is acceptable; driver will pick one A...
code_fim
medium
{ "lang": "rust", "repo": "sigmaSd/libv4l-rs", "path": "/src/format/field.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn try_from(code: u32) -> Result<Self, Self::Error> { match code { 0 => Ok(Self::Any), 1 => Ok(Self::Progressive), 2 => Ok(Self::Top), 3 => Ok(Self::Bottom), 4 => Ok(Self::Interlaced), 5 => Ok(Self::SequentialTB), ...
code_fim
medium
{ "lang": "rust", "repo": "sigmaSd/libv4l-rs", "path": "/src/format/field.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match code { 0 => Ok(Self::Any), 1 => Ok(Self::Progressive), 2 => Ok(Self::Top), 3 => Ok(Self::Bottom), 4 => Ok(Self::Interlaced), 5 => Ok(Self::SequentialTB), 6 => Ok(Self::SequentialBT), 7 => Ok(Self:...
code_fim
medium
{ "lang": "rust", "repo": "sigmaSd/libv4l-rs", "path": "/src/format/field.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::crc16::Crc16; pub use self::crc32::Crc32; pub use self::crc32::Crc32c; pub use self::crc64::Crc64; pub use self::crc8::Crc8;<|fim_prefix|>// repo: althonos/pruefung path: /src/crc/mod.rs //! [Cyclic Redundancy Check][1] implementations. //! //! # References //! //! * [Catalogue of parametri...
code_fim
medium
{ "lang": "rust", "repo": "althonos/pruefung", "path": "/src/crc/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: althonos/pruefung path: /src/crc/mod.rs //! [Cyclic Redundancy Check][1] implementations. //! //! # References //! //! * [Catalogue of parametrised CRC algorithms](http://reveng.sourceforge.net/crc-catalogue/) //! * [Wikipedia list of CRC Polynomials](https://en.wikipedia.org/wiki/Cyclic_redunda...
code_fim
medium
{ "lang": "rust", "repo": "althonos/pruefung", "path": "/src/crc/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndrewHC36/Matrixagon path: /renderer/src/pipeline.rs e, fragment, device.debug_mode); // graphics pipeline let main_func = CString::new("main").unwrap(); let vertx_shd_sinfo = vk::PipelineShaderStageCreateInfo { stage: vk::ShaderStageFlags::VERTEX, ...
code_fim
hard
{ "lang": "rust", "repo": "AndrewHC36/Matrixagon", "path": "/renderer/src/pipeline.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let renderpass_cinfo = vk::RenderPassCreateInfo { attachment_count: attachments.len() as u32, p_attachments: attachments.as_ptr(), subpass_count: 1, p_subpasses: &subpass, dependency_count: 1, p_dependencies: &subpass_dependen...
code_fim
hard
{ "lang": "rust", "repo": "AndrewHC36/Matrixagon", "path": "/renderer/src/pipeline.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let color_blend_attach = vk::PipelineColorBlendAttachmentState { color_write_mask: vk::ColorComponentFlags::all(), blend_enable: vk::FALSE, ..Default::default() }; let color_blending_cinfo = vk::PipelineColorBlendStateCreateInfo { lo...
code_fim
hard
{ "lang": "rust", "repo": "AndrewHC36/Matrixagon", "path": "/renderer/src/pipeline.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dakongyi2014/aiot-rust path: /src/dm/msg.rs use crate::alink::{AlinkRequest, AlinkResponse}; use crate::Result; use serde::{Deserialize, Serialize}; use serde_json::Value; #[derive(Deserialize, Serialize, Debug, Clone)] pub struct DataModelMsg { /// 消息所属设备的product_key, 若为NULL则使用通过aiot_dm_se...
code_fim
hard
{ "lang": "rust", "repo": "dakongyi2014/aiot-rust", "path": "/src/dm/msg.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }