text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> Image { data, width, height, } } pub fn get_color(&self, x: u16, y: u16) -> Color { return self.data[y as usize][x as usize].clone(); } pub fn set_color(&mut self, x: u16, y: u16, color: Color) { return self.data[y as usiz...
code_fim
hard
{ "lang": "rust", "repo": "manueldeval/rust_ray", "path": "/src/ray/src/image.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manueldeval/rust_ray path: /src/ray/src/image.rs use crate::color::Color; pub struct Image { data: Vec<Vec<Color>>, width: u16, height: u16, } <|fim_suffix|> pub fn width(&self) -> u16 { self.width } pub fn height(&self) -> u16 { self.height } }<|fim...
code_fim
hard
{ "lang": "rust", "repo": "manueldeval/rust_ray", "path": "/src/ray/src/image.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> file::mkdir(&path); for (i, example) in children.iter().enumerate() { let tx = tx.clone(); let prefix = if prefix.chars().all(|c| c.is_whitespace()) { format!("{}", id) } else { ...
code_fim
hard
{ "lang": "rust", "repo": "XadillaX/zh-rust-by-example", "path": "/src/example.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XadillaX/zh-rust-by-example path: /src/example.rs use file; use markdown::Markdown; use rustc_serialize::{Decodable,json}; use std::iter::AdditiveIterator; use std::iter::repeat; use std::sync::mpsc; #[derive(RustcDecodable)] pub struct Example { children: Option<Vec<Example>>, id: Stri...
code_fim
hard
{ "lang": "rust", "repo": "XadillaX/zh-rust-by-example", "path": "/src/example.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> macro_rules! rounds4 { ($h0:ident, $h1:ident, $wk:expr, $i:expr) => { sha1_digest_round_x4($h0, sha1_first_half($h1, $wk), $i) }; } // Rounds 0..20 let mut h0 = u32x4(state[0], state[1], state[2], state[3]); let mut w0 = u32x4(block[0], block[1], block[2], ...
code_fim
hard
{ "lang": "rust", "repo": "buttercup/rust-crypto-wasm", "path": "/src/sha1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: buttercup/rust-crypto-wasm path: /src/sha1.rs ndardPadding, }; use digest::Digest; use simd::u32x4; const STATE_LEN: usize = 5; const BLOCK_LEN: usize = 16; const K0: u32 = 0x5A827999u32; const K1: u32 = 0x6ED9EBA1u32; const K2: u32 = 0x8F1BBCDCu32; const K3: u32 = 0xCA62C1D6u32; /// Not an i...
code_fim
hard
{ "lang": "rust", "repo": "buttercup/rust-crypto-wasm", "path": "/src/sha1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> d = d .wrapping_add(e.rotate_left(5)) .wrapping_add(bool3ary_232!(a, b, c)) .wrapping_add(u); a = a.rotate_left(30); c = c .wrapping_add(d.rotate_left(5)) .wrapping_add(bool3ary_232!(e, a, b)) .wrapping_add(v); e = e.rotate_left(30); b ...
code_fim
hard
{ "lang": "rust", "repo": "buttercup/rust-crypto-wasm", "path": "/src/sha1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> m.add_wrapped(wrap_pyfunction!(hello_from_rust))?; m.add_wrapped(wrap_pyfunction!(count_words_rust))?; Ok(()) }<|fim_prefix|>// repo: mulhod/awesome_rust_extensions path: /awesome_package_dev/src/lib.rs use std::collections::HashMap; use std::fs::File; use std::io::Read; use pyo3::prelude::*;...
code_fim
medium
{ "lang": "rust", "repo": "mulhod/awesome_rust_extensions", "path": "/awesome_package_dev/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mulhod/awesome_rust_extensions path: /awesome_package_dev/src/lib.rs use std::collections::HashMap; use std::fs::File; use std::io::Read; use pyo3::prelude::*; use pyo3::wrap_pyfunction; #[pyfunction] fn hello_from_rust() { println!("Hello World from Rust!"); } <|fim_suffix|> m.add_wrap...
code_fim
hard
{ "lang": "rust", "repo": "mulhod/awesome_rust_extensions", "path": "/awesome_package_dev/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn init_at(&self) -> Instant { self.init_at } pub async fn choose(&self) -> Result<CountedItem<Channel>, TonicError> { let channel = self.pool.lock().choose(); let channel = match channel { None => { let channel = make_grpc_channel( ...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/api/src/grpc/dynamic_channel_pool.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qdrant/qdrant path: /lib/api/src/grpc/dynamic_channel_pool.rs use std::time::{Duration, Instant}; use parking_lot::Mutex; use tonic::transport::{Channel, ClientTlsConfig, Error as TonicError, Uri}; use crate::grpc::dynamic_pool::{CountedItem, DynamicPool}; pub async fn make_grpc_channel( ...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/api/src/grpc/dynamic_channel_pool.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn choose(&self) -> Result<CountedItem<Channel>, TonicError> { let channel = self.pool.lock().choose(); let channel = match channel { None => { let channel = make_grpc_channel( self.timeout, self.connection_t...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/api/src/grpc/dynamic_channel_pool.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/pest_meta-2.1.0/src/lib.rs // pest. The Elegant Parser // Copyright (c) 2018 Dragoș Tiselice // // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENS...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/pest_meta-2.1.0/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn unwrap_or_report<T, E>(result: Result<T, E>) -> T where E: IntoIterator, E::Item: Display, { result.unwrap_or_else(|e| { panic!( "grammar error\n\n".to_owned() + &e.into_iter() .map(|error| format!("{}", error)) ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/pest_meta-2.1.0/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[doc(hidden)] pub static UNICODE_PROPERTY_NAMES: &[&str] = &[ /* BINARY */ "ALPHABETIC", "BIDI_CONTROL", "CASE_IGNORABLE", "CASED", "CHANGES_WHEN_CASEFOLDED", "CHANGES_WHEN_CASEMAPPED", "CHANGES_WHEN_LOWERCASED", "CHANGES_WHEN_TITLECASED", "CHANGES_WHEN_UPPERCASED", ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/pest_meta-2.1.0/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for User { fn fmt(&self, f: &mut Formatter<'_>) -> Result { write!(f, r#" -------->Busca<-------- |id: {} |nome: {} |idade: {} |altura: {} |peso: {} -----------------------"#, self.id, self.name, self.age, self.he...
code_fim
medium
{ "lang": "rust", "repo": "walteralleyz/sys_academia_rust", "path": "/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, r#" -------->Busca<-------- |id: {} |nome: {} |idade: {} |altura: {} |peso: {} -----------------------"#, self.id, self.name, self.age, self.height, self.weight) } }<|fim_prefix|>// repo: walteralleyz/sys_academia_ru...
code_fim
hard
{ "lang": "rust", "repo": "walteralleyz/sys_academia_rust", "path": "/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: walteralleyz/sys_academia_rust path: /src/model.rs use std::fmt::{Display, Formatter, Result}; pub struct User { id: u16, name: String, age: u8, height: f32, weight: f32 } impl User { pub fn new(id: u16, name: String, age: u8, height: f32, weight: f32) -> Self { ...
code_fim
medium
{ "lang": "rust", "repo": "walteralleyz/sys_academia_rust", "path": "/src/model.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scy/advent-of-code path: /2019/src/bin/aoc2019_12.rs use std::collections::HashMap; use std::io::{self, Read}; use num::Integer; use regex::Regex; #[derive(Clone, Copy, Debug, PartialEq)] struct Triple { x: i32, y: i32, z: i32, } impl Triple { fn new(x: i32, y: i32, z: i32) ->...
code_fim
hard
{ "lang": "rust", "repo": "scy/advent-of-code", "path": "/2019/src/bin/aoc2019_12.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { moons } } fn from_string(string: &str) -> Self { Self { moons: string.trim().lines().map(|line| Moon::new(Triple::from_string(&line))).collect() } } fn from_stdin() -> Self { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer); ...
code_fim
hard
{ "lang": "rust", "repo": "scy/advent-of-code", "path": "/2019/src/bin/aoc2019_12.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn do_step(&mut self) { self.apply_gravity(); self.apply_velocity(); } fn do_steps(&mut self, count: u32) { for _ in 0..count { self.do_step(); } } fn total_energy(&self) -> u32 { self.moons.iter().map(|moon| moon.total_energy()).su...
code_fim
hard
{ "lang": "rust", "repo": "scy/advent-of-code", "path": "/2019/src/bin/aoc2019_12.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut descendant_vec = vec![10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]; let len = descendant_vec.len(); quick_sort(&mut descendant_vec, 0, len); assert_eq!(descendant_vec, vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); } #[test] fn not_changed_vec_test() { let mut n...
code_fim
hard
{ "lang": "rust", "repo": "shevtsiv/algos", "path": "/src/sort/quick.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shevtsiv/algos path: /src/sort/quick.rs pub fn quick_sort<T: PartialOrd>(mut array: &mut [T], start: usize, end: usize) { if start >= end { return; } let mid = partition(&mut array, start, end); quick_sort(&mut array, start, mid); quick_sort(&mut array, mid + 1, end);...
code_fim
hard
{ "lang": "rust", "repo": "shevtsiv/algos", "path": "/src/sort/quick.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(PartialOrd, PartialEq, Debug)] struct ExampleStruct { some_string: String } #[test] fn custom_type_elem_test() { let mut custom_type_vec = vec![ ExampleStruct { some_string: String::from("B") }, ExampleStruct { some_string: String::from...
code_fim
hard
{ "lang": "rust", "repo": "shevtsiv/algos", "path": "/src/sort/quick.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn ellipse_with() { assert_eq!(&"Hello, World!".truncate_ellipse_with(3, "---"), "Hel---"); } #[test] fn truncate_to_empty() { assert_eq!(&"Hello, World!".truncate_ellipse(0), ""); } #[test] fn weird_chars() { assert_eq!(&"🇩🇪🇬🇧🇮🇹🇫🇷"...
code_fim
hard
{ "lang": "rust", "repo": "NeoLegends/ellipse", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NeoLegends/ellipse path: /src/lib.rs //! Truncate and ellipse strings in a human-friendly way. //! //! Uses unicode extended grapheme clusters. //! //! # Example //! ``` //! use ellipse::Ellipse; //! //! let input = "🇩🇪🇬🇧🇮🇹🇫🇷"; //! assert_eq!(&input.truncate_ellipse(2), "🇩🇪🇬🇧..."); /...
code_fim
hard
{ "lang": "rust", "repo": "NeoLegends/ellipse", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: martins0n/sandbox path: /codeduplication/src/main.rs mod generated; use generated::bindings; use std::os::unix::ffi::OsStrExt; const EMBEDDING_SIZE: usize = 768; fn main() { let input_ids = ndarray::arr2(&[[0, 6, 2, 1040, 126, 2508, 127, 2 as i64]]); let (batch_size, seq_len) = input_...
code_fim
hard
{ "lang": "rust", "repo": "martins0n/sandbox", "path": "/codeduplication/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let run_options_ptr: *const bindings::OrtRunOptions = std::ptr::null(); let mut output_tensor_ptr: *mut bindings::OrtValue = std::ptr::null_mut(); let output_tensor_ptr_ptr: *mut *mut bindings::OrtValue = &mut output_tensor_ptr; println!("Number of inputs = {:?}", num_input_nodes); l...
code_fim
hard
{ "lang": "rust", "repo": "martins0n/sandbox", "path": "/codeduplication/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kagawaming/ecs40 path: /4/src/lib.rs #[derive(Debug)] pub struct Tree<T> { root: Option<Box<Node<T>>>, } #[derive(Debug)] pub struct Node<T> { key:T, L:Option<Box<Tree<T>>>, R:Option<Box<Tree<T>>>, } impl<T: Ord> Tree<T> { /// Creates an empty tree pub fn new() -> Self {...
code_fim
hard
{ "lang": "rust", "repo": "kagawaming/ecs40", "path": "/4/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the inorder traversal of the tree. pub fn inorder(&self) -> Vec<&T> { let mut v: Vec<&T> = Vec::new(); let mut lv: Vec<&T> = Vec::new(); let mut rv: Vec<&T> = Vec::new(); match self.root { None=>{return v;}, Some(ref k)=>{ ...
code_fim
hard
{ "lang": "rust", "repo": "kagawaming/ecs40", "path": "/4/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[delegatable_trait] #[async_trait] pub trait RlayFilter { fn filter_name(&self) -> &'static str; async fn filter_entities(&self, ctx: FilterContext, entities: Vec<Entity>) -> Vec<bool>; }<|fim_prefix|>// repo: rlay-project/rlay-client path: /rlay-plugin-interface/src/lib.rs pub mod prelude { ...
code_fim
hard
{ "lang": "rust", "repo": "rlay-project/rlay-client", "path": "/rlay-plugin-interface/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rlay-project/rlay-client path: /rlay-plugin-interface/src/lib.rs pub mod prelude { pub use rlay_backend::{BoxFuture, GetEntity, ResolveEntity}; pub use rlay_ontology::ontology::Entity; pub use serde_json::Value; pub use super::FilterContext; pub use super::RlayFilter; } use...
code_fim
hard
{ "lang": "rust", "repo": "rlay-project/rlay-client", "path": "/rlay-plugin-interface/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32h7/src/stm32h747cm4/rcc/ahb3enr.rs elf { variant as u8 != 0 } } #[doc = "Reader of field `MDMAEN`"] pub type MDMAEN_R = crate::R<bool, MDMAEN_A>; impl MDMAEN_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub f...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h747cm4/rcc/ahb3enr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>is enabled"] #[inline(always)] pub fn enabled(self) -> &'a mut W { self.variant(MDMAEN_A::ENABLED) } #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h747cm4/rcc/ahb3enr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn take_payment() { println!("Hello take_payment"); }<|fim_prefix|>// repo: gauravagarwaltal/rust_programming path: /src/restaurant/front_of_house/serving.rs fn take_order() { println!("Hello take_order"); } <|fim_middle|>pub fn serve_order() { take_order(); println!("Hello serve_order")...
code_fim
medium
{ "lang": "rust", "repo": "gauravagarwaltal/rust_programming", "path": "/src/restaurant/front_of_house/serving.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gauravagarwaltal/rust_programming path: /src/restaurant/front_of_house/serving.rs fn take_order() { println!("Hello take_order"); } <|fim_suffix|>fn take_payment() { println!("Hello take_payment"); }<|fim_middle|>pub fn serve_order() { take_order(); println!("Hello serve_order")...
code_fim
medium
{ "lang": "rust", "repo": "gauravagarwaltal/rust_programming", "path": "/src/restaurant/front_of_house/serving.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pot-hot/myopic path: /move-lambda/src/main.rs use lambda_runtime::{error::HandlerError, lambda, Context}; use myopic_brain::negascout::SearchContext; use myopic_brain::{Board, ChessBoard, EvalBoard, SearchParameters}; use serde_derive::{Deserialize, Serialize}; use simple_logger::SimpleLogger; u...
code_fim
hard
{ "lang": "rust", "repo": "pot-hot/myopic", "path": "/move-lambda/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Output payload #[derive(Serialize, Clone)] struct ComputeMoveOutput { #[serde(rename = "bestMove")] best_move: String, #[serde(rename = "depthSearched")] depth_searched: usize, #[serde(rename = "searchDurationMillis")] search_duration_millis: u64, eval: i32, } fn main() ->...
code_fim
hard
{ "lang": "rust", "repo": "pot-hot/myopic", "path": "/move-lambda/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Model { const ATTRACTION_FACTOR_MEAN: f32 = 1.0; const ATTRACTION_FACTOR_STD: f32 = 0.1; const REPULSION_FACTOR_MEAN: f32 = -1.0; const REPULSION_FACTOR_STD: f32 = 0.1; pub fn print_configurations(&self) { for (i, grid) in self.grids.iter().enumerate() { print...
code_fim
hard
{ "lang": "rust", "repo": "aqude/physarum-1", "path": "/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aqude/physarum-1 path: /src/model.rs use crate::{ grid::{combine, Grid, PopulationConfig}, palette::{random_palette, Palette}, }; use rand::{seq::SliceRandom, Rng}; use rand_distr::{Distribution, Normal}; use rayon::prelude::*; use itertools::multizip; use std::f32::consts::TAU; /// A...
code_fim
hard
{ "lang": "rust", "repo": "aqude/physarum-1", "path": "/src/model.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let filename = String::from("tests/cube/anatase.cube"); let cube = Cube {}; let (voxel_origin, grid, atoms, densities) = match cube.read(filename) { Ok(r) => r, Err(e) => panic!("{}", e), }; assert_eq!(voxel_origin, [0.5; 3]); assert_...
code_fim
medium
{ "lang": "rust", "repo": "adam-kerrigan/bader-rs", "path": "/tests/cube.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adam-kerrigan/bader-rs path: /tests/cube.rs #[cfg(test)] mod tests { use bader::io::cube::Cube; use bader::io::FileFormat; const LENGTH_UNITS: f64 = 0.52917721067; const VOLUME_UNITS: f64 = LENGTH_UNITS * LENGTH_UNITS * LENGTH_UNITS; <|fim_suffix|> let filename = String:...
code_fim
medium
{ "lang": "rust", "repo": "adam-kerrigan/bader-rs", "path": "/tests/cube.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut min = f64::MAX; let mut minp = Point{x:0, y:0}; for p in set { let v = *f_score.get(p).or(Some(&f64::MAX)).unwrap(); if v < min { min = v; minp = *p; } } minp } fn construct_path(came_from: &HashMap<Point, Point>, point:...
code_fim
hard
{ "lang": "rust", "repo": "Pilchie/AdventOfCode", "path": "/2021/15/chiton/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> res.reverse(); res } fn adjacent(p: Point, max_x: usize, max_y: usize) -> Vec<Point> { let mut res = Vec::new(); // left if p.x > 0 { res.push(Point { x: p.x - 1, y: p.y }); } // above if p.y > 0 { res.push(Point { x: p.x, y: p.y - 1}); } // rig...
code_fim
hard
{ "lang": "rust", "repo": "Pilchie/AdventOfCode", "path": "/2021/15/chiton/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pilchie/AdventOfCode path: /2021/15/chiton/src/main.rs use std::collections::HashSet; use std::collections::HashMap; fn main() -> Result<(), std::io::Error> { let args: Vec<_> = std::env::args().collect(); let input = std::fs::read_to_string(&args[1])?; let mut risks = HashMap::new...
code_fim
hard
{ "lang": "rust", "repo": "Pilchie/AdventOfCode", "path": "/2021/15/chiton/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alonn24/learnings path: /rustlang/src/adventofcode2019/day1/mod.rs use std::fs; use std::iter::Iterator; mod part1; mod part2; fn get_input() -> Vec<i32> { let contents = fs::read_to_string("./src/adventofcode2019/day1/day1.input") .expect("Something went wrong reading the file"); cont...
code_fim
medium
{ "lang": "rust", "repo": "alonn24/learnings", "path": "/rustlang/src/adventofcode2019/day1/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(3362507, part1::part1(get_input())); } #[test] fn calculate_part2() { assert_eq!(5040874, part2::part2(get_input())); } }<|fim_prefix|>// repo: alonn24/learnings path: /rustlang/src/adventofcode2019/day1/mod.rs use std::fs; use std::iter::Iterator; mod part1; mod part2; fn g...
code_fim
medium
{ "lang": "rust", "repo": "alonn24/learnings", "path": "/rustlang/src/adventofcode2019/day1/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn calculate_part2() { assert_eq!(5040874, part2::part2(get_input())); } }<|fim_prefix|>// repo: alonn24/learnings path: /rustlang/src/adventofcode2019/day1/mod.rs use std::fs; use std::iter::Iterator; mod part1; mod part2; fn get_input() -> Vec<i32> { let contents = fs::read_to_str...
code_fim
medium
{ "lang": "rust", "repo": "alonn24/learnings", "path": "/rustlang/src/adventofcode2019/day1/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> order.set_quantity(rust_form.quantity); order.set_product(refinery::OilProductType::from(rust_form.product_type)); order } } // Convert for passing query results to client impl From<Order> for refinery::OrderRecord { fn from(rust_form: Order) -> Self { let mut prot...
code_fim
hard
{ "lang": "rust", "repo": "jsrzx/rust-examples", "path": "/cli-clap-grpc-pingcap-db-diesel/workspace/models/convert.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jsrzx/rust-examples path: /cli-clap-grpc-pingcap-db-diesel/workspace/models/convert.rs use crate::orders::{Order, OrderForm}; use crate::schema::OilProductEnum; use chrono::NaiveDateTime; use protos::refinery; impl From<refinery::OilProductType> for OilProductEnum { fn from(proto_form: refi...
code_fim
hard
{ "lang": "rust", "repo": "jsrzx/rust-examples", "path": "/cli-clap-grpc-pingcap-db-diesel/workspace/models/convert.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut proto_timestamp = protobuf::well_known_types::Timestamp::new(); proto_timestamp.set_seconds(rust_form.received_time.timestamp()); proto_timestamp.set_nanos(rust_form.received_time.timestamp_nanos() as i32); let mut proto_form = refinery::OrderRecord::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "jsrzx/rust-examples", "path": "/cli-clap-grpc-pingcap-db-diesel/workspace/models/convert.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LorenzSelv/dspa-project path: /src/kafka/source.rs use timely::dataflow::channels::pushers::Tee; use timely::dataflow::operators::generic::OutputHandle; use timely::dataflow::operators::Capability; use timely::dataflow::{Scope, Stream}; use timely::Data; use rdkafka::consumer::{BaseConsumer, Co...
code_fim
hard
{ "lang": "rust", "repo": "LorenzSelv/dspa-project", "path": "/src/kafka/source.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Repeatedly interrogate Kafka for [u8] messages. // Cease only when Kafka stops returning new data. // Could cease earlier, if we had a better policy. while let Some(result) = consumer.poll(0) { // If valid data back fro...
code_fim
hard
{ "lang": "rust", "repo": "LorenzSelv/dspa-project", "path": "/src/kafka/source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_timetable(&self, line_id : &str, originator: &str, destination : &str) -> Option<TimeTableResponse> { let req_uri = format!("/line/{}/timetable/{}/to/{}", line_id, originator, destination); let body = self.get(&req_uri); match serde_json::from_str::<TimeTableResponse...
code_fim
hard
{ "lang": "rust", "repo": "melonmochi/tflgtfs", "path": "/src/tfl/client.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let req_uri = format!("https://api.tfl.gov.uk{}?app_id={}&app_key={}", endpoint, self.app_id, self.app_key); let mut body = String::new(); let mut resp = self.client.get(&req_uri) .header(Accept(vec![ qitem(Mime(TopLevel::Application, ...
code_fim
hard
{ "lang": "rust", "repo": "melonmochi/tflgtfs", "path": "/src/tfl/client.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: melonmochi/tflgtfs path: /src/tfl/client.rs use ansi_term::Colour::Red; use hyper::header::{Accept, qitem}; use hyper::mime::{Mime, TopLevel, SubLevel}; use hyper; use serde_json; use std::fs; use std::io::{Read, Write}; use std::path::Path; use std::sync::Arc; use tfl::line::{Line, TimeTableRe...
code_fim
hard
{ "lang": "rust", "repo": "melonmochi/tflgtfs", "path": "/src/tfl/client.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: el-komandante/fifa17-api-rust path: /src/models.rs #[derive(Queryable, RustcDecodable, RustcEncodable)] pub struct User { pub id: i32, pub name: String, pub wins: i32, pub losses: i32, pub elo: i32, pub draws: i32, } <|fim_suffix|>#[derive(Insertable)] #[tab...
code_fim
hard
{ "lang": "rust", "repo": "el-komandante/fifa17-api-rust", "path": "/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Insertable)] #[table_name="games"] pub struct NewGame { pub winner_id: i32, pub loser_id: i32, pub winner_elo: i32, pub loser_elo: i32, pub winner_score: i32, pub loser_score: i32, pub date: i64, pub draw: bool, }<|fim_prefix|>// repo: el-komandante/fifa...
code_fim
hard
{ "lang": "rust", "repo": "el-komandante/fifa17-api-rust", "path": "/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/conditional-compilation/cfg-arg-invalid-9.rs // Test for missing quotes around value, issue #66450. // compile-flags: <|fim_suffix|>ument: `key=value` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/conditional-compilation/cfg-arg-invalid-9.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>propriate for your shell, try 'key="value"' or key=\"value\") fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/conditional-compilation/cfg-arg-invalid-9.rs // Test for missing quotes around value, issue #66450. // compile-flags: --error-format=human --cfg key=value // error-pattern: inva...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/conditional-compilation/cfg-arg-invalid-9.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: virtualgraham/wasm-graph-app path: /tests/graph/iterator/and_test.rs use gizmo_graph_db::graph::iterator::and::{And}; use gizmo_graph_db::graph::iterator::save::{tag}; use gizmo_graph_db::graph::iterator::{Shape, Null, is_null}; use gizmo_graph_db::graph::refs::{Ref, Size}; use gizmo_graph_db::g...
code_fim
hard
{ "lang": "rust", "repo": "virtualgraham/wasm-graph-app", "path": "/tests/graph/iterator/and_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = a.borrow_mut().optimize(); assert!(result.is_some()) } #[test] fn test_and_statistics() { let all = common::Int64::new(100, 300, true); let all2 = common::Int64::new(1, 30000, true); let a = And::new(vec![]); a.borrow_mut().add_sub_iterator(all2); a.borrow_mut()...
code_fim
hard
{ "lang": "rust", "repo": "virtualgraham/wasm-graph-app", "path": "/tests/graph/iterator/and_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Scheduler for Stride { fn new(tasks: Vec<Rc<RefCell<TaskControlBlock>>>) -> Self { let mut scheduler = Self { heap: BinaryHeap::new(), }; for t in tasks.iter() { scheduler.heap.push(*t); } scheduler } fn find_next_task(&self)...
code_fim
hard
{ "lang": "rust", "repo": "buhe/rust_os_study", "path": "/k3/os/src/task/scheduler/stride.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: buhe/rust_os_study path: /k3/os/src/task/scheduler/stride.rs use core::borrow::Borrow; use core::borrow::BorrowMut; use core::cell::RefCell; use super::super::TaskStatus; // use super::super::TASK_MANAGER; use super::Scheduler; use crate::{config::MAX_APP_NUM, task::task::TaskControlBlock}; <|...
code_fim
hard
{ "lang": "rust", "repo": "buhe/rust_os_study", "path": "/k3/os/src/task/scheduler/stride.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if report.histogram.is_none() { BasicStats { response_code, duration, qps, query_total, response_total, query_rate, min_lantency: 0.0, max_lantency: 0.0, ...
code_fim
hard
{ "lang": "rust", "repo": "zhangmingkai4315/snd", "path": "/src/runner/report.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let query: Vec<_> = extension_info .query_type .iter() .map(|a| format!("{}={}", a.key, a.value)) .collect(); let response_code: String = basic_info .response_code .iter() .map(|a| format!("{}={}", a.key, ...
code_fim
hard
{ "lang": "rust", "repo": "zhangmingkai4315/snd", "path": "/src/runner/report.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhangmingkai4315/snd path: /src/runner/report.rs e(v2)) => { if v1 > v2 { Some(v1) } else { Some(v2) } } (Some(v1), None) => Som...
code_fim
hard
{ "lang": "rust", "repo": "zhangmingkai4315/snd", "path": "/src/runner/report.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jstnlef/grumpy_visitors path: /libs/game/src/ecs/systems/mod.rs pub mod missile; pub mod monster; pub mod player; mod action; mod damage_subsystem; mod level; mod net_connection_manager; mod pause; mod state_switcher; mod world_position_transform; mod world_state_subsystem; pub use self::{ ...
code_fim
hard
{ "lang": "rust", "repo": "jstnlef/grumpy_visitors", "path": "/libs/game/src/ecs/systems/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "client")] pub struct GraphicsResourceBundle<'s> { missile_graphics: ReadExpect<'s, MissileGraphics>, meshes: WriteStorageCell<'s, Handle<Mesh>>, materials: WriteStorageCell<'s, Handle<Material>>, } #[cfg(not(feature = "client"))] pub struct GraphicsResourceBundle<'s> { _l...
code_fim
hard
{ "lang": "rust", "repo": "jstnlef/grumpy_visitors", "path": "/libs/game/src/ecs/systems/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn ui() -> impl Widget<String> { druid::widget::TextBox::new().onupdate(|s: &String| println!("{}", s)) }<|fim_prefix|>// repo: nilsmartel/druid-update path: /src/main.rs mod textinput; use textinput::OnUpdate; use druid::{AppLauncher, Widget, WindowDesc}; fn main() { <|fim_middle|> let win = Wi...
code_fim
medium
{ "lang": "rust", "repo": "nilsmartel/druid-update", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nilsmartel/druid-update path: /src/main.rs mod textinput; use textinput::OnUpdate; use druid::{AppLauncher, Widget, WindowDesc}; fn main() { <|fim_suffix|>fn ui() -> impl Widget<String> { druid::widget::TextBox::new().onupdate(|s: &String| println!("{}", s)) }<|fim_middle|> let win = Wi...
code_fim
medium
{ "lang": "rust", "repo": "nilsmartel/druid-update", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Refsa/aoc_2020_rust path: /src/aoc/aoc1.rs use std::io::BufReader; use std::{io::BufRead, fs::File}; pub fn aoc_1(reader: BufReader<File>) -> String { let nums: Vec<u32> = reader .lines() .into_iter() .map(|l|<|fim_suffix|> break; } ...
code_fim
hard
{ "lang": "rust", "repo": "Refsa/aoc_2020_rust", "path": "/src/aoc/aoc1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>r k in j+1..nums.len() { let sum = nums[i] + nums[j] + nums[k]; if sum == 2020 { _val = nums[i] * nums[j] * nums[k]; break; } } } if _val != 0 { ...
code_fim
hard
{ "lang": "rust", "repo": "Refsa/aoc_2020_rust", "path": "/src/aoc/aoc1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match *self { Resource::Account => write!(f, "account"), Resource::OrderInfo => write!(f, "order info"), Resource::UserRoles => write!(f, "user roles"), Resource::Invoice => write!(f, "invoice"), Resource::BillingInfo => write!(f, "billin...
code_fim
medium
{ "lang": "rust", "repo": "SINHASantos/billing", "path": "/src/models/authorization/resource.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SINHASantos/billing path: /src/models/authorization/resource.rs //! Enum for resources available in ACLs use std::fmt; #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Resource { Account, BillingInfo, OrderInfo, UserRoles, Invoice, OrderExchangeRate, PaymentInte...
code_fim
medium
{ "lang": "rust", "repo": "SINHASantos/billing", "path": "/src/models/authorization/resource.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `LDUEN` writer - LDROM Update Enable Bit (Write Protect)\\nLDROM update enable bit.\\nNote: This bit is write protected. Refer to the SYS_REGLCTL register."] pub struct LDUEN_W<'a> { w: &'a mut W, } impl<'a> LDUEN_W<'a> { #[doc = r"Writes `variant` to the fie...
code_fim
hard
{ "lang": "rust", "repo": "samcday/m451", "path": "/pac/src/fmc/fmc_ispctl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samcday/m451 path: /pac/src/fmc/fmc_ispctl.rs -> bool { **self == BS_A::_1 } } impl core::ops::Deref for BS_R { type Target = crate::FieldReader<bool, BS_A>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } #[doc = "Field `BS` writer - Boot Sel...
code_fim
hard
{ "lang": "rust", "repo": "samcday/m451", "path": "/pac/src/fmc/fmc_ispctl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `ISPFF` writer - ISP Fail Flag (Write Protect)\\nThis bit is set by hardware when a triggered ISP meets any of the following conditions:\\nThis bit needs to be cleared by writing 1 to it.\\n(1) APROM writes to itself if APUEN is set to 0.\\n(2) LDROM writes to itself...
code_fim
hard
{ "lang": "rust", "repo": "samcday/m451", "path": "/pac/src/fmc/fmc_ispctl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_signature(&self) -> Signature { self.signature } fn set_signature(&mut self, signature: Signature) { self.signature = signature } } /// Type of the replicated value /// These are labels for values in a record that is associated with `Pubkey` #[derive(PartialEq, Has...
code_fim
hard
{ "lang": "rust", "repo": "luhuimao/morgan", "path": "/core/src/propagationValue.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luhuimao/morgan path: /core/src/propagationValue.rs use crate::connectionInfo::ContactInfo; use bincode::serialize; use morgan_interface::pubkey::Pubkey; use morgan_interface::signature::{Keypair, Signable, Signature}; use morgan_interface::transaction::Transaction; use std::collections::BTreeSe...
code_fim
hard
{ "lang": "rust", "repo": "luhuimao/morgan", "path": "/core/src/propagationValue.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dbartussek/kernel path: /crates/uefi/uefi_loader/src/read_kernel.rs use alloc::vec::Vec; use core::cell::UnsafeCell; use log::*; use uefi::{ prelude::*, proto::media::file::{File, FileAttribute, FileMode, FileType}, }; fn find_protocols<P>(bt: &BootServices) -> Vec<&UnsafeCell<P>> where...
code_fim
hard
{ "lang": "rust", "repo": "dbartussek/kernel", "path": "/crates/uefi/uefi_loader/src/read_kernel.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for fs in file_systems { let fs = unsafe { &mut *fs.get() }; let mut dir = fs.open_volume().unwrap().log(); let mut buffer = Vec::new(); loop { match dir.read_entry(&mut buffer) { Ok(entry) => match entry.log() { Some(en...
code_fim
hard
{ "lang": "rust", "repo": "dbartussek/kernel", "path": "/crates/uefi/uefi_loader/src/read_kernel.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let kernel_file = dir .open(&name, FileMode::Read, attributes) .unwrap() .log(); match kernel_file.into_type().unwrap().log() { ...
code_fim
hard
{ "lang": "rust", "repo": "dbartussek/kernel", "path": "/crates/uefi/uefi_loader/src/read_kernel.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lukasstriebel/differential-dataflow path: /src/operators/join.rs _eq!(extracted[0].1, vec![((0,'a'),1), ((3,'B'),1)]); /// ``` fn join_map<V2: Data, D: Data, R: Fn(&K, &V, &V2)->D+'static>(&self, other: &Collection<G, (K,V2)>, logic: R) -> Collection<G, D>; /// Matches pairs `(key,va...
code_fim
hard
{ "lang": "rust", "repo": "lukasstriebel/differential-dataflow", "path": "/src/operators/join.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where T2: Trace<Key=K,Index=G::Timestamp>+'static, R: Data, RF: Fn(&K,&V,&T2::Value)->R+'static, for<'a> &'a T2: TraceRef<'a,T2::Key,T2::Index,T2::Value> ; } impl<TS: Timestamp, G: Scope<Timestamp=TS>, T: Trace<Index=TS>+'static> JoinArranged<G, T::Key, T::Val...
code_fim
hard
{ "lang": "rust", "repo": "lukasstriebel/differential-dataflow", "path": "/src/operators/join.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let arranged1 = self.arrange_by_key(|k| k.clone(), |x| (VecMap::new(), x)); let arranged2 = other.arrange_by_key(|k| k.clone(), |x| (VecMap::new(), x)); arranged1.join(&arranged2, logic) } fn semijoin_u(&self, other: &Collection<G, K>) -> Collection<G, (K, V)> where K: Unsi...
code_fim
hard
{ "lang": "rust", "repo": "lukasstriebel/differential-dataflow", "path": "/src/operators/join.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( runner().ok("@function map-each($map) {\ \n $values: ();\n\ \n @each $key, $value in $map {\ \n $values: append($values, $value);\ \n }\n\ \n @return $values;\ \n}\n\ \n$map: (foo: bar...
code_fim
medium
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass_closed_issues/issue_577.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/libsass_closed_issues/issue_577.rs //! Tests auto-converted from "sass-spec/spec/libsass-closed-issues/issue_577.hrx" <|fim_suffix|>#[test] fn test() { assert_eq!( runner().ok("@function map-each($map) {\ \n $values: ();\n\ ...
code_fim
medium
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass_closed_issues/issue_577.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qeedquan/challenges path: /leetcode/count-operations-to-obtain-zero.rs /* You are given two non-negative integers num1 and num2. In one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2. For example, if num1 = 5 and num2 = 4, subtract num2 fro...
code_fim
medium
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/leetcode/count-operations-to-obtain-zero.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>*/ fn main() { assert_eq!(operations(2, 3), 3); assert_eq!(operations(10, 10), 1); } fn operations(mut n: usize, mut m: usize) -> usize { let mut c = 0; while n > 0 && m > 0 { if n >= m { n -= m; } else { m -= n; } c += 1; } ...
code_fim
hard
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/leetcode/count-operations-to-obtain-zero.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CaulyKan/leetcode path: /矩阵中的幸运数/src/lib.rs pub struct Solution; impl Solution { pub fn lucky_numbers(matrix: Vec<Vec<i32>>) -> Vec<i32> { let row = matrix.len(); let col = matrix[0].len(); let mut res<|fim_suffix|>[c] { min = matrix[r][c]; ...
code_fim
hard
{ "lang": "rust", "repo": "CaulyKan/leetcode", "path": "/矩阵中的幸运数/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> max = std::cmp::max(max, matrix[r1][min_col]); } if max == min { result.push(max); } } result } }<|fim_prefix|>// repo: CaulyKan/leetcode path: /矩阵中的幸运数/src/lib.rs pub struct Solution; impl Solution { pub fn luc...
code_fim
hard
{ "lang": "rust", "repo": "CaulyKan/leetcode", "path": "/矩阵中的幸运数/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jprendes/whasm path: /whasm/src/grammar/core/array.rs //! This module defines the deserialization of arrays of with 8 or less elements. //! //! A serialized array of size `N` will deserialize `N` elements of the same type. //! The array elements must implement the `Grammar` trait. //! An encode...
code_fim
hard
{ "lang": "rust", "repo": "jprendes/whasm", "path": "/whasm/src/grammar/core/array.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn can_deserialize_empty_array() { let mut iter = [0; 0].iter().copied(); let result: [Byte; 0] = deserialize(&mut iter).unwrap(); assert_eq!(result, [0; 0]); } #[test] fn can_deserialize_4_element_array() { let mut iter = [0x01, 0x02, 0x03, 0x0...
code_fim
hard
{ "lang": "rust", "repo": "jprendes/whasm", "path": "/whasm/src/grammar/core/array.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32f072b-disco path: /examples/panic-ramdump.rs #![no_main] #![no_std] <|fim_suffix|> panic!("Hello world"); }<|fim_middle|>#[allow(unused)] use panic_ramdump; #[allow(unused)] use stm32f072b_disco as board; use cortex_m_rt::entry; #[entry] fn main() -> ! {
code_fim
medium
{ "lang": "rust", "repo": "stm32-rs/stm32f072b-disco", "path": "/examples/panic-ramdump.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32f072b-disco path: /examples/panic-ramdump.rs #![no_main] #![no_std] #[allow(unused)] use panic_ramdump; <|fim_suffix|> panic!("Hello world"); }<|fim_middle|>#[allow(unused)] use stm32f072b_disco as board; use cortex_m_rt::entry; #[entry] fn main() -> ! {
code_fim
medium
{ "lang": "rust", "repo": "stm32-rs/stm32f072b-disco", "path": "/examples/panic-ramdump.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> panic!("Hello world"); }<|fim_prefix|>// repo: stm32-rs/stm32f072b-disco path: /examples/panic-ramdump.rs #![no_main] #![no_std] #[allow(unused)] use panic_ramdump; <|fim_middle|>#[allow(unused)] use stm32f072b_disco as board; use cortex_m_rt::entry; #[entry] fn main() -> ! {
code_fim
medium
{ "lang": "rust", "repo": "stm32-rs/stm32f072b-disco", "path": "/examples/panic-ramdump.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h562/hash/str.rs #[doc = "Register `STR` reader"] pub type R = crate::R<STR_SPEC>; #[doc = "Register `STR` writer"] pub type W = crate::W<STR_SPEC>; #[doc = "Field `NBLW` reader - Number of valid bits in the last word When the last word of the ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h562/hash/str.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>& 0x1f) as u8) } #[doc = "Bit 8 - Digest calculation Writing this bit to 1 starts the message padding using the previously written value of NBLW, and starts the calculation of the final message digest with all the data words written to the input FIFO since the INIT bit was last written to 1. Readi...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h562/hash/str.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let status = command.status().ok().expect("Failed"); match status.code() { Some(0) => { println!("{}", "Finished".green()); } _ => { let formatted = format!("{}{:?}{}", "Failed executing '", actions, "'"); println!("{}", formatted.red()) ...
code_fim
hard
{ "lang": "rust", "repo": "jdiazcano/ocean", "path": "/rust/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }