text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: SneManden/RustRaytracer path: /src/ray_tracer/vector_library.rs #[derive(Debug)] pub struct Vec3D { x: f32, y: f32, z: f32 } #[derive(Debug)] pub struct Point3D { x: f32, y: f32, z: f32 } impl Vec3D { pub fn x(&self) -> f32 { self.x } pub fn y(&self) -> f32 { s...
code_fim
hard
{ "lang": "rust", "repo": "SneManden/RustRaytracer", "path": "/src/ray_tracer/vector_library.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl PartialEq for Point3D { fn eq(&self, other: &Self) -> bool { self.x == other.x && self.y == other.y && self.z == other.z } } #[cfg(test)] mod tests { use super::*; #[test] fn scale() { // Arrange let v = Vec3D::new(3.0, 4.0, 1.0); let k = 2.5; ...
code_fim
hard
{ "lang": "rust", "repo": "SneManden/RustRaytracer", "path": "/src/ray_tracer/vector_library.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!( "{}", min_stoa + min_btoe + AB.iter().map(|&(a, b)| (b - a).abs()).sum::<i64>() ); }<|fim_prefix|>// repo: magurotuna/atcoder-submissions path: /s8pc-6/src/bin/b.rs use libprocon::*; use std::cmp::min; fn main() { input! { N: usize, AB: [(i64, i64); ...
code_fim
hard
{ "lang": "rust", "repo": "magurotuna/atcoder-submissions", "path": "/s8pc-6/src/bin/b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magurotuna/atcoder-submissions path: /s8pc-6/src/bin/b.rs use libprocon::*; use std::cmp::min; fn main() { input! { N: usize, AB: [(i64, i64); N], } let mut ent = 0; let mut min_stoa = 1 << 60; for i in 0..N { let tmp_ent = AB[i].0; let total ...
code_fim
hard
{ "lang": "rust", "repo": "magurotuna/atcoder-submissions", "path": "/s8pc-6/src/bin/b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>doc = "`read()` method returns [`rcc_rng2ckselr::R`](R) reader structure"] impl crate::Readable for RCC_RNG2CKSELR_SPEC {} #[doc = "`write(|w| ..)` method takes [`rcc_rng2ckselr::W`](W) writer structure"] impl crate::Writable for RCC_RNG2CKSELR_SPEC { const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/rcc/rcc_rng2ckselr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp157/rcc/rcc_rng2ckselr.rs #[doc = "Register `RCC_RNG2CKSELR` reader"] pub type R = crate::R<RCC_RNG2CKSELR_SPEC>; #[doc = "Register `RCC_RNG2CKSELR` writer"] pub type W = crate::W<RCC_RNG2CKSELR_SPEC>; #[doc = "Field `RNG2SRC` reader - RNG2S...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/rcc/rcc_rng2ckselr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: underdiskdev/wakeboy-i path: /src/wakeboy/cpu.rs use super::bus::*; use super::registers::*; use super::instructions::*; use super::core::*; pub struct CPU { pub memory: MemoryBus, pub registers: Registers, } impl CPU { pub fn run(&mut self) { loop { let old_pc = self.registers.pc; ...
code_fim
hard
{ "lang": "rust", "repo": "underdiskdev/wakeboy-i", "path": "/src/wakeboy/cpu.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn execute(&mut self, instruction: &Instruction) -> (u16, bool) { self.registers.pc.overflowing_add(1) } } impl Default for CPU { fn default() -> Self { CPU { memory: Default::default(), registers: Default::default(), } } }<|fim_prefix|>// repo: underdiskdev/wakeboy-i path: /src/wake...
code_fim
medium
{ "lang": "rust", "repo": "underdiskdev/wakeboy-i", "path": "/src/wakeboy/cpu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cor/advent-of-code path: /2020/12/src/main.rs use aoc_2020_common::common::load_file; use num_enum::IntoPrimitive; use num_enum::TryFromPrimitive; use std::str::FromStr; use std::convert::TryFrom; // NOTE: I really dislike the extensibility used for this day. #[derive(Debug, Eq, PartialEq, Clo...
code_fim
hard
{ "lang": "rust", "repo": "cor/advent-of-code", "path": "/2020/12/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match direction { Direction::North => self.wy += distance, Direction::East => self.wx += distance, Direction::South => self.wy -= distance, Direction::West => self.wx -= distance, } } } #[derive(Debug)] enum Instruction { Move(Direct...
code_fim
hard
{ "lang": "rust", "repo": "cor/advent-of-code", "path": "/2020/12/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] enum Instruction { Move(Direction, i64), Turn(i64), Forward(i64), } impl FromStr for Instruction { type Err = String; fn from_str(s: &str) -> Result<Self, Self::Err> { let (operation, number) = s.split_at(1); if let Ok(number) = number.parse() { ...
code_fim
hard
{ "lang": "rust", "repo": "cor/advent-of-code", "path": "/2020/12/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 8176135/filepath-tree path: /src/errors.rs use std::error::Error; use std::fmt; #[derive(Debug, Eq, PartialEq)] pub enum StorageError { PathNotRelative, } impl fmt::Display for StorageError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { <|fim_suffix|>impl Error ...
code_fim
medium
{ "lang": "rust", "repo": "8176135/filepath-tree", "path": "/src/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> "Some error happened when using PathStorage" } }<|fim_prefix|>// repo: 8176135/filepath-tree path: /src/errors.rs use std::error::Error; use std::fmt; #[derive(Debug, Eq, PartialEq)] pub enum StorageError { PathNotRelative, } impl fmt::Display for StorageError { fn fmt(&s...
code_fim
medium
{ "lang": "rust", "repo": "8176135/filepath-tree", "path": "/src/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, mut chain_info: ChainInfo, mut prev_info: ChainInfo, ) -> Result<PushResult, PushError> { // Update chain infos. chain_info.on_main_chain = true; prev_info.main_chain_successor = Some(chain_info.head.hash()); // Get write transaction ...
code_fim
hard
{ "lang": "rust", "repo": "viquezclaudio/core-rs-albatross", "path": "/nano-blockchain/src/push.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Store the chain info. chain_store_w.put_chain_info(current); current = prev_info; } // Update the head of the blockchain. self.head = chain_info.head; Ok(PushResult::Rebranched) } /// Pushes an election block backwards into...
code_fim
hard
{ "lang": "rust", "repo": "viquezclaudio/core-rs-albatross", "path": "/nano-blockchain/src/push.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: viquezclaudio/core-rs-albatross path: /nano-blockchain/src/push.rs use nimiq_block::{Block, BlockError, BlockType, MacroHeader}; use nimiq_blockchain::{ AbstractBlockchain, Blockchain, ChainInfo, ChainOrdering, PushError, PushResult, }; use nimiq_hash::{Blake2bHash, Hash}; use nimiq_primitiv...
code_fim
hard
{ "lang": "rust", "repo": "viquezclaudio/core-rs-albatross", "path": "/nano-blockchain/src/push.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ashishtyagi10/rust path: /udemy/src/main.rs #[allow(dead_code)] #[allow(unused_imports)] use std::mem; <|fim_suffix|> println!("Hello, world!"); let age = 32; println!("age is {}", age); let c = 12345678; println!("{} is taking byte {}", c, mem::size_of_val(&c)); let d:is...
code_fim
easy
{ "lang": "rust", "repo": "ashishtyagi10/rust", "path": "/udemy/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Hello, world!"); let age = 32; println!("age is {}", age); let c = 12345678; println!("{} is taking byte {}", c, mem::size_of_val(&c)); let d:isize = 1234567890123456789; println!("{} is taking byte {}", d, mem::size_of_val(&d)); }<|fim_prefix|>// repo: ashishtyagi10/...
code_fim
easy
{ "lang": "rust", "repo": "ashishtyagi10/rust", "path": "/udemy/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] struct Inner { msg: String, }<|fim_prefix|>// repo: someoneonsmile/learn_note path: /rust-code/option_chain/src/main.rs fn main() { println!("Hello, world!"); let inner = map(None); println!("{:?}", inner); } fn map(out: Option<Out>) -> Option<Inner> { let innner = o...
code_fim
easy
{ "lang": "rust", "repo": "someoneonsmile/learn_note", "path": "/rust-code/option_chain/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: someoneonsmile/learn_note path: /rust-code/option_chain/src/main.rs fn main() { println!("Hello, world!"); let inner = map(None); println!("{:?}", inner); } fn map(out: Option<Out>) -> Option<Inner> { <|fim_suffix|>#[derive(Debug)] struct Inner { msg: String, }<|fim_middle|> ...
code_fim
medium
{ "lang": "rust", "repo": "someoneonsmile/learn_note", "path": "/rust-code/option_chain/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self.sender.produce(futures::task::current()) { Err(e) => resume_unwind(Box::new(e.to_string())), Ok(_) => Ok(Async::NotReady), } }, ...
code_fim
hard
{ "lang": "rust", "repo": "GaiaWorld/pi_lib", "path": "/future/src/future.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Send + 'static, E: Send + 'static> Future for FutTask<T, E> { type Item = T; type Error = E; fn poll(&mut self) -> Poll<T, E> { if self.timeout < now_millisecond() as i64 { resume_unwind(Box::new("future task timeout")) //超时 } else { mat...
code_fim
hard
{ "lang": "rust", "repo": "GaiaWorld/pi_lib", "path": "/future/src/future.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaiaWorld/pi_lib path: /future/src/future.rs use std::sync::Arc; use std::panic::resume_unwind; use std::marker::{Send, Sync}; use futures::*; use npnc::ConsumeError; use npnc::bounded::spsc::{Producer, Consumer}; use time::now_millisecond; /// /// 未来任务 /// #[derive(Debug)] pub ...
code_fim
hard
{ "lang": "rust", "repo": "GaiaWorld/pi_lib", "path": "/future/src/future.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> events.put(*fd, interest); }; } event_put!(session_a); event_put!(session_b); } if poll(&mut events, Some(Duration::from_secs(1)))? > 0 { for event in &events { macro_rules! event { ...
code_fim
hard
{ "lang": "rust", "repo": "whidbey/queen", "path": "/src/port/bridge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whidbey/queen path: /src/port/bridge.rs use std::collections::{VecDeque, HashSet}; use std::io::{self, ErrorKind::PermissionDenied}; use std::time::Duration; use std::thread::sleep; use nson::{Message, msg}; use queen_io::poll::{poll, Ready, Events}; use crate::net::Addr; use super::conn::Co...
code_fim
hard
{ "lang": "rust", "repo": "whidbey/queen", "path": "/src/port/bridge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> continue; } else { return Err(io::Error::new(PermissionDenied, "PermissionDenied")) } } ...
code_fim
hard
{ "lang": "rust", "repo": "whidbey/queen", "path": "/src/port/bridge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn construct_meta(&self, next_block_address: u64) -> Vec<u8> { self.size .to_be_bytes() .iter() .chain(&next_block_address.to_be_bytes()) .map(|b| *b) .collect::<Vec<u8>>() } }<|fim_prefix|>// repo: snaztoz/neondb path: /stor...
code_fim
hard
{ "lang": "rust", "repo": "snaztoz/neondb", "path": "/storage/src/alloc/rssalloc/rssblock.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snaztoz/neondb path: /storage/src/alloc/rssalloc/rssblock.rs #[derive(Debug)] pub struct RSSBlock { pub address: u64, pub size: u64, pub is_used: bool, } <|fim_suffix|> pub fn construct_meta(&self, next_block_address: u64) -> Vec<u8> { self.size .to_be_bytes()...
code_fim
hard
{ "lang": "rust", "repo": "snaztoz/neondb", "path": "/storage/src/alloc/rssalloc/rssblock.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blanet/sourcegraph path: /docker-images/syntax-highlighter/crates/sg-lsif/src/lsif.rs rap_or_else(|| ToolInfo::new()) } // string project_root = 3; pub fn get_project_root(&self) -> &str { &self.project_root } pub fn clear_project_root(&mut self) { self.pro...
code_fim
hard
{ "lang": "rust", "repo": "blanet/sourcegraph", "path": "/docker-images/syntax-highlighter/crates/sg-lsif/src/lsif.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blanet/sourcegraph path: /docker-images/syntax-highlighter/crates/sg-lsif/src/lsif.rs stance() -> &'static Document { static instance: ::protobuf::rt::LazyV2<Document> = ::protobuf::rt::LazyV2::INIT; instance.get(Document::new) } } impl ::protobuf::Clear for Document { f...
code_fim
hard
{ "lang": "rust", "repo": "blanet/sourcegraph", "path": "/docker-images/syntax-highlighter/crates/sg-lsif/src/lsif.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_manager(&self) -> &str { &self.manager } pub fn clear_manager(&mut self) { self.manager.clear(); } // Param is passed by value, moved pub fn set_manager(&mut self, v: ::std::string::String) { self.manager = v; } // Mutable pointer to the...
code_fim
hard
{ "lang": "rust", "repo": "blanet/sourcegraph", "path": "/docker-images/syntax-highlighter/crates/sg-lsif/src/lsif.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.as_secs() * MILLIS_PER_SEC + (self.subsec_nanos() / NANOS_PER_MILLI) as u64 } }<|fim_prefix|>// repo: Xujing0823/clang-rs-test path: /src/duration_ext.rs use std::time::Duration; pub trait DurationExt { fn to_millis(&self) -> u64; } <|fim_middle|>con...
code_fim
medium
{ "lang": "rust", "repo": "Xujing0823/clang-rs-test", "path": "/src/duration_ext.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl DurationExt for Duration { fn to_millis(&self) -> u64 { self.as_secs() * MILLIS_PER_SEC + (self.subsec_nanos() / NANOS_PER_MILLI) as u64 } }<|fim_prefix|>// repo: Xujing0823/clang-rs-test path: /src/duration_ext.rs use std::time::Duration; pub trait Durat...
code_fim
medium
{ "lang": "rust", "repo": "Xujing0823/clang-rs-test", "path": "/src/duration_ext.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xujing0823/clang-rs-test path: /src/duration_ext.rs use std::time::Duration; pub trait DurationExt { fn to_millis(&self) -> u64; } <|fim_suffix|> self.as_secs() * MILLIS_PER_SEC + (self.subsec_nanos() / NANOS_PER_MILLI) as u64 } }<|fim_middle|>con...
code_fim
medium
{ "lang": "rust", "repo": "Xujing0823/clang-rs-test", "path": "/src/duration_ext.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> type Params = <Simplifier as Processor>::Params; Params { fidelity: self.params.fidelity, shape_details: self.params.shape_details, } } pub fn init(&mut self) { self.prepare_clustering(); } pub fn tick(&mut self) -> bool { m...
code_fim
hard
{ "lang": "rust", "repo": "visioncortex/visionmagic", "path": "/webapp/src/simplification.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: visioncortex/visionmagic path: /webapp/src/simplification.rs use wasm_bindgen::prelude::*; use visionmagic::visioncortex::ColorImage; use visionmagic::{Processor, Clustering, Simplification as Simplifier}; use crate::canvas::*; use serde::Deserialize; #[derive(Debug, Deserialize)] pub struct ...
code_fim
hard
{ "lang": "rust", "repo": "visioncortex/visionmagic", "path": "/webapp/src/simplification.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut displayTotal = 0; for item in items.iter() { let (pid, class, wmname, keys, clicks, motions, timer) = (*item).clone(); let line = format!( "{: <7$.7$} {: <8$.8$} {: <9$.9$} {: <10$.10$} {: <11$.11$} {: <12$.12$} {: <13$.13$}", pid, class, wmname, key...
code_fim
hard
{ "lang": "rust", "repo": "alxkolm/rust-selftop", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alxkolm/rust-selftop path: /src/main.rs #![feature(globs)] extern crate libc; extern crate rustbox; use libc::*; use x11::xlib; use x11::xtst; use x11wrapper::{Display}; use std::time::Duration; use std::old_io::Timer; use std::ffi; use selftop::{MotionSniffer, WindowSniffer, UserEvent}; use s...
code_fim
hard
{ "lang": "rust", "repo": "alxkolm/rust-selftop", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samhippie/rust_mc_cfr path: /src/game/double_matrix_game.rs use std::fmt::{Display, Formatter}; use crate::game; use crate::game::{Player}; use crate::game::matrix_game::{Move, MatrixGame}; #[derive(Debug, Clone)] pub struct DoubleMatrixGame { games: (MatrixGame, MatrixGame), game1_mov...
code_fim
hard
{ "lang": "rust", "repo": "samhippie/rust_mc_cfr", "path": "/src/game/double_matrix_game.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> writeln!(f, "Matrix 1:")?; writeln!(f, "{}", self.games.0)?; writeln!(f, "Matrix 2:")?; writeln!(f, "{}", self.games.1)?; Ok(()) } } #[cfg(test)] mod test { use super::*; #[test] fn transpose_test() { let m = vec![ 1, 2, 3, ...
code_fim
hard
{ "lang": "rust", "repo": "samhippie/rust_mc_cfr", "path": "/src/game/double_matrix_game.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let fee_basis_points = 25; let db = get_test_database(); let fee_db_utils = FeeDatabaseUtils::new_for_btc_on_eos(); let accrued_fees_before = fee_db_utils.get_accrued_fees_from_db(&db).unwrap(); assert_eq!(accrued_fees_before, 0); let minting_params = get_sa...
code_fim
hard
{ "lang": "rust", "repo": "provable-things/ptokens-core", "path": "/src/btc_on_eos/btc/account_for_fees.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn should_account_for_fees_correctly_in_btc_on_eos_minting_params_if_minting_params_are_emtpy() { let fee_basis_points = 25; assert!(fee_basis_points > 0); let db = get_test_database(); let fee_db_utils = FeeDatabaseUtils::new_for_btc_on_eos(); let a...
code_fim
hard
{ "lang": "rust", "repo": "provable-things/ptokens-core", "path": "/src/btc_on_eos/btc/account_for_fees.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: provable-things/ptokens-core path: /src/btc_on_eos/btc/account_for_fees.rs use crate::{ btc_on_eos::btc::minting_params::BtcOnEosMintingParams, chains::btc::btc_state::BtcState, fees::{fee_constants::DISABLE_FEES, fee_database_utils::FeeDatabaseUtils}, traits::DatabaseInterface, ...
code_fim
hard
{ "lang": "rust", "repo": "provable-things/ptokens-core", "path": "/src/btc_on_eos/btc/account_for_fees.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-chainblock/bfs path: /src/lib_blockstack/src/types/src/file.rs use std::ffi::OsString; #[derive(Debug)] pub struct File { pub name: OsString, pub path: OsString, pub storage_top_level: OsString, pub updated_at: Option<String>, pub content: Option<Vec<u8>>, pub ...
code_fim
medium
{ "lang": "rust", "repo": "rust-chainblock/bfs", "path": "/src/lib_blockstack/src/types/src/file.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct UpdateFileResult { pub file: File, } #[derive(Debug)] pub struct DeleteFileResult { pub file: File, }<|fim_prefix|>// repo: rust-chainblock/bfs path: /src/lib_blockstack/src/types/src/file.rs use std::ffi::OsString; #[derive(Debug)] pub struct File { pub name: Os...
code_fim
hard
{ "lang": "rust", "repo": "rust-chainblock/bfs", "path": "/src/lib_blockstack/src/types/src/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::backend::{Sqlite, SqliteType}; pub use self::connection::SqliteConnection; pub use self::query_builder::SqliteQueryBuilder;<|fim_prefix|>// repo: Felmoks/diesel path: /diesel/src/sqlite/mod.rs mod backend; mod connection; mod types; <|fim_middle|>pub mod query_builder;
code_fim
easy
{ "lang": "rust", "repo": "Felmoks/diesel", "path": "/diesel/src/sqlite/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Felmoks/diesel path: /diesel/src/sqlite/mod.rs mod backend; mod connection; mod types; <|fim_suffix|>pub use self::backend::{Sqlite, SqliteType}; pub use self::connection::SqliteConnection; pub use self::query_builder::SqliteQueryBuilder;<|fim_middle|>pub mod query_builder;
code_fim
easy
{ "lang": "rust", "repo": "Felmoks/diesel", "path": "/diesel/src/sqlite/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jrforrest/sysunit-rust path: /src/error.rs #![macro_use] use std::fmt; pub type BoxedResult<T> = Result<T, Box<dyn std::error::Error>>; <|fim_suffix|>macro_rules! wrap_error { ($format_string: literal, $error: expr) => { Error::new(format!($format_string, $error.to_string())); ...
code_fim
medium
{ "lang": "rust", "repo": "jrforrest/sysunit-rust", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightning-project/lightning path: /src/worker/memory/manager.rs }; replace(&mut self.head, next) } else { None } } fn extend(&mut self, other: &mut RequestList) { let middle = if let Some(head) = take(&mut other.head) { h...
code_fim
hard
{ "lang": "rust", "repo": "lightning-project/lightning", "path": "/src/worker/memory/manager.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightning-project/lightning path: /src/worker/memory/manager.rs t state = chunk.state.borrow_mut(token); let entry = &mut state.host_entry; if entry.data.is_none() { let size_in_bytes = chunk.size_in_bytes; let alignment = chunk.layout.alignment; ...
code_fim
hard
{ "lang": "rust", "repo": "lightning-project/lightning", "path": "/src/worker/memory/manager.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let state = request.state.borrow_mut(&mut self.token); state.place = Some(valid_place); valid_place } fn push_host_allocation(&mut self, request: RequestRef) -> bool { if self.host.active_allocation.is_none() { self.host.active_allocation = Some(Request...
code_fim
hard
{ "lang": "rust", "repo": "lightning-project/lightning", "path": "/src/worker/memory/manager.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>define_type! { /// A single metadata entry value struct MetadataEntry(&aiMetadataEntry) } /// The value of a metadata item. pub enum MetadataValue<'a> { /// A boolean Bool(bool), /// A signed int I32(i32), /// An unsigned int U64(u64), /// A single-precision float ...
code_fim
hard
{ "lang": "rust", "repo": "eira-fransham/assimp-rs", "path": "/src/scene/node.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl MetadataEntry { /// Get the value of this entry pub fn get(&self) -> MetadataValue<'_> { unsafe { match self.mType { ffi::aiMetadataType_AI_BOOL => MetadataValue::Bool(*(self.mData as *const bool)), ffi::aiMetadataType_AI_INT32 => MetadataVa...
code_fim
hard
{ "lang": "rust", "repo": "eira-fransham/assimp-rs", "path": "/src/scene/node.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eira-fransham/assimp-rs path: /src/scene/node.rs use std::{ffi::CStr, ptr::NonNull, slice::from_raw_parts}; use ffi::{aiMetadata, aiMetadataEntry, aiNode, aiString, aiVector3D}; use crate::math::{Matrix4x4, Vector3D}; define_type_and_iterator_indirect! { /// The `Node` type represents a n...
code_fim
hard
{ "lang": "rust", "repo": "eira-fransham/assimp-rs", "path": "/src/scene/node.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Heliozoa/obs-websocket-rs path: /examples/events.rs //! OBS should be running with a WebSocket server running on port 4444 and password set to 1234. //! Try doing various things in OBS and see what events pop up! use obs_websocket::{futures::stream::StreamExt, Obs}; fn main() { <|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "Heliozoa/obs-websocket-rs", "path": "/examples/events.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let future = async { let (mut obs, mut event_receiver) = Obs::connect("localhost", 4444).await.unwrap(); obs.authenticate("1234").await.unwrap(); while let Some(event) = event_receiver.next().await { println!("{:#?}", event); } }; smol::run(future); ...
code_fim
medium
{ "lang": "rust", "repo": "Heliozoa/obs-websocket-rs", "path": "/examples/events.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl WeakObjectRef { pub fn into_strong(&self) -> ObjectRef { unsafe { self.ref_count .as_ref() .unwrap() .fetch_add(1, Ordering::Relaxed); } ObjectRef { ptr: self.ptr, ref_count: self.ref_count...
code_fim
hard
{ "lang": "rust", "repo": "aspen-lang/aspen", "path": "/aspen-runtime/src/object_ref.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aspen-lang/aspen path: /aspen-runtime/src/object_ref.rs use crate::{ActorAddress, Envelope, Inbox, Object, Runtime}; use alloc::boxed::Box; use core::fmt; use core::ops::Deref; use core::sync::atomic::{AtomicUsize, Ordering}; #[repr(C)] #[derive(PartialEq)] pub struct ObjectRef { ptr: *mut ...
code_fim
hard
{ "lang": "rust", "repo": "aspen-lang/aspen", "path": "/aspen-runtime/src/object_ref.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doraneko94/RustAntBook path: /atcoder/examples/abc079c.rs pub fn read1<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } <|fim_suffix|> for i in 0..2_usize.pow(3) { let mut ans = s[0].to_str...
code_fim
hard
{ "lang": "rust", "repo": "doraneko94/RustAntBook", "path": "/atcoder/examples/abc079c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..2_usize.pow(3) { let mut ans = s[0].to_string(); let mut tmp = s[0]; for j in 0..3 { if i >> j & 1 == 1 { ans += "+"; tmp += s[j + 1]; } else { ans += "-"; tmp -= s[j + 1]; ...
code_fim
hard
{ "lang": "rust", "repo": "doraneko94/RustAntBook", "path": "/atcoder/examples/abc079c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut source = RTSPSource::new("").unwrap(); source.on_packet(|p| { println!("{:?}", p); }); source.start(MediaType::All); }<|fim_prefix|>// repo: padu/cloverleaf path: /cloverleaf_rtsp/tests/test_source.rs use cloverleaf_rtsp::client::RTSPSource; use cloverleaf_rtsp::MediaType;...
code_fim
easy
{ "lang": "rust", "repo": "padu/cloverleaf", "path": "/cloverleaf_rtsp/tests/test_source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: padu/cloverleaf path: /cloverleaf_rtsp/tests/test_source.rs use cloverleaf_rtsp::client::RTSPSource; use cloverleaf_rtsp::MediaType; <|fim_suffix|> let mut source = RTSPSource::new("").unwrap(); source.on_packet(|p| { println!("{:?}", p); }); source.start(MediaType::All);...
code_fim
easy
{ "lang": "rust", "repo": "padu/cloverleaf", "path": "/cloverleaf_rtsp/tests/test_source.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let xpath = self.factory.build(expression).unwrap().unwrap(); xpath .evaluate(&self.context, self.package.as_document().root()) .unwrap() } fn parse_properties(&self) -> HashMap<String, String> { let mut properties = HashMap::with_capacity(10); ...
code_fim
hard
{ "lang": "rust", "repo": "chalme/coco", "path": "/psa/src/jvm/maven_dependency.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chalme/coco path: /psa/src/jvm/maven_dependency.rs use crate::{Dependency, DependencyAnalyzer, DependencyScope}; use std::collections::HashMap; use std::fs::read_to_string; use std::path::PathBuf; use sxd_document::{parser, Package}; use sxd_xpath::{Context, Factory, Value}; pub struct MavenDep...
code_fim
hard
{ "lang": "rust", "repo": "chalme/coco", "path": "/psa/src/jvm/maven_dependency.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl MavenDependencyAnalyzer {} impl DependencyAnalyzer for MavenDependencyAnalyzer { fn is_build_file(&self, file: &str) -> bool { match file { "pom.xml" => true, _ => false, } } fn analysis_dependencies(&self, module_path: &str, _build_file: &str) ->...
code_fim
hard
{ "lang": "rust", "repo": "chalme/coco", "path": "/psa/src/jvm/maven_dependency.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wspeirs/rs-libhackrf path: /build.rs extern crate bindgen; use std::env; use std::path::PathBuf; fn main() { // Tell cargo to tell rustc to link libhackrf println!("cargo:rustc-link-lib=hackrf"); <|fim_suffix|> // Write the bindings to the $OUT_DIR/bindings.rs file. let out_pat...
code_fim
hard
{ "lang": "rust", "repo": "wspeirs/rs-libhackrf", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( exports(CompleteStr("((=>), (++))")), Ok(( CompleteStr(""), ExportSet::SubsetExport(vec![fexp("=>"), fexp("++")]) )) ); } #[test] fn simple_constructors_export() { assert_eq!( e...
code_fim
hard
{ "lang": "rust", "repo": "michaeljones/elm-parser", "path": "/src/ast/statement/export.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michaeljones/elm-parser path: /src/ast/statement/export.rs use ast::helpers::{ function_name, operator, spaces_and_newlines, spaces_or_new_lines_and_indent, up_name, IR, }; use ast::statement::core::ExportSet; use nom::types::CompleteStr; named!(all_export<CompleteStr, ExportSet>, map!(t...
code_fim
hard
{ "lang": "rust", "repo": "michaeljones/elm-parser", "path": "/src/ast/statement/export.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn fexp(name: &str) -> ExportSet { ExportSet::FunctionExport(name.to_string()) } #[test] fn simple_all_export() { assert_eq!( exports(CompleteStr("(..)")), Ok((CompleteStr(""), ExportSet::AllExport)) ); } #[test] fn simple_funct...
code_fim
hard
{ "lang": "rust", "repo": "michaeljones/elm-parser", "path": "/src/ast/statement/export.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok((buf, s)) } } impl TryInto<Signature> for DbusSignature { type Error = DbusParseError; fn try_into(self) -> Result<Signature, Self::Error> { self.0 .chars() .into_iter() .try_fold(Signature::default(), |mut sig, character| { ...
code_fim
medium
{ "lang": "rust", "repo": "OtaK/dbus-parser", "path": "/src/types/basic/signature.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OtaK/dbus-parser path: /src/types/basic/signature.rs use crate::error::DbusParseError; use crate::header::components::MessageEndianness; use crate::signature_type::{Signature, SignatureType}; use crate::DbusType; use nom::bytes::streaming::*; use nom::combinator::map; use nom::combinator::map_r...
code_fim
hard
{ "lang": "rust", "repo": "OtaK/dbus-parser", "path": "/src/types/basic/signature.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.0 .chars() .into_iter() .try_fold(Signature::default(), |mut sig, character| { (*sig).push(SignatureType::try_from(character as u8)?); Ok(sig) }) } }<|fim_prefix|>// repo: OtaK/dbus-parser path: /src/types/ba...
code_fim
hard
{ "lang": "rust", "repo": "OtaK/dbus-parser", "path": "/src/types/basic/signature.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ascent12/compiler path: /src/token.rs #[derive(PartialEq, Eq, Clone, Debug, Hash)] pub enum Token { Ident(String), // Single character terminals Term(char), // Binary Operators And, Or, Equal, NotEqual, LessEqual, GreaterEqual, <|fim_suffix|> // Unary...
code_fim
medium
{ "lang": "rust", "repo": "ascent12/compiler", "path": "/src/token.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Constants Binary{v: String, t: String}, Octal{v: String, t: String}, Decimal{v: String, t: String}, Hexadecimal{v: String, t: String}, Float{v: String, t: String}, StringLiteral(String), // Keywords If, Else, Do, While, For, // Types U8, ...
code_fim
medium
{ "lang": "rust", "repo": "ascent12/compiler", "path": "/src/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Assignment operators AssignPlus, AssignMinus, AssignMultiply, AssignDivide, AssignMod, // Unary operators Increment, Decrement, Arrow, // Constants Binary{v: String, t: String}, Octal{v: String, t: String}, Decimal{v: String, t: String}, Hex...
code_fim
medium
{ "lang": "rust", "repo": "ascent12/compiler", "path": "/src/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl NaturalTime for DateTime<Local> { fn time_difference(&self) -> Duration { let now = Local::now(); return -self.signed_duration_since(now); } } #[test] fn test_time_delta_correct() { let new_date = Utc::now() + Duration::days(10); assert_eq!(new_date.time_delta(), "in ...
code_fim
hard
{ "lang": "rust", "repo": "darayus/PrettyDuration", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darayus/PrettyDuration path: /src/lib.rs extern crate chrono; extern crate time; pub mod split; pub mod pretty; use chrono::prelude::*; use time::Duration; pub use pretty::{pretty_short, pretty_full}; pub trait NaturalTime { fn time_difference(&self) -> Duration; fn time_delta(&self)...
code_fim
hard
{ "lang": "rust", "repo": "darayus/PrettyDuration", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl NaturalTime for DateTime<Utc> { fn time_difference(&self) -> Duration { let now = Utc::now(); return -self.signed_duration_since(now); } } impl NaturalTime for DateTime<Local> { fn time_difference(&self) -> Duration { let now = Local::now(); return -self.s...
code_fim
hard
{ "lang": "rust", "repo": "darayus/PrettyDuration", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamsch0/uni-project-svm path: /src/bin/assembler/parser.rs rc2: usize }, Immediate { op: OpCode, dst: usize, src1: usize, imm: ImmediatePlaceholder<'a> }, Store { op: OpCode, src1: usize, src2: usize, imm: ImmediatePlaceholder<'a> }, Upper { op: OpCode, dst: usize, imm: ImmediatePlac...
code_fim
hard
{ "lang": "rust", "repo": "jamsch0/uni-project-svm", "path": "/src/bin/assembler/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn number_sign() { assert_eq!(super::number_sign(""), Done("", 1)); assert_eq!(super::number_sign("+"), Done("", 1)); assert_eq!(super::number_sign("-"), Done("", -1)); } #[test] fn number_radix() { assert_eq!(super::number_radix(""), Done("", 1...
code_fim
hard
{ "lang": "rust", "repo": "jamsch0/uni-project-svm", "path": "/src/bin/assembler/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn instruction_cl() { assert_eq!(super::instruction_i("r3, r1, 0", C_LOAD), Done("", InstructionPlaceholder::Immediate { op: C_LOAD, dst: 3, src1: 1, imm: ImmediatePlaceholder::Value(0) })); } #[test] fn instruction_cs() { assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "jamsch0/uni-project-svm", "path": "/src/bin/assembler/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn log_init() { CombinedLogger::init(vec![ TermLogger::new(LevelFilter::Warn, Config::default()).unwrap(), WriteLogger::new( LevelFilter::Warn, Config::default(), File::create("my_rust_binary.log").unwrap(), ), ]).unwrap(); }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "miyamoen/toy-petshop", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: miyamoen/toy-petshop path: /src/main.rs mod boundary; mod handlers; mod middleware; mod model; mod my_diesel; mod router; mod schema; extern crate simplelog; #[macro_use] extern crate log; use simplelog::*; use std::fs::File; extern crate dotenv; extern crate futures; extern crate gotham; #[ma...
code_fim
medium
{ "lang": "rust", "repo": "miyamoen/toy-petshop", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.sr().test_bsy() } } impl FlashErase for FlashPeriph { fn erase_begin(&self) { self.flash_unlock(); } fn erase_start(&self, addr: *mut u8) -> Result<(), FlashError> { // ignore length for now let addr = addr as u32; let pnb = if addr & 0x7ff ==...
code_fim
hard
{ "lang": "rust", "repo": "bobbin-rs/bobbin-sdk", "path": "/mcu/bobbin-stm32/stm32l432x/src/ext/flash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu/bobbin-stm32/stm32l432x/src/ext/flash.rs use flash::FlashPeriph; use bobbin_hal::flash::*; pub const KEY1: u32 = 0x45670123; pub const KEY2: u32 = 0xCDEF89AB; pub trait FlashLockUnlock { fn flash_locked(&self) -> bool; fn flash_unlock(&self); fn flas...
code_fim
hard
{ "lang": "rust", "repo": "bobbin-rs/bobbin-sdk", "path": "/mcu/bobbin-stm32/stm32l432x/src/ext/flash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let len = src.len(); if len % 8 != 0 { return Err(FlashError::InvalidWriteSize) } let mut i = 0; while i < len { unsafe { let s = src.as_ptr().offset(i as isize) as *const u32; let d = dst.offset(i as isize) as...
code_fim
hard
{ "lang": "rust", "repo": "bobbin-rs/bobbin-sdk", "path": "/mcu/bobbin-stm32/stm32l432x/src/ext/flash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> *self = ColorTransform { r_mult: self.r_mult * rhs.r_mult, g_mult: self.g_mult * rhs.g_mult, b_mult: self.b_mult * rhs.b_mult, a_mult: self.a_mult * rhs.a_mult, r_add: self.r_mult * rhs.r_add + self.r_add, g_add: self.g_mult ...
code_fim
hard
{ "lang": "rust", "repo": "acidburn0zzz/ruffle", "path": "/core/src/color_transform.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: acidburn0zzz/ruffle path: /core/src/color_transform.rs #[derive(Copy, Clone, Debug, PartialEq)] pub struct ColorTransform { pub r_mult: f32, pub g_mult: f32, pub b_mult: f32, pub a_mult: f32, pub r_add: f32, pub g_add: f32, pub b_add: f32, pub a_add: f32, } impl ...
code_fim
hard
{ "lang": "rust", "repo": "acidburn0zzz/ruffle", "path": "/core/src/color_transform.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iotaledger/bee path: /bee-storage/bee-storage-test/src/milestone_index_to_output_diff.rs // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use bee_block::{payload::milestone::MilestoneIndex, rand::milestone::rand_milestone_index}; use bee_ledger_types::{rand::output_di...
code_fim
hard
{ "lang": "rust", "repo": "iotaledger/bee", "path": "/bee-storage/bee-storage-test/src/milestone_index_to_output_diff.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..10 { let (index, output_diff) = (rand_milestone_index(), rand_output_diff()); Batch::<MilestoneIndex, OutputDiff>::batch_insert(storage, &mut batch, &index, &output_diff).unwrap(); indexes.push(index); output_diffs.push((index, Some(output_diff))); } ...
code_fim
hard
{ "lang": "rust", "repo": "iotaledger/bee", "path": "/bee-storage/bee-storage-test/src/milestone_index_to_output_diff.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for result in iter { let (index, output_diff) = result.unwrap(); assert!(output_diffs.contains(&(index, Some(output_diff)))); count += 1; } assert_eq!(count, 10); let results = MultiFetch::<MilestoneIndex, OutputDiff>::multi_fetch(storage, &indexes) .unwra...
code_fim
hard
{ "lang": "rust", "repo": "iotaledger/bee", "path": "/bee-storage/bee-storage-test/src/milestone_index_to_output_diff.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aloso/parkour path: /src/help.rs //! This module provides functionality for automatically generated help //! messages. use std::fmt; use std::iter::FusedIterator; /// This struct defines the possible values of a type representing a _value_. /// See the [`crate::FromInputValue`] trait for more ...
code_fim
hard
{ "lang": "rust", "repo": "Aloso/parkour", "path": "/src/help.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use PossibleValues::*; let values = OneOf(vec![ OneOf(vec![String("A".into())]), OneOf(vec![OneOf(vec![String("B".into())])]), OneOf(vec![OneOf(vec![String("C".into()), String("D".into())])]), OneOf(vec![OneOf(vec![String("E".into()), OneOf(vec![String("F".into())]...
code_fim
hard
{ "lang": "rust", "repo": "Aloso/parkour", "path": "/src/help.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PRDeltoid/recurring-api path: /src/chore.rs use diesel; use diesel::prelude::*; use schema::{chores, chore_entries}; use db::Connection; use chore_entry::ChoreEntry; #[table_name="chores"] #[derive(Identifiable, Serialize, Deserialize, Queryable, Insertable, AsChangeset)] pub struct Chore { ...
code_fim
hard
{ "lang": "rust", "repo": "PRDeltoid/recurring-api", "path": "/src/chore.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update(id: i32, chore: Chore, connection: &Connection) -> bool { diesel::update(chores::table.find(id)).set(&chore).execute(&(**connection)).is_ok() } pub fn delete(id: i32, connection: &Connection) -> bool { diesel::delete(chores::table.find(id)).execute(&(**connection...
code_fim
hard
{ "lang": "rust", "repo": "PRDeltoid/recurring-api", "path": "/src/chore.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] async fn _fortunes(pool: &DieselPool) -> Result<Bytes, Box<dyn Error + Send + Sync + 'static>> { use sailfish::TemplateOnce; let fortunes = pool.tell_fortune().await?.render_once()?; Ok(fortunes.into()) } fn plain_text<D>(req: &mut WebRequest<'_, D>) -> HandleResult { let mut re...
code_fim
hard
{ "lang": "rust", "repo": "trustin/FrameworkBenchmarks", "path": "/frameworks/Rust/xitca-web/src/main_diesel.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> Ok(res) } #[inline(always)] fn json<D>(req: &mut WebRequest<'_, AppState<D>>) -> HandleResult { _json(req, &Message::new()) } #[inline] fn _json<S, D>(req: &mut WebRequest<'_, AppState<D>>, value: &S) -> HandleResult where S: ?Sized + Serialize, { let mut writer = req.state().writer(); ...
code_fim
hard
{ "lang": "rust", "repo": "trustin/FrameworkBenchmarks", "path": "/frameworks/Rust/xitca-web/src/main_diesel.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trustin/FrameworkBenchmarks path: /frameworks/Rust/xitca-web/src/main_diesel.rs #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; #[macro_use] extern crate diesel; mod db_diesel; mod schema; mod ser; mod util; use std::{convert::Infallible, error::Error, io}; use se...
code_fim
hard
{ "lang": "rust", "repo": "trustin/FrameworkBenchmarks", "path": "/frameworks/Rust/xitca-web/src/main_diesel.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twh2898/rs_ant path: /src/support/vertex.rs #[derive(Copy, Clone)] pub struct Vertex { position: [f32; 2], color: [f32; 3], } implement_vertex!(Vertex, position, color); impl Vertex { pub fn new() -> Self { Vertex { position: [0.0, 0.0], color: [0.0,...
code_fim
hard
{ "lang": "rust", "repo": "twh2898/rs_ant", "path": "/src/support/vertex.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_points(x: f32, y: f32) -> Self { Vertex { position: [x, y], color: [1., 1., 1.], } } pub fn with_position(mut self, x: f32, y: f32) -> Self { self.position = [x, y]; self } pub fn with_color(mut self, r: f32, g: f32,...
code_fim
hard
{ "lang": "rust", "repo": "twh2898/rs_ant", "path": "/src/support/vertex.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }