text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>#[derive(Debug, serde::Deserialize)] pub struct TimelineEntry { #[serde(rename = "entryId")] pub entry_id: String, }<|fim_prefix|>// repo: adumbidiot/quarky path: /lib/twitter-scraper/src/model/get_user_tweets.rs use super::{ ResultField, UserField, }; pub type GetUserTweetsResponse = Us...
code_fim
medium
{ "lang": "rust", "repo": "adumbidiot/quarky", "path": "/lib/twitter-scraper/src/model/get_user_tweets.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Database<'a> { pub fn new(client: &Discography) -> Database { Database { client: client } } pub fn labels(&self) -> LabelsEndpoint { LabelsEndpoint::new(self.client) } pub fn artists(&self) -> ArtistsEndpoint { ArtistsEndpoint::new(self.client) } ...
code_fim
medium
{ "lang": "rust", "repo": "RustRome/discography", "path": "/src/database/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustRome/discography path: /src/database/mod.rs //! Database API //! //! https://www.discogs.com/developers/#page:database //! use ::discography::Discography; <|fim_suffix|>pub struct Database<'a> { client: &'a Discography, } impl<'a> Database<'a> { pub fn new(client: &Discography) ->...
code_fim
medium
{ "lang": "rust", "repo": "RustRome/discography", "path": "/src/database/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whitf/cavegen path: /src/episu/mod.rs //use rand::{Rand, Rng}; use rand_derive::Rand; use uuid::Uuid; pub mod cave; #[derive(Debug)] pub enum Style { Cave, Dessert, Dungeon, Grasslands, Hills, Forest, ForestHeavy, ForestSparse, Marsh, Mountain, Tundra, Village, } #[derive(Clone, C...
code_fim
hard
{ "lang": "rust", "repo": "whitf/cavegen", "path": "/src/episu/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn generate(&mut self, style: Style, start: Point) -> Vec<u8> { //let mut grid: Vec<u8> = Vec::with_capacity(cap_x * cap_y); match style { Style::Cave => { return cave::generate(self, start, self.cap_x, self.cap_y); }, _ => {} } return Vec::new(); } pub fn is_legal(&mut sel...
code_fim
hard
{ "lang": "rust", "repo": "whitf/cavegen", "path": "/src/episu/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn move_to(&mut self, x: usize, y: usize, dir: Direction) -> (usize, usize) { if self.is_legal(x, y, dir) { match dir { Direction::North => return (x, y - 1), Direction::East => return (x + 1, y), Direction::South => return (x, y + 1), Direction::West => return (x - 1, y), } ...
code_fim
hard
{ "lang": "rust", "repo": "whitf/cavegen", "path": "/src/episu/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xasmx/rust-la path: /src/internalutil.rs use std::vec; use num; use num::{Float, Signed, One, Zero}; #[inline] pub fn alloc_dirty_vec<T : Copy>(n : usize) -> Vec<T> { let mut v : Vec<T> = vec::Vec::with_capacity(n); unsafe { v.set_len(n); } v } // Ported from JAMA. // sqrt(a^2 + b...
code_fim
medium
{ "lang": "rust", "repo": "xasmx/rust-la", "path": "/src/internalutil.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(hypot(3.0, 4.0) == 5.0); assert!(hypot(4.0, 3.0) == 5.0); assert!(hypot(4.0, 0.0) == 4.0); assert!(hypot(0.0, 4.0) == 4.0); assert!(hypot(-3.0, 4.0) == 5.0); assert!(hypot(4.0, -3.0) == 5.0); assert!(hypot(-4.0, -3.0) == 5.0); assert!(hypot(-4.0, 0.0) == 4.0); assert!(hypot(0.0, ...
code_fim
hard
{ "lang": "rust", "repo": "xasmx/rust-la", "path": "/src/internalutil.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let served_repository = repo .server() .response_overrider(for_not_range_requests(get_responder)) .response_overrider(for_range_requests(ContentRangeCorruptor)) .start() .unwrap(); let env = TestEnvBuilder::new().build().await; env.register_repo(&served...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/pkg/tests/pkg-resolver/src/resolve_resumes_blob_gets.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/pkg/tests/pkg-resolver/src/resolve_resumes_blob_gets.rs // Copyright 2021 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 { cobalt_sw_delivery_registry as me...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/pkg/tests/pkg-resolver/src/resolve_resumes_blob_gets.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if self.exlude_labels.is_empty() && self.include_labels.is_empty() { return true; } if let Some(entry_labels) = self.source.entry_labels(entry_id) { if self .exlude_labels .iter() .any(|lbl| entry_labels.conta...
code_fim
hard
{ "lang": "rust", "repo": "JesperAxelsson/SeriousOrganizerLib", "path": "/src/lens.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> trace!( "set_entry_labels update with {:?} entries took: {:?} ms", count, start.elapsed().whole_milliseconds() ); self.update_ix_list(); } pub fn remove_entry_labels(&mut self, entries: Vec<u32>, labels: Vec<u32>) { let start = ...
code_fim
hard
{ "lang": "rust", "repo": "JesperAxelsson/SeriousOrganizerLib", "path": "/src/lens.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JesperAxelsson/SeriousOrganizerLib path: /src/lens.rs #![allow(unused_imports)] use anyhow::Context; // mod filter; // extern crate intmap; use anyhow::{bail, Result}; use log::{debug, error, info, trace, warn}; use regex::{escape, Regex, RegexBuilder}; use time::Instant; use std::collections:...
code_fim
hard
{ "lang": "rust", "repo": "JesperAxelsson/SeriousOrganizerLib", "path": "/src/lens.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn rec(info: Loc, labels: Vec<LabExpr>, rest: Option<Self>) -> Self { Self::row_polymorphic_type(info, labels, VarRec::Record, rest) } pub fn tup(first: Self, rest: Vec<Self>) -> Self { Expr::Tup(Box::new(Vec1::new(first, rest))) } pub fn sig(params: Vec<Param>, e...
code_fim
hard
{ "lang": "rust", "repo": "clpi/voile-rs", "path": "/src/syntax/surf/ast.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn row_polymorphic_type( info: Loc, labels: Vec<LabExpr>, kind: VarRec, rest: Option<Self>, ) -> Self { Expr::RowPoly(info, kind, labels, rest.map(Box::new)) } pub fn record(info: Loc, fields: Vec<LabExpr>, rest: Option<Self>) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "clpi/voile-rs", "path": "/src/syntax/surf/ast.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clpi/voile-rs path: /src/syntax/surf/ast.rs use voile_util::level::{Level, LevelType}; use voile_util::loc::{Ident, Labelled, Loc}; use voile_util::tags::{Plicit, VarRec}; use voile_util::vec1::Vec1; pub type LabExpr = Labelled<Expr>; /// Surface syntax tree node: Parameter. /// /// It's a par...
code_fim
hard
{ "lang": "rust", "repo": "clpi/voile-rs", "path": "/src/syntax/surf/ast.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use { super::*, solana_runtime::genesis_utils::{ bootstrap_validator_stake_lamports, create_genesis_config_with_leader, }, }; #[test] fn test_leader_schedule_via_bank() { let pubkey = solana_sdk::pubkey::new_rand(); ...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/ledger/src/leader_schedule_utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solana-labs/solana path: /ledger/src/leader_schedule_utils.rs use { crate::leader_schedule::LeaderSchedule, solana_runtime::bank::Bank, solana_sdk::{ clock::{Epoch, Slot, NUM_CONSECUTIVE_LEADER_SLOTS}, pubkey::Pubkey, }, std::collections::HashMap, }; /// Retu...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/ledger/src/leader_schedule_utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let pubkey = solana_sdk::pubkey::new_rand(); let genesis_config = create_genesis_config_with_leader(42, &pubkey, bootstrap_validator_stake_lamports()) .genesis_config; let bank = Bank::new_for_tests(&genesis_config); assert_eq!(slot_leader_at(ban...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/ledger/src/leader_schedule_utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let sum = digits.iter().rev().enumerate().fold(0, |acc, (i, c)| { let mut d = c.to_digit(10).unwrap(); if i % 2 != 0 { d *= 2; if d > 9 { d -= 9; } } acc + d }); sum...
code_fim
hard
{ "lang": "rust", "repo": "jakm/exercism-rust", "path": "/luhn-from/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakm/exercism-rust path: /luhn-from/src/lib.rs pub struct Luhn { code: String, } impl Luhn { /// Check a Luhn checksum. pub fn is_valid(&self) -> bool { if self.code.len() != self .code .matches(|c| char::is_digit(c, 10) || c == ' ...
code_fim
hard
{ "lang": "rust", "repo": "jakm/exercism-rust", "path": "/luhn-from/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ifletsomeclaire/image_processor path: /edge_detector/src/lib.rs use crop::crop_by_edge_detection; use edge::{detect_edges, save_detection}; use std::path::Path; <|fim_suffix|>pub fn edge_crop<P: AsRef<Path>>(path: P) { let detection = detect_edges(&path); save_detection("x_output/edgy.p...
code_fim
easy
{ "lang": "rust", "repo": "ifletsomeclaire/image_processor", "path": "/edge_detector/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn edge_crop<P: AsRef<Path>>(path: P) { let detection = detect_edges(&path); save_detection("x_output/edgy.png", &detection); let images = crop_by_edge_detection( raster::open(path.as_ref().to_str().expect("path to str")).unwrap(), detection, ); editor_utils::image_...
code_fim
easy
{ "lang": "rust", "repo": "ifletsomeclaire/image_processor", "path": "/edge_detector/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> messages .iter() .filter(|message| message.validate(rules)) .count() } fn part2(rules: &Rules, messages: &[Message]) -> usize { let mut modified_rules = rules.clone(); if let Some(rule) = modified_rules.rules.get_mut(&8) { *rule = Rule::OR((vec![42], vec![42, 8...
code_fim
hard
{ "lang": "rust", "repo": "LesnyRumcajs/advent-of-rust-2020", "path": "/src/bin/day19.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LesnyRumcajs/advent-of-rust-2020 path: /src/bin/day19.rs use lazy_static::lazy_static; use regex::Regex; use std::{ collections::HashMap, io::{self, BufRead}, }; #[derive(Clone)] enum Rule { CHAR(char), SINGLE(Vec<u32>), OR((Vec<u32>, Vec<u32>)), } #[derive(Default, Clone)]...
code_fim
hard
{ "lang": "rust", "repo": "LesnyRumcajs/advent-of-rust-2020", "path": "/src/bin/day19.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tari/audiostream.rs path: /src/cpu.rs use std::str::FromStr; use std::env; pub use self::innards::Feature; #[cfg(target_arch = "x86_64")] pub use self::innards::Feature::{Baseline, MMX, SSE, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2}; #[cfg(target_arch = "arm"...
code_fim
hard
{ "lang": "rust", "repo": "tari/audiostream.rs", "path": "/src/cpu.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(target_arch = "x86_64")] mod innards { use self::Feature::*; use std::str::FromStr; #[derive(PartialEq, Eq, Debug, Clone, Copy)] pub enum Feature { Baseline, MMX, SSE, SSE2, SSE3, SSSE3, SSE41, SSE42, OSXSAVE, ...
code_fim
hard
{ "lang": "rust", "repo": "tari/audiostream.rs", "path": "/src/cpu.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> fn do_xgetbv(ecx: u32) -> u64 { let high: u32; let low: u32; unsafe { asm!{ "xgetbv" : "={edx}"(high), "={eax}"(low) : "{ecx}"(ecx) } } ((high as u64) << 32) | low as u64 } } #[cfg(ta...
code_fim
hard
{ "lang": "rust", "repo": "tari/audiostream.rs", "path": "/src/cpu.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> *self = I32x4_41(unsafe { _mm_xor_si128(self.0, rhs.0) }) } } impl BitXorAssign for I32x8 { #[inline(always)] fn bitxor_assign(&mut self, rhs: I32x8) { *self = I32x8(unsafe { _mm256_xor_si256(self.0, rhs.0) }) } } impl BitXorAssign for I64x2 { #[inline(always)] fn b...
code_fim
hard
{ "lang": "rust", "repo": "fasterthanlime/simdeez", "path": "/src/overloads/xor_assign.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fasterthanlime/simdeez path: /src/overloads/xor_assign.rs use super::*; // -- BitXorAssign impl BitXorAssign for I16x1 { #[inline(always)] fn bitxor_assign(&mut self, rhs: I16x1) { *self = I16x1(self.0 ^ rhs.0); } } impl BitXorAssign for I32x1 { #[inline(always)] fn...
code_fim
hard
{ "lang": "rust", "repo": "fasterthanlime/simdeez", "path": "/src/overloads/xor_assign.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> *self = I64x2(unsafe { _mm_xor_si128(self.0, rhs.0) }) } } impl BitXorAssign for I64x2_41 { #[inline(always)] fn bitxor_assign(&mut self, rhs: I64x2_41) { *self = I64x2_41(unsafe { _mm_xor_si128(self.0, rhs.0) }) } } impl BitXorAssign for I64x4 { #[inline(always)] f...
code_fim
hard
{ "lang": "rust", "repo": "fasterthanlime/simdeez", "path": "/src/overloads/xor_assign.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> drink_test(Gender::Male, 0.5, 64.0, 0.033); } #[test] fn female_45_kg() { drink_test(Gender::Female, 0.5, 45.0, 0.056); } #[test] fn female_55_kg() { drink_test(Gender::Female, 0.5, 55.0, 0.046); } #[test] fn female_64_kg() { drink_test(Gender::Female, 0.5, 64.0, 0.04); }<|fim_prefix|>// ...
code_fim
hard
{ "lang": "rust", "repo": "aburd/bac_measurer", "path": "/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> drink_test(Gender::Female, 0.5, 45.0, 0.056); } #[test] fn female_55_kg() { drink_test(Gender::Female, 0.5, 55.0, 0.046); } #[test] fn female_64_kg() { drink_test(Gender::Female, 0.5, 64.0, 0.04); }<|fim_prefix|>// repo: aburd/bac_measurer path: /tests/tests.rs use bac_journal::drink::Drink; ...
code_fim
medium
{ "lang": "rust", "repo": "aburd/bac_measurer", "path": "/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aburd/bac_measurer path: /tests/tests.rs use bac_journal::drink::Drink; use bac_journal::{ person::{Gender, Person}, BAC, }; use measurements::mass::Mass; fn is_close(val: f64, estimate: f64, sig_fig: u64) { let sf: f64 = sig_fig as f64; let val_trunc = (val * (sf * 100.0)).roun...
code_fim
hard
{ "lang": "rust", "repo": "aburd/bac_measurer", "path": "/tests/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> struct NewUser<'a> { name: &'a String, hair_color: Option<&'a String>, } impl_Insertable! { (users) struct NewUser<'a> { name: &'a String, hair_color: Option<&'a String>, } } ...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/diesel", "path": "/diesel/src/macros/insertable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaneutt/diesel path: /diesel/src/macros/insertable.rs #[macro_export] #[doc(hidden)] macro_rules! impl_Insertable { // Strip meta items, pub (if present) and struct from definition ( ($table_name:ident) $(#[$ignore:meta])* $(pub)* struct $($body:tt)* ) => { ...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/diesel", "path": "/diesel/src/macros/insertable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let conn = ::test_helpers::connection(); conn.execute("DROP TABLE IF EXISTS users").unwrap(); conn.execute("CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR NOT NULL, hair_color VARCHAR DEFAULT 'Green')").unwrap(); conn } ...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/diesel", "path": "/diesel/src/macros/insertable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mkulagowski/rustAOCean2020 path: /src/days/day06.rs use crate::common::Solution; use std::collections::HashSet; // P1: 1000-1100us fn _count_chars2(txt: &Vec<String>) -> usize { txt.iter() .flat_map(String::as_bytes) .collect::<HashSet<_>>() .len() } // P2: 2600-300...
code_fim
hard
{ "lang": "rust", "repo": "mkulagowski/rustAOCean2020", "path": "/src/days/day06.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// INPUT NEEDS TO BE PREFORMATTED -> 1 GROUP PER LINE, PEOPLE SEPARATED BY SPACES! type InputType = Vec<Vec<String>>; fn parse_input(raw_input: &[String]) -> InputType { raw_input .iter() .map(|x| x.split_whitespace().map(|s| s.to_string()).collect()) .collect() } pub fn solve...
code_fim
hard
{ "lang": "rust", "repo": "mkulagowski/rustAOCean2020", "path": "/src/days/day06.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let session_id = self.session_id.read().await.as_ref().cloned(); let seq = *self.seq.read().await; if let (Some(session_id), Some(seq)) = (session_id, seq) { if let Err(e) = Arc::clone(&self).do_resume(session_id.clone(), seq).await { ...
code_fim
hard
{ "lang": "rust", "repo": "BEDSpEedTEST/tickets.rs", "path": "/sharder/src/gateway/shard.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BEDSpEedTEST/tickets.rs path: /sharder/src/gateway/shard.rs Should we reconnect? Err(e) => { *total_rx = 0; decoder.reset(true); return Err(e); } }; } *total_rx = decoder.to...
code_fim
hard
{ "lang": "rust", "repo": "BEDSpEedTEST/tickets.rs", "path": "/sharder/src/gateway/shard.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BEDSpEedTEST/tickets.rs path: /sharder/src/gateway/shard.rs >, ) -> Arc<Shard<T>> { let (kill_shard_tx, kill_shard_rx) = oneshot::channel(); let (status_update_tx, status_update_rx) = mpsc::channel(1); Arc::new(Shard { config, identify, ...
code_fim
hard
{ "lang": "rust", "repo": "BEDSpEedTEST/tickets.rs", "path": "/sharder/src/gateway/shard.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lokathor/wide path: /src/u8x16_.rs use super::*; pick! { if #[cfg(target_feature="sse2")] { #[derive(Default, Clone, Copy, PartialEq, Eq)] #[repr(C, align(16))] pub struct u8x16 { pub(crate) sse: m128i } } else if #[cfg(target_feature="simd128")] { use core::arch::wasm32::*;...
code_fim
hard
{ "lang": "rust", "repo": "Lokathor/wide", "path": "/src/u8x16_.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|>impl BitOr for u8x16 { type Output = Self; #[inline] #[must_use] fn bitor(self, rhs: Self) -> Self::Output { pick! { if #[cfg(target_feature="sse2")] { Self { sse: bitor_m128i(self.sse, rhs.sse) } } else if #[cfg(target_feature="simd128")] { Self { simd: v128_or(sel...
code_fim
hard
{ "lang": "rust", "repo": "Lokathor/wide", "path": "/src/u8x16_.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> pick! { if #[cfg(target_feature="sse2")] { Self { sse: sub_i8_m128i(self.sse, rhs.sse) } } else if #[cfg(target_feature="simd128")] { Self { simd: u8x16_sub(self.simd, rhs.simd) } } else if #[cfg(all(target_feature="neon",target_arch="aarch64"))]{ unsafe {Self...
code_fim
hard
{ "lang": "rust", "repo": "Lokathor/wide", "path": "/src/u8x16_.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> // Now for some (potential) deadlock! let mutex_one = Arc::new(Mutex::new(42)); let mutex_two = Arc::new(Mutex::new(1)); let mut threads: Vec<JoinHandle<()>> = vec![]; for i in 0..2 { let m_one = mutex_one.clone(); let m_two = mutex_two.clone(); threads.push(th...
code_fim
hard
{ "lang": "rust", "repo": "42yeah/rust-book-impls", "path": "/concurrency/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 42yeah/rust-book-impls path: /concurrency/src/main.rs use std::{sync::{Arc, Mutex}, thread::{self, JoinHandle}, time::Duration}; fn main() { let mutex = Arc::new(Mutex::new(1)); let mut threads: Vec<JoinHandle<()>> = vec![]; for i in 0..10 { let mutex = mutex.clone(); ...
code_fim
hard
{ "lang": "rust", "repo": "42yeah/rust-book-impls", "path": "/concurrency/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if result > 90 { println!("Test grade is a++"); } else if result > 80 && result <= 90 { println!("Test is grade is a+"); } else if result > 70 && result <= 80 { println!("Test is grade is a"); } else if result ...
code_fim
hard
{ "lang": "rust", "repo": "faisalrwp/MyRustClass", "path": "/20191027/userinput/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: faisalrwp/MyRustClass path: /20191027/userinput/src/main.rs use std::io; fn main() { let mut input1 = String::new(); loop { input1 = "".to_string(); println!("Enter Your Numbers :"); io::stdin() .read_line(&mut input1) .expect("Failed In ...
code_fim
hard
{ "lang": "rust", "repo": "faisalrwp/MyRustClass", "path": "/20191027/userinput/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sbnair/mips-parser-2 path: /src/mem/page.rs use std::vec::Vec; pub const PAGE_SIZE: usize = 4096; pub type Page = [u8; PAGE_SIZE]; pub trait Memory { /// Returns new zeroed slice of memory fn new() -> Self; /// Zeroes out the memory region fn zero(&mut self); /// Access ...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/mips-parser-2", "path": "/src/mem/page.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn word_test() { let page = &mut Page::new(); *page.word_mut(0) = (0xfffefdfc as u32).to_le_bytes(); assert_eq!(*page.byte(0), 0xfc); assert_eq!(*page.byte(1), 0xfd); assert_eq!(*page.byte(2), 0xfe); assert_eq!(*page.byte(3), 0xff); ...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/mips-parser-2", "path": "/src/mem/page.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/hyperlink path: /src/main.rs (base_path) => base_path, None => { // Invalid invocation. Ultra hack to show help if no arguments are provided. Structopt // does not seem to have a functional way to require either an argument or a // subcommand. ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/hyperlink", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if broken_link.hard_404 { bad_links } else { bad_anchors } .insert((Some(*lineno), broken_link.link.href.clone())); } } } if !had_sou...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/hyperlink", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/hyperlink path: /src/main.rs sources_path, }) => { return match_all_paragraphs(base_path, sources_path); } None => {} } let base_path = match base_path { Some(base_path) => base_path, None => { // Invalid invoc...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/hyperlink", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ThomasdenH/rust-openttd-admin path: /src/packet/admin/test/mod.rs use super::server_packets; use crate::packet::serde::from_bytes; #[test] fn test_company_economy_deser() { let buffer = &vec![ 0, 58, 133, 1, 0, 0, 0, 0, 0, 160, 134, 1, 0, 0, 0, 0, 0, 154<|fim_suffix|> money: 9964...
code_fim
hard
{ "lang": "rust", "repo": "ThomasdenH/rust-openttd-admin", "path": "/src/packet/admin/test/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> money: 99642, loan: 100000, income: -358, delivered_cargo: 0, company_value_last: 0, performance_last: 0, delivered_cargo_last: 0, company_value_previous: 0, performance_previous: 0, delivered_previous: 0, }; assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "ThomasdenH/rust-openttd-admin", "path": "/src/packet/admin/test/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match verifier.update(&val){ Ok(_)=>{}, Err(_)=>{ return Err(Error!("failed-load-verifier")); } } match verifier.verify(&sig){ Ok(v)=>{ if v{ return Ok(()); } else { return Err(Error!("invalid-...
code_fim
hard
{ "lang": "rust", "repo": "gzbakku/gzbdb", "path": "/gmessage/src/crypt/sign.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gzbakku/gzbdb path: /gmessage/src/crypt/sign.rs use crate::Error; use crate::common::Error; use openssl::pkey::{Private,Public}; use openssl::pkey::PKey; use openssl::sign::{Signer, Verifier}; use openssl::hash::MessageDigest; pub fn sign(val:Vec<u8>,rsa_key:&PKey<Private>) -> Result<Vec<u8>...
code_fim
hard
{ "lang": "rust", "repo": "gzbakku/gzbdb", "path": "/gmessage/src/crypt/sign.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub fn verify(val:Vec<u8>,rsa_key:&PKey<Public>,sig:Vec<u8>) -> Result<(),Error>{ let mut verifier:Verifier; match Verifier::new(MessageDigest::sha256(), &rsa_key){ Ok(v)=>{verifier = v;}, Err(_)=>{ return Err(Error!("failed-make-verifier")); } } ma...
code_fim
hard
{ "lang": "rust", "repo": "gzbakku/gzbdb", "path": "/gmessage/src/crypt/sign.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn proportion_of(value: u64, x: u64, y: u64) -> u64 { (value as u128 * x as u128 / y as u128) as u64 }<|fim_prefix|>// repo: ellipticoin/moonshined path: /ellipticoin_contracts/src/helpers.rs pub fn pad_left(value: Vec<u8>, padding_size: usize) -> Vec<u8> { let mut new_vec = vec![0; padding_s...
code_fim
medium
{ "lang": "rust", "repo": "ellipticoin/moonshined", "path": "/ellipticoin_contracts/src/helpers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ellipticoin/moonshined path: /ellipticoin_contracts/src/helpers.rs pub fn pad_left(value: Vec<u8>, padding_size: usize) -> Vec<u8> { let mut new_vec = vec![0; padding_size - value.len()]; <|fim_suffix|>pub fn proportion_of(value: u64, x: u64, y: u64) -> u64 { (value as u128 * x as u128 ...
code_fim
medium
{ "lang": "rust", "repo": "ellipticoin/moonshined", "path": "/ellipticoin_contracts/src/helpers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h563/rcc/apb3lpenr.rs #[doc = "Register `APB3LPENR` reader"] pub type R = crate::R<APB3LPENR_SPEC>; #[doc = "Register `APB3LPENR` writer"] pub type W = crate::W<APB3LPENR_SPEC>; #[doc = "Field `SBSLPEN` reader - SBS clock enable during sleep mo...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h563/rcc/apb3lpenr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> LPTIM1LPEN_W::new(self) } #[doc = "Bit 12 - LPTIM3 clock enable during sleep mode Set and reset by software."] #[inline(always)] #[must_use] pub fn lptim3lpen(&mut self) -> LPTIM3LPEN_W<APB3LPENR_SPEC, 12> { LPTIM3LPEN_W::new(self) } #[doc = "Bit 13 - LPTIM4 clock ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h563/rcc/apb3lpenr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmvict/wTools path: /rust/impl/typing/mod.rs // pub use is_slice::*; // // pub use instance_of::*; // #[cfg( feature = "inspect_type" )] // pub use inspect_type::*; <|fim_suffix|>#[ cfg( feature = "typing_tools" ) ] pub use typing_tools::*;<|fim_middle|>// pub use inspect_type::*; // pub use is...
code_fim
medium
{ "lang": "rust", "repo": "dmvict/wTools", "path": "/rust/impl/typing/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[ cfg( feature = "typing_tools" ) ] pub use typing_tools::*;<|fim_prefix|>// repo: dmvict/wTools path: /rust/impl/typing/mod.rs // pub use is_slice::*; // // pub use instance_of::*; // #[cfg( feature = "inspect_type" )] // pub use inspect_type::*; <|fim_middle|>// pub use inspect_type::*; // pub use is...
code_fim
medium
{ "lang": "rust", "repo": "dmvict/wTools", "path": "/rust/impl/typing/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut rem = pass; let mut has_adjacent_2 = false; let mut current_run = 1; let mut prev_digit = 10; while rem > 0 { let last = rem % 10; if last > prev_digit { return false; } if last == prev_digit { current_run += 1; } ...
code_fim
medium
{ "lang": "rust", "repo": "jcdavis/aoc2019", "path": "/day4/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn is_valid(pass: i32) -> bool { let mut rem = pass; let mut has_adjacent_2 = false; let mut current_run = 1; let mut prev_digit = 10; while rem > 0 { let last = rem % 10; if last > prev_digit { return false; } if last == prev_digit { ...
code_fim
medium
{ "lang": "rust", "repo": "jcdavis/aoc2019", "path": "/day4/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcdavis/aoc2019 path: /day4/src/main.rs use std::env; fn main() { let args: Vec<String> = env::args().collect(); let start: i32 = args.get(1).and_then(|x| x.parse().ok()).expect("provide start"); let end: i32 = args.get(2).and_then(|x| x.parse().ok()).expect("provide end"); let ...
code_fim
medium
{ "lang": "rust", "repo": "jcdavis/aoc2019", "path": "/day4/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sathishvinayk/rust_360 path: /advanced traits/copy_trait.rs #[derive(Debug)] struct X { a: i32 } impl Copy for X { } <|fim_suffix|> *self } } fn main() { let x = X { a: 3 }; let y = x; println!("x and y value: {:?} {:?}", x, y); }<|fim_middle|>impl Clo...
code_fim
easy
{ "lang": "rust", "repo": "sathishvinayk/rust_360", "path": "/advanced traits/copy_trait.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("x and y value: {:?} {:?}", x, y); }<|fim_prefix|>// repo: sathishvinayk/rust_360 path: /advanced traits/copy_trait.rs #[derive(Debug)] struct X { a: i32 } impl Copy for X { } impl Clone for X { fn clone(&self) -> Self { *self } } <|fim_middle|>fn main() { let x = ...
code_fim
medium
{ "lang": "rust", "repo": "sathishvinayk/rust_360", "path": "/advanced traits/copy_trait.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: healerkx/code-snippet path: /lang/rust/extract_words/main.rs use std::fs::File; use std::path::Path; use std::collections::hash_map::HashMap; use std::io::BufReader; use std::io::prelude::*; fn read_file_into_vec_char(filename: &str) -> Vec<char> { let file = File::open(Path::new(filename)...
code_fim
medium
{ "lang": "rust", "repo": "healerkx/code-snippet", "path": "/lang/rust/extract_words/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let v = read_file_into_vec_char("foo.txt"); // 单字出现次数统计 let m1 = visit_vec_into_words(&v, 1); println!("{}", m1.len()); // 2字词出现次数统计 let m2 = visit_vec_into_words(&v, 2); for i in m2 { if i.1 > 4 { println!("{}:{}", i.0, i.1); } } // ...
code_fim
hard
{ "lang": "rust", "repo": "healerkx/code-snippet", "path": "/lang/rust/extract_words/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { println!("*ptr = {}", *ptr); } println!("ptr = {:?}", ptr); }<|fim_prefix|>// repo: arch-yzk/Rust path: /ch4/ch4-2/mutrawptr.rs static GLOBAL: i32 = 99; fn main() { let local: i32 = 10; let mut ptr: *const i32 = &local; unsafe { println!("*ptr =...
code_fim
easy
{ "lang": "rust", "repo": "arch-yzk/Rust", "path": "/ch4/ch4-2/mutrawptr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arch-yzk/Rust path: /ch4/ch4-2/mutrawptr.rs static GLOBAL: i32 = 99; fn main() { let local: i32 = 10; let mut ptr: *const i32 = &local; <|fim_suffix|> unsafe { println!("*ptr = {}", *ptr); } println!("ptr = {:?}", ptr); }<|fim_middle|> unsafe { pr...
code_fim
medium
{ "lang": "rust", "repo": "arch-yzk/Rust", "path": "/ch4/ch4-2/mutrawptr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("ptr = {:?}", ptr); }<|fim_prefix|>// repo: arch-yzk/Rust path: /ch4/ch4-2/mutrawptr.rs static GLOBAL: i32 = 99; fn main() { let local: i32 = 10; let mut ptr: *const i32 = &local; unsafe { println!("*ptr = {}", *ptr); } <|fim_middle|> println!("ptr = {:?}", ...
code_fim
medium
{ "lang": "rust", "repo": "arch-yzk/Rust", "path": "/ch4/ch4-2/mutrawptr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_rg() -> RegularGrammar { RegularGrammar { variables: BTreeSet::new(), terminals: BTreeSet::new(), rules: BTreeMap::new(), start_variable: String::new(), } } } mod test { #[test] fn tokens_to_variable() { le...
code_fim
hard
{ "lang": "rust", "repo": "tarberd/formally-cool", "path": "/classy/src/rg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarberd/formally-cool path: /classy/src/rg.rs use formally_cool::regular_languages::RegularGrammar; use std::collections::{BTreeMap, BTreeSet}; use std::io; use std::io::Write; pub struct Rg {} impl Rg { pub fn new() -> Self { Rg {} } fn greatings() { println!("{}"...
code_fim
hard
{ "lang": "rust", "repo": "tarberd/formally-cool", "path": "/classy/src/rg.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for index in 0..tokens.len() { let first_letter = tokens[index].get(0..1).unwrap(); let end = tokens[index].len(); let last_letter = tokens[index].get((end - 1)..end).unwrap(); if open_variable == false { vari...
code_fim
hard
{ "lang": "rust", "repo": "tarberd/formally-cool", "path": "/classy/src/rg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: byrobot-rust/e_drone_rpi path: /examples/display.rs extern crate e_drone_rpi; use chrono::{Timelike, Local}; use e_drone::protocol::display::{*}; use e_drone_rpi::{*}; fn main() { //let mut drone: Drone = Drone::new(); // UART let mut drone: Drone = Drone::new_path("/dev/ttyACM0"); ...
code_fim
hard
{ "lang": "rust", "repo": "byrobot-rust/e_drone_rpi", "path": "/examples/display.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> drone.draw_invert(5, 5, 20, 20); drone.sleep(1000); drone.draw_point(30, 30, Pixel::Black); drone.sleep(1000); drone.draw_line(108, 30, 20, 44, Pixel::Black, Line::Solid); drone.sleep(1000); drone.draw_rect(20, 10, 90, 40, Pixel::Black, true, Line::Solid); drone.sleep(10...
code_fim
medium
{ "lang": "rust", "repo": "byrobot-rust/e_drone_rpi", "path": "/examples/display.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if drone.get_time_passed_from_start() > 20000 { break; } } drone.draw_string(40, 20, Font::LM10x16, Pixel::White, String::from(" BYE ")); drone.sleep(1000); }<|fim_prefix|>// repo: byrobot-rust/e_drone_rpi path: /examples/display.rs extern crate e_drone_rpi; use ...
code_fim
hard
{ "lang": "rust", "repo": "byrobot-rust/e_drone_rpi", "path": "/examples/display.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(QueryCondition::Raw(Box::new(MockQueryPair(true))) .eval(&NULL) .unwrap()); } #[test] fn raw_false() { assert!(!QueryCondition::Raw(Box::new(MockQueryPair(false))) .eval(&NULL) .unwrap()); } #[test] fn not_true...
code_fim
hard
{ "lang": "rust", "repo": "berquerant/jsongrep", "path": "/src/eval/query_condition.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> QueryCondition::And(vec![]).eval(&NULL).unwrap(); } test_and!( and_one, vec![QueryCondition::Raw(Box::new(MockQueryPair(true)))], true ); test_and!( and_one_not, vec![QueryCondition::Raw(Box::new(MockQueryPair(false)))], false ); ...
code_fim
hard
{ "lang": "rust", "repo": "berquerant/jsongrep", "path": "/src/eval/query_condition.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: berquerant/jsongrep path: /src/eval/query_condition.rs use crate::error::{Error, ErrorCode, Result}; use crate::query::{EvaluableQueryCondition, QueryCondition}; use crate::util; use serde_json::value::Value as JSONValue; impl EvaluableQueryCondition for QueryCondition { fn eval(&self, valu...
code_fim
hard
{ "lang": "rust", "repo": "berquerant/jsongrep", "path": "/src/eval/query_condition.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bluss/indexing path: /src/index_error.rs use std::fmt; /// Error produced when an indexing operation is out of bounds or otherwise /// inapplicable. /// /// Carries no context information (to be as light as possible). #[derive(Copy, Debug, PartialEq)] pub struct IndexingError(()); #[inline] pu...
code_fim
medium
{ "lang": "rust", "repo": "bluss/indexing", "path": "/src/index_error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl IndexingError { pub fn description(&self) -> &str { "index error" } } impl fmt::Display for IndexingError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.description()) } }<|fim_prefix|>// repo: bluss/indexing path: /src/index_error.rs use s...
code_fim
medium
{ "lang": "rust", "repo": "bluss/indexing", "path": "/src/index_error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: markubiak/dsp.rs path: /src/filter/biquad.rs /// Basic implementations of common discrete filters use arraydeque::{ArrayDeque, Wrapping}; use itertools::{izip}; use crate::RealBuffer; /// A biquad filter (IIR) #[derive(Clone,Debug)] pub struct BiquadFilter { x: ArrayDeque<[f32; 3], Wrappin...
code_fim
hard
{ "lang": "rust", "repo": "markubiak/dsp.rs", "path": "/src/filter/biquad.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Compute and run the equivalent digital filter. // Bilinear transform of RC filter: // https://en.wikipedia.org/wiki/Bilinear_transform#Example let b = [1.0, 1.0, 0.0]; let a = [1.0+(2.0*rc/t_samp), 1.0-(2.0*rc/t_samp), 0.0]; let mut biquad_rc = BiquadFilt...
code_fim
hard
{ "lang": "rust", "repo": "markubiak/dsp.rs", "path": "/src/filter/biquad.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Abdillah/rdm path: /rdm/src/main.rs #![feature(conservative_impl_trait)] #![allow(unused_imports, dead_code)] #![allow(useless_format)] #[macro_use] extern crate clap; #[macro_use] extern crate slog; extern crate slog_async; extern crate slog_term; extern crate dbus; extern crate libc; extern...
code_fim
hard
{ "lang": "rust", "repo": "Abdillah/rdm", "path": "/rdm/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn setup_logger() -> Logger { let decor = TermDecorator::new().build(); let drain = FullFormat::new(decor).build().fuse(); let drain = Async::new(drain).build().fuse(); let log = Logger::root(drain, o!()); debug!(log, "Initialized logging"); log } fn main() { let matches = App...
code_fim
hard
{ "lang": "rust", "repo": "Abdillah/rdm", "path": "/rdm/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Insertable)] #[table_name="quote"] pub struct NewQuote<'a> { pub author_id: i64, pub text: &'a str, pub note: &'a str, pub retrieved: bool, }<|fim_prefix|>// repo: TheDan64/daily-quote path: /backend/src/models.rs use schema::{author, quote}; #[derive(Associations, Identifiable,...
code_fim
medium
{ "lang": "rust", "repo": "TheDan64/daily-quote", "path": "/backend/src/models.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Insertable)] #[table_name="author"] pub struct NewAuthor<'a> { pub name: &'a str, pub note: &'a str, } #[derive(Insertable)] #[table_name="quote"] pub struct NewQuote<'a> { pub author_id: i64, pub text: &'a str, pub note: &'a str, pub retrieved: bool, }<|fim_prefix|>// re...
code_fim
hard
{ "lang": "rust", "repo": "TheDan64/daily-quote", "path": "/backend/src/models.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheDan64/daily-quote path: /backend/src/models.rs use schema::{author, quote}; #[derive(Associations, Identifiable, Queryable)] #[has_many(quote)] #[table_name="author"] pub struct Author { pub id: i64, pub name: String, pub note: String, } <|fim_suffix|>#[derive(Insertable)] #[tab...
code_fim
hard
{ "lang": "rust", "repo": "TheDan64/daily-quote", "path": "/backend/src/models.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ods/leetcode-rs path: /src/challenge_2021_mar/week5/max_envelopes.rs // Russian Doll Envelopes // https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/592/week-5-march-29th-march-31st/3690/ pub struct Solution; use std::{ cmp::Reverse, collections::BTreeSet, ...
code_fim
hard
{ "lang": "rust", "repo": "ods/leetcode-rs", "path": "/src/challenge_2021_mar/week5/max_envelopes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn fail2() { assert_eq!( Solution::max_envelopes(matrix![ [15, 8], [2, 20], [2, 14], [4, 17], [8, 19], [8, 9], [5, 7], [11, 19], ...
code_fim
hard
{ "lang": "rust", "repo": "ods/leetcode-rs", "path": "/src/challenge_2021_mar/week5/max_envelopes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0b01/rasta path: /src/effects/mod.rs pub mod overdrive; pub mod delay; pub mod autowah; pub mod tuner; pub mod tremelo; pub mod pedals; pub use self::pedals::Pedals; pub trait Effect: Send { fn new(sample_rate: usize, frame_size: u32) -> Self where Self: Sized; fn name(&self) -> ...
code_fim
medium
{ "lang": "rust", "repo": "0b01/rasta", "path": "/src/effects/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} type PedalName = String; type ConfName = String; type Val = f32; pub enum CtrlMsg { Bypass, BypassPedal(String), Tuner, Connect(String, String), Chain(Vec<CtrlMsg>), Disconnect(String), Connections, Add(String, String), Set(PedalName, ConfName, Val), }<|fim_prefix|>...
code_fim
hard
{ "lang": "rust", "repo": "0b01/rasta", "path": "/src/effects/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (@input $value:tt @current () @output ($head:tt $($tail:tt)*)) => ({ c!(@input $value @current ({ c!(@format $head $value); }) @output ($($tail )*)); }); (@input $value:tt @current ($current:block) @output ($head:tt $($tail:tt)*)) => ({ c!(@input $value @cur...
code_fim
hard
{ "lang": "rust", "repo": "bennetthardwick/sample-dsp", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bennetthardwick/sample-dsp path: /src/lib.rs use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; // f32, f64, u8, i8, i16, u16, u32, // pub trait Sample: Sized + FlipSample + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign ...
code_fim
hard
{ "lang": "rust", "repo": "bennetthardwick/sample-dsp", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let oc: Vector3 = r.origin() - self.center; let a = r.direction().length_squared(); let b = oc.dot(&r.direction()); let c = oc.dot(&oc) - self.radius * self.radius; let discriminant = b * b - a * c; if discriminant > 0.0 { let mut temp = (-b - di...
code_fim
hard
{ "lang": "rust", "repo": "superphunthyme/raytracer", "path": "/src/sphere.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }