text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: merge34/re2dfa path: /src/lib.rs pub mod compress; pub mod re; pub mod nfa; pub mod dfa; pub mod print; pub use compress::*; pub use re::*; pub use nfa::*; pub use dfa::*; // return value: // Ok((dfa, ec)): ec is short for equivalent char, any u8 can be the index in the array // if two u8 has ...
code_fim
hard
{ "lang": "rust", "repo": "merge34/re2dfa", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mthstanley/stockpot path: /src/http/mod.rs use anyhow::Context; use crate::commands::server; use axum::routing::get; use axum::Router; <|fim_suffix|>fn build_routes() -> Router { Router::new().route("/", get(index)) }<|fim_middle|>pub async fn index() -> &'static str { "Hello, World!" ...
code_fim
hard
{ "lang": "rust", "repo": "mthstanley/stockpot", "path": "/src/http/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn build_routes() -> Router { Router::new().route("/", get(index)) }<|fim_prefix|>// repo: mthstanley/stockpot path: /src/http/mod.rs use anyhow::Context; use crate::commands::server; use axum::routing::get; use axum::Router; <|fim_middle|>pub async fn index() -> &'static str { "Hello, World!" ...
code_fim
hard
{ "lang": "rust", "repo": "mthstanley/stockpot", "path": "/src/http/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mathphreak/csgo-scoreline-monitor path: /src/game/state.rs extern crate time; use super::super::gsi::{self, message}; use super::super::gsi::message::{TakesUpdates, UpdateReason}; use super::super::prefs::Prefs; use rustc_serialize::json::{ToJson, Json}; use std::collections::BTreeMap; pub str...
code_fim
hard
{ "lang": "rust", "repo": "mathphreak/csgo-scoreline-monitor", "path": "/src/game/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut d = BTreeMap::new(); let twenty_seconds = time::Duration::seconds(20); let twenty_seconds_ago = time::now() - twenty_seconds; let is_up = self.last_up > twenty_seconds_ago; d.insert("up".to_string(), is_up.to_json()); d.insert("in_game".to_string(), ...
code_fim
hard
{ "lang": "rust", "repo": "mathphreak/csgo-scoreline-monitor", "path": "/src/game/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flattiverse/connector-rust path: /src/units/gravity_well.rs use serde_derive::{Deserialize, Serialize}<|fim_suffix|> Clone)] pub struct GravityWell { pub radius: f64, pub force: Option<f64>, }<|fim_middle|>; #[derive(Debug, Serialize, Deserialize,
code_fim
easy
{ "lang": "rust", "repo": "flattiverse/connector-rust", "path": "/src/units/gravity_well.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>radius: f64, pub force: Option<f64>, }<|fim_prefix|>// repo: flattiverse/connector-rust path: /src/units/gravity_well.rs use serde_derive::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize,<|fim_middle|> Clone)] pub struct GravityWell { pub
code_fim
easy
{ "lang": "rust", "repo": "flattiverse/connector-rust", "path": "/src/units/gravity_well.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ToString for ObjectId { fn to_string(&self) -> String { match &self.namespace { Some(ns) => format!("{} [{}]", self.name, ns), None => self.name.clone(), } } } impl ObjectId { fn key_for<K: Meta>(o: &K) -> Self { ObjectId { name...
code_fim
hard
{ "lang": "rust", "repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc", "path": "/kube-rs/src/runtime/reflector.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slinkydeveloper/extending-kubernetes-api-in-process-poc path: /kube-rs/src/runtime/reflector.rs use crate::{ api::{Api, ListParams, Meta, WatchEvent}, Error, Result, }; use futures::{future::FutureExt, lock::Mutex, pin_mut, TryStreamExt}; use serde::de::DeserializeOwned; use std::{colle...
code_fim
hard
{ "lang": "rust", "repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc", "path": "/kube-rs/src/runtime/reflector.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // For every event, modify our state while let Some(ev) = stream.try_next().await? { let mut state = self.state.lock().await; // Informer-like version tracking: match &ev { WatchEvent::Added(o) | WatchEvent::Modified(o) | WatchEvent::Dele...
code_fim
hard
{ "lang": "rust", "repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc", "path": "/kube-rs/src/runtime/reflector.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nisarhassan12/materialize path: /src/compute-client/src/plan/top_k.rs // Copyright Materialize, Inc. and contributors. All rights reserved. // // Use of this software is governed by the Business Source License // included in the LICENSE file. // // As of the Change Date specified in that file, i...
code_fim
hard
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/compute-client/src/plan/top_k.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ProtoTopKPlan { kind: match self { TopKPlan::Basic(plan) => Some(Basic(plan.into_proto())), TopKPlan::MonotonicTop1(plan) => Some(MonotonicTop1(plan.into_proto())), TopKPlan::MonotonicTopK(plan) => Some(MonotonicTopK(plan.into_proto())), ...
code_fim
hard
{ "lang": "rust", "repo": "nisarhassan12/materialize", "path": "/src/compute-client/src/plan/top_k.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bezirg/indy-sdk path: /libindy/src/services/wallet/iterator.rs use std::rc::Rc; use serde_json; use errors::wallet::WalletError; use super::WalletRecord; use super::wallet::Keys; use super::storage::StorageIterator; use super::encryption::{decrypt_tags}; use utils::crypto::chacha20poly1305_ie...
code_fim
hard
{ "lang": "rust", "repo": "bezirg/indy-sdk", "path": "/libindy/src/services/wallet/iterator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl WalletIterator { pub fn new(storage_iter: Box<StorageIterator>, keys: Rc<Keys>) -> Self { WalletIterator { storage_iterator: storage_iter, keys: keys, } } pub fn next(&mut self) -> Result<Option<WalletRecord>, WalletError> { let next_storag...
code_fim
medium
{ "lang": "rust", "repo": "bezirg/indy-sdk", "path": "/libindy/src/services/wallet/iterator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/lint/unused_parens_remove_json_suggestion.rs // compile-flags: --error-format pretty-json -Zunstable-options // build-pass // run-rustfix // The output for humans should just highlight the whole span without showing // the suggested replacement...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/lint/unused_parens_remove_json_suggestion.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for _ in (0 .. 3) { while (true && false) { println!("e~") } } loop { if (break { return true }) { } } false }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/lint/unused_parens_remove_json_suggestion.rs // compile...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/lint/unused_parens_remove_json_suggestion.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let c = false; if(c) { println!("next"); } if (c){ println!("prev"); } while (false && true){ if (c) { println!("norm"); } } while(true && false) { for _ in (0 .. 3){ println!("e~") } } fo...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/lint/unused_parens_remove_json_suggestion.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Takes a [`task`] closure / function and returns a [`task builder object`] /// which is used to configure the task's other paramters, if necessary, /// and then to [`submit`] it for execution by the [`TaskSystem`]. /// /// NOTE - an alternative way to submit the task is to just let ...
code_fim
hard
{ "lang": "rust", "repo": "risooonho/minits", "path": "/src/task/scope.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risooonho/minits path: /src/task/scope.rs ool, name: Option<Cow<'n, str>>, } impl<'t, 'h, 'ts, 'n, F> ScopedTask<'t, 'h, 'ts, 'n, F> where F: TaskFn<'h>, { fn new(scope: &'t mut Scope<'h, 'ts>, f: F) -> Self { Self { scope, main_thread: false, ...
code_fim
hard
{ "lang": "rust", "repo": "risooonho/minits", "path": "/src/task/scope.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risooonho/minits path: /src/task/scope.rs /// `2` means two half-sized chunks per thread (i.e. task oversubscription), etc. /// /// [`task range`]: type.TaskRange.html /// [`TaskSystem`]: struct.TaskSystem.html ChunksPerThread(u32), /// An individual task is spawned for e...
code_fim
hard
{ "lang": "rust", "repo": "risooonho/minits", "path": "/src/task/scope.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update_view_proj(&mut self) { // We don't specifically need homogeneous coordinates since we're just using // a vec3 in the shader. We're using Point3 for the camera.eye, and this is // the easiest way to convert to Vector4. We're using Vector4 because of // the ...
code_fim
hard
{ "lang": "rust", "repo": "hideakitai/Sketches", "path": "/s029_wgpu_better_camera/src/renderer/camera.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hideakitai/Sketches path: /s029_wgpu_better_camera/src/renderer/camera.rs use nannou::math::cgmath::{self, Matrix4, Rad}; use nannou::prelude::*; use nannou::winit::dpi::LogicalPosition; use std::clone::Clone; use std::f32::consts::FRAC_PI_2; use std::time::Duration; use super::buffer::BufferUt...
code_fim
hard
{ "lang": "rust", "repo": "hideakitai/Sketches", "path": "/s029_wgpu_better_camera/src/renderer/camera.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(working_path) = stack.pop() { let src: PathBuf = working_path.components().skip(input_root).collect(); let dest = if src.components().count() == 0 { output_root.clone() } else { output_root.join(&src) }; if fs::metadata(&...
code_fim
hard
{ "lang": "rust", "repo": "MovAh13h/tfio", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MovAh13h/tfio path: /src/lib.rs //! TFIO is a library that provides a Transaction-like interface that are traditionally used in databases on FileIO operations. It gives the flexibility to execute and rollback singlular operations as well as transactions on the fly. The library also provides a bu...
code_fim
hard
{ "lang": "rust", "repo": "MovAh13h/tfio", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } /// A rollbackable Transaction pub struct Transaction { ops: Vec<Box<dyn RollbackableOperation>>, execution_count: usize, } impl Transaction { /// Constructs a new, empty Transaction pub fn new() -> Self { Self { ops: vec![], execution_count: ...
code_fim
hard
{ "lang": "rust", "repo": "MovAh13h/tfio", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut first_zero = 0; let mut last_zero = 0; for _ in 0..30 { cprng_draw(buffer); if buffer[0] == 0 { first_zero += 1; } if buffer.len() > 1 && buffer[buffer.len() - 1] == 0 { last_zero += 1; ...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/zircon/rust/src/cprng.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut buffer = [0; 20]; check_buffer(&mut buffer); } #[test] fn cprng_large() { const SIZE: usize = sys::ZX_CPRNG_DRAW_MAX_LEN + 1; let mut buffer = [0; SIZE]; check_buffer(&mut buffer); for mut s in buffer.chunks_mut(SIZE / 3) { ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/zircon/rust/src/cprng.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/zircon/rust/src/cprng.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. //! Type-safe bindings for the Zircon kernel's CPRNG. //! use crate::{ok, ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/zircon/rust/src/cprng.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let keywords_exists = { if lang_path.exists() { read_syntax_file(language.to_ascii_lowercase(), "keywords.txt", &mut keywords) } else { false } }; let flow_exists = { ...
code_fim
hard
{ "lang": "rust", "repo": "AndrewGrim/NoteMaker", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if keywords_exists { for key in keywords.iter() { for mat in Regex::new((r"\b".to_string() + key + r"\b").as_str()).unwrap().find_iter(o_mat.as_str()) { tokens.push(RegexToken::new(Style::CodeBlockKeyword as usize, mat.start() + o_mat...
code_fim
hard
{ "lang": "rust", "repo": "AndrewGrim/NoteMaker", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndrewGrim/NoteMaker path: /src/lib.rs #![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_imports)] #![allow(unused_assignments)] #![allow(clippy::trivial_regex)] use std::fs; use std::path::Path; use pyo3::prelude::*; use pyo3::wrap_pyfunction; use pyo3::PyObjectProtocol; use re...
code_fim
hard
{ "lang": "rust", "repo": "AndrewGrim/NoteMaker", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arkoh/nrays path: /src/scene.rs use std::vec; use std::rt; use extra::arc::{Arc, RWArc}; use nalgebra::na::{Vec3, Vec4, Mat4}; use nalgebra::na; use ncollide::bounding_volume::{AABB, HasAABB}; use ncollide::partitioning::BVT; // use ncollide::partitioning::bvt_visitor::RayInterferencesCollector;...
code_fim
hard
{ "lang": "rust", "repo": "arkoh/nrays", "path": "/src/scene.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn intersects_ray(&self, ray: &Ray, maxtoi: N) -> bool { self.world.cast_ray(ray, &|b, r| { match b.get().geometry.toi_with_transform_and_ray(&b.get().transform, r) { None => None, Some(t) => if t <= maxtoi { Some((na::cast(-1.0), t)) } else {...
code_fim
hard
{ "lang": "rust", "repo": "arkoh/nrays", "path": "/src/scene.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gorf963/WordFind path: /src/main.rs pub(crate) const SEARCH_X: usize = 100; pub(crate) const SEARCH_Y: usize = 100; mod pause; mod loader; mod process; use pause::pause; use std::env; use std::time::Instant; use loader::loader; use process::brute; fn main() { <|fim_suffix|> if process_ty...
code_fim
hard
{ "lang": "rust", "repo": "Gorf963/WordFind", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Word list let mut final_word_contents: Vec<String> = Vec::new(); let mut search_arr = [['#';SEARCH_X];SEARCH_Y]; let mut results: Vec<String> = Vec::new(); let args: Vec<String> = env::args().collect(); let process_type = &args[1]; let word_filename = &args[2]; let searc...
code_fim
medium
{ "lang": "rust", "repo": "Gorf963/WordFind", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emirayka/nia_events path: /src/listeners/key_chord_listener/device_listener/device_listener_handle.rs use std::sync::mpsc; pub struct DeviceListenerHandle { stop_sender: mpsc::Sender<()>, } <|fim_suffix|> pub fn stop(&self) -> Result<(), ()> { match self.stop_sender.send(()) { ...
code_fim
medium
{ "lang": "rust", "repo": "emirayka/nia_events", "path": "/src/listeners/key_chord_listener/device_listener/device_listener_handle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn stop(&self) -> Result<(), ()> { match self.stop_sender.send(()) { Ok(_) => Ok(()), Err(_) => Err(()), } } }<|fim_prefix|>// repo: emirayka/nia_events path: /src/listeners/key_chord_listener/device_listener/device_listener_handle.rs use std::sync::mps...
code_fim
medium
{ "lang": "rust", "repo": "emirayka/nia_events", "path": "/src/listeners/key_chord_listener/device_listener/device_listener_handle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakeactually/chip-8 path: /src/main.rs extern crate piston_window; extern crate rand; extern crate serde; extern crate serde_json; mod assembler; mod chip8; mod cpu; mod data; mod dissasembler; mod hardware; mod run; use assembler::assemble; use serde::{Deserialize, Serialize}; use std::env; u...
code_fim
hard
{ "lang": "rust", "repo": "jakeactually/chip-8", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!(); println!("choose a game: "); let mut input = String::new(); stdin().read_line(&mut input).unwrap(); let index: u32; if let Ok(number) = input.trim().parse::<u32>() { index = number; } else { println!("not a number"); return } if let...
code_fim
hard
{ "lang": "rust", "repo": "jakeactually/chip-8", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_lift3() { assert_eq!(Some(("a", 1, true)), lift3(Some("a"), Some(1), Some(true))); assert_eq!(None, lift3::<&str, i32, bool>(None, Some(1), Some(true))); assert_eq!(None, lift3::<&str, i32, bool>(Some("a"), None, Some(true))); assert_eq!(None, lift3:...
code_fim
hard
{ "lang": "rust", "repo": "vangroan/rengine", "path": "/src/option.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vangroan/rengine path: /src/option.rs //! `Option` extensions /// Takes two `Option`s and returns a single /// `Option` wrapping both inner values. /// /// If either `Option` is `None`, the result /// will also be `None`. /// /// # Example /// /// ```ignore /// let a = Some("a"); /// let b = So...
code_fim
medium
{ "lang": "rust", "repo": "vangroan/rengine", "path": "/src/option.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let t = TestDir::new(|p| { let d = p.join("untraversable_dir"); create_dir(&d).unwrap(); set_permissions(&d, Permissions::from_mode(0o000)).unwrap(); }); assert!(spawn_threads(&app(t.path()), &mut FakeGCRoots::new(t.path())).is_err()); } ...
code_fim
hard
{ "lang": "rust", "repo": "flyingcircusio/userscan", "path": "/src/walk.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn walk_fixture_dir1() { let mut gcroots = fake_gc(); let stats = spawn_threads(&app("dir1"), &mut gcroots).unwrap(); assert_eq_vecs( gcroots.registered, |s| s.to_owned(), &[ "dir1/duplicated|010yd8jls8w4vcnql4zhjb...
code_fim
hard
{ "lang": "rust", "repo": "flyingcircusio/userscan", "path": "/src/walk.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flyingcircusio/userscan path: /src/walk.rs use crate::errors::UErr; use crate::output::p2s; use crate::registry::{GCRootsTx, Register}; use crate::scan::Scanner; use crate::statistics::{Statistics, StatsMsg, StatsTx}; use crate::storepaths::{Cache, Lookup, StorePaths}; use crate::App; use anyho...
code_fim
hard
{ "lang": "rust", "repo": "flyingcircusio/userscan", "path": "/src/walk.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub fn deserialise_date_greg<'de, D>(deserializer: D) -> Result<DateGreg, D::Error> where D: Deserializer<'de>, { let date_as_string = String::deserialize(deserializer)?; let (remaining_input, date) = parse_date_greg(&date_as_string).map_err(serde::de::Error::custom)?; if remaining_input.is_em...
code_fim
hard
{ "lang": "rust", "repo": "jlek/gedcom-parser", "path": "/src/gedcom_entities/dates.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jlek/gedcom-parser path: /src/gedcom_entities/dates.rs use crate::parsers::{parse_date_exact, parse_date_greg}; use serde::{Deserialize, Deserializer}; use std::fmt::{Display, Formatter}; #[derive(Debug, PartialEq)] pub struct DateExact { pub day: u8, pub month: Month, pub year: i16, } p...
code_fim
hard
{ "lang": "rust", "repo": "jlek/gedcom-parser", "path": "/src/gedcom_entities/dates.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rwooster/in_one_weekend path: /src/ray.rs use super::vec3; // A ray is represnted by P(t) = A + tB // P is a position along a 3D line // A is the origin of the ray // B is the direction of the ray #[derive(Debug, Copy, Clone)] pub struct Ray { pub origin: vec3::Point3, pub direction: ve...
code_fim
hard
{ "lang": "rust", "repo": "rwooster/in_one_weekend", "path": "/src/ray.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_ray() { let r1 = Ray::new(vec3::Vec3(1.0, 1.0, 1.0), vec3::Vec3(2.0, 0.0, 0.0)); assert!(r1.at(5.0) == vec3::Vec3(11.0, 1.0, 1.0)); } }<|fim_prefix|>// repo: rwooster/in_one_weekend path: /src/ray.rs use super::vec3; // A ray is represnted by P(t) = A + tB //...
code_fim
medium
{ "lang": "rust", "repo": "rwooster/in_one_weekend", "path": "/src/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match Message::read_with_detailed_error(&mut rd) { Ok(m) => { let used = rd.used(); self.frames.push_back(m); self.buf_consume(used); BufferContents::Valid } Err(MessageError::TooShortForHeader) | E...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/forks/rustls/src/msgs/deframer.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut rd = ByteRead::new(bytes); d.read(&mut rd) } fn input_bytes_concat( d: &mut MessageDeframer, bytes1: &[u8], bytes2: &[u8], ) -> io::Result<usize> { let mut bytes = vec![0u8; bytes1.len() + bytes2.len()]; bytes[..bytes1.len()].clo...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/forks/rustls/src/msgs/deframer.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/forks/rustls/src/msgs/deframer.rs use std::collections::VecDeque; use std::io; use crate::msgs::codec; use crate::msgs::message::{Message, MessageError}; /// This deframer works to reconstruct TLS messages /// from arbitrary-sized reads, bufferin...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/forks/rustls/src/msgs/deframer.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( FuncDef::new("fn nothing => {}"), Ok(( "", FuncDef { name: "nothing".to_string(), params: Vec::new(), body: Box::new(Stmt::Expr(Expr::Block(Block { stmts: Vec::new() })))...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/eldiro", "path": "/crates/eldiro/src/func_def.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/eldiro path: /crates/eldiro/src/func_def.rs use crate::env::Env; use crate::stmt::Stmt; use crate::utils; #[derive(Debug, Clone, PartialEq)] pub(crate) struct FuncDef { pub(crate) name: String, pub(crate) params: Vec<String>, pub(crate) body: Box<Stmt>, } impl FuncDef { ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/eldiro", "path": "/crates/eldiro/src/func_def.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut rooms = HashMap::new(); rooms.insert((0, 0), 0); visit(&route, &mut |e, (from, d)| { let to = e.apply(from); match rooms.entry(to) { Entry::Vacant(v) => { v.insert(d + 1); }, Entry::Occupied(mut o) => if d + 1 < *o.get...
code_fim
hard
{ "lang": "rust", "repo": "adriensamson/aoc2018", "path": "/src/day20/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adriensamson/aoc2018 path: /src/day20/mod.rs use std::collections::HashMap; use std::collections::hash_map::Entry; pub fn step1(input : String) { let rooms = get_rooms(input); let mut roomsv : Vec<((i32, i32), i32)> = rooms.iter().map(|(k, v)| (*k, *v)).collect(); roomsv.sort_by_ke...
code_fim
hard
{ "lang": "rust", "repo": "adriensamson/aoc2018", "path": "/src/day20/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jtanguy/metallircd path: /libmetallirc/src/util.rs //! Various utility functions. #![experimental] use std::io::{BufferedStream, IoResult}; use std::io::net::tcp::TcpStream; use messages::IRCMessage; /// Write an IRCMessage to a socket. #[experimental] pub fn write_message(socket: &mut Buffe...
code_fim
hard
{ "lang": "rust", "repo": "jtanguy/metallircd", "path": "/libmetallirc/src/util.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(matches_mask("foo", "foo")); assert!(matches_mask("foo", "fo?")); assert!(matches_mask("foo", "f?o")); assert!(matches_mask("foo", "?oo")); assert!(matches_mask("foo", "f*")); assert!(matches_mask("foo", "*")); assert!(!matches_mask("foo", "f...
code_fim
hard
{ "lang": "rust", "repo": "jtanguy/metallircd", "path": "/libmetallirc/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let game_board_move = format!("{} {} {} {}", x1, y1, x2, y2).parse::<GameBoardMove>(); if (x1 > 0 && x1 <= GAME_BOARD_SIZE as isize && y1 > 0 && y1 <= GAME_BOARD_SIZE as isize) && (x2 > 0 && x2 <= GAME_BOARD_SIZE as isize && y2 > 0 && y2 <= GAME_BOARD_SIZE as isize) { ...
code_fim
hard
{ "lang": "rust", "repo": "qbit-org-ua/2018-KhCup-I-am-robot", "path": "/lines-game-engine/src/location/tests/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qbit-org-ua/2018-KhCup-I-am-robot path: /lines-game-engine/src/location/tests/mod.rs use super::super::common::GAME_BOARD_SIZE; use super::{GameBoardLocation, GameBoardMove}; #[test] fn game_board_walker_can_walk() { let mut walker = GameBoardLocation::zero().walk(1, 0); for x in 0..GAM...
code_fim
hard
{ "lang": "rust", "repo": "qbit-org-ua/2018-KhCup-I-am-robot", "path": "/lines-game-engine/src/location/tests/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arucil/hashlife path: /algo/src/universe.rs ot: NodeId, empty_nodes: Vec<NodeId>, /// result is a 2x2 square, whose cells are arranged as follows /// ```ignored /// bit 7 ... 5 4 3 2 1 0 /// - - NW NE - - SW SE /// ``` level2_results: [u8; 65536], rule: Rule, last...
code_fim
hard
{ "lang": "rust", "repo": "arucil/hashlife", "path": "/algo/src/universe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arucil/hashlife path: /algo/src/universe.rs exSet<Box<Node>, BuildHasherDefault<FxHasher>>, root: NodeId, empty_nodes: Vec<NodeId>, /// result is a 2x2 square, whose cells are arranged as follows /// ```ignored /// bit 7 ... 5 4 3 2 1 0 /// - - NW NE - - SW SE /// ```...
code_fim
hard
{ "lang": "rust", "repo": "arucil/hashlife", "path": "/algo/src/universe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_level4_result1() { let mut uni = Universe::new(GAME_OF_LIFE); uni.set(-1, -1, true); uni.set(0, -1, true); uni.set(-2, 0, true); uni.set(-1, 0, true); uni.set(-1, 1, true); uni.expand(); let node = uni.step(uni.root, 0); assert_eq!(uni.debug(node), ...
code_fim
hard
{ "lang": "rust", "repo": "arucil/hashlife", "path": "/algo/src/universe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elpinal/types path: /src/substitution.rs //! Non-explicit substitution. /// A type. #[derive(Clone, Debug, PartialEq)] pub enum Type { /// A type variable with the index. Var(usize), /// An universally-quantified type. Forall(Box<Type>), /// An arrow type. Arr(Box<Type>,...
code_fim
hard
{ "lang": "rust", "repo": "elpinal/types", "path": "/src/substitution.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use self::Type::*; fn f(n: usize) -> Type { let mut t = Var(0); for _ in 0..n { t = Type::arr(Var(0), t) } t } let big = f(100); b.iter(|| big.clone().subst_top(&big)); } }<|fim_prefix|>// repo: elp...
code_fim
hard
{ "lang": "rust", "repo": "elpinal/types", "path": "/src/substitution.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: negrel/magie path: /src/color_space/luma.rs use num::traits::NumOps; use crate::color_space::rgb::RGB; #[derive(Debug)] pub struct Luma<T> { pub val: T, } <|fim_suffix|> Luma { val: luma } } } impl<T: From<isize> + NumOps + Copy> From<RGB<T>> for Luma<T> { fn from(src: RGB...
code_fim
medium
{ "lang": "rust", "repo": "negrel/magie", "path": "/src/color_space/luma.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: From<isize> + NumOps + Copy> From<RGB<T>> for Luma<T> { fn from(src: RGB<T>) -> Self { let luma = (src.r + src.g + src.b) / T::from(3); Luma::new(luma) } }<|fim_prefix|>// repo: negrel/magie path: /src/color_space/luma.rs use num::traits::NumOps; use crate::color_space::r...
code_fim
medium
{ "lang": "rust", "repo": "negrel/magie", "path": "/src/color_space/luma.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/security/scrutiny/lib/framework/src/store/memory.rs // Copyright 2021 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 { super::store::Store, anyhow::{...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/security/scrutiny/lib/framework/src/store/memory.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &self.uri } /// Lists all the collectionsin the database. fn collections(&self) -> Result<Vec<Uuid>> { Ok(self.ram_disk.keys().map(|k| k.clone()).collect()) } /// Create a new table, initializing it and adding it to the database. fn set(&mut self, name: Uuid, coll...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/security/scrutiny/lib/framework/src/store/memory.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chimochio/civ path: /game/src/states/map_editor.rs use allegro::{Color, Event}; use allegro_font::FontAlign; use std::u8; #[no_mangle] #[derive(Clone)] pub struct MapEditor { camera: ::Pos, camera_speed: i32, pressed_keys: ::util::KeySet, map: ::MapDef, selected_tile: ::Pos,...
code_fim
hard
{ "lang": "rust", "repo": "chimochio/civ", "path": "/game/src/states/map_editor.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl MapEditor { fn handle_button(&mut self, id: u32) { match id { 1 => self.add_column(), 2 => self.add_row(), _ => (), } } fn add_column(&mut self) { let column = self.map.last().unwrap().clone(); self.map.push(column); ...
code_fim
hard
{ "lang": "rust", "repo": "chimochio/civ", "path": "/game/src/states/map_editor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn empty_braces_deref_a_tag() { let rec = parse("v1.2^{}"); assert!(rec.kind.is_none()); assert_eq!(rec.get_ref(0), "v1.2"); assert_eq!(rec.peel_to, vec![PeelTo::RecursiveTagObject]); assert_eq!(rec.calls, 2); } #[test] fn invalid_object_type() { let err = try_parse("@^{i...
code_fim
hard
{ "lang": "rust", "repo": "Byron/gitoxide", "path": "/gix-revision/tests/spec/parse/navigate/caret_symbol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(rec.kind.is_none()); assert!(rec.find_ref[0].as_ref().is_some() || rec.prefix[0].is_some()); assert_eq!(rec.patterns, vec![(regex.into(), false)], "{msg}"); assert_eq!(rec.calls, 2); } } #[test] fn regex_with_revision_starting_point_and_negation() { for (sp...
code_fim
hard
{ "lang": "rust", "repo": "Byron/gitoxide", "path": "/gix-revision/tests/spec/parse/navigate/caret_symbol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Byron/gitoxide path: /gix-revision/tests/spec/parse/navigate/caret_symbol.rs use gix_revision::{spec, spec::parse::delegate::Traversal}; use crate::spec::parse::{parse, try_parse, PeelToOwned as PeelTo}; #[test] fn single_is_first_parent() { let rec = parse("@^"); assert!(rec.kind.is_...
code_fim
hard
{ "lang": "rust", "repo": "Byron/gitoxide", "path": "/gix-revision/tests/spec/parse/navigate/caret_symbol.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let long_delimiter = r###"A string with "# in it. And even "##!"###; println!("{}", long_delimiter); /// 3. let bytestring = b"this is a bytestring"; println!("A bytestring: {:?}", bytestring); let escaped = b"\x52\x75\x73\x74 as bytes"; println!("Some escaped bytes: {:?}",...
code_fim
hard
{ "lang": "rust", "repo": "chinagxwei/rust-by-example", "path": "/src/example_19_std/example_19_3_str.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let shift_jis = b"\x82\xe6\x82\xa8\x82\xb1\x82"; match std::str::from_utf8(shift_jis) { Ok(my_str) => println!("Conversion successful: {}", my_str), Err(e) => println!("Conversion failed: {:?}", e) } } #[cfg(test)] mod tests { use super::*; #[test] fn example_19_...
code_fim
hard
{ "lang": "rust", "repo": "chinagxwei/rust-by-example", "path": "/src/example_19_std/example_19_3_str.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chinagxwei/rust-by-example path: /src/example_19_std/example_19_3_str.rs fn strings() { let pangram = "the quick brown fox jumps over the lazy dog"; println!("Pangram: {}", pangram); println!("Words in reverse"); for word in pangram.split_whitespace().rev() { println!(">...
code_fim
hard
{ "lang": "rust", "repo": "chinagxwei/rust-by-example", "path": "/src/example_19_std/example_19_3_str.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredrb/rust-brainfck path: /tests/machine_test.rs extern crate brainfck; use brainfck::machine::Machine as m; <|fim_suffix|> let mut machine = m::new(); machine.load_program("+++."); }<|fim_middle|>#[test] fn test_load_program() {
code_fim
easy
{ "lang": "rust", "repo": "fredrb/rust-brainfck", "path": "/tests/machine_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut machine = m::new(); machine.load_program("+++."); }<|fim_prefix|>// repo: fredrb/rust-brainfck path: /tests/machine_test.rs extern crate brainfck; use brainfck::machine::Machine as m; <|fim_middle|>#[test] fn test_load_program() {
code_fim
easy
{ "lang": "rust", "repo": "fredrb/rust-brainfck", "path": "/tests/machine_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } } } } // @lc code=end<|fim_prefix|>// repo: fujiehuang/leetcode-rust path: /10.regular-expression-matching.rs /* * @lc app=leetcode id=10 lang=rust * * [10] Regular Expression Matching */ // @lc code=start impl Solution { pub fn is_match(s: String, p: String) -> bool { ...
code_fim
medium
{ "lang": "rust", "repo": "fujiehuang/leetcode-rust", "path": "/10.regular-expression-matching.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fujiehuang/leetcode-rust path: /10.regular-expression-matching.rs /* * @lc app=leetcode id=10 lang=rust * * [10] Regular Expression Matching */ // @lc code=start impl Solution { pub fn is_match(s: String, p: String) -> bool { let sn = s.len(); let pn = p.len(); <|fim_su...
code_fim
medium
{ "lang": "rust", "repo": "fujiehuang/leetcode-rust", "path": "/10.regular-expression-matching.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ConnorBelman/SHA-CLI path: /src/sha512.rs #[path = "preprocess.rs"] mod preprocess; use std::num::Wrapping; const H0_0: u64 = 0x6A09E667F3BCC908; const H1_0: u64 = 0xBB67AE8584CAA73B; const H2_0: u64 = 0x3C6EF372FE94F82B; const H3_0: u64 = 0xA54FF53A5F1D36F1; const H4_0: u64 = 0x510E527FADE68...
code_fim
hard
{ "lang": "rust", "repo": "ConnorBelman/SHA-CLI", "path": "/src/sha512.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn process_blocks(blocks: Vec<[u128; 8]>) -> [u64; 8] { let mut hash = [H0_0, H1_0, H2_0, H3_0, H4_0, H5_0, H6_0, H7_0]; for block in blocks { let mut w: [u64; 80] = break_block_into_words(block); for i in 16..80 { let s0: u64 = w[i - 15].rotate_right(1) ^ w[i - 15].rotate_right(8) ^ (w[i - 15] >...
code_fim
hard
{ "lang": "rust", "repo": "ConnorBelman/SHA-CLI", "path": "/src/sha512.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if count > max { max = count; } count = 0; } } if count > max { max = count; } return max; } #[test] pub fn t1() { assert_eq!(find_max_consecutive_ones(vec![1, 1, 0, 1, 1, 1]), 3); }<|fim_prefix|>// repo: gengjiawen/leetcode p...
code_fim
hard
{ "lang": "rust", "repo": "gengjiawen/leetcode", "path": "/Array/_0485_max_consecutive_ones.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gengjiawen/leetcode path: /Array/_0485_max_consecutive_ones.rs // https://leetcode.com/problems/max-consecutive-ones // // Given a binary array `nums`, return _the maximum number of consecutive_ `1`_'s in the array_. // // **Example 1:** // // ``` // **Input:** nums = [1,1,0,1,1,1] // **Output:*...
code_fim
hard
{ "lang": "rust", "repo": "gengjiawen/leetcode", "path": "/Array/_0485_max_consecutive_ones.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /compiler/rustc_error_messages/src/lib.rs LanguageIdentifier>, additional_ftl_path: Option<&Path>, with_directionality_markers: bool, ) -> Result<Option<Lrc<FluentBundle>>, TranslationBundleError> { if requested_locale.is_none() && additional_ftl_path.is_none() {...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/compiler/rustc_error_messages/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the strings to highlight. We always ensure that there /// is an entry for each of the primary spans -- for each primary /// span `P`, if there is at least one label with span `P`, we return /// those labels (marked as primary). But otherwise we return /// `SpanLabel` instan...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/compiler/rustc_error_messages/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /compiler/rustc_error_messages/src/lib.rs ssingLocale, /// Cannot read directory entries of `$sysroot/share/locale/$locale`. ReadLocalesDir(io::Error), /// Cannot read directory entry of `$sysroot/share/locale/$locale`. ReadLocalesDirEntry(io::Error), ///...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/compiler/rustc_error_messages/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>declare_clippy_lint! { /// ### What it does /// Finds patterns that reimplement `Option::unwrap_or` or `Result::unwrap_or`. /// /// ### Why is this bad? /// Concise code helps focusing on behavior instead of boilerplate. /// /// ### Example /// ```rust /// let foo: Opti...
code_fim
hard
{ "lang": "rust", "repo": "avborhanian/rust-clippy", "path": "/clippy_lints/src/matches/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avborhanian/rust-clippy path: /clippy_lints/src/matches/mod.rs pattern used with others patterns in same match arm. /// /// ### Why is this bad? /// Wildcard pattern already covers any other pattern as it will match anyway. /// It makes the code less readable, especially to spot ...
code_fim
hard
{ "lang": "rust", "repo": "avborhanian/rust-clippy", "path": "/clippy_lints/src/matches/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>declare_clippy_lint! { /// ### What it does /// Lint for redundant pattern matching over `Result`, `Option`, /// `std::task::Poll` or `std::net::IpAddr` /// /// ### Why is this bad? /// It's more concise and clear to just use the proper /// utility function /// /// ### ...
code_fim
hard
{ "lang": "rust", "repo": "avborhanian/rust-clippy", "path": "/clippy_lints/src/matches/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trisiel/trisiel path: /src/bin/api.rs #![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; use color_eyre::eyre::Result; use rocket_contrib::helmet::SpaceHelmet; use rocket_oauth2::OAuth2; use ::wasmcloud_api::{api, b2, gitea, jwt, Gitea, MainDatabase}; <|fim_suffix|...
code_fim
medium
{ "lang": "rust", "repo": "trisiel/trisiel", "path": "/src/bin/api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> rocket::ignite() .attach(OAuth2::<Gitea>::fairing("gitea")) .attach(MainDatabase::fairing()) .attach(SpaceHelmet::default()) .mount( "/api", routes![ api::handler::create, api::handler::list, api::h...
code_fim
hard
{ "lang": "rust", "repo": "trisiel/trisiel", "path": "/src/bin/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koute/Peroxide path: /src/bin/rand_test.rs extern crate rand; extern crate peroxide; use rand::prelude::*; use rand::distributions::{Gamma, Normal}; use peroxide::*; fn main() { let mut rng1 = thread_rng(); let mut rng2 = thread_rng(); let n = Normal::new(0f64, 1f64); println!...
code_fim
medium
{ "lang": "rust", "repo": "koute/Peroxide", "path": "/src/bin/rand_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0 .. 10000 { v[i] = rng1.sample(g); } v.mean().print(); v.var().print(); }<|fim_prefix|>// repo: koute/Peroxide path: /src/bin/rand_test.rs extern crate rand; extern crate peroxide; use rand::prelude::*; use rand::distributions::{Gamma, Normal}; use peroxide::*; fn mai...
code_fim
medium
{ "lang": "rust", "repo": "koute/Peroxide", "path": "/src/bin/rand_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let child = thread::spawn(move || { println!("Starting child thread, press Ctrl-C to exit"); while stay_alive.load(Ordering::SeqCst) { thread::sleep(half_sec); output.toggle(); } }); println!("Main thread is waiting for input pin to go HIGH"); ...
code_fim
hard
{ "lang": "rust", "repo": "ntd-94/beaglebone-projects", "path": "/learning-beaglebone/gpio_rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ntd-94/beaglebone-projects path: /learning-beaglebone/gpio_rust/src/main.rs use std::{thread, time}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use simple_signal::Signal; // From this module use gpio_rust::{OutputPin, InputPin}; <|fim_suffix|> let child = thread::spaw...
code_fim
hard
{ "lang": "rust", "repo": "ntd-94/beaglebone-projects", "path": "/learning-beaglebone/gpio_rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Main thread is waiting for input pin to go HIGH"); input.poll_until_high(); println!("Input pin went high, joining child and waiting for you to exit."); child.join().expect("Could not join child thread"); }<|fim_prefix|>// repo: ntd-94/beaglebone-projects path: /learning-beagle...
code_fim
hard
{ "lang": "rust", "repo": "ntd-94/beaglebone-projects", "path": "/learning-beaglebone/gpio_rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> f.pad(&format!("{}({})", self.name, self.code)) } } impl fmt::Display for TrackedCameraError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad(&self.name) } } pub fn check_err(fn_tab: FnTable, code: sys::EVRTrackedCameraError) -> Result<(), TrackedCameraError> { if code =...
code_fim
medium
{ "lang": "rust", "repo": "funmaker/Project39-ar", "path": "/src/application/vr/tracked_camera/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn check_err(fn_tab: FnTable, code: sys::EVRTrackedCameraError) -> Result<(), TrackedCameraError> { if code == sys::EVRTrackedCameraError_VRTrackedCameraError_None { Ok(()) } else { let name = fn_tab.GetCameraErrorNameFromEnum .map(|f| unsafe { f(code) }) ...
code_fim
hard
{ "lang": "rust", "repo": "funmaker/Project39-ar", "path": "/src/application/vr/tracked_camera/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: funmaker/Project39-ar path: /src/application/vr/tracked_camera/error.rs use std::{error, fmt}; use std::ffi::CStr; use ::openvr_sys as sys; use super::FnTable; pub struct InitError(pub sys::EVRInitError); impl error::Error for InitError {} impl fmt::Debug for InitError { fn fmt(&self,...
code_fim
hard
{ "lang": "rust", "repo": "funmaker/Project39-ar", "path": "/src/application/vr/tracked_camera/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }