text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> Ok(SrdOffer {
ciphers,
key_size,
generator,
prime,
public_key,
nonce,
})
}
fn write_to<W: Write>(&self, writer: &mut W) -> Result<()> {
writer.write_u32::<LittleEndian>(self.ciphers)?;
writer.w... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/sardine-rs",
"path": "/sardine/src/messages/srd_offer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let res = run("boxed-error.rs");
println!("{:?}", res);
}<|fim_prefix|>// repo: johnyenter-briars/gentle_intro_to_rust path: /err_handling/boxed-error.rs
use std::fs::File;
use std::io::prelude::*;
use std::error::Error;
//handle BOTH io errors and conversions error
fn run(file: &str) -> ... | code_fim | medium | {
"lang": "rust",
"repo": "johnyenter-briars/gentle_intro_to_rust",
"path": "/err_handling/boxed-error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = run("boxed-error.rs");
println!("{:?}", res);
}<|fim_prefix|>// repo: johnyenter-briars/gentle_intro_to_rust path: /err_handling/boxed-error.rs
use std::fs::File;
use std::io::prelude::*;
use std::error::Error;
<|fim_middle|>
//handle BOTH io errors and conversions error
fn run(file: &str) -... | code_fim | hard | {
"lang": "rust",
"repo": "johnyenter-briars/gentle_intro_to_rust",
"path": "/err_handling/boxed-error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnyenter-briars/gentle_intro_to_rust path: /err_handling/boxed-error.rs
use std::fs::File;
use std::io::prelude::*;
use std::error::Error;
<|fim_suffix|> let mut file = File::open(file)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
Ok(contents.trim().parse()?) /... | code_fim | medium | {
"lang": "rust",
"repo": "johnyenter-briars/gentle_intro_to_rust",
"path": "/err_handling/boxed-error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cedretaber/codes_for_atcoder path: /abc/042/a.rs
macro_rules! get {
($t:ty) => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse::<$t>().unwrap()
}
};
($($t:ty),*) => {
... | code_fim | medium | {
"lang": "rust",
"repo": "cedretaber/codes_for_atcoder",
"path": "/abc/042/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let abc = get!(String);
let mut abc: Vec<i32> = abc.split_whitespace().map(|c| c.parse().unwrap()).collect();
abc.sort();
let cor = vec![5, 5, 7];
println!("{}", if abc == cor {
"YES"
} else {
"NO"
});
}<|fim_prefix|>// repo: cedretaber/codes_for_atcoder p... | code_fim | medium | {
"lang": "rust",
"repo": "cedretaber/codes_for_atcoder",
"path": "/abc/042/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let arg = Expr::Const(1i32.into());
let bin_op = Expr::BinOp(BinOp {
kind: RelationOp::Eq.into(),
left: Box::new(
ValUse {
val_id: 1.into(),
tpe: SType::SInt,
}
.into(),
... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergotree-interpreter/src/eval/apply.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ergoplatform/sigma-rust path: /ergotree-interpreter/src/eval/apply.rs
use ergotree_ir::mir::apply::Apply;
use ergotree_ir::mir::val_def::ValId;
use ergotree_ir::mir::value::Value;
use crate::eval::env::Env;
use crate::eval::EvalContext;
use crate::eval::EvalError;
use crate::eval::Evaluable;
i... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergotree-interpreter/src/eval/apply.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JJJollyjim/crate2nix path: /crate2nix/src/sources.rs
//! Manage nix-generated Cargo workspaces.
use crate::{
config,
prefetch::PrefetchableSource,
resolve::{CratesIoSource, GitSource},
};
use anyhow::{bail, format_err, Context, Error};
use semver::Version;
use std::{
borrow::Cow... | code_fim | hard | {
"lang": "rust",
"repo": "JJJollyjim/crate2nix",
"path": "/crate2nix/src/sources.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let inputs = [self.crate2nix_json_path.as_ref()];
let last_modified: fn(&std::path::Path) -> Option<SystemTime> =
|f: &std::path::Path| f.metadata().ok().and_then(|m| m.modified().ok());
let input_last_modified: SystemTime = inputs
.iter()
.flat... | code_fim | hard | {
"lang": "rust",
"repo": "JJJollyjim/crate2nix",
"path": "/crate2nix/src/sources.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
fn cargo_generate_lockfile(
project_dir: impl AsRef<Path>,
cargo_toml: impl AsRef<Path>,
) -> Result<(), Error> {
crate::command::run(
"Updating Cargo.lock",
Command::new("cargo").current_dir(&project_dir).args(&[
"generate-lockfile",
... | code_fim | hard | {
"lang": "rust",
"repo": "JJJollyjim/crate2nix",
"path": "/crate2nix/src/sources.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/fsh path: /src/process.rs
use crate::history::History;
use glob::glob;
use std::env;
use std::process::Command;
use std::str;
pub(crate) fn execute(command_line: String, history_handler: &mut History) {
// Split command line
// [0] is command and [1..] are arguments
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/fsh",
"path": "/src/process.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for arg in args {
if arg.contains('*') {
let path = std::path::Path::new(arg);
let paths = if path.is_relative() {
glob(&format!("./{}", arg)).expect("Failed to read glob pattern")
} else {
glob(arg).expect("Failed to read glo... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/fsh",
"path": "/src/process.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn send_recv_shared() {
let (tx, rx) = unbounded::<usize>();
let rx2 = rx.clone();
let mut rx = rx.wait();
let mut rx2 = rx2.wait();
tx.send(1).wait().unwrap();
assert_eq!(rx.next().unwrap().unwrap().deref(), &1);
assert_eq!(rx2.next().unwrap().unwrap().deref(), &1);
... | code_fim | medium | {
"lang": "rust",
"repo": "AtsukiTak/ex-futures",
"path": "/tests/unsync_unbounded.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AtsukiTak/ex-futures path: /tests/unsync_unbounded.rs
extern crate ex_futures;
extern crate futures;
extern crate tokio_core;
use ex_futures::unsync::pubsub::unbounded;
use futures::{Future, Stream, Sink};
use futures::stream::unfold;
use futures::future::ok;
<|fim_suffix|>#[test]
fn send_rec... | code_fim | medium | {
"lang": "rust",
"repo": "AtsukiTak/ex-futures",
"path": "/tests/unsync_unbounded.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(rx.next().unwrap().unwrap().deref(), &1);
assert_eq!(rx2.next().unwrap().unwrap().deref(), &1);
}
#[test]
fn send_many_items() {
let mut core = Core::new().unwrap();
let stream = unfold(0, |i| Some(ok::<_, _>((i, i + 1)))).take(4);
let (tx, rx) = unbounded::<usize>();
... | code_fim | medium | {
"lang": "rust",
"repo": "AtsukiTak/ex-futures",
"path": "/tests/unsync_unbounded.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: berquist/eg path: /rust/test-cxx/src/lib.rs
#[cxx::bridge]
mod ffi {
extern "C++" {
include!("test-cxx/include/wrapper.hpp");
type Dummy;
fn make_new_dummy() -> UniquePtr<Dummy>;
<|fim_middle|> }
}
#[cfg(test)]
mo... | code_fim | medium | {
"lang": "rust",
"repo": "berquist/eg",
"path": "/rust/test-cxx/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: berquist/eg path: /rust/test-cxx/src/lib.rs
#[cxx::bridge]
mod ffi {
extern "C++" {
include!("test-cxx/include/wrapper.hpp");
type Dummy;
fn make_new_dummy() -> UniquePtr<Dummy>;
}
}
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_middle|>#[cfg(test)]
mo... | code_fim | easy | {
"lang": "rust",
"repo": "berquist/eg",
"path": "/rust/test-cxx/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_shuffled_deck() -> Vec<i32> {
let mut rng = rand::thread_rng();
let mut deck = (0..4).flat_map(|_| (0..13)).collect::<Vec<i32>>();
deck.shuffle(&mut rng);
deck
}<|fim_prefix|>// repo: stripedpajamas/go-fish path: /src/main.rs
use rand::prelude::*;
fn main() {
<|fim_middle|> let... | code_fim | medium | {
"lang": "rust",
"repo": "stripedpajamas/go-fish",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stripedpajamas/go-fish path: /src/main.rs
use rand::prelude::*;
fn main() {
let deck = get_shuffled_deck();
println!("{:?}", deck);
}
<|fim_suffix|> let mut rng = rand::thread_rng();
let mut deck = (0..4).flat_map(|_| (0..13)).collect::<Vec<i32>>();
deck.shuffle(&mut rng);
... | code_fim | easy | {
"lang": "rust",
"repo": "stripedpajamas/go-fish",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{:?}", deck);
}
fn get_shuffled_deck() -> Vec<i32> {
let mut rng = rand::thread_rng();
let mut deck = (0..4).flat_map(|_| (0..13)).collect::<Vec<i32>>();
deck.shuffle(&mut rng);
deck
}<|fim_prefix|>// repo: stripedpajamas/go-fish path: /src/main.rs
use rand::prelude::*;
fn... | code_fim | easy | {
"lang": "rust",
"repo": "stripedpajamas/go-fish",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: badboy/base-emoji-rs path: /src/lib.rs
//! # base_emoji
//!
//! Convert everything to Emojis (and back)!
//!
//! 🐫🔦🔥🎲🐬🍀🍟🔋🐬🎲🐬🍀🎁🍟💧👂🔥🚪🔋🍟🔦🔋🚗👣🔦🌍👂🍤🐗
//!
//! Reimplementation of [base_emoji](https://github.com/pfrazee/base-emoji) (JavaScript).
//!
//! ## Example
//!
//! ```... | code_fim | hard | {
"lang": "rust",
"repo": "badboy/base-emoji-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = "💯🔢👍👎🎱🅰🚡✈️👽🚑⚓️👼💢😠🐜🍎⬇️⬅️➡️⬆️🎨🏧👶🍼🎈🎍🍌‼️📊💈🏀🛀🔋🐻🐝🍺🐞🔔🚴👙🎂🃏🌼📘🚙💙🐗⛵️💣📖📚💥👢💐🎳👦🍞👰💼💔🐛💡🚌👤🌵🍰📆🐫🍬🚗🐈💿🏁🍒🐔🍫🎄👏🎬☁️🍸☕️💻🎊🚧🍪🌽👫🐄🐊👑🔮💘🌀💃🎯💨🌳💫🐕💵🐬🍩🚪💧👂🌍👓👊👣🔥🔦💾🏈🍀🍤🍟🐸🎲💎👻🎁🌐⛳️🍇🍏🎸🔫🍔🔨👜🐣🌿🔆👠🐴⌛️🍨🎃🔑💋🐨🍃�... | code_fim | hard | {
"lang": "rust",
"repo": "badboy/base-emoji-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if env::var(EMTESTS_ENV_VAR).unwrap_or("0".to_string()) == "1" {
emtests::build();
}
}<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/build/mod.rs
use std::env;
mod emtests;
<|fim_middle|>static EMTESTS_ENV_VAR: &str = "WASM_EMSCRIPTEN_GENERATE_EMTESTS";
fn main() {
| code_fim | medium | {
"lang": "rust",
"repo": "forkkit/wasmer",
"path": "/lib/emscripten-tests/build/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/build/mod.rs
use std::env;
mod emtests;
<|fim_suffix|> if env::var(EMTESTS_ENV_VAR).unwrap_or("0".to_string()) == "1" {
emtests::build();
}
}<|fim_middle|>static EMTESTS_ENV_VAR: &str = "WASM_EMSCRIPTEN_GENERATE_EMTESTS";
fn main() {
| code_fim | medium | {
"lang": "rust",
"repo": "forkkit/wasmer",
"path": "/lib/emscripten-tests/build/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bumblepie/advent-of-code-2018 path: /day-16/part-1/src/main.rs
#[macro_use]
extern crate lazy_static;
extern crate regex;
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::process;
use regex::Regex;
fn main() {
let ar... | code_fim | hard | {
"lang": "rust",
"repo": "bumblepie/advent-of-code-2018",
"path": "/day-16/part-1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, Eq, PartialEq, Hash)]
enum Op {
Addr,
Addi,
Mulr,
Muli,
Banr,
Bani,
Borr,
Bori,
Setr,
Seti,
Gtir,
Gtri,
Gtrr,
Eqir,
Eqri,
Eqrr,
}
fn op_values() -> Vec<Op> {
vec![Op::Addr,
Op::Addi,
Op::Mulr,
... | code_fim | hard | {
"lang": "rust",
"repo": "bumblepie/advent-of-code-2018",
"path": "/day-16/part-1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen(inspectable)]
#[derive(Clone, Debug, PartialEq)]
pub struct Service(pub(crate) IotaService);
#[wasm_bindgen]
impl Service {
/// Serializes a `Service` object as a JSON object.
#[wasm_bindgen(js_name = toJSON)]
pub fn to_json(&self) -> Result<JsValue, JsValue> {
JsValue::from_serd... | code_fim | medium | {
"lang": "rust",
"repo": "maxverbeek/Blockchain-based-E-voting",
"path": "/myDigitalWalletWebApp/src/app/auth-verif/src/service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen]
impl Service {
/// Serializes a `Service` object as a JSON object.
#[wasm_bindgen(js_name = toJSON)]
pub fn to_json(&self) -> Result<JsValue, JsValue> {
JsValue::from_serde(&self.0).map_err(err)
}
/// Deserializes a `Service` object from a JSON object.
#[wasm_bindgen(js_na... | code_fim | medium | {
"lang": "rust",
"repo": "maxverbeek/Blockchain-based-E-voting",
"path": "/myDigitalWalletWebApp/src/app/auth-verif/src/service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxverbeek/Blockchain-based-E-voting path: /myDigitalWalletWebApp/src/app/auth-verif/src/service.rs
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use crate::utils::err;
use identity::did::Service as IotaService;
use wasm_bindgen::prelude::*;
#[wasm_bindgen(inspect... | code_fim | hard | {
"lang": "rust",
"repo": "maxverbeek/Blockchain-based-E-voting",
"path": "/myDigitalWalletWebApp/src/app/auth-verif/src/service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_valid_hair_color(&self) -> bool {
if self.hair_color.as_ref().is_none() {
return false;
}
HAIR_COLOR_RE.is_match(self.hair_color.as_ref().unwrap().as_str())
}
pub fn is_valid_eye_color(&self) -> bool {
if self.eye_color.as_ref().is_none()... | code_fim | hard | {
"lang": "rust",
"repo": "colingm/advent-of-code",
"path": "/2020/day-04/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> passports.iter()
.filter(|passport| passport.is_complete())
.count()
}
fn count_valid_passports(passports: &Vec<Passport>) -> usize {
passports.iter()
.filter(|passport| passport.is_valid())
.count()
}
fn main() {
let passports = get_passports("input.txt");
... | code_fim | hard | {
"lang": "rust",
"repo": "colingm/advent-of-code",
"path": "/2020/day-04/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: colingm/advent-of-code path: /2020/day-04/src/main.rs
use lazy_static::lazy_static;
use regex::Regex;
use std::fs;
lazy_static! {
static ref PASSPORT_FIELD_RE: Regex = Regex::new(r"(\w{3}):([#\w\d]+)").unwrap();
static ref HEIGHT_RE: Regex = Regex::new(r"^(\d+)(cm|in)$").unwrap();
s... | code_fim | hard | {
"lang": "rust",
"repo": "colingm/advent-of-code",
"path": "/2020/day-04/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/elab/passes/validate_like_hint.rs
// Copyright (c) Meta Platforms, Inc. and affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
<|fim_suffix|>impl Pass for ValidateLikeH... | code_fim | medium | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/elab/passes/validate_like_hint.rs",
"mode": "psm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Pass for ValidateLikeHintPass {
fn on_ty_hint_top_down(&mut self, env: &Env, hint: &mut Hint) -> ControlFlow<()> {
match hint {
Hint(pos, box Hint_::Hlike(_)) if !env.like_type_hints_enabled() => {
env.emit_error(ExperimentalFeature::LikeType(pos.clone()));
... | code_fim | medium | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/elab/passes/validate_like_hint.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|>use crate::prelude::*;
#[derive(Clone, Copy, Default)]
pub struct ValidateLikeHintPass {}
impl Pass for ValidateLikeHintPass {
fn on_ty_hint_top_down(&mut self, env: &Env, hint: &mut Hint) -> ControlFlow<()> {
match hint {
Hint(pos, box Hint_::Hlike(_)) if !env.like_type_hints_en... | code_fim | medium | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/elab/passes/validate_like_hint.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Divijkatyal0406/Secret-Contract path: /src/lib.rs
pub mod contract;
mod error;
mod msg;
mod state;
<|fim_suffix|> state::Constants;
pub use crate::hashable::Hashable;<|fim_middle|>
pub use msg::{
GiftCard, ExecuteMsg, InitialBalance, InstantiateMsg,QueryMsg,QueryAnswer
};
pub use | code_fim | medium | {
"lang": "rust",
"repo": "Divijkatyal0406/Secret-Contract",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ance, InstantiateMsg,QueryMsg,QueryAnswer
};
pub use state::Constants;
pub use crate::hashable::Hashable;<|fim_prefix|>// repo: Divijkatyal0406/Secret-Contract path: /src/lib.rs
pub mod contract;
mod error;
mod msg;
mod state;
<|fim_middle|>
pub use msg::{
GiftCard, ExecuteMsg, InitialBal | code_fim | easy | {
"lang": "rust",
"repo": "Divijkatyal0406/Secret-Contract",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kryptan/lithium path: /lithium_core/src/css/image.rs
// https://drafts.csswg.org/css-images/
use cssparser::Parser;
use theme::element_style::{LengthOrPercentage, BackgroundImage, LinearGradient, RadialGradient,
AngleOrCorner, ColorStop, RadialGradientShape, RadialGradientExtent, PositionCo... | code_fim | hard | {
"lang": "rust",
"repo": "kryptan/lithium",
"path": "/lithium_core/src/css/image.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // [left | right] || [top | bottom]
let (horizontal, vertical) = syntax::one_or_more_of_2(parser,
Horizontal::parse,
Vertical::parse,
)?;
Ok(match (horizontal, vertical) {
(Some(Horizontal::Left), Some(Vertic... | code_fim | hard | {
"lang": "rust",
"repo": "kryptan/lithium",
"path": "/lithium_core/src/css/image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> css_enum!(Horizontal, Left = "left", Right = "right");
css_enum!(Vertical, Top = "top", Bottom = "bottom");
syntax::one_of_3(parser,
// <zero>
|parser| {
value::zero(parser)?;
Ok(AngleOrCorner::Angle(0.0))
},
// <angle>
|parser|... | code_fim | hard | {
"lang": "rust",
"repo": "kryptan/lithium",
"path": "/lithium_core/src/css/image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> fmt::Debug for Value<'a>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
{
write!(f, "Value::new({:?}, {:?}, {:?}, {:?})",
self.position, self.tag, self.pointers, self.bytes)
}
}
/// List operations.
impl<'a> Value<'a>
{
/// Return whether the value ... | code_fim | hard | {
"lang": "rust",
"repo": "chloekek/petrol",
"path": "/petrolc/src/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chloekek/petrol path: /petrolc/src/value.rs
use Hash;
use Position;
use std::cell::Cell;
use std::collections::hash_map::DefaultHasher;
use std::fmt;
use std::hash::Hasher;
/// In the compiler, values contain all their usual information, but also their
/// position in the source code. This allo... | code_fim | hard | {
"lang": "rust",
"repo": "chloekek/petrol",
"path": "/petrolc/src/value.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Return whether the value is a cons.
pub fn is_cons(&self) -> bool
{
&self.tag == b"cons" && self.pointers.len() >= 2
}
/// Return whether the value is a nil.
pub fn is_nil(&self) -> bool
{
&self.tag == b"nil "
}
/// If the value is a cons, return t... | code_fim | hard | {
"lang": "rust",
"repo": "chloekek/petrol",
"path": "/petrolc/src/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndrewGi/EECalc path: /src/parser.rs
use crate::scanner::Scanner;
use crate::scanner::Token;
use crate::scanner::TokenType;
use std::iter::Peekable;
use crate::si::UnitWithExponent;
use crate::parser::ParserError::ExpectedNumber;
<|fim_suffix|> &mut self.parent.scanner
}
pub fn next_int(&mut... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewGi/EECalc",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self.parent.scanner
}
pub fn next_int(&mut self) -> Result<i64, ParserError> {
let mut clone = self.clone();
let start = clone.scanner().peek().ok_or(ExpectedNumber)?;
loop {
}
}
}<|fim_prefix|>// repo: AndrewGi/EECalc path: /src/parser.rs
use crate::scanner::Scanner;
use crate::scan... | code_fim | medium | {
"lang": "rust",
"repo": "AndrewGi/EECalc",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivanceras/restq path: /tests/select.rs
use restq::{
ast::{ddl::*, dml::*, *},
*,
};
#[test]
fn complex_select() {
let input = "person?age=lt.42&(student=eq.true|gender=eq.'M')&group_by=sum(age),grade,gender&having=min(age)=gt.42&order_by=age.desc,height.asc&page=20&page_size=100";
... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/restq",
"path": "/tests/select.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn complex_select_with_filter_in() {
let input = "person{person_id,name,updated}?person_id=in.[100,101,102]";
let input_chars = to_chars(input);
let ret = select().parse(&input_chars).expect("must be parsed");
println!("ret: {:#?}", ret);
assert_eq!(input, ret.to_string());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/restq",
"path": "/tests/select.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let css = Entities::parse_str(include_str!("./simple.css"));
println!("{}", css.unwrap().to_css_string());
}<|fim_prefix|>// repo: imxood/imxood.github.io path: /src/program/rust/code/pest-examples/examples/simple.rs
use pest_examples::properties::entry::Entities;
use pest_examples::properties::*... | code_fim | easy | {
"lang": "rust",
"repo": "imxood/imxood.github.io",
"path": "/src/program/rust/code/pest-examples/examples/simple.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imxood/imxood.github.io path: /src/program/rust/code/pest-examples/examples/simple.rs
use pest_examples::properties::entry::Entities;
use pest_examples::properties::*;
<|fim_suffix|> let css = Entities::parse_str(include_str!("./simple.css"));
println!("{}", css.unwrap().to_css_string())... | code_fim | easy | {
"lang": "rust",
"repo": "imxood/imxood.github.io",
"path": "/src/program/rust/code/pest-examples/examples/simple.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thepwagner/dependagot path: /rust/cargo/src/state.rs
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::Mutex;
<|fim_suffix|>impl State {
pub fn new() -> State {
State {
files: Arc::new(Mutex::new(HashMap::new())),
}
}
}<|fim_middle|>/// Stat... | code_fim | hard | {
"lang": "rust",
"repo": "thepwagner/dependagot",
"path": "/rust/cargo/src/state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Files are paths loaded into context for dependency updates.
pub type Files = Arc<Mutex<HashMap<String, String>>>;
impl State {
pub fn new() -> State {
State {
files: Arc::new(Mutex::new(HashMap::new())),
}
}
}<|fim_prefix|>// repo: thepwagner/dependagot path: /rus... | code_fim | medium | {
"lang": "rust",
"repo": "thepwagner/dependagot",
"path": "/rust/cargo/src/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nathanqueija/pipeviewer path: /src/read.rs
use crate::CHUNK_SIZE;
use std::fs::File;
use std::io::{self, BufReader, Read, Result};
pub fn read(infile: &str) -> Result<Vec<u8>> {
let mut reader: Box<dyn Read> = if !infile.is_empty() {
Box::new(BufReader::new(File::open(infile)?))
... | code_fim | medium | {
"lang": "rust",
"repo": "nathanqueija/pipeviewer",
"path": "/src/read.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // If you use the ? syntax it means that if this operations returns an Error
// it will be returned from this function
// io::stdout().write_all(&buffer[..num_read])?
let num_read = reader.read(&mut buffer)?;
Ok(Vec::from(&buffer[..num_read]))
}<|fim_prefix|>// repo: nathanqueija/pipev... | code_fim | hard | {
"lang": "rust",
"repo": "nathanqueija/pipeviewer",
"path": "/src/read.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// An error that can occur while creating a representation of class
/// from class file representation.
#[derive(Error, Debug)]
pub enum CreateClassError {
#[error(transparent)]
Class {
#[from]
source: ClassError
},
#[error(transparent)]
Method {
#[from]
... | code_fim | hard | {
"lang": "rust",
"repo": "miroslavkrysl/mvm",
"path": "/src/vm/parse/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: miroslavkrysl/mvm path: /src/vm/parse/error.rs
//! Parsing errors.
use std::fmt;
use std::fmt::Display;
use std::num::{ParseFloatError, ParseIntError};
use thiserror::Error;
use crate::vm::class::error::{ClassError, CodeError, DescriptorError, MethodError, NameError, SignatureError};
/// An... | code_fim | hard | {
"lang": "rust",
"repo": "miroslavkrysl/mvm",
"path": "/src/vm/parse/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// An error that can occur while parsing a number.
#[derive(Error, Debug)]
pub enum ParseNumberError {
#[error("not int or float: i - {i_error}, f - {f_error}")]
NotIntOrFloat {
i_error: ParseIntError,
f_error: ParseFloatError,
},
#[error("not long or double: l - {i_error... | code_fim | hard | {
"lang": "rust",
"repo": "miroslavkrysl/mvm",
"path": "/src/vm/parse/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jetbrains-academy/rustlings-course path: /Structs, Methods, Enums, and Pattern Matching/Enums/The Option Enum/src/main.rs
fn main() {
let some_number = Some(5);
let some_string = Some("a string");
let absent_number: Option<i32> = None;
<|fim_suffix|> // !!! ERROR
// let sum ... | code_fim | medium | {
"lang": "rust",
"repo": "jetbrains-academy/rustlings-course",
"path": "/Structs, Methods, Enums, and Pattern Matching/Enums/The Option Enum/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // !!! ERROR
// let sum = x + y;
}<|fim_prefix|>// repo: jetbrains-academy/rustlings-course path: /Structs, Methods, Enums, and Pattern Matching/Enums/The Option Enum/src/main.rs
fn main() {
let some_number = Some(5);
let some_string = Some("a string");
<|fim_middle|> let absent_numbe... | code_fim | hard | {
"lang": "rust",
"repo": "jetbrains-academy/rustlings-course",
"path": "/Structs, Methods, Enums, and Pattern Matching/Enums/The Option Enum/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zrayyes/Rust-Training path: /progress_calculator/src/main.rs
use std::env;
use std::io;
use std::process;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 1 {
welcome_message();
} else if args[1] == "1" {
calculate_percentage();
} else ... | code_fim | medium | {
"lang": "rust",
"repo": "zrayyes/Rust-Training",
"path": "/progress_calculator/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> read
}
fn readline_as_float(message: &str) -> f32 {
println!("{}", message);
let read = readline();
if let "0" = read.trim() {
println!("Invalid number");
process::exit(1);
}
read.trim().parse::<f32>().expect("Invalid Number")
}<|fim_prefix|>// repo: zrayyes/Rust... | code_fim | hard | {
"lang": "rust",
"repo": "zrayyes/Rust-Training",
"path": "/progress_calculator/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AtsukiTak/mod-gen path: /tests/gen.rs
/// ```
/// mod others {
/// pub fn top_fn() {}
///
/// mod one {
/// pub fn one_fn() {}
/// }
///
/// mod two {
/// pub fn two_fn() {}
/// }
/// }
/// ```
#[mod_gen::expand(path = "tests/others")]
mod others {}
<|fim_suf... | code_fim | easy | {
"lang": "rust",
"repo": "AtsukiTak/mod-gen",
"path": "/tests/gen.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> others::top_fn();
others::one::one_fn();
others::two::two_fn();
}<|fim_prefix|>// repo: AtsukiTak/mod-gen path: /tests/gen.rs
/// ```
/// mod others {
/// pub fn top_fn() {}
///
/// mod one {
/// pub fn one_fn() {}
/// }
///
/// mod two {
/// pub fn two_fn() {}... | code_fim | easy | {
"lang": "rust",
"repo": "AtsukiTak/mod-gen",
"path": "/tests/gen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-kr/doc.rust-kr.org path: /listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/src/main.rs
// ANCHOR: here
struct QuitMessage; // 유닛 구조체
struct MoveMessage<|fim_suffix|>조체
struct ChangeColorMessage(i32, i32, i32); // 튜플 구조체
... | code_fim | medium | {
"lang": "rust",
"repo": "rust-kr/doc.rust-kr.org",
"path": "/listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ANCHOR_END: here
fn main() {}<|fim_prefix|>// repo: rust-kr/doc.rust-kr.org path: /listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/src/main.rs
// ANCHOR: here
struct QuitMessage; // 유닛 구조체
struct MoveMessage<|fim_middle|> {
x:... | code_fim | medium | {
"lang": "rust",
"repo": "rust-kr/doc.rust-kr.org",
"path": "/listings/ch06-enums-and-pattern-matching/no-listing-04-structs-similar-to-message-enum/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yishn/adventofcode path: /2015/25.rs
#[derive(Debug, Copy, Clone, PartialEq)]
struct Pos(usize, usize);
struct CodeIterator {
value: Option<u64>
}
impl CodeIterator {
fn new() -> CodeIterator {
CodeIterator {value: None}
}
}
impl Iterator for CodeIterator {
type Item =... | code_fim | medium | {
"lang": "rust",
"repo": "yishn/adventofcode",
"path": "/2015/25.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> CodeIterator {value: None}
}
}
impl Iterator for CodeIterator {
type Item = u64;
fn next(&mut self) -> Option<Self::Item> {
self.value = Some(match self.value {
None => 20151125,
Some(x) => (x * 252533) % 33554393
});
self.value.clone(... | code_fim | medium | {
"lang": "rust",
"repo": "yishn/adventofcode",
"path": "/2015/25.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> {
self.value = Some(match self.value {
None => 20151125,
Some(x) => (x * 252533) % 33554393
});
self.value.clone()
}
}
fn pos_to_index(Pos(row, col): Pos) -> usize {
let level = row + col - 1;
(1..le... | code_fim | medium | {
"lang": "rust",
"repo": "yishn/adventofcode",
"path": "/2015/25.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript_sdk/src/sdk/std/test/assert/mod_test.rs
use super::*;
use crate::test;
use crate::test::CommandValidation;
#[test]
fn common_functions() {
test::test_common_command_functions(create(""));
}
#[test]
fn run_no_args() {
test::run_script_and_crash(v... | code_fim | medium | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript_sdk/src/sdk/std/test/assert/mod_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn run_single_false_condition_and_message() {
test::run_script_and_crash(vec![create("")], "out = assert false test error");
}<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript_sdk/src/sdk/std/test/assert/mod_test.rs
use super::*;
use crate::test;
use crate::test::CommandValidati... | code_fim | medium | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript_sdk/src/sdk/std/test/assert/mod_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gfx-rs/wgpu path: /tests/tests/root.rs
use wasm_bindgen_test::wasm_bindgen_test_configure;
mod regression {
mod issue_3457;
mod issue_4024;
}
mod bind_group_layout_dedup;
mod buffer;
mod buffer_copy;
m<|fim_suffix|>er_view_format;
mod texture_bounds;
mod transfer;
mod vertex_indices;
m... | code_fim | hard | {
"lang": "rust",
"repo": "gfx-rs/wgpu",
"path": "/tests/tests/root.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>er_view_format;
mod texture_bounds;
mod transfer;
mod vertex_indices;
mod write_texture;
mod zero_init_texture_after_discard;
wasm_bindgen_test_configure!(run_in_browser);<|fim_prefix|>// repo: gfx-rs/wgpu path: /tests/tests/root.rs
use wasm_bindgen_test::wasm_bindgen_test_configure;
mod regression {
... | code_fim | medium | {
"lang": "rust",
"repo": "gfx-rs/wgpu",
"path": "/tests/tests/root.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leavehouse/git-remote-ipgrv-rs path: /src/remote/push.rs
use git2;
use ipld_git;
use multihash;
use std::collections::VecDeque;
use ipfs_api;
use super::Error;
use super::tracker;
pub struct PushHelper<'a> {
queue: VecDeque<git2::Oid>,
repo: &'a git2::Repository,
tracker: &'a track... | code_fim | hard | {
"lang": "rust",
"repo": "leavehouse/git-remote-ipgrv-rs",
"path": "/src/remote/push.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Selicre/piped-asm path: /src/bin/piped.rs
extern crate piped_asm;
use std::process;
<|fim_suffix|> if let Err(e) = piped_asm::run() {
println!("\x1B[1;31mError\x1B[0m: {}", e);
process::exit(1);
}
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "Selicre/piped-asm",
"path": "/src/bin/piped.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
if let Err(e) = piped_asm::run() {
println!("\x1B[1;31mError\x1B[0m: {}", e);
process::exit(1);
}
}<|fim_prefix|>// repo: Selicre/piped-asm path: /src/bin/piped.rs
extern crate piped_asm;
<|fim_middle|>use std::process;
| code_fim | easy | {
"lang": "rust",
"repo": "Selicre/piped-asm",
"path": "/src/bin/piped.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kbz/beatmap-repo path: /datafiles/m_024_easy.rs
{"song_name":"これからのSomeday","difficulty":1,"rank_info":[{"rank":5,"rank_max":14230},{"rank":4,"rank_max":21346},{"rank":3,"rank_max":28461},{"rank":2,"rank_max":35577},{"rank":1,"rank_max":0}],"song_info":[{"notes_speed":1.6,"notes":[{"timing_sec"... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_024_easy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>"position":8},{"timing_sec":76.65,"effect":17,"effect_value":2.0,"position":7},{"timing_sec":76.65,"effect":17,"effect_value":2.0,"position":3},{"timing_sec":77.65,"effect":17,"effect_value":2.0,"position":6},{"timing_sec":77.65,"effect":17,"effect_value":2.0,"position":4},{"timing_sec":78.15,"effect":1,"... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_024_easy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tejasbubane/adventofcode-2020 path: /tests/day2_test.rs
#[cfg(test)]
mod day2_test {
use adventofcode_2020::day2::{run_1, run_2};
#[test]
fn part1_works_for_sample_input() {
assert_eq!(run_1("tests/inputs/day2_sample.txt"), 2);
}
#[test]
fn part1_works_for_puzzl... | code_fim | medium | {
"lang": "rust",
"repo": "tejasbubane/adventofcode-2020",
"path": "/tests/day2_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(run_1("tests/inputs/day2_puzzle.txt"), 614);
}
#[test]
fn part2_works_for_sample_input() {
assert_eq!(run_2("tests/inputs/day2_sample.txt"), 1);
}
#[test]
fn part2_works_for_puzzle_input() {
assert_eq!(run_2("tests/inputs/day2_puzzle.txt"), 354)... | code_fim | medium | {
"lang": "rust",
"repo": "tejasbubane/adventofcode-2020",
"path": "/tests/day2_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bozbez/interception-sys path: /src/bindings.rs
/* automatically generated by rust-bindgen 0.54.1 */
pub const INTERCEPTION_MAX_KEYBOARD: u32 = 10;
pub const INTERCEPTION_MAX_MOUSE: u32 = 10;
pub const INTERCEPTION_MAX_DEVICE: u32 = 20;
pub type InterceptionContext = *mut ::std::os::raw::c_void;... | code_fim | hard | {
"lang": "rust",
"repo": "bozbez/interception-sys",
"path": "/src/bindings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
::std::mem::size_of::<InterceptionKeyStroke>(),
8usize,
concat!("Size of: ", stringify!(InterceptionKeyStroke))
);
assert_eq!(
::std::mem::align_of::<InterceptionKeyStroke>(),
4usize,
concat!("Alignment of ", stringify!(InterceptionKe... | code_fim | hard | {
"lang": "rust",
"repo": "bozbez/interception-sys",
"path": "/src/bindings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LucioFranco/clique-old path: /clique-agent/src/main.rs
#![feature(pin, await_macro, async_await, futures_api)]
use {
clique::{Net, Node as RawNode},
futures::future::{FutureExt, TryFutureExt},
log::{error, info},
std::{net::SocketAddr, sync::Arc},
};
type Node = RawNode<Net>;
... | code_fim | hard | {
"lang": "rust",
"repo": "LucioFranco/clique-old",
"path": "/clique-agent/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let local_addr: SocketAddr = std::env::args()
.nth(1)
.unwrap_or("127.0.0.1:8080".into())
.parse()
.unwrap();
let peer_addr = std::env::args().nth(2);
std::env::set_var("RUST_LOG", "clique=debug");
pretty_env_logger::init();
// Bootstrap lazy future t... | code_fim | medium | {
"lang": "rust",
"repo": "LucioFranco/clique-old",
"path": "/clique-agent/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn idat_to_channels(
compressed: &[u8],
bpp: i32,
width: u32,
height: u32,
) -> Result<Vec<u8>, String> {
let bytes = inflate::inflate_bytes_zlib(compressed)?;
let mut out: Vec<u8> = vec![];
let mut idx = 0;
for y in 0..height as i32 {
let filter = bytes[idx];
idx += 1;
matc... | code_fim | hard | {
"lang": "rust",
"repo": "bwiklund/rust-png-decoder",
"path": "/src/image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bwiklund/rust-png-decoder path: /src/image.rs
use crate::chunks::ChunkHashMap;
use crate::chunks::Png;
use crate::chunks::{parse_ihdr_chunk, ChunkRaw};
// TODO only store the last line for filters
// TODO take a buffer writer instead, or something
pub fn png_to_rgba(png: &Png) -> Result<Vec<u8>... | code_fim | hard | {
"lang": "rust",
"repo": "bwiklund/rust-png-decoder",
"path": "/src/image.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> compressed: &[u8],
bpp: i32,
width: u32,
height: u32,
) -> Result<Vec<u8>, String> {
let bytes = inflate::inflate_bytes_zlib(compressed)?;
let mut out: Vec<u8> = vec![];
let mut idx = 0;
for y in 0..height as i32 {
let filter = bytes[idx];
idx += 1;
match filter {
0 =>... | code_fim | hard | {
"lang": "rust",
"repo": "bwiklund/rust-png-decoder",
"path": "/src/image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r2 = DnaString::from_dna_string(&inp.r2.read);
let iter2: KmerIter<Pmer, _> = r2.iter_kmers();
for pmer in iter2 {
let min_pmer = pmer.min_rc();
let e = counter.entry(min_pmer).or_insert_with(|| 0);
... | code_fim | hard | {
"lang": "rust",
"repo": "RagnarDanneskjold/longranger",
"path": "/lib/tada/src/cmd_msp.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn count_pmers_fastq<T: Iterator<Item = InputRead>>(mut input: T) -> HashMap<Pmer, usize> {
let mut counter = HashMap::new();
loop {
match input.next() {
Some(inp) => {
// R1 is numbered with an even number, R2 is the next value
let r1 = DnaStri... | code_fim | hard | {
"lang": "rust",
"repo": "RagnarDanneskjold/longranger",
"path": "/lib/tada/src/cmd_msp.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RagnarDanneskjold/longranger path: /lib/tada/src/cmd_msp.rs
//
// Copyright (c) 2017 10X Genomics, Inc. All rights reserved.
//
//! Command to generate barcoded MSP substrings from FASTQ data
//!
//! For each input read, compute the MSP substrings. Each substring is at most 2K-P long, and
//! i... | code_fim | hard | {
"lang": "rust",
"repo": "RagnarDanneskjold/longranger",
"path": "/lib/tada/src/cmd_msp.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub upramp: i32,
pub time: i32,
pub fade: i32,
}<|fim_prefix|>// repo: flattiverse/connector-rust path: /src/units/activation.rs
use serde_derive::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Activation <|fim_middle|>{
pub probability: f64,
pub f... | code_fim | easy | {
"lang": "rust",
"repo": "flattiverse/connector-rust",
"path": "/src/units/activation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flattiverse/connector-rust path: /src/units/activation.rs
use serde_derive::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Activation <|fim_suffix|> pub upramp: i32,
pub time: i32,
pub fade: i32,
}<|fim_middle|>{
pub probability: f64,
pub f... | code_fim | easy | {
"lang": "rust",
"repo": "flattiverse/connector-rust",
"path": "/src/units/activation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChangeCaps/tree path: /src/sky.rs
rMode, SamplerDescriptor, TextureDescriptor,
TextureDimension, TextureFormat, TextureUsage, SAMPLER_ASSET_INDEX,
TEXTURE_ASSET_INDEX,
},
},
window::{WindowCreated, WindowId, WindowResized},
};
use std::sync::{Arc, Mutex};
... | code_fim | hard | {
"lang": "rust",
"repo": "ChangeCaps/tree",
"path": "/src/sky.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChangeCaps/tree path: /src/sky.rs
der: ManualEventReader<WindowCreated>,
window_resized_event_reader: ManualEventReader<WindowResized>,
scale: u32,
}
impl ScaledWindowTextureNode {
pub const OUT_TEXTURE: &'static str = "texture";
pub fn new(window_id: WindowId, descriptor: Text... | code_fim | hard | {
"lang": "rust",
"repo": "ChangeCaps/tree",
"path": "/src/sky.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> volume_pass_node.add_camera(base::camera::CAMERA_3D);
let mut render_graph = app_builder
.world_mut()
.get_resource_mut::<RenderGraph>()
.unwrap();
render_graph.add_node(SKY_PASS_NODE, sky_pass_node);
render_graph.add_node(VOLUME_PASS_N... | code_fim | hard | {
"lang": "rust",
"repo": "ChangeCaps/tree",
"path": "/src/sky.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parampavar/piranha path: /polyglot/piranha/src/models/matches.rs
/*
Copyright (c) 2022 Uber Technologies, Inc.
<p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at
<p>http:/... | code_fim | hard | {
"lang": "rust",
"repo": "parampavar/piranha",
"path": "/polyglot/piranha/src/models/matches.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Match {
pub(crate) fn new(
range: Range, matches: HashMap<String, String>,
) -> Self {
Self {
range,
matches,
}
}
/// Get the edit's replacement range.
pub(crate) fn range(&self) -> Range {
self.range
}
pub(crate) fn matches(&self) -> &HashMap<String, Strin... | code_fim | hard | {
"lang": "rust",
"repo": "parampavar/piranha",
"path": "/polyglot/piranha/src/models/matches.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttys3/http-server path: /tests/basic_auth.rs
#[cfg(test)]
mod tests {
use http::{HeaderValue, Request, Response, StatusCode};
use http_auth_basic::Credentials;
use hyper::{Body, Client};
async fn http_get(url: &str) -> Response<Body> {
let client = Client::default();
<|... | code_fim | hard | {
"lang": "rust",
"repo": "ttys3/http-server",
"path": "/tests/basic_auth.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[tokio::test]
async fn basic_auth_resolves_request_unauthorized_when_header_is_missing() {
let response = http_get("http://0.0.0.0:7878").await;
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
}
}<|fim_prefix|>// repo: ttys3/http-server path: /tests/basic_auth.rs
#[... | code_fim | hard | {
"lang": "rust",
"repo": "ttys3/http-server",
"path": "/tests/basic_auth.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(response.status(), StatusCode::OK);
}
#[tokio::test]
async fn basic_auth_validates_wrong_credentials() {
let response = http_get_with_basic_auth("http://0.0.0.0:7878", "somebody", "else").await;
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
}... | code_fim | medium | {
"lang": "rust",
"repo": "ttys3/http-server",
"path": "/tests/basic_auth.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for field in fields.iter() {
let field_name = field.ident.clone().unwrap();
field_names.push(field_name.clone());
let field_type = &field.ty;
let field_name_str = field_name.to_string();
let options = get_options(ATTR_NAME, &field.attrs);
let mut pos... | code_fim | hard | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/macros/src/args.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.