text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let now: DateTime<Local> = Local::now(); println!("{}", now.format("%Y/%m/%d %H:%M:%S")) }<|fim_prefix|>// repo: hikarine3/programming_language_comparison path: /examples/time/date_time/date_time.rs extern crate chrono; use chrono::{Local, DateTime}; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "hikarine3/programming_language_comparison", "path": "/examples/time/date_time/date_time.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spacejam/async-std path: /src/fs/set_permissions.rs use std::fs; use std::path::Path; use crate::io; use crate::task::blocking; /// Changes the permissions on a file or directory. /// /// This function is an async version of [`std::fs::set_permissions`]. /// /// [`std::fs::set_permissions`]: h...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/async-std", "path": "/src/fs/set_permissions.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>, perm).await?; /// # /// # Ok(()) }) } /// ``` pub async fn set_permissions<P: AsRef<Path>>(path: P, perm: fs::Permissions) -> io::Result<()> { let path = path.as_ref().to_owned(); blocking::spawn(async move { fs::set_permissions(path, perm) }).await }<|fim_prefix|>// repo: spacejam/async-std pa...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/async-std", "path": "/src/fs/set_permissions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Auxnon/interval-five path: /src/ogmain.rs // C Vertex { position: [0.35966998, -0.3473291, 0.0], color: [0.5, 0.0, 0.5], }, // D Vertex { position: [0.44147372, 0.2347359, 0.0], color: [0.5, 0.0, 0.5], }, // E ]; const INDICES: &[u16] = &[0, 1, 4,...
code_fim
hard
{ "lang": "rust", "repo": "Auxnon/interval-five", "path": "/src/ogmain.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> public static MouseSelector mouseSelector; public static float Wx=-32f; public static float Wy=-32f; public static float Wz=0f; public static float panSpeed=0f; public static Player player; public static Player reservePlayer; public static World world; static int timer=0; static boolean escapeLo...
code_fim
hard
{ "lang": "rust", "repo": "Auxnon/interval-five", "path": "/src/ogmain.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Auxnon/interval-five path: /src/ogmain.rs device: wgpu::Device, queue: wgpu::Queue, sc_desc: wgpu::SwapChainDescriptor, swap_chain: wgpu::SwapChain, size: winit::dpi::PhysicalSize<u32>, render_pipeline: wgpu::RenderPipeline, // NEW! vertex_buffer: wgpu::Buffer, ...
code_fim
hard
{ "lang": "rust", "repo": "Auxnon/interval-five", "path": "/src/ogmain.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn opendir(&self, _req: RequestInfo, path: &Path, flags: u32) -> ResultOpen { Ok(( (*self.file_handles.lock().unwrap()) .get_mut() .new_handle(self.get_data(path, None)?, flags), 0, )) } fn readdir(&self, _req: RequestInf...
code_fim
hard
{ "lang": "rust", "repo": "ashkitten/confuse", "path": "/src/fs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ashkitten/confuse path: /src/fs.rs use crate::{data::ConfuseData, file_handle::FileHandleMap}; use fuse_mt::{ DirectoryEntry, FileAttr, FileType, FilesystemMT, RequestInfo, ResultEmpty, ResultEntry, ResultOpen, ResultReaddir, }; use inotify::{Inotify, WatchMask}; use libc::c_int; use log...
code_fim
hard
{ "lang": "rust", "repo": "ashkitten/confuse", "path": "/src/fs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>e, Deserialize, Debug)] pub struct EchoMsg { pub payload: String, pub ts: DateTime<Utc>, }<|fim_prefix|>// repo: hydro-project/hydroflow path: /hydroflow/examples/echoserver/protocol.rs use chrono::prelude::*; use serde::{Deserialize,<|fim_middle|> Serialize}; #[derive(PartialEq, Clone, Serializ
code_fim
easy
{ "lang": "rust", "repo": "hydro-project/hydroflow", "path": "/hydroflow/examples/echoserver/protocol.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hydro-project/hydroflow path: /hydroflow/examples/echoserver/protocol.rs use chrono::prelude::*; use serde::{Deserialize,<|fim_suffix|>pub payload: String, pub ts: DateTime<Utc>, }<|fim_middle|> Serialize}; #[derive(PartialEq, Clone, Serialize, Deserialize, Debug)] pub struct EchoMsg {
code_fim
medium
{ "lang": "rust", "repo": "hydro-project/hydroflow", "path": "/hydroflow/examples/echoserver/protocol.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub payload: String, pub ts: DateTime<Utc>, }<|fim_prefix|>// repo: hydro-project/hydroflow path: /hydroflow/examples/echoserver/protocol.rs use chrono::prelude::*; use serde::{Deserialize,<|fim_middle|> Serialize}; #[derive(PartialEq, Clone, Serialize, Deserialize, Debug)] pub struct EchoMsg {
code_fim
medium
{ "lang": "rust", "repo": "hydro-project/hydroflow", "path": "/hydroflow/examples/echoserver/protocol.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> gdt }; } lazy_static! { static ref IDT: idt::Idt = { let mut idt = idt::Idt::new(); // Exceptions idt.set_handler(0, divide_by_zero_wrapper as u64); idt.set_handler(1, debug_wrapper as u64); idt.set_handler(3, breakpoint_wrapper as u64); idt....
code_fim
hard
{ "lang": "rust", "repo": "sjy-dv/mini_rust_os_kernel", "path": "/kernel/arch/x86_64/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sjy-dv/mini_rust_os_kernel path: /kernel/arch/x86_64/mod.rs #[macro_use] pub mod idt; pub mod int; pub mod gdt; pub mod mem; extern "C" { // Default handlers fn isr_default(); fn isr_default_err(); // Exceptions fn divide_by_zero_wrapper(); fn debug_wrapper(); f...
code_fim
hard
{ "lang": "rust", "repo": "sjy-dv/mini_rust_os_kernel", "path": "/kernel/arch/x86_64/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lazy_static! { static ref IDT: idt::Idt = { let mut idt = idt::Idt::new(); // Exceptions idt.set_handler(0, divide_by_zero_wrapper as u64); idt.set_handler(1, debug_wrapper as u64); idt.set_handler(3, breakpoint_wrapper as u64); idt.set_handler(4, overflo...
code_fim
hard
{ "lang": "rust", "repo": "sjy-dv/mini_rust_os_kernel", "path": "/kernel/arch/x86_64/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Non-integers. for &(name, age) in &[("Mike", "!"), ("Michael", "hi"), ("A", "blah"), ("a", "0-1")] { test(&format!("/hello/{}/{}", name, age), format!("Hi {}! Your age ({}) is kind of funky.", name, age)); } }<|fim_prefix|>// repo: wonism/Rocket path: /examples/hello_ra...
code_fim
hard
{ "lang": "rust", "repo": "wonism/Rocket", "path": "/examples/hello_ranks/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wonism/Rocket path: /examples/hello_ranks/src/tests.rs use super::rocket; use rocket::testing::MockRequest; use rocket::http::Method::*; fn test(uri: &str, expected: String) { let rocket = rocket::ignite().mount("/", routes![super::hello, super::hi]); let mut req = MockRequest::new(Get,...
code_fim
hard
{ "lang": "rust", "repo": "wonism/Rocket", "path": "/examples/hello_ranks/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_failing_hello_hi() { // Invalid integers. for &(name, age) in &[("Mike", 1000), ("Michael", 128), ("A", -800), ("a", -200)] { test(&format!("/hello/{}/{}", name, age), format!("Hi {}! Your age ({}) is kind of funky.", name, age)); } // Non-integers. ...
code_fim
hard
{ "lang": "rust", "repo": "wonism/Rocket", "path": "/examples/hello_ranks/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(value, 5); } #[test] fn succeeds_with_maximum_retries() { let mut collection = vec![1, 2].into_iter(); let value = retry(NoDelay.take(1), || match collection.next() { Some(n) if n == 2 => Ok(n), Some(_) => Err("not 2"), N...
code_fim
hard
{ "lang": "rust", "repo": "rbtcollins/retry", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rbtcollins/retry path: /src/lib.rs //! Crate `retry` provides utilities for retrying operations that can fail. //! //! # Usage //! //! Retry an operation using the `retry` function. `retry` accepts an iterator //! over `Duration`s and a closure that returns a `retry::OperationResult`. The //! it...
code_fim
hard
{ "lang": "rust", "repo": "rbtcollins/retry", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: awelkie/rustfst path: /rustfst/src/tests_openfst/algorithms/encode.rs use std::fmt::Display; use anyhow::{format_err, Result, Context}; use pretty_assertions::assert_eq; use serde_derive::{Deserialize, Serialize}; use crate::algorithms::{decode, encode}; use crate::fst_properties::FstPropertie...
code_fim
hard
{ "lang": "rust", "repo": "awelkie/rustfst", "path": "/rustfst/src/tests_openfst/algorithms/encode.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn test_encode<F>(test_data: &FstTestData<F>) -> Result<()> where F: SerializableFst + MutableFst + Display, F::W: SerializableSemiring, { for encode_test_data in &test_data.encode { let mut fst_encoded = test_data.raw.clone(); encode(&mut fst_encoded, encode_test_data.enco...
code_fim
hard
{ "lang": "rust", "repo": "awelkie/rustfst", "path": "/rustfst/src/tests_openfst/algorithms/encode.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn test_encode_decode<F>(test_data: &FstTestData<F>) -> Result<()> where F: SerializableFst + MutableFst + Display, F::W: SerializableSemiring, { for encode_test_data in &test_data.encode_decode { let mut fst_encoded = test_data.raw.clone(); let encode_table = encode(&mut f...
code_fim
hard
{ "lang": "rust", "repo": "awelkie/rustfst", "path": "/rustfst/src/tests_openfst/algorithms/encode.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twmb/rsfs path: /src/mem/test/unix.rs .as_mut() .map(|f| f(InFile::ReadAt(self, buf, offset))) { sz = cmp::min(r?, buf.len()); } (&self.inner).read_at(&mut buf[..sz], offset) } fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize> { ...
code_fim
hard
{ "lang": "rust", "repo": "twmb/rsfs", "path": "/src/mem/test/unix.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Debug for FS { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FS {{ inner: {:?} }}", &self.inner) } } impl FS { /// Creates an empty `FS` with mode `0o777`. pub fn new() -> FS { Self::with_mode(0o777) } /// Creates an empty `FS` with t...
code_fim
hard
{ "lang": "rust", "repo": "twmb/rsfs", "path": "/src/mem/test/unix.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.inner.mode(mode); self } fn custom_flags(&mut self, flags: i32) -> &mut Self { self.inner.custom_flags(flags); self } } /// Iterator over entries in a directory. /// /// This struct wraps [`mem::ReadDir`] with the addition that `.next()` can potentially consume /// [`test...
code_fim
hard
{ "lang": "rust", "repo": "twmb/rsfs", "path": "/src/mem/test/unix.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns a localized `timeago::Formatter`. /// If user has chosen a language whic his not supported by `timeago` we fallback to english. pub fn localized_timeago_formatter() -> timeago::Formatter<Box<dyn timeago::Language>> { let lang = LANG.get().expect("LANG not set").read().unwrap(); let iso...
code_fim
hard
{ "lang": "rust", "repo": "bing050802/ajour", "path": "/src/localization.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bing050802/ajour path: /src/localization.rs use json_gettext::{get_text, static_json_gettext_build, JSONGetText}; use once_cell::sync::{Lazy, OnceCell}; use std::sync::RwLock; pub static LOCALIZATION_CTX: Lazy<JSONGetText<'static>> = Lazy::new(|| { static_json_gettext_build!( "en_U...
code_fim
hard
{ "lang": "rust", "repo": "bing050802/ajour", "path": "/src/localization.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // this step might fail if timeago does not support the chosen language. // In that case we fallback to `en_US`. if let Some(timeago_lang) = timeago::from_isolang(isolang) { timeago::Formatter::with_language(timeago_lang) } else { timeago::Formatter::with_language(Box::new(...
code_fim
hard
{ "lang": "rust", "repo": "bing050802/ajour", "path": "/src/localization.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.into_result_lock().1 } fn into_result_lock(self) -> (MutexGuard<'a, Data<T>>, Result<Option<T>, ()>) { (self.lock, match self.kind { RecvOpKind::Ok(val) => Ok(Some(val)), RecvOpKind::WouldBlock => Err(()), RecvOpKind:...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/chan", "path": "/src/lib.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/chan path: /src/lib.rs s impossible for the channel to close because the internal reference count will never reach `0`. # Warning: performance The primary purpose of this crate is to provide a safe, concurrent abstraction. Notably, it is *not* a zero-cost abstraction. It is not eve...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/chan", "path": "/src/lib.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/chan path: /src/lib.rs fn main() { let (sdone, rdone) = chan::sync(0); thread::spawn(move || do_work(sdone)); // block until work is done, and then quit the program. rdone.recv(); } ``` We no longer need to explicitly do anything with the `_done` channel. We give `do_...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/chan", "path": "/src/lib.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let (metadata_key, metadata_bump_seed) = Pubkey::find_program_address(metadata_seeds, program_id); let metadata_authority_signer_seeds = &[ PREFIX.as_bytes(), program_id.as_ref(), mint_info.key.as_ref(), &[metadata_bump_seed], ]; if metadata_account_info.key != &metadata_key { ...
code_fim
hard
{ "lang": "rust", "repo": "tomoima525/solana-sandbox", "path": "/rust/token-metadata/program/src/logic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tomoima525/solana-sandbox path: /rust/token-metadata/program/src/logic.rs use { crate::{ error::MetadataError, state::{ Data, Key, Metadata, EDITION, MAX_CREATOR_LIMIT, MAX_METADATA_LEN, MAX_NAME_LENGTH, MAX_SYMBOL_LENGTH, MAX_URI_LENGTH, PREFIX, }, }, arrayref::{ar...
code_fim
hard
{ "lang": "rust", "repo": "tomoima525/solana-sandbox", "path": "/rust/token-metadata/program/src/logic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gefjon/phoebe path: /src/types/error.rs use crate::prelude::*; use crate::stack::{ArgIndexError, StackOverflowError, StackUnderflowError}; use crate::symbol_lookup::UnboundSymbolError; use crate::types::conversions::ConversionError; use crate::types::pointer_tagging::{ObjectTag, PointerTag}; use...
code_fim
hard
{ "lang": "rust", "repo": "gefjon/phoebe", "path": "/src/types/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> EvaluatorError::StackUnderflow(e) } } impl convert::From<StackUnderflowError> for Error { fn from(e: StackUnderflowError) -> Self { let e = EvaluatorError::from(e); e.into() } } impl convert::From<StackUnderflowError> for GcRef<Error> { fn from(e: StackUnderflowEr...
code_fim
hard
{ "lang": "rust", "repo": "gefjon/phoebe", "path": "/src/types/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (icon_name, d) in FILES { std::process::Command::new("convert") .arg("-resize") .arg(format!("{d}x{d}")) .args(&[ "-background", "transparent", "-gravity", ...
code_fim
hard
{ "lang": "rust", "repo": "divvun/kbdgen", "path": "/src/build/macos/macos_bundle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: divvun/kbdgen path: /src/build/macos/macos_bundle.rs use std::{collections::HashMap, path::PathBuf}; use indexmap::IndexMap; use language_tags::LanguageTag; use serde::{Deserialize, Serialize}; use xmlem::{display::Config, display::EntityMode, Document}; const TOP_FOLDER: &str = "Contents"; co...
code_fim
hard
{ "lang": "rust", "repo": "divvun/kbdgen", "path": "/src/build/macos/macos_bundle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: servo/green-rs path: /libgreen/src/context.rs // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://...
code_fim
hard
{ "lang": "rust", "repo": "servo/green-rs", "path": "/libgreen/src/context.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Redefinitions from rt/arch/x86_64/regs.h static RUSTRT_RSP: uint = 1; static RUSTRT_IP: uint = 8; static RUSTRT_RBP: uint = 2; static RUSTRT_R12: uint = 4; static RUSTRT_R13: uint = 5; static RUSTRT_R14: uint = 6; static RUSTRT_R15: uint = 7; let sp = align_down(sp)...
code_fim
hard
{ "lang": "rust", "repo": "servo/green-rs", "path": "/libgreen/src/context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let sp = align_down(sp); let sp = mut_offset(sp, -1); // The final return address. 0 indicates the bottom of the stack unsafe { *sp = 0; } rtdebug!("creating call frame"); rtdebug!("fptr {:#x}", fptr as libc::uintptr_t); rtdebug!("arg {:#x}", arg); rtdebug!("sp {}", sp); ...
code_fim
hard
{ "lang": "rust", "repo": "servo/green-rs", "path": "/libgreen/src/context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn twostage_test(t_threads: usize, r_threads: usize) { let lock1 = Arc::new(Mutex::new(())); let lock2 = Arc::new(Mutex::new(())); let mut threads = vec![]; for i in 0..t_threads { let l1 = lock1.clone(); let l2 = lock2.clone(); threads.push(thread::spawn(move|| fun...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/crucible", "path": "/crux-mir/test/concurrency/sv-benchmarks/c/pthread/twostage.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaloisInc/crucible path: /crux-mir/test/concurrency/sv-benchmarks/c/pthread/twostage.rs extern crate crucible; use crucible::*; use std::thread; use std::sync::{Arc,Mutex,}; use std::sync::atomic::AtomicI32; use std::sync::atomic::Ordering::SeqCst; <|fim_suffix|>fn func_b(lock1: Arc<Mutex<()>...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/crucible", "path": "/crux-mir/test/concurrency/sv-benchmarks/c/pthread/twostage.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-command/tests/commands/error_make.rs use nu_test_support::nu; #[test] fn error_label_works() { let actual = nu!("error make {msg:foo label:{text:unseen}}"); assert!(actual.err.contains("unseen")); assert!(actual.err.contains("╰──")); } #[test] fn n...
code_fim
medium
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/tests/commands/error_make.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(!actual.err.contains("unseen")); } #[test] fn error_start_bigger_than_end_should_fail() { let actual = nu!("error make {msg: foo label: {text: bar start 456 end 123}}"); assert!(!actual.err.contains("invalid error format")); assert!(!actual .err .contains("`$.labe...
code_fim
medium
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/tests/commands/error_make.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let actual = nu!("error make {msg: foo label: {text: bar start 456 end 123}}"); assert!(!actual.err.contains("invalid error format")); assert!(!actual .err .contains("`$.label.start` should be smaller than `$.label.end`")); }<|fim_prefix|>// repo: nushell/nushell path: /crate...
code_fim
medium
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/tests/commands/error_make.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scnsh/benimator path: /tests/spec.rs #[macro_use] extern crate rstest; use std::time::Duration; use bevy::prelude::*; use bevy_core::CorePlugin; use benimator::*; #[rstest] fn repeated(mut app: App) { let entity = app .world .spawn() .insert_bundle(( T...
code_fim
hard
{ "lang": "rust", "repo": "scnsh/benimator", "path": "/tests/spec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> app.update(); assert!(app.world.get::<Play>(entity).is_some()); assert_eq!( app.world.get::<TextureAtlasSprite>(entity).unwrap().index, 2 ); app.update(); assert!(app.world.get::<Play>(entity).is_none()); assert_eq!( app.world.get::<TextureAtlasSprite>(...
code_fim
hard
{ "lang": "rust", "repo": "scnsh/benimator", "path": "/tests/spec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let entity = app .world .spawn() .insert_bundle(( TextureAtlasSprite::new(0), SpriteSheetAnimation::from_range(0..=2, Duration::from_nanos(0)).once(), Play, )) .id(); app.update(); assert!(app.world.get::<Play>(entity...
code_fim
hard
{ "lang": "rust", "repo": "scnsh/benimator", "path": "/tests/spec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>_dir_all(&dir)?; debug!("Ensuring fresh dir: {}", &dir.display()); Ok(()) }<|fim_prefix|>// repo: lalbuild/lal path: /src/core/ensure.rs use std::{fs, io, path::Path}; /// Ensure a directory exists and is empty pub fn<|fim_middle|> ensure_dir_exists_fresh(dir: &Path) -> io::Result<()> { if ...
code_fim
medium
{ "lang": "rust", "repo": "lalbuild/lal", "path": "/src/core/ensure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lalbuild/lal path: /src/core/ensure.rs use std::{fs, io, path::Path}; /// Ensure a directory exists and is empty pub fn<|fim_suffix|> // clean it out first fs::remove_dir_all(&dir)?; } fs::create_dir_all(&dir)?; debug!("Ensuring fresh dir: {}", &dir.display()); Ok((...
code_fim
medium
{ "lang": "rust", "repo": "lalbuild/lal", "path": "/src/core/ensure.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koji-m/criteox path: /src/main.rs use chrono::{DateTime, Duration, Utc}; use reqwest::StatusCode; use serde::{Deserialize, Serialize}; use std::env; use std::collections::HashMap; const AUTH_URL: &str = "https://api.criteo.com/oauth2/token"; const STATISTICS_URL: &str = "https://api.criteo.com...
code_fim
hard
{ "lang": "rust", "repo": "koji-m/criteox", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Content-Type", "application/x-www-form-urlencoded".parse().unwrap()); headers.insert("Accept", "application/json".parse().unwrap()); let mut payload = HashMap::new(); payload.insert("grant_type", "client_credentials"...
code_fim
hard
{ "lang": "rust", "repo": "koji-m/criteox", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/sfn/src/error_meta.rs eStateMachineForExecutionErrorKind::InvalidArn(inner) => { Error::InvalidArn(inner) } crate::error::DescribeStateMachineForExecutionErrorKind::Unhandled(inner) => { Error:...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/sfn/src/error_meta.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/sfn/src/error_meta.rs :error::CreateStateMachineErrorKind::InvalidLoggingConfiguration(inner) => { Error::InvalidLoggingConfiguration(inner) } crate::error::CreateStateMachineErrorKind::InvalidName(inner) => { ...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/sfn/src/error_meta.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// nist256 curve pub const CURVE_A: isize = -3; pub const CURVE_B:[Chunk;NLEN]=[0x7D2604B,0x1E71E1F1,0x14EC3D8E,0x1A0D6198,0x86BC651,0x1EAABB4C,0xF9ECFAE,0x1B154752,0x5AC635]; pub const CURVE_ORDER:[Chunk;NLEN]=[0x1C632551,0x1DCE5617,0x5E7A13C,0xDF55B4E,0x1FFFFBCE,0x1FFFFFFF,0x3FFFF,0x1FE00000,0xFFFFFF];...
code_fim
medium
{ "lang": "rust", "repo": "MRJCrunch/amcl", "path": "/version3/rust/rom_nist256_32.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MRJCrunch/amcl path: /version3/rust/rom_nist256_32.rs /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you...
code_fim
medium
{ "lang": "rust", "repo": "MRJCrunch/amcl", "path": "/version3/rust/rom_nist256_32.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn fill_console_output_character( cells_written: &mut u32, start_location: COORD, cells_to_write: u32, ) -> bool { let output_handle = get_output_handle(); unsafe { // fill the cells in console with blanks let success = FillConsoleOutputCharacterA( outpu...
code_fim
hard
{ "lang": "rust", "repo": "tkaden4/crossterm", "path": "/src/kernel/windows_kernel/kernel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tkaden4/crossterm path: /src/kernel/windows_kernel/kernel.rs //! This module is the core of all the `WINAPI` actions. All unsafe `WINAPI` function call are done here. use winapi::shared::minwindef::TRUE; use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode}; use winapi::um::handleapi::IN...
code_fim
hard
{ "lang": "rust", "repo": "tkaden4/crossterm", "path": "/src/kernel/windows_kernel/kernel.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: olsner/rust-core path: /core/lib.rs // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/...
code_fim
hard
{ "lang": "rust", "repo": "olsner/rust-core", "path": "/core/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod int; pub mod i8; pub mod i16; pub mod i32; pub mod i64; #[cfg(target_os="linux")] pub mod c_types; #[cfg(libc)] pub mod f32; #[cfg(libc)] pub mod f64; #[cfg(libc)] pub mod heap; #[cfg(libc)] pub mod heap_closure; #[cfg(libc)] pub mod os; pub fn ignore<T>(_: T) {} // FIXME: for deriving mod ...
code_fim
hard
{ "lang": "rust", "repo": "olsner/rust-core", "path": "/core/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/darling/examples/fallible_read.rs use darling::{FromDeriveInput, FromMeta}; use syn::parse_str; #[derive(Debug, FromDeriveInput)] #[darling(attributes(my_trait), and_then = "MyInputReceiver::autocorrect")] pub struct MyInputRece...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/darling/examples/fallible_read.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let amplitude = match amplitude { Ok(amp) => amp, Err(mi) => (i64::from_meta(&mi)?).unsigned_abs(), }; Ok(Self { name, frequency, amplitude: Ok(amplitude), }) } } fn main() { let input = r#"#[derive(MyTra...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/darling/examples/fallible_read.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let Self { name, frequency, amplitude, } = self; let amplitude = match amplitude { Ok(amp) => amp, Err(mi) => (i64::from_meta(&mi)?).unsigned_abs(), }; Ok(Self { name, ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/darling/examples/fallible_read.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn insert_artists(collection: &coll::Collection, artists: Vec<Artist>) -> Option<()> { let artists_len = artists.len(); let mut buffer_vec = Vec::new(); for (i, artist) in artists.iter().enumerate() { if let Ok(Bson::Document(document)) = to_bson(&artist) { buffer_vec.p...
code_fim
hard
{ "lang": "rust", "repo": "Yasu-umi/rust_nlp_100_examples", "path": "/src/mongo_utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yasu-umi/rust_nlp_100_examples path: /src/mongo_utils.rs extern crate mongodb; use ::bson::{Bson, to_bson, from_bson, ordered}; use self::mongodb::{Client, ThreadedClient, coll}; use self::mongodb::db::ThreadedDatabase; use std::error::Error; use config::Config; use artist::Artist; pub fn cr...
code_fim
medium
{ "lang": "rust", "repo": "Yasu-umi/rust_nlp_100_examples", "path": "/src/mongo_utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn create_artist_cursor<'a>( collection: &coll::Collection, query: Option<ordered::OrderedDocument>, option: Option<coll::options::FindOptions>, ) -> Result<impl Iterator<Item=Option<Artist>> + 'a, Box<Error>> { let cursor = try!(collection.find(query, option)); Ok(...
code_fim
hard
{ "lang": "rust", "repo": "Yasu-umi/rust_nlp_100_examples", "path": "/src/mongo_utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.cpu.interrupt(); } pub fn new_frame(&self) -> bool { self.cpu.memory.gpu.new_frame } pub fn frame(&self) -> &[u8] { &self.cpu.memory.gpu.frame } pub fn key_down(&mut self, button: Button) { self.cpu.memory.input.key_down(button); } p...
code_fim
hard
{ "lang": "rust", "repo": "DuoSRX/yeeboy", "path": "/src/console.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.cpu.memory.timer.tick(elapsed) { self.cpu.request_interrupt(4); } if self.cpu.memory.gpu.interrupts > 0 { self.cpu.request_interrupt(self.cpu.memory.gpu.interrupts); self.cpu.memory.gpu.interrupts = 0; } self.cpu.interru...
code_fim
medium
{ "lang": "rust", "repo": "DuoSRX/yeeboy", "path": "/src/console.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DuoSRX/yeeboy path: /src/console.rs use crate::cartridge::Cartridge; use crate::cpu::Cpu; use crate::input::Button; pub struct Console { pub cpu: Cpu, } impl Console { pub fn new(cartridge: Cartridge, trace: bool) -> Self { let cpu = Cpu::new(cartridge, trace); Self { c...
code_fim
medium
{ "lang": "rust", "repo": "DuoSRX/yeeboy", "path": "/src/console.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wjdz99/ChineseChess path: /src/game.rs use sdl2::render::{Texture, WindowCanvas}; use sdl2::rect::Rect; use sdl2::video::Window; use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::EventPump; use sdl2::image::LoadTexture; use std::time::Duration; use std::collections::LinkedList; use ...
code_fim
hard
{ "lang": "rust", "repo": "wjdz99/ChineseChess", "path": "/src/game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // check pos is outrange fn check_pos_valid(&self, pos: &(usize, usize)) -> bool { return pos.0 < ROW_NUM && pos.1 < COL_NUM && (self.chesses[pos.0][pos.1].id == EMPTY || get_chess_role(self.chesses[pos.0][pos.1].id) != self.role); } fn move_pawn(&self, pos...
code_fim
hard
{ "lang": "rust", "repo": "wjdz99/ChineseChess", "path": "/src/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some((row, col)) = self.get_click_rect(pos) { if self.chesses[row][col].id == EMPTY || get_chess_role(self.chesses[row][col].id) != self.role { // may be move if let Some(_) = self.movable_pos.iter().find(|&&(r, l)| { return (r, l) == (row, col) }...
code_fim
hard
{ "lang": "rust", "repo": "wjdz99/ChineseChess", "path": "/src/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Attach these file descriptors onto the current test case context for further use. test_case.input_file = Some(input_file); test_case.judgee_output_file = Some(output_file); test_case.judgee_error_file = Some(error_file); // Execute the judgee alone. let ...
code_fim
hard
{ "lang": "rust", "repo": "fky2015/WaveJudge", "path": "/judge/src/engine.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fky2015/WaveJudge path: /judge/src/engine.rs LanguageIdentifier, LanguageManager, LanguageProvider, ExecutionScheme }; use checkers::{Checker, CheckerContext}; use io::{ ReadExt, FileExt, TokenizedReader, TempFile }; /// Configuration for a judge engine instance. ...
code_fim
hard
{ "lang": "rust", "repo": "fky2015/WaveJudge", "path": "/judge/src/engine.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.execute_judgee_on_test_case(context)?; let test_case = context.test_case.as_ref().unwrap(); if !test_case.result.verdict.is_accepted() { return Ok(()); } self.execute_checker(context) } /// Execute the judgee program on the current test c...
code_fim
hard
{ "lang": "rust", "repo": "fky2015/WaveJudge", "path": "/judge/src/engine.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> mod state; pub mod storage; pub mod traits; pub mod transfer; pub mod utils;<|fim_prefix|>// repo: rakanalh/raiden-rust-old path: /raiden/lib.rs extern crate tokio; #[macro_use] extern crate slog; extern crate web3; pub <|fim_middle|>mod accounts; pub mod api; pub mod blockchain; pub mod cli; pub mod c...
code_fim
medium
{ "lang": "rust", "repo": "rakanalh/raiden-rust-old", "path": "/raiden/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rakanalh/raiden-rust-old path: /raiden/lib.rs extern crate tokio; #[macro_use] extern crate slog; extern crate web3; pub mod accounts; pub mod api; pub mod blockchain; pub mod cli; pub mod constants<|fim_suffix|> mod state; pub mod storage; pub mod traits; pub mod transfer; pub mod utils;<|fim_...
code_fim
medium
{ "lang": "rust", "repo": "rakanalh/raiden-rust-old", "path": "/raiden/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DarthGandalf/advent-of-code path: /2017/days6-/src/day13.rs use aoc_runner_derive::{aoc, aoc_generator}; use itertools::Itertools; #[aoc_generator(day13)] fn parse(input: &str) -> std::collections::BTreeMap<i32, i32> { crate::numbers::parse(input) .into_iter() .chunks(2) .into_iter() ....
code_fim
hard
{ "lang": "rust", "repo": "DarthGandalf/advent-of-code", "path": "/2017/days6-/src/day13.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn answers() { let input = parse(include_str!("../input/2017/day13.txt")); assert_eq!(part1(&input), 1528); assert_eq!(part2(&input), 3896406); } }<|fim_prefix|>// repo: DarthGandalf/advent-of-code path: /2017/days6-/src/day13.rs use aoc_runner_derive::{aoc, aoc_generator}; use itertools...
code_fim
hard
{ "lang": "rust", "repo": "DarthGandalf/advent-of-code", "path": "/2017/days6-/src/day13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[aoc(day13, part2)] fn part2(input: &std::collections::BTreeMap<i32, i32>) -> i32 { for delay in 0.. { if input.iter().all(|(k, v)| (*k + delay) % (2 * *v - 2) != 0) { return delay; } } unreachable!(); } #[cfg(test)] mod tests { use super::*; #[test] fn test_example() { let input = parse...
code_fim
medium
{ "lang": "rust", "repo": "DarthGandalf/advent-of-code", "path": "/2017/days6-/src/day13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<Vec<i16>> for Array { fn from(i: Vec<i16>) -> Array { let data = af::Array::new(&i, dim4(i.len())); Array::I16(data.into()) } } impl From<Vec<i32>> for Array { fn from(i: Vec<i32>) -> Array { let data = af::Array::new(&i, dim4(i.len())); Array::I32(da...
code_fim
hard
{ "lang": "rust", "repo": "zmilan/tinychain", "path": "/prototype/collection/tensor/dense/array.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zmilan/tinychain path: /prototype/collection/tensor/dense/array.rs f::Convertable>::OutType as af::ImplicitPromote<<T as af::Convertable>::OutType>>::Output: af::HasAfEnum, { type Output = ArrayExt<<<T as af::Convertable>::OutType as af::ImplicitPromote<<T as af::Convertable>::OutType>>::Ou...
code_fim
hard
{ "lang": "rust", "repo": "zmilan/tinychain", "path": "/prototype/collection/tensor/dense/array.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zmilan/tinychain path: /prototype/collection/tensor/dense/array.rs IntType::I64 => I64(vec_into(values).into()), } } NumberType::UInt(u) => { let values: Vec<UInt> = vec_try_into(values)?; match u { ...
code_fim
hard
{ "lang": "rust", "repo": "zmilan/tinychain", "path": "/prototype/collection/tensor/dense/array.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T, R> Stream for ResponseStream<T, R> where R: prost::Message + Default, T: FromProtobuf<R>, { type Item = T; type Error = core_error::Error; fn poll(&mut self) -> Poll<Option<T>, core_error::Error> { let maybe_msg = try_ready!(self.inner.poll().map_err(error_from_grpc));...
code_fim
hard
{ "lang": "rust", "repo": "Emurgo/chain-libs", "path": "/network-grpc/src/client/server_streaming.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Emurgo/chain-libs path: /network-grpc/src/client/server_streaming.rs use crate::convert::{error_from_grpc, FromProtobuf}; use network_core::error as core_error; use futures::prelude::*; use tower_grpc::Streaming; use std::marker::PhantomData; type GrpcFuture<R> = tower_grpc::client::server_st...
code_fim
hard
{ "lang": "rust", "repo": "Emurgo/chain-libs", "path": "/network-grpc/src/client/server_streaming.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let res = try_ready!(self.inner.poll().map_err(error_from_grpc)); let stream = ResponseStream { inner: res.into_inner(), _phantom: PhantomData, }; Ok(Async::Ready(stream)) } } pub struct ResponseStream<T, R> { inner: Streaming<R, tower_hyper...
code_fim
hard
{ "lang": "rust", "repo": "Emurgo/chain-libs", "path": "/network-grpc/src/client/server_streaming.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hizoul/tetris-link-research path: /src/game_logic/field/user_actions.rs use super::GameField; use crate::game_logic::tetromino::{get_rotation_amount}; use crate::game_logic::log::{Play}; use crate::game_logic::val::{GAMEFIELD_MAX_WIDTH,AMOUNT_OF_UNIQUE_PIECES}; pub const ACTION_LEFT: u8 = ...
code_fim
medium
{ "lang": "rust", "repo": "Hizoul/tetris-link-research", "path": "/src/game_logic/field/user_actions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let found_action = self.possible_plays.iter().find(|play| { play.x == x && play.block == block && play.rotation == orientation }); found_action } fn do_user_action(&mut self, user_action: u8) { match user_action { ACTION_PLACE_BLOCK => { let action: Option<&...
code_fim
medium
{ "lang": "rust", "repo": "Hizoul/tetris-link-research", "path": "/src/game_logic/field/user_actions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl UserActions for GameField { fn find_action(&self, block: i8, orientation: i8, x: i8) -> Option<&Play> { let found_action = self.possible_plays.iter().find(|play| { play.x == x && play.block == block && play.rotation == orientation }); found_action } fn do_user_acti...
code_fim
medium
{ "lang": "rust", "repo": "Hizoul/tetris-link-research", "path": "/src/game_logic/field/user_actions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl Into<abstract_ns::Error> for Error { fn into(self) -> abstract_ns::Error { match self { Error::Name(name, _) => { abstract_ns::Error::InvalidName(name, "bad name") } Error::Port(name, _) => { abstract_ns::Error::InvalidN...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/ns-router", "path": "/src/name.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tailhook/ns-router path: /src/name.rs use std::str::FromStr; use std::num::ParseIntError; use std::net::{IpAddr, SocketAddr}; use abstract_ns; use abstract_ns::name::{self, Name}; use quick_error::ResultExt; quick_error! { #[derive(Debug)] pub enum Error { Name(name: String, er...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/ns-router", "path": "/src/name.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(unused)] pub async fn run(conn: &PgPool) -> Result<(), DbError> { //TODO: embed and run migrations Ok(()) }<|fim_prefix|>// repo: HansTrashy/trashy_bot path: /src/migrations.rs use sqlx::postgres::PgPool; <|fim_middle|>pub type DbError = sqlx::Error;
code_fim
easy
{ "lang": "rust", "repo": "HansTrashy/trashy_bot", "path": "/src/migrations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HansTrashy/trashy_bot path: /src/migrations.rs use sqlx::postgres::PgPool; <|fim_suffix|>#[allow(unused)] pub async fn run(conn: &PgPool) -> Result<(), DbError> { //TODO: embed and run migrations Ok(()) }<|fim_middle|>pub type DbError = sqlx::Error;
code_fim
easy
{ "lang": "rust", "repo": "HansTrashy/trashy_bot", "path": "/src/migrations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: citronneur/mignosaurus path: /src/render.rs use miniquad::{graphics::*, Context}; use system::render::PixelBuffer; use std::slice; #[repr(C)] struct Vec2 { x: f32, y: f32, } #[repr(C)] struct Vertex { pos: Vec2, uv: Vec2, } pub struct Render { pipeline: Pipeline, textur...
code_fim
hard
{ "lang": "rust", "repo": "citronneur/mignosaurus", "path": "/src/render.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> gl_Position = vec4(pos, 0, 1); texcoord = uv; }"#; pub const FRAGMENT: &str = r#"#version 100 varying lowp vec2 texcoord; uniform sampler2D tex; void main() { gl_FragColor = texture2D(tex, texcoord); }"#; pub const META: ShaderMeta = ShaderMeta { ...
code_fim
hard
{ "lang": "rust", "repo": "citronneur/mignosaurus", "path": "/src/render.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eduadiez/PowersOfTau-SGX path: /enclave/src/lib.rs and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions ...
code_fim
hard
{ "lang": "rust", "repo": "eduadiez/PowersOfTau-SGX", "path": "/enclave/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eduadiez/PowersOfTau-SGX path: /enclave/src/lib.rs edistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // * Redistributions of source code must retain the above copyright // notice, this list o...
code_fim
hard
{ "lang": "rust", "repo": "eduadiez/PowersOfTau-SGX", "path": "/enclave/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let res = unsafe { ocall_sgx_init_quote(&mut rt as *mut sgx_status_t, &mut ti as *mut sgx_target_info_t, &mut eg as *mut sgx_epid_group_id_t) }; if res != sgx_status_t::SGX_SUCCESS { return Err(res); } if rt...
code_fim
hard
{ "lang": "rust", "repo": "eduadiez/PowersOfTau-SGX", "path": "/enclave/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaivol/drone-stm32f4-hal path: /src/uart/setup.rs use drone_cortexm::thr::IntToken; use drone_stm32f4_rcc_drv::{ConfiguredClk, clktree::PClkToken}; use drone_stm32_map::periph::uart::UartPeriph; pub use crate::UartMap; /// Uart setup. pub struct UartSetup<Uart: UartMap, UartInt: IntToken, Clk: ...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/uart/setup.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Uart stop bits. #[derive(Copy, Clone, PartialEq)] pub enum StopBits { #[doc = "½ stop bit."] Half, #[doc = "1 stop bit."] One, #[doc = "1½ stop bit."] OneHalf, #[doc = "2 stop bits."] Two, } #[macro_export] macro_rules! uart_setup_init { ($uart:ident, $pclk:ident) ...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/uart/setup.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }