text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: scrblue/transaction-processor path: /src/model.rs use serde::{Deserialize, Serialize}; use crate::fixed_point_util; /// A global error type #[derive(Debug)] pub enum Error { /// If a Deposit or Withdrawal transaction has no amount NoAmount, /// If the Withdrawal can not process bec...
code_fim
hard
{ "lang": "rust", "repo": "scrblue/transaction-processor", "path": "/src/model.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// The total funds available for withdrawal or other use. #[serde(serialize_with = "fixed_point_util::serialize")] pub available: i64, /// The total funds held for dispute #[serde(serialize_with = "fixed_point_util::serialize")] pub held: i64, /// The total funds of the acco...
code_fim
hard
{ "lang": "rust", "repo": "scrblue/transaction-processor", "path": "/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jlgerber/packybara path: /src/db/utils.rs pub fn search_mode_name_to_op(name: &str) -> &'static str { match name { "exact" => "=", "ancestor" => "@>", "descendant" => "<@", _ => "<@", } } pub fn prep_query_str(default: &'static str, value: &str, substitut...
code_fim
medium
{ "lang": "rust", "repo": "jlgerber/packybara", "path": "/src/db/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = match value { _ if value == default => default.to_string(), _ if value.contains("%") => value.to_string(), _ => format!("{}.{}", default, value), }; if substitute { result = result.replace("_", "."); } result }<|fim_prefix|>// repo: jlgerb...
code_fim
medium
{ "lang": "rust", "repo": "jlgerber/packybara", "path": "/src/db/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: im-0/kexlinux path: /src/lib/kexlinux.rs use std; extern crate natord; extern crate syslinux_conf; use blockdev; const CMD_KEXEC: &'static str = "kexec"; #[derive(Debug)] pub struct SyslinuxConf { pub timeout: Option<f64>, pub total_timeout: Option<f64>, pub ontimeout: syslinux_...
code_fim
hard
{ "lang": "rust", "repo": "im-0/kexlinux", "path": "/src/lib/kexlinux.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let kernel = match label.kernel_or_config { syslinux_conf::KernelOrConfig::Kernel(ref kernel) => kernel, }; let kernel_file = match kernel.kernel_file { Some(syslinux_conf::KernelFile::Linux(ref kernel_file)) => { kernel_file }, ...
code_fim
hard
{ "lang": "rust", "repo": "im-0/kexlinux", "path": "/src/lib/kexlinux.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(ref kernel_file) => { error!("Unsupported kernel type {:?}, unable to kexec", kernel_file); return Err(KexLinuxError{}); }, None => { error!("No kernel, unable to kexec"); retur...
code_fim
hard
{ "lang": "rust", "repo": "im-0/kexlinux", "path": "/src/lib/kexlinux.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h7/src/stm32h753v/ethernet_dma/dmacsr.rs #[doc = "Register `DMACSR` reader"] pub type R = crate::R<DMACSR_SPEC>; #[doc = "Register `DMACSR` writer"] pub type W = crate::W<DMACSR_SPEC>; #[doc = "Field `TI` reader - Transmit Interrupt"] pub type TI_R = crate...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h753v/ethernet_dma/dmacsr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>RWT_W::new(self) } #[doc = "Bit 10 - Early Transmit Interrupt"] #[inline(always)] #[must_use] pub fn et(&mut self) -> ET_W<DMACSR_SPEC, 10> { ET_W::new(self) } #[doc = "Bit 11 - Early Receive Interrupt"] #[inline(always)] #[must_use] pub fn er(&mut self) -> ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h753v/ethernet_dma/dmacsr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e(always)] pub fn er(&self) -> ER_R { ER_R::new(((self.bits >> 11) & 1) != 0) } #[doc = "Bit 12 - Fatal Bus Error"] #[inline(always)] pub fn fbe(&self) -> FBE_R { FBE_R::new(((self.bits >> 12) & 1) != 0) } #[doc = "Bit 13 - Context Descriptor Error"] #[inlin...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h753v/ethernet_dma/dmacsr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>enum Branches2AfromB { End(MeshedChannels<End, RoleEnd, NameA>), Looping(MeshedChannels<Recv<A0, Send<D1, Recurs2BfromA>>, RoleB<RoleB<RoleB<RoleEnd>>>, NameA>), Extend(MeshedChannels<Recv<A1, Choose0fromAtoB>, RoleB<RoleBroadcast>, NameA>), } // B type Recurs0BfromA = Recv<Branches0BfromA, E...
code_fim
hard
{ "lang": "rust", "repo": "NicolasLagaillardie/mpst_rust_github", "path": "/tests/checking_mod/complex/alternating_bit.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( format!("{:?}", Dot::new(&graph_a)), "digraph {\n \ 0 [ label = \"\\\"0\\\"\" ]\n \ 1 [ label = \"\\\"0.1\\\"\" ]\n \ 2 [ label = \"\\\"0.1\\\"\" ]\n \ 3 [ label = \"\\\"0.1.1\\\"\" ]\n \ 4 [ label =...
code_fim
hard
{ "lang": "rust", "repo": "NicolasLagaillardie/mpst_rust_github", "path": "/tests/checking_mod/complex/alternating_bit.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NicolasLagaillardie/mpst_rust_github path: /tests/checking_mod/complex/alternating_bit.rs use mpstthree::binary::struct_trait::end::End; use mpstthree::binary::struct_trait::recv::Recv; use mpstthree::binary::struct_trait::send::Send; use mpstthree::role::broadcast::RoleBroadcast; use mpstthree:...
code_fim
hard
{ "lang": "rust", "repo": "NicolasLagaillardie/mpst_rust_github", "path": "/tests/checking_mod/complex/alternating_bit.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SneManden/RustRaytracer path: /src/ray_tracer/sphere3d.rs use super::vector_library::{Point3D, Vec3D}; use super::ray::Ray; use super::ppm::Color; #[derive(Debug)] pub struct Sphere3D { pub center: Point3D, pub radius: f32, pub color: Color } impl Sphere3D { pub fn new(cx: f32,...
code_fim
hard
{ "lang": "rust", "repo": "SneManden/RustRaytracer", "path": "/src/ray_tracer/sphere3d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn intersect_with_ray_straight_on() { // Arrange let sphere = Sphere3D::new(0.0, 0.0, -3.0, 1.0); let origin = Point3D::zero(); let target = Point3D::new(0.0, 0.0, -1.0); let ray = Ray::new(origin, &target); let expected = Point3D::new(0.0, 0...
code_fim
hard
{ "lang": "rust", "repo": "SneManden/RustRaytracer", "path": "/src/ray_tracer/sphere3d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NotIntMan/n-lang path: /src/project_analysis/source.rs use helpers::{ Path, PathBuf, }; use lexeme_scanner::rules::word::word; use std::{ collections::hash_map::{ HashMap, Iter, }, fs::{ File, read_dir, }, io::{ self, Re...
code_fim
hard
{ "lang": "rust", "repo": "NotIntMan/n-lang", "path": "/src/project_analysis/source.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait TextSource { fn get_text(&self, path: Path) -> Option<Arc<Text>>; } #[derive(Clone, Debug)] pub struct HashMapSource { map: HashMap<PathBuf, Arc<Text>>, } fn extract_file_name(path: &path::Path) -> io::Result<&str> { let filename = path.file_name() .ok_or_else(|| io::Error:...
code_fim
hard
{ "lang": "rust", "repo": "NotIntMan/n-lang", "path": "/src/project_analysis/source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hvnsweeting/adventofcode path: /2021/src/day08.rs use regex::Regex; use std::collections::HashMap; use std::collections::HashSet; fn line_mapper(line: &str) -> (&str, &str) { match line.split(" | ").collect::<Vec<&str>>()[..] { [patterns, output] => (patterns, output), _ => ...
code_fim
hard
{ "lang": "rust", "repo": "hvnsweeting/adventofcode", "path": "/2021/src/day08.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> signals .iter() .map(|signal| sum_a_line(signal.clone())) .sum() } #[cfg(test)] mod tests { use super::*; use std::fs; #[test] fn test_81() { let _s = "be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe ed...
code_fim
hard
{ "lang": "rust", "repo": "hvnsweeting/adventofcode", "path": "/2021/src/day08.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aurae-runtime/aurae path: /auraed/src/cells/cell_service/cells/nested_auraed/isolation_controls.rs /* -------------------------------------------------------------------------- *\ * Apache 2.0 License Copyright © 2022-2023 The Aurae Authors * * ...
code_fim
hard
{ "lang": "rust", "repo": "aurae-runtime/aurae", "path": "/auraed/src/cells/cell_service/cells/nested_auraed/isolation_controls.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> //Mount proc in the new pid and mount namespace let target = PathBuf::from("/proc"); nix::mount::mount( Some("/proc"), &target, Some("proc"), nix::mount::MsFlags::empty(), None::<&str>, ) .map_err(|e| io::E...
code_fim
hard
{ "lang": "rust", "repo": "aurae-runtime/aurae", "path": "/auraed/src/cells/cell_service/cells/nested_auraed/isolation_controls.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // We are in a new UTS namespace so we manage hostname and domainname. // hostname and domainname both allow null bytes and are not required to be null terminated. if unsafe { #[allow(trivial_casts)] libc::sethostname( self.name.as_ptr() as *...
code_fim
hard
{ "lang": "rust", "repo": "aurae-runtime/aurae", "path": "/auraed/src/cells/cell_service/cells/nested_auraed/isolation_controls.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let de: Glob = serde_json::from_str(&ser).unwrap(); assert_eq!(test_glob, de); } }<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/globset/src/serde_impl.rs use serde::de::Error; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use crate::Glob; impl Serial...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/globset/src/serde_impl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/globset/src/serde_impl.rs use serde::de::Error; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use crate::Glob; <|fim_suffix|>#[cfg(test)] mod tests { use Glob; #[test] fn glob_json_works() { let test_glob = Glob::new(...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/globset/src/serde_impl.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ainevsia/Leetcode-Rust path: /35. Search Insert Position/src/main.rs fn main() { Solution::search_insert(vec![1,3,5,6], 5); } struct Solution {} impl Solution { pub fn search_insert(nums: Vec<i32>, target: i32) -> i32 { for (i, x) in nums.iter().enumerate() { if *x ...
code_fim
medium
{ "lang": "rust", "repo": "Ainevsia/Leetcode-Rust", "path": "/35. Search Insert Position/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Solution::search_insert(vec![1,3,5,6], 5), 2); assert_eq!(Solution::search_insert(vec![1,3,5,6], 2), 1); assert_eq!(Solution::search_insert(vec![1,3,5,6], 7), 4); assert_eq!(Solution::search_insert(vec![1,3,5,6], 0), 0); } }<|fim_prefix|>// repo: Ainevsia/Le...
code_fim
medium
{ "lang": "rust", "repo": "Ainevsia/Leetcode-Rust", "path": "/35. Search Insert Position/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert!((result.width() - expected_result.width()).abs() < ERROR_MARGIN); assert!((result.height() - expected_result.height()).abs() < ERROR_MARGIN); } #[test] fn test_add() { let expected_result = Size::new(13., 9.); const ERROR_MARGIN: f64 = 0.00001; ...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/orbtk", "path": "/utils/src/size.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let left_side = Size::new(5., 7.); let right_side = Size::new(8., 2.); let result = left_side + right_side; assert!((result.width() - expected_result.width()).abs() < ERROR_MARGIN); assert!((result.height() - expected_result.height()).abs() < ERROR_MARGIN); } ...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/orbtk", "path": "/utils/src/size.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/orbtk path: /utils/src/size.rs use derive_more::{Add, Constructor, From, Sub}; use std::ops::Div; /// A `Size` specified by width and height. /// /// # Examples /// ```rust /// # use orbtk_utils::Size; /// let size = Size::new(10., 10.); /// let other_size = Size::new(5., 7.); /// let ...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/orbtk", "path": "/utils/src/size.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gggto/hi-tension path: /src/lib.rs //! `hi-tension` (contraction of high tension) is a Rust crate designed for *basic* //! but *fast* network communication between scientific applications. The focus is //! on transferring large unsized arrays of `f64` with maximum throughput and //! minimum late...
code_fim
hard
{ "lang": "rust", "repo": "gggto/hi-tension", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn as_u8_slice_mut<T>(v: &mut [T]) -> &mut [u8] { unsafe { std::slice::from_raw_parts_mut(v.as_ptr() as *mut u8, v.len() * std::mem::size_of::<T>()) } } /// Read a *High Tension Message* from the `stream`. /// /// This function is blocking. /// /// During operation, this function allocate...
code_fim
hard
{ "lang": "rust", "repo": "gggto/hi-tension", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mrkgnao/sqlx path: /sqlx-macros/src/query_macros/args.rs use proc_macro2::TokenStream; use quote::{quote, quote_spanned, ToTokens}; use syn::Expr; use sqlx::describe::Describe; use crate::database::{DatabaseExt, ParamChecking}; use crate::query_macros::QueryMacroInput; pub fn quote_args<DB: D...
code_fim
hard
{ "lang": "rust", "repo": "mrkgnao/sqlx", "path": "/sqlx-macros/src/query_macros/args.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let args = input.arg_names.iter(); Ok(quote! { // emit as a tuple first so each expression is only evaluated once let args = (#(&$#args),*,); #args_check }) } fn get_type_override(expr: &Expr) -> Option<TokenStream> { match expr { Expr::Cast(cast) => Some(...
code_fim
hard
{ "lang": "rust", "repo": "mrkgnao/sqlx", "path": "/sqlx-macros/src/query_macros/args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/static/static-extern-type.rs // build-pass (FIXME(62277): could be check-pass?) #![feature(extern_types)] pub mod a { extern "C" { pub type StartFn; pub static start: StartFn; } } <|fim_suffix|>pub mod c { #[repr(C)...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/static/static-extern-type.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod c { #[repr(C)] pub struct CType(u32, ::b::TransparentType); extern "C" { pub static start: CType; } } fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/static/static-extern-type.rs // build-pass (FIXME(62277): could be check-pass?) #![f...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/static/static-extern-type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let cwd = env::current_dir().unwrap(); let cwd_prefix = cwd.get_path_prefix().unwrap(); let target_prefix = if cwd_prefix.as_os_str().ne("C:") { "C:" } else { "D:" }; let target = PathBuf::from(format!(r"{}..\123\567", target_prefix)); let cwd_parent = cwd.p...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/path-absolutize", "path": "/tests/windows.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/path-absolutize path: /tests/windows.rs #![cfg(all(windows, not(feature = "unsafe_cache")))] #[macro_use] extern crate slash_formatter; extern crate path_absolutize; use std::env; use std::path::{Path, PathBuf}; use path_absolutize::path_dedot::ParsePrefix; use path_absolutize::Absol...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/path-absolutize", "path": "/tests/windows.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn criterion_benchmark(c: &mut Criterion) { let filename = "tests/samples/minimal.mp4"; c.bench_with_input(BenchmarkId::new("input_example", filename), &filename, |b, &s| { b.iter(|| read_mp4(s)); }); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches);<|fim_pr...
code_fim
medium
{ "lang": "rust", "repo": "vgarleanu/mp4-rust", "path": "/benches/bench_main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vgarleanu/mp4-rust path: /benches/bench_main.rs use criterion::BenchmarkId; use criterion::{criterion_group, criterion_main, Criterion}; use mp4; use std::fs::File; <|fim_suffix|>fn criterion_benchmark(c: &mut Criterion) { let filename = "tests/samples/minimal.mp4"; c.bench_with_input(...
code_fim
medium
{ "lang": "rust", "repo": "vgarleanu/mp4-rust", "path": "/benches/bench_main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> c.bench_with_input(BenchmarkId::new("input_example", filename), &filename, |b, &s| { b.iter(|| read_mp4(s)); }); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches);<|fim_prefix|>// repo: vgarleanu/mp4-rust path: /benches/bench_main.rs use criterion::BenchmarkId; u...
code_fim
medium
{ "lang": "rust", "repo": "vgarleanu/mp4-rust", "path": "/benches/bench_main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main(){ let a = 2; let b = 3; assert_eq!(math(sum,a,b), 5); assert_eq!(math(product,a,b), 6); }<|fim_prefix|>// repo: R1ckyZhang/trust_me path: /chapter2/methods.rs /** * 注意 rust与go 相同的地方 函数都为一等公民 */ //函数作为参数的情况 pub fn math(op: fn(i32,i32)->i32,a:i32,b:i32) ->i32{ op(a,b) } <|...
code_fim
medium
{ "lang": "rust", "repo": "R1ckyZhang/trust_me", "path": "/chapter2/methods.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: R1ckyZhang/trust_me path: /chapter2/methods.rs /** * 注意 rust与go 相同的地方 函数都为一等公民 */ //函数作为参数的情况 pub fn math(op: fn(i32,i32)->i32,a:i32,b:i32) ->i32{ op(a,b) } fn sum(a:i32,b:i32) ->i32{ a+b } fn product(a:i32,b:i32) ->i32{ <|fim_suffix|> let a = 2; let b = 3; assert_eq!(ma...
code_fim
easy
{ "lang": "rust", "repo": "R1ckyZhang/trust_me", "path": "/chapter2/methods.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn binom(n: u64, k: u64) -> BigInt { let mut res = BigInt::one(); for i in 0..k { res = (res * (n - i).to_bigint().unwrap()) / (i + 1).to_bigint().unwrap(); } res } fn binom_prop(n: u64, k: u64, prop: &f64) -> f64 { binom(n, k).to_f64().unwrap() * prop.powf(k as ...
code_fim
hard
{ "lang": "rust", "repo": "mbrner/rustlind", "path": "/lia/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mbrner/rustlind path: /lia/src/main.rs use std::collections::HashMap; use std::collections::HashSet; use std::fmt; use std::env; use std::fs; extern crate num; use num::bigint::BigInt; use num::bigint::ToBigInt; use num::traits::One; use num::cast::ToPrimitive; #[derive(Hash, Clone, Debug)]...
code_fim
hard
{ "lang": "rust", "repo": "mbrner/rustlind", "path": "/lia/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut res = BigInt::one(); for i in 0..k { res = (res * (n - i).to_bigint().unwrap()) / (i + 1).to_bigint().unwrap(); } res } fn binom_prop(n: u64, k: u64, prop: &f64) -> f64 { binom(n, k).to_f64().unwrap() * prop.powf(k as f64) * (1f64 - prop).powf((n-k) as f6...
code_fim
hard
{ "lang": "rust", "repo": "mbrner/rustlind", "path": "/lia/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diwic/alsa-rs path: /src/io.rs use crate::alsa; use super::error::*; use std::{slice, ptr, fmt}; /// [snd_output_t](http://www.alsa-project.org/alsa-doc/alsa-lib/group___output.html) wrapper pub struct Output(*mut alsa::snd_output_t); unsafe impl Send for Output {} impl Drop for Output { ...
code_fim
hard
{ "lang": "rust", "repo": "diwic/alsa-rs", "path": "/src/io.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Debug for Output { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Output(")?; fmt::Display::fmt(self, f)?; write!(f, ")") /* self.buffer_string(|b| f.write_str(try!(str::from_utf8(b).map_err(|_| fmt::Error)))) */ } } impl fmt::Display f...
code_fim
hard
{ "lang": "rust", "repo": "diwic/alsa-rs", "path": "/src/io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jellyfish-project/jellyfish path: /src/core/fsqual.rs use std::fs::{remove_file, OpenOptions}; use std::os::unix::io::AsRawFd; use std::os::unix::prelude::OpenOptionsExt; use std::result::Result; use linux_aio::{AlignedBuf, Context, ControlBlock}; use libc::{getrusage, rusage, timeval, O_DIRECT...
code_fim
hard
{ "lang": "rust", "repo": "jellyfish-project/jellyfish", "path": "/src/core/fsqual.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { getrusage(RUSAGE_THREAD, &mut rusg as *mut rusage); csws += rusg.ru_nvcsw; } let events = try!( context .get_events(1, 1, None) .map_err(|_| "Failed to call iogetevents(2).") ); events.int...
code_fim
hard
{ "lang": "rust", "repo": "jellyfish-project/jellyfish", "path": "/src/core/fsqual.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { getrusage(RUSAGE_THREAD, &mut rusg as *mut rusage); csws -= rusg.ru_nvcsw; } try!( context .submit(ControlBlock::pwrite(raw_fd, buf, BLOCK_SIZE * i)) .map_err(|_| "Failed to call iosubmmit(2).") )...
code_fim
hard
{ "lang": "rust", "repo": "jellyfish-project/jellyfish", "path": "/src/core/fsqual.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("The direction is {:?}", value); find_direction(Direction::North); let south = Direction::South as u32; let north = Direction::North as u32; println!("South value is {:?}", south); println!("North value is {:?}", north); let west = Direction::West as u32; let e...
code_fim
hard
{ "lang": "rust", "repo": "sathishvinayk/rust_360", "path": "/enums/creating_an_enum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("West value is {:?}", west); println!("East value is {:?}", east); assert_eq!(value.find(), "South pole"); let _no_variant = Novariant::new(); }<|fim_prefix|>// repo: sathishvinayk/rust_360 path: /enums/creating_an_enum.rs #![allow(dead_code)] #[derive(Debug, PartialEq)] enum D...
code_fim
hard
{ "lang": "rust", "repo": "sathishvinayk/rust_360", "path": "/enums/creating_an_enum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sathishvinayk/rust_360 path: /enums/creating_an_enum.rs #![allow(dead_code)] #[derive(Debug, PartialEq)] enum Direction { North, South = 99, East, West } #[derive(Debug)] enum Novariant { } impl Novariant { fn new() { println!("Hi this is offset function!"); } }...
code_fim
medium
{ "lang": "rust", "repo": "sathishvinayk/rust_360", "path": "/enums/creating_an_enum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PurpleBooth/fizz-buzz-rust path: /src/fizz_buzz.rs pub fn fizz_buzz(value: i128) -> String { if value % 15 == 0 { return "fizz_buzz".to_string(); } if value % 3 == 0 { return "fizz".to_string(); } if value % 5 == 0 { return "buzz".to_string(); } ...
code_fim
hard
{ "lang": "rust", "repo": "PurpleBooth/fizz-buzz-rust", "path": "/src/fizz_buzz.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_returns_fizz_when_the_value_is_6() { assert_eq!(fizz_buzz(6), "fizz"); } #[test] fn it_returns_fizz_when_the_value_is_9() { assert_eq!(fizz_buzz(9), "fizz"); } #[test] fn it_returns_buzz_when_the_value_is_5() { assert_eq!(fizz_buzz(5)...
code_fim
hard
{ "lang": "rust", "repo": "PurpleBooth/fizz-buzz-rust", "path": "/src/fizz_buzz.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Arbitrary for ShortUuid { type Parameters = ShortUuidParameters; fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { (args.uuid, any_with::<Alphabet>(args.alphabet)) .prop_map(|(uid, abc)| ShortUuid::from_uuid(uid, &abc)) .sboxed() } type St...
code_fim
hard
{ "lang": "rust", "repo": "mgeisler/shorter-uuid-rs", "path": "/src/proptest_support.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mgeisler/shorter-uuid-rs path: /src/proptest_support.rs /* * Copyright 2019 Alexey Shuksto. * * 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/LICENSE-2.0> or the...
code_fim
hard
{ "lang": "rust", "repo": "mgeisler/shorter-uuid-rs", "path": "/src/proptest_support.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mavallad/ahorcado_rust path: /src/graphics/mod.rs pub fn paint(attempts_left: u8) -> String { let hangman_str = match attempts_left { 6 => r" ______ | | | | | | | ...
code_fim
hard
{ "lang": "rust", "repo": "mavallad/ahorcado_rust", "path": "/src/graphics/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> | /| | | | --------------", 2 => r" ______ | | | 0 | /|\ | | | --------------", 1 => r" ...
code_fim
hard
{ "lang": "rust", "repo": "mavallad/ahorcado_rust", "path": "/src/graphics/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn idle(ref prio: P0, ref thres: T0) -> ! { let gpiob = stm32f103xx::GPIOB.get(); let itm = ITM.access(prio, thres); loop { rtfm::wfi(); } } tasks!(stm32f103xx, { periodic: Task { interrupt: TIM2, priority: P1, enabled: true, }, exti9_5: Task { ...
code_fim
hard
{ "lang": "rust", "repo": "Emilgardis/f103-test2", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Emilgardis/f103-test2 path: /src/main.rs #![feature(used, const_fn, never_type, get_type_id)] #![no_std] #[macro_use] extern crate cortex_m; extern crate cortex_m_rt; #[macro_use] extern crate cortex_m_rtfm as rtfm; extern crate stm32f103xx; extern crate embedded_hal as hal; extern crate nb; ...
code_fim
hard
{ "lang": "rust", "repo": "Emilgardis/f103-test2", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/ui/wayland/server/src/client.rs // Copyright 2018 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { crate::display::{Display, DISPLAY_SINGLETON_OBJECT_ID}, ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/ui/wayland/server/src/client.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl EventQueueChannel { fn write(&self, message: wl::Message) -> Result<(), Error> { ftrace::duration!("wayland", "EventQueue::write_to_chan"); let (bytes, mut handles) = message.take(); match self { EventQueueChannel::Local(sender) => { let buf = z...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/ui/wayland/server/src/client.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); SqliteConnection::establish(&database_url) .unwrap_or_else(|_| panic!("Error connecting to {}", database_url)) }<|fim_prefix|>// repo: gobanos/movies-db path: /src/lib.rs #![warn(clippy::pedantic)] #![war...
code_fim
medium
{ "lang": "rust", "repo": "gobanos/movies-db", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn establish_connection() -> SqliteConnection { dotenv::dotenv().ok(); let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); SqliteConnection::establish(&database_url) .unwrap_or_else(|_| panic!("Error connecting to {}", database_url)) }<|fim_prefix|...
code_fim
easy
{ "lang": "rust", "repo": "gobanos/movies-db", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gobanos/movies-db path: /src/lib.rs #![warn(clippy::pedantic)] #![warn(clippy::nursery)] #[macro_use] extern crate diesel; <|fim_suffix|> let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); SqliteConnection::establish(&database_url) .unwrap_or_el...
code_fim
medium
{ "lang": "rust", "repo": "gobanos/movies-db", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: syntheticsh/ffmpeg_and_sdl_tutorial path: /src/tut1/main.rs extern crate ffmpeg_next as ffmpeg; use anyhow::{anyhow, Context as AContext, Result}; use ffmpeg::format::{input, Pixel}; use ffmpeg::media::Type; use ffmpeg::software::scaling::{context::Context, flag::Flags}; use ffmpeg::util::frame...
code_fim
hard
{ "lang": "rust", "repo": "syntheticsh/ffmpeg_and_sdl_tutorial", "path": "/src/tut1/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn save_file(frame: &Video, index: usize) -> Result<()> { let mut buffer: Vec<u8> = format!("P6\n{} {}\n255\n", frame.width(), frame.height()).into_bytes(); buffer.extend_from_slice(frame.data(0)); image::save_buffer( format!("frame{}.jpeg", index), &buffe...
code_fim
hard
{ "lang": "rust", "repo": "syntheticsh/ffmpeg_and_sdl_tutorial", "path": "/src/tut1/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let help_text_widget = Paragraph::new(help_text) .block( Block::default() .title(Spans::from( Span::styled("帮助", Style::default().fg(Color::Gray)) )) .borders(Borders::ALL) .border_style(Style::default().fg(Color::Gray)) ) .style(Style::default().fg(Color::Gray)) ; f.render_wi...
code_fim
hard
{ "lang": "rust", "repo": "cx-emerge/terminal_commander", "path": "/src/ui/draw_help.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cx-emerge/terminal_commander path: /src/ui/draw_help.rs use std::error; use tui::{ Frame, backend::Backend, layout::{ Rect, }, widgets::{ Block, Borders, Paragraph, }, text::{ Spans, Span }, style::{ Style, Color, }, }; <|fim_suffix|> let help_text_widget = Paragraph::new(help_text) ....
code_fim
hard
{ "lang": "rust", "repo": "cx-emerge/terminal_commander", "path": "/src/ui/draw_help.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl TryFrom<&str> for Cid { type Error = Error; fn try_from(value: &str) -> Result<Self, Self::Error> { Ok(Cid(CidGeneric::try_from(value)?)) } } impl FromStr for Cid { type Err = Error; fn from_str(src: &str) -> Result<Self, Error> { Cid::try_from(src) } } imp...
code_fim
medium
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/ipld/cid/src/to_cid.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: creativcoder/forest path: /ipld/cid/src/to_cid.rs // Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT use crate::{Cid, Error}; use cid::CidGeneric; use std::convert::TryFrom; use std::str::FromStr; impl TryFrom<String> for Cid { type Error = Error; fn try_f...
code_fim
hard
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/ipld/cid/src/to_cid.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Some(AABB { min: Point::new( self.v0.x.min(self.v1.x).min(self.v2.x), self.v0.y.min(self.v1.y).min(self.v2.y), self.v0.z.min(self.v1.z).min(self.v2.z), ), max: Point::new( self.v0.x.max(self.v1.x).m...
code_fim
hard
{ "lang": "rust", "repo": "guimcaballero/sunray", "path": "/src/hittable/triangle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guimcaballero/sunray path: /src/hittable/triangle.rs use crate::{hittable::*, material::*}; #[derive(Clone)] pub struct Triangle { pub v0: Point, pub v1: Point, pub v2: Point, pub material: Material, } impl Hittable for Triangle { fn hit(&self, ray: &Ray, taemin: f32, t_max...
code_fim
hard
{ "lang": "rust", "repo": "guimcaballero/sunray", "path": "/src/hittable/triangle.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Drip drop out of here if we're out of bounds if taemin > t || t > t_max { return false; } hit_record.t = t; hit_record.point = ray.at(t); hit_record.set_face_normal(&ray, &normal.normalize()); hit_record.material = self.material.clone...
code_fim
hard
{ "lang": "rust", "repo": "guimcaballero/sunray", "path": "/src/hittable/triangle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nimbol/euler path: /rust/src/bin/p018.rs /// # Maximum path sum I /// By starting at the top of the triangle below and moving to adjacent numbers on the row below, /// the maximum total from top to bottom is 23. /// 3 /// 7 4 /// 2 4 6 /// 8 5 9 3 /// /// That is, 3 + 7 + 4 + 9 = 23. /// /...
code_fim
hard
{ "lang": "rust", "repo": "nimbol/euler", "path": "/rust/src/bin/p018.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // For each pair within a row: add the highest n to the number in the next row. previous .windows(2) .filter_map(|w| w.iter().max()) .enumerate() .for_each(|(i, &n)| { current[i] += n; }); previous = curre...
code_fim
hard
{ "lang": "rust", "repo": "nimbol/euler", "path": "/rust/src/bin/p018.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: x7c1/plus path: /libs/env-extractor/src/var.rs use crate::Error; use crate::Error::{NotPresent, ParseError}; use std::env; use std::env::VarError; use std::fmt::Debug; use std::str::FromStr; pub struct EnvVar { pub key: String, } type EnvResult<Y, X> = crate::Result<Y, <X as FromStr>::Err>...
code_fim
hard
{ "lang": "rust", "repo": "x7c1/plus", "path": "/libs/env-extractor/src/var.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where X: FromStr, <X as FromStr>::Err: Debug, F1: Fn() -> EnvResult<Y, X>, F2: Fn(X) -> EnvResult<Y, X>, { let to_parsed = |value: String| { X::from_str(&value) .map_err(|e| to_parse_error(self.key.to_string(), value, e)) ...
code_fim
hard
{ "lang": "rust", "repo": "x7c1/plus", "path": "/libs/env-extractor/src/var.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _ => 0, }; if x == 1 && y == 1 { ans += 400000; } println!("{}", ans); }<|fim_prefix|>// repo: KatsuyaKikuchi/programming_contest_rust path: /src/VirtualContest/20210217/a.rs use proconio::input; fn main() { input! { x:u32, y:u32 } let mut ans = 0; <|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "KatsuyaKikuchi/programming_contest_rust", "path": "/src/VirtualContest/20210217/a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KatsuyaKikuchi/programming_contest_rust path: /src/VirtualContest/20210217/a.rs use proconio::input; fn main() { input! { x:u32, y:u32 } let mut ans = 0; ans += match x { 1 => 300000, 2 => 200000, 3 => 100000, _ => 0, <|fim_suffix|> _ => ...
code_fim
medium
{ "lang": "rust", "repo": "KatsuyaKikuchi/programming_contest_rust", "path": "/src/VirtualContest/20210217/a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(*b, 5); assert_eq!(*b as i32, 5); } //---------------------------------------------------------------------------- /// \brief bytes crate example /// \ref https://github.com/paulkernfeld/contiguous-data-in-rust //---------------------------------------------------------------...
code_fim
easy
{ "lang": "rust", "repo": "ernestyalumni/HrdwCCppCUDA", "path": "/Constructicon/Mixmaster/projects/pointers/src/on_heap/examples.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //---------------------------------------------------------------------------- /// \brief bytes crate example /// \ref https://github.com/paulkernfeld/contiguous-data-in-rust //---------------------------------------------------------------------------- #[test] fn bytes }<|fim_prefix|>// repo...
code_fim
medium
{ "lang": "rust", "repo": "ernestyalumni/HrdwCCppCUDA", "path": "/Constructicon/Mixmaster/projects/pointers/src/on_heap/examples.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ernestyalumni/HrdwCCppCUDA path: /Constructicon/Mixmaster/projects/pointers/src/on_heap/examples.rs #[cfg(test)] mod tests { use super::*; #[test] fn box_stores_i32_value_on_heap() { let b = Box::new(5); //println!("b = {}", b); <|fim_suffix|> //-------------------------------...
code_fim
easy
{ "lang": "rust", "repo": "ernestyalumni/HrdwCCppCUDA", "path": "/Constructicon/Mixmaster/projects/pointers/src/on_heap/examples.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// A newline parser that accepts: // // - A newline. // - The end of input. pub fn eol(i: &str) -> ParserResult<()> { alt(( eoi, // this one goes first because it’s very cheap value((), newline), ))(i) } // Apply the `f` parser until `g` succeeds. Both parsers consume the input. pub fn till<'...
code_fim
hard
{ "lang": "rust", "repo": "unjello/glsl", "path": "/glsl/src/parsers/nom_helpers.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unjello/glsl path: /glsl/src/parsers/nom_helpers.rs //! Various nom parser helpers. use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::{anychar, multispace1, newline}; use nom::combinator::{map, recognize, value}; use nom::error::{ErrorKind, VerboseError, Verbose...
code_fim
hard
{ "lang": "rust", "repo": "unjello/glsl", "path": "/glsl/src/parsers/nom_helpers.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>// Apply the `f` parser until `g` succeeds. Both parsers consume the input. pub fn till<'a, A, B, F, G>(mut f: F, mut g: G) -> impl FnMut(&'a str) -> ParserResult<'a, ()> where F: FnMut(&'a str) -> ParserResult<'a, A>, G: FnMut(&'a str) -> ParserResult<'a, B>, { move |mut i| loop { if let Ok((i2...
code_fim
hard
{ "lang": "rust", "repo": "unjello/glsl", "path": "/glsl/src/parsers/nom_helpers.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] pub struct Settings { pub catalog_path: String, pub catalog_dir: String, pub stash_config: StashConfig, pub database: Database, pub server: Server, pub domain_repo_type: DomainRepoType, } impl Settings { pub fn new() -> Result<Self, ConfigError> {...
code_fim
medium
{ "lang": "rust", "repo": "omallassi/apis-catalog", "path": "/server/src/settings/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: omallassi/apis-catalog path: /server/src/settings/mod.rs use std::env; extern crate log; use log::info; //extern crate env_logger; extern crate config; use config::ConfigError; use serde::Deserialize; #[derive(Debug, Deserialize)] pub struct StashConfig { pub base_uri: String, pub ac...
code_fim
medium
{ "lang": "rust", "repo": "omallassi/apis-catalog", "path": "/server/src/settings/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Settings { pub fn new() -> Result<Self, ConfigError> { let mut settings = config::Config::default(); let config_file_path = match env::var("API_SERVER_CONFIG_FILE") { Ok(var) => var, Err(_why) => String::from("server/config/local"), }; inf...
code_fim
hard
{ "lang": "rust", "repo": "omallassi/apis-catalog", "path": "/server/src/settings/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn ujson4c_parse(string: &str) { unsafe { let mut state: *mut c_void = mem::uninitialized(); UJDecode(string.as_bytes().as_ptr(), string.len() as size_t, ptr::null(), &mut state as *mut *mut c_void); } }<|fim_prefix|>// repo: Geal/pestvsnom path: /src/lib.rs extern crate libc;...
code_fim
medium
{ "lang": "rust", "repo": "Geal/pestvsnom", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Geal/pestvsnom path: /src/lib.rs extern crate libc; use std::mem; use std::ptr; <|fim_suffix|>} pub fn ujson4c_parse(string: &str) { unsafe { let mut state: *mut c_void = mem::uninitialized(); UJDecode(string.as_bytes().as_ptr(), string.len() as size_t, ptr::null(), &mut s...
code_fim
medium
{ "lang": "rust", "repo": "Geal/pestvsnom", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Geal/pestvsnom path: /src/lib.rs extern crate libc; use std::mem; use std::ptr; use libc::{c_void, size_t}; <|fim_suffix|>pub fn ujson4c_parse(string: &str) { unsafe { let mut state: *mut c_void = mem::uninitialized(); UJDecode(string.as_bytes().as_ptr(), string.len() as s...
code_fim
medium
{ "lang": "rust", "repo": "Geal/pestvsnom", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{} {} {}", ir, ig, ib); } } eprintln!("\nDone."); }<|fim_prefix|>// repo: feserr/raytracing-rs path: /examples/output-image/main.rs fn main() { // Image let image_width = 256; let image_height = 256; // Render println!("P3\n{} {}\n255", image_width, image_height); fo...
code_fim
medium
{ "lang": "rust", "repo": "feserr/raytracing-rs", "path": "/examples/output-image/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let ir = (255.999 * r) as u32; let ig = (255.999 * g) as u32; let ib = (255.999 * b) as u32; println!("{} {} {}", ir, ig, ib); } } eprintln!("\nDone."); }<|fim_prefix|>// repo: feserr/raytracing-rs path: /examples/output-image/main.rs fn main() { // Image let image_wi...
code_fim
hard
{ "lang": "rust", "repo": "feserr/raytracing-rs", "path": "/examples/output-image/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: feserr/raytracing-rs path: /examples/output-image/main.rs fn main() { // Image let image_width = 256; let image_height = 256; <|fim_suffix|> for j in (0..image_height).rev() { for i in 0..image_width { eprint!("\rScanlines remaining: {} ", j); let r = (i as f32) / ((image...
code_fim
medium
{ "lang": "rust", "repo": "feserr/raytracing-rs", "path": "/examples/output-image/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// A thread-safe (`Send`) trait object encapsulating a `Service` with /// the given `Output` type. /// /// Types which implement the `Service` trait and the `Send` trait can /// be converted to objects of this type via the `From`/`Into` traits. pub struct ServiceObj<'a, Output>(Box<dyn Service<Output = O...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/fuchsia-component/src/server/service.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/fuchsia-component/src/server/service.rs // Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! The `Service` trait and its trait-object wrappers. use...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/fuchsia-component/src/server/service.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn fill(&mut self, h: &mut dyn Hardware) { for y in 0..VRAM_HEIGHT { let b = y * VRAM_WIDTH; let e = b + VRAM_WIDTH; h.vram_update(y, &self.vram[b..e]); } } } struct KeyState { on: bool, time: u64, key: Key, } impl KeyState { fn...
code_fim
hard
{ "lang": "rust", "repo": "YushiOMOTE/rgy", "path": "/utils/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YushiOMOTE/rgy path: /utils/src/lib.rs #![no_std] extern crate alloc; use alloc::format; use alloc::string::String; use alloc::{vec, vec::Vec}; use rgy::{Hardware, Key, VRAM_HEIGHT, VRAM_WIDTH}; pub trait Loader { fn roms(&mut self) -> Vec<String>; fn load(&mut self, rom: &str) -> V...
code_fim
hard
{ "lang": "rust", "repo": "YushiOMOTE/rgy", "path": "/utils/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }