text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: kkirstein/proglang-playground path: /Rust/Benchmark/src/fibonacci.rs // fibonacci.rs // Calulate Fibonacci numbers in Rust // // vim: ft=rust sw=4 ts=4 // use num::bigint::BigInt; use num::{One, Zero}; // a naive recursive implementation pub fn fib_naive(n: u64) -> u64 { if n < 2 { ...
code_fim
medium
{ "lang": "rust", "repo": "kkirstein/proglang-playground", "path": "/Rust/Benchmark/src/fibonacci.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use num::bigint::ToBigInt; assert_eq!(fib(0), 0.to_bigint().unwrap()); assert_eq!(fib(1), 1.to_bigint().unwrap()); assert_eq!(fib(2), 1.to_bigint().unwrap()); assert_eq!(fib(3), 2.to_bigint().unwrap()); assert_eq!(fib(4), 3.to_bigint().unwrap()); ass...
code_fim
hard
{ "lang": "rust", "repo": "kkirstein/proglang-playground", "path": "/Rust/Benchmark/src/fibonacci.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andreasots/eris path: /src/commands/tracing.rs use std::future::Future; use std::pin::Pin; use anyhow::{Context, Error}; use tracing_subscriber::reload::Handle; use tracing_subscriber::EnvFilter; use twilight_cache_inmemory::InMemoryCache; use twilight_http::Client as DiscordClient; use twiligh...
code_fim
hard
{ "lang": "rust", "repo": "andreasots/eris", "path": "/src/commands/tracing.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let filter = EnvFilter::try_new(directives).context("failed to construct the new filter")?; let mut old_filter = String::new(); self.reload_handle.modify(|layer| { old_filter = layer.to_string(); *layer = filter; ...
code_fim
hard
{ "lang": "rust", "repo": "andreasots/eris", "path": "/src/commands/tracing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rappet/lookout path: /src/main.rs extern crate actix_web; extern crate actix_files; extern crate actix_rt; extern crate futures; #[macro_use] extern crate log; extern crate pretty_env_logger; extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate tera; extern crate...
code_fim
medium
{ "lang": "rust", "repo": "rappet/lookout", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pretty_env_logger::init(); let state = State::new(); let sys = actix_rt::System::new("lookout"); HttpServer::new(move || { let templ = compile_templates!("templates/**/*"); App::new() .data(templ) .data(state.clone()) .wrap(middleware::L...
code_fim
medium
{ "lang": "rust", "repo": "rappet/lookout", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> Result<()> { pretty_env_logger::init(); let state = State::new(); let sys = actix_rt::System::new("lookout"); HttpServer::new(move || { let templ = compile_templates!("templates/**/*"); App::new() .data(templ) .data(state.clone()) ...
code_fim
medium
{ "lang": "rust", "repo": "rappet/lookout", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut entries = Vec::new(); for capture in ENUM_FINDER.captures_iter(&contents) { let elements: Vec<String> = ENUM_ANALIZER.captures_iter(&capture["content"]).map(|c| c.name("rename").map(|m| m.as_str()).unwrap_or(&c["symbol"]).to_owned()).collect(); if !elements.is_empty() { ...
code_fim
hard
{ "lang": "rust", "repo": "lnicola/serde_fix", "path": "/enum_checker/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let entries = try_join_all(files.into_iter().map(|path| async { read_file(path).await })).await?; let ref_entries = entries.iter().fold(HashMap::new(), |mut hm, ev| { for e in ev { let entry = hm.entry(format!("{:?}", e.elements)).or_insert_with(Vec::new); ...
code_fim
hard
{ "lang": "rust", "repo": "lnicola/serde_fix", "path": "/enum_checker/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lnicola/serde_fix path: /enum_checker/src/main.rs use std::{collections::HashMap, fs::read_dir, path::{PathBuf, Path}}; use tokio::{fs::File, io::AsyncReadExt}; // use async_lock::RwLock; use futures_util::future::try_join_all; use structopt::StructOpt; use once_cell::sync::Lazy; use regex...
code_fim
hard
{ "lang": "rust", "repo": "lnicola/serde_fix", "path": "/enum_checker/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // adding a task to scheduler to execute it every 2 minutes scheduler.add(Job::new("1/2 * * * * *".parse().unwrap(),|| { println!("Get executed every 2 seconds"); })); scheduler.add(Job::new("1/10 * * * * *".parse().unwrap(), || { println!("Get executed every 10 seconds"); })); loop { schedu...
code_fim
medium
{ "lang": "rust", "repo": "justisGipson/scheduler", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { scheduler.tick(); std::thread::sleep(Duration::from_millis(100)); } }<|fim_prefix|>// repo: justisGipson/scheduler path: /src/main.rs extern crate job_scheduler; use job_scheduler::{Job, JobScheduler}; use std::time::Duration; fn main() { let mut scheduler = JobScheduler::new(); <|fim_mi...
code_fim
hard
{ "lang": "rust", "repo": "justisGipson/scheduler", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: justisGipson/scheduler path: /src/main.rs extern crate job_scheduler; use job_scheduler::{Job, JobScheduler}; use std::time::Duration; fn main() { let mut scheduler = JobScheduler::new(); <|fim_suffix|> loop { scheduler.tick(); std::thread::sleep(Duration::from_millis(100)); } }<|fim_mi...
code_fim
hard
{ "lang": "rust", "repo": "justisGipson/scheduler", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>_ptr()); }; let mut delkey: libc::c_int = (jv_array_length(jv_array_get(jv_copy(paths), i)) == start + 1 as libc::c_int) as libc::c_int; let mut key: jv = jv_array_get(jv_array_get(jv_copy(paths), i), start); while j < jv_array_lengt...
code_fim
hard
{ "lang": "rust", "repo": "thomasmatecki/jq2rs", "path": "/jq2rs/src/src/jv_aux.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>id_with_msg(jv_string_fmt(b"Cannot index %s with %s\x00" as *const u8 as *const libc::c_char, jv_kind_name(jv_get_kind(t)), ...
code_fim
hard
{ "lang": "rust", "repo": "thomasmatecki/jq2rs", "path": "/jq2rs/src/src/jv_aux.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomasmatecki/jq2rs path: /jq2rs/src/src/jv_aux.rs t == JV_KIND_STRING as libc::c_int as libc::c_uint || jv_get_kind(k) as libc::c_uint == JV_KIND_NUMBER as libc::c_int as libc::c_uint || jv_get_kind(...
code_fim
hard
{ "lang": "rust", "repo": "thomasmatecki/jq2rs", "path": "/jq2rs/src/src/jv_aux.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shensam/rust-realworld-example-app path: /src/http/guards/auth.rs use rocket::http::Status; use rocket::request::{self, FromRequest}; use rocket::{Outcome, Request, State}; use core::types::user::CurrentUser; use settings::Settings; use jwt::{Algorithm, decode}; impl<'a, 'r> FromRequest<'a, 'r...
code_fim
hard
{ "lang": "rust", "repo": "shensam/rust-realworld-example-app", "path": "/src/http/guards/auth.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let settings = request.guard::<State<Settings>>()?; let secret = settings.auth.secret.clone(); request.headers().get_one("Authorization") .and_then(|token| { let token = if token.len() > 6 {&token[6..]} else {""}; // "Token JWTToken" deb...
code_fim
hard
{ "lang": "rust", "repo": "shensam/rust-realworld-example-app", "path": "/src/http/guards/auth.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn color(mut self, color: Vector4<f32>) -> Self { self.color = Some(color); self } pub fn random_color(mut self) -> Self { self.color = None; self } pub fn build( self, ctx: &GraphicsContext, slice_pipeline: &SlicePipeline, ...
code_fim
hard
{ "lang": "rust", "repo": "t-veor/hypervis", "path": "/src/shapes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn angular_velocity(mut self, angular_velocity: Bivec4) -> Self { self.velocity.angular = angular_velocity; self } pub fn mass(mut self, mass: f32) -> Self { self.mass = mass; self } pub fn material(mut self, material: Material) -> Self { s...
code_fim
hard
{ "lang": "rust", "repo": "t-veor/hypervis", "path": "/src/shapes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: t-veor/hypervis path: /src/shapes.rs use cgmath::{InnerSpace, Vector4, Zero}; use crate::alg::{Bivec4, Rotor4}; use crate::context::{graphics::SlicePipeline, GraphicsContext}; use crate::mesh::{Mesh, TetrahedronMesh}; use crate::physics::{Body, Collider, Material, Velocity}; use crate::world::O...
code_fim
hard
{ "lang": "rust", "repo": "t-veor/hypervis", "path": "/src/shapes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kunicmarko20/ghnotifier-rs path: /src/infrastructure/factory/notifier_factory.rs use crate::infrastructure::noop::noop_notifier::NoopNotifier; use crate::infrastructure::system::system_notifier::SystemNotifier; use crate::ui::gui::notifier::Notifier; <|fim_suffix|> pub fn from_arg(&self, qui...
code_fim
medium
{ "lang": "rust", "repo": "kunicmarko20/ghnotifier-rs", "path": "/src/infrastructure/factory/notifier_factory.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Box::new(SystemNotifier::default()) } }<|fim_prefix|>// repo: kunicmarko20/ghnotifier-rs path: /src/infrastructure/factory/notifier_factory.rs use crate::infrastructure::noop::noop_notifier::NoopNotifier; use crate::infrastructure::system::system_notifier::SystemNotifier; use crate::ui::gui::...
code_fim
medium
{ "lang": "rust", "repo": "kunicmarko20/ghnotifier-rs", "path": "/src/infrastructure/factory/notifier_factory.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl NotifierFactory { pub fn new() -> Self { NotifierFactory } pub fn from_arg(&self, quiet: bool) -> Box<Notifier> { if quiet { return Box::new(NoopNotifier::new()); } Box::new(SystemNotifier::default()) } }<|fim_prefix|>// repo: kunicmarko20...
code_fim
easy
{ "lang": "rust", "repo": "kunicmarko20/ghnotifier-rs", "path": "/src/infrastructure/factory/notifier_factory.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zonyitoo/crypto2 path: /src/streamcipher/mod.rs pub use crate::blockmode::{ Sm4Ctr, Aes128Ctr, Aes192Ctr, Aes256Ctr, Aria128Ctr, Aria192Ctr, Aria256Ctr, Camellia128Ctr, Camellia192Ctr, Camellia256Ctr, Sm4Ofb, Aes128Ofb, Aes192Ofb, Aes256Ofb, Aria128Ofb, Aria192Ofb, A...
code_fim
hard
{ "lang": "rust", "repo": "zonyitoo/crypto2", "path": "/src/streamcipher/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut plaintext_and_ciphertext = test::black_box([1u8; Chacha20::BLOCK_LEN]); let chacha20 = Chacha20::new(&key); b.bytes = Chacha20::BLOCK_LEN as u64; b.iter(|| { chacha20.encrypt_slice(1, &nonce, &mut plaintext_and_ciphertext); }) }<|fim_prefix|>// repo: zonyitoo/...
code_fim
hard
{ "lang": "rust", "repo": "zonyitoo/crypto2", "path": "/src/streamcipher/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peku33/logicblocks path: /Controller/src/devices/houseblocks/avr_v1/properties/state_in.rs use parking_lot::Mutex; #[derive(Debug)] struct State<T> where T: Eq + Clone + Send + Sync + 'static, { value: Option<T>, user_pending: bool, } impl<T> State<T> where T: Eq + Clone + Send ...
code_fim
hard
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/devices/houseblocks/avr_v1/properties/state_in.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn take_pending(&self) -> Option<Option<T>> { let mut state = self.property.state.lock(); if !state.user_pending { return None; } let value = state.value.clone(); state.user_pending = false; drop(state); Some(value) } ...
code_fim
hard
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/devices/houseblocks/avr_v1/properties/state_in.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> value } } #[cfg(test)] mod tests { use super::*; #[test] fn test_1() { let property = Property::<usize>::new(); let stream = property.user_remote(); assert!(stream.take_pending().is_none()); assert!(property.device_must_read()); assert_eq...
code_fim
hard
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/devices/houseblocks/avr_v1/properties/state_in.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl Executor for Handle { fn execute(&self, f: Pin<Box<dyn Future<Output = ()> + Send + 'static>>) { self.spawn(f); } }<|fim_prefix|>// repo: gengteng/rust-http2 path: /src/exec.rs use std::future::Future; use std::pin::Pin; use tokio::runtime::Handle; <|fim_middle|>pub trait Executo...
code_fim
medium
{ "lang": "rust", "repo": "gengteng/rust-http2", "path": "/src/exec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gengteng/rust-http2 path: /src/exec.rs use std::future::Future; use std::pin::Pin; use tokio::runtime::Handle; <|fim_suffix|>} impl Executor for Handle { fn execute(&self, f: Pin<Box<dyn Future<Output = ()> + Send + 'static>>) { self.spawn(f); } }<|fim_middle|>pub trait Executo...
code_fim
medium
{ "lang": "rust", "repo": "gengteng/rust-http2", "path": "/src/exec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Executor for Handle { fn execute(&self, f: Pin<Box<dyn Future<Output = ()> + Send + 'static>>) { self.spawn(f); } }<|fim_prefix|>// repo: gengteng/rust-http2 path: /src/exec.rs use std::future::Future; use std::pin::Pin; use tokio::runtime::Handle; <|fim_middle|>pub trait Executor {...
code_fim
medium
{ "lang": "rust", "repo": "gengteng/rust-http2", "path": "/src/exec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nkbai/lock-free-stack path: /src/lib.rs use std::sync::atomic::Ordering; extern crate crossbeam_epoch as epoch; use epoch::{Atomic, Owned, Shared}; pub struct Node { value: i32, next: *const Node, } pub struct LockFreeStack { next: Atomic<Node>, } unsafe impl Sync for LockFreeStack {...
code_fim
hard
{ "lang": "rust", "repo": "nkbai/lock-free-stack", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _i in 0..100 { test_lock_free_stack_push_and_pop(); } } #[test] fn test_lock_free_stack_push_and_pop() { extern crate crossbeam_utils; use crossbeam_utils::sync::WaitGroup; use std::sync::{Arc, Barrier, Mutex}; use std::thread; ...
code_fim
hard
{ "lang": "rust", "repo": "nkbai/lock-free-stack", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _i in 0..100 { test_lock_free_stack_push_then_pop(); } } #[test] fn test_lock_free_stack_push_then_pop() { extern crate crossbeam_utils; use crossbeam_utils::sync::WaitGroup; use std::sync::{Arc, Barrier, Mutex}; use std::thread; ...
code_fim
hard
{ "lang": "rust", "repo": "nkbai/lock-free-stack", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mxinden/kvs path: /src/thread_pool/shared.rs use log::error; use std::panic; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::{Arc, Mutex}; use std::thread; use super::ThreadPool; use crate::error::Result; /// A shared thread pool implementation. pub struct SharedQueueThreadPoo...
code_fim
hard
{ "lang": "rust", "repo": "mxinden/kvs", "path": "/src/thread_pool/shared.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let job = rx.recv(); drop(rx); match job { Ok(job) => match panic::catch_unwind(job) { Ok(()) => {} Err(e) => error!("{:?}", e), }, ...
code_fim
hard
{ "lang": "rust", "repo": "mxinden/kvs", "path": "/src/thread_pool/shared.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>.red,c.green,c.blue); let mut c=Color(255,0,0); println!("Color:{} {} {}",c.0,c.1,c.2 ); }<|fim_prefix|>// repo: alenops/opal path: /learn_notes/rust/src/structs.rs // 结构体 // struct Color{ // red:u8, // green:u8, // blue:u8 // } // tuple Sruct struct Color(u8,u8,u8); pub fn run(){ // let ...
code_fim
medium
{ "lang": "rust", "repo": "alenops/opal", "path": "/learn_notes/rust/src/structs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alenops/opal path: /learn_notes/rust/src/structs.rs // 结构体 // struct Color{ // red:u8, // green:u8, // blue:u8 // } // tuple Sru<|fim_suffix|> green:0, // blue:0 // } ; // c.red=200; // println!("Color:{} {} {}",c.red,c.green,c.blue); let mut c=Color(255,0,0); prin...
code_fim
medium
{ "lang": "rust", "repo": "alenops/opal", "path": "/learn_notes/rust/src/structs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gterzian/tendermint-rs path: /tendermint-lite/src/main.rs #[macro_use] extern crate futures; use futures::stream::StreamExt; use tendermint::hash; use tendermint::lite; use tendermint::lite::TrustThresholdFraction; use tendermint::lite::{Header as _, Requester as _, ValidatorSet as _}; use ten...
code_fim
hard
{ "lang": "rust", "repo": "gterzian/tendermint-rs", "path": "/tendermint-lite/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // sleep for a few secs ? } } /* * The following is initialization logic that should have a * function in the lite crate like: * `subjective_init(height, vals_hash, store, requester) -> Result<(), Error` * it would fetch the initial header/vals from the requester and populate a * trusted...
code_fim
hard
{ "lang": "rust", "repo": "gterzian/tendermint-rs", "path": "/tendermint-lite/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<ChangedPath> for InnerPath { fn from(path: ChangedPath) -> Self { match path { ChangedPath::Created(path) => path.into(), ChangedPath::Deleted(path) => path.into(), } } } impl From<Path> for InnerPath { fn from(path: Path) -> Self { ma...
code_fim
hard
{ "lang": "rust", "repo": "m-rots/bernard-rs", "path": "/src/model/path.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m-rots/bernard-rs path: /src/model/path.rs use std::path::PathBuf; use crate::database::Pool; use futures::prelude::*; #[derive(Debug)] pub enum Path { File(InnerPath), Folder(InnerPath), } impl Path { pub fn trashed(&self) -> bool { match self { Self::File(inn...
code_fim
hard
{ "lang": "rust", "repo": "m-rots/bernard-rs", "path": "/src/model/path.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darshimo/copl path: /src/evalml3.rs (Debug)] enum Rule { EInt, EBool, EVar1, EVar2(Derivation), EIfT(Derivation, Derivation), EIfF(Derivation, Derivation), EPlus(Derivation, Derivation, Derivation), EMinus(Derivation, Derivation, Derivation), ETimes(Derivation...
code_fim
hard
{ "lang": "rust", "repo": "darshimo/copl", "path": "/src/evalml3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let i0 = get_num(&v0)?; let i1 = get_num(&v1)?; let n0 = NUM::new(&i0.to_string()); let n1 = NUM::new(&i1.to_string()); let (d2, n) = derive_plus(&n0, &n1)?; (Rule::EPlus(d0, d1, d2), Value::Value0(Box::new(n))) } G...
code_fim
hard
{ "lang": "rust", "repo": "darshimo/copl", "path": "/src/evalml3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn eval_envlist(el: &EnvList, x: &VAR) -> io::Result<(Derivation, Value)> { let (rule, v) = match el { EnvList::EnvList0(el_, _, y, _, v) => { if x == y.deref() { (Rule::EVar1, v.deref().clone()) } else { let (d_, v_) = eval_envlist(el_, ...
code_fim
hard
{ "lang": "rust", "repo": "darshimo/copl", "path": "/src/evalml3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("listing all areas (names)..."); let area_names = api.list_areas().await.expect("query failed."); println!("{:?}", area_names); // println!("Getting all the categories..."); // let categories = api.get_categories().await.expect("query failed!"); // categories.iter().for_e...
code_fim
hard
{ "lang": "rust", "repo": "theunkn0wn1/themealdb-rs", "path": "/examples/basic_usage.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // println!("Getting all ingredients..."); // let ingredients = api.list_ingreedients().await.expect("query failed!"); // for x in ingredients { // println!( // "name :: {:?}\tid:: {}\ttype ::{:?}", // x.name, x.id, x.ingredient_type // ); // } ...
code_fim
hard
{ "lang": "rust", "repo": "theunkn0wn1/themealdb-rs", "path": "/examples/basic_usage.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theunkn0wn1/themealdb-rs path: /examples/basic_usage.rs use mealdb::prelude::*; #[tokio::main] pub async fn main() { println!("hello, world!"); // Create handle to the API let api = mealdb::V1::new("https://www.themealdb.com", "1"); // Searching for meals that contain a keywor...
code_fim
hard
{ "lang": "rust", "repo": "theunkn0wn1/themealdb-rs", "path": "/examples/basic_usage.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: desmonty/game_test_03 path: /src/Axis.rs use std::slice::Iter; /* Idea enum. Used to know which room we are going to see. */ pub const NUM_IDEAS: usize = 5; #[derive(Debug)] pub enum Idea { Deny, Rage, Negociation, Depression, Acceptation, } <|fim_suffix|>/* EmotionalContext enum. Use...
code_fim
hard
{ "lang": "rust", "repo": "desmonty/game_test_03", "path": "/src/Axis.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* EmotionalContext enum. Used to know in each kind of mindset we should see the room. This can be seen as a filter. */ #[derive(Debug)] pub enum EmotionalContext { Reality, Love, Logic, }<|fim_prefix|>// repo: desmonty/game_test_03 path: /src/Axis.rs use std::slice::Iter; /* Idea enum. Used to...
code_fim
hard
{ "lang": "rust", "repo": "desmonty/game_test_03", "path": "/src/Axis.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (_, info, response) = will_success( &mut deps, "Actor".to_string(), Uint128::new(1000), ); assert_eq!(response.messages, vec![ SubMsg::new(CosmosMsg::Bank(BankMsg::Burn { amount: vec![coin(1000, "uluna")], })), ]); let execution ...
code_fim
medium
{ "lang": "rust", "repo": "valkyrieprotocol/qualifier-sample", "path": "/src/tests/execute.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: valkyrieprotocol/qualifier-sample path: /src/tests/execute.rs use cosmwasm_std::{coin, Env, MessageInfo, Response, Uint128, SubMsg, CosmosMsg, BankMsg}; use cosmwasm_std::testing::{mock_env, mock_info}; use crate::executions::{ExecuteResult, execute}; use crate::tests::mock_querier::{custom_dep...
code_fim
medium
{ "lang": "rust", "repo": "valkyrieprotocol/qualifier-sample", "path": "/src/tests/execute.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nephele-rs/nephele path: /nephele/src/common/tls/connector.rs use std::fmt; use std::marker::Unpin; use native_tls::Error; use crate::common::tls::handshake::handshake; use crate::common::tls::runtime::{AsyncRead, AsyncWrite}; use crate::common::tls::TlsStream; #[derive(Clone)] pub(crate) str...
code_fim
hard
{ "lang": "rust", "repo": "nephele-rs/nephele", "path": "/nephele/src/common/tls/connector.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<native_tls::TlsConnector> for TlsConnector { fn from(inner: native_tls::TlsConnector) -> TlsConnector { TlsConnector(inner) } }<|fim_prefix|>// repo: nephele-rs/nephele path: /nephele/src/common/tls/connector.rs use std::fmt; use std::marker::Unpin; use native_tls::Error; use ...
code_fim
medium
{ "lang": "rust", "repo": "nephele-rs/nephele", "path": "/nephele/src/common/tls/connector.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnuvince/minilang-rs path: /src/cgen.rs use ast::*; use types::Type; use typecheck::{Symtable, Exprtable}; pub struct Generator<'a> { tmp_counter: i32, symtable: &'a Symtable, exprtable: &'a Exprtable, } pub fn codegen(program: &Program, symtable: &Symtable, exprtable: &Exprtable) ...
code_fim
hard
{ "lang": "rust", "repo": "gnuvince/minilang-rs", "path": "/src/cgen.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn codegen_decls(&mut self) { for (id, ty) in self.symtable { match *ty { Type::Int => { println!("int {};", id); } Type::Float => { println!("float {};", id); } } } } fn codegen_stmts(&mut self, stmts: &[Stmt]) { ...
code_fim
hard
{ "lang": "rust", "repo": "gnuvince/minilang-rs", "path": "/src/cgen.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.tmp_counter += 1; let tmp = format!("tmp_{}", self.tmp_counter); tmp.to_string() } fn codegen_expr(&mut self, expr: &Expr) -> String { let tmp = self.new_tmp(); let ty_str = match self.exprtable.get(expr) { Some(&Type::Int) => "int", ...
code_fim
hard
{ "lang": "rust", "repo": "gnuvince/minilang-rs", "path": "/src/cgen.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sile/erl_dist path: /src/message.rs Self::OP, self.from_pid, self.to_pid, self.trace_token, self.reason, )?; Ok(()) } fn read_from<R: Read>(_reader: &mut R, ctrl_msg: Tuple) -> Result<Self, DecodeError> { let (...
code_fim
hard
{ "lang": "rust", "repo": "sile/erl_dist", "path": "/src/message.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sile/erl_dist path: /src/message.rs ()?; Ok(Self { from_pid, to_pid, message, }) } } /// [`SendSender`] with a trace token. #[derive(Debug, Clone, PartialEq)] #[allow(missing_docs)] pub struct SendSenderTt { pub from_pid: Pid, pub ...
code_fim
hard
{ "lang": "rust", "repo": "sile/erl_dist", "path": "/src/message.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Makes a [`RegSendTt`] message. pub fn reg_send_tt(from_pid: Pid, to_name: Atom, message: Term, trace_token: Term) -> Self { Self::RegSendTt(RegSendTt { from_pid, to_name, trace_token, message, }) } /// Makes a [`Exit2Tt`]...
code_fim
hard
{ "lang": "rust", "repo": "sile/erl_dist", "path": "/src/message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HectorPulido/wasm-conways-game-of-life path: /source/src/lib.rs use std::fmt; use wasm_bindgen::prelude::*; #[wasm_bindgen] #[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Cell { Dead = 0, Alive = 1, } #[wasm_bindgen] pub struct Universe { width: u32, height: ...
code_fim
hard
{ "lang": "rust", "repo": "HectorPulido/wasm-conways-game-of-life", "path": "/source/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn part_one_example() { assert_eq!(String::from("foo"), part_one("foobar")); } #[test] fn part_two_example() { assert_eq!(String::from("bar"), part_two("foobar")); }<|fim_prefix|>// repo: logansquirel/advent_of_code path: /aoc_yyyy/day_dd/src/lib.rs pub fn part_one(input: &str) -> String...
code_fim
medium
{ "lang": "rust", "repo": "logansquirel/advent_of_code", "path": "/aoc_yyyy/day_dd/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(String::from("foo"), part_one("foobar")); } #[test] fn part_two_example() { assert_eq!(String::from("bar"), part_two("foobar")); }<|fim_prefix|>// repo: logansquirel/advent_of_code path: /aoc_yyyy/day_dd/src/lib.rs pub fn part_one(input: &str) -> String { String::from(input[..3].t...
code_fim
medium
{ "lang": "rust", "repo": "logansquirel/advent_of_code", "path": "/aoc_yyyy/day_dd/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: logansquirel/advent_of_code path: /aoc_yyyy/day_dd/src/lib.rs pub fn part_one(input: &str) -> String { String::from(input[..3].trim()) } <|fim_suffix|>#[test] fn part_one_example() { assert_eq!(String::from("foo"), part_one("foobar")); } #[test] fn part_two_example() { assert_eq!(S...
code_fim
medium
{ "lang": "rust", "repo": "logansquirel/advent_of_code", "path": "/aoc_yyyy/day_dd/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DiveFish/ambiguity-stats path: /src/io.rs extern crate conllx; use conllx::{ReadSentence, Reader, Token, Sentence}; use flate2::read::GzDecoder; use std::collections::HashMap; use std::fs::OpenOptions; use std::fs::{self, File}; use std::io::{self, BufRead, BufReader, Write}; use std::path::Pat...
code_fim
hard
{ "lang": "rust", "repo": "DiveFish/ambiguity-stats", "path": "/src/io.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn bigram_pmi_to_dpar_pmis( input_dir: &Path, output_filename: &str, file_ending: &str, ) -> io::Result<()> { if fs::metadata(&output_filename).is_ok() { println!("Appending to file ({})", output_filename); let mut file = OpenOptions::new() .append(true) ...
code_fim
hard
{ "lang": "rust", "repo": "DiveFish/ambiguity-stats", "path": "/src/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_wrap_unwrap() { let kek = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F]; let to_wrap = [0x00, 0x11, 0...
code_fim
hard
{ "lang": "rust", "repo": "coyotebush/rust-openssl", "path": "/src/crypto/aes.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coyotebush/rust-openssl path: /src/crypto/aes.rs use ffi; #[repr(C)] struct AesKey { rd_key: [u32,..60], rounds: i32, } impl AesKey { fn new() -> AesKey { AesKey{rd_key: [0u32,..60], rounds: 0} } } pub fn wrap(kek: &[u8], to_wrap: &[u8]) -> Vec<u8> { unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "coyotebush/rust-openssl", "path": "/src/crypto/aes.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aleph-naught2tog/rust-wasm-experiments path: /src/dom.rs use wasm_bindgen::JsCast; pub struct Dom { document: web_sys::Document, } impl Dom { pub fn find() -> Self { let window = web_sys::window().expect("no global `window` exists"); let document = window.document().exp...
code_fim
hard
{ "lang": "rust", "repo": "aleph-naught2tog/rust-wasm-experiments", "path": "/src/dom.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn create_element_wrap(&self, element_type: &str) -> web_sys::Element { self.document .create_element(element_type) .unwrap_or_else(|_| { let message = format!("error creating {}", element_type); panic!(message) }) } }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "aleph-naught2tog/rust-wasm-experiments", "path": "/src/dom.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: google/google-ctf path: /2021/quals/pwn-memsafety/challenge/noflag.rs /* Copyright 2021 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at ht...
code_fim
hard
{ "lang": "rust", "repo": "google/google-ctf", "path": "/2021/quals/pwn-memsafety/challenge/noflag.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|>#[sandbox] pub mod user { static FLAG: &'static str = "CTF{fake flag}"; use prelude::{mem::ManuallyDrop, Service, Box, String}; pub struct State(ManuallyDrop<String>); impl State { pub fn new() -> Box<dyn Service> { Box::new(State(ManuallyDrop::new(String::from(FLAG))))...
code_fim
hard
{ "lang": "rust", "repo": "google/google-ctf", "path": "/2021/quals/pwn-memsafety/challenge/noflag.rs", "mode": "spm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bowser1704/image-service path: /rafs/src/metadata/layout.rs E as u32), s_block_size: u32::to_le(RAFS_DEFAULT_BLOCK_SIZE as u32), s_flags: u64::to_le(0), s_inodes_count: u64::to_le(0), s_inode_table_entries: u32::to_le(0), s_inode_table_...
code_fim
hard
{ "lang": "rust", "repo": "Bowser1704/image-service", "path": "/rafs/src/metadata/layout.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bowser1704/image-service path: /rafs/src/metadata/layout.rs Writer) -> Result<usize> { w.write_all(self.as_ref())?; Ok(self.as_ref().len()) } } impl_bootstrap_converter!(OndiskSuperBlock); impl fmt::Display for OndiskSuperBlock { fn fmt(&self, f: &mut fmt::Formatter<'_>...
code_fim
hard
{ "lang": "rust", "repo": "Bowser1704/image-service", "path": "/rafs/src/metadata/layout.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn pointer_offset(former_ptr: *const u8, later_ptr: *const u8) -> usize { // Rust provides unsafe method `offset_from` from 1.47.0 // Hopefully, we can adopt it someday. For now, for compatibility, use blow trick. later_ptr as usize - former_ptr as usize } // TODO: FIXME: This is not a well d...
code_fim
hard
{ "lang": "rust", "repo": "Bowser1704/image-service", "path": "/rafs/src/metadata/layout.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgraef/murmur3 path: /src/state/x64_128.rs use std::convert::{ TryFrom, TryInto, }; use crate::{ seed::Seedable, state::State, }; fn fmix64(mut k: u64) -> u64 { k ^= k >> 33; k = k.wrapping_mul(0xff51afd7ed558ccd); k ^= k >> 33; k = k.wrapping_mul(0xc4ceb9fe1a85...
code_fim
hard
{ "lang": "rust", "repo": "jgraef/murmur3", "path": "/src/state/x64_128.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_hashes_empty() { let data = b""; let expected_hash = murmur3::murmur3_x64_128(&mut Cursor::new(&data), 69).unwrap(); let h = State64x128::from_seed(69); assert_eq!(h.finish(), expected_hash); } #[test] fn it_hashes_a_tail() { let...
code_fim
hard
{ "lang": "rust", "repo": "jgraef/murmur3", "path": "/src/state/x64_128.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nucle0tides/crab-shell path: /src/main.rs use std::io::{self, Write}; use std::process; use std::env; extern crate colored; use colored::*; const HOSTNAME: &str = "gabby@cosmonaut"; fn main() { println!("In the beginning there was darkness."); loop { print!("{}:~{}{} ", HOSTN...
code_fim
hard
{ "lang": "rust", "repo": "nucle0tides/crab-shell", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> command.pop(); if command.is_empty() { continue } let tokens: Vec<_> = command.split_whitespace().map(String::from).collect(); for token in &tokens { if *token == "exit" { process::exit(0); } } p...
code_fim
hard
{ "lang": "rust", "repo": "nucle0tides/crab-shell", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Anything that represents a 3D point. pub trait Point<F: Float> { /// Returns a reference to the point. fn point(&self) -> &Point3<F>; } impl<F: Float> Point<F> for Point3<F> { fn point(&self) -> &Point3<F> { self } }<|fim_prefix|>// repo: lars-frogner/Impact path: /src/geomet...
code_fim
hard
{ "lang": "rust", "repo": "lars-frogner/Impact", "path": "/src/geometry.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lars-frogner/Impact path: /src/geometry.rs //! Geometrical objects. mod angle; mod axis_aligned_box; mod bounds; mod camera; mod frustum; mod instance; mod mesh; mod oriented_box; mod plane; mod projection; mod sphere; mod texture_projection; mod tracking; mod uniform; <|fim_suffix|>use crate:...
code_fim
hard
{ "lang": "rust", "repo": "lars-frogner/Impact", "path": "/src/geometry.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laopo001/leetcode-rust path: /src/convert_a_number_to_hexadecimal/mod.rs struct Solution; use std::collections::HashMap; use std::ops::{Div, Rem, Sub}; fn num_to_vec<T>(n: T, d: T) -> Vec<T> where T: Div<Output=T> + Rem<Output=T> + Copy + Sub<Output=T> + std::cmp::PartialEq + From<i32> {...
code_fim
hard
{ "lang": "rust", "repo": "laopo001/leetcode-rust", "path": "/src/convert_a_number_to_hexadecimal/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>; map.insert(10, "a"); map.insert(11, "b"); map.insert(12, "c"); map.insert(13, "d"); map.insert(14, "e"); map.insert(15, "f"); let arr = num_to_vec(num, 16); // println!("{:?}", arr); let mut res = "".to_string(); for i in arr { res += map.get(&i).unwrap(); } return...
code_fim
hard
{ "lang": "rust", "repo": "laopo001/leetcode-rust", "path": "/src/convert_a_number_to_hexadecimal/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.reader = Some(res.fetch_mut::<OnTimerEvent>().register_reader()); Self::SystemData::setup(res); } fn run(&mut self, (data, mut pingdata): Self::SystemData) { let clock = (Instant::now() - data.starttime.0).to_clock(); for evt in data.channel.read(self.reader.as_mut().unwrap()) { if ev...
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/mighty-server", "path": "/server/src/handlers/ping.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> data.conns.send_to_player( ent, OwnedMessage::Binary( to_bytes(&ServerPacket::Ping(ServerPing { clock, num: ping.idx, })).unwrap(), ), ) }); } } } use dispatch::SystemInfo; use handlers::OnCloseHandler; use systems::TimerHandler; impl Syst...
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/mighty-server", "path": "/server/src/handlers/ping.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Phantomical/mighty-server path: /server/src/handlers/ping.rs use specs::*; use types::*; use std::time::Instant; use consts::timer::PING_DISPATCH; use protocol::server::Ping as ServerPing; use protocol::{to_bytes, ServerPacket}; use OwnedMessage; use component::channel::{OnTimerEvent, OnTime...
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/mighty-server", "path": "/server/src/handlers/ping.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/core_detect path: /tests/compare_std.rs #[test] #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] fn compare_with_std() { macro_rules! check_feature { ($feature:tt) => { if cfg!(allow_false_negative) { if core_detect::is_x86_feature_detected...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/core_detect", "path": "/tests/compare_std.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>); check_feature!("sse4a"); check_feature!("sha"); check_feature!("avx"); check_feature!("avx2"); check_feature!("avx512f"); check_feature!("avx512cd"); check_feature!("avx512er"); check_feature!("avx512pf"); check_feature!("avx512bw"); check_feature!("avx512dq"); ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/core_detect", "path": "/tests/compare_std.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn setup(world: &mut World) { world.register::<Position>(); world.register::<Velocity>(); world.register::<Scale>(); world.register::<Rotation>(); world.register::<Model>(); world.register::<UvMesh>(); world.register::<Camera>(); world.register::<FirstPersonController>(...
code_fim
medium
{ "lang": "rust", "repo": "Blugatroff/clone2", "path": "/src/setup/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Blugatroff/clone2 path: /src/setup/mod.rs mod setup_cross_hair; mod setup_highlight_cube; mod setup_player; use crate::{ chunk::{Chunk, CHUNK_SIZE}, components::LookedAt, resources::SoundPlayer, }; use crate::{chunk_map::ChunkMap, components::*}; use crate::{ components::BlockHi...
code_fim
medium
{ "lang": "rust", "repo": "Blugatroff/clone2", "path": "/src/setup/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tuanemuy/cartta path: /src/web/controllers/mod.rs pub mod app_controller; pub mod user_controller; pub mod session_controller; pub mod note_controller; pub mod tag_controller; <|fim_suffix|> let conn = request.guard::<DbConn>()?; let user_id = request.cookies() ...
code_fim
hard
{ "lang": "rust", "repo": "tuanemuy/cartta", "path": "/src/web/controllers/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let conn = request.guard::<DbConn>()?; let user_id = request.cookies() .get_private("user_id") .and_then(|cookie| cookie.value().parse().ok()); let user = match user_id { Some(user_id) => get_user(&user_id, &conn).ok(), No...
code_fim
hard
{ "lang": "rust", "repo": "tuanemuy/cartta", "path": "/src/web/controllers/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, 'r> FromRequest<'a, 'r> for User { type Error = (); fn from_request(request: &'a Request<'r>) -> request::Outcome<User, ()> { let conn = request.guard::<DbConn>()?; let user_id = request.cookies() .get_private("user_id") .and_then(|cook...
code_fim
medium
{ "lang": "rust", "repo": "tuanemuy/cartta", "path": "/src/web/controllers/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn update(id: ObjectId, sessions: Session, connection: &Conn) -> Result<Session, Error> { let mut new_session = sessions.clone(); new_session.id = Some(id.clone()); match bson::to_bson(&new_session) { Ok(model_bson) => match model_bson { bson::Bson::Document(model_doc) ...
code_fim
hard
{ "lang": "rust", "repo": "AstrubTools/bot-dofus-orchestrator", "path": "/src/sessions/repository.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn insert(sessions: Session, connection: &Conn) -> Result<Session, Error> { let insertable = InsertableSession::from_session(sessions.clone()); match bson::to_bson(&insertable) { Ok(model_bson) => match model_bson { bson::Bson::Document(model_doc) => { match...
code_fim
hard
{ "lang": "rust", "repo": "AstrubTools/bot-dofus-orchestrator", "path": "/src/sessions/repository.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AstrubTools/bot-dofus-orchestrator path: /src/sessions/repository.rs #![allow(proc_macro_derive_resolution_fallback)] use crate::mongo_connection::Conn; use crate::sessions::{InsertableSession, Session}; use crate::r2d2_mongodb::mongodb::db::ThreadedDatabase; use mongodb::{bson, coll::results::D...
code_fim
hard
{ "lang": "rust", "repo": "AstrubTools/bot-dofus-orchestrator", "path": "/src/sessions/repository.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct Mouse { pub multiplier: f64, pub left_button_state: ElementState, pub middle_button_state: ElementState, pub right_button_state: ElementState, pub last_click_timestamp: Instant, pub last_click_button: MouseButton, pub click_state: ClickState, pub...
code_fim
medium
{ "lang": "rust", "repo": "raphamorim/rio", "path": "/rio/src/screen/mouse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for Mouse { fn default() -> Mouse { Mouse { multiplier: 3.0, last_click_timestamp: Instant::now(), last_click_button: MouseButton::Left, left_button_state: ElementState::Released, middle_button_state: ElementState::Releas...
code_fim
hard
{ "lang": "rust", "repo": "raphamorim/rio", "path": "/rio/src/screen/mouse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raphamorim/rio path: /rio/src/screen/mouse.rs use crate::crosswords::pos::Side; use crate::event::ClickState; use std::time::Instant; use winit::event::ElementState; use winit::event::MouseButton; #[derive(Default, Debug)] pub struct AccumulatedScroll { /// Scroll we should perform along `x...
code_fim
hard
{ "lang": "rust", "repo": "raphamorim/rio", "path": "/rio/src/screen/mouse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }