text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: brain0/binomial-rs path: /tests/i128_overflow.rs #![cfg(feature = "i128")] extern crate binomial; use binomial::Binomial; #[test] fn binomial131_no_overflow() { <|fim_suffix|> assert!(131i128.choose(65).is_none()); }<|fim_middle|> assert_eq!( 130i128.choose(65).unwrap(), 9...
code_fim
medium
{ "lang": "rust", "repo": "brain0/binomial-rs", "path": "/tests/i128_overflow.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(131i128.choose(65).is_none()); }<|fim_prefix|>// repo: brain0/binomial-rs path: /tests/i128_overflow.rs #![cfg(feature = "i128")] extern crate binomial; use binomial::Binomial; <|fim_middle|>#[test] fn binomial131_no_overflow() { assert_eq!( 130i128.choose(65).unwrap(), 9...
code_fim
medium
{ "lang": "rust", "repo": "brain0/binomial-rs", "path": "/tests/i128_overflow.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LycrusHamster/muta path: /framework/src/binding/tests/sdk.rs use std::cell::RefCell; use std::rc::Rc; use std::sync::Arc; use async_trait::async_trait; use bytes::Bytes; use cita_trie::MemoryDB; use protocol::traits::{CommonStorage, Context, ServiceResponse, ServiceSDK, Storage}; use protocol:...
code_fim
hard
{ "lang": "rust", "repo": "LycrusHamster/muta", "path": "/framework/src/binding/tests/sdk.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn mock_proof() -> Proof { Proof { height: 4, round: 99, block_hash: mock_hash(), signature: Default::default(), bitmap: Default::default(), } } pub fn mock_block_header() -> BlockHeader { BlockHeader { chain_id: ...
code_fim
hard
{ "lang": "rust", "repo": "LycrusHamster/muta", "path": "/framework/src/binding/tests/sdk.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/energy_loading/src/energy_loading_bundle.rs use amethyst::{ assets::Processor, core::bundle::SystemBundle, ecs::{DispatcherBuilder, World}, Error, }; use derive_new::new; use energy_model::config::EnergyDefinition; <|fim_suffix|>impl<'a, 'b> Sy...
code_fim
medium
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/energy_loading/src/energy_loading_bundle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tayspen72/BluetoothBlinker path: /BluetoothBlinker-MCU-rust/src/config.rs //============================================================================== // Notes //============================================================================== // config.rs //===================================...
code_fim
hard
{ "lang": "rust", "repo": "tayspen72/BluetoothBlinker", "path": "/BluetoothBlinker-MCU-rust/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>//============================================================================== // LCD //============================================================================== //============================================================================== // Push Button //=====================================...
code_fim
hard
{ "lang": "rust", "repo": "tayspen72/BluetoothBlinker", "path": "/BluetoothBlinker-MCU-rust/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amethyst/rendy path: /mesh/src/lib.rs //! //! This crates provides means to deal with vertex buffers and meshes. //! //! `Attribute` and `VertexFormat` allow vertex structure to declare semantics. //! `Mesh` can be created from typed vertex structures and provides mechanism to bind //! vertex at...
code_fim
hard
{ "lang": "rust", "repo": "amethyst/rendy", "path": "/mesh/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod format; mod mesh; pub use crate::{format::*, mesh::*}; pub use rendy_core::types::vertex::*;<|fim_prefix|>// repo: amethyst/rendy path: /mesh/src/lib.rs //! //! This crates provides means to deal with vertex buffers and meshes. //! //! `Attribute` and `VertexFormat` allow vertex structure to declare...
code_fim
hard
{ "lang": "rust", "repo": "amethyst/rendy", "path": "/mesh/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sparkle-os/sparkle path: /src/arch/x86_64/memory/paging/frame.rs //! Physical page frames. /// A page frame in physical memory. /// /// # Limitations /// Currently, page frames are all the same size (4kib) and represented internally with an index, /// starting with frame 0 at physical memory lo...
code_fim
hard
{ "lang": "rust", "repo": "sparkle-os/sparkle", "path": "/src/arch/x86_64/memory/paging/frame.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Frame> { if self.start <= self.end { let frame = self.start.clone(); self.start.index += 1; Some(frame) } else { None } } }<|fim_prefix|>// repo: sparkle-os/sparkle path: /src/arch/x86_64/memory/p...
code_fim
hard
{ "lang": "rust", "repo": "sparkle-os/sparkle", "path": "/src/arch/x86_64/memory/paging/frame.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl Iterator for FrameIter { type Item = Frame; fn next(&mut self) -> Option<Frame> { if self.start <= self.end { let frame = self.start.clone(); self.start.index += 1; Some(frame) } else { None } } }<|fim_prefix|>// rep...
code_fim
hard
{ "lang": "rust", "repo": "sparkle-os/sparkle", "path": "/src/arch/x86_64/memory/paging/frame.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TVerse/sfota path: /src/parser/instruction/mnemonic.rs use std::str::FromStr; use nom::combinator::map_res; use nom::error::{context, ErrorKind as NomErrorKind, FromExternalError}; use crate::parser::{valid_word, Error, ErrorKind, IResult, Input}; struct UndefinedMnemonic(String); impl<'a> F...
code_fim
hard
{ "lang": "rust", "repo": "TVerse/sfota", "path": "/src/parser/instruction/mnemonic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Error { errors: vec![ (input, ErrorKind::Nom(kind)), (input, ErrorKind::UndefinedMnemonic(e.0)), ], } } } #[derive(Debug, Eq, PartialEq, strum_macros::EnumString, strum_macros::Display)] pub enum Mnemonic { STZ, RTS, ...
code_fim
medium
{ "lang": "rust", "repo": "TVerse/sfota", "path": "/src/parser/instruction/mnemonic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn mnemonic_fail_1() { let input = " not This_is_a_val1d_mnemOnIc end"; let result = Mnemonic::parse(input); assert!(result.is_err()) } #[test] fn mnemonic_fail_2() { let input = "STA #$0300"; let result = Mnemonic::parse(input); ...
code_fim
hard
{ "lang": "rust", "repo": "TVerse/sfota", "path": "/src/parser/instruction/mnemonic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// A unique identifier for a typedef (*i.e.* a relation). Rule::RelationId => pub struct RelationIdent; /// A unique identifier for a subset Rule::SubsetId => pub struct SubsetIdent; /// A unique identifier for a synonym type. Rule::SynonymTypeId => pub struct SynonymTypeIdent; ...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/fastobo", "path": "/fastobo/src/ast/id/subclasses.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> macro_rules! id_subclasses { ($(#[doc = $docstring:literal] $rule:expr => pub struct $name:ident : &$life:lifetime $owned:ident;)*) => { $(id_subclass!(#[doc = $docstring] $rule => pub struct $name : &$life $owned);)* } } // NB(@althonos): All identifiers are defined as separate typedefs...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/fastobo", "path": "/fastobo/src/ast/id/subclasses.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/fastobo path: /fastobo/src/ast/id/subclasses.rs use std::str::FromStr; use pest::iterators::Pair; use url::Url; use crate::ast::*; use crate::error::Result; use crate::parser::FromPair; use crate::parser::FromSlice; use crate::parser::Rule; use crate::share::Share; use crate::share::R...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/fastobo", "path": "/fastobo/src/ast/id/subclasses.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match n { 0 => ~[Empty], 1 => ~[Node('x', ~Empty, ~Empty)], _ => { let p2 = hbal_tree(n-2); let p1 = hbal_tree(n-1); let mut r = ~[]; for t in p1.iter() { for s in p2.iter() { r.push(Node('x', ~...
code_fim
hard
{ "lang": "rust", "repo": "rjosephwright/99-Problems-Rust", "path": "/51-60/p59.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rjosephwright/99-Problems-Rust path: /51-60/p59.rs #[deriving(Clone)] enum BinaryTree<T> { Node(T, ~BinaryTree<T>, ~BinaryTree<T>), Empty } <|fim_suffix|> match n { 0 => ~[Empty], 1 => ~[Node('x', ~Empty, ~Empty)], _ => { let p2 = hbal_tree(n-2); ...
code_fim
hard
{ "lang": "rust", "repo": "rjosephwright/99-Problems-Rust", "path": "/51-60/p59.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_transforms_base/src/rename/analyzer/mod.rs use swc_common::Mark; use swc_ecma_ast::*; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use self::scope::{Scope, ScopeKind}; mod reverse_map; pub(super) mod scope; #[derive(Debug, Default)] pub(super...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_ecma_transforms_base/src/rename/analyzer/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> if let Expr::Ident(i) = e { self.add_usage(i.to_id()) } self.is_pat_decl = old_is_pat_decl; } fn visit_fn_decl(&mut self, f: &FnDecl) { self.add_decl(f.ident.to_id(), true); // https://github.com/swc-project/swc/issues/6819 let has_res...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_ecma_transforms_base/src/rename/analyzer/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> for e in v { r.push( *e * b ); }; r }; let a = |v1: &Vec<f64>, v2: &Vec<f64>| -> Vec<f64> { let mut r: Vec<f64> = vec![]; for (i, _) in v1.iter().enumerate() { r.push( v1[i] + v2[i] ); ...
code_fim
medium
{ "lang": "rust", "repo": "blolya/ode45", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for (i, _) in v1.iter().enumerate() { r.push( v1[i] + v2[i] ); }; r }; let k1 = (self.f)( self.t, &self.y ); let k2 = (self.f)( self.t + self.h / 2.0, &a( &self.y, &m(&k1, self.h / 2.0) ) ); let k3 = (self.f)( self.t + se...
code_fim
hard
{ "lang": "rust", "repo": "blolya/ode45", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blolya/ode45 path: /src/lib.rs pub struct Solver<F> where F: Fn(f64, &Vec<f64>) -> Vec<f64> { f: F, y: Vec<f64>, t: f64, tk: f64, h: f64, } impl<F> Solver<F> where F: Fn(f64, &Vec<f64>) -> Vec<f64> { pub fn new(f: F, t0: f64, y0: Vec<f64>, tk: f64) -> Solver<F> ...
code_fim
hard
{ "lang": "rust", "repo": "blolya/ode45", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Axect/Peroxide path: /src/structure/polynomial.rs let value = self.coef[0]; let temp = choose_shorter_string(format!("{}", value), format!("{:.4}", value)); return write!(f, "{}", temp); } if l == 1 { let coef_1 = self.coef[0]; ...
code_fim
hard
{ "lang": "rust", "repo": "Axect/Peroxide", "path": "/src/structure/polynomial.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Axect/Peroxide path: /src/structure/polynomial.rs ial Structure #[derive(Debug, Clone, Default)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Polynomial { pub coef: Vec<f64>, } /// Polynomial Print /// /// # Examples /// ``` /// #[macro_use] /// extern crate per...
code_fim
hard
{ "lang": "rust", "repo": "Axect/Peroxide", "path": "/src/structure/polynomial.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn integral(&self) -> Self { let l = self.coef.len(); let mut result = vec![0f64; l + 1]; for i in 0..l { result[i] = self.coef[i] / (l - i) as f64; } Self::new(result) } fn integrate<T: Into<f64> + Copy>(&self, interval: (T, T)) -> f64 { ...
code_fim
hard
{ "lang": "rust", "repo": "Axect/Peroxide", "path": "/src/structure/polynomial.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Serialize, Deserialize)] pub struct SecuredPollConfiguration { pub poll_identifier: AEADString, pub poll_trustees: Vec<PollConfigurationTrustee>, pub encrypted_poll_configuration: AEADString, pub signing_certificate: AEADString }<|fim_prefix|>// repo: seventh-estate/...
code_fim
medium
{ "lang": "rust", "repo": "seventh-estate/seventh-estate", "path": "/src/poll_configuration/secured.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seventh-estate/seventh-estate path: /src/poll_configuration/secured.rs //! # Persistent Secure Poll Configuration File //! //! The structure of the secured configuration has the following properties: //! * The poll identifier is visible, but integrity-protected. //! * The poll trustees and KDF p...
code_fim
medium
{ "lang": "rust", "repo": "seventh-estate/seventh-estate", "path": "/src/poll_configuration/secured.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] pub struct BalanceList { pub balance: Option<Vec<Balance>>, }<|fim_prefix|>// repo: incker2/luno-rust path: /src/accounts.rs use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct Account { pub id: Option<String>, pub currency: ...
code_fim
hard
{ "lang": "rust", "repo": "incker2/luno-rust", "path": "/src/accounts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: incker2/luno-rust path: /src/accounts.rs use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct Account { pub id: Option<String>, pub currency: String, pub name: String, } <|fim_suffix|>#[derive(Debug, Deserialize)] pub struct BalanceList { pub...
code_fim
hard
{ "lang": "rust", "repo": "incker2/luno-rust", "path": "/src/accounts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/tests/elf_runner/args_reporter.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. <|fim_suffix|> let args: Vec<String> = std::...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/tests/elf_runner/args_reporter.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let args: Vec<String> = std::env::args().collect(); assert_eq!(args, vec!["/pkg/bin/args_reporter", "Hippos", "rule!"]); }<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/tests/elf_runner/args_reporter.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use o...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/tests/elf_runner/args_reporter.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kampersanda/lzd-rs path: /src/bit_serializer.rs use crate::serializer::Serializer; use std::io::{Result, Write}; ///! Bit-wise serializer. pub struct BitSerializer<W> where W: Write, { stream: W, buffer: [u8; 8], cursor: usize, } impl<W> BitSerializer<W> where W: Write, { ...
code_fim
hard
{ "lang": "rust", "repo": "kampersanda/lzd-rs", "path": "/src/bit_serializer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if nbits == 0 { self.buffer[0] = 0; self.cursor = 0; } else { let mask = (1 << nbits) - 1; self.buffer[0] = (x & mask) as u8; self.cursor = nbits; } Ok(()) } fn finish(&mut self) -> Result<()> { s...
code_fim
hard
{ "lang": "rust", "repo": "kampersanda/lzd-rs", "path": "/src/bit_serializer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AssafAoc/aoc2019 path: /src/d1.rs fn calc_fuel(mass: u32) -> Option<u32> { ((mass as f32 / 3.0) as u32).checked_sub(2) } <|fim_suffix|> let mut total_fuel = fuel; let mut current_fuel = fuel; while let Some(more_fuel) = calc_fuel(current_fuel) { total_fuel += more_fuel; ...
code_fim
medium
{ "lang": "rust", "repo": "AssafAoc/aoc2019", "path": "/src/d1.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] pub fn run() { let input = super::get_input(1, ""); let fuel_mass = input.iter() .map(|line| line.parse::<u32>().unwrap()) .map(calc_fuel).map(|f| f.unwrap()) .sum::<u32>(); let fuel_total_mass = input.iter() .map(|line| line.parse::<u32>()...
code_fim
hard
{ "lang": "rust", "repo": "AssafAoc/aoc2019", "path": "/src/d1.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> emd.graphics().begin().unwrap(); emd.graphics().draw_world(&mut self.world).unwrap(); emd.graphics().render().unwrap(); } }<|fim_prefix|>// repo: Bombfuse/emerald path: /emerald/examples/load_world_file.rs use emerald::{rendering::components::aseprite_update_system, *}; pub f...
code_fim
hard
{ "lang": "rust", "repo": "Bombfuse/emerald", "path": "/emerald/examples/load_world_file.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn draw(&mut self, mut emd: Emerald) { emd.graphics().begin().unwrap(); emd.graphics().draw_world(&mut self.world).unwrap(); emd.graphics().render().unwrap(); } }<|fim_prefix|>// repo: Bombfuse/emerald path: /emerald/examples/load_world_file.rs use emerald::{rendering::com...
code_fim
medium
{ "lang": "rust", "repo": "Bombfuse/emerald", "path": "/emerald/examples/load_world_file.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bombfuse/emerald path: /emerald/examples/load_world_file.rs use emerald::{rendering::components::aseprite_update_system, *}; pub fn main() { emerald::start( Box::new(WorldLoadingExample { world: World::new(), }), GameSettings::default(), ) } pub stru...
code_fim
medium
{ "lang": "rust", "repo": "Bombfuse/emerald", "path": "/emerald/examples/load_world_file.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let value = self.next_u32(); let value = value >> (float_size - precision); scale * value as f32 } pub fn next_f32_range(&mut self, min: f32, max: f32) -> f32 { min + (max - min) * self.next_f32() } } pub type DefaultRng = PCG32si;<|fim_prefix|>// repo: hatoo/...
code_fim
medium
{ "lang": "rust", "repo": "hatoo/rukako", "path": "/rukako-shader/src/rand.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hatoo/rukako path: /rukako-shader/src/rand.rs pub struct PCG32si { state: u32, } impl PCG32si { const PCG_DEFAULT_MULTIPLIER_32: u32 = 747796405; const PCG_DEFAULT_INCREMENT_32: u32 = 2891336453; fn pcg_oneseq_32_step_r(&mut self) { self.state = self .state ...
code_fim
hard
{ "lang": "rust", "repo": "hatoo/rukako", "path": "/rukako-shader/src/rand.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tjwilson90/turbo-hearts path: /bot/src/encoder.rs use std::collections::HashMap; use turbo_hearts_api::{ Card, Cards, ChargeState, GameState, Rank, Seat, Suit, Suits, Trick, WonState, }; const EMPTY: &'static [f32] = &[0.0, 0.0, 0.0, 0.0]; pub struct Encoder(Vec<f32>); impl Encoder { ...
code_fim
hard
{ "lang": "rust", "repo": "tjwilson90/turbo-hearts", "path": "/bot/src/encoder.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn plays(mut self, hand: Cards, game_state: &GameState, plays: &[i16]) -> Self { let min = *plays.into_iter().min().unwrap(); let max = *plays.into_iter().max().unwrap(); if min == max { return self; } let avg = (min + max) as f32 / 2.0; ...
code_fim
hard
{ "lang": "rust", "repo": "tjwilson90/turbo-hearts", "path": "/bot/src/encoder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for &suit in &Suit::VALUES { let chargeable = (suit.cards() & Cards::CHARGEABLE).max(); let nine = suit.with_rank(Rank::Nine); let high = chargeable.above(); let middle = nine.above() - high - chargeable; let low = nine.below(); ...
code_fim
hard
{ "lang": "rust", "repo": "tjwilson90/turbo-hearts", "path": "/bot/src/encoder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wdiviner/geektime-rust path: /15_smart_pointers/src/borrow.rs use std::borrow::Borrow; fn main() { <|fim_suffix|> // 这里必须声明类型,因为 String 有多个 Borrow<T> 实现 // 借用为 &String let r1: &String = s.borrow(); // 借用为 &str let r2: &str = s.borrow(); println!("r1: {:p}, r2: {:p}", r1,...
code_fim
easy
{ "lang": "rust", "repo": "Wdiviner/geektime-rust", "path": "/15_smart_pointers/src/borrow.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("r1: {:p}, r2: {:p}", r1, r2); }<|fim_prefix|>// repo: Wdiviner/geektime-rust path: /15_smart_pointers/src/borrow.rs use std::borrow::Borrow; fn main() { <|fim_middle|> let s = "hello world!".to_owned(); // 这里必须声明类型,因为 String 有多个 Borrow<T> 实现 // 借用为 &String let r1: &String =...
code_fim
medium
{ "lang": "rust", "repo": "Wdiviner/geektime-rust", "path": "/15_smart_pointers/src/borrow.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kata-containers/cgroups-rs path: /src/cgroup.rs archy `hier`, with name `path` and `relative_paths` /// /// Returns a handle to the control group that can be used to manipulate it. /// /// Note that this method is only meaningful for cgroup v1, call it is equivalent to call `new`...
code_fim
hard
{ "lang": "rust", "repo": "kata-containers/cgroups-rs", "path": "/src/cgroup.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fs::write(p, val) .map_err(|e| Error::with_cause(WriteFailed(file_name.to_string(), val.to_string()), e)) } /// Attach a task to the control group. pub fn add_task(&self, tid: CgroupPid) -> Result<()> { if self.v2() { let subsystems = self.subsystems();...
code_fim
hard
{ "lang": "rust", "repo": "kata-containers/cgroups-rs", "path": "/src/cgroup.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// The list of subsystems that this control group supports. pub fn subsystems(&self) -> &Vec<Subsystem> { &self.subsystems } /// Deletes the control group. /// /// Note that this function makes no effort in cleaning up the descendant and the underlying /// system call...
code_fim
hard
{ "lang": "rust", "repo": "kata-containers/cgroups-rs", "path": "/src/cgroup.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match template.ai_type.unwrap() { AiType::MovingRandomly => { commands.add_component(entity, MovingRandomly {}); } AiType::Chasing => { commands.add_component(entity, ChasingPla...
code_fim
hard
{ "lang": "rust", "repo": "dwino/EngineRustLegionBracketLib", "path": "/src/spawner/template.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dwino/EngineRustLegionBracketLib path: /src/spawner/template.rs use crate::prelude::*; use ron::de::from_reader; use serde::Deserialize; use std::collections::{HashMap, HashSet}; use std::fs::File; #[derive(Clone, Deserialize, Debug, PartialEq)] pub enum EntityType { Equipment, ...
code_fim
hard
{ "lang": "rust", "repo": "dwino/EngineRustLegionBracketLib", "path": "/src/spawner/template.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0x0c72/crust-of-rust-notes path: /2_cell/src/cell.rs use std::cell::UnsafeCell; pub struct Cell<T> { value: UnsafeCell<T>, } // implied by UnsafeCell being in the struct // impl<T> !Sync for Cell<T> {} <|fim_suffix|> pub fn get(&self) -> T where T: Copy, { ...
code_fim
hard
{ "lang": "rust", "repo": "0x0c72/crust-of-rust-notes", "path": "/2_cell/src/cell.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::Cell; use std::sync::Arc; use std::thread; // #[test] // fn bad() { // let x = Arc::new(Cell::new([0; 1024])); // let x1 = Arc::clone(&x); // let jh1 = thread::spawn(move || { // x1.set([1; 1024]); ...
code_fim
hard
{ "lang": "rust", "repo": "0x0c72/crust-of-rust-notes", "path": "/2_cell/src/cell.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut curr_keys = 0; let mut prev_keys = 0; let mut frame = 0; loop { video::vsync(); if frame & 7 == 0 { prev_keys = curr_keys; curr_keys = input::poll(); } for i in 0..KEY_MAX { let key = input::key(i); ...
code_fim
hard
{ "lang": "rust", "repo": "Ruin0x11/gba-rs", "path": "/gba-examples/examples/tonc-05.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ruin0x11/gba-rs path: /gba-examples/examples/tonc-05.rs #![no_std] #![no_main] extern crate panic_halt; use gba::{data, mmio::{self, Dispcnt}, input, util, video}; use gba_boot::entry; const KEY_MAX: usize = 10; const BTN_PAL_ID: usize = 5; #[entry] fn main() -> ! { let gba_pic_bitmap = ...
code_fim
hard
{ "lang": "rust", "repo": "Ruin0x11/gba-rs", "path": "/gba-examples/examples/tonc-05.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn should_not_detect_root_plugin_configs() { let glob_set = build_glob_set(vec![ // String::from("!(Cargo.toml)"), String::from("*/**/Cargo.toml"), ]) .unwrap(); assert!(glob_set.is_match("packages/a/Cargo.toml")); assert!(glo...
code_fim
hard
{ "lang": "rust", "repo": "NathanWalker/nx", "path": "/packages/nx/src/native/utils/glob.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NathanWalker/nx path: /packages/nx/src/native/utils/glob.rs use globset::{GlobBuilder, GlobSet, GlobSetBuilder}; pub(crate) fn build_glob_set(globs: Vec<String>) -> anyhow::Result<GlobSet> { let mut glob_set_builder = GlobSetBuilder::new(); for glob in globs { let glob = GlobBui...
code_fim
medium
{ "lang": "rust", "repo": "NathanWalker/nx", "path": "/packages/nx/src/native/utils/glob.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // render to texture/depth let mut target = target.lock().unwrap(); let (target_color, target_depth) = render_to_texture(&self.post_effect, &context, &mut *target, |target| { // clear the colour and depth buffers t...
code_fim
hard
{ "lang": "rust", "repo": "shockham/caper", "path": "/src/renderer/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shockham/caper path: /src/renderer/mod.rs ssing pub post_effect: PostEffect, /// The shaders that can be used for rendering pub shaders: Shaders, /// The lighting system pub lighting: Lighting, /// Info on the current gif being written to gif_info: Option<GifInfo>, ...
code_fim
hard
{ "lang": "rust", "repo": "shockham/caper", "path": "/src/renderer/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tex_name = item .material .texture_name .clone() .unwrap_or_else(|| "default".to_string()); let normal_tex_name = item...
code_fim
hard
{ "lang": "rust", "repo": "shockham/caper", "path": "/src/renderer/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let x = x + 1; println!("The value of x is {}", x); // Tuples // creating let tup = (1, "hi", true); // destructuring let(x, y, z) = tup; println!("x: {}, y: {}, z: {}", x, y, z); // direct access println!("y is: {}", tup.1) // Arrays must contain all of t...
code_fim
medium
{ "lang": "rust", "repo": "thoiberg/rust-book-code-snippets", "path": "/variables/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thoiberg/rust-book-code-snippets path: /variables/src/main.rs fn main() { // By default variables are immutable and cannot be reassigned // let x = 5; // println!("The value of x is {}", x); // x = 6; // println!("The value of x is {}", x); // The mut keyword allows the ...
code_fim
medium
{ "lang": "rust", "repo": "thoiberg/rust-book-code-snippets", "path": "/variables/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<I> StTy<I> { fn m_lt<#[rustc_lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } fn m_ty<#[rustc_ty_meth] P>(_: P) { } } fn hof_lt<Q>(_: Q) where Q: for <#[rustc_lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 { } fn main() { }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/attr-on-generic-formals.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/attr-on-generic-formals.rs #![allow(unused_attributes)] // This test ensures we can attach attributes to the formals in all // places where generic parameter lists occur, assuming appropriate // feature gates are enabled. // // (We are pr...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/attr-on-generic-formals.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<#[rustc_lt_impl_for] 'f> TrLt<'f> for StLt<'f> { fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } } } impl<#[rustc_ty_impl_for] N> TrTy<N> for StTy<N> { fn foo(&self, _: N) { } } fn f_lt<#[rustc_lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } fn f_ty<#[rustc_ty_fn] O>(_: O) { } impl<I> St...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/attr-on-generic-formals.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LuisAyuso/rquarfs path: /src/renderer/shader.rs use regex::*; use glium; use std::path; use std::fs; use std::vec::*; use std::time; use context::Context; fn print_err(err: glium::program::ProgramCreationError) { match err { glium::program::ProgramCreationError::CompilationError(x...
code_fim
hard
{ "lang": "rust", "repo": "LuisAyuso/rquarfs", "path": "/src/renderer/shader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum ShaderParseError { InvalidPath, SyntaxError(String), MissingShader, CompileError, } #[derive(Debug)] struct ShaderPack { vertex: String, fragment: String, tess_control: Option<String>, tess_eval: Option<String>, geom: Option<String>, } impl S...
code_fim
hard
{ "lang": "rust", "repo": "LuisAyuso/rquarfs", "path": "/src/renderer/shader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc110/src/bin/b.rs use proconio::input; fn main() { input! { n: usize, m: usize, capital_x: i64, <|fim_suffix|>i >= z) { continue; } println!("No War"); return; } ...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc110/src/bin/b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>i >= z) { continue; } println!("No War"); return; } println!("War"); }<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc110/src/bin/b.rs use proconio::input; fn main() { input! { n: usize, m: usize, capi...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc110/src/bin/b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaloisInc/RustyFlight path: /transpiled/SPRACINGF3/src/src/main/drivers/bus_i2c_config.rs use core; use libc; extern "C" { #[no_mangle] fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; #[no_mangle] static i2cHardware: [i2cHardware_t; 0]...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/RustyFlight", "path": "/transpiled/SPRACINGF3/src/src/main/drivers/bus_i2c_config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>(*hardware).reg.is_null() { let mut device: I2CDevice = (*hardware).device; let mut pDev: *mut i2cDevice_t = &mut *i2cDevice.as_mut_ptr().offset(device as isize) as *mut i2cDevice_t; memset(pDev as *mut libc::c_void, 0i32, ...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/RustyFlight", "path": "/transpiled/SPRACINGF3/src/src/main/drivers/bus_i2c_config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] pub(crate) fn write_payload(bf: &mut BytesMut, metadata: Option<&Bytes>, data: Option<&Bytes>) { if let Some(v) = metadata { u24::from(v.len()).write_to(bf); bf.extend_from_slice(v); } if let Some(v) = data { bf.extend_from_slice(v); } }<|fim_prefix|>// re...
code_fim
hard
{ "lang": "rust", "repo": "rsocket/rsocket-rust", "path": "/rsocket/src/frame/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rsocket/rsocket-rust path: /rsocket/src/frame/utils.rs use bytes::{Buf, BufMut, Bytes, BytesMut}; use super::Frame; use crate::error::RSocketError; use crate::utils::{u24, Writeable}; <|fim_suffix|>#[inline] pub(crate) fn write_payload(bf: &mut BytesMut, metadata: Option<&Bytes>, data: Option<...
code_fim
hard
{ "lang": "rust", "repo": "rsocket/rsocket-rust", "path": "/rsocket/src/frame/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h7/src/stm32h743v/rcc/apb4lpenr.rs #[doc = "Register `APB4LPENR` reader"] pub type R = crate::R<APB4LPENR_SPEC>; #[doc = "Register `APB4LPENR` writer"] pub type W = crate::W<APB4LPENR_SPEC>; #[doc = "Field `SYSCFGLPEN` reader - SYSCFG peripheral clock enab...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h743v/rcc/apb4lpenr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> LPTIM2LPEN_W::new(self) } #[doc = "Bit 10 - LPTIM3 Peripheral Clocks Enable During CSleep Mode"] #[inline(always)] #[must_use] pub fn lptim3lpen(&mut self) -> LPTIM3LPEN_W<APB4LPENR_SPEC, 10> { LPTIM3LPEN_W::new(self) } #[doc = "Bit 11 - LPTIM4 Peripheral Clocks E...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h743v/rcc/apb4lpenr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/ron/tests/large_number.rs use ron : : value : : { Number Value } ; # [ test ] fn test_large_number ( ) { let test_var = Value : : Number ( Number : : new ( 10000000000000000000000 . 0f64 ) ) ; let test_ser = ron : : ser : : to_string ( & test_v...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/ron/tests/large_number.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>t ( ) { use ron : : value : : Float ; let test_var = std : : i64 : : MAX as u64 + 1 ; let expected = test_var as f64 ; / / Is exactly representable by f64 let test_ser = ron : : ser : : to_string ( & test_var ) . unwrap ( ) ; assert_eq ! ( test_ser test_var . to_string ( ) ) ; let test_deser = ron : : de ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/ron/tests/large_number.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn ex1_combos() { assert_eq!(count_combos(&read_diffs(&mut EX1.as_bytes())), 19208); } #[test] fn answer2() { assert_eq!(count_combos(&read_diffs(&mut INPUT.as_bytes())), 49607173328384); } #[test] fn combos() { let cases...
code_fim
hard
{ "lang": "rust", "repo": "spadix0/AoC2020", "path": "/10/adapters/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spadix0/AoC2020 path: /10/adapters/src/main.rs use std::{io, collections::HashMap}; use itertools::Itertools; fn main() { let path = std::env::args().nth(1).unwrap(); let diff = read_diffs(&mut std::fs::File::open(path).unwrap()); //println!("{:?}", diff); let hist = histogram(...
code_fim
hard
{ "lang": "rust", "repo": "spadix0/AoC2020", "path": "/10/adapters/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use std::rc::Rc; use std::cell::RefCell; mod buddy; #[macro_use] mod macros; mod help_your_granny; mod bleatrix_trotter; mod last_digit; mod candy; mod add_two_numbers; mod masking_personal_information; mod repeated_times; mod max_subarray_sum_circular; mod find_max_consecutive_ones; mod delete_node; mod...
code_fim
medium
{ "lang": "rust", "repo": "across-travel/rust_algorithm", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: across-travel/rust_algorithm path: /src/lib.rs #![feature(box_patterns)] #![feature(is_sorted)] #![feature(toowned_clone_into)] // Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right:...
code_fim
medium
{ "lang": "rust", "repo": "across-travel/rust_algorithm", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>extern crate regex; extern crate core; use std::rc::Rc; use std::cell::RefCell; mod buddy; #[macro_use] mod macros; mod help_your_granny; mod bleatrix_trotter; mod last_digit; mod candy; mod add_two_numbers; mod masking_personal_information; mod repeated_times; mod max_subarray_sum_circular; mod find_ma...
code_fim
medium
{ "lang": "rust", "repo": "across-travel/rust_algorithm", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (self.__dropfn)(&mut self.__value) } } #[test] fn test_defer() { use std::cell::Cell; let drops = Cell::new(0); defer!(drops.set(1000)); assert_eq!(drops.get(), 0); }<|fim_prefix|>// repo: akamit91/rustkpi path: /rust/rust-src-1.25.0/src/vendor/scopeguard-0.1.2/src/lib.rs us...
code_fim
medium
{ "lang": "rust", "repo": "akamit91/rustkpi", "path": "/rust/rust-src-1.25.0/src/vendor/scopeguard-0.1.2/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T, F> Drop for Guard<T, F> where F: FnMut(&mut T) { fn drop(&mut self) { (self.__dropfn)(&mut self.__value) } } #[test] fn test_defer() { use std::cell::Cell; let drops = Cell::new(0); defer!(drops.set(1000)); assert_eq!(drops.get(), 0); }<|fim_prefix|>// repo: a...
code_fim
medium
{ "lang": "rust", "repo": "akamit91/rustkpi", "path": "/rust/rust-src-1.25.0/src/vendor/scopeguard-0.1.2/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akamit91/rustkpi path: /rust/rust-src-1.25.0/src/vendor/scopeguard-0.1.2/src/lib.rs use std::ops::{Deref, DerefMut}; /// Macro to create a `Guard` (without any owned value). /// /// The macro takes one expression `$e`, which is the body of a closure /// that will run when the scope is exited. T...
code_fim
hard
{ "lang": "rust", "repo": "akamit91/rustkpi", "path": "/rust/rust-src-1.25.0/src/vendor/scopeguard-0.1.2/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let index = self.table_state.selected().unwrap_or_default(); if index == 0 { self.table_state.select(None); } else { self.table_state.select(Some(index - 1)); } } fn on_down(&mut self, app_state: &mut AppState) { let index = self.tab...
code_fim
hard
{ "lang": "rust", "repo": "sdbondi/tari", "path": "/applications/tari_console_wallet/src/ui/components/assets_tab.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn on_up(&mut self, _app_state: &mut AppState) { let index = self.table_state.selected().unwrap_or_default(); if index == 0 { self.table_state.select(None); } else { self.table_state.select(Some(index - 1)); } } fn on_down(&mut self, app...
code_fim
hard
{ "lang": "rust", "repo": "sdbondi/tari", "path": "/applications/tari_console_wallet/src/ui/components/assets_tab.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sdbondi/tari path: /applications/tari_console_wallet/src/ui/components/assets_tab.rs // Copyright 2021. The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistribution...
code_fim
hard
{ "lang": "rust", "repo": "sdbondi/tari", "path": "/applications/tari_console_wallet/src/ui/components/assets_tab.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sminez/penrose path: /src/core/hooks.rs //! Traits for writing and composing hooks. //! //! ## Hook points //! //! Penrose offers several differnt hook points where you are able to provide custom //! logic to execute as part of the main WindowManager event loop. Unlike logic you //! add as KeyEv...
code_fim
hard
{ "lang": "rust", "repo": "sminez/penrose", "path": "/src/core/hooks.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Convert to a trait object fn boxed(self) -> Box<dyn StateHook<X>> where Self: Sized + 'static, { Box::new(self) } /// Compose this hook with a boxed [StateHook]. fn then_boxed(self, next: Box<dyn StateHook<X>>) -> Box<dyn StateHook<X>> where Sel...
code_fim
hard
{ "lang": "rust", "repo": "sminez/penrose", "path": "/src/core/hooks.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charypar/advent-of-code-2020 path: /shuttle-search/src/main.rs use std::io::BufRead; fn main() { let inputs = std::io::stdin() .lock() .lines() .map(|it| it.unwrap()) .collect::<Vec<_>>(); let when = inputs[0].parse::<usize>().unwrap(); let raw_lines...
code_fim
hard
{ "lang": "rust", "repo": "charypar/advent-of-code-2020", "path": "/shuttle-search/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(find_time(&delays), 779210); } #[test] fn finds_timestamp_4() { // 67,7,x,59,61 let delays = [(67, 0), (59, 3), (61, 4), (7, 1)]; assert_eq!(find_time(&delays), 1261476); } #[test] fn finds_timestamp_5() { // 1789,37,47,1889 ...
code_fim
hard
{ "lang": "rust", "repo": "charypar/advent-of-code-2020", "path": "/shuttle-search/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hellertime/blip path: /src/collections/mod.rs // Copyright 2020 nytopop (Eric Izoita) // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your o<|fim_suff...
code_fim
medium
{ "lang": "rust", "repo": "hellertime/blip", "path": "/src/collections/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ption. This file may not be // copied, modified, or distributed except according to those terms. mod event; mod freqset; mod tumbler; pub use event::{Filter as EventFilter, Id as EventId}; pub use freqset::FreqSet; pub use tumbler::Tumbler;<|fim_prefix|>// repo: hellertime/blip path: /src/collections/mo...
code_fim
medium
{ "lang": "rust", "repo": "hellertime/blip", "path": "/src/collections/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> mod tumbler; pub use event::{Filter as EventFilter, Id as EventId}; pub use freqset::FreqSet; pub use tumbler::Tumbler;<|fim_prefix|>// repo: hellertime/blip path: /src/collections/mod.rs // Copyright 2020 nytopop (Eric Izoita) // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or //...
code_fim
hard
{ "lang": "rust", "repo": "hellertime/blip", "path": "/src/collections/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brayniac/rpc-perf path: /src/clients/momento/commands/delete.rs use super::*; /// Remove a key from the cache. pub async fn delete( client: &mut SimpleCacheClient, con<|fim_suffix|> client.delete(cache_name, (*request.key).to_owned()), ) .await; record_result!(result, DE...
code_fim
hard
{ "lang": "rust", "repo": "brayniac/rpc-perf", "path": "/src/clients/momento/commands/delete.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> client.delete(cache_name, (*request.key).to_owned()), ) .await; record_result!(result, DELETE) }<|fim_prefix|>// repo: brayniac/rpc-perf path: /src/clients/momento/commands/delete.rs use super::*; /// Remove a key from the cache. pub async fn delete( client: &mut SimpleCacheClient, ...
code_fim
medium
{ "lang": "rust", "repo": "brayniac/rpc-perf", "path": "/src/clients/momento/commands/delete.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shritesh/webgl.rs path: /src/lib.rs mod linear_algebra; mod programs; mod utils; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::WebGlRenderingContext; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; fn get_context() -> Result<WebGlRende...
code_fim
hard
{ "lang": "rust", "repo": "shritesh/webgl.rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }