text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> for (i, d) in self.devices.iter().enumerate() { debug!(i=i, device = %d, "Iter devices"); if d == &device { debug!("Matched device"); if let Some(p) = self.rev_slot_map.get_mut(&i) { debug!( "Found ...
code_fim
hard
{ "lang": "rust", "repo": "kbknapp/usbwatch-rs", "path": "/src/state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "dcap")] pub use self::dcap::{ QuoteGenerator as SgxDCAPQuoteGenerator, QuoteVerifier as SgxDCAPQuoteVerifier, }; pub use self::epid::AttestationAgent as SgxEPIDAttestationAgent; pub use self::sgx_key::get_key; pub use self::sgx_report::{create_report, get_self_target, verify_report}; ...
code_fim
hard
{ "lang": "rust", "repo": "occlum/occlum", "path": "/src/libos/src/util/sgx/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bartlomieju/jsonc-parser path: /src/lib.rs pub mod common; pub mod ast; pub mod errors; pub mod <|fim_suffix|>rse_to_value::*; pub use scanner::*; pub use value::*;<|fim_middle|>tokens; mod parse_to_ast; mod scanner; mod parse_to_value; mod value; pub use parse_to_ast::*; pub use pa
code_fim
medium
{ "lang": "rust", "repo": "bartlomieju/jsonc-parser", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>alue; mod value; pub use parse_to_ast::*; pub use parse_to_value::*; pub use scanner::*; pub use value::*;<|fim_prefix|>// repo: bartlomieju/jsonc-parser path: /src/lib.rs pub mod common; pub mod ast; pub mod errors; pub mod <|fim_middle|>tokens; mod parse_to_ast; mod scanner; mod parse_to_v
code_fim
easy
{ "lang": "rust", "repo": "bartlomieju/jsonc-parser", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod device; pub mod field_type; pub mod periph; pub mod register;<|fim_prefix|>// repo: kellda/peripherals path: /src/attributes/mod.rs //! Example of attribute in macros //! //! By default, attributes exand on generated types and fields, and not expand on generated impls. //! This shows how it can b...
code_fim
medium
{ "lang": "rust", "repo": "kellda/peripherals", "path": "/src/attributes/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kellda/peripherals path: /src/attributes/mod.rs //! Example of attribute in macros //! //! By default, attributes exand on generated types and fields, and not expand on generated impls. //! This shows how it can be changed. //! //! The macro invocations can be seen in the source code. This modul...
code_fim
medium
{ "lang": "rust", "repo": "kellda/peripherals", "path": "/src/attributes/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// match_opts.case_sensitive = !ignore_case; // for entry in glob_with(&glob_expanded, match_opts)? { // match entry { // Ok(path) => { // contents.push(content); // } // Err(e) => println!("{:?}", e), // } // } // Ok(co...
code_fim
hard
{ "lang": "rust", "repo": "Excloudx6/freq-word-counter-rust", "path": "/src/utils/traverse.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // let mut file = File::create(&file_path)?; // let mut file_glob_1 = File::create(file_glob_1_path)?; // let mut file_glob_2 = File::create(file_glob_2_path)?; // let inputs = vec![ // // Input::String(TEST_STRING.to_string()), // Input::FsPath(fil...
code_fim
hard
{ "lang": "rust", "repo": "Excloudx6/freq-word-counter-rust", "path": "/src/utils/traverse.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnzlbg/stdsimd path: /coresimd/src/macros.rs macros macro_rules! define_ty { ($name:ident, $($elty:ident),+) => { #[repr(simd)] #[derive(Clone, Copy, Debug, PartialEq)] #[allow(non_camel_case_types)] pub struct $name($($elty),*); } } macro_rules! define...
code_fim
hard
{ "lang": "rust", "repo": "gnzlbg/stdsimd", "path": "/coresimd/src/macros.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnzlbg/stdsimd path: /coresimd/src/macros.rs const fn new($($elname: $elemty),*) -> $name { $name($($elname),*) } #[inline(always)] pub fn len() -> i32 { $nelems } #[inline(always)] pub con...
code_fim
hard
{ "lang": "rust", "repo": "gnzlbg/stdsimd", "path": "/coresimd/src/macros.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[inline(always)] pub fn gt(self, other: $name) -> $boolname { unsafe { simd_gt(self, other) } } #[inline(always)] pub fn ge(self, other: $name) -> $boolname { unsafe { simd_ge(self, other) } } ...
code_fim
hard
{ "lang": "rust", "repo": "gnzlbg/stdsimd", "path": "/coresimd/src/macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// submission codes end #[cfg(test)] mod tests { use super::*; #[test] fn test_1122() { assert_eq!( vec![2, 2, 2, 1, 4, 3, 3, 9, 6, 7, 19], Solution::relative_sort_array( vec![2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19], vec![2, 1, 4, 3, ...
code_fim
hard
{ "lang": "rust", "repo": "potatosalad/leetcode", "path": "/src/n1122_relative_sort_array.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( vec![2, 2, 2, 1, 4, 3, 3, 9, 6, 7, 19], Solution::relative_sort_array( vec![2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19], vec![2, 1, 4, 3, 9, 6] ) ); } }<|fim_prefix|>// repo: potatosalad/leetcode path: /src/n1122_re...
code_fim
medium
{ "lang": "rust", "repo": "potatosalad/leetcode", "path": "/src/n1122_relative_sort_array.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // ----------------------------------------------------------------------------- config & pg let config = get_config().expect("failed to read settings"); let addr = format!("{}:{}", config.app.host, config.app.port); // configure sqlx connection let mut conn_options = config.database....
code_fim
medium
{ "lang": "rust", "repo": "ilmoi/sol_wtf", "path": "/backend/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // ----------------------------------------------------------------------------- run let arc_pool = Arc::new(pg_pool); let arc_config = Arc::new(config); schedule_tweet_refresh(arc_pool.clone(), arc_config.clone()).await; run_server(&addr, arc_pool.clone(), arc_config.clone())?.await ...
code_fim
hard
{ "lang": "rust", "repo": "ilmoi/sol_wtf", "path": "/backend/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Mutable methods for [crate::features2d::AffineFeature] pub trait AffineFeatureTrait: crate::features2d::AffineFeatureTraitConst + crate::features2d::Feature2DTrait { fn as_raw_mut_AffineFeature(&mut self) -> *mut c_void; #[inline] fn set_view_params(&mut self, tilts: &core::Vector<f32>, roll...
code_fim
hard
{ "lang": "rust", "repo": "twistedfall/opencv-rust", "path": "/docs/features2d.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twistedfall/opencv-rust path: /docs/features2d.rs /// /// ## Parameters /// * queryDescriptors: Query set of descriptors. /// * trainDescriptors: Train set of descriptors. This set is not added to the train descriptors /// collection stored in the class object. /// * matches: Match...
code_fim
hard
{ "lang": "rust", "repo": "twistedfall/opencv-rust", "path": "/docs/features2d.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twistedfall/opencv-rust path: /docs/features2d.rs Result<bool> { return_send!(via ocvrs_return); unsafe { sys::cv_AgastFeatureDetector_getNonmaxSuppression_const(self.as_raw_AgastFeatureDetector(), ocvrs_return.as_mut_ptr()) }; return_receive!(unsafe ocvrs_return => ret); let ret = ...
code_fim
hard
{ "lang": "rust", "repo": "twistedfall/opencv-rust", "path": "/docs/features2d.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>/// All the different asynchronous events the updater thread needs to listen for and act on pub enum SyncMsg { NewState { buffer: BufferIdentifier, new_buf: Vec<u8>, done: Option<Promise<Option<PageSnapshot_Server>, fidl::Error>>, }, TransactionReady { buffer: B...
code_fim
hard
{ "lang": "rust", "repo": "xi-editor/xi-editor", "path": "/rust/core-lib/src/fuchsia/sync.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xi-editor/xi-editor path: /rust/core-lib/src/fuchsia/sync.rs // Copyright 2017 The xi-editor Authors. // // 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 // // htt...
code_fim
hard
{ "lang": "rust", "repo": "xi-editor/xi-editor", "path": "/rust/core-lib/src/fuchsia/sync.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Template for NumericBox { fn template(self, id: Entity, ctx: &mut BuildContext) -> Self { self.name("NumericBox") .background("transparent") .foreground(colors::LINK_WATER_COLOR) .border_brush("#647b91") .border_width(1.0) .borde...
code_fim
hard
{ "lang": "rust", "repo": "FengchenX/orbtk-mirror", "path": "/crates/widgets/src/numeric_box.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Sets or shares the focused property focused: bool, /// Sets or shares the foreground color property foreground: Brush, /// Sets or shares the minimum allowed value property min: f64, /// Sets or shares the maximum allowed value property ...
code_fim
hard
{ "lang": "rust", "repo": "FengchenX/orbtk-mirror", "path": "/crates/widgets/src/numeric_box.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> $( chum_struct_binary_write!($type, writer, fmt, &self.$name, self)?; )* Ok(()) } } }; } /// Special macro that just implements ChumStruct and ChumBinary instead of also defining the struct. /// Useful for Generic...
code_fim
hard
{ "lang": "rust", "repo": "escape209/chum-world", "path": "/libchum/src/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: escape209/chum-world path: /libchum/src/macros.rs ( vec![ $( stringify!($name).to_owned(), )* ] )) }; ([int_custom [$repr:tt] $min:expr, $max:expr],$value:expr) => { Integer($value as ::std::primi...
code_fim
hard
{ "lang": "rust", "repo": "escape209/chum-world", "path": "/libchum/src/macros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: escape209/chum-world path: /libchum/src/macros.rs ansform2D]) => {$crate::common::Transform2D}; ([Vector2]) => {$crate::common::Vector2}; ([Vector3]) => {$crate::common::Vector3}; ([Vector3 rgb]) => {$crate::common::Vector3}; ([Color]) => {$crate::common::ColorRGBA}; ([Quater...
code_fim
hard
{ "lang": "rust", "repo": "escape209/chum-world", "path": "/libchum/src/macros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hpolloni/xagima path: /src/testing.rs use core::panic::PanicInfo; use crate::println; pub fn runner(tests: &[&dyn Fn()]) { println!("Running {} tests", tests.len()); for test in tests { test(); } success(); } pub fn default_panic_handler(info: &PanicInfo) -> ! { pr...
code_fim
medium
{ "lang": "rust", "repo": "hpolloni/xagima", "path": "/src/testing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let mut port = Port::new(0xf4); port.write(exit_code); } } pub fn fail() { exit_qemu(0x11); } pub fn success() { exit_qemu(0x10); }<|fim_prefix|>// repo: hpolloni/xagima path: /src/testing.rs use core::panic::PanicInfo; use crate::println; pub fn runner(tests:...
code_fim
hard
{ "lang": "rust", "repo": "hpolloni/xagima", "path": "/src/testing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>read::spawn(move || { // 发送一个消息,此处是数字id tx.send(1).unwrap(); }); // 在主线程中接收子线程发送的消息并输出 println!("receive {}", rx.recv().unwrap()); } //输出 receive 1<|fim_prefix|>// repo: maxueshan/quick_get_start_rust path: /src/bin/mpsc_test.rs use std::sync::mpsc; use std::thread; fn main() ...
code_fim
medium
{ "lang": "rust", "repo": "maxueshan/quick_get_start_rust", "path": "/src/bin/mpsc_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxueshan/quick_get_start_rust path: /src/bin/mpsc_test.rs use std::sync::mpsc; use std::thread; fn main() { // 创建一个通道 let (tx, rx): (mpsc<|fim_suffix|> // 在主线程中接收子线程发送的消息并输出 println!("receive {}", rx.recv().unwrap()); } //输出 receive 1<|fim_middle|>::Sender<i32>, mpsc::Receiver<i32>...
code_fim
medium
{ "lang": "rust", "repo": "maxueshan/quick_get_start_rust", "path": "/src/bin/mpsc_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 在主线程中接收子线程发送的消息并输出 println!("receive {}", rx.recv().unwrap()); } //输出 receive 1<|fim_prefix|>// repo: maxueshan/quick_get_start_rust path: /src/bin/mpsc_test.rs use std::sync::mpsc; use std::thread; fn main() { // 创建一个通道 let (tx, rx): (mpsc::Sender<i32>, mpsc::Receiver<i32>) = mp...
code_fim
medium
{ "lang": "rust", "repo": "maxueshan/quick_get_start_rust", "path": "/src/bin/mpsc_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let key_json = serde_json::to_vec(&unsealed) .map_err(|e| Error::Other(format!("{:?}", e).into()))?; Ok(seal(&key_json, RSA3072_SEALED_KEY_FILE)?) } } impl SealedIO for Rsa3072Seal { type Error = Error; type Unsealed = Rsa3072KeyPair; fn unseal(&self) -> Result<Self::Unsealed> { S...
code_fim
hard
{ "lang": "rust", "repo": "encointer/encointer-worker", "path": "/core-primitives/sgx/crypto/src/rsa3072.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Collection { pub fn new() -> Collection { Collection { path_to_id_map: BTreeMap::new(), id_to_path_map: BTreeMap::new(), path_to_url_map: BTreeMap::new(), path_to_dir_map: Mutex::new(BTreeMap::new()), next_id: 0, cach...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/src/fonts/src/font_service/asset/collection.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winksaville/fuchsia path: /src/fonts/src/font_service/asset/collection.rs // Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { super::{asset::Asset, cache::Cache}, failur...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/src/fonts/src/font_service/asset/collection.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // Get directory handle from FontResolver let font_resolver = connect_to_service::<FontResolverMarker>()?; let mut update_policy = UpdatePolicy { fetch_if_absent: true, allow_old_versions: false }; let (dir_proxy, dir_requ...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/src/fonts/src/font_service/asset/collection.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> response_message.set_id(request_id); Some(response_message) } async fn get_message_for_cache_hit( &self, request_key: &RequestKey, request_id: u16, ) -> Option<Message> { let cache_object = match self.cache.get(&request_key).await { ...
code_fim
hard
{ "lang": "rust", "repo": "aaronriekenberg/rust-doh-proxy", "path": "/src/doh/proxy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: glpeon/rpfm path: /rpfm_cli/src/logger/mod.rs //---------------------------------------------------------------------------// // Copyright (c) 2017-2020 Ismael Gutiérrez González. All rights reserved. // // This file is part of the Rusted PackFile Manager (RPFM) project, // which can be found he...
code_fim
medium
{ "lang": "rust", "repo": "glpeon/rpfm", "path": "/rpfm_cli/src/logger/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// This function initialize the logging stuff. To be used at the start of the program. pub fn initialize_logs() -> Result<()> { // In Release Builds, initiallize the logger, so we get messages in the terminal and recorded to disk. if !cfg!(debug_assertions) { CrashReport::init()?; ...
code_fim
hard
{ "lang": "rust", "repo": "glpeon/rpfm", "path": "/rpfm_cli/src/logger/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: russelltg/srt-rs path: /srt-protocol/src/protocol/pending_connection/rendezvous.rs ic: SocketAddr, init_settings: ConnInitSettings, starting_seqnum: SeqNumber, ) -> Self { let cookie = gen_cookie(&local_addr); let last_packet = ( ControlPacket { ...
code_fim
hard
{ "lang": "rust", "repo": "russelltg/srt-rs", "path": "/srt-protocol/src/protocol/pending_connection/rendezvous.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn handle_initiated_initiator( &mut self, info: &HandshakeControlInfo, initiator: StartedInitiator, now: Instant, ) -> ConnectionResult { match info.shake_type { ShakeType::Conclusion => match extract_ext_info(info) { Ok(Some(SrtC...
code_fim
hard
{ "lang": "rust", "repo": "russelltg/srt-rs", "path": "/srt-protocol/src/protocol/pending_connection/rendezvous.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let settings = match initiator.finish_hsv5_initiation(info, self.remote_public, now) { Ok(s) => s, Err(r) => return NotHandled(r), }; self.set_connected(settings...
code_fim
hard
{ "lang": "rust", "repo": "russelltg/srt-rs", "path": "/srt-protocol/src/protocol/pending_connection/rendezvous.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> merger .run(matches.is_present("auto")) .unwrap_or_else(|e| die(e)); } fn die(err: impl Error) -> ! { println!("{}", err); std::process::exit(1); }<|fim_prefix|>// repo: mmcclimon/rustmergency path: /src/main.rs mod config; mod errors; mod logger; mod merger; mod remote; mod step; use cla...
code_fim
medium
{ "lang": "rust", "repo": "mmcclimon/rustmergency", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmcclimon/rustmergency path: /src/main.rs mod config; mod errors; mod logger; mod merger; mod remote; mod step; use clap::{crate_name, crate_version, App, Arg}; use std::error::Error; use merger::Merger; const TEMPLATE: &str = "\ {bin} {version} - {about} {usage} {unified} "; <|fim_suffix|...
code_fim
hard
{ "lang": "rust", "repo": "mmcclimon/rustmergency", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let matches = App::new(crate_name!()) .version(crate_version!()) .about("build git branches from merge requests") .template(TEMPLATE) .arg( Arg::with_name("config") .short("c") .long("config") .value_name("FILE") .required(true) ....
code_fim
medium
{ "lang": "rust", "repo": "mmcclimon/rustmergency", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ResponseError for JkError { fn status_code(&self) -> StatusCode { match self { JkError::NotFound => StatusCode::NOT_FOUND, JkError::Unauthorized => StatusCode::UNAUTHORIZED, JkError::PGError(error) if Self::is_unique_constraint_violation(error) => { ...
code_fim
hard
{ "lang": "rust", "repo": "ilkkahanninen/juhlakalu", "path": "/backend/src/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoshKarpel/fungoid path: /src/examples.rs use std::collections::HashMap; pub const DNA: &str = include_str!("examples/dna.bf"); pub const ERATOSTHENES: &str = include_str!("examples/eratosthenes.bf"); pub const FACTORIAL: &str = include_str!("examples/factori<|fim_suffix|> include_str!("example...
code_fim
hard
{ "lang": "rust", "repo": "JoshKarpel/fungoid", "path": "/src/examples.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> include_str!("examples/rng.bf"); lazy_static! { pub static ref EXAMPLES: HashMap<&'static str, &'static str> = { let mut m = HashMap::new(); m.insert("dna", DNA); m.insert("eratosthenes", ERATOSTHENES); m.insert("factorial", FACTORIAL); m.insert("hello_world",...
code_fim
hard
{ "lang": "rust", "repo": "JoshKarpel/fungoid", "path": "/src/examples.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum FormKind { ModuleAttr, ExportAttr, ExportTypeAttr, ImportAttr, FileAttr, WildAttr, FunSpec, CallbackSpec, FunDecl, RecordDecl, TypeDecl, } impl FormKind { pub fn guess<T>(parser: &mut Parser<T>) -> Result<Self> where T: ...
code_fim
hard
{ "lang": "rust", "repo": "sile/erl_parse", "path": "/src/cst/form.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let system = actix::System::new("Translator"); /* let storer = database::TradeHistoryStorer::new(config.database_url()); let storer_addr = storer.start(); */ let db_url = config.database_url().to_owned(); let storer_addr = SyncArbiter::start(config.database_connections() as ...
code_fim
medium
{ "lang": "rust", "repo": "kvsari/sammy", "path": "/collector/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kvsari/sammy path: /collector/src/main.rs //! Entrypoint #[macro_use] extern crate log; extern crate env_logger; extern crate dotenv; extern crate actix; extern crate actix_web; extern crate common; extern crate collector_lib as lib; use actix::{Actor, SyncArbiter}; use actix_web::{server::Htt...
code_fim
medium
{ "lang": "rust", "repo": "kvsari/sammy", "path": "/collector/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let binance_filter = filter::BinanceTradeHistory::new(storer_addr); let bf_addr = binance_filter.start(); let rest_state = lib::restful::State::new(kf_addr, bf_addr); HttpServer::new(move || { App::with_state(rest_state.clone()) .middleware(Logger::default()) ...
code_fim
hard
{ "lang": "rust", "repo": "kvsari/sammy", "path": "/collector/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where P: AsRef<Path> { let bindings = bindgen::Builder::default() .clang_arg("-IVulkan-Headers/include") .header("VulkanMemoryAllocator/include/vk_mem_alloc.h") .rustfmt_bindings(true) .size_t_is_usize(true) .blocklist_type("__darwin_.*") .allowlist_...
code_fim
hard
{ "lang": "rust", "repo": "K0bin/SourceRenderer", "path": "/vendor/vma-sys/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Assert all nodes are in non-voter state & have no entries. sleep(Duration::from_secs(10)).await; router.assert_pristine_cluster().await; // Initialize the cluster, then assert that a stable cluster was formed & held. tracing::info!("--- initializing cluster"); router.initialize...
code_fim
hard
{ "lang": "rust", "repo": "async-raft/async-raft", "path": "/async-raft/tests/shutdown.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>dit manually index.html and other paths for images etc. #[get("/<file..>")] pub fn file(file: PathBuf) -> Option<NamedFile> { NamedFile::open(Path::new("public/").join(file)).ok() }<|fim_prefix|>// repo: steadylearner/Rust-Full-Stack path: /React_Rust/server/rocket/src/routes/static_files.rs use std:...
code_fim
medium
{ "lang": "rust", "repo": "steadylearner/Rust-Full-Stack", "path": "/React_Rust/server/rocket/src/routes/static_files.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steadylearner/Rust-Full-Stack path: /React_Rust/server/rocket/src/routes/static_files.rs use std::path::{Path, PathBuf}; use rocket::response::NamedFile; // Follow the structure of<|fim_suffix|>dit manually index.html and other paths for images etc. #[get("/<file..>")] pub fn file(file: PathBuf...
code_fim
medium
{ "lang": "rust", "repo": "steadylearner/Rust-Full-Stack", "path": "/React_Rust/server/rocket/src/routes/static_files.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Creates iterator that emits read/write accessors for vertices. pub fn iter_mut(&mut self) -> impl Iterator<Item = VertexViewMut<'_>> + '_ { unsafe { VertexViewMutIterator { ptr: self.vertex_buffer.data.as_mut_ptr(), end: self.data.as_mut_ptr(...
code_fim
hard
{ "lang": "rust", "repo": "FyroxEngine/Fyrox", "path": "/src/scene/mesh/buffer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /src/scene/mesh/buffer.rs exViewRef<'a>; fn next(&mut self) -> Option<Self::Item> { if self.offset >= self.end { None } else { let view = VertexViewRef { vertex_data: &self.data[self.offset..(self.offset + self....
code_fim
hard
{ "lang": "rust", "repo": "FyroxEngine/Fyrox", "path": "/src/scene/mesh/buffer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /src/scene/mesh/buffer.rs possible and calculate vertex size. let mut sparse_layout = [None; VertexAttributeUsage::Count as usize]; let mut vertex_size_bytes = 0u8; for attribute in layout.iter() { if attribute.size < 1 || attribute.siz...
code_fim
hard
{ "lang": "rust", "repo": "FyroxEngine/Fyrox", "path": "/src/scene/mesh/buffer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // self.container.set_opacity(state, 1.0); // // Shouldn't need to do this but it's required for some reason. TODO: Investigate // self.container.set_z_order(state, 1); // } // WindowEvent::MouseUp(button) => matc...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/widgets/src/dropdown.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let list = List::new().build(state, self.container, |builder| builder .set_height(Auto) ); entity.set_element(state, "dropdown").set_layout_type(state, LayoutType::Row); // (entity, self.header, self.container) let container = self.co...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/widgets/src/dropdown.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Krout0n/vecmat-rs path: /src/complex/complex_.rs use crate::{ matrix::Matrix2x2, traits::{Conj, Dot, NormL1, NormL2, Normalize}, vector::Vector2, }; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign}; use num_complex::{Complex as NumComplex, Par...
code_fim
hard
{ "lang": "rust", "repo": "Krout0n/vecmat-rs", "path": "/src/complex/complex_.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (self.into_num() % other.into_num()).into() } } impl<T: Neg<Output = T> + Num + Copy> Num for Complex<T> { type FromStrRadixErr = ParseComplexError<T::FromStrRadixErr>; fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr> { NumComplex::from_str_radix(s...
code_fim
hard
{ "lang": "rust", "repo": "Krout0n/vecmat-rs", "path": "/src/complex/complex_.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Neg<Output = T> + Num + Copy> Num for Complex<T> { type FromStrRadixErr = ParseComplexError<T::FromStrRadixErr>; fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr> { NumComplex::from_str_radix(s, radix).map(Self::from_num) } } macro_rules! reverse_mu...
code_fim
hard
{ "lang": "rust", "repo": "Krout0n/vecmat-rs", "path": "/src/complex/complex_.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod tests { use super::*; #[test] fn test_is_permutation() { assert_eq!( is_permutation(&String::from("asdf"), &String::from("dsaf")), true ); assert_eq!(is_permutation("asdf", "safd"), true); assert_eq!(is_permutation("asdf", "zsdf"), f...
code_fim
hard
{ "lang": "rust", "repo": "shreyasdamle/rust_101", "path": "/src/ctci_02.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/generator path: /google_rest_api_generator/src/lib.rs {#ident}, parent_path: parent_path.clone(), type_desc, } } } } } } fn type_path(&self) ->...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/generator", "path": "/google_rest_api_generator/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/generator path: /google_rest_api_generator/src/lib.rs accum = param.typ.fold_nested(accum, f); } if let Some(RefOrType::Type(req)) = method.request.as_ref() { accum = req.fold_nested(accum, f); } if let Some(RefOrType::Type(...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/generator", "path": "/google_rest_api_generator/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Perform a fold ('reduce') operation on this type and all nested types // defined within it. This does *not* follow references. fn fold_nested<A, F>(&self, mut accum: A, f: F) -> A where F: Fn(A, &Type) -> A + Copy, { accum = f(accum, self); match &self.type_d...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/generator", "path": "/google_rest_api_generator/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use float_eq::assert_float_eq; use test_case::test_case; #[test_case(&[11], 0.; "uniform_one")] #[test_case(&[1; 4], 4.0_f64.ln(); "uniform_four")] #[test_case(&[1; 8], 8.0_f64.ln(); "uniform_eight")] #[test_case(&[1, 2, 3, 4, 5, 6], 1.66...
code_fim
hard
{ "lang": "rust", "repo": "Misha007007/approx_entropy", "path": "/src/estimator/naive.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot/src/core/events/interaction/command.rs use std::{mem, sync::Arc}; use eyre::Result; use crate::{ core::{ commands::{ checks::check_authority, interaction::{InteractionCommandKind, InteractionCommands, SlashCommand}, }, ...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/core/events/interaction/command.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> return Ok(Some(ProcessResult::Ratelimited(bucket))); } } // Only for authorities? if slash.flags.authority() { match check_authority(ctx, user_id, command.guild_id).await { Ok(None) => {} Ok(Some(content)) => { command.error_...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/core/events/interaction/command.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MattWoelk/rust-roguelike path: /src/components.rs use specs::{Component, NullStorage, VecStorage}; use specs_derive::Component; <|fim_suffix|>#[derive(Debug, Default, Component)] #[storage(VecStorage)] pub struct PrintMeTag; #[derive(Debug, Component)] #[storage(VecStorage)] pub struct Charact...
code_fim
medium
{ "lang": "rust", "repo": "MattWoelk/rust-roguelike", "path": "/src/components.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Component)] #[storage(VecStorage)] pub struct CharacterGlyph { pub glyph: char, } #[derive(Debug, Default, Component)] #[storage(NullStorage)] pub struct PlayerController;<|fim_prefix|>// repo: MattWoelk/rust-roguelike path: /src/components.rs use specs::{Component, NullStorage, VecS...
code_fim
hard
{ "lang": "rust", "repo": "MattWoelk/rust-roguelike", "path": "/src/components.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rezural/mesh-ripper path: /src/app/input.rs use crate::support::loader_fu::render::RenderCache; use super::loading::MeshAssets; use super::resources::actions::{Actions, FrameDirection, State as AppState}; use super::resources::camera::CameraSystem; use super::resources::mesh_pool::MeshPool; use...
code_fim
hard
{ "lang": "rust", "repo": "rezural/mesh-ripper", "path": "/src/app/input.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> // Can only control one camera at a time. let controller = if let Some(controller) = controllers.iter().next() { controller } else { return; }; let FpsCameraController { enabled, translate_sensitivity, .. } = *controller; if !enabled { ...
code_fim
hard
{ "lang": "rust", "repo": "rezural/mesh-ripper", "path": "/src/app/input.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> off: Vec::new(), }; } fn is_intresecting(&self, other: &Cuboid) -> bool { does_line_intersect(self.x0, self.x1, other.x0, other.x1) && does_line_intersect(self.y0, self.y1, other.y0, other.y1) && does_line_intersect(self.z0, self.z1, other.z0, o...
code_fim
hard
{ "lang": "rust", "repo": "Fadi88/AoC", "path": "/2021/day22/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> does_line_intersect(self.x0, self.x1, other.x0, other.x1) && does_line_intersect(self.y0, self.y1, other.y0, other.y1) && does_line_intersect(self.z0, self.z1, other.z0, other.z1) } pub fn substraction(&mut self, other: &Cuboid) { if self.is_intresecting(ot...
code_fim
hard
{ "lang": "rust", "repo": "Fadi88/AoC", "path": "/2021/day22/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>fn roll_with_advantage(die: i32) -> (i32, i32) { let mut rng = rand::thread_rng(); let roll1 = rng.gen_range(1, die); let roll2 = rng.gen_range(1, die); return if roll1 > roll2 { (roll1, roll2) } else { (roll2, roll1) } } fn roll_with_disadvantage(die: i32) -> (i32, i32) { let mut rng = rand::t...
code_fim
medium
{ "lang": "rust", "repo": "danambrogio/roll20", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: casept/socks5_frontend path: /src/lib.rs mod address; mod auth; mod command; mod connection; mod reply; mod request;<|fim_suffix|>::SOCKSConnection as Connection; pub use server::SOCKSServer as Server; pub use socks_error::SOCKSError as Error; pub use address::Address as Address;<|fim_middle|> m...
code_fim
medium
{ "lang": "rust", "repo": "casept/socks5_frontend", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use socks_error::SOCKSError as Error; pub use address::Address as Address;<|fim_prefix|>// repo: casept/socks5_frontend path: /src/lib.rs mod address; mod auth; mod command; mod connection; mod reply; mod request;<|fim_middle|> mod server; mod socks_error; pub use auth::AuthMethod; pub use connection::...
code_fim
medium
{ "lang": "rust", "repo": "casept/socks5_frontend", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/rust-analyzer path: /xtask/src/codegen.rs //! We use code generation heavily in rust-analyzer. //! //! Rather then doing it via proc-macros, we use old-school way of just dumping //! the source code. //! //! This module's submodules define specific bits that we generate. mod gen_synt...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/xtask/src/codegen.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let prefix = "// "; let lines = text.lines().map(str::trim_start); let mut block = vec![]; for line in lines { if line == "//" && allow_blocks_with_empty_lines { block.push(String::new()); continue; } let is_comment = line.starts_with(prefi...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/xtask/src/codegen.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theotherjimmy/cmsis-pack-manager path: /rust/cmsis-update/src/dl_pdsc.rs use std::path::PathBuf; use failure::Error; use futures::prelude::*; use hyper::{Body, Client, Uri}; use hyper::client::Connect; use slog::Logger; use pack_index::{PdscRef}; use pack_index::config::Config; <|fim_suffix|>...
code_fim
hard
{ "lang": "rust", "repo": "theotherjimmy/cmsis-pack-manager", "path": "/rust/cmsis-update/src/dl_pdsc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn into_fd(&self, config: &Config) -> PathBuf { let &PdscRef {ref vendor, ref name, ref version, ..} = self; let mut filename = config.pack_store.clone(); let pdscname = format!("{}.{}.{}.pdsc", vendor, name, version); filename.push(pdscname); filename } } ...
code_fim
hard
{ "lang": "rust", "repo": "theotherjimmy/cmsis-pack-manager", "path": "/rust/cmsis-update/src/dl_pdsc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TerminalStudio/nativeshell path: /nativeshell/src/shell/platform/win32/window_base.rs sult<()> where F: FnOnce() + 'static, { unsafe { ShowWindow(self.hwnd, SW_SHOW); // false is not an error } callback(); Ok(()) } pub fn set_g...
code_fim
hard
{ "lang": "rust", "repo": "TerminalStudio/nativeshell", "path": "/nativeshell/src/shell/platform/win32/window_base.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let min_content = &*self.min_content_size.borrow() + &size_delta; let min_content: ISize = min_content.scaled(scale).into(); let min_frame = self.min_frame_size.borrow(); let min_frame: ISize = min_frame.scaled(scale).into(); let min_size = ISize::wh( ...
code_fim
hard
{ "lang": "rust", "repo": "TerminalStudio/nativeshell", "path": "/nativeshell/src/shell/platform/win32/window_base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn do_hit_test(&self, x: i32, y: i32) -> u32 { let mut win_rect = RECT::default(); unsafe { GetWindowRect(self.hwnd, &mut win_rect as *mut _); } let border_width = (7.0 * self.get_scaling_factor()) as i32; if x < win_rect.left + border_width && y <...
code_fim
hard
{ "lang": "rust", "repo": "TerminalStudio/nativeshell", "path": "/nativeshell/src/shell/platform/win32/window_base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> f.debug_struct("MustFuture").finish() } } /// BoxFutures cannot be marked must_use because they are just type definitions. /// This newtype struct wraps a BoxFuture with something that can be marked must_use. #[must_use = "futures do nothing unless you `.await` or poll them"] pub struct MustB...
code_fim
hard
{ "lang": "rust", "repo": "neonphog/must_future", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> MustBoxFuture::new(async { "test1" }) } assert_eq!("test1", get_future().await); } #[tokio::test] pub async fn must_box_future_with_must_box() { fn get_future() -> MustBoxFuture<'static, &'static str> { async { "test1" }.must_box() } ...
code_fim
hard
{ "lang": "rust", "repo": "neonphog/must_future", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// fn setup_logging(verbosity: u64) -> Result<(), fern::InitError> { // let mut base_config = fern::Dispatch::new(); // base_config = match verbosity { // 0 => base_config // .level(log::LevelFilter::Info) // .level_for("overly-verbose-target", log::LevelFilter::Wa...
code_fim
hard
{ "lang": "rust", "repo": "ycd/soda", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> error!("{}", message); self.callback(message); } pub fn setLevel(&mut self, verbosity: u8) { match verbosity { 1 => self.level = Level::DEBUG, 2 => self.level = Level::INFO, 3 => self.level = Level::WARNING, _ => { ...
code_fim
hard
{ "lang": "rust", "repo": "ycd/soda", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Sets a new environment variable to check the correct value retrieval from Gura let env_var_name = "env_var_value"; let env_value = "using_env_var"; env::set_var(env_var_name, env_value); let parsed_data = parse(&format!("test: ${}", env_var_name)).unwrap(); assert_eq!(parsed_dat...
code_fim
hard
{ "lang": "rust", "repo": "meltinglava/gura-rs-parser", "path": "/tests/variables.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xiaolang315/json-schema-to-c path: /src/main.rs // use std::process::Command; use std::fs::read_to_string; use std::fs::write; use serde_json::from_str; use serde_json::{Value}; <|fim_suffix|>}All ; All parser_print(const char* str); "#); write("./src/demo.h", make_str(body)) ...
code_fim
hard
{ "lang": "rust", "repo": "xiaolang315/json-schema-to-c", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>typedef struct All{ char name[100]; int value; }All ; All parser_print(const char* str); "#); write("./src/demo.h", make_str(body)) .unwrap(); } #[test] fn test(){ }<|fim_prefix|>// repo: xiaolang315/json-schema-to-c path: /src/main.rs // use std::process::Command; use st...
code_fim
medium
{ "lang": "rust", "repo": "xiaolang315/json-schema-to-c", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>}All ; All parser_print(const char* str); "#); write("./src/demo.h", make_str(body)) .unwrap(); } #[test] fn test(){ }<|fim_prefix|>// repo: xiaolang315/json-schema-to-c path: /src/main.rs // use std::process::Command; use std::fs::read_to_string; use std::fs::write; use serde_js...
code_fim
hard
{ "lang": "rust", "repo": "xiaolang315/json-schema-to-c", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gijs/t-rex path: /src/cache/filecache.rs // // Copyright (c) Pirmin Kalberer. All rights reserved. // Licensed under the MIT License. See LICENSE file in the project root for full license information. // use cache::cache::Cache; use std::fs::{self,File}; use std::io::{self,Read,Write}; use std:...
code_fim
hard
{ "lang": "rust", "repo": "gijs/t-rex", "path": "/src/cache/filecache.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_file() { use std::env; let mut dir = env::temp_dir(); dir.push("t_rex_test"); let basepath = format!("{}", &dir.display()); fs::remove_dir_all(&basepath); let cache = Filecache { basepath: basepath }; assert_eq!(cache.dir("tileset", 1, 2, 0), format!("{}/{}", ...
code_fim
hard
{ "lang": "rust", "repo": "gijs/t-rex", "path": "/src/cache/filecache.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!( "[{}] {:<5} {}", time::now().strftime("%F %T").unwrap(), record.level(), record.args() ); } fn flush(&self) {} }<|fim_prefix|>// repo: jbudding/xdns path: /src/logger.rs use log::{LevelFilter, Metadata, Record, SetLoggerEr...
code_fim
medium
{ "lang": "rust", "repo": "jbudding/xdns", "path": "/src/logger.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbudding/xdns path: /src/logger.rs use log::{LevelFilter, Metadata, Record, SetLoggerError}; static LOGGER: Logger = Logger; pub fn init() -> Result<(), SetLoggerError> { log::set_logger(&LOGGER).map(|()| log::set_max_level(LevelFilter::Trace)) } <|fim_suffix|> println!( ...
code_fim
medium
{ "lang": "rust", "repo": "jbudding/xdns", "path": "/src/logger.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>struct Logger; impl log::Log for Logger { fn enabled(&self, _: &Metadata) -> bool { true } fn log(&self, record: &Record) { println!( "[{}] {:<5} {}", time::now().strftime("%F %T").unwrap(), record.level(), record.args() ...
code_fim
medium
{ "lang": "rust", "repo": "jbudding/xdns", "path": "/src/logger.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); // } } enum Platform { Windows, Mac, Linux, } fn get_platform() -> Platform { match env::var("TARGET").unwrap().split('-').nth(2).unwrap() { "win32" | "windows" => P...
code_fim
hard
{ "lang": "rust", "repo": "peter-suggate/cef-sys", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..8 { let key = Keys::from_primitive(Keys::Number1.to_primitive() + i); if let Some(key) = key { s.push(KeyboardShortcut { key: KeyboardShortcutKey::CtrlKey(key), command_description: format!("Select Scene {}...
code_fim
hard
{ "lang": "rust", "repo": "rudib/axess", "path": "/axess_gui/src/windows/keyboard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }