text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: krsmanian1972/ferries path: /src/service_tests/program_creation_feature.rs
use diesel::prelude::*;
use super::prelude::connection_without_transaction;
use crate::services::programs::create_new_program;
use crate::services::users::INVALID_COACH_ID;
use crate::models::programs::NewProgramReques... | code_fim | hard | {
"lang": "rust",
"repo": "krsmanian1972/ferries",
"path": "/src/service_tests/program_creation_feature.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn build_program_with_unknown_coach() -> NewProgramRequest {
NewProgramRequest{
coach_id:"coach-x".to_string(),
name: "name-1".to_string(),
description: "desc".to_string(),
genre_id: None,
is_private: true,
}
}<|fim_prefix|>// repo: krsmanian1972/ferries pa... | code_fim | hard | {
"lang": "rust",
"repo": "krsmanian1972/ferries",
"path": "/src/service_tests/program_creation_feature.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rkat0/AtCoder path: /DPC/S.rs
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
let mut next = || { iter.next().unwrap() };
input_inner!{next, $($r)*}
};
($($r:tt)*) => {
let stdin = std::io::stdin();
... | code_fim | hard | {
"lang": "rust",
"repo": "rkat0/AtCoder",
"path": "/DPC/S.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
input!{
k: chars,
d: usize
}
let m = 1000000007;
let n = k.len();
let mut tab: Vec<Vec<usize>> = vec![vec![0; d]; n];
tab[0][0] = 1;
for i in 1..n {
let mut t: usize = 0;
for j in 0..10 {
t += tab[i - 1][(11 * d - 1 - j) %... | code_fim | hard | {
"lang": "rust",
"repo": "rkat0/AtCoder",
"path": "/DPC/S.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gsuyemoto/M031AE-rs path: /src/pwm0/pwm_capif.rs
#[inline(always)]
pub fn variant(&self) -> CRLIF5_A {
match self.bits {
false => CRLIF5_A::_0,
true => CRLIF5_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
... | code_fim | hard | {
"lang": "rust",
"repo": "gsuyemoto/M031AE-rs",
"path": "/src/pwm0/pwm_capif.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `CFLIF1` writer - PWM Capture Falling Latch Interrupt Flag\nNote 1: When Capture with PDMA operating, CAPIF corresponding channel CFLIF will be cleared by hardware after PDMA transfer data.\nNote 2: This bit is cleared by writing 1 to it."]
pub struct CFLIF1_W<'a> {
... | code_fim | hard | {
"lang": "rust",
"repo": "gsuyemoto/M031AE-rs",
"path": "/src/pwm0/pwm_capif.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Field `CFLIF4` reader - PWM Capture Falling Latch Interrupt Flag\nNote 1: When Capture with PDMA operating, CAPIF corresponding channel CFLIF will be cleared by hardware after PDMA transfer data.\nNote 2: This bit is cleared by writing 1 to it."]
pub struct CFLI... | code_fim | hard | {
"lang": "rust",
"repo": "gsuyemoto/M031AE-rs",
"path": "/src/pwm0/pwm_capif.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: ?Sized + Eq> Eq for Strong<T> {}
impl<T: ?Sized + PartialOrd> PartialOrd for Strong<T> {
/// Partial comparison for two `Strong`s.
///
/// The two are compared by calling `partial_cmp()` on their inner values.
///
/// # Examples
///
/// ```
/// use arbalest::sync::... | code_fim | hard | {
"lang": "rust",
"repo": "nox/arbalest",
"path": "/src/sync.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nox/arbalest path: /src/sync.rs
`
/// use arbalest::sync::Strong;
///
/// let five = Strong::new(5);
///
/// let frail_five = Strong::downgrade(&five);
/// ```
#[inline]
pub fn downgrade(this: &Self) -> Frail<T> {
this.inner().downgrade()
}
/// Ge... | code_fim | hard | {
"lang": "rust",
"repo": "nox/arbalest",
"path": "/src/sync.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nox/arbalest path: /src/sync.rs
///
/// ```
/// use arbalest::sync::Strong;
///
/// let x = Strong::new(10);
/// let x_ptr = Strong::into_raw(x);
///
/// unsafe {
/// // Convert back to an `Arc` to prevent leak.
/// let x = Strong::from_raw(x_ptr);
... | code_fim | hard | {
"lang": "rust",
"repo": "nox/arbalest",
"path": "/src/sync.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shra1dhar/rust-shed path: /shed/thrift_compiler/src/lib.rs
/*
* Copyright (c) Facebook, Inc. and its 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, Version 2.0 found ... | code_fim | hard | {
"lang": "rust",
"repo": "shra1dhar/rust-shed",
"path": "/shed/thrift_compiler/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args = {
let mut args = Vec::new();
if let Some(crate_map) = &self.crate_map {
args.push(format!("cratemap={}", crate_map.display()))
}
if let Some(base_path) = &self.base_path {
args.push(format!("include_prefix={... | code_fim | hard | {
"lang": "rust",
"repo": "shra1dhar/rust-shed",
"path": "/shed/thrift_compiler/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: watashi/AlgoSolution path: /codeforces/ac/16/1629/B.rs
use std::*;
fn read_line() -> String {
let mut line = String::new();
io::stdin().read_line(&mut line).unwrap();
line
}
fn read_vec<T: str::FromStr>() -> Vec<T> {
read_line()
.split_whitespace()
.filter_map(|... | code_fim | medium | {
"lang": "rust",
"repo": "watashi/AlgoSolution",
"path": "/codeforces/ac/16/1629/B.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let yes = ["NO", "YES"];
let re = read_line().trim().parse().unwrap();
let mut ans = vec![];
for _ in 0..re {
if let [l, r, k] = read_vec::<usize>()[..] {
if l == r {
ans.push(yes[(l > 1) as usize]);
} else {
ans.push(yes[(r /... | code_fim | medium | {
"lang": "rust",
"repo": "watashi/AlgoSolution",
"path": "/codeforces/ac/16/1629/B.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> opts.parse(&args[1..]).unwrap().opt_str("c")
}
fn main() {
let opt_cmd_line = get_cmdline_from_args();
match opt_cmd_line {
Some(cmd_line) => Shell::new("").run_cmdline(&cmd_line),
None => Shell::new("gash > ").run(),
}
}<|fim_prefix|>// repo: lovesh/cs4144 pat... | code_fim | hard | {
"lang": "rust",
"repo": "lovesh/cs4144",
"path": "/ps2/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lovesh/cs4144 path: /ps2/src/main.rs
//
// gash.rs
//
// Starting code for PS2
// Running on Rust 1+
//
// University of Virginia - cs4414 Spring 2014
// Weilin Xu, David Evans
// Version 0.4
//
extern crate getopts;
use getopts::Options;
use std::env;
use std::io::{self, Write};
use std::proc... | code_fim | hard | {
"lang": "rust",
"repo": "lovesh/cs4144",
"path": "/ps2/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Command::new("which").arg(cmd_path).status().unwrap().success()
}
}
fn get_cmdline_from_args() -> Option<String> {
/* Begin processing program arguments and initiate the parameters. */
let args: Vec<_> = env::args().collect();
let mut opts = Options::new();
opts.optopt("c", "... | code_fim | hard | {
"lang": "rust",
"repo": "lovesh/cs4144",
"path": "/ps2/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e usd_tf::token::TfToken;
pub use super::scalar_array::*;
pub use super::trait_array::*;
pub use super::tftoken_array::*;<|fim_prefix|>// repo: anderslanglands/usd-bind path: /usd-rs/crates/usd-vt/src/array.rs
use cppmm_refptr::*;
use imath_traits::{Vec2, Vec3, Vec4};
us<|fim_middle|>e std::ffi::CStr;
u... | code_fim | medium | {
"lang": "rust",
"repo": "anderslanglands/usd-bind",
"path": "/usd-rs/crates/usd-vt/src/array.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anderslanglands/usd-bind path: /usd-rs/crates/usd-vt/src/array.rs
use cppmm_refptr::*;
use imath_traits::{Vec2, Vec3, Vec4};
use std::ffi::CStr;
use std::ops::Deref;
use usd_sys as sys;
us<|fim_suffix|>b use super::trait_array::*;
pub use super::tftoken_array::*;<|fim_middle|>e usd_tf::token::Tf... | code_fim | medium | {
"lang": "rust",
"repo": "anderslanglands/usd-bind",
"path": "/usd-rs/crates/usd-vt/src/array.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: optimalstrategy/ppga path: /ppga/src/lib/frontend/mod.rs
//! Contains the implementations of the PPGA Lexer and Parser
//! as well as the AST definitions.
pub mod ast;
pub mod lexer;
pub mod parser;
<|fim_suffix|>/// Creates a new lexer from the given source code.
#[inline(always)]
pub fn lexer... | code_fim | easy | {
"lang": "rust",
"repo": "optimalstrategy/ppga",
"path": "/ppga/src/lib/frontend/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Creates a new lexer from the given source code.
#[inline(always)]
pub fn lexer<'a>(source: &'a str) -> parser::Lexer<'a> {
lexer::TokenKind::lexer(source)
}<|fim_prefix|>// repo: optimalstrategy/ppga path: /ppga/src/lib/frontend/mod.rs
//! Contains the implementations of the PPGA Lexer and Parser... | code_fim | easy | {
"lang": "rust",
"repo": "optimalstrategy/ppga",
"path": "/ppga/src/lib/frontend/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MR1991/wasp path: /contracts/wasm/testcore/src/results.rs
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
// (Re-)generated by schema tool
// >>>> DO NOT CHANGE THIS FILE! <<<<
// Change the json schema instead
#![allow(dead_code)]
#![allow(unused_imports)]
use wasmlib:... | code_fim | hard | {
"lang": "rust",
"repo": "MR1991/wasp",
"path": "/contracts/wasm/testcore/src/results.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct MapStringToImmutableString {
pub(crate) obj_id: i32,
}
impl MapStringToImmutableString {
pub fn get_string(&self, key: &str) -> ScImmutableString {
ScImmutableString::new(self.obj_id, key.get_key_id())
}
}
#[derive(Clone, Copy)]
pub struct ImmutableGetStringValueResults {
... | code_fim | hard | {
"lang": "rust",
"repo": "MR1991/wasp",
"path": "/contracts/wasm/testcore/src/results.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ImmutableTestChainOwnerIDViewResults {
pub fn chain_owner_id(&self) -> ScImmutableAgentID {
ScImmutableAgentID::new(self.id, idx_map(IDX_RESULT_CHAIN_OWNER_ID))
}
}
#[derive(Clone, Copy)]
pub struct MutableTestChainOwnerIDViewResults {
pub(crate) id: i32,
}
impl MutableTestChain... | code_fim | hard | {
"lang": "rust",
"repo": "MR1991/wasp",
"path": "/contracts/wasm/testcore/src/results.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn compliment_person(&self, person: &Person) -> String {
let default_compliment = self.compliment_repository.fetch_compliment();
default_compliment.display_sentence_for_pronouns(&person.pronoun)
}
}<|fim_prefix|>// repo: bachrc/bienveillance-land path: /bienveillance-core/src... | code_fim | hard | {
"lang": "rust",
"repo": "bachrc/bienveillance-land",
"path": "/bienveillance-core/src/smoothtalker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bachrc/bienveillance-land path: /bienveillance-core/src/smoothtalker.rs
use crate::person::{Person, Pronoun};
#[derive(Clone)]
pub struct Sentence {
pub components: Vec<SentenceComponent>,
}
impl Sentence {
pub fn display_sentence_for_pronouns(&self, pronouns: &Option<Pronoun>) -> Stri... | code_fim | medium | {
"lang": "rust",
"repo": "bachrc/bienveillance-land",
"path": "/bienveillance-core/src/smoothtalker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SmoothTalker {
pub fn new(compliment_repository: Box<dyn ComplimentRepository>) -> SmoothTalker {
SmoothTalker {
compliment_repository
}
}
pub fn compliment_person(&self, person: &Person) -> String {
let default_compliment = self.compliment_repository.... | code_fim | hard | {
"lang": "rust",
"repo": "bachrc/bienveillance-land",
"path": "/bienveillance-core/src/smoothtalker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewgazelka/rust-parallel path: /src/par_poly.rs
use rayon::prelude::*;
// pub fn calculate(coefficients: &mut [f64], input: f64) -> f64 {
// let len = coefficients.len();
//
// // modifies coeff idx i to be result of coeff_i*i<|fim_suffix|> });
//
// println!("coeff {:?}", coe... | code_fim | medium | {
"lang": "rust",
"repo": "andrewgazelka/rust-parallel",
"path": "/src/par_poly.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>icients.par_chunks_mut(chunk_size)
// .for_each(|x| x[0] += x[chunk_size / 2]);
// chunk_size *= 2;
// }
//
// // the result
// return coefficients[0];
// }<|fim_prefix|>// repo: andrewgazelka/rust-parallel path: /src/par_poly.rs
use rayon::prelude::*;
// pub fn calculate... | code_fim | hard | {
"lang": "rust",
"repo": "andrewgazelka/rust-parallel",
"path": "/src/par_poly.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rpc::{RPCEvent,RPCRequest,RPCResponse,RPCErrorResponse,RPCProtocol,RPC};
pub use service::Libp2pEvent;
pub use service::Service;
pub use service::Message;
pub use service::DISCOVERY;
pub use service::GOSSIP;
pub use service::RPC;<|fim_prefix|>// repo: sgryphon/mothra path: /core/src/libp2p-wrapper/src/l... | code_fim | hard | {
"lang": "rust",
"repo": "sgryphon/mothra",
"path": "/core/src/libp2p-wrapper/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgryphon/mothra path: /core/src/libp2p-wrapper/src/lib.rs
/// This crate contains the main link for artemis to rust-libp2p. It therefore re-exports
/// all required libp2p functionality.
///
/// This crate builds and manages the libp2p services required by the beacon node.
pub mod behaviour;
mod... | code_fim | hard | {
"lang": "rust",
"repo": "sgryphon/mothra",
"path": "/core/src/libp2p-wrapper/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shun159/mist path: /src/logger.rs
// Copyright 2020 Eishun Kondoh
// SPDX-License-Identifier: Apache-2.0
<|fim_suffix|>pub fn info<'a>(msg: &'a str) {
info!("{}", msg)
}
pub fn warn<'a>(msg: &'a str) {
warn!("{}", msg)
}
pub fn error<'a>(msg: &'a str) {
error!("{}", msg)
}<|fim_mi... | code_fim | medium | {
"lang": "rust",
"repo": "shun159/mist",
"path": "/src/logger.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn info<'a>(msg: &'a str) {
info!("{}", msg)
}
pub fn warn<'a>(msg: &'a str) {
warn!("{}", msg)
}
pub fn error<'a>(msg: &'a str) {
error!("{}", msg)
}<|fim_prefix|>// repo: shun159/mist path: /src/logger.rs
// Copyright 2020 Eishun Kondoh
// SPDX-License-Identifier: Apache-2.0
use log:... | code_fim | easy | {
"lang": "rust",
"repo": "shun159/mist",
"path": "/src/logger.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn warn<'a>(msg: &'a str) {
warn!("{}", msg)
}
pub fn error<'a>(msg: &'a str) {
error!("{}", msg)
}<|fim_prefix|>// repo: shun159/mist path: /src/logger.rs
// Copyright 2020 Eishun Kondoh
// SPDX-License-Identifier: Apache-2.0
use log::{debug, error, info, warn};
pub fn debug<'a>(msg: &'a ... | code_fim | easy | {
"lang": "rust",
"repo": "shun159/mist",
"path": "/src/logger.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArtDark/sigchain path: /sigchain_client/src/block_validation/membership_tests.rs
.hash(), false);
users.push(user);
blocks.extend(user_add_blocks);
blocks.push(self_remove_block);
});
gen_test!(member_remove_non_member,
|users: &mut Vec<User>, blocks: &mut Vec<TestBlock>| {
//... | code_fim | hard | {
"lang": "rust",
"repo": "ArtDark/sigchain",
"path": "/sigchain_client/src/block_validation/membership_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArtDark/sigchain path: /sigchain_client/src/block_validation/membership_tests.rs
&mut Vec<TestBlock>| {
// Generate and add (direct invite and accept) user 1 to team.
let user_1 = generate_user(&users[0].client.team_public_key, 1);
let user_1_add_blocks = add_user_blocks(&users[0], ... | code_fim | hard | {
"lang": "rust",
"repo": "ArtDark/sigchain",
"path": "/sigchain_client/src/block_validation/membership_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>gen_test!(admin_demote_non_member,
|users: &mut Vec<User>, blocks: &mut Vec<TestBlock>| {
// Generate user.
let user = generate_user(&users[0].client.team_public_key, 1);
// Try to demote user.
let user_demote_block = demote_user_block(
&users[0], &user, &blocks.last().unwrap().h... | code_fim | hard | {
"lang": "rust",
"repo": "ArtDark/sigchain",
"path": "/sigchain_client/src/block_validation/membership_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamespharaoh/rzbackup path: /src/zbackup/bundle_loader.rs
use std::collections::HashMap;
use std::collections::LinkedList;
use std::ops::DerefMut;
use std::sync::Arc;
use std::sync::Mutex;
use std::thread;
use std::thread::JoinHandle;
use futures::BoxFuture;
use futures::Future;
use futures::Si... | code_fim | hard | {
"lang": "rust",
"repo": "jamespharaoh/rzbackup",
"path": "/src/zbackup/bundle_loader.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (bundle_sender, bundle_receiver) =
oneshot::channel ();
let bundle_receiver =
bundle_receiver.shared ().cloning ();
self.load_bundle_async_impl (
self_state,
bundle_id,
bundle_sender,
bundle_receiver.clone ());
let bundle_future_channel =
self_stat... | code_fim | hard | {
"lang": "rust",
"repo": "jamespharaoh/rzbackup",
"path": "/src/zbackup/bundle_loader.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("PART 1 | {}", counts[0] * counts[2]);
println!("PART 2 | {}", adapters.n_arrangements());
}<|fim_prefix|>// repo: lawrencecrane/adventofcode2020 path: /day10/src/main.rs
use aoc_utils::*;
mod lib;
use lib::*;
fn main() {
<|fim_middle|> let adapters = Adapters::new(
read_li... | code_fim | hard | {
"lang": "rust",
"repo": "lawrencecrane/adventofcode2020",
"path": "/day10/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lawrencecrane/adventofcode2020 path: /day10/src/main.rs
use aoc_utils::*;
mod lib;
use lib::*;
fn main() {
let adapters = Adapters::new(
read_lines("../data/10_input")
.unwrap()
.map(|s| s.unwrap().parse().unwrap())
.collect(),
);
<|fim_suf... | code_fim | easy | {
"lang": "rust",
"repo": "lawrencecrane/adventofcode2020",
"path": "/day10/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tmantock/rust path: /functions/src/main.rs
fn main() {
let x: i32 = 5;
let y: i32 = 68;
print_number(y);
let sum_to_print = sum_number(x,y);
println!("{:?}", sum_to_print);
// without type inference
let f: fn(i32) -> i32 = plus_one;
// with type inference
l... | code_fim | medium | {
"lang": "rust",
"repo": "tmantock/rust",
"path": "/functions/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("x is {}", a);
}
// fn diverges() -> ! {
// panic!("This function never returns!");
// }<|fim_prefix|>// repo: tmantock/rust path: /functions/src/main.rs
fn main() {
let x: i32 = 5;
let y: i32 = 68;
print_number(y);
let sum_to_print = sum_number(x,y);
println!("{:?}... | code_fim | medium | {
"lang": "rust",
"repo": "tmantock/rust",
"path": "/functions/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: codefather-labs/TON-SDK path: /ton_client/platforms/ton-client-web/src/lib.rs
/*
* Copyright 2018-2020 TON DEV SOLUTIONS LTD.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable l... | code_fim | medium | {
"lang": "rust",
"repo": "codefather-labs/TON-SDK",
"path": "/ton_client/platforms/ton-client-web/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen]
pub fn request(method: String, params_json: String) -> String {
serde_json::to_string(
&json_sync_request(
create_context(),
method,
params_json))
.unwrap_or("{message: \"???\"".to_string())
}<|fim_prefix|>// repo: codefather-labs/TON... | code_fim | medium | {
"lang": "rust",
"repo": "codefather-labs/TON-SDK",
"path": "/ton_client/platforms/ton-client-web/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laopo001/wasm-math path: /src/node.rs
extern crate wasm_bindgen;
#[allow(unused_imports)]
use wasm_bindgen::prelude::*;
use crate::mat4::Mat4;
use crate::quat::Quat;
use crate::vec3::Vec3;
#[allow(unused_imports)]
use std::cell::{RefCell, UnsafeCell};
#[allow(unused_imports)]
use std::ops::Dere... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/wasm-math",
"path": "/src/node.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_child_set_get_angles() {
let mut node = Node::new();
let mut child = Node::new();
let mut grandson = Node::new();
node.add_child(&mut child);
child.add_child(&mut grandson);
node.set_local_euler_angles(1.0, 0.0, 0.0);
child.set_local_euler_angles(1.0, 0.0, 0.0);... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/wasm-math",
"path": "/src/node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if unlock_end_ts <= grant_start_ts {
msg!("Grant issue time is in the future!");
return Err(ProgramError::InvalidArgument);
}
if grant_account.initial_cliff_sec > 0 {
let initial_cliff_ts = grant_account.issue_ts +
grant_account.... | code_fim | hard | {
"lang": "rust",
"repo": "marius-x/spur",
"path": "/programs/spur/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut unlock_amount_available = grant_account.amount_total;
if unlock_end_ts < grant_end_ts {
// Grant is not yet fully vested
let grant_num_periods = (grant_account.duration_sec + grant_account.vest_interval_sec - 1)
/ grant_account.vest_interval_... | code_fim | hard | {
"lang": "rust",
"repo": "marius-x/spur",
"path": "/programs/spur/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marius-x/spur path: /programs/spur/src/lib.rs
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Transfer};
use spl_associated_token_account::{get_associated_token_address};
// //use spl_token::instruction::AuthorityType;
// use anchor_spl::associated_token;
use context::*;
mod account... | code_fim | hard | {
"lang": "rust",
"repo": "marius-x/spur",
"path": "/programs/spur/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maghoff/post-box path: /src/main.rs
extern crate base64;
extern crate crypto;
extern crate getopts;
extern crate rotor;
extern crate rotor_http;
use std::path::PathBuf;
use std::time::Duration;
use rotor::{Scope, Time};
use rotor_http::server::{RecvMode, Server, Head, Response, Fsm};
use rotor:... | code_fim | hard | {
"lang": "rust",
"repo": "maghoff/post-box",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn request_chunk(self, _chunk: &[u8], _response: &mut Response, _scope: &mut Scope<Context>)
-> Option<Self>
{
unreachable!();
}
/// End of request body, only for Progressive requests
fn request_end(self, _response: &mut Response, _scope: &mut Scope<Context>)
-... | code_fim | hard | {
"lang": "rust",
"repo": "maghoff/post-box",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let context = Context {
file_root: PathBuf::from(&matches.opt_str("root").unwrap_or("".to_owned())),
key: base64::decode(
&matches.opt_str("key").expect("You must specify HMAC key with --key")
).expect("KEY must be correctly base64 encoded"),
root_ur... | code_fim | hard | {
"lang": "rust",
"repo": "maghoff/post-box",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>= "dmic_ints (rw) register accessor: an alias for `Reg<DMIC_INTS_SPEC>`"]
pub type DMIC_INTS = crate::Reg<dmic_ints::DMIC_INTS_SPEC>;
#[doc = "DMIC Interrupt Status Register"]
pub mod dmic_ints;
#[doc = "dmic_rxfifo_ctr (rw) register accessor: an alias for `Reg<DMIC_RXFIFO_CTR_SPEC>`"]
pub type DMIC_RXFIF... | code_fim | hard | {
"lang": "rust",
"repo": "duskmoon314/aw-pac",
"path": "/d1-pac/src/dmic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>NT_SPEC>;
#[doc = "DMIC Counter Register"]
pub mod dmic_cnt;
#[doc = "data0_data1_vol_ctr (rw) register accessor: an alias for `Reg<DATA0_DATA1_VOL_CTR_SPEC>`"]
pub type DATA0_DATA1_VOL_CTR = crate::Reg<data0_data1_vol_ctr::DATA0_DATA1_VOL_CTR_SPEC>;
#[doc = "Data0 and Data1 Volume Control Register"]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "duskmoon314/aw-pac",
"path": "/d1-pac/src/dmic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /d1-pac/src/dmic.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - DMIC Enable Control Register"]
pub dmic_en: DMIC_EN,
#[doc = "0x04 - DMIC Sample Rate Register"]
pub dmic_sr: DMIC_SR,
#[doc = "0x08 - DMIC Control Re... | code_fim | hard | {
"lang": "rust",
"repo": "duskmoon314/aw-pac",
"path": "/d1-pac/src/dmic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Elianagam/blockchain path: /src/utils/logger.rs
use std::fs::File;
use std::io::{Error, Write};
use std::sync::Mutex;
#[derive(Debug)]
pub struct Logger {
file: Mutex<std::fs::File>,
}
<|fim_suffix|> pub fn info(&self, msg: String) {
match self.write(format!("[INFO] - {}", msg))... | code_fim | hard | {
"lang": "rust",
"repo": "Elianagam/blockchain",
"path": "/src/utils/logger.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn info(&self, msg: String) {
match self.write(format!("[INFO] - {}", msg)) {
Ok(_) => {}
Err(_) => {
println!("Unable to write to logging file. Logging messages won't be saved.");
}
}
}
}<|fim_prefix|>// repo: Elianagam/block... | code_fim | hard | {
"lang": "rust",
"repo": "Elianagam/blockchain",
"path": "/src/utils/logger.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m-hilgendorf/tuix path: /core/src/systems/layout_system.rs
_ => {}
}
//state.transform.set_posx(child, new_posx);
//state.transform.set_posy(child, new_posy);
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "m-hilgendorf/tuix",
"path": "/core/src/systems/layout_system.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parent_padding_bottom = match state
.style
.padding_bottom
.get(parent)
.cloned()
.unwrap_or_default()
{
Length::Pixels(val) => val,
Length::Percentage(val) => parent_height * val,
_ => 0.0,... | code_fim | hard | {
"lang": "rust",
"repo": "m-hilgendorf/tuix",
"path": "/core/src/systems/layout_system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Apply size contraints
if new_width < child_min_width {
new_width = child_min_width;
}
if new_width > child_max_width {
new_wid... | code_fim | hard | {
"lang": "rust",
"repo": "m-hilgendorf/tuix",
"path": "/core/src/systems/layout_system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/macros/macro-lifetime.rs
// run-pass
macro_rules! foo {
($l:lifetime) => {
fn f<$l>(arg: &$l str) -> &$l str {
<|fim_suffix|>pub fn main() {
foo!('a);
let x: &'static str = f("hi");
assert_eq!("hi", x);
}<|fim_middl... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/macros/macro-lifetime.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn main() {
foo!('a);
let x: &'static str = f("hi");
assert_eq!("hi", x);
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/macros/macro-lifetime.rs
// run-pass
macro_rules! foo {
($l:lifetime) => {
fn f<$l>(arg: &$l str) -> &$l str {
<|fim_middl... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/macros/macro-lifetime.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rsantos16/HashMap path: /src/lib.rs
pub struct HashMap<K, V> {
buckets: Vec<Vec<(K, V)>>,
}
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_middle|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
| code_fim | easy | {
"lang": "rust",
"repo": "rsantos16/HashMap",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: rsantos16/HashMap path: /src/lib.rs
pub struct HashMap<K, V> {
buckets: Vec<Vec<(K, V)>>,
}
<|fim_middle|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
| code_fim | easy | {
"lang": "rust",
"repo": "rsantos16/HashMap",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ekaats/bevy_ecs_tilemap path: /examples/animation.rs
use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
};
use bevy_ecs_tilemap::prelude::*;
use rand::{thread_rng, Rng};
mod helpers;
fn startup(
mut commands: Commands,
asset_server: Res<Asse... | code_fim | hard | {
"lang": "rust",
"repo": "ekaats/bevy_ecs_tilemap",
"path": "/examples/animation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
env_logger::Builder::from_default_env()
.filter_level(log::LevelFilter::Info)
.init();
App::build()
.insert_resource(WindowDescriptor {
width: 1270.0,
height: 720.0,
title: String::from("Animated Map Example"),
..... | code_fim | hard | {
"lang": "rust",
"repo": "ekaats/bevy_ecs_tilemap",
"path": "/examples/animation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mohammed-Kashem/zenith path: /src/game/enemy.rs
use bevy::prelude::*;
use rand::prelude::*;
use crate::game::animation::{self, AnimationTimer};
use crate::game::bullet::{Bullet, FireRate};
use crate::game::collision::{self, DespawnOutside, Hitbox, SpriteSize};
use crate::game::level::{CurrentLe... | code_fim | hard | {
"lang": "rust",
"repo": "Mohammed-Kashem/zenith",
"path": "/src/game/enemy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (
atlas,
Attack::Bomb,
DeathBehavior::Star,
FireRate::Random(0.005),
2,
Movement::Strafe,
31.0,
... | code_fim | hard | {
"lang": "rust",
"repo": "Mohammed-Kashem/zenith",
"path": "/src/game/enemy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kethku/Pando path: /src/controllers/handles_mouse.rs
use druid::*;
use druid::widget::Controller;
pub struct HandlesMouse;
<|fim_suffix|> child.event(ctx, event, data, env);
match event {
Event::MouseDown(_) => ctx.set_handled(),
Event::MouseMo... | code_fim | medium | {
"lang": "rust",
"repo": "Kethku/Pando",
"path": "/src/controllers/handles_mouse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> child.event(ctx, event, data, env);
match event {
Event::MouseDown(_) => ctx.set_handled(),
Event::MouseMove(_) => ctx.set_handled(),
Event::MouseUp(_) => ctx.set_handled(),
_ => { }
}
}
}<|fim_prefix|>// repo: Kethku/Pa... | code_fim | medium | {
"lang": "rust",
"repo": "Kethku/Pando",
"path": "/src/controllers/handles_mouse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_get_set_pid() {
let mut container = Container::default();
assert_eq!(container.pid(), None);
container.set_pid(1);
assert_eq!(container.pid(), Some(Pid::from_raw(1)));
}
#[test]
fn test_basic_getter() -> Result<()> {
let mut con... | code_fim | hard | {
"lang": "rust",
"repo": "krisnova/youki",
"path": "/crates/libcontainer/src/container/container.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
#[serial]
fn test_get_spec() -> Result<()> {
let tmp_dir = create_temp_dir("test_get_spec")?;
use oci_spec::runtime::Spec;
let spec = Spec::default();
let config =
YoukiConfig::from_spec(&spec, "123", false).context("convert spec to config")?... | code_fim | hard | {
"lang": "rust",
"repo": "krisnova/youki",
"path": "/crates/libcontainer/src/container/container.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: krisnova/youki path: /crates/libcontainer/src/container/container.rs
use std::collections::HashMap;
use std::ffi::OsString;
use std::fs;
use std::path::{Path, PathBuf};
use anyhow::Result;
use chrono::DateTime;
use nix::unistd::Pid;
use chrono::Utc;
use procfs::process::Process;
use crate::co... | code_fim | hard | {
"lang": "rust",
"repo": "krisnova/youki",
"path": "/crates/libcontainer/src/container/container.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut roots: Vec<u32> = Vec::new();
if matches.is_present("use-most-linked") {
let count: u32 = matches.value_of("use-most-linked").unwrap().parse().unwrap();
roots = analysis.get_most_links(count)
.iter()
.m... | code_fim | hard | {
"lang": "rust",
"repo": "tdransfield/wikipedia-analysis",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tdransfield/wikipedia-analysis path: /src/main.rs
.help("Wikipedia XML dump file to parse")
)
.arg(Arg::with_name("output")
.short("o")
.long("output")
.takes_value(true)
.default_value("_proc... | code_fim | hard | {
"lang": "rust",
"repo": "tdransfield/wikipedia-analysis",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(matches) = matches.subcommand_matches("most-linked") {
let count: u32 = match matches.value_of("count").unwrap().parse().unwrap() {
0 => analysis.articles.len().try_into().unwrap(),
x => x
};
let link_counts = analysi... | code_fim | hard | {
"lang": "rust",
"repo": "tdransfield/wikipedia-analysis",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/finspacedata/src/error.rs
> Some(_inner),
CreateChangesetErrorKind::Unhandled(_inner) => Some(_inner.as_ref()),
}
}
}
#[non_exhaustive]
#[derive(std::fmt::Debug)]
pub struct GetProgrammaticAccessCredentialsError {
pub kind: GetProgramma... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/finspacedata/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/finspacedata/src/error.rs
-> &smithy_types::Error {
&self.meta
}
pub fn request_id(&self) -> Option<&str> {
self.meta.request_id()
}
pub fn code(&self) -> Option<&str> {
self.meta.code()
}
pub fn is_access_denied_ex... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/finspacedata/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "ThrottlingException")?;
if let Some(inner_2) = &self.message {
write!(f, ": {}", inner_2)?;
}
Ok(())
}
}
impl std::error::Error for ThrottlingException {}
/// See [`ThrottlingException`](crate::error::ThrottlingException)
pub mod throttling_except... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/finspacedata/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GlebIrovich/rudo path: /src/app_layout.rs
use crate::app::{App, AppSorting, AppStage};
use tui::backend::Backend;
use tui::layout::{Alignment, Constraint, Direction, Layout, Rect};
use tui::style::{Color, Modifier, Style};
use tui::widgets::{Block, Borders, List, ListItem, ListState, Paragraph, ... | code_fim | hard | {
"lang": "rust",
"repo": "GlebIrovich/rudo",
"path": "/src/app_layout.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> frame.render_widget(paragraph.block(help_block), info_layout_chunks[0]);
frame.render_widget(
version_paragraph.block(version_block),
info_layout_chunks[1],
);
}
pub fn draw_filter_widget<B>(&self, frame: &mut Frame<B>, filter_term: &str, area: Rect... | code_fim | hard | {
"lang": "rust",
"repo": "GlebIrovich/rudo",
"path": "/src/app_layout.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.filter_block = Block::default()
.borders(Borders::ALL)
.title("Filter")
.border_style(Style::default().fg(border_color));
let app_layout_chunks = self.layout.split(area);
let list_layout_chunks =
self.list_layout
... | code_fim | hard | {
"lang": "rust",
"repo": "GlebIrovich/rudo",
"path": "/src/app_layout.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnmcl001/TheRustProgrammingLanguage path: /RustByExample/19_StandardLibraryTypes/19_2_vectors.rs
fn main() {
// Iterators an be collected into vectors
let collected_iterator: Vec<i32> = (0..10).collect();
println!("Collected (0..10) into: {:?}", collected_iterator);
// The vec! macro can... | code_fim | hard | {
"lang": "rust",
"repo": "johnmcl001/TheRustProgrammingLanguage",
"path": "/RustByExample/19_StandardLibraryTypes/19_2_vectors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // vector can also be iterated over while the iteration count is enumerated
for (i, x) in xs.iter().enumerate() {
println!("The position of {} is {}", x, i);
}
// iter_mut lets mutable vectors be iterated over in a way that allows
// modification
for x in xs.iter_mut() {
*x += 3;
}
println!("... | code_fim | hard | {
"lang": "rust",
"repo": "johnmcl001/TheRustProgrammingLanguage",
"path": "/RustByExample/19_StandardLibraryTypes/19_2_vectors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: str4d/metrics path: /metrics-macros/src/lib.rs
extern crate proc_macro;
use self::proc_macro::TokenStream;
use lazy_static::lazy_static;
use proc_macro_hack::proc_macro_hack;
use quote::{format_ident, quote, ToTokens};
use regex::Regex;
use syn::parse::discouraged::Speculative;
use syn::parse:... | code_fim | hard | {
"lang": "rust",
"repo": "str4d/metrics",
"path": "/metrics-macros/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> metric_type: &str,
key: LitStr,
unit: Option<Expr>,
description: Option<LitStr>,
labels: Option<Labels>,
) -> proc_macro2::TokenStream {
let register_ident = format_ident!("register_{}", metric_type);
let key = key_to_quoted(key, labels);
let unit = match unit {
So... | code_fim | hard | {
"lang": "rust",
"repo": "str4d/metrics",
"path": "/metrics-macros/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_labels(input: &mut ParseStream) -> Result<Option<Labels>> {
if input.is_empty() {
return Ok(None);
}
if !input.peek(Token![,]) {
// This is a hack to generate the proper error message for parsing the comma next without
// actually parsing it and thus removing ... | code_fim | hard | {
"lang": "rust",
"repo": "str4d/metrics",
"path": "/metrics-macros/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: book-resources/rustlernen path: /10-Benutzerdefinierte Typen/programmtext-125.rs
#[derive(Debug)]
struct Rechteck {
breite: u32,
hoehe: u32
}
impl Rechteck {
fn create(breite: u32, hoehe: u32) -> Rechteck {
<|fim_suffix|> let r1 = Rechteck::create(10, 15);
println!("r1 = {:?}", r... | code_fim | easy | {
"lang": "rust",
"repo": "book-resources/rustlernen",
"path": "/10-Benutzerdefinierte Typen/programmtext-125.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Rechteck {breite, hoehe}
}
}
fn main() {
let r1 = Rechteck::create(10, 15);
println!("r1 = {:?}", r1);
}<|fim_prefix|>// repo: book-resources/rustlernen path: /10-Benutzerdefinierte Typen/programmtext-125.rs
#[derive(Debug)]
struct Rechteck {
breite: u32,
hoehe: u32
}
<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "book-resources/rustlernen",
"path": "/10-Benutzerdefinierte Typen/programmtext-125.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("r1 = {:?}", r1);
}<|fim_prefix|>// repo: book-resources/rustlernen path: /10-Benutzerdefinierte Typen/programmtext-125.rs
#[derive(Debug)]
struct Rechteck {
breite: u32,
hoehe: u32
}
<|fim_middle|>impl Rechteck {
fn create(breite: u32, hoehe: u32) -> Rechteck {
Rechteck {breite,... | code_fim | medium | {
"lang": "rust",
"repo": "book-resources/rustlernen",
"path": "/10-Benutzerdefinierte Typen/programmtext-125.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cx: sio::ctx = sio::new();
sio::destroy(cx);
}<|fim_prefix|>// repo: ehsan/rust path: /src/test/run-pass/sio-ctx.rs
// Seems to hang for long periods, probably with RUST_THREADS > 1. Issue #810
// xfail-test
<|fim_middle|>use std;
import std::sio;
fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "ehsan/rust",
"path": "/src/test/run-pass/sio-ctx.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let cx: sio::ctx = sio::new();
sio::destroy(cx);
}<|fim_prefix|>// repo: ehsan/rust path: /src/test/run-pass/sio-ctx.rs
// Seems to hang for long periods, probably with RUST_THREADS > 1. Issue #810
// xfail-test
<|fim_middle|>use std;
import std::sio;
| code_fim | easy | {
"lang": "rust",
"repo": "ehsan/rust",
"path": "/src/test/run-pass/sio-ctx.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehsan/rust path: /src/test/run-pass/sio-ctx.rs
// Seems to hang for long periods, probably with RUST_THREADS > 1. Issue #810
// xfail-test
use std;
import std::sio;
<|fim_suffix|> let cx: sio::ctx = sio::new();
sio::destroy(cx);
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "ehsan/rust",
"path": "/src/test/run-pass/sio-ctx.rs",
"mode": "psm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SaurabhTotey/Minotaur path: /src/network/mod.rs
use std::net::TcpStream;
use std::io::Read;
pub mod HeroManager;
pub mod MinotaurManager;
pub mod Action;
pub mod MinotaurMessage;
const PORT: i32 = 6669;
/**
* Blocks and gets input from stdin
*/
fn getUserInput() -> Action::Action {
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "SaurabhTotey/Minotaur",
"path": "/src/network/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /**
* Should handle a response from the other player over the network
* Network manager should take in the network response itself in this method
* Should return whether the program is done
*/
fn handleResponse(&mut self) -> bool;
/**
* Should actually run the game to completion
*/
fn run... | code_fim | hard | {
"lang": "rust",
"repo": "SaurabhTotey/Minotaur",
"path": "/src/network/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ret.push_str(&format!("struct __wasi_{}_t {{\n", ident_name(name)));
for member in &s.members {
if !member.docs.is_empty() {
ret.push_str(" /**\n");
for line in member.docs.lines() {
ret.push_str(&format!(" * {}\n", line));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "WasmEdge/WasmEdge",
"path": "/utils/wasi-cpp-header/src/cpp_header.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_record(ret: &mut String, name: &Id, s: &RecordDatatype) {
if let Some(repr) = s.bitflags_repr() {
ret.push_str(&format!(
"enum __wasi_{}_t : {} {{\n",
ident_name(name),
intrepr_name(repr)
));
ret.push_str("\n");
for (i, membe... | code_fim | hard | {
"lang": "rust",
"repo": "WasmEdge/WasmEdge",
"path": "/utils/wasi-cpp-header/src/cpp_header.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WasmEdge/WasmEdge path: /utils/wasi-cpp-header/src/cpp_header.rs
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2019-2022 Second State INC
use heck::ShoutySnakeCase;
use witx::*;
pub fn to_cpp_header(doc: &Document, inputs_str: &str) -> String {
let mut ret = String::new... | code_fim | hard | {
"lang": "rust",
"repo": "WasmEdge/WasmEdge",
"path": "/utils/wasi-cpp-header/src/cpp_header.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use crate::query_document::*;<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/core/src/query_graph_builder/extractors/mod.rs
mod filters;
mod query_arguments;
mod rel_aggregations;
mod utils;
<|fim_middle|>pub(crate) use filters::*;
pub(crate) use query_arguments::*;
pub(crate) use rel_a... | code_fim | medium | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/core/src/query_graph_builder/extractors/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.