text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>} pub trait OpenOfficeDoc<T>: Read + HasKind { fn open<P: AsRef<Path>>(path: P) -> io::Result<T>; } pub(crate) fn open_doc_read_data<P: AsRef<Path>>(path: P, content_name:&str, tags:&[&str]) -> io::Result<String> { let file = File::open(path.as_ref())?; let mut archive = ZipArchive::new(fil...
code_fim
hard
{ "lang": "rust", "repo": "ctjhoa/dotext", "path": "/src/doc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NiceneNerd/byml-rust path: /src/write.rs use crate::{Byml, Endian, NodeType, U24}; use binwrite::{BinWrite, WriterOption}; use byteorder::{BigEndian, ByteOrder, LittleEndian}; use indexmap::{IndexMap, IndexSet}; use rayon::prelude::*; use std::collections::{hash_map::DefaultHasher, BTreeMap}; us...
code_fim
hard
{ "lang": "rust", "repo": "NiceneNerd/byml-rust", "path": "/src/write.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut s = DefaultHasher::new(); t.hash(&mut s); s.finish() } fn collect_strings(data: &Byml) -> IndexSet<String> { let mut strs: IndexSet<String> = IndexSet::new(); match data { Byml::String(v) => { strs.insert(v.to_owned()); } Byml::Array(v) => s...
code_fim
hard
{ "lang": "rust", "repo": "NiceneNerd/byml-rust", "path": "/src/write.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn parses_correctly() { let mut input = vec![0, 2, 1, 2]; let expected = Node { children: Vec::new(), metadata: vec![1, 2], }; assert_eq!(expected, parse(&mut input)); let mut input = vec![1, 0, 0, 2, 1, 2]; let expe...
code_fim
hard
{ "lang": "rust", "repo": "djquan/advent2018", "path": "/day08/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: djquan/advent2018 path: /day08/src/main.rs use std::env; use std::fs; #[derive(PartialEq, Debug)] struct Node { children: Vec<Node>, metadata: Vec<u32>, } fn main() { let filename = env::args().nth(1).expect("Usage: ./run FILENAME"); let mut records: Vec<u32> = fs::read_to_stri...
code_fim
hard
{ "lang": "rust", "repo": "djquan/advent2018", "path": "/day08/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sum: u32 = node.metadata.iter().sum(); let children_sum: u32 = node.children.iter().map(|child| part_one(child)).sum(); sum + children_sum } fn part_two(node: &Node) -> u32 { if node.children.len() == 0 { return node.metadata.iter().sum(); } let node_sum: u32 = node ...
code_fim
hard
{ "lang": "rust", "repo": "djquan/advent2018", "path": "/day08/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaloisInc/crucible path: /crux-mir/test/conc_eval/mem/maybe_uninit.rs use std::mem::MaybeUninit; <|fim_suffix|> let mut i = MaybeUninit::uninit(); unsafe { *i.as_mut_ptr() = 1; i.assume_init() } } pub fn main() { println!("{:?}", crux_test()); }<|fim_middle|>#[cf...
code_fim
easy
{ "lang": "rust", "repo": "GaloisInc/crucible", "path": "/crux-mir/test/conc_eval/mem/maybe_uninit.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut i = MaybeUninit::uninit(); unsafe { *i.as_mut_ptr() = 1; i.assume_init() } } pub fn main() { println!("{:?}", crux_test()); }<|fim_prefix|>// repo: GaloisInc/crucible path: /crux-mir/test/conc_eval/mem/maybe_uninit.rs use std::mem::MaybeUninit; <|fim_middle|>#[cf...
code_fim
easy
{ "lang": "rust", "repo": "GaloisInc/crucible", "path": "/crux-mir/test/conc_eval/mem/maybe_uninit.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andy128k/sanitize-html-rs path: /src/lib.rs //! HTML Sanitization library //! //! # Examples //! //! ``` //! use sanitize_html::sanitize_str; //! use sanitize_html::rules::predefined::DEFAULT; //! //! let input = "<b>Lo<!-- comment -->rem</b> <a href=\"pants\" title=\"foo\">ipsum</a> <a href=\"h...
code_fim
medium
{ "lang": "rust", "repo": "andy128k/sanitize-html-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Sanitize HTML bytes pub fn sanitize_bytes(rules: &Rules, input: &[u8]) -> Result<Vec<u8>, SanitizeError> { let input_str = std::str::from_utf8(input).map_err(SanitizeError::StrUtf8Error)?; let dom = parse::parse_str(input_str); let new_dom = sanitize::sanitize_dom(&dom, rules); let res...
code_fim
medium
{ "lang": "rust", "repo": "andy128k/sanitize-html-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Sanitize HTML string pub fn sanitize_str(rules: &Rules, input: &str) -> Result<String, SanitizeError> { let dom = parse::parse_str(input); let new_dom = sanitize::sanitize_dom(&dom, rules); let result_bytes = parse::unparse_bytes(&new_dom)?; let result_string = String::from_utf8(result...
code_fim
hard
{ "lang": "rust", "repo": "andy128k/sanitize-html-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /d1-pac/src/csic/csic_dma/csic_dma_fifo_stat.rs #[doc = "Register `csic_dma_fifo_stat` reader"] pub struct R(crate::R<CSIC_DMA_FIFO_STAT_SPEC>); impl core::ops::Deref for R { type Target = crate::R<CSIC_DMA_FIFO_STAT_SPEC>; #[inline(always)] fn deref(&self) -...
code_fim
medium
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/csic/csic_dma/csic_dma_fifo_stat.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `fifo_frm_max` reader - Indicates the maximum depth of FIFO being occupied for whole frame. Update at every vsync or framedone."] pub type FIFO_FRM_MAX_R = crate::FieldReader<u16, u16>; #[doc = "Field `line` reader - Line Index Indicates the line index in current v...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/csic/csic_dma/csic_dma_fifo_stat.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fkaaa568/Rust-Tasks path: /q5/src/main.rs use std::io; fn main() { println!("Please Enter The String"); <|fim_suffix|> println!("How Many Copies Do you Have"); let mut number = String::new(); io::stdin().read_line(&mut number).expect("failed"); let number : u32 = number....
code_fim
medium
{ "lang": "rust", "repo": "fkaaa568/Rust-Tasks", "path": "/q5/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut text = String::new(); io::stdin().read_line(&mut text).expect(""); for a in 0..number{ text = text.to_string() + &text; } println!("{}",text); }<|fim_prefix|>// repo: fkaaa568/Rust-Tasks path: /q5/src/main.rs use std::io; fn main() { println!("Please Ente...
code_fim
medium
{ "lang": "rust", "repo": "fkaaa568/Rust-Tasks", "path": "/q5/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn add(x: i32, y: i32) -> i32 { x + y }<|fim_prefix|>// repo: zillani/learn-rust path: /src/functions.rs pub fn run() { greeting("Hello", "Shaik!"); println!("Sum is {}", add(2, 2)); //Closure let add_nums = |x: i32, y: i32| x + y; println!("Sum is {}", add_nums(3, 3)); } fn gree...
code_fim
easy
{ "lang": "rust", "repo": "zillani/learn-rust", "path": "/src/functions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zillani/learn-rust path: /src/functions.rs pub fn run() { greeting("Hello", "Shaik!"); println!("Sum is {}", add(2, 2)); //Closure let add_nums = |x: i32, y: i32| x + y; println!("Sum is {}", add_nums(3, 3)); } fn greeting(greet: &str, name: &str) { <|fim_suffix|>fn add(x: i...
code_fim
easy
{ "lang": "rust", "repo": "zillani/learn-rust", "path": "/src/functions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_post(id: &str) -> Option<Post> { let id = match ObjectId::with_string(id) { Ok(i) => Some(doc! { "_id": i }), Err(_) => return None }; let post = POST_COLLECTION .find_one(id, None) .ok() .unwrap(); utils::doc_to_post(post, true) } pub fn...
code_fim
hard
{ "lang": "rust", "repo": "Aedron/do.codes.backend", "path": "/src/db/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_posts(count: Option<i32>, skip: Option<i64>) -> Vec<Post> { // let total = POST_COLLECTION.count(None, None); let posts = POST_COLLECTION .find(None, None) .ok() .unwrap(); let mut result: Vec<Post> = vec![]; for post in posts { match utils::doc_t...
code_fim
medium
{ "lang": "rust", "repo": "Aedron/do.codes.backend", "path": "/src/db/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aedron/do.codes.backend path: /src/db/mod.rs pub mod models; pub mod utils; use mongodb::{coll::Collection, ThreadedClient}; use mongodb::db::ThreadedDatabase; use bson::{to_bson, oid::ObjectId}; use self::models::{NewPost, Post}; use super::utils::get_timestamp; <|fim_suffix|>pub fn get_post...
code_fim
medium
{ "lang": "rust", "repo": "Aedron/do.codes.backend", "path": "/src/db/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl InsertablePlan { pub fn insert(plan_form_input: PlanFormInput, conn: &SqliteConnection) -> bool { let description = plan_form_input.description.filter(|s| !s.is_empty()); let plan = InsertablePlan { task_id: plan_form_input.task_id, description, ...
code_fim
hard
{ "lang": "rust", "repo": "HarrisonMc555/task-planner-rocket", "path": "/src/plan.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HarrisonMc555/task-planner-rocket path: /src/plan.rs use diesel::{self, prelude::*}; mod schema { table! { plans (id) { id -> Integer, task_id -> Integer, description -> Nullable<Text>, completed -> Bool, } } } use self::s...
code_fim
hard
{ "lang": "rust", "repo": "HarrisonMc555/task-planner-rocket", "path": "/src/plan.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn animate(&mut self, time: f32) { let delta = time - self.time; self.projection_params.view_matrix = Matrix4::look_at( Point3::new( 0.0 + self.center.x, -self.radius / 5.0 * 2.0 + self.center.y, self.radius + self.center...
code_fim
hard
{ "lang": "rust", "repo": "forkeith/ldraw.rs", "path": "/examples/renderer/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkeith/ldraw.rs path: /examples/renderer/src/lib.rs use std::{ rc::Rc, vec::Vec, }; use cgmath::{Deg, PerspectiveFov, Point3, Quaternion, Rad, Rotation3, SquareMatrix}; use glow::HasContext; use ldraw::{ color::{ColorReference, Material, MaterialRegistry}, {Matrix3, Matrix4, V...
code_fim
hard
{ "lang": "rust", "repo": "forkeith/ldraw.rs", "path": "/examples/renderer/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Creates a file from bytes /// and returns a boolean based on success or failure. /// /// # Usage: /// /// ``` /// let binary_file: &'static [u8] = b"01001000 01100101 01101100 01101100 01101111 00100001"; /// /// assert_eq!(fsutils::create_file_bytes("a_binary_file", binary_file), true); /// /// # // ...
code_fim
hard
{ "lang": "rust", "repo": "jaredforth/fsutils", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaredforth/fsutils path: /src/lib.rs // Copyright 2020 Jared Forth. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This file may...
code_fim
hard
{ "lang": "rust", "repo": "jaredforth/fsutils", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn k_line_for_pair(pair: &str, closes: &mut Vec<f64>) { let keep_running = AtomicBool::new(true); // Used to control the event loop let kline: String = format!("{}{}", pair, "@kline_1m"); let mut in_position: bool = false; println!("k_liner is {}", &kline); let mut web_socket: WebSocke...
code_fim
medium
{ "lang": "rust", "repo": "valekar/tradingbot", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: valekar/tradingbot path: /src/main.rs use binance::websockets::*; use std::sync::atomic::AtomicBool; extern crate ta_lib_wrapper; use strategy::rsi::use_rsi; use ta_lib_wrapper::{TA_RetCode, TA_RSI}; use utils::util::{display_contents, load_env}; mod example; mod strategy; mod utils; const TRA...
code_fim
medium
{ "lang": "rust", "repo": "valekar/tradingbot", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust9x/rust path: /compiler/rustc_parse/src/parser/attr_wrapper.rs use super::attr; use super::{ForceCollect, Parser, TokenCursor, TrailingToken}; use rustc_ast::token::{self, Token, TokenKind}; use rustc_ast::tokenstream::{CreateTokenStream, TokenStream, TokenTree, TreeAndSpacing}; use rustc_as...
code_fim
hard
{ "lang": "rust", "repo": "rust9x/rust", "path": "/compiler/rustc_parse/src/parser/attr_wrapper.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // When the `LazyTokenStreamImpl` was original produced, we did *not* // include `NoDelim` tokens in `num_calls`, since they are normally ignored // by the parser. Therefore, we only increment our counter for other types of tokens. ...
code_fim
hard
{ "lang": "rust", "repo": "rust9x/rust", "path": "/compiler/rustc_parse/src/parser/attr_wrapper.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match *vertex { Geo(_) | GeoTex(_)| GeoNorm(_) | GeoTexNorm(_) => (), GeoTexNormTan(_) => { gl::EnableVertexAttribArray(3); gl::VertexAttribPointer(2, 3, gl::FLOAT, gl::FALSE, stride, offset as *const c_void); ...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/snowmew", "path": "/src/snowmew-render/vertex_buffer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steveklabnik/snowmew path: /src/snowmew-render/vertex_buffer.rs // Copyright 2014 Colin Sherratt // // 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 // // ...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/snowmew", "path": "/src/snowmew-render/vertex_buffer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let offset = match *vertex { Geo(_) | GeoNorm(_) => offset, GeoTex(_) | GeoTexNorm(_) | GeoTexNormTan(_) => { gl::EnableVertexAttribArray(1); gl::VertexAttribPointer(1, 2, gl::FLOAT, gl::FALSE, stride, offset as *const c_v...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/snowmew", "path": "/src/snowmew-render/vertex_buffer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // update parents references for parent_id in &parents { self.links .get_mut(parent_id) .expect("exists") .children .insert(short_id.clone()); } // insert links self.links.insert( ...
code_fim
hard
{ "lang": "rust", "repo": "SPERAXIO/ckb", "path": "/tx-pool/src/component/container.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SPERAXIO/ckb path: /tx-pool/src/component/container.rs ate and return the min one fn min_fee_and_vbytes(&self) -> (Capacity, u64) { // avoid division a_fee/a_vbytes > b_fee/b_vbytes let tx_weight = u128::from(self.fee.as_u64()) * u128::from(self.ancestors_vbytes); let...
code_fim
hard
{ "lang": "rust", "repo": "SPERAXIO/ckb", "path": "/tx-pool/src/component/container.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SPERAXIO/ckb path: /tx-pool/src/component/container.rs } } } impl PartialOrd for AncestorsScoreSortKey { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) } } impl Ord for AncestorsScoreSortKey { fn cmp(&self, other: &Self) -> Ordering { ...
code_fim
hard
{ "lang": "rust", "repo": "SPERAXIO/ckb", "path": "/tx-pool/src/component/container.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if i == *k { ans.push(sub_arr); sub_arr = Vec::new(); i = 0; } } } ans } }<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/medium/group_the_people_given_the_group_size_they_belong_to....
code_fim
hard
{ "lang": "rust", "repo": "stackcats/leetcode", "path": "/algorithms/medium/group_the_people_given_the_group_size_they_belong_to.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/medium/group_the_people_given_the_group_size_they_belong_to.rs use std::collections::HashMap; impl Solution { pub fn group_the_people(group_sizes: Vec<i32>) -> Vec<Vec<i32>> { let mut map = HashMap::new(); for i in 0..group_sizes.len() { ...
code_fim
hard
{ "lang": "rust", "repo": "stackcats/leetcode", "path": "/algorithms/medium/group_the_people_given_the_group_size_they_belong_to.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jutley/rust_chapt2_practice path: /src/fibonacci.rs fn fibonacci(n: u32) -> u32 { match n { 0 => 0, 1 => 1, n => fibonacci(n - 2) + fibonacci(n - 1) } } <|fim_suffix|> let res = fibonacci(test_val); println!("{} should be {}: {}", res, expected, res == expected); } pub fn te...
code_fim
easy
{ "lang": "rust", "repo": "jutley/rust_chapt2_practice", "path": "/src/fibonacci.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn test() { test_case(0, 0); test_case(1, 1); test_case(2, 1); test_case(3, 2); test_case(4, 3); test_case(5, 5); test_case(10, 55); test_case(20, 6765); }<|fim_prefix|>// repo: jutley/rust_chapt2_practice path: /src/fibonacci.rs fn fibonacci(n: u32) -> u32 { match n { 0 => 0, ...
code_fim
medium
{ "lang": "rust", "repo": "jutley/rust_chapt2_practice", "path": "/src/fibonacci.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hdxia/ocicrypt-rs path: /build.rs // Copyright The ocicrypt Authors. // SPDX-License-Identifier: Apache-2.0 extern crate tonic_build; <|fim_suffix|> tonic_build::configure() .build_server(true) .out_dir("src/utils/") .compile(&["src/utils/proto/keyprovider.proto"], &...
code_fim
easy
{ "lang": "rust", "repo": "hdxia/ocicrypt-rs", "path": "/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> Result<(), Box<dyn std::error::Error>> { tonic_build::configure() .build_server(true) .out_dir("src/utils/") .compile(&["src/utils/proto/keyprovider.proto"], &["src/utils"])?; Ok(()) }<|fim_prefix|>// repo: hdxia/ocicrypt-rs path: /build.rs // Copyright The oc...
code_fim
easy
{ "lang": "rust", "repo": "hdxia/ocicrypt-rs", "path": "/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { Iron::new(|_: &mut Request| { Ok(Response::with((status::Ok, "Hello world!"))) }).http("0.0.0.0:4000").unwrap(); }<|fim_prefix|>// repo: kzmake/benchmark-app-servers path: /servers/iron/src/main.rs extern crate iron; <|fim_middle|>use iron::prelude::*; use iron::status;
code_fim
easy
{ "lang": "rust", "repo": "kzmake/benchmark-app-servers", "path": "/servers/iron/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kzmake/benchmark-app-servers path: /servers/iron/src/main.rs extern crate iron; use iron::prelude::*; use iron::status; <|fim_suffix|> Iron::new(|_: &mut Request| { Ok(Response::with((status::Ok, "Hello world!"))) }).http("0.0.0.0:4000").unwrap(); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "kzmake/benchmark-app-servers", "path": "/servers/iron/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Iron::new(|_: &mut Request| { Ok(Response::with((status::Ok, "Hello world!"))) }).http("0.0.0.0:4000").unwrap(); }<|fim_prefix|>// repo: kzmake/benchmark-app-servers path: /servers/iron/src/main.rs extern crate iron; use iron::prelude::*; use iron::status; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "kzmake/benchmark-app-servers", "path": "/servers/iron/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// assumes well-formed `ident_with_metadata` fn label_identifier(ident_with_metadata: String) -> (String, String) { let (ident, meta_data) = raw_to_ident_and_metadata(ident_with_metadata); let (raw_label, annotated_ident) = label_identifier_optional(make_raw_label(meta_data), ident); l...
code_fim
hard
{ "lang": "rust", "repo": "zingolabs/quizface", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zingolabs/quizface path: /src/lib.rs &str>>()[1] .to_string(); let arg_vec = vec![annotate_object(&mut nested_pairs.chars())]; arg_map.insert(ident, serde_json::Value::Array(arg_vec.clone())); } else { let (raw_label, annotated_iden...
code_fim
hard
{ "lang": "rust", "repo": "zingolabs/quizface", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zingolabs/quizface path: /src/lib.rs ch result_chars.next().unwrap() { '{' => annotate_object(result_chars), '[' => annotate_array(result_chars), i if i.is_alphabetic() || i == '"' => annotate_lonetype(format!( "{}{}", i, result_chars.a...
code_fim
hard
{ "lang": "rust", "repo": "zingolabs/quizface", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn create<D: UserDataType>(def: &B2JointDefEnum<D>) -> B2jointPtr<D> { match def { B2JointDefEnum::DistanceJoint(ref def)=> Rc::new(RefCell::new(B2distanceJoint::new(def))), B2JointDefEnum::FrictionJoint(ref def)=> Rc::new(RefCell::new(B2frictionJoint::new(def))), B2JointDefEnum::GearJo...
code_fim
hard
{ "lang": "rust", "repo": "yangfengzzz/box2d-rs", "path": "/src/private/dynamics/b2_joint.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yangfengzzz/box2d-rs path: /src/private/dynamics/b2_joint.rs use crate::b2_joint::*; use crate::b2_draw::*; use crate::b2_settings::*; use crate::b2_math::*; use crate::b2_body::*; use crate::joints::b2_distance_joint::*; use crate::joints::b2_friction_joint::*; use crate::joints::b2_gear_joint...
code_fim
hard
{ "lang": "rust", "repo": "yangfengzzz/box2d-rs", "path": "/src/private/dynamics/b2_joint.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jerry73204/rust-lidar-utils path: /velodyne-lidar/src/traits/firing_like.rs use crate::consts::CHANNEL_PERIOD; use std::time::Duration; pub trait FiringLike { type Point<'a> where Self: 'a; fn start_time(&self) -> Duration; <|fim_suffix|> fn point_at(&self, index: usize...
code_fim
medium
{ "lang": "rust", "repo": "jerry73204/rust-lidar-utils", "path": "/velodyne-lidar/src/traits/firing_like.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { if self.index == self.len { return None; } let value = self.value; self.index += 1; self.value += CHANNEL_PERIOD; Some(value) } }<|fim_prefix|>// repo: jerry73204/rust-lidar-utils path: /velody...
code_fim
hard
{ "lang": "rust", "repo": "jerry73204/rust-lidar-utils", "path": "/velodyne-lidar/src/traits/firing_like.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crd477/biased-work-queues path: /src/biased_work_queue.rs use crossbeam::channel; use crossbeam::sync::{Parker, Unparker}; pub enum QueueError { Disconnected, } pub trait QueueReceiver: Clone { type Item; fn try_receive(&self) -> Result<Option<Self::Item>, QueueError>; fn recei...
code_fim
hard
{ "lang": "rust", "repo": "crd477/biased-work-queues", "path": "/src/biased_work_queue.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct BiasedWorkQueueReceiver<R: QueueReceiver> { /// The single work queue channel receiver: R, /// For all threads but the first one, we block on this instead of the channel. parker: Option<Parker>, /// For all threads but the last one, we wake up the next thread /// when th...
code_fim
hard
{ "lang": "rust", "repo": "crd477/biased-work-queues", "path": "/src/biased_work_queue.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<R: QueueReceiver> BiasedWorkQueueReceiver<R> { /// Returns a list of items to work on. pub fn recv(&self) -> Result<Vec<R::Item>, QueueError> { let mut buf = Vec::new(); loop { // Grab up to BATCH_SIZE work items without blocking. while buf.len() < BATC...
code_fim
hard
{ "lang": "rust", "repo": "crd477/biased-work-queues", "path": "/src/biased_work_queue.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mihaicostin/advent-of-code path: /aoc-2019-rust/src/bin/day1.rs use std::{ fs::File, io::{prelude::*, BufReader}, path::Path, }; fn main() { let result = lines_from_file("src/bin/day1.txt"); println!("Result:\n{:?}", result); } fn lines_from_file(filename: impl AsRef<Path>...
code_fim
hard
{ "lang": "rust", "repo": "mihaicostin/advent-of-code", "path": "/aoc-2019-rust/src/bin/day1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn extraFuel(a: i32) -> i32 { if a <= 0 { return 0; } else { return a + ffun(a / 3 - 2) } }<|fim_prefix|>// repo: mihaicostin/advent-of-code path: /aoc-2019-rust/src/bin/day1.rs use std::{ fs::File, io::{prelude::*, BufReader}, path::Path, }; <|fim_middle|>fn mai...
code_fim
hard
{ "lang": "rust", "repo": "mihaicostin/advent-of-code", "path": "/aoc-2019-rust/src/bin/day1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Model { fn map_raw_addr(&self, raw_addr: MemAddr) -> RelativeAddr; }<|fim_prefix|>// repo: piderman314/snert path: /src/mem/model/mod.rs pub mod lomem; use crate::mem::MemAddr; <|fim_middle|>pub enum MemType { Cartridge, } pub struct RelativeAddr(pub MemType, pub usize);
code_fim
medium
{ "lang": "rust", "repo": "piderman314/snert", "path": "/src/mem/model/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piderman314/snert path: /src/mem/model/mod.rs pub mod lomem; use crate::mem::MemAddr; <|fim_suffix|>pub trait Model { fn map_raw_addr(&self, raw_addr: MemAddr) -> RelativeAddr; }<|fim_middle|>pub enum MemType { Cartridge, } pub struct RelativeAddr(pub MemType, pub usize);
code_fim
medium
{ "lang": "rust", "repo": "piderman314/snert", "path": "/src/mem/model/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piderman314/snert path: /src/mem/model/mod.rs pub mod lomem; use crate::mem::MemAddr; pub enum MemType { Cartridge, } <|fim_suffix|>pub trait Model { fn map_raw_addr(&self, raw_addr: MemAddr) -> RelativeAddr; }<|fim_middle|>pub struct RelativeAddr(pub MemType, pub usize);
code_fim
easy
{ "lang": "rust", "repo": "piderman314/snert", "path": "/src/mem/model/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ault()); } return rows; } pub fn to_set<T: Default + FromStr + Eq + Hash>(path: &str, split_on: &str) -> HashSet<T> { let mut set = HashSet::new(); let content = fs::read_to_string(path).expect("could not read file"); for row in content.split(split_on) { // Should probably not...
code_fim
hard
{ "lang": "rust", "repo": "ksala/advent-of-code-2020", "path": "/src/input.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ksala/advent-of-code-2020 path: /src/input.rs use std::{hash::Hash, fs}; use std::str::FromStr; use std::collections::HashSet; pub fn to_vec<T: Default + FromStr>(path: &str, split_on: &str) -> Vec<T> { let mut rows: Vec<T> = vec![]; let content = fs::read_to_string(path).expect("could ...
code_fim
hard
{ "lang": "rust", "repo": "ksala/advent-of-code-2020", "path": "/src/input.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>not read file"); for row in content.split(split_on) { // Should probably not use default and either return a Result or crash set.insert(row.parse::<T>().unwrap_or_default()); } return set; }<|fim_prefix|>// repo: ksala/advent-of-code-2020 path: /src/input.rs use std::{hash::Ha...
code_fim
hard
{ "lang": "rust", "repo": "ksala/advent-of-code-2020", "path": "/src/input.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let x = match A(3) { A(..) => 1 }; assert_eq!(x, 1); let x = match A(4) { A(1) => 1, A(..) => 2 }; assert_eq!(x, 2); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/issues/issue-14308.rs // run-pass struct A(isize); <|fim_...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/issues/issue-14308.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/issues/issue-14308.rs // run-pass struct A(isize); <|fim_suffix|> let x = match A(3) { A(..) => 1 }; assert_eq!(x, 1); let x = match A(4) { A(1) => 1, A(..) => 2 }; assert_eq!(x, 2); }<|fim_...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/issues/issue-14308.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kconte/project-euler-rust path: /solvers/033/src/main.rs #![warn(clippy::all)] #![warn(clippy::pedantic)] fn main() { run(); } fn run() { let start = std::time::Instant::now(); // code goes here let mut num = 1; let mut den = 1; for n in 10..100 { for d in (n + 1)..100 { ...
code_fim
hard
{ "lang": "rust", "repo": "kconte/project-euler-rust", "path": "/solvers/033/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match a.cmp(&b) { | std::cmp::Ordering::Equal => a, | std::cmp::Ordering::Greater => gcd(a - b, b), | std::cmp::Ordering::Less => gcd(a, b - a), } }<|fim_prefix|>// repo: kconte/project-euler-rust path: /solvers/033/src/main.rs #![warn(clippy::all)] #![warn(clippy::pedantic)] fn main() {...
code_fim
medium
{ "lang": "rust", "repo": "kconte/project-euler-rust", "path": "/solvers/033/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if n % 10 == 0 && d % 10 == 0 { return false; } let n_t = n / 10; let n_o = n % 10; let d_t = d / 10; let d_o = d % 10; let f_1 = (n_t as f64) / (d_o as f64); let f_2 = (n_o as f64) / (d_t as f64); let f_o = (n as f64) / (d as f64); if n_t == d_o { f_2 == f_o } else if n_o...
code_fim
medium
{ "lang": "rust", "repo": "kconte/project-euler-rust", "path": "/solvers/033/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Indicates the endianness of the underlying pixel format #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Endian { /// Stored in little-endian format Big, /// Stored in big-endian format Little, }<|fim_prefix|>// repo: robojeb/ffmpeg-libav-rs path: /crates/ffav/src/util/colo...
code_fim
medium
{ "lang": "rust", "repo": "robojeb/ffmpeg-libav-rs", "path": "/crates/ffav/src/util/color/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robojeb/ffmpeg-libav-rs path: /crates/ffav/src/util/color/mod.rs mod color_primary; #[cfg(feature = "image-decode")] mod image_ext; mod pixel_format; <|fim_suffix|>/// Indicates the endianness of the underlying pixel format #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Endian { ...
code_fim
medium
{ "lang": "rust", "repo": "robojeb/ffmpeg-libav-rs", "path": "/crates/ffav/src/util/color/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrigocfd/winsafe path: /src/dxgi/com_interfaces/idxgioutput.rs #![allow(non_camel_case_types, non_snake_case)] use crate::co; use crate::decl::*; use crate::kernel::ffi_types::*; use crate::ole::privs::*; use crate::prelude::*; use crate::vt::*; /// [`IDXGIAdapter`](crate::IDXGIAdap...
code_fim
hard
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/dxgi/com_interfaces/idxgioutput.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ) -> HrResult<DXGI_GAMMA_CONTROL_CAPABILITIES> { let mut capa = DXGI_GAMMA_CONTROL_CAPABILITIES::default(); ok_to_hrresult( unsafe { (vt::<IDXGIOutputVT>(self).GetGammaControlCapabilities)( self.ptr(), &mut capa as *mut _ as _, ) }, ).map(|_| capa) } /// [`I...
code_fim
hard
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/dxgi/com_interfaces/idxgioutput.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let test = Solution::is_ugly(14); println!("{}", test) }<|fim_prefix|>// repo: jeremy-nevado/leetcode-solutions path: /rust/easy-rust/ugly-numbers/src/main.rs struct Solution {} impl Solution { pub fn is_ugly(num: i32) -> bool { let mut temp = num; if num == 0 { f...
code_fim
easy
{ "lang": "rust", "repo": "jeremy-nevado/leetcode-solutions", "path": "/rust/easy-rust/ugly-numbers/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeremy-nevado/leetcode-solutions path: /rust/easy-rust/ugly-numbers/src/main.rs struct Solution {} impl Solution { pub fn is_ugly(num: i32) -> bool { let mut temp = num; if num == 0 { false; } if num == 1 { true; } for ...
code_fim
easy
{ "lang": "rust", "repo": "jeremy-nevado/leetcode-solutions", "path": "/rust/easy-rust/ugly-numbers/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cmsd2/rogue1 path: /src/main.rs #[macro_use] extern crate log; pub mod ai; pub mod qs_game; pub mod qs_ui; pub mod scene; pub mod data; pub mod game; pub mod color; pub mod tween; <|fim_suffix|> env_logger::init(); let settings = Settings { // If the graphics do need to be scal...
code_fim
hard
{ "lang": "rust", "repo": "cmsd2/rogue1", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { std::env::set_var("WINIT_HIDPI_FACTOR", "1.0"); std::env::set_var("WINIT_UNIX_BACKEND", "x11"); env_logger::init(); let settings = Settings { // If the graphics do need to be scaled (e.g. using // `with_center`), blur them. This looks better with fonts. ...
code_fim
medium
{ "lang": "rust", "repo": "cmsd2/rogue1", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/crates.io path: /src/models/download.rs use crate::models::Version; use crate::schema::version_downloads; use chrono::NaiveDate; #[d<|fim_suffix|>n_id, date), belongs_to(Version))] pub struct VersionDownload { pub version_id: i32, pub downloads: i32, pub counted: i32, ...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/crates.io", "path": "/src/models/download.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub downloads: i32, pub counted: i32, pub date: NaiveDate, pub processed: bool, }<|fim_prefix|>// repo: rust-lang/crates.io path: /src/models/download.rs use crate::models::Version; use crate::schema::version_downloads; use chrono::NaiveDate; #[d<|fim_middle|>erive(Queryable, Identifiable, A...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/crates.io", "path": "/src/models/download.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: headcrab-rs/headcrab path: /headcrab_inject/src/module.rs use std::collections::HashMap; use cranelift_codegen::{binemit, ir, isa::TargetIsa, Context}; use cranelift_module::{DataId, FuncId}; use headcrab::{target::LinuxTarget, CrabResult}; use crate::InjectionContext; // FIXME unmap memory w...
code_fim
hard
{ "lang": "rust", "repo": "headcrab-rs/headcrab", "path": "/headcrab_inject/src/module.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ctx.compile_and_emit(isa, &mut code_mem).unwrap(); let code_region = self.inj_ctx.allocate_code(code_mem.len() as u64, None)?; for reloc_entry in ctx.mach_compile_result.as_ref().unwrap().buffer.relocs() { let sym = match reloc_entry.name { ir::Externa...
code_fim
hard
{ "lang": "rust", "repo": "headcrab-rs/headcrab", "path": "/headcrab_inject/src/module.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct SuperNode { pub modules: HashSet<String>, pub edges: HashMap<Gate, Gate>, pub periphery_in: HashMap<GateIndex, Gate>, pub periphery_out: HashMap<GateIndex, Gate>, }<|fim_prefix|>// repo: melvinw/besstools path: /tools/src/bin/bessctl/supernode.rs use std::collections::{HashSet,...
code_fim
medium
{ "lang": "rust", "repo": "melvinw/besstools", "path": "/tools/src/bin/bessctl/supernode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: melvinw/besstools path: /tools/src/bin/bessctl/supernode.rs use std::collections::{HashSet,HashMap}; type GateIndex = u16; pub trait TaskGroup { } <|fim_suffix|>pub struct SuperNode { pub modules: HashSet<String>, pub edges: HashMap<Gate, Gate>, pub periphery_in: HashMap<GateIndex...
code_fim
medium
{ "lang": "rust", "repo": "melvinw/besstools", "path": "/tools/src/bin/bessctl/supernode.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> res.iter() .for_each(|(&c, &count)| { acc.entry(c) .and_modify(|x| *x += count) .or_insert(count); }); acc } pub fn frequency(input: &[&str], worker_count: usize) -> HashMap<char, usize> { let (tx, rx) = mpsc::channel(); input.chunks(in...
code_fim
hard
{ "lang": "rust", "repo": "ipetr0v/exercism", "path": "/rust/parallel-letter-frequency/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn frequency(input: &[&str], worker_count: usize) -> HashMap<char, usize> { let (tx, rx) = mpsc::channel(); input.chunks(input.len() / worker_count + 1) .map(|chunk| chunk.concat()) .map(|chunk| { let thread_tx = tx.clone(); thread::spawn(move || thr...
code_fim
hard
{ "lang": "rust", "repo": "ipetr0v/exercism", "path": "/rust/parallel-letter-frequency/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ipetr0v/exercism path: /rust/parallel-letter-frequency/src/lib.rs use std::collections::HashMap; use std::thread; use std::sync::mpsc; fn count_freq(input: String) -> HashMap<char, usize> { input.to_lowercase() .chars() .filter(|c| c.is_alphabetic()) .fold(HashMap...
code_fim
hard
{ "lang": "rust", "repo": "ipetr0v/exercism", "path": "/rust/parallel-letter-frequency/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>USAGE: cargo xtask install [FLAGS] FLAGS: --client[=CLIENT] Install only VS Code plugin. CLIENT is one of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss' --server Install only the language server --mimalloc Use mim...
code_fim
hard
{ "lang": "rust", "repo": "WilliamVenner/rust-analyzer", "path": "/xtask/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WilliamVenner/rust-analyzer path: /xtask/src/main.rs //! See https://github.com/matklad/cargo-xtask/. //! //! This binary defines various auxiliary build commands, which are not //! expressible with just `cargo`. Notably, it provides `cargo xtask codegen` //! for code generation and `cargo xtask...
code_fim
hard
{ "lang": "rust", "repo": "WilliamVenner/rust-analyzer", "path": "/xtask/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jabedude/RustFS path: /libslab/lib.rs #![allow(raw_pointer_deriving)] #![crate_type = "lib"] #![crate_id = "slab"] /** * A growing (not yet shrinking), typed slab allocator. * * To use: * * let s = SlabAllocator::new(10); * { * let mut first = s.alloc(0); // Type is SlabBox<'a, int> *...
code_fim
hard
{ "lang": "rust", "repo": "jabedude/RustFS", "path": "/libslab/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> struct MyThing<'r> { item: RefCell<Option<SlabBox<'r, int>>>, allocator: SlabAllocator<int> } impl<'r> MyThing<'r> { fn new() -> MyThing { let thing = MyThing { item: RefCell::new(None), allocator: SlabAllocator::new(10) }; thing ...
code_fim
hard
{ "lang": "rust", "repo": "jabedude/RustFS", "path": "/libslab/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] #[should_panic] fn test_box_struct_dealloc() { let slab_allocator = SlabAllocator::new(20); { let struct_obj = box MyThing { field1: Some(box 2445), done: false }; let object = slab_allocator.alloc(struct_obj); assert_eq!(object.field1, Some(box 2445)); } //...
code_fim
hard
{ "lang": "rust", "repo": "jabedude/RustFS", "path": "/libslab/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wujinderead/MyGoProjects path: /gotest/leet_rust/tests/leet1889_minimum_space_wasted_from_packaging.rs // https://leetcode.com/problems/minimum-space-wasted-from-packaging/ // You have n packages that you are trying to place in boxes, one package in each box. There are // m suppliers that each ...
code_fim
hard
{ "lang": "rust", "repo": "wujinderead/MyGoProjects", "path": "/gotest/leet_rust/tests/leet1889_minimum_space_wasted_from_packaging.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test() { let testcases = vec![ Solution { packages: vec![2,3,5], boxes: vec![vec![4,8],vec![2,8]], ans: 6, }, Solution { packages: vec![2,3,5], boxes: vec![vec![1,...
code_fim
hard
{ "lang": "rust", "repo": "wujinderead/MyGoProjects", "path": "/gotest/leet_rust/tests/leet1889_minimum_space_wasted_from_packaging.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ftvkyo/succotash path: /src/analyze/features/hue.rs //! TODO /// Hue of an image, in degrees, normalized. /// /// Can be used as a key for sorting in a regular way. /// This hue may be calculated in a weird way, don't rely on it /// to be generated in some potentially existing standard way. ///...
code_fim
hard
{ "lang": "rust", "repo": "ftvkyo/succotash", "path": "/src/analyze/features/hue.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Find mean color and then extract its hue in the HSV color space. let mut color_rgb = (0., 0., 0.); let original_rgb_bytes = original_rgb.as_raw(); let pixels = original_rgb_bytes.len() / 3; for i in 0..pixels { color_rgb = ( color_rgb....
code_fim
hard
{ "lang": "rust", "repo": "ftvkyo/succotash", "path": "/src/analyze/features/hue.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>nder::TokioMpscSender; pub(crate) use tokio_oneshot_receiver::TokioOneshotReceiver; pub(crate) use tokio_oneshot_sender::TokioOneshotSender; pub(crate) use tokio_socket_connect::TokioSocketConnect; pub use tokio_type_factory::TokioTypeFactory;<|fim_prefix|>// repo: rsbt/rsbt path: /_rsbt-app/src/tokio/mo...
code_fim
medium
{ "lang": "rust", "repo": "rsbt/rsbt", "path": "/_rsbt-app/src/tokio/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rsbt/rsbt path: /_rsbt-app/src/tokio/mod.rs mod socket_listener; mod tokio_app_runtime; mod tokio_mpsc_sender; mod tokio_oneshot_receiver; mod tokio_oneshot_sender; <|fim_suffix|>nder::TokioMpscSender; pub(crate) use tokio_oneshot_receiver::TokioOneshotReceiver; pub(crate) use tokio_oneshot_send...
code_fim
medium
{ "lang": "rust", "repo": "rsbt/rsbt", "path": "/_rsbt-app/src/tokio/mod.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> println!("Recv: {}", a); assert_eq!(a, i); i += 1; if i == PACKETS { break; } } assert_eq!(i, PACKETS); }) .unwrap(); // start stransmit process let mut c...
code_fim
hard
{ "lang": "rust", "repo": "vidanio/srt-rs", "path": "/tests/stransmit_interop.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vidanio/srt-rs path: /tests/stransmit_interop.rs use std::process::Command; use std::str; use std::str::FromStr; use std::thread; use std::time::{Duration, Instant}; use futures::{stream::iter_ok, Future, Sink, Stream}; use futures_timer::Interval; use tokio_codec::BytesCodec; use tokio_udp::...
code_fim
hard
{ "lang": "rust", "repo": "vidanio/srt-rs", "path": "/tests/stransmit_interop.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> event_loop.run_once(&mut server, Some(100)).unwrap(); } /// Run server (in separate thread) pub fn run_async(&self) -> Result<(), Error> { if self.is_stopping.load(Ordering::Relaxed) { return Err(Error::IsStopping) } if !self.is_stopped.load(Ordering::Relaxed) { return...
code_fim
hard
{ "lang": "rust", "repo": "DigixGlobal/json-tcp-server", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DigixGlobal/json-tcp-server path: /src/lib.rs hould have received a copy of the GNU General Public License // along with Parity. If not, see <http://www.gnu.org/licenses/>. //! jsonrpc server over unix sockets //! //! ```no_run //! extern crate jsonrpc_core; //! extern crate json_tcp_server; /...
code_fim
hard
{ "lang": "rust", "repo": "DigixGlobal/json-tcp-server", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }