text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fn get_bytevector(&mut self) -> Result<Located<Datum>> { let leftveccon = self.advance(); debug_assert_eq!(leftveccon.clone().map(|l| l.data), Some(Ok(Token::VecConsIntro))); let pair_location = leftveccon.unwrap().location; let mut bytes = vec![]; return Ok(lo...
code_fim
hard
{ "lang": "rust", "repo": "shadw3002/risp", "path": "/src/processor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: masahiko-ofgp/my-rustlang-warehouse path: /hanoi.rs fn hanoi(n: u8, a: char, b: char, c: char) { <|fim_suffix|> hanoi(3_u8, 'A', 'B', 'C'); }<|fim_middle|> if n > 0 { hanoi(n - 1, a, c, b); println!("{} => {}", a, c); hanoi(n - 1, b, a, c); } } fn main() {
code_fim
medium
{ "lang": "rust", "repo": "masahiko-ofgp/my-rustlang-warehouse", "path": "/hanoi.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { hanoi(3_u8, 'A', 'B', 'C'); }<|fim_prefix|>// repo: masahiko-ofgp/my-rustlang-warehouse path: /hanoi.rs fn hanoi(n: u8, a: char, b: char, c: char) { <|fim_middle|> if n > 0 { hanoi(n - 1, a, c, b); println!("{} => {}", a, c); hanoi(n - 1, b, a, c); } }
code_fim
medium
{ "lang": "rust", "repo": "masahiko-ofgp/my-rustlang-warehouse", "path": "/hanoi.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> window.make_current(); gl::load_with(|s| window.get_proc_address(s)); while !window.should_close() { glfw.poll_events(); unsafe { gl::ClearColor(0.3, 0.3, 0.3, 1.0); gl::Clear(gl::COLOR_BUFFER_BIT); } window.swap_buffers(); } }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "eriksvedang/OpenGlBookInRust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eriksvedang/OpenGlBookInRust path: /src/main.rs extern crate gl; extern crate glfw; use glfw::{Context, OpenGlProfileHint, WindowHint, WindowMode}; fn main() { let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap(); <|fim_suffix|> window.make_current(); gl::load_with(|s| window.g...
code_fim
hard
{ "lang": "rust", "repo": "eriksvedang/OpenGlBookInRust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { gl::ClearColor(0.3, 0.3, 0.3, 1.0); gl::Clear(gl::COLOR_BUFFER_BIT); } window.swap_buffers(); } }<|fim_prefix|>// repo: eriksvedang/OpenGlBookInRust path: /src/main.rs extern crate gl; extern crate glfw; use glfw::{Context, OpenGlProfileHint,...
code_fim
hard
{ "lang": "rust", "repo": "eriksvedang/OpenGlBookInRust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> dp[n as usize] = f1 + f2; // memoize return dp[n as usize]; } #[cfg(test)] mod tests { use super::*; #[test] fn fibonacci_iterative_test() { assert_eq!(fibonacci_iterative(40), 102334155); } #[test] fn fibonacci_recursive_test() { assert_eq!(fibonacci_rec...
code_fim
hard
{ "lang": "rust", "repo": "0xisk/rust-algorithms", "path": "/src/dynamic_programming/fibonacci.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xisk/rust-algorithms path: /src/dynamic_programming/fibonacci.rs /** * Fibonacci Sequence * f[0] = 0 * f[1] = 1 * f[n] = f[n-1] + f[n-2] */ pub fn fibonacci_iterative(n: i64) -> i64 { // O(n) time let mut f: Vec<i64> = vec![0; n as usize + 1]; f[1] = 1; for i in 2..n + 1 {...
code_fim
hard
{ "lang": "rust", "repo": "0xisk/rust-algorithms", "path": "/src/dynamic_programming/fibonacci.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toshinomi/rust_image_proc_edge path: /src/module/gray_scale.rs use image::GenericImageView; use image::GenericImage; use image::DynamicImage; use image::Rgba; // use crate::base_module::common::PixelSumData; // use crate::base_module::common::Pixel; use crate::base_module::common::PixelKind; use...
code_fim
hard
{ "lang": "rust", "repo": "toshinomi/rust_image_proc_edge", "path": "/src/module/gray_scale.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let new_color = [ gray_scale as u8, gray_scale as u8, gray_scale as u8, pixel[PixelKind::Alpha as usize] ]; let pixel: Rgba<u8> = Rgba(new_color); image.put_pixel...
code_fim
hard
{ "lang": "rust", "repo": "toshinomi/rust_image_proc_edge", "path": "/src/module/gray_scale.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (width, height) = image.dimensions(); for y in 0..height { for x in 0..width { let pixel: Rgba<u8> = image.get_pixel(x, y); let gray_scale: u64 = (pixel[PixelKind::Red as usize] as u64 + pixel[PixelKind::Green as usize] as u64 + pixel[PixelK...
code_fim
medium
{ "lang": "rust", "repo": "toshinomi/rust_image_proc_edge", "path": "/src/module/gray_scale.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pronvis/distributed_join_task path: /src/map_reduce.rs use anyhow::anyhow; use std::collections::HashMap; use std::fmt::Debug; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::time::Instant; use tokio::sync::mpsc; use crate::Result; pub async fn run<T: AsRef<str>>( ...
code_fim
hard
{ "lang": "rust", "repo": "pronvis/distributed_join_task", "path": "/src/map_reduce.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Err(anyhow!( "fail to find '{}' or '{}' in '{}' header", first_col_name, second_col_name, header )) } struct DonorInfo { id: String, state: String, } impl DonorInfo { fn from_line(id_index: usize, state_index: usize, line: String) -> Self { let...
code_fim
hard
{ "lang": "rust", "repo": "pronvis/distributed_join_task", "path": "/src/map_reduce.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: valenting/rust-learning path: /tcp-client-server/client.rs use std::io::Writer; use std::io::net::tcp::TcpStream; use std::io::net::ip::{SocketAddr, Ipv4Addr}; use std::io; use std::io::buffered::BufferedReader; <|fim_suffix|> loop { let line = BufferedReader::new(io::stdin()).read_lin...
code_fim
hard
{ "lang": "rust", "repo": "valenting/rust-learning", "path": "/tcp-client-server/client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { let line = BufferedReader::new(io::stdin()).read_line(); match line { Some(s) => connection.write(s.as_bytes()), _ => fail!("error") } } }<|fim_prefix|>// repo: valenting/rust-learning path: /tcp-client-server/client.rs use std::io::Writer; use std:...
code_fim
hard
{ "lang": "rust", "repo": "valenting/rust-learning", "path": "/tcp-client-server/client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m-labs/dslite2svd path: /crates/tm4c129x/src/epi0/ris.rs #[doc = "Reader of register RIS"] pub type R = crate::R<u32, super::RIS>; #[doc = "Reader of field `ERRRIS`"] pub type ERRRIS_R = crate::R<bool, bool>; #[doc = "Reader of field `RDRIS`"] pub type RDRIS_R = crate::R<bool, bool>; #[doc = "Re...
code_fim
hard
{ "lang": "rust", "repo": "m-labs/dslite2svd", "path": "/crates/tm4c129x/src/epi0/ris.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Interrupt Status"] #[inline(always)] pub fn rdris(&self) -> RDRIS_R { RDRIS_R::new(((self.bits >> 1) & 0x01) != 0) } #[doc = "Bit 2 - Write Raw Interrupt Status"] #[inline(always)] pub fn wrris(&self) -> WRRIS_R { WRRIS_R::new(((self.bits >> 2) & 0x01) != 0) } ...
code_fim
hard
{ "lang": "rust", "repo": "m-labs/dslite2svd", "path": "/crates/tm4c129x/src/epi0/ris.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twitter/pelikan path: /src/common/src/signal.rs // Copyright 2021 Twitter, Inc. // Licensed under the Apache License, Version 2.0 // http://www.<|fim_suffix|>] pub enum Signal { FlushAll, Shutdown, }<|fim_middle|>apache.org/licenses/LICENSE-2.0 #[derive(Clone)
code_fim
easy
{ "lang": "rust", "repo": "twitter/pelikan", "path": "/src/common/src/signal.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>] pub enum Signal { FlushAll, Shutdown, }<|fim_prefix|>// repo: twitter/pelikan path: /src/common/src/signal.rs // Copyright 2021 Twitter, Inc. // Licensed under the Apache License, Version 2.0 // http://www.<|fim_middle|>apache.org/licenses/LICENSE-2.0 #[derive(Clone)
code_fim
easy
{ "lang": "rust", "repo": "twitter/pelikan", "path": "/src/common/src/signal.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spwilson2/ertos path: /build.rs fn main() { use std::{env, path::PathBuf}; use std::ffi::OsString; use std::fs; println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-env-changed=TARGET"); <|fim_suffix|> cc::Build::new() .compiler(PathBuf::from("c...
code_fim
hard
{ "lang": "rust", "repo": "spwilson2/ertos", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cc::Build::new() .compiler(PathBuf::from("clang")) .target("riscv64") .files(&entries) .pic(true) .static_flag(true) .shared_flag(false) .flag("-march=rv64gc") // Disable floating point code generation // https://gcc.gnu.org/onlin...
code_fim
hard
{ "lang": "rust", "repo": "spwilson2/ertos", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adriensamson/aoc2019 path: /src/bin/day14.rs fn main() { let input = include_str!("day14input.txt"); step1(input); step2(input); } use regex::Regex; use std::collections::HashMap; use std::str::FromStr; #[macro_use] extern crate lazy_static; pub fn step1(input: &str) { let reac...
code_fim
hard
{ "lang": "rust", "repo": "adriensamson/aoc2019", "path": "/src/bin/day14.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_x_needed_for_y(&self, x: &str, y: &str, ny: usize) -> Option<usize> { let mut needed = HashMap::new(); needed.insert(y, ny); let mut consumed = 0usize; let mut remaining = HashMap::new(); while !needed.is_empty() { let el = *needed.keys().take...
code_fim
hard
{ "lang": "rust", "repo": "adriensamson/aoc2019", "path": "/src/bin/day14.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: petereichinger/kazm path: /libkazm/src/request/mod.rs pub mod header; pub mod method; pub mod uri_parser; #[cfg(test)] mod tests { use std::collections::HashMap; use crate::request::header::HeaderError; use crate::request::uri_parser::{UriParseError, UriValues}; use super::*; ...
code_fim
hard
{ "lang": "rust", "repo": "petereichinger/kazm", "path": "/libkazm/src/request/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(values.path, String::from("/Foo")); assert_eq!(values.parameters, Default::default()); } #[test] fn uri_parser_fails_when_path_is_missing() { let values = UriValues::from("?Foo=Bar").err(); assert_eq!(values, Some(UriParseError::MissingPath)); }...
code_fim
hard
{ "lang": "rust", "repo": "petereichinger/kazm", "path": "/libkazm/src/request/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>; pub use read_range::*; mod seekless; pub use seekless::*;<|fim_prefix|>// repo: MaulingMonkey/io-adapters path: /src/read/_read.rs mod abs_seek_pos; pub(crate) use abs_seek_pos::*; mod into_clone_r<|fim_middle|>al; pub use into_clone_ral::*; mod read_at_cursor; pub use read_at_cursor::*; mo...
code_fim
medium
{ "lang": "rust", "repo": "MaulingMonkey/io-adapters", "path": "/src/read/_read.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaulingMonkey/io-adapters path: /src/read/_read.rs mod abs_seek_pos; pub(crate) use abs_seek_pos::*; mod into_clone_r<|fim_suffix|>ursor::*; mod read_at_ref; pub use read_at_ref::*; mod read_range; pub use read_range::*; mod seekless; pub use seekless::*;<|fim_middle|>al; pub use ...
code_fim
medium
{ "lang": "rust", "repo": "MaulingMonkey/io-adapters", "path": "/src/read/_read.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Separate points into y_left and y_right vectors based on their x-coordinate. Since y is // already sorted by y_axis, y_left and y_right will also be sorted. let mut y_left = vec![]; let mut y_right = vec![]; for point in &points_y { if point.x < mid_x { y_left.pu...
code_fim
hard
{ "lang": "rust", "repo": "TheAlgorithms/Rust", "path": "/src/geometry/closest_points.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheAlgorithms/Rust path: /src/geometry/closest_points.rs use crate::geometry::Point; use std::cmp::Ordering; fn cmp_x(p1: &Point, p2: &Point) -> Ordering { let acmp = f64_cmp(&p1.x, &p2.x); match acmp { Ordering::Equal => f64_cmp(&p1.y, &p2.y), _ => acmp, } } fn f64...
code_fim
hard
{ "lang": "rust", "repo": "TheAlgorithms/Rust", "path": "/src/geometry/closest_points.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let app = clap::App::new("pfind"); let exclude_arg = clap::Arg::with_name("exclude") .short("x") .long("exclude") .help("exclude this term from search"); let case_sensitive_arg = clap::Arg::with_name("case_sensitive_off") .short("i") .help("turn off cas...
code_fim
hard
{ "lang": "rust", "repo": "abhijat/pfinder", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abhijat/pfinder path: /src/main.rs extern crate clap; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate users; use process::Process; use search::Search; use std::io::{Error, ErrorKind, Read}; use utils::is_numeric; use utils::make_error; use utils...
code_fim
hard
{ "lang": "rust", "repo": "abhijat/pfinder", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> path.push("cmdline"); if !path.exists() { return Err(Error::new(ErrorKind::NotFound, format!("missing path: {:?}", path))); } let mut file = std::fs::File::open(path)?; let mut buffer = String::new(); file.read_to_string(&mut buffer)?; Ok(remove_nulls(&buffer)) } fn ...
code_fim
hard
{ "lang": "rust", "repo": "abhijat/pfinder", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(parse(tokens).unwrap(), Stmt::Expr(var("x"))); } #[test] fn test_binary() { // 1+2*(3-4/5) let tokens = vec![ token(Literal, "1"), token(Plus, ""), token(Literal, "2"), token(Star, ""), token(OpenPa...
code_fim
hard
{ "lang": "rust", "repo": "matematikaadit/kalk", "path": "/kalk/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_binary() { // 1+2*(3-4/5) let tokens = vec![ token(Literal, "1"), token(Plus, ""), token(Literal, "2"), token(Star, ""), token(OpenParenthesis, ""), token(Literal, "3"), token(Minus,...
code_fim
hard
{ "lang": "rust", "repo": "matematikaadit/kalk", "path": "/kalk/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matematikaadit/kalk path: /kalk/src/parser.rs /// whenever a unit in the expression is found. Eg. unit a = 3b, it will be set to Some("b") unit_decl_base_unit: Option<String>, } impl Context { pub fn new() -> Self { let mut context = Self { tokens: Vec::new(), ...
code_fim
hard
{ "lang": "rust", "repo": "matematikaadit/kalk", "path": "/kalk/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let start = Instant::now(); sort_fn(list); let end = Instant::now(); let time = (end - start).as_secs_f32(); let time_frac = time.log(1.04).abs().round() as u8; Chalk::new().rgb(255 - time_frac, time_frac, 0).println(&format!("{} ms", time * 1000.0)); } fn run_test(msg: &str, list: Vec<usize>) { ...
code_fim
hard
{ "lang": "rust", "repo": "botahamec/sorting_algos", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // update the min and max if necessary if *item > max {max = *item;} if *item < min {min = *item;} } let mut sorted_list = Vec::with_capacity(list.len()); let mut current = min; // put the elements into a sorted list while current <= max { if let Some(n) = items.get(&current) { for _i in...
code_fim
hard
{ "lang": "rust", "repo": "botahamec/sorting_algos", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: botahamec/sorting_algos path: /src/main.rs use rand::prelude::*; use rand::distributions; use chalk_rs::Chalk; use std::time::Instant; /// performs a out-of-place insertion sort fn insertion_sort<T: PartialOrd + Copy>(list: Vec<T>) -> Vec<T> { /// inserts a single value into the list fn in...
code_fim
hard
{ "lang": "rust", "repo": "botahamec/sorting_algos", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trashbyte/voxelgame path: /src/game.rs //! Main type for the game. `Game::new().run()` runs the game. use std::sync::Arc; use std::sync::atomic::Ordering; use std::thread; use std::time::Instant; use cgmath::Point3; use vulkano::buffer::BufferUsage; use vulkano::instance::Instance; use vulkan...
code_fim
hard
{ "lang": "rust", "repo": "trashbyte/voxelgame", "path": "/src/game.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input_state = InputState::new(); let mut player = Player::new(); player.position = Point3::new(16.0, 32.0, 16.0); player.yaw = 135.0; player.pitch = -30.0; let mut dimension_registry = DimensionRegistry::new(); let dimension = Dimension::new();...
code_fim
hard
{ "lang": "rust", "repo": "trashbyte/voxelgame", "path": "/src/game.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(feature = "pool_tests")] #[test] fn test_get_schema_attrs_from_ledger(){ init!("ledger"); let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS); let (_, schema_attrs ) = get_schema_attrs("i...
code_fim
hard
{ "lang": "rust", "repo": "RustMania/indy-sdk", "path": "/vcx/libvcx/src/schema.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustMania/indy-sdk path: /vcx/libvcx/src/schema.rs ame: String::new(), source_id: String::new(), sequence_num: 0, payment_txn: None, } } } pub trait Schema: ToString { type SchemaType; fn retrieve_schema(submitter_did: &str, schema_id: &s...
code_fim
hard
{ "lang": "rust", "repo": "RustMania/indy-sdk", "path": "/vcx/libvcx/src/schema.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> init!("true"); let data = r#"["name","male"]"#; assert!(create_new_schema("1", "VsKV7grR1BUE29mG2Fm2kX".to_string(), "name".to_string(), "1.0".to_string(), ...
code_fim
hard
{ "lang": "rust", "repo": "RustMania/indy-sdk", "path": "/vcx/libvcx/src/schema.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tiwalun/hifive-flashloader path: /build.rs use std::path::PathBuf; use std::{env, fs}; <|fim_suffix|> let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); println!("cargo:rustc-link-search)={}", out_dir.display()); fs::copy("loader.x", out_dir.join("loader.x")).unwrap(); p...
code_fim
easy
{ "lang": "rust", "repo": "Tiwalun/hifive-flashloader", "path": "/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); println!("cargo:rustc-link-search)={}", out_dir.display()); fs::copy("loader.x", out_dir.join("loader.x")).unwrap(); println!("cargo:rerun-if-changed=loader.x"); }<|fim_prefix|>// repo: Tiwalun/hifive-flashloader path: /build.rs ...
code_fim
easy
{ "lang": "rust", "repo": "Tiwalun/hifive-flashloader", "path": "/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pierremarc/apply path: /mafe/src/main.rs mod piet_cairo; mod render; use apply::{op::OpList, run_map}; use cairo::{Context, Format, ImageSurface, IoError}; use clap::{App, Arg, ArgMatches}; use parser::parse_str; use piet::{ kurbo::{Affine, Vec2}, RenderContext, }; use piet_cairo::Cairo...
code_fim
hard
{ "lang": "rust", "repo": "pierremarc/apply", "path": "/mafe/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.size[0] } fn height(&self) -> f64 { self.size[1] } fn extent_width(&self) -> f64 { self.extent[2] - self.extent[0] } fn extent_height(&self) -> f64 { self.extent[3] - self.extent[1] } fn south(&self) -> f64 { self.extent[1] ...
code_fim
hard
{ "lang": "rust", "repo": "pierremarc/apply", "path": "/mafe/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgarvin/threadstack path: /src/lib.rs ! feature](https://docs.racket-lang.org/reference/parameters.html) //! from Racket. //! //! The general idea is the following. Many applications have //! "context" variables that are needed by almost every module in the //! application. It is extremely tedio...
code_fim
hard
{ "lang": "rust", "repo": "jgarvin/threadstack", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgarvin/threadstack path: /src/lib.rs cal storage. //! //! Inspired by the [parameters //! feature](https://docs.racket-lang.org/reference/parameters.html) //! from Racket. //! //! The general idea is the following. Many applications have //! "context" variables that are needed by almost every m...
code_fim
hard
{ "lang": "rust", "repo": "jgarvin/threadstack", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[doc(hidden)] pub trait IsThreadStack<T> { fn get_inner(&self) -> &ThreadStackInner<T>; unsafe fn push_value_impl<'a>(&self, new_value: &'a T) -> ThreadStackGuard<'a, T> { let inner = self.get_inner(); let top: &mut RelPtr<T> = &mut *inner.top.get(); let old_top: RelPtr<T...
code_fim
hard
{ "lang": "rust", "repo": "jgarvin/threadstack", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adarqui/small-bites path: /rust/iteration.rs fn while_loop(y: int) -> int { println("while_loop:"); let mut x: int = 0; while x < y { println!("\tx = {}", x); x += 1; <|fim_suffix|> let mut n = 0; while n < v.len() { op(v[n]); n+=1; } } fn closure_iteration(x: &[int]) -> (int,int)...
code_fim
hard
{ "lang": "rust", "repo": "adarqui/small-bites", "path": "/rust/iteration.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { while_loop(5); for_loop(100,3); let mut a: int = 0; let mut b: int = 0; closure_iteration([1,2,3,4,5,6,7]); }<|fim_prefix|>// repo: adarqui/small-bites path: /rust/iteration.rs fn while_loop(y: int) -> int { println("while_loop:"); let mut x: int = 0; while x < y { println!("\tx = ...
code_fim
hard
{ "lang": "rust", "repo": "adarqui/small-bites", "path": "/rust/iteration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut n = 0; while n < v.len() { op(v[n]); n+=1; } } fn closure_iteration(x: &[int]) -> (int,int) { println("closure_iteration:"); let mut n: int = 0; let mut tot: int = 0; do each(x) |i| { //n = n + i; n=n+1; tot = tot + i; println!("\ti={}",i); } println!("\tn={}, tot={}",n,tot);...
code_fim
medium
{ "lang": "rust", "repo": "adarqui/small-bites", "path": "/rust/iteration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spacemeshos/svm path: /crates/host/codec/src/section/sections/data.rs //! //! # `Data Section` //! //! +------------+----------------+-----------+ //! | | | | //! | #Layouts | Layout #1 | ... | //! | (2 bytes) | (see `Layout`) | | //! |...
code_fim
hard
{ "lang": "rust", "repo": "spacemeshos/svm", "path": "/crates/host/codec/src/section/sections/data.rs", "mode": "psm", "license": "LicenseRef-scancode-free-unknown", "source": "the-stack-v2" }
<|fim_suffix|> if var_count > 0 { first_var_id = u32::decode(reader)?; // Decoding each `var` for _ in 0..var_count { let byte_size = decode_var_byte_size(reader)?; byte_sizes.push(byte_size); ...
code_fim
hard
{ "lang": "rust", "repo": "spacemeshos/svm", "path": "/crates/host/codec/src/section/sections/data.rs", "mode": "spm", "license": "LicenseRef-scancode-free-unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nlhepler/riaw path: /src/sphere.rs use crate::prelude::{vec3, HitRecord, Hittable, Material, Ray, Vec3, AABB}; pub struct Sphere { pub center: Vec3, pub radius: f32, pub material: Box<dyn Material>, } impl Sphere { pub fn new(center: Vec3, radius: f32, material: Box<dyn Materia...
code_fim
hard
{ "lang": "rust", "repo": "nlhepler/riaw", "path": "/src/sphere.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(AABB::new( self.center - vec3![self.radius, self.radius, self.radius], self.center + vec3![self.radius, self.radius, self.radius], )) } fn into_box(self) -> Box<dyn Hittable + Sync> { Box::new(self) as Box<dyn Hittable + Sync> } } pub stru...
code_fim
hard
{ "lang": "rust", "repo": "nlhepler/riaw", "path": "/src/sphere.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let box0 = AABB::new( self.center(t0) - vec3![self.radius, self.radius, self.radius], self.center(t0) + vec3![self.radius, self.radius, self.radius], ); let box1 = AABB::new( self.center(t1) - vec3![self.radius, self.radius, self.radius], ...
code_fim
hard
{ "lang": "rust", "repo": "nlhepler/riaw", "path": "/src/sphere.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match &export_decl.decl { Decl::Class(class_decl) => { let (name, class_def, decorator_js_doc) = super::class::get_doc_for_class_decl(parsed_source, class_decl); let js_doc = if js_doc.is_empty() { decorator_js_doc } else { js_doc }; DocNode::cla...
code_fim
hard
{ "lang": "rust", "repo": "bartlomieju/deno_doc", "path": "/src/module.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bartlomieju/deno_doc path: /src/module.rs // Copyright 2020-2022 the Deno authors. All rights reserved. MIT license. use deno_ast::ParsedSource; use deno_ast::SourceRanged; use deno_ast::SourceRangedForSpanned; use crate::node::DeclarationKind; use crate::node::DocNode; use crate::parser::DocP...
code_fim
hard
{ "lang": "rust", "repo": "bartlomieju/deno_doc", "path": "/src/module.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn is_transaction_valid<A, E>(tx: &AuthenticatedTransaction<A, E>) -> bool { tx.transaction.verify_possibly_balanced().is_ok() } pub(super) mod internal { use super::*; use crate::fragment::{FragmentId, PoolEntry}; use std::{ collections::{hash_map::Entry, HashMap, VecDeque}, ...
code_fim
hard
{ "lang": "rust", "repo": "Dankmemes201/jormungandr", "path": "/jormungandr/src/fragment/pool.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dankmemes201/jormungandr path: /jormungandr/src/fragment/pool.rs use crate::{ blockcfg::{HeaderContentEvalContext, Ledger, LedgerParameters}, fragment::{selection::FragmentSelectionAlgorithm, Fragment, Logs}, }; use chain_core::property::Fragment as _; use chain_impl_mockchain::transacti...
code_fim
hard
{ "lang": "rust", "repo": "Dankmemes201/jormungandr", "path": "/jormungandr/src/fragment/pool.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: edgedb/edgedb path: /edb/graphql-rewrite/src/pyerrors.rs use cpython::{PyObject, ToPyObject, Python, PyErr, PythonObject, PyType}; use cpython::exc::Exception; use crate::cpython::PythonObjectWithTypeObject; // can't use py_exception macro because that fails on dotted module name pub struct Le...
code_fim
hard
{ "lang": "rust", "repo": "edgedb/edgedb", "path": "/edb/graphql-rewrite/src/pyerrors.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn downcast_borrow_from<'a, 'p>(py: Python<'p>, obj: &'a PyObject) -> Result<&'a NotFoundError, cpython::PythonObjectDowncastError<'p>> { if NotFoundError::type_object(py).is_instance(py, obj) { Ok(unsafe { PythonObject::unchecked_downcast_borrow_from(obj)...
code_fim
hard
{ "lang": "rust", "repo": "edgedb/edgedb", "path": "/edb/graphql-rewrite/src/pyerrors.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MiaoMiaoGarden/databend path: /query/src/servers/http/http_services.rs // Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // h...
code_fim
hard
{ "lang": "rust", "repo": "MiaoMiaoGarden/databend", "path": "/query/src/servers/http/http_services.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct HttpHandler { session_manager: SessionManagerRef, shutdown_handler: HttpShutdownHandler, } impl HttpHandler { pub fn create(session_manager: SessionManagerRef) -> Box<dyn Server> { Box::new(HttpHandler { session_manager, shutdown_handler: HttpShutdow...
code_fim
hard
{ "lang": "rust", "repo": "MiaoMiaoGarden/databend", "path": "/query/src/servers/http/http_services.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut indexed_buses: Vec<(i128, i128)> = schedule .iter() .enumerate() .filter(|bus| *bus.1 != "x") .map(|bus| (pos_rem(-(bus.0 as i128), bus.1.parse::<i128>().unwrap()), bus.1.parse::<i128>().unwrap())) .collect(); indexed_buses.sort_by_key(|e| -e.1)...
code_fim
hard
{ "lang": "rust", "repo": "pdhborges/advent-of-code-2020", "path": "/day-13/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pdhborges/advent-of-code-2020 path: /day-13/src/main.rs use std::error::Error; use std::io::{self, Read, Write}; use std::result; type Result<T> = result::Result<T, Box<dyn Error>>; fn pos_rem(rem: i128, multiple: i128) -> i128 { <|fim_suffix|> // sieve CRT let mut indexed_buses: Vec<(...
code_fim
hard
{ "lang": "rust", "repo": "pdhborges/advent-of-code-2020", "path": "/day-13/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut curr_sol = indexed_buses[0].0; let mut curr_sum = indexed_buses[0].1; for i in 1..indexed_buses.len() { let mut sol = curr_sol; while sol % indexed_buses[i].1 != indexed_buses[i].0 { sol += curr_sum; } curr_sol = sol; curr_sum *= ind...
code_fim
hard
{ "lang": "rust", "repo": "pdhborges/advent-of-code-2020", "path": "/day-13/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ScottBailey/project_euler path: /p0041/src/main.rs /* https://projecteuler.net We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime tha...
code_fim
hard
{ "lang": "rust", "repo": "ScottBailey/project_euler", "path": "/p0041/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let elapsed = start_time.elapsed().as_micros(); println!("\nSolution: {}", sol); let mut remain = elapsed; let mut s = String::new(); if remain == 0 { s.insert(0,'0'); } while remain > 0 { let temp = remain%1000; remain /= 1000; if remain > 0 { ...
code_fim
hard
{ "lang": "rust", "repo": "ScottBailey/project_euler", "path": "/p0041/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: packysauce/rdfs path: /rdfs-proto/src/gen/InterDatanodeProtocol.rs r_state(&mut self) { self.state = ::std::option::Option::None; } pub fn has_state(&self) -> bool { self.state.is_some() } // Param is passed by value, moved pub fn set_state(&mut self, v: sup...
code_fim
hard
{ "lang": "rust", "repo": "packysauce/rdfs", "path": "/rdfs-proto/src/gen/InterDatanodeProtocol.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut my_size = 0; if let Some(ref v) = self.block.as_ref() { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; } if let Some(v) = self.recoveryId { my_size += ::protobuf::rt::value_size(2,...
code_fim
hard
{ "lang": "rust", "repo": "packysauce/rdfs", "path": "/rdfs-proto/src/gen/InterDatanodeProtocol.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: packysauce/rdfs path: /rdfs-proto/src/gen/InterDatanodeProtocol.rs } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; descriptor.get(...
code_fim
hard
{ "lang": "rust", "repo": "packysauce/rdfs", "path": "/rdfs-proto/src/gen/InterDatanodeProtocol.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cargo-generate/cargo-generate path: /tests/integration/helpers/project_builder.rs use indoc::indoc; use std::fs; use std::io::Write; use std::str; use crate::helpers::project::Project; use tempfile::TempDir; pub struct ProjectBuilder { files: Vec<(String, String)>, submodules: Vec<(Str...
code_fim
hard
{ "lang": "rust", "repo": "cargo-generate/cargo-generate", "path": "/tests/integration/helpers/project_builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Command::new("git") .arg("add") .arg("--all") .current_dir(path) .assert() .success(); Command::new("git") .arg("commit") .arg("--mes...
code_fim
hard
{ "lang": "rust", "repo": "cargo-generate/cargo-generate", "path": "/tests/integration/helpers/project_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// The "unspecified" address (all zero) of the given family pub const fn unspecified_address(&self) -> IpAddr { match self { Self::Ipv4 => IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), Self::Ipv6 => IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)), } } /// The "loopback" address (`127.0.0.1` or ...
code_fim
hard
{ "lang": "rust", "repo": "stbuehler/rust-cidr", "path": "/src/family.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stbuehler/rust-cidr path: /src/family.rs use std::net::{ IpAddr, Ipv4Addr, Ipv6Addr, }; /// Represents the type of an IP address #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub enum Family { /// IPv4 Ipv4, /// IPv6 Ipv6, } <|fim_suffix|> /// The "loopback" address (`12...
code_fim
hard
{ "lang": "rust", "repo": "stbuehler/rust-cidr", "path": "/src/family.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// The "loopback" address (`127.0.0.1` or `::1`) of the given family pub const fn loopback_address(&self) -> IpAddr { match self { Self::Ipv4 => IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), Self::Ipv6 => IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)), } } }<|fim_prefix|>// repo: stbuehler/rus...
code_fim
hard
{ "lang": "rust", "repo": "stbuehler/rust-cidr", "path": "/src/family.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn mul(self, other: f32) -> Vec4 { Vec4::from([self[0] * other, self[1] * other, self[2] * other, self[3] * other]) } } impl Display for Vec4 { fn fmt(&self, f: &mut Formatter) -> Result<(), Error>{ write!(f, "({}, {}, {}, {})", self[0], self[1], self[2], self[3]) } }<|fim_prefix|>// ...
code_fim
hard
{ "lang": "rust", "repo": "yeliknewo/rs-dorp", "path": "/src/math/vec4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yeliknewo/rs-dorp path: /src/math/vec4.rs use glium::uniforms::{AsUniformValue, UniformValue}; use std::ops::{Index, IndexMut, Add, Sub, Mul}; use std::fmt::{Display, Formatter, Error}; #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4 { vals: [f32; 4], } impl Vec4 { pub fn zero(...
code_fim
hard
{ "lang": "rust", "repo": "yeliknewo/rs-dorp", "path": "/src/math/vec4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn add(self, other: Vec4) -> Vec4 { Vec4::from([self[0] + other[0], self[1] + other[1], self[2] + other[2], self[3] + other[3]]) } } impl Sub<Vec4> for Vec4 { type Output = Vec4; fn sub(self, other: Vec4) -> Vec4 { Vec4::from([self[0] - other[0], self[1] - other[1], self[2] - other[2],...
code_fim
hard
{ "lang": "rust", "repo": "yeliknewo/rs-dorp", "path": "/src/math/vec4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return match self { None => false, Some(b) => { if b.element == element { true } else if element < b.element { b.left.search_value(element) } else { b.right.search_va...
code_fim
hard
{ "lang": "rust", "repo": "darylhjd/learning-rust", "path": "/src/hw03/second.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut bst = BST::new(); assert_eq!(bst.search(4), false); bst.insert(2); bst.insert(3); bst.insert(4); assert_eq!(bst.search(4), true); let mut bst_letter = BST::new(); assert_eq!(bst_letter.search('z'), false); bst_letter.insert...
code_fim
hard
{ "lang": "rust", "repo": "darylhjd/learning-rust", "path": "/src/hw03/second.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darylhjd/learning-rust path: /src/hw03/second.rs // Binary Search Tree second implementation type Link<T> = Option<Box<Node<T>>>; trait InsertSearch<T> { fn insert_value(&mut self, e: T) -> bool; fn search_value(&self, e: T) -> bool; } #[derive(Debug)] struct Node<T> { element: T, ...
code_fim
hard
{ "lang": "rust", "repo": "darylhjd/learning-rust", "path": "/src/hw03/second.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // destructure the tuple into two variables names let (a, b) = swap(result.0, result.1); println!("{} {}", a, b); let a = make_nothing(); let b = make_nothing2(); // Printing a debug string for a and b // Because it's hard to print nothingness println!("The value of a: {:...
code_fim
hard
{ "lang": "rust", "repo": "suryapandian/rust", "path": "/examples/01.basics/011functions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suryapandian/rust path: /examples/01.basics/011functions.rs fn swap(x: i32, y: i32) -> (i32, i32) { return (y, x); } fn add(x: i32, y: i32) -> i32 { return x + y; } fn make_nothing() -> () { <|fim_suffix|> // this function will return () if nothing is specified to return } fn main(...
code_fim
medium
{ "lang": "rust", "repo": "suryapandian/rust", "path": "/examples/01.basics/011functions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitsuhiko/minijinja path: /minijinja/tests/test_deserialization.rs #![cfg(feature = "deserialization")] use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; use similar_asserts::assert_eq; use minijinja::value::{SeqObject, StructObject, Value}; #[test] fn test_seq() { let ...
code_fim
hard
{ "lang": "rust", "repo": "mitsuhiko/minijinja", "path": "/minijinja/tests/test_deserialization.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_invalid() { struct X; impl Serialize for X { fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { Err(serde::ser::Error::custom("meh")) } } let v = Value::from_serializable(...
code_fim
hard
{ "lang": "rust", "repo": "mitsuhiko/minijinja", "path": "/minijinja/tests/test_deserialization.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(bool::deserialize(Value::from(true)).unwrap(), true); assert_eq!(bool::deserialize(Value::from(false)).unwrap(), false); assert_eq!(f32::deserialize(Value::from(1.0)).unwrap(), 1.0); assert_eq!(i32::deserialize(Value::from(2)).unwrap(), 2); assert_eq!(String::deserialize(Val...
code_fim
hard
{ "lang": "rust", "repo": "mitsuhiko/minijinja", "path": "/minijinja/tests/test_deserialization.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize, Clone, Default)] pub struct TasksFiles {} pub fn extract_name_and_params(value: String) -> DevrcResult<(String, Params)> { let mut parts = value.splitn(2, ' '); let name = parts.next().ok_or(DevrcError::InvalidName)?; let mut params: Params = Params::default(); ...
code_fim
hard
{ "lang": "rust", "repo": "stepht/devrc", "path": "/src/tasks/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stepht/devrc path: /src/tasks/mod.rs use std::{convert::TryFrom, fmt, marker::PhantomData}; use indexmap::IndexMap; use serde::{Deserialize, Deserializer}; use serde::de::{MapAccess, Visitor}; use crate::{ config::Config, errors::{DevrcError, DevrcResult}, scope::Scope, works...
code_fim
hard
{ "lang": "rust", "repo": "stepht/devrc", "path": "/src/tasks/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danylaporte/str_utils path: /src/str_utils_ext.rs use super::cmp::EqExt; use super::CharExt; /// Trait for searching string with accent / case insensitive comparison. pub trait StrUtilsExt { /// Returns true if the given pattern matches a suffix of this string slice. /// Returns false i...
code_fim
hard
{ "lang": "rust", "repo": "danylaporte/str_utils", "path": "/src/str_utils_ext.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> None } #[derive(Eq, PartialEq)] enum SearchResult { /// Found Found, /// Not found and cannot continue searching NotFoundFinal, /// Not found and can continue searching NotFoundContinue, } #[inline] fn ends_with<F>(src: &str, pat: &str, f: F) -> bool where F: Fn(char, cha...
code_fim
hard
{ "lang": "rust", "repo": "danylaporte/str_utils", "path": "/src/str_utils_ext.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where Self: Sized, { find_str(self, pat, EqExt::eq_ai) } #[inline] fn find_ai_ci(self, pat: &str) -> Option<usize> where Self: Sized, { find_str(self, pat, EqExt::eq_ai_ci) } #[inline] fn find_ci(self, pat: &str) -> Option<usize> ...
code_fim
hard
{ "lang": "rust", "repo": "danylaporte/str_utils", "path": "/src/str_utils_ext.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iacsa/exercism-solutions path: /rust/rectangles/src/lib.rs pub fn count(board: &[&str]) -> usize { let height = board.len(); let width = board.first().map(|row| row.len()).unwrap_or(0); let is_str = |x: usize, y: usize, s: &str| -> bool { &board[y][x..=x] == s }; let is_corner =...
code_fim
hard
{ "lang": "rust", "repo": "iacsa/exercism-solutions", "path": "/rust/rectangles/src/lib.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> (y1 + 1..height) // Left side .take_while(move |&y| is_vertical(x1, y)) // Lower left corner .filter(move |&y| is_corner(x1, y)) .map(move |y2| { (...
code_fim
hard
{ "lang": "rust", "repo": "iacsa/exercism-solutions", "path": "/rust/rectangles/src/lib.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dkull/cryptopals path: /src/bin/s4c30_md4_keyed_mac_break.rs extern crate byteorder; extern crate cryptopals; use std::fmt::Write; use std::process::exit; use byteorder::{BigEndian, LittleEndian, WriteBytesExt}; fn md4_padding(data_len: usize) -> Vec<u8> { let mut padding: Vec<u8> = vec![...
code_fim
hard
{ "lang": "rust", "repo": "dkull/cryptopals", "path": "/src/bin/s4c30_md4_keyed_mac_break.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let authenticator = Authenticator::new(key.as_bytes()); // create hasher let mut good_input = vec![]; good_input.extend(key.as_bytes()); good_input.extend(msg.as_bytes()); let original_mac = cryptopals::md4::md4(good_input.clone(), 0, None); /*good_input.extend(md4_padding(ke...
code_fim
hard
{ "lang": "rust", "repo": "dkull/cryptopals", "path": "/src/bin/s4c30_md4_keyed_mac_break.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: z1queue/incubator-teaclave path: /rpc/src/transport.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": "z1queue/incubator-teaclave", "path": "/rpc/src/transport.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }