text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: tatmanblue/copper path: /src/output/html_generator.rs //! generates an html page using OrganizedTestResults (the output of cargo test) //! http://siciarz.net/24-days-rust-tera/ use std::fs::File; use std::io::Write; use tera::{Context, Tera}; use output::output_trait::OutputTrait; use process...
code_fim
hard
{ "lang": "rust", "repo": "tatmanblue/copper", "path": "/src/output/html_generator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> trace!("templates expected at: '{}'", template_search); let tera: Tera = Tera::new(&template_search).unwrap(); let mut context: Context = Context::new(); context.insert("project_name", &env.get_working_dir_short_name()); context.insert("title", &"test results"); ...
code_fim
hard
{ "lang": "rust", "repo": "tatmanblue/copper", "path": "/src/output/html_generator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[error("failed to parse shell given {0}")] BadShellCommand(#[from] shell_words::ParseError), } impl GitMitError { pub(crate) fn new_io(source: String, error: &std::io::Error) -> GitMitError { GitMitError::Io(source, format!("{}", error)) } pub(crate) fn new_exec(source: Str...
code_fim
hard
{ "lang": "rust", "repo": "Justin-Schmitz/git-mit", "path": "/git-mit/src/errors.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>windows"))] #[error("failed to calculate config directory {0}")] Xdg(#[from] xdg::BaseDirectoriesError), #[error("failed to parse mit author config {0}")] AuthorConfigParse(#[from] mit::AuthorConfigParseError), #[error("failed to set mit in vcs {0}")] AuthorVcs(#[from] mit::VcsErro...
code_fim
hard
{ "lang": "rust", "repo": "Justin-Schmitz/git-mit", "path": "/git-mit/src/errors.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Justin-Schmitz/git-mit path: /git-mit/src/errors.rs use std::string; use thiserror::Error; use mit_commit_message_lints::{external, mit}; #[derive(Error, Debug)] pub enum GitMitError { #[error("failed convert to unicode: {0}")] Utf8(#[from] string::FromUtf8Error), #[error("failed ...
code_fim
hard
{ "lang": "rust", "repo": "Justin-Schmitz/git-mit", "path": "/git-mit/src/errors.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dlrobertson/rust-libp2p path: /protocols/kad/src/topology.rs // Copyright 2018 Parity Technologies (UK) Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software with...
code_fim
hard
{ "lang": "rust", "repo": "dlrobertson/rust-libp2p", "path": "/protocols/kad/src/topology.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// TODO: stupid idea to implement on `MemoryTopology` impl KademliaTopology for MemoryTopology { type ClosestPeersIter = vec::IntoIter<PeerId>; type GetProvidersIter = vec::IntoIter<PeerId>; fn add_kad_discovered_address(&mut self, peer: PeerId, addr: Multiaddr, _: KadConnectionType) { ...
code_fim
hard
{ "lang": "rust", "repo": "dlrobertson/rust-libp2p", "path": "/protocols/kad/src/topology.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebookexperimental/rust-shed path: /shed/fbthrift_ext/adapters/lib.rs /* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Ver...
code_fim
hard
{ "lang": "rust", "repo": "facebookexperimental/rust-shed", "path": "/shed/fbthrift_ext/adapters/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[doc(inline)] pub use crate::duration::*; #[doc(inline)] pub use crate::nonnegative::NonNegativeAdapter; #[doc(inline)] pub use crate::ordered_float::OrderedFloatAdapter; #[doc(inline)] pub use crate::path::Utf8PathAdapter; #[doc(inline)] pub use crate::unsigned_int::UnsignedIntAdapter; #[doc(inline)] pu...
code_fim
hard
{ "lang": "rust", "repo": "facebookexperimental/rust-shed", "path": "/shed/fbthrift_ext/adapters/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: d3n972/getup path: /src/units.rs use ini::Ini; use lazy_static::lazy_static; use nix::errno::Errno::{EINVAL, EPERM, ESRCH}; use nix::sys::signal::{kill, Signal}; use nix::unistd::Pid; use nix::Error::Sys; use serde::Serialize; use serde_json; use std::io; use std::path::Path; use std::process::{...
code_fim
hard
{ "lang": "rust", "repo": "d3n972/getup", "path": "/src/units.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // We use Option and Arc here because these values can be None and we need // to Read these values through multiple threads and might need sharing, // because of which, we need some sort of reference counting structure. /// Start this unit file after the service file for after is started. ...
code_fim
hard
{ "lang": "rust", "repo": "d3n972/getup", "path": "/src/units.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::name::ExtName; pub use self::function::{ExtFn, ExtObjectPool}; pub use self::types::ExtType; pub use self::module::ExtModule; pub use self::invocation::ExtInvocation; pub use self::interp::ExtInterp;<|fim_prefix|>// repo: atthecodeface/picointerp path: /picointerp/src/external/mod.rs /*a Co...
code_fim
hard
{ "lang": "rust", "repo": "atthecodeface/picointerp", "path": "/picointerp/src/external/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atthecodeface/picointerp path: /picointerp/src/external/mod.rs /*a Copyright 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 http://www.apache.org/licenses/LICENSE-2.0 <|...
code_fim
hard
{ "lang": "rust", "repo": "atthecodeface/picointerp", "path": "/picointerp/src/external/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nmusatti/pokedex path: /src/api.rs use rocket::{get, http::Status, response::status::Custom, serde::json::Json, Either}; use crate::{ backend::backend, error::Error, model::{Mode, Pokemon}, }; async fn process(name: &str, mode: Mode) -> Either<Json<Pokemon>, Custom<String>> { l...
code_fim
medium
{ "lang": "rust", "repo": "nmusatti/pokedex", "path": "/src/api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[get("/translated/<name>")] pub(crate) async fn translated(name: &str) -> Either<Json<Pokemon>, Custom<String>> { process(name, Mode::Translated).await }<|fim_prefix|>// repo: nmusatti/pokedex path: /src/api.rs use rocket::{get, http::Status, response::status::Custom, serde::json::Json, Either}; us...
code_fim
hard
{ "lang": "rust", "repo": "nmusatti/pokedex", "path": "/src/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kornelski/rust-lcms2 path: /src/namedcolorlist.rs use crate::*; use foreign_types::ForeignTypeRef; use std::ffi::{CStr, CString}; use std::fmt; use std::os::raw::c_char; use std::ptr; #[derive(Clone, Debug, Eq, PartialEq)] /// Color in the palette pub struct NamedColorInfo { pub name: Strin...
code_fim
hard
{ "lang": "rust", "repo": "kornelski/rust-lcms2", "path": "/src/namedcolorlist.rs", "mode": "psm", "license": "MIT-0", "source": "the-stack-v2" }
<|fim_suffix|> /// Find color by name fn index_of(&self, color_name: &str) -> usize { let s = CString::new(color_name).unwrap(); unsafe { ffi::cmsNamedColorIndex(self.as_ptr(), s.as_ptr()) as usize } } /// Get color info fn get(&self, index: usize) -> Option<NamedColorInfo> { ...
code_fim
hard
{ "lang": "rust", "repo": "kornelski/rust-lcms2", "path": "/src/namedcolorlist.rs", "mode": "spm", "license": "MIT-0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rklaehn/sorted-iter path: /examples/relational.rs extern crate maplit; extern crate sorted_iter; <|fim_suffix|> let city = btreemap! { 1 => "New York", 2 => "Tokyo", }; let country = btreemap! { 1 => "USA", 2 => "Japan", }; let res: Vec<_> = ci...
code_fim
medium
{ "lang": "rust", "repo": "rklaehn/sorted-iter", "path": "/examples/relational.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let city = btreemap! { 1 => "New York", 2 => "Tokyo", }; let country = btreemap! { 1 => "USA", 2 => "Japan", }; let res: Vec<_> = city.iter().join(country.iter()).collect(); println!("{:?}", res); }<|fim_prefix|>// repo: rklaehn/sorted-iter path: /e...
code_fim
easy
{ "lang": "rust", "repo": "rklaehn/sorted-iter", "path": "/examples/relational.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qbit-org-ua/2018-KhCup-I-am-robot path: /lines-checker/src/main.rs use std::env; use std::iter; use std::path::PathBuf; extern crate env_logger; #[macro_use] extern crate log; #[macro_use] extern crate failure; use failure::ResultExt; extern crate lines_game_engine; use lines_game_engine::{Gam...
code_fim
hard
{ "lang": "rust", "repo": "qbit-org-ua/2018-KhCup-I-am-robot", "path": "/lines-checker/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let expected_game_score = self.expected_game_score(); if game_score < expected_game_score { return CheckerVerdict::WrongAnswer(format!( "The expected game score ({}) is not reached ({})", expected_game_score, game_score )...
code_fim
hard
{ "lang": "rust", "repo": "qbit-org-ua/2018-KhCup-I-am-robot", "path": "/lines-checker/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut l = Deque::new(); let t10 = l.push_front(10u8); let r = l.remove(&t10); assert_eq!(Some(10), r); } #[test] fn push_remove_front_get_is_none() { let mut l = Deque::new(); let t10 = l.push_front(10u8); let r = l.get_front(); ...
code_fim
hard
{ "lang": "rust", "repo": "sw17ch/token_deque", "path": "/src/deque.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sw17ch/token_deque path: /src/deque.rs // Index of the first element on the free list. MAX when the // free-list is empty. free_list: usize, // The index of the front of the deque. MAX when the deque is empty. pub(crate) front: usize, // The index of the back of the deque. ...
code_fim
hard
{ "lang": "rust", "repo": "sw17ch/token_deque", "path": "/src/deque.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Get a mutable reference to the item associted with `token`. If /// the item has been removed, then `None` will be returned. /// /// # Examples /// /// ``` /// use token_deque::Deque; /// /// let mut l = Deque::new(); /// let tok = l.push_front(10); /// /...
code_fim
hard
{ "lang": "rust", "repo": "sw17ch/token_deque", "path": "/src/deque.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // init_export_config() let output_ext = crate::CONFIG.get_str("extensions/output_file"); let convert_ext = crate::CONFIG.get_str("document_export/output_extension"); let convert_tool = crate::CONFIG.get_str("document_export/convert_tool"); let output_folder = util::get_valid_pat...
code_fim
hard
{ "lang": "rust", "repo": "ascii-dresden/asciii", "path": "/src/document_export/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // ok, so apparently we can create a tex file, so lets do it if !defy && document_file.exists() && file_age(&tex_file)? < file_age(&project_file)? { // no wait, nothing has changed, so lets save ourselves the work use std::ffi::OsStr; log::info!("Nothing...
code_fim
hard
{ "lang": "rust", "repo": "ascii-dresden/asciii", "path": "/src/document_export/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ascii-dresden/asciii path: /src/document_export/mod.rs //! Fills export templates to create tex documents. //! //! Haven't decided on a templating engine yet, my own will probably not do. use std::{time,fs}; use std::path::{Path, PathBuf}; use serde::ser::Serialize; use anyhow::{bail, Error}; ...
code_fim
hard
{ "lang": "rust", "repo": "ascii-dresden/asciii", "path": "/src/document_export/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Checks if a given user is banned. pub fn is_banned(&self, user: &UserUuid) -> bool { self.0.read().unwrap().contains(user) } } pub fn banned_list_filter(banned_list: BannedList) -> BoxedFilter<(BannedList,)> { warp::any().map(move || banned_list.clone()).boxed() }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "thienpow/FullstackRustDemo", "path": "/backend/warp_server/src/state/banned_list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl BannedList { /// Bans the user from this server. pub fn ban(&self, user: UserUuid) { self.0.write().unwrap().insert(user); } /// Unbans the user from this server. pub fn unban(&self, user: &UserUuid) { self.0.write().unwrap().remove(user); } /// Checks if...
code_fim
hard
{ "lang": "rust", "repo": "thienpow/FullstackRustDemo", "path": "/backend/warp_server/src/state/banned_list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thienpow/FullstackRustDemo path: /backend/warp_server/src/state/banned_list.rs use identifiers::user::UserUuid; use std::{ collections::BTreeSet, sync::{ Arc, RwLock, }, }; use warp::{ filters::BoxedFilter, Filter, }; /// The BannedList contains a list of use...
code_fim
medium
{ "lang": "rust", "repo": "thienpow/FullstackRustDemo", "path": "/backend/warp_server/src/state/banned_list.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.deserialize()) .unwrap_or_else(|e| e.exit()); for arg in &args.arg_file { let path = Path::new(&arg); print_lines(&path, &args); } }<|fim_prefix|>// repo: hhatto/...
code_fim
hard
{ "lang": "rust", "repo": "hhatto/rust-snippets", "path": "/parse-cmdline-option/src/cat-docopt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hhatto/rust-snippets path: /parse-cmdline-option/src/cat-docopt.rs #[macro_use] extern crate serde; extern crate docopt; use docopt::Docopt; use std::io::BufReader; use std::io::prelude::*; use std::error::Error; use std::fs::File; use std::path::Path; static USAGE: &'static str = " cat Usage:...
code_fim
hard
{ "lang": "rust", "repo": "hhatto/rust-snippets", "path": "/parse-cmdline-option/src/cat-docopt.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] struct Args { flag_b: bool, flag_n: bool, arg_file: Vec<String>, } fn print_lines(path: &Path, opt: &Args) { let display = path.display(); let f = match File::open(&path) { Err(why) => panic!("could not open {}: {}", display, Error::description(&w...
code_fim
medium
{ "lang": "rust", "repo": "hhatto/rust-snippets", "path": "/parse-cmdline-option/src/cat-docopt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WadeBarnes/aries-askar path: /src/db_utils.rs use std::future::Future; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::sync::Arc; use sqlx::{ database::HasArguments, pool::PoolConnection, Arguments, Database, Encode, IntoArguments, Pool, TransactionManager, Type,...
code_fim
hard
{ "lang": "rust", "repo": "WadeBarnes/aries-askar", "path": "/src/db_utils.rs", "mode": "psm", "license": "LicenseRef-scancode-dco-1.1", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) async fn close(mut self, commit: bool) -> Result<()> { if self.transaction { if let Some(conn) = self.connection_mut() { if commit { info!("Commit transaction on close"); DB::TransactionManager::commit(conn).await ...
code_fim
hard
{ "lang": "rust", "repo": "WadeBarnes/aries-askar", "path": "/src/db_utils.rs", "mode": "spm", "license": "LicenseRef-scancode-dco-1.1", "source": "the-stack-v2" }
<|fim_suffix|>pub struct QueryParams<'q, DB: Database> { args: <DB as HasArguments<'q>>::Arguments, count: usize, } impl<'q, DB: Database> QueryParams<'q, DB> { pub fn new() -> Self { Self { args: Default::default(), count: 0, } } pub fn extend<I, T>(&mut se...
code_fim
hard
{ "lang": "rust", "repo": "WadeBarnes/aries-askar", "path": "/src/db_utils.rs", "mode": "spm", "license": "LicenseRef-scancode-dco-1.1", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EmbarkStudios/rust-gpu path: /tests/ui/arch/all_memory_barrier_with_group_sync.rs // build-pass // compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model // compile-flags: -C llvm-args=--disassemble-fn=all_memory_barrier_with_group_sync::all_memory_bar...
code_fim
medium
{ "lang": "rust", "repo": "EmbarkStudios/rust-gpu", "path": "/tests/ui/arch/all_memory_barrier_with_group_sync.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>unsafe fn all_memory_barrier_with_group_sync() { spirv_std::arch::all_memory_barrier_with_group_sync(); } #[spirv(compute(threads(1, 1, 1)))] pub fn main() { unsafe { all_memory_barrier_with_group_sync(); } }<|fim_prefix|>// repo: EmbarkStudios/rust-gpu path: /tests/ui/arch/all_memor...
code_fim
easy
{ "lang": "rust", "repo": "EmbarkStudios/rust-gpu", "path": "/tests/ui/arch/all_memory_barrier_with_group_sync.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl SVGWrapper { /// Displays the contents of the `SVGWrapper` struct. pub fn evcxr_display(&self) { println!("{:?}", self); } /// Sets the style of the `SVGWrapper` struct. pub fn style<S: Into<String>>(mut self, style: S) -> Self { self.1 = style.into(); self...
code_fim
medium
{ "lang": "rust", "repo": "plotters-rs/plotters", "path": "/plotters/src/evcxr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plotters-rs/plotters path: /plotters/src/evcxr.rs use crate::coord::Shift; use crate::drawing::{DrawingArea, IntoDrawingArea}; use plotters_backend::DrawingBackend; use plotters_svg::SVGBackend; #[cfg(feature = "evcxr_bitmap")] use plotters_bitmap::BitMapBackend; /// The wrapper for the genera...
code_fim
hard
{ "lang": "rust", "repo": "plotters-rs/plotters", "path": "/plotters/src/evcxr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_octal_literal() -> Result<(), Box<EvalAltResult>> { let engine = Engine::new(); assert_eq!(engine.eval::<INT>("let x = 0o77; x")?, 63); assert_eq!(engine.eval::<INT>("let x = 0O77; x")?, 63); assert_eq!(engine.eval::<INT>("let x = 0o1234; x")?, 668); Ok(()) } #[test]...
code_fim
hard
{ "lang": "rust", "repo": "Eliah-Lakhin/rhai", "path": "/tests/number_literals.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Eliah-Lakhin/rhai path: /tests/number_literals.rs use rhai::{Engine, EvalAltResult, INT}; #[test] fn test_number_literal() -> Result<(), Box<EvalAltResult>> { let engine = Engine::new(); assert_eq!(engine.eval::<INT>("65")?, 65); Ok(()) } #[test] fn test_hex_literal() -> Result<(...
code_fim
medium
{ "lang": "rust", "repo": "Eliah-Lakhin/rhai", "path": "/tests/number_literals.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } #[test] fn test_octal_literal() -> Result<(), Box<EvalAltResult>> { let engine = Engine::new(); assert_eq!(engine.eval::<INT>("let x = 0o77; x")?, 63); assert_eq!(engine.eval::<INT>("let x = 0O77; x")?, 63); assert_eq!(engine.eval::<INT>("let x = 0o1234; x")?, 668); Ok(...
code_fim
hard
{ "lang": "rust", "repo": "Eliah-Lakhin/rhai", "path": "/tests/number_literals.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: weoking/flavors path: /fuzz/fuzzers/header.rs #![no_main] extern crate libfuzzer_sys; extern crate flavors; <|fim_suffix|>#[export_name="rust_fuzzer_test_input"] pub extern fn go(data: &[u8]) { let header_result = header(data); }<|fim_middle|>use flavors::parser::header;
code_fim
easy
{ "lang": "rust", "repo": "weoking/flavors", "path": "/fuzz/fuzzers/header.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[export_name="rust_fuzzer_test_input"] pub extern fn go(data: &[u8]) { let header_result = header(data); }<|fim_prefix|>// repo: weoking/flavors path: /fuzz/fuzzers/header.rs #![no_main] extern crate libfuzzer_sys; extern crate flavors; <|fim_middle|>use flavors::parser::header;
code_fim
easy
{ "lang": "rust", "repo": "weoking/flavors", "path": "/fuzz/fuzzers/header.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joscha/dprint path: /crates/dprint/src/cli/run_cli.rs assert_eq!(environment.take_logged_errors().len(), 0); assert_eq!(environment.read_file(&file_path).unwrap(), "text_formatted"); assert_eq!(environment.read_file(&file_path2).unwrap(), "text"); } #[test] fn it_should_ignore_fi...
code_fim
hard
{ "lang": "rust", "repo": "joscha/dprint", "path": "/crates/dprint/src/cli/run_cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joscha/dprint path: /crates/dprint/src/cli/run_cli.rs "); } #[test] fn it_should_override_config_includes_and_excludes_with_cli() { let file_path1 = "/file1.txt"; let file_path2 = "/file2.txt"; let environment = TestEnvironmentBuilder::with_remote_wasm_plugin() .write_fi...
code_fim
hard
{ "lang": "rust", "repo": "joscha/dprint", "path": "/crates/dprint/src/cli/run_cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(communicator.check_file(&txt_file_path).unwrap(), true); assert_eq!(communicator.check_file(&PathBuf::from("/non-existent.txt")).unwrap(), true); assert_eq!(communicator.check_file(&other_ext_path).unwrap(), false); assert_eq!(communicator.check_file(&ts_file_pat...
code_fim
hard
{ "lang": "rust", "repo": "joscha/dprint", "path": "/crates/dprint/src/cli/run_cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thedanieljun/2dgames-in-rust path: /2dgames-jorge-danny-cynthia/src/bin/flappy/main.rs if input_events.update(&event) { // Close events if input_events.key_pressed(VirtualKeyCode::Escape) || input_events.quit() { *control_flow = ...
code_fim
hard
{ "lang": "rust", "repo": "thedanieljun/2dgames-in-rust", "path": "/2dgames-jorge-danny-cynthia/src/bin/flappy/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { animation_data: vec![ // bird glide (pigeon.png) Rc::new(AnimationData { frames: vec![(Rect::new(0.0, 0.0, 20.0, 17.0), 1)], looping: false, }), // bird flap R...
code_fim
hard
{ "lang": "rust", "repo": "thedanieljun/2dgames-in-rust", "path": "/2dgames-jorge-danny-cynthia/src/bin/flappy/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thedanieljun/2dgames-in-rust path: /2dgames-jorge-danny-cynthia/src/bin/flappy/main.rs e::Play; state.last_flap_noise = Instant::now(); state.player.x = 30.0; state.player.y = HEIGHT as f32 / 2.0 - 10.0; ...
code_fim
hard
{ "lang": "rust", "repo": "thedanieljun/2dgames-in-rust", "path": "/2dgames-jorge-danny-cynthia/src/bin/flappy/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> cont = current_marble != final_marble_worth; current_marble += 1; current_player = mod_add(current_player, 1, total_players); } let (_, winning_score) = player_scores.iter().max_by_key(|(_, &v)| v).unwrap(); println!("Winning score: {}", winning_score); } fn rotate_...
code_fim
hard
{ "lang": "rust", "repo": "mrdrbob/aoc-2018", "path": "/src/day9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mrdrbob/aoc-2018 path: /src/day9.rs use std::collections::VecDeque; use std::collections::HashMap; pub fn execute() { // too lazy to parse the input, deal with it. // /* let total_players:usize = 427; let final_marble_worth = 70723 * 100; // */ /* let total_players:u...
code_fim
hard
{ "lang": "rust", "repo": "mrdrbob/aoc-2018", "path": "/src/day9.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn rotate_back(mut queue:VecDeque<i64>, count:i32) -> VecDeque<i64> { for _ in 0..count { let value = queue.pop_front().expect("rotate back value"); queue.push_back(value); } queue } fn rotate_forward(mut queue:VecDeque<i64>, count:i32) -> VecDeque<i64> { for _ in 0..count...
code_fim
hard
{ "lang": "rust", "repo": "mrdrbob/aoc-2018", "path": "/src/day9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn warning<'a>(props: WarningProps) -> Element<'a, AllStates> { match props.percent { x if x <= 0 => { Element::Node(Node::new(50, 27).set_text(Some("Can't go lower than 0!".to_string()))) } x if x >= 100 => { Element::Node(Node::new(50, 27).set_text...
code_fim
medium
{ "lang": "rust", "repo": "netgusto/reactive-rust-experiment", "path": "/src/components/warning.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: netgusto/reactive-rust-experiment path: /src/components/warning.rs use crate::lib::{Element, Node}; use crate::AllStates; <|fim_suffix|>pub fn warning<'a>(props: WarningProps) -> Element<'a, AllStates> { match props.percent { x if x <= 0 => { Element::Node(Node::new(50, ...
code_fim
medium
{ "lang": "rust", "repo": "netgusto/reactive-rust-experiment", "path": "/src/components/warning.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raftario/wae path: /src/task/util.rs use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; use winapi::{shared::minwindef::TRUE, um::threadpoolapiset::CallbackMayRunLong}; use crate::threadpool::Handle; impl Handle { pub fn may_block(&self) -> bool { match sel...
code_fim
medium
{ "lang": "rust", "repo": "raftario/wae", "path": "/src/task/util.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if !self.0 { self.0 = true; cx.waker().wake_by_ref(); Poll::Pending } else { Poll::Ready(()) } } } #[inline] pub async fn yield_now() { YieldNow(false).await }<|fim_prefix|>// repo: raftario/wae path: /src/task/util.rs use s...
code_fim
hard
{ "lang": "rust", "repo": "raftario/wae", "path": "/src/task/util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn pow(self, rhs: BigUint) -> Self::Output { Self(self.0.modpow(&rhs, &N::value()), PhantomData) } } impl<N: BigPrime> Product for Zn<N> { fn product<I: Iterator<Item = Self>>(iter: I) -> Self { iter.into_iter().fold(Self::one(), Self::mul) } } impl<N: BigPrime> Inv for Z...
code_fim
hard
{ "lang": "rust", "repo": "TurtlePU/elliptic", "path": "/src/algebra/fields/zn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TurtlePU/elliptic path: /src/algebra/fields/zn.rs use std::{array::TryFromSliceError, convert::{TryFrom, TryInto}, iter::{Product, Sum}, marker::PhantomData, ops::{Add, Div, Mul, Neg, Sub}}; use num_bigint::{BigInt, BigUint}; use num_traits::{Inv, One, Pow, Zero}; use rand::{distributions::Stan...
code_fim
hard
{ "lang": "rust", "repo": "TurtlePU/elliptic", "path": "/src/algebra/fields/zn.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<N: BigPrime> Sqrt for Zn<N> { fn sqrt(self) -> Option<Self> { let deg = (N::value() + BigUint::one()) >> 2; let sqrt = self.clone().pow(deg); if sqrt.clone() * sqrt.clone() == self { Some(Self::from(sqrt)) } else { None } } } im...
code_fim
hard
{ "lang": "rust", "repo": "TurtlePU/elliptic", "path": "/src/algebra/fields/zn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johnfercher/rust-web-example path: /src/main.rs #[macro_use] extern crate envconfig_derive; extern crate envconfig; #[macro_use] extern crate slog; extern crate actix_web; #[macro_use] extern crate failure; extern crate reqwest; #[macro_use] extern crate serde_derive; extern crate serde; extern ...
code_fim
medium
{ "lang": "rust", "repo": "johnfercher/rust-web-example", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct AppState { log: slog::Logger, } fn main() { let log = logging::setup_logging(); info!(log, "Server Started on localhost:8080"); server::new(move || { App::with_state(AppState { log: log.clone(), }) .scope("/rest/v1", |v1_scop...
code_fim
medium
{ "lang": "rust", "repo": "johnfercher/rust-web-example", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> } pub fn new() -> Reactor { Reactor { selector: PollSelector::new() } } }<|fim_prefix|>// repo: hahn-w/reactor path: /src/core.rs use crate::descriptor::{ReadDescriptor, DescriptorCollect, FileDescriptor}; use crate::selector::{Selector, PollSelector}; use crate::...
code_fim
hard
{ "lang": "rust", "repo": "hahn-w/reactor", "path": "/src/core.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hahn-w/reactor path: /src/core.rs use crate::descriptor::{ReadDescriptor, DescriptorCollect, FileDescriptor}; use crate::selector::{Selector, PollSelector}; use crate::event::{Event}; use std::convert::AsMut; pub type add_event = fn(Event); pub struct Reactor { pub selector: Box<dyn Selec...
code_fim
medium
{ "lang": "rust", "repo": "hahn-w/reactor", "path": "/src/core.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>feasible to store on one's person. pub struct Item {}<|fim_prefix|>// repo: aschuhardt/Finniko path: /src/game/item.rs /// Stores information about a single item in the game's current state. //// /// An item in this case is a<|fim_middle|>nything that can be used and/or examined, /// and is
code_fim
easy
{ "lang": "rust", "repo": "aschuhardt/Finniko", "path": "/src/game/item.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aschuhardt/Finniko path: /src/game/item.rs /// Stores information about a single item in the game's current state. //// /// An item in this case is a<|fim_suffix|>feasible to store on one's person. pub struct Item {}<|fim_middle|>nything that can be used and/or examined, /// and is
code_fim
easy
{ "lang": "rust", "repo": "aschuhardt/Finniko", "path": "/src/game/item.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args: Vec<_> = env::args().collect(); let hostfile = Hostfile::new(&PathBuf::from(&args[1])); let mut ctrl_serv = ControlServer::new(hostfile); ctrl_serv.runloop(); }<|fim_prefix|>// repo: peterhj/hydra path: /tools/hydra-ctrld.rs extern crate hydra; use hydra::control::{ControlServer}; use ...
code_fim
easy
{ "lang": "rust", "repo": "peterhj/hydra", "path": "/tools/hydra-ctrld.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peterhj/hydra path: /tools/hydra-ctrld.rs extern crate hydra; use hydra::control::{ControlServer}; use hydra::hosts::{Hostfile}; //use hydra::server::{ResourceCacheConfig}; //use hydra::worker::{WorkerServer}; <|fim_suffix|> let args: Vec<_> = env::args().collect(); let hostfile = Hostfile:...
code_fim
easy
{ "lang": "rust", "repo": "peterhj/hydra", "path": "/tools/hydra-ctrld.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod frame; mod physaddr; mod frame_allocator;<|fim_prefix|>// repo: ivanium/RustOS path: /crate/memory/src/physical/mod.rs pub use self::physaddr::PhysAddr; pub use self::frame::Frame; pub use self::frame_allocator::FrameAllocator; <|fim_middle|>use super::*;
code_fim
easy
{ "lang": "rust", "repo": "ivanium/RustOS", "path": "/crate/memory/src/physical/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivanium/RustOS path: /crate/memory/src/physical/mod.rs pub use self::physaddr::PhysAddr; pub use self::frame::Frame; pub use self::frame_allocator::FrameAllocator; <|fim_suffix|>mod frame; mod physaddr; mod frame_allocator;<|fim_middle|>use super::*;
code_fim
easy
{ "lang": "rust", "repo": "ivanium/RustOS", "path": "/crate/memory/src/physical/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("max seat ID = {}", seat_ids.iter().max().unwrap()); println!("gapped seat ID = {}", gapped_seat_id) }<|fim_prefix|>// repo: jgoldschrafe/advent-of-code path: /2020/day-5/src/main.rs use itertools::Itertools; use std::io; use std::io::prelude::*; fn calculate_seat_id(ops: &String) -> Op...
code_fim
medium
{ "lang": "rust", "repo": "jgoldschrafe/advent-of-code", "path": "/2020/day-5/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let seat_ids: Vec<i32> = io::stdin().lock() .lines() .map(|line| line.unwrap()) .filter_map(|ops| calculate_seat_id(&ops)) .collect(); let gapped_seat_id = find_missing_seat(&seat_ids).unwrap(); println!("max seat ID = {}", seat_ids.iter().max().unwrap());...
code_fim
medium
{ "lang": "rust", "repo": "jgoldschrafe/advent-of-code", "path": "/2020/day-5/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgoldschrafe/advent-of-code path: /2020/day-5/src/main.rs use itertools::Itertools; use std::io; use std::io::prelude::*; fn calculate_seat_id(ops: &String) -> Option<i32> { let binary_str = ops .replace("F", "0") .replace("B", "1") .replace("L", "0") .replac...
code_fim
hard
{ "lang": "rust", "repo": "jgoldschrafe/advent-of-code", "path": "/2020/day-5/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn multiple_of_3_are_with_limit_of_10_is_23() { assert_eq!(run(10), 23); }<|fim_prefix|>// repo: rorepoid/project-euler-rust path: /src/problems/problem1.rs pub fn run(limit: u32) -> u32 { multiple_3_and_5(limit).iter().sum() } fn multiple_3_and_5(limit: u32) -> Vec<u32> { let mut re...
code_fim
medium
{ "lang": "rust", "repo": "rorepoid/project-euler-rust", "path": "/src/problems/problem1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rorepoid/project-euler-rust path: /src/problems/problem1.rs pub fn run(limit: u32) -> u32 { multiple_3_and_5(limit).iter().sum() } fn multiple_3_and_5(limit: u32) -> Vec<u32> { <|fim_suffix|> assert_eq!(multiple_3_and_5(10), [3, 5, 6, 9]); } #[test] fn multiple_of_3_are_with_limit_of_10...
code_fim
hard
{ "lang": "rust", "repo": "rorepoid/project-euler-rust", "path": "/src/problems/problem1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xanium4332/combo path: /src/lib.rs //! Small crate containing functionality for iterating over combinations of a sequence. //! //! See documentation of `combinations` function for usage details. #[cfg(test)] use std::collections::BTreeSet; /// An non-standard iterator yielding combinations of ...
code_fim
hard
{ "lang": "rust", "repo": "xanium4332/combo", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns a (non-standard) iterator yielding all combinations of length `len` from /// the sequence `seq`. /// /// Each combination is itself a (standard) `Iterator` yielding references to each element of the /// combination. /// /// # Panics /// When attempting to iterate over combination lengths longe...
code_fim
hard
{ "lang": "rust", "repo": "xanium4332/combo", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Set of all combinations let combos: BTreeSet<BTreeSet<u32>> = [[0, 1, 2].iter().cloned().collect(), [0, 1, 3].iter().cloned().collect(), [0, 2, 3].iter().cloned().collect(), ...
code_fim
hard
{ "lang": "rust", "repo": "xanium4332/combo", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut current_offset = n; match self { &Circuit::Resistor(Resistance(r), Voltage(v), Current(c)) => { s.push_str(&format!( "r{}.\tR: {:.3} Ohms,\tV: {:.3} Volts,\tI: {:.3} Amps\n", n, r, v, c )); ...
code_fim
hard
{ "lang": "rust", "repo": "philipper905/circuit-calculator", "path": "/src/circuits/circuit.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: philipper905/circuit-calculator path: /src/circuits/circuit.rs use super::{Current, Resistance, Voltage}; #[derive(Debug)] pub enum Circuit { Resistor(Resistance, Voltage, Current), Parallel(Box<[Circuit]>, Voltage, Current), Series(Box<[Circuit]>, Voltage, Current), } impl Circuit...
code_fim
hard
{ "lang": "rust", "repo": "philipper905/circuit-calculator", "path": "/src/circuits/circuit.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Cow::from(format!( "soft/value/broadcast_event_a<{}>", type_name::<V>() )) } fn as_runnable(&self) -> &dyn Runnable { self } fn as_signals_device_base(&self) -> &dyn signals::DeviceBase { self } } #[async_trait] impl<V> Runnable...
code_fim
hard
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/devices/soft/value/broadcast_event_a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peku33/logicblocks path: /Controller/src/devices/soft/value/broadcast_event_a.rs use crate::{ devices, signals::{self, signal, types::event::Value}, util::{ async_ext::stream_take_until_exhausted::StreamTakeUntilExhaustedExt, async_flag, runtime::{Exited, Runn...
code_fim
hard
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/devices/soft/value/broadcast_event_a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let my_2 = Num(2); println!("{}", my_2 + Str(" times the love")); println!("still here: {:?}", my_2); }<|fim_prefix|>// repo: Bietola/snippets path: /rust/rust_book/free/funky_op_overload/src/main.rs use std::ops::Add; #[derive(Debug, Clone, Copy)] struct Num(i32); #[derive(Debug)] struct St...
code_fim
medium
{ "lang": "rust", "repo": "Bietola/snippets", "path": "/rust/rust_book/free/funky_op_overload/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bietola/snippets path: /rust/rust_book/free/funky_op_overload/src/main.rs use std::ops::Add; #[derive(Debug, Clone, Copy)] struct Num(i32); #[derive(Debug)] struct Str<'a>(&'a str); impl Add<Str<'_>> for Num { type Output = String; fn add(self, other: Str) -> Self::Output { le...
code_fim
easy
{ "lang": "rust", "repo": "Bietola/snippets", "path": "/rust/rust_book/free/funky_op_overload/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn c_call(to: *const c_char) -> *mut c_char { START.call_once(|| { android_logger::init_once(Config::default().with_min_level(Level::Debug)); }); let input = unsafe { CStr::from_ptr(to) }; info!("<-- ({:?})", input); let output = rust_call(input) ...
code_fim
hard
{ "lang": "rust", "repo": "lvaccaro/firma", "path": "/lib/src/android/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lvaccaro/firma path: /lib/src/android/mod.rs use crate::common::list::ListOptions; use crate::offline::descriptor::DeriveAddressOpts; use crate::offline::dice::DiceOptions; use crate::offline::print::PrintOptions; use crate::offline::random::RandomOptions; use crate::offline::restore::RestoreOpt...
code_fim
hard
{ "lang": "rust", "repo": "lvaccaro/firma", "path": "/lib/src/android/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TyPR124/winping path: /src/async_pinger.rs ICMP handle initialization fails, all ping requests will return /// an error. /// /// # Panics /// /// This may panic if the compile-time environment variable `WINPING_ASYNC_BUFFER_SIZE` /// is set but cannot be parsed to a valid...
code_fim
hard
{ "lang": "rust", "repo": "TyPR124/winping", "path": "/src/async_pinger.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if ret != 0 { let arc = unsafe { Arc::from_raw(arcptr) }; let mut lock = arc.lock().unwrap(); let state = replace(&mut *lock, State::Invalid); match state { State::Unpolled(buf) => *lock = State::FailedAsyncSend(buf, ret), ...
code_fim
hard
{ "lang": "rust", "repo": "TyPR124/winping", "path": "/src/async_pinger.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TyPR124/winping path: /src/async_pinger.rs uffer), Polled(Buffer, Waker), Ready(Buffer), Failed(Buffer, u32), FailedAsyncSend(Buffer, u32), Invalid, } // Expected State Transitions // Initial state: Unpolled // Unpolled -> FailedAsyncSend if IcmpSend* returns unexpected value...
code_fim
hard
{ "lang": "rust", "repo": "TyPR124/winping", "path": "/src/async_pinger.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pendulum-project/ntpd-rs path: /ntp-udp/src/lib.rs //! This crate contains networking and timestamping code for ntpd-rs and is not //! intended as a public interface at this time. It follows the same version as the //! main ntpd-rs crate, but that version is not intended to give any stability //...
code_fim
hard
{ "lang": "rust", "repo": "pendulum-project/ntpd-rs", "path": "/ntp-udp/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { LibcTimestamp::TimeSpec { seconds, nanos } => { // truncates the higher bits of the i64 let seconds = (seconds as u32).wrapping_add(EPOCH_OFFSET); // tv_nsec is always within [0, 1e10) let nanos = nanos as u3...
code_fim
hard
{ "lang": "rust", "repo": "pendulum-project/ntpd-rs", "path": "/ntp-udp/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cmisenas/nand2tetris path: /stack_vm/src/main.rs mod code_writer_module; mod parser_module; mod utils; use crate::code_writer_module::*; use crate::parser_module::*; use crate::utils::*; use std::env; use std::fs; fn get_file_name(filepath: String) -> String { filepath.replace(".vm", ".asm...
code_fim
hard
{ "lang": "rust", "repo": "cmisenas/nand2tetris", "path": "/stack_vm/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut code_writer = CodeWriter::new(); let mut vm_programs: Vec<Vec<String>> = Vec::new(); for vm_file in vm_files.iter() { let vm_program = read_lines(vm_file.to_string()); vm_programs.push(vm_program.clone()); let mut parser = Parser::new(vm_program.clone()); ...
code_fim
hard
{ "lang": "rust", "repo": "cmisenas/nand2tetris", "path": "/stack_vm/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn schedule_at(&self, at: Instant, event: Event) { for producer in self.producers.borrow().iter() { let sender = producer.clone(); let delay = at - Instant::now(); let evt = event.clone(); self.thread_pool.execute_after(delay, move || { ...
code_fim
hard
{ "lang": "rust", "repo": "jintwo/tonic", "path": "/src/scheduler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jintwo/tonic path: /src/scheduler.rs use std::sync::mpsc::{channel, Sender}; use std::time::Instant; use RefCell; use crate::backends::Backend; use crate::event::Event; pub struct Scheduler { thread_pool: scheduled_thread_pool::ScheduledThreadPool, producers: RefCell<Vec<Sender<Event>>...
code_fim
hard
{ "lang": "rust", "repo": "jintwo/tonic", "path": "/src/scheduler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_id(&mut self, id_type: IdType) -> IdSize { let id = match self.map.get(&id_type) { Some(id) => *id, None => 0, }; self.map.insert(id_type, id + 1); id } } pub type IdSize = u64;<|fim_prefix|>// repo: yeliknewo/rs-dorp path: /src/logi...
code_fim
hard
{ "lang": "rust", "repo": "yeliknewo/rs-dorp", "path": "/src/logic/ids.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yeliknewo/rs-dorp path: /src/logic/ids.rs use std::collections::{HashMap}; use std::fmt::{Display, Formatter, Error}; #[derive(Debug, Copy, Clone, Eq, Hash, PartialEq, Ord, PartialOrd)] pub struct Id { id: IdSize, } impl Id { pub fn new(manager: &mut IdManager, id_type: IdType) -> Id ...
code_fim
medium
{ "lang": "rust", "repo": "yeliknewo/rs-dorp", "path": "/src/logic/ids.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] pub struct WVWMapDeaths { pub red: u64, pub green: u64, pub blue: u64, } /// The `WVWMatch` struct represents all associated data related to a World versus World matchup. #[derive(Debug, Deserialize)] pub struct WVWMatch { pub id: WVWMatchId, pub start_ti...
code_fim
hard
{ "lang": "rust", "repo": "Sunspar/gw2rs", "path": "/src/anet/wvw/wvw_match.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sunspar/gw2rs path: /src/anet/wvw/wvw_match.rs use ::prelude::*; gw2rs_id_string!(WVWMatchId); #[derive(Debug, Deserialize)] pub struct WVWMatchScores { pub red: u64, pub green: u64, pub blue: u64, } #[derive(Debug, Deserialize)] pub struct WVWMatchServers { pub red: WorldId, ...
code_fim
hard
{ "lang": "rust", "repo": "Sunspar/gw2rs", "path": "/src/anet/wvw/wvw_match.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }