text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> #[test] fn it_works() { assert_eq!(Solution::is_match("aa".to_string(), "a".to_string()), false); assert_eq!(Solution::is_match("aa".to_string(), "a*".to_string()), true); } }<|fim_prefix|>// repo: lcdsmao/leetcode-rust path: /problem/src/solution/p010_regular_expression_matc...
code_fim
hard
{ "lang": "rust", "repo": "lcdsmao/leetcode-rust", "path": "/problem/src/solution/p010_regular_expression_matching.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lcdsmao/leetcode-rust path: /problem/src/solution/p010_regular_expression_matching.rs pub struct Solution {} impl Solution { pub fn is_match(s: String, p: String) -> bool { let mut dp = vec![vec![false; p.len() + 1]; s.len() + 1]; dp[0][0] = true; for (j, chp) in p.c...
code_fim
hard
{ "lang": "rust", "repo": "lcdsmao/leetcode-rust", "path": "/problem/src/solution/p010_regular_expression_matching.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn write_sep(&mut self) { write!( self.buf, "{}", console::Style::new() .fg(self.cfg.colors.separator) .apply_to(&self.cfg.separator) ) .unwrap(); } fn finish(&mut self) { println!("{}", self.b...
code_fim
hard
{ "lang": "rust", "repo": "foldu/statusbar", "path": "/src/output/terminal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn write_colored(&mut self, c: Color, s: fmt::Arguments) { let color = match c { Color::Good => self.cfg.colors.good, Color::Mediocre => self.cfg.colors.mediocre, Color::Bad => self.cfg.colors.bad, }; write!(self.buf, "{}", console::Style::ne...
code_fim
hard
{ "lang": "rust", "repo": "foldu/statusbar", "path": "/src/output/terminal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foldu/statusbar path: /src/output/terminal.rs use std::fmt::{self, Write}; use super::color::{ColorCfg, TerminalColors}; use crate::output::Color; #[derive(Debug, Clone)] pub struct Output { buf: String, cfg: Cfg, } #[derive(Debug, Clone)] pub struct Cfg { separator: String, c...
code_fim
hard
{ "lang": "rust", "repo": "foldu/statusbar", "path": "/src/output/terminal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: findelabs/mongo_alerts_2teams path: /src/transform.rs ialize, Serialize}; use serde_json::json; #[derive(Hash, Eq, Default, PartialEq, Debug, Clone, Serialize, Deserialize, Ord, PartialOrd)] struct FactEntry { pub name: String, pub value: String, } // Accept alert json and return micro...
code_fim
hard
{ "lang": "rust", "repo": "findelabs/mongo_alerts_2teams", "path": "/src/transform.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_message_string(alert_type: &str) -> Option<&str> { match alert_type { "AUTOMATION_AGENT_DOWN" => Some("Automation is down"), "AUTOMATION_AGENT_UP" => Some("Automation is up"), "BACKUP_AGENT_CONF_CALL_FAILURE" => Some("Backup has too many conf call failures"), ...
code_fim
hard
{ "lang": "rust", "repo": "findelabs/mongo_alerts_2teams", "path": "/src/transform.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn capitalize(s: &str) -> String { let mut c = s.chars(); match c.next() { None => String::new(), Some(f) => f.to_uppercase().collect::<String>() + c.as_str(), } }<|fim_prefix|>// repo: Basicprogrammer10/Languge-Bot path: /src/common.rs use serenity::{model, prelude::*}; ...
code_fim
medium
{ "lang": "rust", "repo": "Basicprogrammer10/Languge-Bot", "path": "/src/common.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Basicprogrammer10/Languge-Bot path: /src/common.rs use serenity::{model, prelude::*}; static mut WORDS: Option<Vec<String>> = None; /// Check if a message contains a bad word then send a message to the channel pub async fn check_send( ctx: Context, content: String, author_name: Str...
code_fim
hard
{ "lang": "rust", "repo": "Basicprogrammer10/Languge-Bot", "path": "/src/common.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hb029/JA-2-Stracciatella path: /rust/stracciatella/src/stracciatella.rs Ok(exe) => { // use directory of the executable if let Some(dir) = exe.parent() { dir.into() } else { ".".into() } } Err...
code_fim
hard
{ "lang": "rust", "repo": "hb029/JA-2-Stracciatella", "path": "/rust/stracciatella/src/stracciatella.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(engine_options.start_without_sound, true); } #[test] fn parse_json_config_should_not_be_able_to_run_help() { let temp_dir = write_temp_folder_with_ja2_json(b"{ \"help\": true, \"show_help\": true }"); let engine_options = parse_json_config(&temp_dir.path().j...
code_fim
hard
{ "lang": "rust", "repo": "hb029/JA-2-Stracciatella", "path": "/rust/stracciatella/src/stracciatella.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn parse_json_config_should_fail_with_invalid_mod() { let temp_dir = write_temp_folder_with_ja2_json(b"{ \"mods\": [ \"a\", true ] }"); let stracciatella_home = temp_dir.path().join(".ja2"); assert_eq!(parse_json_config(&stracciatella_home), Err(String::from("Error...
code_fim
hard
{ "lang": "rust", "repo": "hb029/JA-2-Stracciatella", "path": "/rust/stracciatella/src/stracciatella.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let threads = self.thread_num; let wg = WaitGroup::new(); let (tx, rx) = bounded::<Option<Package>>(threads); let failures = Arc::new(Mutex::new(vec![])); let pending = Arc::new(Mutex::new(vec![])); for _ in 0..threads { let rx = rx.clone(); ...
code_fim
hard
{ "lang": "rust", "repo": "maralla/pack", "path": "/src/task.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maralla/pack path: /src/task.rs use crate::echo; use crate::package::Package; use crate::utils::Spinner; use crate::Error; use crate::Result; use crossbeam_channel::{bounded, select, Receiver}; use crossbeam_utils::sync::WaitGroup; use signal_hook::iterator::Signals; use std::fs; use std::io; u...
code_fim
hard
{ "lang": "rust", "repo": "maralla/pack", "path": "/src/task.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andreheringer/rstz path: /src/encodeco/value_decoder.rs use serde_json::Value; use bitvec::prelude::*; <|fim_suffix|> fn decompress(&mut self, bitptr: &mut BitSlice<Msb0, u8>) -> Value; }<|fim_middle|>pub trait ValueDecoder { fn new() -> Self;
code_fim
easy
{ "lang": "rust", "repo": "andreheringer/rstz", "path": "/src/encodeco/value_decoder.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn decompress(&mut self, bitptr: &mut BitSlice<Msb0, u8>) -> Value; }<|fim_prefix|>// repo: andreheringer/rstz path: /src/encodeco/value_decoder.rs use serde_json::Value; use bitvec::prelude::*; <|fim_middle|>pub trait ValueDecoder { fn new() -> Self;
code_fim
easy
{ "lang": "rust", "repo": "andreheringer/rstz", "path": "/src/encodeco/value_decoder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/weedle2/src/dictionary.rs use crate : : attribute : : ExtendedAttributeList ; use crate : : common : : { Default Identifier } ; use crate : : types : : Type ; / / / Parses dictionary members pub type DictionaryMembers < ' a > = Vec < Dictionary...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/weedle2/src/dictionary.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>red : Option < term ! ( required ) > type_ : Type < ' a > identifier : Identifier < ' a > default : Option < Default < ' a > > semi_colon : term ! ( ; ) } } # [ cfg ( test ) ] mod test { use super : : * ; use crate : : Parse ; test ! ( should_parse_dictionary_member { " required long num = 5 ; " = > " " ;...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/weedle2/src/dictionary.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(AsChangeset)] #[table_name = "users"] #[changeset_options] struct UserForm6 { id: i32, name: String, } fn main() {}<|fim_prefix|>// repo: sshyran/diesel path: /diesel_compile_tests/tests/ui/as_changeset_bad_options.rs #[macro_use] extern crate diesel; table! { users { id ->...
code_fim
medium
{ "lang": "rust", "repo": "sshyran/diesel", "path": "/diesel_compile_tests/tests/ui/as_changeset_bad_options.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sshyran/diesel path: /diesel_compile_tests/tests/ui/as_changeset_bad_options.rs #[macro_use] extern crate diesel; table! { users { id -> Integer, name -> Text, } } #[derive(AsChangeset)] #[table_name = "users"] #[changeset_options(treat_none_as_null("true"))] struct Use...
code_fim
medium
{ "lang": "rust", "repo": "sshyran/diesel", "path": "/diesel_compile_tests/tests/ui/as_changeset_bad_options.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let neighbor_mass = neighbor.mass; let mass_total = cur_particle_mass + neighbor_mass; self.particles[idx].pos = self.particles[idx].pos - 0.5 * force * dt * dt * (neighbor_mass / mass_total); self.particles[idx].vel = self.particles[idx].vel - force * dt * (neigh...
code_fim
hard
{ "lang": "rust", "repo": "shadaj/liquid-sim", "path": "/src/world.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn build_spatial_map(&self) -> HashMap<(i32, i32), Vec<usize>> { // build hash map with a list of particles with the same hash value // (key = hash_position, value = list of particles) let mut particle_map = HashMap::<(i32, i32), Vec<usize>>::new(); for (idx, particle) in self.particles...
code_fim
hard
{ "lang": "rust", "repo": "shadaj/liquid-sim", "path": "/src/world.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shadaj/liquid-sim path: /src/world.rs use wasm_bindgen::prelude::*; use crate::particle::*; use std::panic; use std::collections::HashMap; extern crate console_error_panic_hook; #[wasm_bindgen] pub struct World { pub(crate) particles: Vec<Particle>, neighbors: HashMap<(i32, i32), Vec<usiz...
code_fim
hard
{ "lang": "rust", "repo": "shadaj/liquid-sim", "path": "/src/world.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonasbb/serde_with path: /serde_with/src/duplicate_key_impls/last_value_wins.rs use crate::prelude::*; pub trait DuplicateInsertsLastWinsSet<T> { fn new(size_hint: Option<usize>) -> Self; /// Insert or replace the existing value fn replace(&mut self, value: T); } #[cfg(feature = "...
code_fim
hard
{ "lang": "rust", "repo": "jonasbb/serde_with", "path": "/serde_with/src/duplicate_key_impls/last_value_wins.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Hashset already fulfils the contract self.replace(value); } } #[cfg(feature = "indexmap_1")] impl<T, S> DuplicateInsertsLastWinsSet<T> for indexmap_1::IndexSet<T, S> where T: Eq + Hash, S: BuildHasher + Default, { #[inline] fn new(size_hint: Option<usize>) -> Self {...
code_fim
hard
{ "lang": "rust", "repo": "jonasbb/serde_with", "path": "/serde_with/src/duplicate_key_impls/last_value_wins.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andygrove/arrow-rs path: /parquet/src/util/interner.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this f...
code_fim
hard
{ "lang": "rust", "repo": "andygrove/arrow-rs", "path": "/parquet/src/util/interner.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Used to provide a lookup from value to unique value /// /// Note: `S::Key`'s hash implementation is not used, instead the raw entry /// API is used to store keys w.r.t the hash of the strings themselves /// dedup: HashMap<S::Key, (), ()>, storage: S, } impl<S: Storage> In...
code_fim
hard
{ "lang": "rust", "repo": "andygrove/arrow-rs", "path": "/parquet/src/util/interner.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andyyu2004/logic path: /logic-ir/src/subst.rs use crate::*; pub trait Substitute<I: Interner>: Fold<I> { fn subst(self, interner: I, subst: &Subst<I>) -> Self::Folded; <|fim_suffix|>impl<I: Interner> Folder<I> for SubstFolder<'_, I> { fn interner(&self) -> I { self.interner ...
code_fim
medium
{ "lang": "rust", "repo": "andyyu2004/logic", "path": "/logic-ir/src/subst.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<I: Interner, T: Fold<I>> Substitute<I> for T { fn subst(self, interner: I, subst: &Subst<I>) -> Self::Folded { self.fold_with(&mut SubstFolder { interner, subst }).unwrap() } }<|fim_prefix|>// repo: andyyu2004/logic path: /logic-ir/src/subst.rs use crate::*; pub trait Substitute<I: ...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/logic", "path": "/logic-ir/src/subst.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<I: Interner> Subst<I> { pub fn apply<T: Fold<I>>(&self, interner: I, value: T) -> T::Folded { value.subst(interner, self) } } impl<I: Interner, T: Fold<I>> Substitute<I> for T { fn subst(self, interner: I, subst: &Subst<I>) -> Self::Folded { self.fold_with(&mut SubstFolde...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/logic", "path": "/logic-ir/src/subst.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> FNetEncoder { layers, output_hidden_states, } } pub fn forward_t(&self, hidden_states: &Tensor, train: bool) -> FNetEncoderOutput { let mut all_hidden_states: Option<Vec<Tensor>> = if self.output_hidden_states { Some(vec![]) } el...
code_fim
hard
{ "lang": "rust", "repo": "guillaume-be/rust-bert", "path": "/src/models/fnet/encoder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guillaume-be/rust-bert path: /src/models/fnet/encoder.rs // Copyright 2021 Google Research // Copyright 2020-present, the HuggingFace Inc. team. // Copyright 2021 Guillaume Becquin // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complianc...
code_fim
hard
{ "lang": "rust", "repo": "guillaume-be/rust-bert", "path": "/src/models/fnet/encoder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for layer_index in 0..config.num_hidden_layers { layers.push(FNetLayer::new(&p_layers / layer_index, config)); } let output_hidden_states = config.output_hidden_states.unwrap_or(false); FNetEncoder { layers, output_hidden_states, ...
code_fim
hard
{ "lang": "rust", "repo": "guillaume-be/rust-bert", "path": "/src/models/fnet/encoder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: longfangsong/union_type path: /test/main.rs #[macro_use] extern crate union_type; use std::convert::TryInto; use std::fmt::Display; #[derive(Debug, Clone)] struct A(String); impl A { fn f(&self, a: i32) -> i32 { <|fim_suffix|>union_type! { #[derive(Debug, Clone)] enum C { ...
code_fim
hard
{ "lang": "rust", "repo": "longfangsong/union_type", "path": "/test/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> format!("{}:{}", self.0, t) } } union_type! { #[derive(Debug, Clone)] enum C { A, B } impl C { fn f(&self, a: i32) -> i32; fn g<T: Display>(&self, t: T) -> String; } } fn main() { let a = A("abc".to_string()); let mut c: C = a.into(...
code_fim
hard
{ "lang": "rust", "repo": "longfangsong/union_type", "path": "/test/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> println!("from B {}", a + self.0); a + self.0 } fn g<T: Display>(&self, t: T) -> String { format!("{}:{}", self.0, t) } } union_type! { #[derive(Debug, Clone)] enum C { A, B } impl C { fn f(&self, a: i32) -> i32; fn g<T:...
code_fim
medium
{ "lang": "rust", "repo": "longfangsong/union_type", "path": "/test/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns a random number within a range. /// /// # Examples /// /// ``` /// # use pix_engine::prelude::*; /// let x = random!(); // x will range from (0.0..1.0] /// assert!(x >= 0.0 && x < 1.0); /// /// let x = random!(100); // x will range from (0..100] /// assert!(x >= 0 && x < 100); /// let y = rand...
code_fim
hard
{ "lang": "rust", "repo": "lukexor/pix-engine", "path": "/src/math.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (mut n1, mut n2, mut n3); let scaled_cosine = |i: f64| 0.5 * (1.0 - (i - PI).cos()); let perlin_octaves = 4; // default to medium smooth let perlin_amp_falloff = 0.5; // 50% reduction/octave for _ in 0..perlin_octaves { let mut of = xi + (yi << PERLIN_YWRAPB) + (zi << PER...
code_fim
hard
{ "lang": "rust", "repo": "lukexor/pix-engine", "path": "/src/math.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lukexor/pix-engine path: /src/math.rs //! Math functions and constants. use crate::prelude::Vector; use num_traits::{ Float as FloatT, Num as NumT, NumAssignOps, NumAssignRef, NumCast, NumOps, NumRef, }; use rand::{self, distributions::uniform::SampleUniform, Rng}; use std::ops::{AddAssign,...
code_fim
hard
{ "lang": "rust", "repo": "lukexor/pix-engine", "path": "/src/math.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match stmt { ir::Stmt::Expr { target, mut expr } => { match self.prev_expr_if_moving_to_next.take() { Some(prev_expr) => { match &expr { ir::Expr::Read { source: _ } => {} ...
code_fim
hard
{ "lang": "rust", "repo": "erikdesjardins/jsssa", "path": "/src/opt/forward.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn wrap_scope<R>( &mut self, ty: &ScopeTy, block: ir::Block, enter: impl FnOnce(&mut Self, ir::Block) -> R, ) -> R { if let ScopeTy::Toplevel = ty { let mut prev_ref_if_single_use = None; visit_with(&block, |stmt: &ir::Stmt| { ...
code_fim
hard
{ "lang": "rust", "repo": "erikdesjardins/jsssa", "path": "/src/opt/forward.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erikdesjardins/jsssa path: /src/opt/forward.rs use std::collections::HashMap; use crate::ir; use crate::ir::traverse::{visit_with, Folder, ScopeTy}; /// Forward `ir::Expr::Read` to the source SSA ref. /// /// Does not profit from multiple passes. /// Does not profit from DCE running first; may...
code_fim
hard
{ "lang": "rust", "repo": "erikdesjardins/jsssa", "path": "/src/opt/forward.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/24424.rs trait Trait1<'l0, T0> {} trait Trait0<'l0> {} impl <'l0, 'l1, T0> Trait1<<|fim_suffix|>l0>, T0 : Trait0<'l1> {} fn main() {}<|fim_middle|>'l0, T0> for bool where T0 : Trait0<'
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/glacier", "path": "/fixed/24424.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>l0>, T0 : Trait0<'l1> {} fn main() {}<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/24424.rs trait Trait1<'l0, T0> {} trait Trait0<'l0> {} impl <'l0, 'l1, T0> Trait1<<|fim_middle|>'l0, T0> for bool where T0 : Trait0<'
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/glacier", "path": "/fixed/24424.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xanewok/tailed path: /src/lib.rs //! Supposedly a "safe" way to create a custom DSTs with flexible array members. //! //! Currently, the main usage is FFI that uses a single allocation to return //! both the API-consumable data and the backing storage for it at the same, //! think inline strings...
code_fim
hard
{ "lang": "rust", "repo": "Xanewok/tailed", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let slice = unsafe { slice::from_raw_parts_mut(data as *mut (), count) }; slice as *mut [()] as *mut Self } } impl<H> Tailed<mem::MaybeUninit<H>, [u8]> { /// Creates a Tailed view into a slice of bytes. /// ``` /// #![feature(maybe_uninit_extra)] /// # use tailed::Tail...
code_fim
hard
{ "lang": "rust", "repo": "Xanewok/tailed", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gurjeet/zenith-clone path: /zenith_utils/src/zid.rs use std::{fmt, str::FromStr}; use hex::FromHex; use rand::Rng; use serde::{Deserialize, Serialize}; // Zenith ID is a 128-bit random ID. // Used to represent various identifiers. Provides handy utility methods and impls. #[derive(Debug, Clone...
code_fim
hard
{ "lang": "rust", "repo": "gurjeet/zenith-clone", "path": "/zenith_utils/src/zid.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 .0 } } impl fmt::Display for $t { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } }; } /// Zenith timeline IDs are different from PostgreSQL timeline /// IDs. They serve a...
code_fim
hard
{ "lang": "rust", "repo": "gurjeet/zenith-clone", "path": "/zenith_utils/src/zid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(s: &str) -> Result<$t, Self::Err> { let value = ZId::from_str(s)?; Ok($t(value)) } } impl From<[u8; 16]> for $t { fn from(b: [u8; 16]) -> Self { $t(ZId::from(b)) } } ...
code_fim
hard
{ "lang": "rust", "repo": "gurjeet/zenith-clone", "path": "/zenith_utils/src/zid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> <Registration as Evented>::deregister(&self.registration, poll) } } fn main() { let localhost = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); // Create and bind the socket let socket = UdpSocket::bind(&SocketAddr::new(localhost, ECHO_PORT)).unwrap(); // Set up mio polling let...
code_fim
hard
{ "lang": "rust", "repo": "goriunov/tokio-aio-examples", "path": "/src/bin/mio-mixed.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goriunov/tokio-aio-examples path: /src/bin/mio-mixed.rs // This program demonstrates how a single mio instance can be used to // receive both system events (e.g. file descriptor events) and // non-system events (e.g. events sourced on user-space threads other // than the thread running the mio p...
code_fim
hard
{ "lang": "rust", "repo": "goriunov/tokio-aio-examples", "path": "/src/bin/mio-mixed.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let localhost = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); // Create and bind the socket let socket = UdpSocket::bind(&SocketAddr::new(localhost, ECHO_PORT)).unwrap(); // Set up mio polling let poll = Poll::new().unwrap(); let mut events = Events::with_capacity(MAX_EVENTS); pol...
code_fim
hard
{ "lang": "rust", "repo": "goriunov/tokio-aio-examples", "path": "/src/bin/mio-mixed.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// This sends a ping, and blocks execution until it either times out, or a ping is received. /// It immediately destroys all of its temporary allocated connections to the Net crate upon exit, /// so it does not return a Ping object. pub fn blocking(remote: IpAddr) -> (bool, u32) { ...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/net/src/protocols/ping.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betrusted-io/xous-core path: /services/net/src/protocols/ping.rs use std::net::IpAddr; use std::sync::Arc; use std::thread; use std::thread::JoinHandle; use core::sync::atomic::{AtomicBool, AtomicU32, Ordering}; use xous::{Message, msg_scalar_unpack, send_message}; use xous_ipc::Buffer; use cra...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/net/src/protocols/ping.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let memory = match address { _ if FLASH_START <= address && address < self.flash_end => Memory::Flash, _ if self.eeprom_start <= address && address < self.eeprom_end => Memory::Eeprom, _ => Memory::Other, }; if memory.is_other() { pa...
code_fim
hard
{ "lang": "rust", "repo": "electroCutie/stm32l0xx-hal", "path": "/src/flash.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: electroCutie/stm32l0xx-hal path: /src/flash.rs //! Interface to the FLASH peripheral //! //! See STM32L0x2 reference manual, chapter 3. use cortex_m::interrupt; use crate::{ pac::{self, flash::acr::LATENCY_A}, rcc::Rcc, }; /// The first address of flash memory pub const FLASH_START: u...
code_fim
hard
{ "lang": "rust", "repo": "electroCutie/stm32l0xx-hal", "path": "/src/flash.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> result } fn verify_address(&self, address: *mut u32) -> Memory { let address = address as u32; let memory = match address { _ if FLASH_START <= address && address < self.flash_end => Memory::Flash, _ if self.eeprom_start <= address && address < sel...
code_fim
hard
{ "lang": "rust", "repo": "electroCutie/stm32l0xx-hal", "path": "/src/flash.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> if lefti < left.len() && righti < right.len() { if left[lefti] < right[righti] { acc.push(left[lefti]); lefti += 1; continue; } else { acc.push(right[righti]); righti += 1; conti...
code_fim
hard
{ "lang": "rust", "repo": "nambrot/algorithms", "path": "/rust/src/mergesort.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if lefti == left.len() { acc.push(right[righti]); righti += 1; continue; } if righti == right.len() { acc.push(left[lefti]); lefti += 1; continue; } } } // Problematic is that Rust does not have ...
code_fim
hard
{ "lang": "rust", "repo": "nambrot/algorithms", "path": "/rust/src/mergesort.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nambrot/algorithms path: /rust/src/mergesort.rs use std; pub fn sort(x: &Vec<u32>) -> Vec<u32> { iter_sort(x) } pub fn iter_sort(x: &Vec<u32>) -> Vec<u32> { let mut result: Vec<u32> = x.clone(); let mut step = 1; while step < x.len() { let base = result.clone(); ...
code_fim
hard
{ "lang": "rust", "repo": "nambrot/algorithms", "path": "/rust/src/mergesort.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let t = ppga::Translator::new(&v.position); let m = t.mul_rotor(&rotor).normalize(); Self { position: v.position, uv: v.uv, cayley_motor: m.cayley_ln().into(), } } } #[repr(C)] #[derive(Debug)] pub struct OuterMotor { pub positio...
code_fim
hard
{ "lang": "rust", "repo": "pvdklei/thesis", "path": "/src/vertices.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pvdklei/thesis path: /src/vertices.rs use pgl::vao::HasVertexAttributes; use pgl::GlslDType; #[repr(C)] #[derive(Debug)] pub struct All { pub position: [f32; 3], pub uv: [f32; 2], pub normal: [f32; 3], pub tangent: [f32; 3], pub bitangent: [f32; 3], pub rotor: [f32; 4], ...
code_fim
hard
{ "lang": "rust", "repo": "pvdklei/thesis", "path": "/src/vertices.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let rotor = ppga::Rotor::from_base( &tangent.normalize().into(), &bitangent.normalize().into(), &normal.normalize().into(), ) .normalize() .into(); let t = ppga::Translator::new(&v.position); let m = t.mul_rotor(&rotor).n...
code_fim
hard
{ "lang": "rust", "repo": "pvdklei/thesis", "path": "/src/vertices.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wezm/cc2650 path: /src/trng/irqflagclr.rs #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::IRQFLAGCLR { #[doc = r" Writes to the register"] #[inline] pub fn write<F>(&self, f: F) where F: FnOnce(&mut W) -> &mut W, { let m...
code_fim
hard
{ "lang": "rust", "repo": "wezm/cc2650", "path": "/src/trng/irqflagclr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> raw bits to the register"] #[inline] pub unsafe fn bits(&mut self, bits: u32) -> &mut Self { self.bits = bits; self } #[doc = "Bits 2:31 - Software should not rely on the value of a reserved. Writing any other value than the reset value may result in undefined behavior."] ...
code_fim
hard
{ "lang": "rust", "repo": "wezm/cc2650", "path": "/src/trng/irqflagclr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/rayon-1.3.0/src/delegate.rs //! Macros for delegating newtype iterators to inner types. // Note: these place `impl` bounds at the end, as token gobbling is the only way // I know how to consume an arbitrary list of constraints, with `$($arg...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/rayon-1.3.0/src/delegate.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.inner.len() } fn with_producer<CB>(self, callback: CB) -> CB::Output where CB: ProducerCallback<Self::Item> { self.inner.with_producer(callback) } } } }<|fim_prefix|>// repo: gnoliyil/fuchsia ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/rayon-1.3.0/src/delegate.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> where C: Consumer<Self::Item> { self.inner.drive(consumer) } fn len(&self) -> usize { self.inner.len() } fn with_producer<CB>(self, callback: CB) -> CB::Output where CB: ProducerCa...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/rayon-1.3.0/src/delegate.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonas-schievink/jaylink path: /examples/blink.rs //! Uses the functions for controlling individual pin states to toggle them periodically. use jaylink::*; use std::thread::sleep; use std::time::Duration; use structopt::StructOpt; #[derive(StructOpt)] struct Opts { /// Serial number of the ...
code_fim
hard
{ "lang": "rust", "repo": "jonas-schievink/jaylink", "path": "/examples/blink.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> let mut probe = JayLink::open_by_serial(opts.serial.as_deref())?; // Enable power to enable testing all blinky pins without an ext. supply. // Ignore errors since probes may not support this. probe.set_kickstart_power(true).ok(); loop { probe.set_tms(true)?; probe.set...
code_fim
hard
{ "lang": "rust", "repo": "jonas-schievink/jaylink", "path": "/examples/blink.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> loop { probe.set_tms(true)?; probe.set_tdi(true)?; probe.set_reset(true)?; probe.set_trst(true)?; println!("on {} V", probe.read_target_voltage()? as f32 / 1000.0); sleep(Duration::from_millis(500)); probe.set_tms(false)?; probe.set_tdi(...
code_fim
hard
{ "lang": "rust", "repo": "jonas-schievink/jaylink", "path": "/examples/blink.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|>mod http; mod methods; pub mod common; pub mod docker;<|fim_prefix|>// repo: abh1nav/docker-rust path: /src/lib.rs #![comment = "Rust Docker Client"] <|fim_middle|>#![license = "MIT/ASL2"] #![crate_type = "lib"] #![feature (globs, macro_rules)] extern crate collections; extern crate debug; extern cr...
code_fim
medium
{ "lang": "rust", "repo": "abh1nav/docker-rust", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abh1nav/docker-rust path: /src/lib.rs #![comment = "Rust Docker Client"] <|fim_suffix|>pub mod common; pub mod docker;<|fim_middle|>#![license = "MIT/ASL2"] #![crate_type = "lib"] #![feature (globs, macro_rules)] extern crate collections; extern crate debug; extern crate serialize; pub use ...
code_fim
hard
{ "lang": "rust", "repo": "abh1nav/docker-rust", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abh1nav/docker-rust path: /src/lib.rs #![comment = "Rust Docker Client"] #![license = "MIT/ASL2"] #![crate_type = "lib"] <|fim_suffix|>extern crate collections; extern crate debug; extern crate serialize; pub use docker::Docker; mod http; mod methods; pub mod common; pub mod docker;<|fim_m...
code_fim
easy
{ "lang": "rust", "repo": "abh1nav/docker-rust", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alwin-Stockinger/RustyTodo path: /src/review.rs use std::io::stdin; use crate::project::{Project, task::Task}; pub fn review_project(project: &mut Project) -> bool{ println!("\n"); println!("Project name: {}", project.name); let task_string = project.tasks.values().fold(String::...
code_fim
hard
{ "lang": "rust", "repo": "Alwin-Stockinger/RustyTodo", "path": "/src/review.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match cmds.pop(){ Some(arg) => { match arg.as_str() { "new" | "n" => { match cmds.pop(){ Some(task_name) => { project.add_task(Task::new(task_name)) } ...
code_fim
hard
{ "lang": "rust", "repo": "Alwin-Stockinger/RustyTodo", "path": "/src/review.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn handle_task(project:&mut Project, mut cmds: Vec<String>){ cmds.reverse(); match cmds.pop(){ Some(arg) => { match arg.as_str() { "new" | "n" => { match cmds.pop(){ Some(task_name) => { pr...
code_fim
hard
{ "lang": "rust", "repo": "Alwin-Stockinger/RustyTodo", "path": "/src/review.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/cargo path: /src/cargo/core/resolver/resolve.rs use super::encode::Metadata; use crate::core::dependency::DepKind; use crate::core::{Dependency, PackageId, PackageIdSpec, Summary, Target}; use crate::util::errors::CargoResult; use crate::util::interning::InternedString; use crate::util...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/src/cargo/core/resolver/resolve.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub fn specs_to_ids(&self, specs: &[PackageIdSpec]) -> CargoResult<Vec<PackageId>> { specs.iter().map(|s| s.query(self.iter())).collect() } pub fn unused_patches(&self) -> &[PackageId] { &self.unused_patches } pub fn checksums(&self) -> &HashMap<PackageId, Option<Stri...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/src/cargo/core/resolver/resolve.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub fn deps_not_replaced( &self, pkg: PackageId, ) -> impl Iterator<Item = (PackageId, &HashSet<Dependency>)> { self.graph.edges(&pkg).map(|(id, deps)| (*id, deps)) } pub fn replacement(&self, pkg: PackageId) -> Option<PackageId> { self.replacements.get(&pk...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/src/cargo/core/resolver/resolve.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>pub fn scroll_to() { // scroll to #work-history and expand let hash = get_hash(); if hash == "work-history" { let input_el = document().query_selector("#cv-toggle").unwrap(); let scroll_to_el = document().query_selector(&format!("#{}", hash)).unwrap(); if input_el.is_some() && scroll_to_...
code_fim
hard
{ "lang": "rust", "repo": "alienfacepalm/www", "path": "/src/work_history.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alienfacepalm/www path: /src/work_history.rs use util::get_hash; use stdweb::traits::*; use stdweb::unstable::TryInto; use stdweb::web::{ document, Element }; use stdweb::web::event::{ ClickEvent }; fn scroll_into_view(el: Element) { js!{ @(no_return) @{el}.scrollIntoView(); } } ...
code_fim
medium
{ "lang": "rust", "repo": "alienfacepalm/www", "path": "/src/work_history.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sean-purcell/gba-rs path: /src/mmu/gba/save/eeprom.rs use std::cell::RefCell; use std::fmt; use std::ops::{Deref, DerefMut}; use serde::de::{Error, SeqAccess, Visitor}; use serde::ser::SerializeTuple; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use shared::Shared; use io::I...
code_fim
hard
{ "lang": "rust", "repo": "sean-purcell/gba-rs", "path": "/src/mmu/gba/save/eeprom.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut s = serializer.serialize_tuple(MEM_SIZE)?; for val in self.0.iter() { s.serialize_element(val)?; } s.end() } } impl<'de> Deserialize<'de> for EepromMem { fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { s...
code_fim
hard
{ "lang": "rust", "repo": "sean-purcell/gba-rs", "path": "/src/mmu/gba/save/eeprom.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> struct EepromMemVisitor; impl<'de> Visitor<'de> for EepromMemVisitor { type Value = EepromMem; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("EepromMem") } fn visit_seq<A: SeqAccess...
code_fim
hard
{ "lang": "rust", "repo": "sean-purcell/gba-rs", "path": "/src/mmu/gba/save/eeprom.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: draftedus/tangram path: /ui/nested_nav.rs use html::{classes, component, html}; #[component] pub fn NestedNav() { html! { <div class="nested-nav">{children}</div> } } #[component] pub fn NestedNavSection() { html! { <div class="nested-nav-section">{children}</div> } } <|fim_suffix|>#[...
code_fim
medium
{ "lang": "rust", "repo": "draftedus/tangram", "path": "/ui/nested_nav.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[component] pub fn NestedNavItem(href: String, selected: Option<bool>) { let class = classes!("nested_nav_item", selected.map(|_| "nested-nav-selected")); html! { <div class={class}> <a href={href}>{children}</a> </div> } }<|fim_prefix|>// repo: draftedus/tangram path: /ui/nested_nav.rs use ht...
code_fim
hard
{ "lang": "rust", "repo": "draftedus/tangram", "path": "/ui/nested_nav.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize)] struct SearchWine { description: String, } #[derive(Clone, Debug)] struct PicItem { pic_name: String, pic_url: String, embedding: Vec<f32>, } #[derive(Serialize, Deserialize, Debug)] struct WineReviewsItem { id: String, country: String, description: Str...
code_fim
hard
{ "lang": "rust", "repo": "hora-search/hora-site", "path": "/demos/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hora-search/hora-site path: /demos/src/main.rs use actix_web::{get, web, App, HttpResponse, HttpServer, Result}; use hora::core::ann_index::ANNIndex; use rand::{thread_rng, Rng}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use embedding::embeder_client::EmbederClient;...
code_fim
hard
{ "lang": "rust", "repo": "hora-search/hora-site", "path": "/demos/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(HttpResponse::Ok().json(PicSearchResp { resp: resp_list })) } None => Ok(HttpResponse::NotFound().finish()), } } #[get("/cat_random")] async fn cat_random(data: web::Data<ServingData>) -> Result<HttpResponse> { static K: usize = 5; let mut rng = thread_rng(); ...
code_fim
hard
{ "lang": "rust", "repo": "hora-search/hora-site", "path": "/demos/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theseus-os/Theseus path: /kernel/ata/src/lib.rs from the device. const NIEN = 0x02; // all other bits are reserved } } #[allow(dead_code)] /// The possible commands that can be issued to an ATA drive's command port. /// More esoteric commands (nearly a full list) are here: <https://...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/kernel/ata/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.identify_data.user_addressable_sectors != 0 { self.identify_data.user_addressable_sectors as usize } else { self.identify_data.max_48_bit_lba as usize } } } impl BlockIo for AtaDrive { fn block_size(&self) -> usize { SECTOR_SIZE_IN_BYTES } } impl KnownLength for AtaDrive { fn len(&s...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/kernel/ata/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Waits until the bus is ready to transfer data (either read or write). /// This is intended to be used **after** commands have been issued. /// /// This performs a blocking poll that reads the bus's status /// until it is no longer busy and data is ready to be transferred /// (`AtaStatus::BUSY`...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/kernel/ata/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: burrbull/libm path: /src/math/musl/frexp.rs /// Split floating-point number (f64) /// /// All nonzero, normal numbers can be described as `m*2^p`. /// Represents the double *val* as a mantissa *m* and a power of two *p*. /// The resulting mantissa will always be greater than or equal to `0.5`, /...
code_fim
hard
{ "lang": "rust", "repo": "burrbull/libm", "path": "/src/math/musl/frexp.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let e = ee - 0x3fe; y &= 0x_800f_ffff_ffff_ffff; y |= 0x_3fe0_0000_0000_0000; (f64::from_bits(y), e) }<|fim_prefix|>// repo: burrbull/libm path: /src/math/musl/frexp.rs /// Split floating-point number (f64) /// /// All nonzero, normal numbers can be described as `m*2^p`. /// Represents th...
code_fim
hard
{ "lang": "rust", "repo": "burrbull/libm", "path": "/src/math/musl/frexp.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mpression")] pub mod compression; mod internal;<|fim_prefix|>// repo: SamHDev/tycho path: /src/into/mod.rs pub mod ident; pub(crate) mod element; pub(crat<|fim_middle|>e) mod encode; pub mod value; pub(crate) mod display; pub(crate) mod decode; #[cfg(feature="co
code_fim
medium
{ "lang": "rust", "repo": "SamHDev/tycho", "path": "/src/into/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SamHDev/tycho path: /src/into/mod.rs pub mod ident; pub(crate) mod element; pub(crat<|fim_suffix|>mpression")] pub mod compression; mod internal;<|fim_middle|>e) mod encode; pub mod value; pub(crate) mod display; pub(crate) mod decode; #[cfg(feature="co
code_fim
medium
{ "lang": "rust", "repo": "SamHDev/tycho", "path": "/src/into/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let query = DatabaseImpl::default(); query.memoized_a(); } #[test] #[should_panic(expected = "cycle detected")] fn cycle_volatile() { let query = DatabaseImpl::default(); query.volatile_a(); }<|fim_prefix|>// repo: guanqun/salsa path: /tests/cycles.rs #[salsa::database(GroupStruct)] #[de...
code_fim
hard
{ "lang": "rust", "repo": "guanqun/salsa", "path": "/tests/cycles.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guanqun/salsa path: /tests/cycles.rs #[salsa::database(GroupStruct)] #[derive(Default)] struct DatabaseImpl { runtime: salsa::Runtime<DatabaseImpl>, } impl salsa::Database for DatabaseImpl { fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> { &self.runtime } } #[sals...
code_fim
hard
{ "lang": "rust", "repo": "guanqun/salsa", "path": "/tests/cycles.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn memoized_b(db: &impl Database) -> () { db.memoized_a() } fn volatile_a(db: &impl Database) -> () { db.salsa_runtime().report_untracked_read(); db.volatile_b() } fn volatile_b(db: &impl Database) -> () { db.salsa_runtime().report_untracked_read(); db.volatile_a() } #[test] #[shoul...
code_fim
medium
{ "lang": "rust", "repo": "guanqun/salsa", "path": "/tests/cycles.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }