text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> match self.0 { Some(ref mut b) => b.deref_mut().write(buf), None => self.1.write(buf), } } fn flush(&mut self) -> std::io::Result<()> { match self.0 { None => self.1.flush(), _ => Ok(()), } } } #[cfg(test)] mod t...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/lib/writer/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> else { format!("{} bottles of beer on the wall, {} bottles of beer.\nTake one down and pass it around, {} bottles of beer on the wall.\n", n, n , n - 1)} } pub fn sing(start: i32, end: i32) -> String { let mut song = String::new(); for i in (end..start+1).rev(){ //println!("{...
code_fim
hard
{ "lang": "rust", "repo": "shivanth/exercism-rust", "path": "/beer-song/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shivanth/exercism-rust path: /beer-song/src/lib.rs pub fn verse(n : i32)->String{ if n == 0 { return "No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall.\n".to_string(); } <|fim_suffix|> pub fn sing(st...
code_fim
hard
{ "lang": "rust", "repo": "shivanth/exercism-rust", "path": "/beer-song/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bitterbit/LibAFL path: /libafl/src/fuzzer.rs executor: &mut E, manager: &mut EM, input: I, ) -> Result<usize, Error>; } /// The main fuzzer trait. pub trait Fuzzer<E, EM, I, S, ST> { /// Fuzz for a single iteration /// Returns the index of the last fuzzed corpus...
code_fim
hard
{ "lang": "rust", "repo": "bitterbit/LibAFL", "path": "/libafl/src/fuzzer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, state: &mut S, manager: &mut EM, input: &I, observers: &OT, exit_kind: &ExitKind, ) -> Result<bool, Error> where EM: EventFirer<I, S>, { self.feedback_mut() .is_interesting(state, manager, input, observers, ...
code_fim
hard
{ "lang": "rust", "repo": "bitterbit/LibAFL", "path": "/libafl/src/fuzzer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, state: &mut S, executor: &mut E, manager: &mut EM, input: I, ) -> Result<usize, Error> { let _ = self.execute_input(state, executor, manager, &input)?; let observers = executor.observers(); // Always consider this to be "intere...
code_fim
hard
{ "lang": "rust", "repo": "bitterbit/LibAFL", "path": "/libafl/src/fuzzer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let size = os2ip(&input[..size_bytes])?; if size_bytes + size > input.len() { return Err(PakeError::SerializationError); } Ok(( input[size_bytes..size_bytes + size].to_vec(), input[size_bytes + size..].to_vec(), )) } #[cfg(test)] mod tests;<|fim_prefix|>// rep...
code_fim
hard
{ "lang": "rust", "repo": "haochenuw/opaque-ke", "path": "/src/serialization/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut output_array = [0u8; std::mem::size_of::<usize>()]; output_array[std::mem::size_of::<usize>() - input.len()..].copy_from_slice(input); Ok(usize::from_be_bytes(output_array)) } // Computes I2OSP(len(input), max_bytes) || input pub(crate) fn serialize(input: &[u8], max_bytes: usize) -> ...
code_fim
hard
{ "lang": "rust", "repo": "haochenuw/opaque-ke", "path": "/src/serialization/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: haochenuw/opaque-ke path: /src/serialization/mod.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. use crate::errors::PakeError; <|fim_suffix|> let size = os...
code_fim
hard
{ "lang": "rust", "repo": "haochenuw/opaque-ke", "path": "/src/serialization/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } } } 0 } fn main() { println!("{}", calcul()); }<|fim_prefix|>// repo: remigranotier/Project_Euler_Rust path: /problem_9/src/main.rs fn calcul() -> u32 { let res; for a in 1..1001 { for b in 1..(1001-a) { for c in 1..(1001-a-b...
code_fim
hard
{ "lang": "rust", "repo": "remigranotier/Project_Euler_Rust", "path": "/problem_9/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: remigranotier/Project_Euler_Rust path: /problem_9/src/main.rs fn calcul() -> u32 { let res; for a in 1..1001 { for b in 1..(1001-a) { <|fim_suffix|> res = a*b*c; println!("{} {} {}", a, b, c); return res; } ...
code_fim
hard
{ "lang": "rust", "repo": "remigranotier/Project_Euler_Rust", "path": "/problem_9/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Response::builder() .body( urls.iter() .map(|url| url.as_str().to_string()) .collect::<Vec<String>>() .join(", "), ) .into...
code_fim
hard
{ "lang": "rust", "repo": "jjmark15/bookmarks-search-engine", "path": "/bookmarks/src/ports/http/warp/search.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jjmark15/bookmarks-search-engine path: /bookmarks/src/ports/http/warp/search.rs use std::collections::HashMap; use std::str::FromStr; use std::sync::Arc; use warp::http::{Response, StatusCode, Uri}; use warp::{Filter, Reply}; use crate::application::ApplicationService; use crate::ports::http::...
code_fim
hard
{ "lang": "rust", "repo": "jjmark15/bookmarks-search-engine", "path": "/bookmarks/src/ports/http/warp/search.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> p: HashMap<String, String>, application_service: Arc<AS>, ) -> warp::reply::Response { match p.get("q") { Some(term) => match application_service.search(term.clone()) { Ok(urls) => { if urls.len() == 1 { let url = urls.get(0).unwrap().clo...
code_fim
hard
{ "lang": "rust", "repo": "jjmark15/bookmarks-search-engine", "path": "/bookmarks/src/ports/http/warp/search.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kellpossible/oldnav path: /src/navdata/country.rs //! A module with methods for `Country` and other associated functions and interfaces. use std::fmt; /// Represents a country on earth that is recognised in the icao codes. pub struct Country { /// The [icao code](http://www.avcodes.co.uk/i...
code_fim
hard
{ "lang": "rust", "repo": "kellpossible/oldnav", "path": "/src/navdata/country.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Debug for Country { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { return write!(f, "Country: {{code: {}, name: {}}}", self.code, self.name); } }<|fim_prefix|>// repo: kellpossible/oldnav path: /src/navdata/country.rs //! A module with methods for `Country` and other as...
code_fim
hard
{ "lang": "rust", "repo": "kellpossible/oldnav", "path": "/src/navdata/country.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let d = (0, 0, "data_id".to_owned()); let config = Config { do_foo_op: true, conditional_add: Some(3), }; let _result = transform(d, &config); }<|fim_prefix|>// repo: jlricon/rust-impl-struct path: /examples/tidy_enum.rs struct Config { do_foo_op: bool, conditional...
code_fim
hard
{ "lang": "rust", "repo": "jlricon/rust-impl-struct", "path": "/examples/tidy_enum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jlricon/rust-impl-struct path: /examples/tidy_enum.rs struct Config { do_foo_op: bool, conditional_add: Option<u32>, } type Data = (u32, u32, String); enum Operation { FooOp, ConditionalAdd, } #[derive(Copy, Clone)] enum Step { First, Second, } fn foo_op(d: &mut Data, c: ...
code_fim
hard
{ "lang": "rust", "repo": "jlricon/rust-impl-struct", "path": "/examples/tidy_enum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let carry = __add2(&mut self.data, &[other as BigDigit]); if carry != 0 { self.data.push(carry); } } } } impl Add<u128> for BigUint { type Output = BigUint; #[inline] fn add(mut self, other: u128) -> BigUint { self += ot...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/num-bigint/src/biguint/addition.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/vendor/num-bigint/src/biguint/addition.rs #[cfg(not(u64_digit))] use super::u32_from_u128; use super::{BigUint, IntDigits}; use crate::big_digit::{self, BigDigit}; use crate::UsizePromotion; use core::iter::Sum; use core::ops::{Add, AddAssign}; u...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/num-bigint/src/biguint/addition.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zireael-N/node-weakauras-parser path: /native/src/lib_serialize/deserialization/mod.rs mod reader; use super::{EmbeddedTypeTag, TypeTag, MINOR}; use crate::macros::check_recursion; use reader::SliceReader; use serde_json::{map::Map, Number, Value}; fn f64_to_json_value(value: f64) -> Value { ...
code_fim
hard
{ "lang": "rust", "repo": "Zireael-N/node-weakauras-parser", "path": "/native/src/lib_serialize/deserialization/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..len { check_recursion!(self, { let (key, value) = (self.extract_key()?, self.extract_value()?); map.insert(key, value); }); } let map = Value::Object(map); self.table_refs.push(map.clone()); Ok(ma...
code_fim
hard
{ "lang": "rust", "repo": "Zireael-N/node-weakauras-parser", "path": "/native/src/lib_serialize/deserialization/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>self.utf8().unwrap().$method($($args),*), DataType::UInt8 => $self.u8().unwrap().$method($($args),*), DataType::UInt16 => $self.u16().unwrap().$method($($args),*), DataType::UInt32 => $self.u32().unwrap().$method($($args),*), DataType::UInt64 => $self.u64()....
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/py-polars/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pola-rs/polars path: /py-polars/src/utils.rs use polars::prelude::*; pub fn reinterpret(s: &Series, signed: bool) -> PolarsResult<Series> { Ok(match (s.dtype(), signed) { (DataType::UInt64, true) => s.u64().unwrap().reinterpret_signed().into_series(), (DataType::UInt64, fals...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/py-polars/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl MuteModel { pub async fn from_mute(services: &Services, mute: &Mute) -> MuteModel { let user = if let Some(id) = NonZeroU64::new(mute.user_id as u64) { let user_id = UserId(id); UserModel::from_id(services, user_id).await } else { Default::defau...
code_fim
hard
{ "lang": "rust", "repo": "Samoxive/SafetyJim", "path": "/src/server/model/mute.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let moderator_user = if let Some(id) = NonZeroU64::new(mute.moderator_user_id as u64) { let user_id = UserId(id); UserModel::from_id(services, user_id).await } else { Default::default() }; MuteModel { id: mute.id, ...
code_fim
hard
{ "lang": "rust", "repo": "Samoxive/SafetyJim", "path": "/src/server/model/mute.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Samoxive/SafetyJim path: /src/server/model/mute.rs use std::num::NonZeroU64; use serde::{Deserialize, Serialize}; use serenity::model::id::UserId; use crate::server::model::user::UserModel; use crate::database::mutes::Mute; use crate::service::Services; #[derive(Serialize, Deserialize)] #[ser...
code_fim
hard
{ "lang": "rust", "repo": "Samoxive/SafetyJim", "path": "/src/server/model/mute.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if local_path.is_dir(){ if fnas_path.exists() == false { match fs::create_dir(fnas_path) { Ok(_) => println!("{}% - Created new folder: {}", *file_count*100/total_count, fnas_path.to_str().unwrap()), ...
code_fim
hard
{ "lang": "rust", "repo": "jackfisher100/file_backup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for file in local_files{ let file = file.unwrap(); let local_path = file.path(); let fnas_dir = &format!("{}{}\\{}", FNAS_BASE, dir, file.file_name().to_str().unwrap()); let fnas_path = Path::new(fnas_dir); ...
code_fim
hard
{ "lang": "rust", "repo": "jackfisher100/file_backup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jackfisher100/file_backup path: /src/main.rs use std::fs; use std::path::Path; #[allow(unused_imports)] use std::io; #[allow(unused_imports)] use ftp::FtpStream; #[allow(unused_imports)] use std::time::SystemTime; const LOCAL_BASE: &str = "D:\\Documents\\Computing\\Rust\\file_backup"; const F...
code_fim
hard
{ "lang": "rust", "repo": "jackfisher100/file_backup", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>!(max_prio, 99); /// ``` pub unsafe fn sched_get_priority_max(policy: i32) -> Result<i32, Errno> { let policy = policy as usize; syscall1(SYS_SCHED_GET_PRIORITY_MAX, policy).map(|ret| ret as i32) }<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/sched_get_priority_max.rs /// Get static priori...
code_fim
medium
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/sched_get_priority_max.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/sched_get_priority_max.rs /// Get static priority max value. /// /// # Example /// /// ``` /// let ret = unsafe { nc::sched_get_<|fim_suffix|> let policy = policy as usize; syscall1(SYS_SCHED_GET_PRIORITY_MAX, policy).map(|ret| ret as i32) }<|fim_middle|>priorit...
code_fim
hard
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/sched_get_priority_max.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KeenS/tempfile path: /src/imp/windows.rs use std::os::windows::ffi::OsStrExt; use std::os::windows::io::{FromRawHandle, AsRawHandle, RawHandle}; use std::path::Path; use std::io; use std::ptr; use std::fs::{self, File}; use winapi::{self, DWORD, HANDLE}; use kernel32::{CreateFileW, ReOpenFile, S...
code_fim
hard
{ "lang": "rust", "repo": "KeenS/tempfile", "path": "/src/imp/windows.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let old_path_w = to_utf16(old_path); // Don't succeed if this fails. We don't want to claim to have successfully persisted a file // still marked as temporary because this file won't have the same consistency guarantees. if unsafe { SetFileAttributesW(old_path_w.as_ptr(), winapi::FILE_ATT...
code_fim
hard
{ "lang": "rust", "repo": "KeenS/tempfile", "path": "/src/imp/windows.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yours-plus/first_ray_tracer path: /src/util.rs use super::vec3d::*; pub fn random_in_unit_sphere() -> Vec3D { loop { let p = 2.0 * new_vec3d(rand::rando<|fim_suffix|> if p.norm() <= 1.0 { return p; } } }<|fim_middle|>m(), rand::random(), rand:...
code_fim
medium
{ "lang": "rust", "repo": "yours-plus/first_ray_tracer", "path": "/src/util.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if p.norm() <= 1.0 { return p; } } }<|fim_prefix|>// repo: yours-plus/first_ray_tracer path: /src/util.rs use super::vec3d::*; pub fn random_in_unit_sphere() -> Vec3D { <|fim_middle|> loop { let p = 2.0 * new_vec3d(rand::random(), rand::random(), rand:...
code_fim
medium
{ "lang": "rust", "repo": "yours-plus/first_ray_tracer", "path": "/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>m(), rand::random(), rand::random()) - new_vec3d(1., 1., 1.); if p.norm() <= 1.0 { return p; } } }<|fim_prefix|>// repo: yours-plus/first_ray_tracer path: /src/util.rs use super::vec3d::*; pub fn random_in_unit_sphere() -> Vec3D { <|fim_middle|> loop { let p = ...
code_fim
medium
{ "lang": "rust", "repo": "yours-plus/first_ray_tracer", "path": "/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexandru-calinoiu/rustician path: /slices/src/main.rs fn main() { let string = String::from("Wizz air"); let wizz = &string[0..=3]; let air = &string[5..]; <|fim_suffix|> let greeting = String::from("Hello world!"); println!("First word is '{}'", first_word(&greeting)); } ...
code_fim
medium
{ "lang": "rust", "repo": "alexandru-calinoiu/rustician", "path": "/slices/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { if let Some(qp) = heap.pop() { // If the size per axis on the partition is 1 (3*1) we have reached the coordinate we're looking for if qp.p.dist() == 3 { found_coord = qp.p.p2; break; } // For every iterati...
code_fim
hard
{ "lang": "rust", "repo": "bwestlin/advent-of-code-2018-rs", "path": "/src/day23/day23.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bwestlin/advent-of-code-2018-rs path: /src/day23/day23.rs extern crate regex; #[macro_use] extern crate lazy_static; extern crate utils; use std::cmp::Ordering; use std::cmp; use std::collections::BinaryHeap; use std::str::FromStr; use std::error::Error; use std::num::ParseIntError; use std::io...
code_fim
hard
{ "lang": "rust", "repo": "bwestlin/advent-of-code-2018-rs", "path": "/src/day23/day23.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn dist_origo(&self) -> i32 { let d1 = (self.p1.x).abs() + (self.p1.y).abs() + (self.p1.z).abs(); let d2 = (self.p2.x).abs() + (self.p2.y).abs() + (self.p2.z).abs(); if d1 < d2 { d1 } else { d2 } } } #[derive(Eq, Debug)] struct QueuedPartition { p: Partition, nb_id...
code_fim
hard
{ "lang": "rust", "repo": "bwestlin/advent-of-code-2018-rs", "path": "/src/day23/day23.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum XmlPhase { StartPhase, MainPhase, EndPhase, } /// A subset/refinement of `tokenizer::XToken`. Everything else is handled /// specially at the beginning of `process_token`. #[derive(PartialEq, Eq, Clone, Debug)] pub enum Token { TagTok...
code_fim
medium
{ "lang": "rust", "repo": "servo/html5ever", "path": "/xml5ever/src/tree_builder/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use crate::tendril::StrTendril; use crate::tokenizer::{Doctype, Pi, Tag}; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum XmlPhase { StartPhase, MainPhase, EndPhase, } /// A subset/refinement of `tokenizer::XToken`. Everything else is handled /// specially at the beginning of `process...
code_fim
medium
{ "lang": "rust", "repo": "servo/html5ever", "path": "/xml5ever/src/tree_builder/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: servo/html5ever path: /xml5ever/src/tree_builder/types.rs // Copyright 2014-2017 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/...
code_fim
medium
{ "lang": "rust", "repo": "servo/html5ever", "path": "/xml5ever/src/tree_builder/types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Iterate over items whose spans are exactly equal to `span`. The order of the returned /// items is unspecified. pub fn lookup_exact(&self, span: Span) -> impl Iterator<Item = &T> { let data = span.data(); let start = self.v.partition_point(|(s, _)| s.lo() < data.lo); ...
code_fim
hard
{ "lang": "rust", "repo": "immunant/c2rust", "path": "/c2rust-analyze/src/rewrite/span_index.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: immunant/c2rust path: /c2rust-analyze/src/rewrite/span_index.rs //! Defines the [`SpanIndex`] data structure for looking up MIR statements by span. use rustc_span::Span; /// A mapping from [`Span`]s to values of type `T`. Allows looking up all items whose span is a /// subset of some target sp...
code_fim
hard
{ "lang": "rust", "repo": "immunant/c2rust", "path": "/c2rust-analyze/src/rewrite/span_index.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mart368b/simple_gl path: /src/storage/buffer/vao.rs use gl::types::*; use super::{Primitive, Buffer, BufferData, BufferAcces, BufferType, Format}; use crate::get_value; use anyhow::{Result, bail}; use std::collections::HashMap; type AttributePoint = (GLuint, GLint, GLenum, GLboolean, GLsizei,...
code_fim
hard
{ "lang": "rust", "repo": "mart368b/simple_gl", "path": "/src/storage/buffer/vao.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Keep track of offset between parameters let mut offset: GLuint = 0; let mut bindings = Vec::new(); for (id, (ty, count)) in prototype.iter().enumerate() { if (id as GLuint) + location > self.location_count { bail!("Ran out of shader variable l...
code_fim
hard
{ "lang": "rust", "repo": "mart368b/simple_gl", "path": "/src/storage/buffer/vao.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: praffn/rusty-rays path: /src/geom/scene.rs use super::mat::Material; use crate::film::Color; use crate::light::Light; use crate::linalg::Ray; use crate::Shape; <|fim_suffix|>impl Scene { pub fn trace(&self, ray: &Ray) -> Color { match self.shape.hit(ray) { None => Color:...
code_fim
medium
{ "lang": "rust", "repo": "praffn/rusty-rays", "path": "/src/geom/scene.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Scene { pub fn trace(&self, ray: &Ray) -> Color { match self.shape.hit(ray) { None => Color::black(), Some(hit_info) => hit_info.material.shade(&ray, &hit_info, self), } } }<|fim_prefix|>// repo: praffn/rusty-rays path: /src/geom/scene.rs use super::ma...
code_fim
medium
{ "lang": "rust", "repo": "praffn/rusty-rays", "path": "/src/geom/scene.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>FINE_GUID! {IID_IDirectXFileDataReference, 0x3d82ab45, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} DEFINE_GUID! {IID_IDirectXFileBinary, 0x3d82ab46, 0x62da, 0x11cf, 0xab, 0x39, 0x00, 0x20, 0xaf, 0x71, 0xe4, 0x33} DEFINE_GUID! {TID_DXFILEHeader, 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0...
code_fim
hard
{ "lang": "rust", "repo": "eiz/winapi-rs-ex", "path": "/src/um/dxfile.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eiz/winapi-rs-ex path: /src/um/dxfile.rs // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice...
code_fim
hard
{ "lang": "rust", "repo": "eiz/winapi-rs-ex", "path": "/src/um/dxfile.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<Key, Data> Default for InProgressCommitData<Key, Data> { fn default() -> Self { Self { commit_waiters: SmallVec::new(), next_deadline: None, } } } #[derive(Default)] struct InProgressCommit<Key, Data> { inner: Option<Box<InProgressCommitData<Key, D...
code_fim
hard
{ "lang": "rust", "repo": "coadler/thingvellir", "path": "/src/shard/upstream_manager.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coadler/thingvellir path: /src/shard/upstream_manager.rs use std::collections::HashMap; use std::future::Future; use std::hash::Hash; use smallvec::SmallVec; use tokio::sync::mpsc; use tokio::time::Instant; use super::commit_queue::{ poll_option_ready, CommitQueue, EnqueuedCommit, Persist...
code_fim
hard
{ "lang": "rust", "repo": "coadler/thingvellir", "path": "/src/shard/upstream_manager.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>struct TakeDataPending {} impl<Key, Data> InProgressCommit<Key, Data> { /// Creates an `InProgressCommit` with the given immediate commit waiters. The waiters will be called /// once the commit is finished, with the result. fn with_immediate_waiters(waiters: ImmediateCommitWaiters) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "coadler/thingvellir", "path": "/src/shard/upstream_manager.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // println!("{}: {:?}", self.label, self.start.elapsed()); } } pub struct Scene<B: hal::Backend> { pub camera: Camera, pub object_mesh: Option<Mesh<B>>, pub per_instance_const: Vec<PerInstanceConst>, pub per_instance: Vec<PerInstance>, pub rx_rad_buffer: Receiver<Vec<cryst...
code_fim
hard
{ "lang": "rust", "repo": "adamnemecek/rendy_playground", "path": "/examples/crystal_planes/render.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self, factory: &mut Factory<B>, _scene: &Scene<B>, ) -> rendy_shader::ShaderSet<B> { SHADERS.build(factory, Default::default()).unwrap() } fn vertices( &self, ) -> Vec<( Vec<hal::pso::Element<hal::format::Format>>, hal::pso::ElemStr...
code_fim
hard
{ "lang": "rust", "repo": "adamnemecek/rendy_playground", "path": "/examples/crystal_planes/render.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamnemecek/rendy_playground path: /examples/crystal_planes/render.rs #![cfg_attr( not(any(feature = "dx12", feature = "metal", feature = "vulkan")), allow(unused) )] // #[cfg(feature = "dx12")] // use gfx_backend_dx12::Backend; // #[cfg(feature = "metal")] // use gfx_backend_metal::Ba...
code_fim
hard
{ "lang": "rust", "repo": "adamnemecek/rendy_playground", "path": "/examples/crystal_planes/render.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jolestar/libra path: /consensus/src/test_utils/mod.rs // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::block_storage::{BlockReader, BlockStore}; use consensus_types::{ block::{block_test_utils::certificate_for_genesis, Block}, common::Round,...
code_fim
hard
{ "lang": "rust", "repo": "jolestar/libra", "path": "/consensus/src/test_utils/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn create_block_with_qc( &self, parent_qc: QuorumCert, timestamp_usecs: u64, round: Round, payload: TestPayload, ) -> Block<TestPayload> { Block::new_proposal(payload, round, timestamp_usecs, parent_qc, &self.signer) } pub fn insert_reco...
code_fim
hard
{ "lang": "rust", "repo": "jolestar/libra", "path": "/consensus/src/test_utils/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KWierso/fetchlogs path: /src/main.rs #[macro_use] extern crate clap; extern crate reqwest; extern crate serde_json; extern crate scoped_threadpool; use clap::{App, Arg}; use serde_json::value::Value; use std::collections::BTreeMap; use std::env; use std::fs::{File, rename}; use std::io::BufWrit...
code_fim
hard
{ "lang": "rust", "repo": "KWierso/fetchlogs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let task_graph_url = get_log_url(client, job_guid, "task-graph.json").unwrap(); get_json(client, &task_graph_url, None) } fn wpt_complete(client: &reqwest::Client, branch: &str, result_set_id: u64) -> bool { // This is assuming that the job has at least started let decision_result = get_d...
code_fim
hard
{ "lang": "rust", "repo": "KWierso/fetchlogs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DasEtwas/enginesound path: /src/utils.rs use crate::gen::{Engine, LoopBuffer, LowPassFilter}; use std::fs::File; pub const SPEED_OF_SOUND: f32 = 343.0; // m/s /// converts a given amount of time into samples #[inline] pub fn seconds_to_samples(seconds: f32, sample_rate: u32) -> usize { (se...
code_fim
hard
{ "lang": "rust", "repo": "DasEtwas/enginesound", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> engine .muffler .muffler_elements .iter_mut() .chain(std::iter::once(&mut engine.muffler.straight_pipe)) .flat_map(|waveguide| vec![&mut waveguide.chamber0, &mut waveguide.chamber1].into_iter()) .chain(engine.cylinders.iter_mut().flat_map(|cylinder| { ...
code_fim
hard
{ "lang": "rust", "repo": "DasEtwas/enginesound", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub type GraphResult<T> = Result<T, GraphFailure>;<|fim_prefix|>// repo: Arstman/graph-rs path: /graph-error/src/lib.rs //! Various errors used to implement the Graph API and OAuth clients for the graph-rs project //! See the project on [GitHub](https://github.com/sreeise/graph-rs). #[macro_use] extern ...
code_fim
medium
{ "lang": "rust", "repo": "Arstman/graph-rs", "path": "/graph-error/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Arstman/graph-rs path: /graph-error/src/lib.rs //! Various errors used to implement the Graph API and OAuth clients for the graph-rs project //! See the project on [GitHub](https://github.com/sreeise/graph-rs). #[macro_use] extern crate serde; <|fim_suffix|>pub type GraphResult<T> = Result<T, ...
code_fim
medium
{ "lang": "rust", "repo": "Arstman/graph-rs", "path": "/graph-error/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wisest30/AlgoStudy path: /source/KickStart/2022_Round_D_3_Touchbar_Typing/hyo.rs use std::cmp::min; use std::io::{stdin, Read}; fn lower_bound(v: &Vec<usize>, val: usize) -> usize { if v.is_empty() || val <= v[0] { 0 } else if *v.last().unwrap() < val { v.len() } els...
code_fim
hard
{ "lang": "rust", "repo": "wisest30/AlgoStudy", "path": "/source/KickStart/2022_Round_D_3_Touchbar_Typing/hyo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut dp = (0..m) .map(|i| if k[i] == s[0] { 0 } else { std::i32::MAX }) .collect::<Vec<_>>(); for i in 1..n { let mut ndp = vec![std::i32::MAX; m]; for &j in idxs[s[i] as usize].iter() { let v = &idxs[s[i - 1] as usize]; ...
code_fim
hard
{ "lang": "rust", "repo": "wisest30/AlgoStudy", "path": "/source/KickStart/2022_Round_D_3_Touchbar_Typing/hyo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut stdin = stdin(); let mut buf = String::new(); stdin.read_to_string(&mut buf).ok(); let mut input = buf.split_ascii_whitespace(); let test_case = input.next().unwrap().parse::<usize>().unwrap(); for tc in 1..=test_case { let n = input.next().unwrap().parse::<usize>(...
code_fim
hard
{ "lang": "rust", "repo": "wisest30/AlgoStudy", "path": "/source/KickStart/2022_Round_D_3_Touchbar_Typing/hyo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust-bindgen path: /bindgen-tests/tests/expectations/tests/virtual_overloaded.rs #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] pub struct C__bindgen_vtable { pub C_do_thing: unsafe extern "C" fn(this: *mut C, arg1: ::std::os::raw::c_c...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-bindgen", "path": "/bindgen-tests/tests/expectations/tests/virtual_overloaded.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mopp/CodeGarage path: /rust/design_patterns/memento.rs trait Originator { fn generate_memento(&self) -> Box<Memento>; fn restore_from_memento(&mut self, &Memento); } trait Caretaker { fn add_memento(&mut self, Box<Memento>); fn get_memento(&mut self, usize) -> &Memento; } tra...
code_fim
hard
{ "lang": "rust", "repo": "mopp/CodeGarage", "path": "/rust/design_patterns/memento.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> CaretakerX { history: Vec::new(), } } } impl Caretaker for CaretakerX { fn add_memento(&mut self, m: Box<Memento>) { self.history.push(m) } fn get_memento(&mut self, index: usize) -> &Memento { & *self.history[index] } } fn main()...
code_fim
hard
{ "lang": "rust", "repo": "mopp/CodeGarage", "path": "/rust/design_patterns/memento.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/impl-trait/where-allowed.rs //! A simple test for testing many permutations of allowedness of //! impl Trait use std::fmt::Debug; // Allowed fn in_parameters(_: impl Debug) { panic!() } // Allowed fn in_return() -> impl Debug { panic!() } // ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/impl-trait/where-allowed.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types } // Allowed struct DummyType; impl DummyType { fn in_inherent_impl_parameters(_: impl Debug) { } fn in_inherent_impl_return() -> impl Debug { () } } // Disallowed extern "C" { fn in_foreign_paramete...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/impl-trait/where-allowed.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rwx-777/Rust-LearningRepo path: /vars.rs //Varibles hold primitive data or reference to data //Varibles are imutable by default <|fim_suffix|> //Assign multiple varibles at once let (myname, my_age ) = ("Darleen", 29); println!("Name:{} Age:{}",myname, my_age); }<|fim_middle|>pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "rwx-777/Rust-LearningRepo", "path": "/vars.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Assign multiple varibles at once let (myname, my_age ) = ("Darleen", 29); println!("Name:{} Age:{}",myname, my_age); }<|fim_prefix|>// repo: rwx-777/Rust-LearningRepo path: /vars.rs //Varibles hold primitive data or reference to data //Varibles are imutable by default <|fim_middle|>pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "rwx-777/Rust-LearningRepo", "path": "/vars.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf9160-pac path: /src/ficr_s/info/variant.rs #[doc = "Reader of register VARIANT"] pub type R = crate::R<u32, super::VARIANT>; #[doc = "Part Variant, Hardware version and Production configuration, encoded as ASCII\n\nValue on reset: 268435455"] #[derive(Clone, Copy, Debug, PartialEq)] #[...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf9160-pac", "path": "/src/ficr_s/info/variant.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> use crate::Variant::*; match self.bits { 1094795585 => Val(VARIANT_A::AAAA), 1094795568 => Val(VARIANT_A::AAA0), i => Res(i), } } #[doc = "Checks if the value of the field is `AAAA`"] #[inline(always)] pub fn is_aaaa(&self) -> bool ...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf9160-pac", "path": "/src/ficr_s/info/variant.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Blockstream/gdk path: /subprojects/gdk_rust/gdk_common/src/be/transaction.rs { let outpoint = elements::OutPoint { txid: tx.txid(), vout, }; all_unblinded.get(&outpoint).map(|unblinded| unblinded.value) ...
code_fim
hard
{ "lang": "rust", "repo": "Blockstream/gdk", "path": "/subprojects/gdk_rust/gdk_common/src/be/transaction.rs", "mode": "psm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Blockstream/gdk path: /subprojects/gdk_rust/gdk_common/src/be/transaction.rs lf::Bitcoin(tx) => BEOutPoint::new_bitcoin(tx.txid(), vout), Self::Elements(tx) => BEOutPoint::new_elements(tx.txid(), vout), } } pub fn output_value( &self, vout: u32, ...
code_fim
hard
{ "lang": "rust", "repo": "Blockstream/gdk", "path": "/subprojects/gdk_rust/gdk_common/src/be/transaction.rs", "mode": "psm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_suffix|> tx.input .iter() .map(|i| BEOutPoint::Bitcoin(i.previous_output)) .filter_map(|o| all_txs.get_previous_output_value(&o, &HashMap::new())) //no need of unblinded since this fn is bitcoin only .sum() } #[derive(Default, Serialize, Deserialize)] pub struct BETransactions(...
code_fim
hard
{ "lang": "rust", "repo": "Blockstream/gdk", "path": "/subprojects/gdk_rust/gdk_common/src/be/transaction.rs", "mode": "spm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "std")] pub mod fileio; #[doc(hidden)] #[cfg(feature = "std")] pub use fileio::FileIOMemory; #[cfg(feature = "filemap")] pub mod filemap; #[cfg(feature = "filemap")] pub use filemap::{ MMAPInfo, MMAPInfoMut, ReadMappedFilePhysicalMemory, WriteMappedFilePhysicalMemory, }; pub mod mmap...
code_fim
hard
{ "lang": "rust", "repo": "MurphyKyle/apex_dma_kvm_pub", "path": "/apex_dma/memflow_lib/memflow/src/connector/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "filemap")] pub mod filemap; #[cfg(feature = "filemap")] pub use filemap::{ MMAPInfo, MMAPInfoMut, ReadMappedFilePhysicalMemory, WriteMappedFilePhysicalMemory, }; pub mod mmap; #[doc(hidden)] pub use mmap::MappedPhysicalMemory;<|fim_prefix|>// repo: MurphyKyle/apex_dma_kvm_pub path: ...
code_fim
medium
{ "lang": "rust", "repo": "MurphyKyle/apex_dma_kvm_pub", "path": "/apex_dma/memflow_lib/memflow/src/connector/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MurphyKyle/apex_dma_kvm_pub path: /apex_dma/memflow_lib/memflow/src/connector/mod.rs /*! Module containing basic connector and inventory related functions. This module provides basic building blocks when building connectors. It contains a file i/o and memory mapped file interface as well as a i...
code_fim
hard
{ "lang": "rust", "repo": "MurphyKyle/apex_dma_kvm_pub", "path": "/apex_dma/memflow_lib/memflow/src/connector/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>] impl crate::Writable for IEN {} #[doc = "Interrupt Enable Register"] pub mod ien; #[doc = "Synchronization Busy Register\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [syncbusy](sy...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/letimer1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/letimer1.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control Register"] pub ctrl: CTRL, #[doc = "0x04 - Command Register"] pub cmd: CMD, #[doc = "0x08 - Status Register"] pub status: ST...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/letimer1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vpanghalCohesity/c-ares-resolver path: /src/windows/eventloop.rs use std::mem; use std::ptr; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; use winapi::um::winsock2::{ fd_set, select, timeval, WSACleanup, WSAStartup, SOC...
code_fim
hard
{ "lang": "rust", "repo": "vpanghalCohesity/c-ares-resolver", "path": "/src/windows/eventloop.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Process whatever happened. match results { SOCKET_ERROR => panic!("Socket error"), _ => self .ares_channel .lock() .unwrap() .process(&...
code_fim
hard
{ "lang": "rust", "repo": "vpanghalCohesity/c-ares-resolver", "path": "/src/windows/eventloop.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if count == 0 { thread::sleep(Duration::from_millis(100)); } else { let timeout = timeval { tv_sec: 0, tv_usec: 100_000, }; let results = unsafe { select(0, &...
code_fim
hard
{ "lang": "rust", "repo": "vpanghalCohesity/c-ares-resolver", "path": "/src/windows/eventloop.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Styren/contraband path: /examples/diesel/src/controller.rs use crate::service::{BookService, InsertBook}; use actix_web::{web, HttpResponse}; use contraband::{controller, Injectable}; use serde::{Deserialize, Serialize}; use std::sync::Arc; <|fim_suffix|>#[derive(Serialize, Deserialize)] pub st...
code_fim
medium
{ "lang": "rust", "repo": "Styren/contraband", "path": "/examples/diesel/src/controller.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[post] async fn add_book(self, input: web::Json<NewBookInput>) -> HttpResponse { match self .book_service .add_book(InsertBook { title: input.title.clone(), author: input.author.clone(), }) .await { ...
code_fim
hard
{ "lang": "rust", "repo": "Styren/contraband", "path": "/examples/diesel/src/controller.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod constants; mod storage; pub use constants::{Version, VERSION, VERSION_STRING}; pub use storage::{OptionalStorage, RamStorage};<|fim_prefix|>// repo: Nitrokey/nitrokey-3-firmware path: /components/utils/src/lib.rs #![cfg_attr(not(test), no_std)] <|fim_middle|>extern crate delog; delog::generate_macr...
code_fim
easy
{ "lang": "rust", "repo": "Nitrokey/nitrokey-3-firmware", "path": "/components/utils/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nitrokey/nitrokey-3-firmware path: /components/utils/src/lib.rs #![cfg_attr(not(test), no_std)] <|fim_suffix|>mod constants; mod storage; pub use constants::{Version, VERSION, VERSION_STRING}; pub use storage::{OptionalStorage, RamStorage};<|fim_middle|>extern crate delog; delog::generate_macr...
code_fim
easy
{ "lang": "rust", "repo": "Nitrokey/nitrokey-3-firmware", "path": "/components/utils/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Happy-Ferret/wasm-pack path: /src/main.rs extern crate wasm_pack; extern crate indicatif; #[macro_use] extern crate quicli; use std::time::Instant; use indicatif::HumanDuration; use quicli::prelude::*; use wasm_pack::{bindgen, build, emoji, manifest, npm, readme, PBAR}; /// 📦 ✨ pack and pu...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/wasm-pack", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>main!(|args: Cli, log_level: verbosity| match args.cmd { Command::Init { path, scope } => { let started = Instant::now(); let crate_path = match path { Some(p) => p, None => ".".to_string(), }; build::rustup_add_wasm_target(); build::ca...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/wasm-pack", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let crate_path = match path { Some(p) => p, None => ".".to_string(), }; build::rustup_add_wasm_target(); build::cargo_build_wasm(&crate_path); wasm_pack::create_pkg_dir(&crate_path)?; manifest::write_package_json(&crate_path, scope)?...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/wasm-pack", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uuu-mp4/realm path: /src/relay/types.rs use std::net::{SocketAddr, ToSocketAddrs}; use tokio::io; use super::dns; #[derive(Clone)] pub enum RemoteAddr { SocketAddr(SocketAddr), DomainName(String, u16), } <|fim_suffix|>impl RemoteAddr { pub async fn into_sockaddr(self) -> io::Result...
code_fim
medium
{ "lang": "rust", "repo": "uuu-mp4/realm", "path": "/src/relay/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Endpoint { pub fn new(local: &str, remote: &str, udp: bool) -> Self { let local = local .to_socket_addrs() .expect("invalid local address") .next() .unwrap(); let remote = if let Ok(sockaddr) = remote.parse::<SocketAddr>() { ...
code_fim
hard
{ "lang": "rust", "repo": "uuu-mp4/realm", "path": "/src/relay/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lstarby/libp2p-rs path: /protocols/kad/src/cli.rs // Copyright 2020 Netwarps Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including ...
code_fim
hard
{ "lang": "rust", "repo": "lstarby/libp2p-rs", "path": "/protocols/kad/src/cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let value_any = app.get_handler(DHT).expect(DHT); let kad = value_any.downcast_ref::<Control>().expect("control").clone(); kad } fn cli_close_kad(app: &App, _args: &[&str]) -> XcliResult { let mut kad = handler(app); kad.close(); Ok(CmdExeCode::Ok) } fn cli_bootstrap(app: &App, _...
code_fim
hard
{ "lang": "rust", "repo": "lstarby/libp2p-rs", "path": "/protocols/kad/src/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }