text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: jaysonsantos/rsdocs2docset path: /src/dom/fixtures.rs
lderOpts { drop_doctype: true, ..Default::default() },
..Default::default()
};
let dom = parse_document(RcDom::default(), opts)
.from_utf8()
.read_from(&mut format!("<html><head></head><bod... | code_fim | hard | {
"lang": "rust",
"repo": "jaysonsantos/rsdocs2docset",
"path": "/src/dom/fixtures.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jaysonsantos/rsdocs2docset path: /src/dom/fixtures.rs
n dom_from_snippet(s: &str) -> RcDom {
let opts = ParseOpts {
tree_builder: TreeBuilderOpts { drop_doctype: true, ..Default::default() },
..Default::default()
};
let dom = parse_document(RcDom::default(), opts)
... | code_fim | hard | {
"lang": "rust",
"repo": "jaysonsantos/rsdocs2docset",
"path": "/src/dom/fixtures.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub unsafe fn sys_write(fd: usize, buf: *const u8, count: usize) -> usize {
return syscall(SYS_WRITE, fd as u32, buf as u32, count as u32) as usize;
}
pub unsafe fn sys_open(path: *const u8, flags: isize, mode: isize) -> usize {
return syscall(SYS_OPEN, path as u32, (flags as i32) as u32, (mode a... | code_fim | hard | {
"lang": "rust",
"repo": "alwayrun/redox",
"path": "/src/syscall/call.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alwayrun/redox path: /src/syscall/call.rs
use common::event::*;
use common::time::*;
use graphics::window::*;
use syscall::common::*;
pub unsafe fn syscall(mut eax: u32, ebx: u32, ecx: u32, edx: u32) -> u32 {
asm!("int 0x80"
: "={eax}"(eax)
: "{eax}"(eax), "{ebx}"(ebx), "{... | code_fim | hard | {
"lang": "rust",
"repo": "alwayrun/redox",
"path": "/src/syscall/call.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = read_file_to_string().unwrap();
let dice_parent: DiceParent = serde_yaml::from_str(&s)?;
println!("Dice parent property val1 = {}", dice_parent.val1.unwrap());
Ok(())
}<|fim_prefix|>// repo: artem-korolev/serde_yaml_back_reference_fails path: /src/main.rs
// FILE READ
use std::fs:... | code_fim | hard | {
"lang": "rust",
"repo": "artem-korolev/serde_yaml_back_reference_fails",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: artem-korolev/serde_yaml_back_reference_fails path: /src/main.rs
// FILE READ
use std::fs::File;
use std::io::Read;
use std::io;
<|fim_suffix|>fn read_file_to_string() -> Result<String, io::Error> {
let mut f = File::open("data.yml")?;
let mut s = String::new();
f.read_to_string(&mu... | code_fim | medium | {
"lang": "rust",
"repo": "artem-korolev/serde_yaml_back_reference_fails",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrcoinzzz/Safecoin path: /cli/src/inflation.rs
use crate::cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult};
use clap::{App, ArgMatches, SubCommand};
use solana_clap_utils::keypair::*;
use solana_cli_output::CliInflation;
use solana_client::rpc_client::RpcClient;
use solana_r... | code_fim | medium | {
"lang": "rust",
"repo": "mrcoinzzz/Safecoin",
"path": "/cli/src/inflation.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn parse_inflation_subcommand(
_matches: &ArgMatches<'_>,
_default_signer: &DefaultSigner,
_wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, CliError> {
Ok(CliCommandInfo {
command: CliCommand::Inflation(InflationCliCommand::Show),
sign... | code_fim | medium | {
"lang": "rust",
"repo": "mrcoinzzz/Safecoin",
"path": "/cli/src/inflation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> vars.get("table_mode")
.map_or(nu_table::Theme::compact(), |mode| match mode.as_string() {
Ok(m) if m == "basic" => nu_table::Theme::basic(),
Ok(m) if m == "compact" => nu_table::Theme::compact(),
Ok(m) if m == "light" => nu_table::Theme::light(),
... | code_fim | hard | {
"lang": "rust",
"repo": "seanwallawalla-forks/nushell",
"path": "/crates/nu-command/src/commands/viewers/table/options.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanwallawalla-forks/nushell path: /crates/nu-command/src/commands/viewers/table/options.rs
pub use nu_data::config::NuConfig;
use nu_data::primitive::lookup_ansi_color_style;
use nu_protocol::Value;
use nu_table::{Alignment, TextStyle};
use std::fmt::Debug;
pub trait ConfigExtensions: Debug + ... | code_fim | hard | {
"lang": "rust",
"repo": "seanwallawalla-forks/nushell",
"path": "/crates/nu-command/src/commands/viewers/table/options.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nbaraz/tricone-lang path: /src/lib.rs
extern crate lalrpop_util;
pub mod ast;
pub mod grammar;
pub mod codegen;
pub mod instruction;
#[cfg(test)]
mod tests {
macro_rules! test_parser {
($parser:expr, $($to_parse:expr => $expected:expr,)*) => {{
let parser = $parser;
... | code_fim | hard | {
"lang": "rust",
"repo": "nbaraz/tricone-lang",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> macro_rules! function {
($name:expr, ($($p:expr),*) $body:expr) => {
Item::Func {
name: ast::Ident($name.to_owned()),
params: vec![$(ast::Ident($p.to_owned())),*],
body: $body,
}
};
}
#[test]
fn test_f... | code_fim | hard | {
"lang": "rust",
"repo": "nbaraz/tricone-lang",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn channel_withdraw_expired(origin, channel: Channel<T::AccountId, T::Balance>) -> Result {
let sender = ensure_signed(origin)?;
<balances::Module<T>>::increase_free_balance_creating(&sender, channel.deposit);
Ok(())
}
fn channel_withdraw(origin, chan... | code_fim | hard | {
"lang": "rust",
"repo": "AmbireTech/adex-protocol-substrate",
"path": "/runtime/src/adex_v3.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
}
decl_storage! {
trait Store for Module<T: Trait> as AdExV3 {
Payment get(payment) config(): Option<T::Balance>;
// @TODO Balance should carry multiple tokens
}
}
impl<T: Trait> Module<T> {}<|fim_prefix|>// repo: AmbireTech/adex-protocol-substrate path: /run... | code_fim | hard | {
"lang": "rust",
"repo": "AmbireTech/adex-protocol-substrate",
"path": "/runtime/src/adex_v3.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AmbireTech/adex-protocol-substrate path: /runtime/src/adex_v3.rs
use parity_codec::Encode;
use srml_support::{StorageValue, dispatch::Result};
use {balances, system::{self, ensure_signed}};
pub trait Trait: balances::Trait {}
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
... | code_fim | medium | {
"lang": "rust",
"repo": "AmbireTech/adex-protocol-substrate",
"path": "/runtime/src/adex_v3.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Retsam/AdventOfCode path: /2019/day6/src/main.rs
use std::io::{self, Read};
use std::collections::HashMap;
type ObjId = String;
type Orbit = (ObjId, ObjId);
#[derive(Debug)]
struct OrbitInfo {
primary: Option<ObjId>,
satellites: Vec<ObjId>,
}
impl OrbitInfo {
fn new() -> OrbitInfo ... | code_fim | hard | {
"lang": "rust",
"repo": "Retsam/AdventOfCode",
"path": "/2019/day6/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let orbit_info = build_orbit_info(orbits);
println!("Orbit checksum is {:#?}", count_orbits(&orbit_info));
// Minus 2, because the distance doesn't include "YOU" or "SAN"
println!("Minimum transfer distance is {}", shortest_transfer(&orbit_info, "YOU", "SAN") - 2);
Ok(())
}<|fim_prefi... | code_fim | hard | {
"lang": "rust",
"repo": "Retsam/AdventOfCode",
"path": "/2019/day6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxwells-daemons/reason path: /rust/reason-player/src/mcts.rs
//! Code for monte-carlo tree search, used for earlygame and midgame play.
use crate::network::{self, Prediction};
use dot;
use rand;
use reason_othello::{Game, Move, Player};
use std::collections::HashMap;
use tch::CModule;
pub str... | code_fim | hard | {
"lang": "rust",
"repo": "maxwells-daemons/reason",
"path": "/rust/reason-player/src/mcts.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Select an action out of the root proportionally to its visit count.
pub fn sample_action(&self) -> Move {
if let Some(PositionData::Internal(data)) = self.positions.get(&self.root) {
let visit_counts: Vec<i32> = data.actions.iter().map(|action| action.visits).collect();
... | code_fim | hard | {
"lang": "rust",
"repo": "maxwells-daemons/reason",
"path": "/rust/reason-player/src/mcts.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO(jdr): I've never really been satisfied with simply
// taking the first one in the list ....
// These might just as well be functions since they are referencing
// internal values.
if !album.tracks.is_empty() {
// Preference if we have a named album artist
// oth... | code_fim | hard | {
"lang": "rust",
"repo": "jdrivas/rlt",
"path": "/lt/src/album.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdrivas/rlt path: /lt/src/album.rs
//! The model for a collection of audio tracks.
use crate::track;
use std::error::Error;
use std::io;
use std::path;
/// A group of tracks with common metadata ie. an album.
#[derive(Debug)]
pub struct Album {
/// List of tracks for this Album.
pub tr... | code_fim | hard | {
"lang": "rust",
"repo": "jdrivas/rlt",
"path": "/lt/src/album.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Create an album from a group of tracks.
/// This will look to the first track in the group to gather Album
/// metadata. This is not optimal and should be fixed.
/// However, the use case is intended for a grouping of tracks
/// that are actually part of an album.
pub fn album_from_tracks(tks: Vec<tra... | code_fim | medium | {
"lang": "rust",
"repo": "jdrivas/rlt",
"path": "/lt/src/album.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::{
bubblesort::{
bubblesort as s_bubble_i,
bubblesort_by as s_bubble_if,
},
insertionsort::{
insertionsort as s_insert_i,
insertionsort_by as s_insert_if
},
mergesort::{
merge,
mergesort as s_merge_i,
merg... | code_fim | hard | {
"lang": "rust",
"repo": "RenoirTan/algocol",
"path": "/src/sort/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RenoirTan/algocol path: /src/sort/mod.rs
//! A collection of sorting algorithms.
//!
//! All of the functions defined in this module and its child modules take in
//! a mutable reference which can be converted to `&mut [T]` via `AsMut<[T]>`.
//! `T` must implement `std::cmp::Ord` so that th... | code_fim | hard | {
"lang": "rust",
"repo": "RenoirTan/algocol",
"path": "/src/sort/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nou4r/modernwarfare-internal-rs path: /src/funcs.rs
use crate::memory::MEMORY;
use crate::offsets;
use crate::util::Global;
<|fim_suffix|>impl Funcs {
pub unsafe fn set_uav(&self, enabled: bool) {
(self.dvar_setbool)(MEMORY.image_base + offsets::funcs::DVAR_UAV, enabled);
}
}
*/... | code_fim | hard | {
"lang": "rust",
"repo": "Nou4r/modernwarfare-internal-rs",
"path": "/src/funcs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
impl Default for Funcs {
fn default() -> Self {
Self {
dvar_setbool: unsafe { std::mem::transmute(MEMORY.image_base + offsets::funcs::DVAR_SETBOOL) }
}
}
}
impl Funcs {
pub unsafe fn set_uav(&self, enabled: bool) {
(self.dvar_setbool)(MEMORY.image_base +... | code_fim | medium | {
"lang": "rust",
"repo": "Nou4r/modernwarfare-internal-rs",
"path": "/src/funcs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jedisct1/wasmsign path: /src/wasm_signature/attach.rs
use super::super::errors::*;
use super::super::signature::*;
use byteorder::{LittleEndian, WriteBytesExt};
use parity_wasm::elements::*;
use std::{i32, u32};
pub fn attach_signature(
module_bytes: &[u8],
signature_alg: &Box<dyn Signa... | code_fim | hard | {
"lang": "rust",
"repo": "jedisct1/wasmsign",
"path": "/src/wasm_signature/attach.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let export_section = module.export_section().expect("No export section");
if export_section
.entries()
.iter()
.any(|export_entry| export_entry.field() == signature_symbol)
{
return Err(WError::ParseError(format!(
... | code_fim | hard | {
"lang": "rust",
"repo": "jedisct1/wasmsign",
"path": "/src/wasm_signature/attach.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check if the Custom Section with a signature already exists
{
let module: Module = parity_wasm::deserialize_buffer(module_bytes)?;
if module
.custom_sections()
.any(|section| section.name() == signature_section_name)
{
return Err(WErr... | code_fim | hard | {
"lang": "rust",
"repo": "jedisct1/wasmsign",
"path": "/src/wasm_signature/attach.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod attribute;
pub mod visitor;<|fim_prefix|>// repo: rapilab/rguard path: /rguard_core/src/classfile/mod.rs
pub mod class_pool;
<|fim_middle|>pub mod clazz;
pub mod program_class;
pub mod program_field;
pub mod program_member;
pub mod program_method;
pub mod library_clazz;
| code_fim | medium | {
"lang": "rust",
"repo": "rapilab/rguard",
"path": "/rguard_core/src/classfile/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rapilab/rguard path: /rguard_core/src/classfile/mod.rs
pub mod class_pool;
pub mod clazz;
pub mod program_class;
pub mod program_field;
pub mod program_member;
pub mod program_method;
<|fim_suffix|>pub mod attribute;
pub mod visitor;<|fim_middle|>pub mod library_clazz;
| code_fim | easy | {
"lang": "rust",
"repo": "rapilab/rguard",
"path": "/rguard_core/src/classfile/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likr/rust-fd-layout path: /src/group_force.rs
use force::{Point, Force};
use many_body_force::ManyBodyForce;
#[derive(Copy, Clone, Debug)]
pub struct Group {
pub x: f32,
pub y: f32,
}
impl Group {
pub fn new(x: f32, y: f32) -> Group {
Group { x: x, y: y }
}
}
pub struc... | code_fim | hard | {
"lang": "rust",
"repo": "likr/rust-fd-layout",
"path": "/src/group_force.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let groups = &self.groups;
let node_groups = &self.node_groups;
let k = self.strength * alpha;
for (point, &g) in points.iter_mut().zip(node_groups) {
point.vx += (groups[g].x - point.x) * k;
point.vy += (groups[g].y - point.y) * k;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "likr/rust-fd-layout",
"path": "/src/group_force.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create a new secret from a byte vector.
pub(crate) fn from_slice(
bytes: &[u8],
mls_version: ProtocolVersion,
ciphersuite: &'static Ciphersuite,
) -> Self {
Secret {
value: bytes.to_vec(),
mls_version,
ciphersuite,
... | code_fim | hard | {
"lang": "rust",
"repo": "imoldfella/openmls",
"path": "/openmls/src/ciphersuite/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> SignedStruct<T> for Signature {
fn from_payload(_payload: T, signature: Signature) -> Self {
signature
}
}
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub struct SignaturePrivateKey {
signature_scheme: SignatureScheme,
value: Vec<u8>,
}
#[derive(Eq, Parti... | code_fim | hard | {
"lang": "rust",
"repo": "imoldfella/openmls",
"path": "/openmls/src/ciphersuite/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imoldfella/openmls path: /openmls/src/ciphersuite/mod.rs
tureScheme::ECDSA_SECP256R1_SHA256),
0x0603 => Ok(SignatureScheme::ECDSA_SECP521R1_SHA512),
0x0807 => Ok(SignatureScheme::ED25519),
0x0808 => Ok(SignatureScheme::ED448),
_ => Err(format!("Uns... | code_fim | hard | {
"lang": "rust",
"repo": "imoldfella/openmls",
"path": "/openmls/src/ciphersuite/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rupansh/mongo-rust-driver path: /src/sdam/state/server.rs
use std::sync::{
atomic::{AtomicU32, Ordering},
Arc,
};
use super::WeakTopology;
use crate::{
cmap::{options::ConnectionPoolOptions, ConnectionPool},
error::Error,
options::{ClientOptions, StreamAddress},
runtime:... | code_fim | hard | {
"lang": "rust",
"repo": "rupansh/mongo-rust-driver",
"path": "/src/sdam/state/server.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ServerUpdateSender {
/// Create a new sender/receiver pair.
pub(crate) fn channel() -> (Self, ServerUpdateReceiver) {
let (sender, receiver) = tokio::sync::mpsc::channel(1);
(
ServerUpdateSender { sender },
ServerUpdateReceiver { receiver },
)
... | code_fim | hard | {
"lang": "rust",
"repo": "rupansh/mongo-rust-driver",
"path": "/src/sdam/state/server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tikv/client-rust path: /src/generated/debugpb.rs
Module::Pd => "PD",
Module::Metric => "METRIC",
Module::Coprocessor => "COPROCESSOR",
Module::Security => "SECURITY",
Module::Import => "IMPORT",
}
}
/// Creates an enum from field... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/client-rust",
"path": "/src/generated/debugpb.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>degen::*;
use tonic::codegen::http::Uri;
/// Debug service for TiKV.
///
/// Errors are defined as follow:
/// - OK: Okay, we are good!
/// - UNKNOWN: For unknown error.
/// - INVALID_ARGUMENT: Something goes wrong within requests.
/// - NOT_FOUND: It is key or regi... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/client-rust",
"path": "/src/generated/debugpb.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tikv/client-rust path: /src/generated/debugpb.rs
wrong within requests.
/// - NOT_FOUND: It is key or region not found, it's based on context, detailed
/// reason can be found in grpc message.
/// Note: It bypasses raft layer.
#[derive(Debug, Clone)]
pub stru... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/client-rust",
"path": "/src/generated/debugpb.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: project-oak/oak path: /oak_functions/examples/weather_lookup/module/src/tests.rs
//
// Copyright 2021 The Project Oak 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 ... | code_fim | hard | {
"lang": "rust",
"repo": "project-oak/oak",
"path": "/oak_functions/examples/weather_lookup/module/src/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Wait for the server to start up.
std::thread::sleep(Duration::from_secs(20));
let summary = bencher.bench(|bencher| {
bencher.iter(|| {
let response =
runtime.block_on(make_request(server_port, br#"{"lat":-60.1,"lng":120.1}"#));
assert!(!resp... | code_fim | hard | {
"lang": "rust",
"repo": "project-oak/oak",
"path": "/oak_functions/examples/weather_lookup/module/src/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lookup_data_file = oak_functions_test_utils::write_to_temp_file(
&oak_functions_test_utils::serialize_entries(hashmap! {
location_to_bytes(&location_0).to_vec() => br#"{"temperature_degrees_celsius":10}"#.to_vec(),
location_to_bytes(&location_1).to_vec() => br#"{"te... | code_fim | hard | {
"lang": "rust",
"repo": "project-oak/oak",
"path": "/oak_functions/examples/weather_lookup/module/src/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>buffer = [0u8; 256];
let mut read_bytes = 0;
let success = bindings::ReadFile(
f,
buffer.as_mut_ptr() as *mut c_void,
buffer.len() as c_uint,
&mut read_bytes,
null_mut(),
);
if success == 0 {
panic!("Re... | code_fim | hard | {
"lang": "rust",
"repo": "divvun/cpr",
"path": "/samples/demo/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: divvun/cpr path: /samples/demo/src/main.rs
use std::{ffi::c_void, os::raw::*, ptr::null_mut};
fn main() {
unsafe {
let path: Vec<u16> = "Cargo.toml"
.encode_utf16()
.chain(Some(0u16).into_iter())
.collect();
let f = bindings::CreateFileW(
... | code_fim | hard | {
"lang": "rust",
"repo": "divvun/cpr",
"path": "/samples/demo/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> null_mut(),
);
if success == 0 {
panic!("ReadFile call failed");
}
println!(
"{}",
String::from_utf8_lossy(&buffer[..read_bytes as usize])
);
}
}<|fim_prefix|>// repo: divvun/cpr path: /samples/demo/src/main.rs
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "divvun/cpr",
"path": "/samples/demo/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Copy)]
#[repr(u8)]
pub enum PrivacyLevel {
Public = 1,
GuildOnly = 2,
}<|fim_prefix|>// repo: BEDSpEedTEST/tickets.rs path: /model/src/stage/stage_instance.rs
use crate::Snowflake;
use serde::{Deserialize, Serialize};
use serde_repr::{Deser... | code_fim | hard | {
"lang": "rust",
"repo": "BEDSpEedTEST/tickets.rs",
"path": "/model/src/stage/stage_instance.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BEDSpEedTEST/tickets.rs path: /model/src/stage/stage_instance.rs
use crate::Snowflake;
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
<|fim_suffix|>#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Copy)]
#[repr(u8)]
pub enum PrivacyLevel {
P... | code_fim | hard | {
"lang": "rust",
"repo": "BEDSpEedTEST/tickets.rs",
"path": "/model/src/stage/stage_instance.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn string_bottles(n: u32) -> String {
match n {
0 => "no more bottles of beer".to_string(),
1 => "1 bottle of beer".to_string(),
_ => format!("{} bottles of beer", n),
}
}<|fim_prefix|>// repo: longlb/exercism path: /rust/beer-song/src/lib.rs
pub fn verse(n: u32) -> String... | code_fim | hard | {
"lang": "rust",
"repo": "longlb/exercism",
"path": "/rust/beer-song/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match n {
0 => "no more bottles of beer".to_string(),
1 => "1 bottle of beer".to_string(),
_ => format!("{} bottles of beer", n),
}
}<|fim_prefix|>// repo: longlb/exercism path: /rust/beer-song/src/lib.rs
pub fn verse(n: u32) -> String {
if n == 0 {
format!(
... | code_fim | medium | {
"lang": "rust",
"repo": "longlb/exercism",
"path": "/rust/beer-song/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: longlb/exercism path: /rust/beer-song/src/lib.rs
pub fn verse(n: u32) -> String {
if n == 0 {
format!(
"No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n",
)
} else {
for... | code_fim | hard | {
"lang": "rust",
"repo": "longlb/exercism",
"path": "/rust/beer-song/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: max-ym/kobzar-old path: /src/mem/mod.rs
mod arch;
pub use self::arch::*;
<|fim_suffix|>/// Memory allocator traits and structs.
mod alloc;
pub use self::alloc::*;<|fim_middle|>/// Memory address operations.
mod addr;
pub use self::addr::Address;
| code_fim | medium | {
"lang": "rust",
"repo": "max-ym/kobzar-old",
"path": "/src/mem/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Memory allocator traits and structs.
mod alloc;
pub use self::alloc::*;<|fim_prefix|>// repo: max-ym/kobzar-old path: /src/mem/mod.rs
mod arch;
pub use self::arch::*;
<|fim_middle|>/// Memory address operations.
mod addr;
pub use self::addr::Address;
| code_fim | medium | {
"lang": "rust",
"repo": "max-ym/kobzar-old",
"path": "/src/mem/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: urantialife/draco path: /src/html.rs
use crate::{element::Ns, Element, NonKeyedElement};
macro_rules! names {
($($ident:ident)+) => {
$(
pub fn $ident<Message: 'static>() -> NonKeyedElement<Message> {
Element::new(Ns::Html, stringify!($ident))
... | code_fim | hard | {
"lang": "rust",
"repo": "urantialife/draco",
"path": "/src/html.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s kbd label legend li main mark math menu
menuitem meter nav object ol optgroup option output p param pre progress q rp rt ruby s samp
section select small source span strong sub summary sup table tbody td textarea tfoot th thead
time tr track u ul var video wbr
}<|fim_prefix|>// repo: urantia... | code_fim | hard | {
"lang": "rust",
"repo": "urantialife/draco",
"path": "/src/html.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
}
names! {
a abbr address article aside audio b bdi bdo blockquote br button canvas caption cite code col
colgroup datalist dd del details dfn div dl dt em embed fieldset figcaption figure footer form
h1 h2 h3 h4 h5 h6 header hr i iframe img input ins kbd label legend li main mark... | code_fim | hard | {
"lang": "rust",
"repo": "urantialife/draco",
"path": "/src/html.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn fg(fg: i16) -> chtype {
pair(fg, COLOR_DEFAULT)
}
fn index(fg: i16, bg: i16) -> i16 {
// each color code is 4 bits and the resulting index can't be 0
(fg << 4 | bg) + 1
}<|fim_prefix|>// repo: coffeecup-winner/parc path: /src/ui/color.rs
use pancurses::*;
pub const COLOR_DEFAULT: i16... | code_fim | medium | {
"lang": "rust",
"repo": "coffeecup-winner/parc",
"path": "/src/ui/color.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coffeecup-winner/parc path: /src/ui/color.rs
use pancurses::*;
pub const COLOR_DEFAULT: i16 = COLOR_WHITE + 1;
pub fn init() {
start_color();
use_default_colors();
for fg in COLOR_BLACK..=COLOR_DEFAULT {
for bg in COLOR_BLACK..=COLOR_DEFAULT {
let fg_color = if ... | code_fim | medium | {
"lang": "rust",
"repo": "coffeecup-winner/parc",
"path": "/src/ui/color.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arash-hacker/pt-rs path: /src/shape.rs
use crate::vector::*;
use crate::ray::*;
use crate::bbox::*;
use crate::color::*;
use crate::axis::*;
use crate::material::*;
use crate::matrix::*;
use crate::hit::*;
pub trait Shape {
fn GetType(&self)->&str;
fn Compile(&self)->();
<|fim_suffix|>}
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "arash-hacker/pt-rs",
"path": "/src/shape.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.matrix.MulBox(self.shape.BoundingBox())
}
fn Intersect(&self, r:Ray)->Hit {
let shapeRay = self.inverse.MulRay(r);
let mut hit = self.shape.Intersect(shapeRay);
if !hit.Ok() {
return hit;
}
let shape = hit.Shape.unwrap();
let shapePosition = shapeRay.Position(hit.T);
let... | code_fim | hard | {
"lang": "rust",
"repo": "arash-hacker/pt-rs",
"path": "/src/shape.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn GetType(&self)-> &str {
"TransformedShape"
}
fn BoundingBox(&self)-> BBox {
return self.matrix.MulBox(self.shape.BoundingBox())
}
fn Intersect(&self, r:Ray)->Hit {
let shapeRay = self.inverse.MulRay(r);
let mut hit = self.shape.Intersect(shapeRay);
if !hit.Ok() {
return hit;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "arash-hacker/pt-rs",
"path": "/src/shape.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BaldyAsh/test-token-solana path: /src/state.rs
use solana_program::{
program_error::ProgramError,
program_option::COption,
pubkey::Pubkey,
program_pack::{IsInitialized, Pack, Sealed},
};
use num_enum::TryFromPrimitive;
use arrayref::{array_mut_ref, array_ref, array_refs, mut_arra... | code_fim | hard | {
"lang": "rust",
"repo": "BaldyAsh/test-token-solana",
"path": "/src/state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dst = array_mut_ref![dst, 0, 46];
let (
mint_authority_dst,
supply_dst,
decimals_dst,
is_initialized_dst,
) = mut_array_refs![dst, 36, 8, 1, 1];
let &Mint {
ref mint_authority,
supply,
... | code_fim | hard | {
"lang": "rust",
"repo": "BaldyAsh/test-token-solana",
"path": "/src/state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cda-group/arcon path: /arcon/src/metrics/log_recorder.rs
use crate::application::conf::logger::ArconLogger;
use arcon::prelude::*;
use metrics::{GaugeValue, Key, Recorder, Unit};
pub struct LogRecorder {
pub(crate) logger: ArconLogger,
}
impl Recorder for LogRecorder {
fn register_coun... | code_fim | hard | {
"lang": "rust",
"repo": "cda-group/arcon",
"path": "/arcon/src/metrics/log_recorder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!(self.logger, "(counter) got value {} for key {}", value, key);
}
fn update_gauge(&self, key: &Key, value: GaugeValue) {
info!(self.logger, "(gauge) got value {:?} for key {}", value, key);
}
fn record_histogram(&self, key: &Key, value: f64) {
info!(
... | code_fim | medium | {
"lang": "rust",
"repo": "cda-group/arcon",
"path": "/arcon/src/metrics/log_recorder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Relrin/quickproj path: /src/constants.rs
use console::Emoji;
pub static CLONING_REPOSITORY_EMOJI: Emoji<'_, '_> = Emoji("📦 ", "");
pub static COPYING_REPOSITORY_EMOJI: Emoji<'_, '_> = Emoji("💾 ", "");
<|fim_suffix|>pub static OPERATION_HAS_BEEN_COMPLETED_EMOJI: Emoji<'_, '_> = Emoji("✨", ":)... | code_fim | hard | {
"lang": "rust",
"repo": "Relrin/quickproj",
"path": "/src/constants.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub static OPERATION_HAS_BEEN_COMPLETED_EMOJI: Emoji<'_, '_> = Emoji("✨", ":)");<|fim_prefix|>// repo: Relrin/quickproj path: /src/constants.rs
use console::Emoji;
pub static CLONING_REPOSITORY_EMOJI: Emoji<'_, '_> = Emoji("📦 ", "");
pub static COPYING_REPOSITORY_EMOJI: Emoji<'_, '_> = Emoji("💾 ", "")... | code_fim | hard | {
"lang": "rust",
"repo": "Relrin/quickproj",
"path": "/src/constants.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lovesh/merkle_trees path: /src/hasher.rs
use crate::errors::MerkleTreeError;
use crate::sha2::{Digest, Sha256};
/// To be used with a binary tree
/// `D` is the type of data the leaf has, like a string or a big number, etc.
/// `H` is the type for the hash
pub trait Arity2Hasher<D, H> {
///... | code_fim | hard | {
"lang": "rust",
"repo": "lovesh/merkle_trees",
"path": "/src/hasher.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_sha256_arity_2_hasher() {
// Choice of domain separators is arbitrary
let hasher = Sha256Hasher {
leaf_data_domain_separator: 0,
node_domain_separator: 1,
};
let left_leaf = Arity2Hasher::hash_leaf_data(&hasher, "hi").unwrap(... | code_fim | hard | {
"lang": "rust",
"repo": "lovesh/merkle_trees",
"path": "/src/hasher.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Array for BaseArray {
fn is_null(&self, i: i32) -> bool {
unsafe { arr_is_null(self.raw_array, i) }
}
fn len(&self) -> i32 {
unsafe { arr_len(self.raw_array) }
}
fn null_count(&self) -> i32 {
unsafe { arr_null_count(self.raw_array) }
}
fn data_type(&self) -> DataType {
... | code_fim | hard | {
"lang": "rust",
"repo": "jihoonson/arrow-rs",
"path": "/src/array.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // must not be called
unimplemented!()
}
fn from_raw(raw_array: RawArrayPtr) -> BaseArray {
BaseArray {
raw_array: raw_array
}
}
}
impl PartialEq for BaseArray {
fn eq(&self, other: &BaseArray) -> bool {
unsafe { arr_equals_exact(self.raw_array, other.raw_array) }
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jihoonson/arrow-rs",
"path": "/src/array.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jihoonson/arrow-rs path: /src/array.rs
use ty;
use ty::{DataType, RawDataTypePtr, Ty};
use buffer::{Buf, Buffer};
use types::primitive;
use std::mem;
// TODO: inheritance relationship for Array and its sub classes
pub trait Array<Ty=Self> {
fn is_null(&self, i: i32) -> bool;
fn len(&self... | code_fim | hard | {
"lang": "rust",
"repo": "jihoonson/arrow-rs",
"path": "/src/array.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wahello/spin path: /crates/templates/src/interaction.rs
use crate::template::{TemplateParameter, TemplateParameterDataType};
// use console::style;
use dialoguer::{Confirm, Input};
<|fim_suffix|>fn ask_free_text(prompt: &str, default_value: &Option<String>) -> anyhow::Result<String> {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "wahello/spin",
"path": "/crates/templates/src/interaction.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = Input::<String>::new();
input.with_prompt(prompt);
if let Some(s) = default_value {
input.default(s.to_owned());
}
let result = input.interact_text()?;
Ok(result)
}<|fim_prefix|>// repo: wahello/spin path: /crates/templates/src/interaction.rs
use crate::tem... | code_fim | hard | {
"lang": "rust",
"repo": "wahello/spin",
"path": "/crates/templates/src/interaction.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn prompt_parameter(parameter: &TemplateParameter) -> Option<String> {
let prompt = parameter.prompt();
let default_value = parameter.default_value();
loop {
let input = match parameter.data_type() {
TemplateParameterDataType::String(_) => ask_free_text(prompt, ... | code_fim | medium | {
"lang": "rust",
"repo": "wahello/spin",
"path": "/crates/templates/src/interaction.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pdf_path = cursor_path.stringByAppendingPathComponent(ns_string!("cursor.pdf"));
let image = NSImage::new_by_referencing_file(&pdf_path);
// TODO: Handle PLists better
let info_path = cursor_path.stringByAppendingPathComponent(ns_string!("info.plist"));... | code_fim | hard | {
"lang": "rust",
"repo": "rust-windowing/winit",
"path": "/src/platform_impl/macos/appkit/cursor.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-windowing/winit path: /src/platform_impl/macos/appkit/cursor.rs
use once_cell::sync::Lazy;
use icrate::ns_string;
use icrate::Foundation::{
NSData, NSDictionary, NSNumber, NSObject, NSObjectProtocol, NSPoint, NSString,
};
use objc2::rc::{DefaultId, Id};
use objc2::runtime::Sel;
use obj... | code_fim | hard | {
"lang": "rust",
"repo": "rust-windowing/winit",
"path": "/src/platform_impl/macos/appkit/cursor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let hotspot = NSPoint::new(x, y);
Self::new(&image, hotspot)
}
pub fn moveCursor() -> Id<Self> {
unsafe { Self::load_webkit_cursor(ns_string!("move")) }
}
pub fn cellCursor() -> Id<Self> {
unsafe { Self::load_webkit_cursor(n... | code_fim | hard | {
"lang": "rust",
"repo": "rust-windowing/winit",
"path": "/src/platform_impl/macos/appkit/cursor.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> archive_reader: *mut ffi::archive,
archive_writer: *mut ffi::archive,
) -> Result<()> {
let mut buffer = std::ptr::null();
let mut offset = 0;
let mut size = 0;
unsafe {
loop {
match ffi::archive_read_data_block(archive_reader, &mut buffer, &mut size, &mut offs... | code_fim | hard | {
"lang": "rust",
"repo": "afdw/compress-tools-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: afdw/compress-tools-rs path: /src/lib.rs
// Copyright (C) 2019, 2020 O.S. Systems Sofware LTDA
//
// SPDX-License-Identifier: MIT OR Apache-2.0
//! The `compress-tools` crate aims to provide a convenient and easy to use set
//! of methods which builds on top of `libarchive` exposing a small set... | code_fim | hard | {
"lang": "rust",
"repo": "afdw/compress-tools-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Collecting all the threads
let mut thread_holder = Vec::with_capacity(NO_THREADS as usize);
for _ in 0..NO_THREADS {
// Get the message from channel
thread_holder.push(rx.recv());
}
// Print the execution order
println!("{:?}", thread_holder);
}<|fim_prefix|>// ... | code_fim | hard | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Cookbook",
"path": "/Chapter05/sample_channel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Sending threads via the channel
thread::spawn(move || {
// thread sends the message to the channel
thread_tx.send(thread_id).unwrap();
println!("thread {} finished", thread_id);
});
}
// Collecting all the threads
let mut thread_h... | code_fim | hard | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Cookbook",
"path": "/Chapter05/sample_channel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PacktPublishing/Rust-Cookbook path: /Chapter05/sample_channel.rs
//-- #########################
//-- Task: Using channels to perform safe pass of data between threads
//-- Author: Vigneshwer.D
//-- Version: 1.0.0
//-- Date: 19 March 17
//-- #########################
// Using standard libraries
... | code_fim | medium | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Cookbook",
"path": "/Chapter05/sample_channel.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let max_len = max_encode_len(src.len());
let mut dst = Vec::<u8>::with_capacity(max_len);
dst.resize(max_len, 0);
let got_len = encode(&mut dst, &src);
dst.resize(got_len, 0);
assert!(cmp(&dst, &want));
}
#[test]
fn it_works() {
test_go... | code_fim | hard | {
"lang": "rust",
"repo": "blackredscarf/xsnappy",
"path": "/snappy_test/src/golden.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blackredscarf/xsnappy path: /snappy_test/src/golden.rs
use std::fs::File;
use std::io::Read;
pub fn read_file_to_vec(filename: &str) -> Vec<u8> {
let mut file = File::open(filename).unwrap();
let mut data = vec!();
file.read_to_end(&mut data).unwrap();
data
}
pub fn cmp(dst: &[... | code_fim | hard | {
"lang": "rust",
"repo": "blackredscarf/xsnappy",
"path": "/snappy_test/src/golden.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TOSPIO/tospio-scripts path: /bin/tyme/wrapper_facility.rs
use std::mem;
use std::time::Instant;
trait Runnable {
type TResult;
fn run(&self) -> Self::TResult;
}
<|fim_suffix|> fn on_end(&mut self);
fn run(&mut self, r: TRunnable) -> TRunnable::TResult {
self.on_start();
... | code_fim | medium | {
"lang": "rust",
"repo": "TOSPIO/tospio-scripts",
"path": "/bin/tyme/wrapper_facility.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, r: TRunnable) -> TRunnable::TResult {
self.on_start();
let result = r.run();
self.on_end();
result
}
}
pub struct TimerFacility {
start_time: Instant,
end_time: Instant
}
impl<TRunnable: Runnable> Facility<TRunnable> for TimerFacility {
... | code_fim | medium | {
"lang": "rust",
"repo": "TOSPIO/tospio-scripts",
"path": "/bin/tyme/wrapper_facility.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.start_time = Instant::now();
}
fn on_end(&mut self) {
self.end_time = Instant::now();
}
}<|fim_prefix|>// repo: TOSPIO/tospio-scripts path: /bin/tyme/wrapper_facility.rs
use std::mem;
use std::time::Instant;
trait Runnable {
type TResult;
fn run(&self) -> Self::... | code_fim | hard | {
"lang": "rust",
"repo": "TOSPIO/tospio-scripts",
"path": "/bin/tyme/wrapper_facility.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut v = Vec::<u32>::with_capacity(10_000_020);
let mut n = Vec::<u32>::with_capacity(32);
n.push(0);
while v.len() <= 1_000_000 {
v.extend(&n);
increment(&mut n);
}
v[1] * v[10] * v[100] * v[1000] * v[10_000] * v[100_000] * v[1_000_000]
}
fn main() {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "ScottBailey/project_euler",
"path": "/p0040/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sol = solve();
let elapsed = start_time.elapsed().as_micros();
println!("\nSolution: {}", sol);
let mut remain = elapsed;
let mut s = String::new();
if remain == 0 {
s.insert(0,'0');
}
while remain > 0 {
let temp = remain%1000;
remain /= 1000;
... | code_fim | hard | {
"lang": "rust",
"repo": "ScottBailey/project_euler",
"path": "/p0040/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ScottBailey/project_euler path: /p0040/src/main.rs
/*
https://projecteuler.net
An irrational decimal fraction is created by concatenating the
positive integers:
0.123456789101112131415161718192021...
^
It can be seen that the 12th digit of the fractional part is 1.
If dn repres... | code_fim | hard | {
"lang": "rust",
"repo": "ScottBailey/project_euler",
"path": "/p0040/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ullUp>>,
mock_hal::gpioa::PA2<Input<PullUp>>,
mock_hal::gpioa::PA3<Input<PullUp>>,
),
columns: (
mock_hal::gpioa::PA4<Output<OpenDrain>>,
mock_hal::gpioa::PA5<Output<OpenDrain>>,
mock_hal::gpioa::PA6<Output<OpenDrain>>,
... | code_fim | hard | {
"lang": "rust",
"repo": "e-matteson/keypad",
"path": "/src/example_generated.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: e-matteson/keypad path: /src/example_generated.rs
//! An example of a struct generated by the `keypad_struct!()` macro.
use crate::mock_hal::{self, Input, OpenDrain, Output, PullUp};
use core::convert::Infallible;
keypad_struct! {
#[doc= "Example output of `keypad_struct!()`- for documenta... | code_fim | hard | {
"lang": "rust",
"repo": "e-matteson/keypad",
"path": "/src/example_generated.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LexxFedoroff/leetcode path: /src/solutions/split_array_largest_sum/tests.rs
use crate::Solution;
#[test]
fn example1() {
let nums = vec![7, 2, 5, 10, 8];
assert_eq!(18, Solution::split_array(nums, 2));
}
#[test]
fn example2() {
let nums = vec![1, 2147483647];
assert_eq!(2147483... | code_fim | medium | {
"lang": "rust",
"repo": "LexxFedoroff/leetcode",
"path": "/src/solutions/split_array_largest_sum/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nums = vec![
5334, 6299, 4199, 9663, 8945, 3566, 9509, 3124, 6026, 6250, 7475, 5420, 9201, 9501, 38,
5897, 4411, 6638, 9845, 161, 9563, 8854, 3731, 5564, 5331, 4294, 3275, 1972, 1521, 2377,
3701, 6462, 6778, 187, 9778, 758, 550, 7510, 6225, 8691, 3666, 4622, 9722, 8011, 724... | code_fim | medium | {
"lang": "rust",
"repo": "LexxFedoroff/leetcode",
"path": "/src/solutions/split_array_largest_sum/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn distance(steps: &str) -> u32 {
let (q, r, s) = steps.split(',')
.filter_map(|d| d.parse::<Direction>().ok())
.fold((0, 0, 0), |(q, r, s), d| {
(q + d.q(), r + d.r(), s + d.s())
});
((q.abs() + r.abs() + s.abs()) / 2i32) as u32
}
#[cfg(test)]
mod tests {... | code_fim | hard | {
"lang": "rust",
"repo": "dcoxall/advent-of-code-2017",
"path": "/1101-hex-ed/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dcoxall/advent-of-code-2017 path: /1101-hex-ed/src/lib.rs
use std::str::FromStr;
struct Direction(i32, i32, i32);
impl Direction {
fn q(&self) -> i32 { self.0 }
fn r(&self) -> i32 { self.1 }
fn s(&self) -> i32 { self.2 }
<|fim_suffix|>pub fn distance(steps: &str) -> u32 {
let (... | code_fim | hard | {
"lang": "rust",
"repo": "dcoxall/advent-of-code-2017",
"path": "/1101-hex-ed/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> response.send(Status::Ok, serialized)
},
_ => response.send(Status::NoContent, "Error: ISO date string was not provided".to_string())
}
}
_ => response.send(Status::BadRequest, "".to_string())
}... | code_fim | hard | {
"lang": "rust",
"repo": "adace123/rust_http_handler",
"path": "/src/routes/time.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adace123/rust_http_handler path: /src/routes/time.rs
use serde_derive::Serialize;
use serde_json::json;
use chrono::prelude::*;
use chrono::{DateTime, Utc};
use super::RouteHandler;
use super::super::http_request::HttpRequest;
use super::super::http_response::{Status, HttpResponse};
<|fim_suffi... | code_fim | hard | {
"lang": "rust",
"repo": "adace123/rust_http_handler",
"path": "/src/routes/time.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.