text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: iptq/rosu-v2 path: /src/model/cursor.rs
use crate::request::Query;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
#[serde(transparent)]
pub struct Cursor {
cursor: Value,
}
<|fim_suffix|> pub(crate) fn push_to_... | code_fim | hard | {
"lang": "rust",
"repo": "iptq/rosu-v2",
"path": "/src/model/cursor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match value {
Value::Bool(v) => query.push(key.as_str(), v),
Value::Number(v) => query.push(key.as_str(), v),
Value::String(v) => query.push(key.as_str(), v),
Value::Null | Value::Array(_) | Value::Object(_) =>... | code_fim | hard | {
"lang": "rust",
"repo": "iptq/rosu-v2",
"path": "/src/model/cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set the Event, waking up the thread that is waiting for it if any.
/// This will be used assuming a Release memory ordering.
fn set(&self);
}<|fim_prefix|>// repo: kprotty/lock-bench path: /wlock/src/event/mod.rs
#[cfg(all(feature = "os", windows))]
mod windows;
#[cfg(all(feature = "os",... | code_fim | hard | {
"lang": "rust",
"repo": "kprotty/lock-bench",
"path": "/wlock/src/event/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kprotty/lock-bench path: /wlock/src/event/mod.rs
#[cfg(all(feature = "os", windows))]
mod windows;
#[cfg(all(feature = "os", windows))]
pub use windows::OsEvent;
#[cfg(all(feature = "os", target_os = "linux"))]
mod linux;
#[cfg(all(feature = "os", target_os = "linux"))]
pub use linux::OsEvent;... | code_fim | medium | {
"lang": "rust",
"repo": "kprotty/lock-bench",
"path": "/wlock/src/event/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wonism/Rocket path: /codegen/tests/run-pass/dynamic-paths.rs
#![feature(plugin)]
#![plugin(rocket_codegen)]
<|fim_suffix|> let _ = routes![get];
}<|fim_middle|>extern crate rocket;
#[get("/test/<one>/<two>/<three>")]
fn get(one: &str, two: usize, three: isize) -> &'static str { "hi" }
fn m... | code_fim | medium | {
"lang": "rust",
"repo": "wonism/Rocket",
"path": "/codegen/tests/run-pass/dynamic-paths.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = routes![get];
}<|fim_prefix|>// repo: wonism/Rocket path: /codegen/tests/run-pass/dynamic-paths.rs
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
<|fim_middle|>#[get("/test/<one>/<two>/<three>")]
fn get(one: &str, two: usize, three: isize) -> &'static str { "hi" }
fn m... | code_fim | medium | {
"lang": "rust",
"repo": "wonism/Rocket",
"path": "/codegen/tests/run-pass/dynamic-paths.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bp713/directions-api-clients path: /rust/src/models/route_response_path.rs
/*
* GraphHopper Directions API
*
* You use the GraphHopper Directions API to add route planning, navigation and route optimization to your software. E.g. the Routing API has turn instructions and elevation data and t... | code_fim | hard | {
"lang": "rust",
"repo": "bp713/directions-api-clients",
"path": "/rust/src/models/route_response_path.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn reset_descend(&mut self) {
self.descend = None;
}
pub fn set_points(&mut self, points: ::models::ResponseCoordinates) {
self.points = Some(points);
}
pub fn with_points(mut self, points: ::models::ResponseCoordinates) -> RouteResponsePath {
self.points = Some(points);
se... | code_fim | hard | {
"lang": "rust",
"repo": "bp713/directions-api-clients",
"path": "/rust/src/models/route_response_path.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let entry = cur.move_to_next().unwrap();
assert!(entry.is_none());
}
#[test]
fn test_move_to() {
let (env, db) = get_filled_db();
let txn = env.txn(false).unwrap();
let mut cur = db.cursor(&txn).unwrap();
let entry = cur.move_to(b"key2").unwra... | code_fim | hard | {
"lang": "rust",
"repo": "saeed-golshan/isar-core",
"path": "/src/lmdb/cursor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saeed-golshan/isar-core path: /src/lmdb/cursor.rs
use crate::error::Result;
use crate::lmdb::db::Db;
use crate::lmdb::error::{lmdb_result, LmdbError};
use crate::lmdb::txn::Txn;
use crate::lmdb::{from_mdb_val, to_mdb_val, KeyVal, EMPTY_KEY, EMPTY_VAL};
use core::ptr;
use lmdb_sys as ffi;
use lmd... | code_fim | hard | {
"lang": "rust",
"repo": "saeed-golshan/isar-core",
"path": "/src/lmdb/cursor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hamaluik/cef-simple path: /src/imp/mod.rs
pub mod app;
pub mod bindings;
pub mod browser;
pub mod browser_process_handler;
pub mod browser_view_delegat<|fim_suffix|>n_file_dialog_callback;
pub mod v8_file_dialog_handler;
pub mod v8_pdf_print_handler;
pub mod window_delegate;<|fim_middle|>e;
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "hamaluik/cef-simple",
"path": "/src/imp/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>n_file_dialog_callback;
pub mod v8_file_dialog_handler;
pub mod v8_pdf_print_handler;
pub mod window_delegate;<|fim_prefix|>// repo: hamaluik/cef-simple path: /src/imp/mod.rs
pub mod app;
pub mod bindings;
pub mod browser;
pub mod browser_process_handler;
pub mod browser_view_delegate;
pub mod client;
pu... | code_fim | medium | {
"lang": "rust",
"repo": "hamaluik/cef-simple",
"path": "/src/imp/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dseevr/assassin path: /src/assassin/order.rs
use std::rc::Rc;
use assassin::quote::Quote;
extern crate greenback;
use greenback::Greenback as Money;
#[derive(Clone)]
pub struct Order {
symbol: Rc<str>,
name: Rc<str>,
buy: bool,
open: bool,
quantity: i32,
limit: Money,
... | code_fim | hard | {
"lang": "rust",
"repo": "dseevr/assassin",
"path": "/src/assassin/order.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cost_basis = o.cost_basis();
let unrealized = o.unrealized_value(&q1);
let profit = o.unrealized_value(&q2) - o.cost_basis();
debug!(
"cost_basis: {} unrealized: {} profit: {}",
cost_basis,
unrealized,
profit
);
... | code_fim | hard | {
"lang": "rust",
"repo": "dseevr/assassin",
"path": "/src/assassin/order.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamiebidelia/star_slammers path: /src/direction.rs
/*
_____ _ _____ _
/ ____| | / ____| | _
| (___ | |_ __ _ _ __ | (___ | | __ _ _ __ ___ _ __ ___ ___ _... | code_fim | hard | {
"lang": "rust",
"repo": "jamiebidelia/star_slammers",
"path": "/src/direction.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> _ \
_| |_| | | | | | | | | | | || __/ / ____ \ (_| |\ V / __/ | | | |_| |_| | | | __/
|_____|_| |_|_| |_|_| |_|_|\__\___| /_/ \_\__,_| \_/ \___|_| |_|\__|\__,_|_| \___|
*/
//! This module contains the Direction enum.
pub enum Direction
{
North,
South,
East,
West
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "jamiebidelia/star_slammers",
"path": "/src/direction.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DirtGrubDylan/adventofcode2019 path: /src/day_12/mod.rs
mod moons;
use crate::file_reader::to_string_vector;
use crate::location::point_3d::Point3d;
use moons::System;
const INVALID_CHARS: [char; 7] = ['<', '=', ' ', '>', 'x', 'y', 'z'];
pub fn run_day_12() {
let file_input = to_string_v... | code_fim | hard | {
"lang": "rust",
"repo": "DirtGrubDylan/adventofcode2019",
"path": "/src/day_12/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Day 12 Part 2 Solution: {}", steps_to_origin);
}
fn location_str_to_point(location_str: &str) -> Point3d<i32> {
let temp: Vec<i32> = location_str
.replace(&INVALID_CHARS[..], "")
.split(',')
.collect::<Vec<&str>>()
.iter()
.map(|s| s.parse().unwra... | code_fim | hard | {
"lang": "rust",
"repo": "DirtGrubDylan/adventofcode2019",
"path": "/src/day_12/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut key = [0; 32];
openssl::aes::unwrap_key(&kek, Some(iv), &mut key, encrypted_key).unwrap();
let cipher = Cipher::aes_256_cbc();
let result = openssl::symm::decrypt(cipher, &key, Some(payload_iv), payload).unwrap();
Ok(result)
}<|fim_prefix|>// repo: TylerHorth/onion pa... | code_fim | hard | {
"lang": "rust",
"repo": "TylerHorth/onion",
"path": "/src/aes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TylerHorth/onion path: /src/aes.rs
use anyhow::Result;
use openssl::aes::AesKey;
use openssl::symm::Cipher;
use std::convert::TryInto;
<|fim_suffix|> let mut key = [0; 32];
openssl::aes::unwrap_key(&kek, Some(iv), &mut key, encrypted_key).unwrap();
let cipher = Cipher::aes_2... | code_fim | hard | {
"lang": "rust",
"repo": "TylerHorth/onion",
"path": "/src/aes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrstsmth/ciphertools-rs path: /cipher-lib/src/alphabet/latin.rs
use std::convert::TryFrom;
use std::fmt;
use serde::ser::{Serialize, Serializer};
use serde::de::{self, Deserialize, Deserializer, Visitor, Unexpected};
use rand::distributions::{Distribution, Standard};
use rand::Rng;
use variant_... | code_fim | hard | {
"lang": "rust",
"repo": "chrstsmth/ciphertools-rs",
"path": "/cipher-lib/src/alphabet/latin.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<Latin> for u32 {
fn from(a: Latin) -> u32 {
match a {
Latin::A => 0,
Latin::B => 1,
Latin::C => 2,
Latin::D => 3,
Latin::E => 4,
Latin::F => 5,
Latin::G => 6,
Latin::H => 7,
Latin::I => 8,
Latin::J => 9,
Latin::K => 10,
Latin::L => 11,
Latin::M => 12,
... | code_fim | hard | {
"lang": "rust",
"repo": "chrstsmth/ciphertools-rs",
"path": "/cipher-lib/src/alphabet/latin.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> E: de::Error,
{
let c = s.chars().next().unwrap();
match Latin::try_from(c) {
Ok(a) => Ok(a),
Err(_) => Err(de::Error::invalid_value(Unexpected::Char(c), &self)),
}
}
}
deserializer.deserialize_char(LatinVisitor)
}
}
impl From<Latin> for u32 {
fn from(a: Latin) -> u... | code_fim | hard | {
"lang": "rust",
"repo": "chrstsmth/ciphertools-rs",
"path": "/cipher-lib/src/alphabet/latin.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn bzhi_4() {
run_test(&Instruction { mnemonic: Mnemonic::BZHI, operand1: Some(Direct(EBP)), operand2: Some(IndirectScaledDisplaced(RCX, Eight, 1656634637, Some(OperandSize::Dword), None)), operand3: Some(Direct(EDI)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mas... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/bzhi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/bzhi.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn bzhi_1() {
run_test(&Instr... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/bzhi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
struct InventoryItem {
item_number: u64,
pub item_weight: ItemWeight,
}
impl InventoryItem {
fn new(item_number: u64, item_weight: ItemWeight) -> Self {
Self {
item_number: item_number,
item_weight: item_weight,
}
}
}
fn main() {
... | code_fim | medium | {
"lang": "rust",
"repo": "blittable/rust-top-down",
"path": "/exercise_solutions/lesson_12/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blittable/rust-top-down path: /exercise_solutions/lesson_12/src/main.rs
#[macro_use]
extern crate lazy_static;
use std::collections::HashMap;
#[derive(Eq, Debug, PartialEq, Hash, Copy, Clone)]
pub enum UomWeight {
Pound,
Kilo,
Stone,
}
lazy_static! {
static ref CONVERSION_MAP:... | code_fim | medium | {
"lang": "rust",
"repo": "blittable/rust-top-down",
"path": "/exercise_solutions/lesson_12/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
#[derive(Debug, Copy, Clone)]
pub struct ItemWeight {
weight: f64,
uom: UomWeight,
}
#[derive(Debug)]
struct InventoryItem {
item_number: u64,
pub item_weight: ItemWeight,
}
impl InventoryItem {
fn new(item_number: u64, item_weight: ItemWeight) -> Self {
Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "blittable/rust-top-down",
"path": "/exercise_solutions/lesson_12/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>cycle() {}
if vec[0] == 19690720 {
let num = 100 * i + j;
println!("{}", num);
break 'outer;
}
}
}
}<|fim_prefix|>// repo: janhrastnik/adventofcode path: /aoc2019/day2-2/src/main.rs
use intcode::Intcode;
use std::fs;
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "janhrastnik/adventofcode",
"path": "/aoc2019/day2-2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: janhrastnik/adventofcode path: /aoc2019/day2-2/src/main.rs
use intcode::Intcode;
use std::fs;
fn main() {
let data = fs::read_to_string("input").expect("Error");
'outer: for i in 0..100 {
'inner: for j in 0..100 {
let mut vec: Vec<usize> = data
.trim_... | code_fim | hard | {
"lang": "rust",
"repo": "janhrastnik/adventofcode",
"path": "/aoc2019/day2-2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn t0() {
assert_eq!(Solution::climb_stairs(2), 2);
assert_eq!(Solution::climb_stairs(3), 3);
assert_eq!(Solution::climb_stairs(4), 5);
assert_eq!(Solution::climb_stairs(5), 8);
}
}<|fim_prefix|>// repo: zhongsp/code-kata path: /LeetCode/rs/51-100/climb... | code_fim | hard | {
"lang": "rust",
"repo": "zhongsp/code-kata",
"path": "/LeetCode/rs/51-100/climbing_stairs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhongsp/code-kata path: /LeetCode/rs/51-100/climbing_stairs.rs
//! https://leetcode.cn/problems/climbing-stairs/
struct Solution;
<|fim_suffix|>#[cfg(test)]
mod test {
use super::*;
#[test]
fn t0() {
assert_eq!(Solution::climb_stairs(2), 2);
assert_eq!(Solution::cl... | code_fim | hard | {
"lang": "rust",
"repo": "zhongsp/code-kata",
"path": "/LeetCode/rs/51-100/climbing_stairs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> f[n]
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn t0() {
assert_eq!(Solution::climb_stairs(2), 2);
assert_eq!(Solution::climb_stairs(3), 3);
assert_eq!(Solution::climb_stairs(4), 5);
assert_eq!(Solution::climb_stairs(5), 8);
}
}<|fim_pr... | code_fim | hard | {
"lang": "rust",
"repo": "zhongsp/code-kata",
"path": "/LeetCode/rs/51-100/climbing_stairs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sarlaccpit/pravega-client-rust path: /src/sync/mod.rs
//
// Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the... | code_fim | hard | {
"lang": "rust",
"repo": "sarlaccpit/pravega-client-rust",
"path": "/src/sync/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e [details].
//!
//! [synchronizer]: crate::sync::synchronizer::Synchronizer
//! [details]: https://pravega.io/docs/nightly/state-synchronizer-design/
pub mod synchronizer;
pub mod table;
#[doc(inline)]
pub use synchronizer::Synchronizer;
#[doc(inline)]
pub use table::Table;<|fim_prefix|>// repo: sarlacc... | code_fim | hard | {
"lang": "rust",
"repo": "sarlaccpit/pravega-client-rust",
"path": "/src/sync/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_works() {
let test_enum = TestEnum::Two;
assert_eq!(test_enum, CTestEnum::from(test_enum).into())
}
}<|fim_prefix|>// repo: xorpse/unionise path: /unionise/src/lib.rs
pub use unionise_codegen::*;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Unionise)]
pub enum Te... | code_fim | medium | {
"lang": "rust",
"repo": "xorpse/unionise",
"path": "/unionise/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xorpse/unionise path: /unionise/src/lib.rs
pub use unionise_codegen::*;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Unionise)]
pub enum TestEnum {
One,
Two,
Three,
}
#[derive(Unionise)]
pub enum TestEnumFields {
One(i32, #[unionise(CTestEnum)] TestEnum),
Two,
Three { #[... | code_fim | medium | {
"lang": "rust",
"repo": "xorpse/unionise",
"path": "/unionise/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guoyucode/rbatis path: /rbatis-core/src/io/buf.rs
use byteorder::ByteOrder;
use memchr::memchr;
use std::{io, slice, str};
pub trait Buf<'a> {
fn advance(&mut self, cnt: usize);
fn get_uint<T: ByteOrder>(&mut self, n: usize) -> io::Result<u64>;
fn get_i8(&mut self) -> io::Result<i... | code_fim | hard | {
"lang": "rust",
"repo": "guoyucode/rbatis",
"path": "/rbatis-core/src/io/buf.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(val)
}
fn get_u32<T: ByteOrder>(&mut self) -> io::Result<u32> {
let val = T::read_u32(*self);
self.advance(4);
Ok(val)
}
fn get_u64<T: ByteOrder>(&mut self) -> io::Result<u64> {
let val = T::read_u64(*self);
self.advance(8);
Ok... | code_fim | hard | {
"lang": "rust",
"repo": "guoyucode/rbatis",
"path": "/rbatis-core/src/io/buf.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
pub trait Monad<U>: Applicative<U> {
fn bind<F>(&self, F) -> Self::T where F : FnMut(&Self::C) -> Self::T;
fn return_(x: U) -> Self::T where Self: HKT<U, C=U> {
Self::pure_(x)
}
fn join<T>(&self) -> T where Self: HKT<U, T=T, C=T>, T: Clone {
... | code_fim | hard | {
"lang": "rust",
"repo": "mopp/CodeGarage",
"path": "/rust/mapping.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mopp/CodeGarage path: /rust/mapping.rs
// https://gist.github.com/14427/af90a21b917d2892eace
// https://gist.github.com/badboy/6954cc6ce1c71b921094
// 1. Functor
// (A => B) => (C<A> => C<B>)
trait Functor<A, B, T> {
fn map<F>(self, f: F) -> T where F: Fn(A) -> B;
}
// 2. Applicative
// C<... | code_fim | hard | {
"lang": "rust",
"repo": "mopp/CodeGarage",
"path": "/rust/mapping.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jasperav/cdrs path: /src/cluster/ssl_connection_pool.rs
use openssl::ssl::SslConnector;
use r2d2::{Builder, ManageConnection, Pool};
use std::cell::RefCell;
use std::error::Error;
use std::io::Write;
use std::net::{SocketAddr, ToSocketAddrs};
use crate::authenticators::Authenticator;
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs",
"path": "/src/cluster/ssl_connection_pool.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let transport = RefCell::new(TransportTls::new(&self.addr, &self.ssl_connector)?);
startup(&transport, &self.auth)?;
Ok(transport)
}
fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error> {
let options_frame = Frame::new_req_options().into_cbyt... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs",
"path": "/src/cluster/ssl_connection_pool.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Injects the given Opentelemetry Context into a reqwest::Request headers to allow propagation downstream.
pub fn inject_opentracing_context_into_request(span: &Span, request: Request) -> Request {
let context = span.context();
let mut request = request;
global::get_text_map_propagator(|inj... | code_fim | medium | {
"lang": "rust",
"repo": "sformisano/reqwest-middleware",
"path": "/reqwest-tracing/src/otel.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sformisano/reqwest-middleware path: /reqwest-tracing/src/otel.rs
use reqwest::header::{HeaderName, HeaderValue};
use reqwest::Request;
use std::str::FromStr;
use tracing::Span;
#[cfg(feature = "opentelemetry_0_13")]
use opentelemetry_0_13_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_... | code_fim | hard | {
"lang": "rust",
"repo": "sformisano/reqwest-middleware",
"path": "/reqwest-tracing/src/otel.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use opentelemetry::global;
use opentelemetry::propagation::Injector;
use tracing_opentelemetry::OpenTelemetrySpanExt;
/// Injects the given Opentelemetry Context into a reqwest::Request headers to allow propagation downstream.
pub fn inject_opentracing_context_into_request(span: &Span, request: Request) ... | code_fim | medium | {
"lang": "rust",
"repo": "sformisano/reqwest-middleware",
"path": "/reqwest-tracing/src/otel.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kognise/avigraph path: /src/arinc424/fields/p105_call_sign.rs
use crate::trimmed_str_parseable;
trimmed_str_parseable! {
/**
The "Call Sign" field specifies the name of the facility bei<|fim_suffix|>l be shown with
the first record only of any Flight Information Region or Flight Ser... | code_fim | hard | {
"lang": "rust",
"repo": "kognise/avigraph",
"path": "/src/arinc424/fields/p105_call_sign.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> being called will be omitted when is it the same as the
communication type. On Enroute Communication records, the Call Name will be shown with
the first record only of any Flight Information Region or Flight Service Station.
*/
pub CallSign: 25;
}<|fim_prefix|>// repo: kognise/avigraph p... | code_fim | medium | {
"lang": "rust",
"repo": "kognise/avigraph",
"path": "/src/arinc424/fields/p105_call_sign.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for token in self.to_reregister.iter() {
if let Some(connection) = self.connections.get(*token) {
poll.reregister(connection.incoming_stream(),
token.as_raw_token(),
Ready::readable() | Ready::writable(),
... | code_fim | hard | {
"lang": "rust",
"repo": "topelinux/loadbalancer-rs",
"path": "/src/driver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: topelinux/loadbalancer-rs path: /src/driver.rs
use std::collections::HashSet;
use mio::{Poll, PollOpt, Events, Ready};
use mio::tcp::TcpStream;
use slab::Slab;
// use config::RootConfig;
use connection::{TokenType, ListenerToken, IncomingToken, OutgoingToken, Connection};
use driver_state::Dr... | code_fim | hard | {
"lang": "rust",
"repo": "topelinux/loadbalancer-rs",
"path": "/src/driver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deffen3/rally_game path: /src/resources/game_mode_setup.rs
use serde::Deserialize;
use crate::components::{ArenaNames, VehicleNames, VehicleStats, WeaponNames};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Hash)]
pub enum GameModes {
ClassicGunGame, //First to get a kill with e... | code_fim | hard | {
"lang": "rust",
"repo": "deffen3/rally_game",
"path": "/src/resources/game_mode_setup.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct GameWeaponSetup {
pub mode: GameWeaponSelectionMode,
pub starter_weapon: WeaponNames,
pub allowable_starter_weapons: Vec<WeaponNames>,
pub random_weapon_spawns: bool,
pub random_weapon_spawn_count: u32,
pub random_weapon_spawn_first_timer: f32,
pub random_weapon_spaw... | code_fim | hard | {
"lang": "rust",
"repo": "deffen3/rally_game",
"path": "/src/resources/game_mode_setup.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redsnapper2006/leetcode-cn path: /C/2559-count-vowel-strings-in-ranges/main.rs
struct Solution {}
impl Solution {
pub fn vowel_strings(words: Vec<String>, queries: Vec<Vec<i32>>) -> Vec<i32> {
fn is_vowel(b: u8) -> bool {
b == 'a' as u8 || b == 'e' as u8 || b == 'i' as u8 || b == 'o... | code_fim | medium | {
"lang": "rust",
"repo": "redsnapper2006/leetcode-cn",
"path": "/C/2559-count-vowel-strings-in-ranges/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!(
"{:?}",
Solution::vowel_strings(
vec![
"aba".to_string(),
"bcb".to_string(),
"ece".to_string(),
"aa".to_string(),
"e".to_string()
],
vec![vec![0, 2], vec![1, 4], vec![1, 1]]
)
);
}<|fim_prefix|>// repo: redsnap... | code_fim | hard | {
"lang": "rust",
"repo": "redsnapper2006/leetcode-cn",
"path": "/C/2559-count-vowel-strings-in-ranges/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: balena-io-modules/libnm-rs path: /src/object.rs
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute};
gl... | code_fim | hard | {
"lang": "rust",
"repo": "balena-io-modules/libnm-rs",
"path": "/src/object.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(any(feature = "v1_34", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_34")))]
fn connect_client_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_client_trampoline<P: IsA<Object>, F: Fn(&P) + 'static>(
t... | code_fim | hard | {
"lang": "rust",
"repo": "balena-io-modules/libnm-rs",
"path": "/src/object.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[doc(alias = "path")]
fn connect_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<Object>> ObjectExt for O {
//#[cfg(any(feature = "v1_24", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_24")))]
//fn client(&self) -> /*Unimple... | code_fim | hard | {
"lang": "rust",
"repo": "balena-io-modules/libnm-rs",
"path": "/src/object.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/corda-rpc path: /corda-rpc/src/client.rs
use std::collections::HashMap;
use std::convert::TryFrom;
use std::time::SystemTime;
use oasis_amqp::{amqp, proto::BytesFrame};
use rand::{self, Rng};
use serde_bytes::Bytes;
use tokio::net::ToSocketAddrs;
use uuid::Uuid;
use crate::types::Rpc;
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/corda-rpc",
"path": "/corda-rpc/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let now = SystemTime::now();
let timestamp = now.duration_since(SystemTime::UNIX_EPOCH).unwrap();
let timestamp = i64::try_from(timestamp.as_millis()).unwrap();
let rpc_id = format!("{:x}", Uuid::new_v4().to_hyphenated());
let rpc_session_id = format!("{:x}", Uuid:... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/corda-rpc",
"path": "/corda-rpc/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
#[cfg(not(tarpaulin_include))]
mod tests {
use super::*;
use crate::env;
#[test]
fn test_get_gist() -> Result<()> {
let gh_token = env::github_token(&None::<String>)?;
let id = "9c6aa4ba5d7464066d55175f59e428ac";
get_gist(gh_token, id)?;
Ok(())... | code_fim | hard | {
"lang": "rust",
"repo": "sapporo-wes/yevis-cli",
"path": "/src/gh/gist.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sapporo-wes/yevis-cli path: /src/gh/gist.rs
use crate::gh;
use anyhow::{anyhow, Result};
use serde_json::Value;
use url::Url;
/// https://docs.github.com/ja/rest/gists/gists#get-a-gist
pub fn get_gist(gh_token: impl AsRef<str>, id: impl AsRef<str>) -> Result<Value> {
let res = gh::get_requ... | code_fim | hard | {
"lang": "rust",
"repo": "sapporo-wes/yevis-cli",
"path": "/src/gh/gist.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn close(&self) -> Result<()> {
sys::close(self.fd)?;
Ok(())
}
}
pub fn new_err_pipe() -> (ErrPipeRead, ErrPipeWrite) {
let (read_fd, write_fd) = sys::pipe().unwrap_or_else(|err| {
eprintln!("failed to create err pipe: {}", err);
std::process::exit(exitcode... | code_fim | hard | {
"lang": "rust",
"repo": "alexhsamuel/ir",
"path": "/src/err_pipe.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexhsamuel/ir path: /src/err_pipe.rs
use crate::err::{Error, Result};
use crate::fdio;
use crate::sel;
use crate::sys;
use crate::sys::fd_t;
pub struct ErrPipeRead {
fd: fd_t,
errs: Vec<String>,
}
<|fim_suffix|> pub fn get_errors(self) -> Vec<String> {
self.errs
}
}
im... | code_fim | medium | {
"lang": "rust",
"repo": "alexhsamuel/ir",
"path": "/src/err_pipe.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn new_err_pipe() -> (ErrPipeRead, ErrPipeWrite) {
let (read_fd, write_fd) = sys::pipe().unwrap_or_else(|err| {
eprintln!("failed to create err pipe: {}", err);
std::process::exit(exitcode::OSERR);
});
let err_read = ErrPipeRead {fd: read_fd, errs: Vec::new()};
let err_... | code_fim | hard | {
"lang": "rust",
"repo": "alexhsamuel/ir",
"path": "/src/err_pipe.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", colored_cells(1)); // 1
println!("{}", colored_cells(2)); // 5
println!("{}", colored_cells(3)); // 13
println!("{}", colored_cells(4)); // 25
println!("{}", colored_cells(5)); // 41
println!("{}", colored_cells(6)); // 61
println!("{}", colored_cells(7)); // 85
... | code_fim | medium | {
"lang": "rust",
"repo": "fredyw/leetcode",
"path": "/src/main/rust/src/bin/problem2579.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fredyw/leetcode path: /src/main/rust/src/bin/problem2579.rs
// https://leetcode.com/problems/count-total-number-of-colored-cells/
pub fn colored_cells(n: i32) -> i64 {
let mut answer: i64 = 1;
let multiplier = 4;
for i in 1..n {
answer += i as i64 * multiplier;
}
answ... | code_fim | medium | {
"lang": "rust",
"repo": "fredyw/leetcode",
"path": "/src/main/rust/src/bin/problem2579.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bencaddyro/demo-rust-kafka path: /src/main.rs
use rdkafka::config::ClientConfig;
use rdkafka::producer::{BaseProducer, BaseRecord, Producer};
use rdkafka::consumer::{BaseConsumer, Consumer};
use rdkafka::message::{Message};
use std::time::Duration;
use std::str::from_utf8;
use std::env::args;
... | code_fim | hard | {
"lang": "rust",
"repo": "Bencaddyro/demo-rust-kafka",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//Consume and display incoming message on one topic
fn consume(brokers: &str, topic: &str, group_id: &str) {
println!("Receiving on \"{}\", topic is \"{}\"", brokers, topic);
let consumer: BaseConsumer = ClientConfig::new()
.set("group.id", group_id)
.set("bootstrap.servers", broke... | code_fim | hard | {
"lang": "rust",
"repo": "Bencaddyro/demo-rust-kafka",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZacharyKamerling/rust_rts path: /src/behavior/unit/core.rs
_towards_point(game, id, tx, ty);
slow_down(game, id);
} else {
move_towards_target(game, id, t_id, mg);
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ZacharyKamerling/rust_rts",
"path": "/src/behavior/unit/core.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZacharyKamerling/rust_rts path: /src/behavior/unit/core.rs
range(game, id, t_id, wpn_range);
let is_bomber = match game.units.weapons(id)[0].attack() {
&Attack::Bomb(_) |
&Attack::LaserBomb(_) => true,
... | code_fim | hard | {
"lang": "rust",
"repo": "ZacharyKamerling/rust_rts",
"path": "/src/behavior/unit/core.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x_dif = new_x - x;
let y_dif = new_y - y;
let dist_traveled = f64::sqrt(x_dif * x_dif + y_dif * y_dif);
let reduct = f64::max(1.0, dist_traveled / game.units.top_speed(id));
let x_repel;
let y_repel;
if x_corrected {
x_repel = 0.0;
} else {
x_repel = ... | code_fim | hard | {
"lang": "rust",
"repo": "ZacharyKamerling/rust_rts",
"path": "/src/behavior/unit/core.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: froydnj/rust-makecab path: /mszip/src/lib.rs
_sys;
use std::io::prelude::*;
use std::io::{self, BufReader, Cursor};
use flate2::{Compress, Decompress, Flush, Status};
use flate2::raw::mz_stream;
pub use flate2::Compression;
use libz_sys::{Z_OK, inflateReset, inflateSetDictionary};
// libz-sy... | code_fim | hard | {
"lang": "rust",
"repo": "froydnj/rust-makecab",
"path": "/mszip/src/lib.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> AllocationRoutines: PCOMPRESS_ALLOCATION_ROUTINES,
DecompressorHandle: PDECOMPRESSOR_HANDLE) -> BOOL;
fn CloseDecompressor(DecompressorHandle: DECOMPRESSOR_HANDLE) -> BOOL;
fn Decompress(DecompressorHandle: DECOMPR... | code_fim | hard | {
"lang": "rust",
"repo": "froydnj/rust-makecab",
"path": "/mszip/src/lib.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: froydnj/rust-makecab path: /mszip/src/lib.rs
mpress, Decompress, Flush, Status};
use flate2::raw::mz_stream;
pub use flate2::Compression;
use libz_sys::{Z_OK, inflateReset, inflateSetDictionary};
// libz-sys doesn't expose these, as they're undocumented and not
// generally useful, but per Mar... | code_fim | hard | {
"lang": "rust",
"repo": "froydnj/rust-makecab",
"path": "/mszip/src/lib.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndrewTweddle/GoogleCodeJam path: /Practice/2022/Round1B/pancake_deque/src/main.rs
use std::collections::VecDeque;
use std::io;
use std::io::{BufRead, Write};
fn main() {
let stdin = io::stdin();
let stdin_lock = stdin.lock();
let stdout = io::stdout();
let mut stdout_lock = st... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewTweddle/GoogleCodeJam",
"path": "/Practice/2022/Round1B/pancake_deque/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut answer: usize = 0;
let mut biggest_val: u32 = 0;
while !d.is_empty() {
let next_val = (if d.front() < d.back() {
d.pop_front()
} else {
d.pop_back()
})
.unwrap();
if next_val >= bigg... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewTweddle/GoogleCodeJam",
"path": "/Practice/2022/Round1B/pancake_deque/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Extracts filename and crypto_content from enc file
pub fn dismantle_enc(&self) -> Result<(&str, &[u8]), ScryptoError> {
// Splits the enc file on the / inbetween filename and params/ciphertext
let split = match self.content.iter().position(|&b| b == b"/"[..][0]) {
S... | code_fim | hard | {
"lang": "rust",
"repo": "ryanleh/scrypto",
"path": "/rust/src/file_handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Push all components to be written
to_write.push(self.filename.as_bytes());
to_write.push(b"/");
to_write.append(&mut crypto_content);
self.write(&to_write)?;
Ok(())
}
/// Extracts filename and crypto_content from enc file
pub fn dismantle_enc... | code_fim | hard | {
"lang": "rust",
"repo": "ryanleh/scrypto",
"path": "/rust/src/file_handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryanleh/scrypto path: /rust/src/file_handler.rs
use std::str;
use std::io;
use self::io::prelude::*;
use std::io::{ Error, ErrorKind };
use std::fs;
use std::fs::File;
use std::path::Path;
use std::cell::RefCell;
use Operation;
use ScryptoError;
pub struct FileHandler<'a> {
filename: &'a st... | code_fim | hard | {
"lang": "rust",
"repo": "ryanleh/scrypto",
"path": "/rust/src/file_handler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/bevy_networking_turbulence path: /examples/utils/mod.rs
// Arg parser for the examples.
//
// each example gets a different Args struct, which it adds as a bevy resource
use clap::{Arg, App as ClapApp, value_t_or_exit};
#[derive(Debug)]
pub struct SimpleArgs {
pub is_server: bool,... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/bevy_networking_turbulence",
"path": "/examples/utils/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
fn flushing_strategy_args<'a>() -> Vec<Arg<'a, 'a>> {
vec![
Arg::with_name("auto-flush")
.help("Flush after every send")
.long("auto-flush")
.required_unless("manual-flush")
.conflicts_with("manual-flush")
.takes_value(false)
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/bevy_networking_turbulence",
"path": "/examples/utils/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: intgr/anaXgram path: /src/main.rs
use memchr::memchr;
use memcmp::Memcmp;
use memmap::MmapOptions;
use num_cpus;
use std::cmp::max;
use std::env;
use std::fs::File;
use std::io::Result;
use std::num::Wrapping;
use std::process::exit;
use std::sync::Arc;
use std::thread;
use std::time::Instant;
... | code_fim | hard | {
"lang": "rust",
"repo": "intgr/anaXgram",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut children = vec![];
let mut startpos = 0;
for i in 0..threads-1 {
// Find a linebreak for each thread
let tmp_pos = max(startpos, (data.len() * (i+1))/threads);
match memchr(b'\n', &data[tmp_pos..]) {
Some(offset) => {
let endpos = tm... | code_fim | hard | {
"lang": "rust",
"repo": "intgr/anaXgram",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomaseizinger/autocxx path: /src/lib.rs
//! Crate to `#include` C++ headers in your Rust code, and generate
//! idiomatic bindings using `cxx`. See [include_cpp] for details.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use t... | code_fim | hard | {
"lang": "rust",
"repo": "thomaseizinger/autocxx",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Generate as "plain old data".
/// Generate Rust bindings for the given C++ type such that
/// it can be passed and owned by value in Rust. This only works
/// for C++ types which have trivial move constructors and no
/// destructor - you'll encounter a compile error otherwise.
/// If your type doesn't... | code_fim | hard | {
"lang": "rust",
"repo": "thomaseizinger/autocxx",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dekuraan/building-blocks path: /crates/building_blocks_core/src/point3.rs
use crate::{
point::SmallOne, Bounded, Distance, DotProduct, IntegerPoint, Norm, Ones, Point, Point2,
PointN, SmallZero,
};
use core::ops::{Add, AddAssign, Div, Mul, Sub, SubAssign};
use num::{traits::Pow, Integer... | code_fim | hard | {
"lang": "rust",
"repo": "dekuraan/building-blocks",
"path": "/crates/building_blocks_core/src/point3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> DotProduct for Point3<T>
where
T: Copy + Add<Output = T> + Mul<Output = T>,
{
type Scalar = T;
fn dot(&self, other: &Self) -> Self::Scalar {
self.x() * other.x() + self.y() * other.y() + self.z() * other.z()
}
}
impl IntegerPoint for Point3i {
const MIN: Self = PointN... | code_fim | hard | {
"lang": "rust",
"repo": "dekuraan/building-blocks",
"path": "/crates/building_blocks_core/src/point3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> Mul<Point3<T>> for Point3<T>
where
T: Copy + Mul<Output = T>,
{
type Output = Self;
fn mul(self, other: Self) -> Self {
PointN([
other.x() * self.x(),
other.y() * self.y(),
other.z() * self.z(),
])
}
}
// Use specialized impleme... | code_fim | hard | {
"lang": "rust",
"repo": "dekuraan/building-blocks",
"path": "/crates/building_blocks_core/src/point3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[test]
fn play_join_game() {
new_test_ext().execute_with(|| {
RockPaperScissors::create_game(Origin::signed(1));
RockPaperScissors::join_game(Origin::signed(1), 123);
assert_eq!(1, 1);
});
}<|fim_prefix|>// repo: bmacer/rock-paper-scissors path: /pallets/rock-paper-scissors/src/tests.rs
// use ... | code_fim | hard | {
"lang": "rust",
"repo": "bmacer/rock-paper-scissors",
"path": "/pallets/rock-paper-scissors/src/tests.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bmacer/rock-paper-scissors path: /pallets/rock-paper-scissors/src/tests.rs
// use crate::{Error, mock::*};
// use frame_support::{assert_ok, assert_noop};
use crate::{mock::*};
/*
#[test]
fn it_works_for_default_value() {
new_test_ext().execute_with(|| {
// Dispatch a signed extrinsic.
// ... | code_fim | hard | {
"lang": "rust",
"repo": "bmacer/rock-paper-scissors",
"path": "/pallets/rock-paper-scissors/src/tests.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>er: MIT
pub fn run() {
println!("run!");
}<|fim_prefix|>// repo: tauri-apps/tauri path: /examples/workspace/core/src/lib.rs
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Ide<|fim_middle|>ntifier: Apache-2.0
// SPDX-License-Identifi | code_fim | easy | {
"lang": "rust",
"repo": "tauri-apps/tauri",
"path": "/examples/workspace/core/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tauri-apps/tauri path: /examples/workspace/core/src/lib.rs
// Copyright 2019-2023 Tauri Programme withi<|fim_suffix|>ntifier: Apache-2.0
// SPDX-License-Identifier: MIT
pub fn run() {
println!("run!");
}<|fim_middle|>n The Commons Conservancy
// SPDX-License-Ide | code_fim | easy | {
"lang": "rust",
"repo": "tauri-apps/tauri",
"path": "/examples/workspace/core/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_connector(
mut self,
connector: Connector<'a>,
) -> PipelineInit<'a> {
self.connector = Some(connector);
self
}
pub fn set_crtc(mut self, crtc: Crtc<'a>) -> PipelineInit<'a> {
self.crtc = Some(crtc);
self
}
pub fn set_enc... | code_fim | hard | {
"lang": "rust",
"repo": "mripard/doremi",
"path": "/src/pipeline.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mripard/doremi path: /src/pipeline.rs
use crate::atomic::AtomicRequest;
use crate::buffer::Buffer;
use crate::connector::Connector;
use crate::crtc::Crtc;
use crate::device::Device;
use crate::encoder::Encoder;
use crate::error::Error;
use crate::error::Result;
use crate::mode::Mode;
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "mripard/doremi",
"path": "/src/pipeline.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AsBytes for Macro {
fn as_bytes(&self) -> Result<Vec<u8>, DATError> {
let sections = self.as_sections()?;
let mut byte_vec = Vec::<u8>::new();
for section in sections.into_iter() {
let mut sec_bytes = Vec::<u8>::from(section);
byte_vec.append(&mut s... | code_fim | hard | {
"lang": "rust",
"repo": "atrense/libxivdat",
"path": "/src/high_level_modules/macro.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Returns a byte vector representing a slice of [`MacroData`]. This can then be written back
/// to a a file using [`write_content()`](crate::dat_file::write_content).
///
/// # Errors
///
/// Returns [`DATError::Overflow`] if a macro data section would exceed the maximum possible
/// size for that sect... | code_fim | hard | {
"lang": "rust",
"repo": "atrense/libxivdat",
"path": "/src/high_level_modules/macro.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atrense/libxivdat path: /src/high_level_modules/macro.rs
to memory
/// to prevent repeat file access. This is similar to [`read_content()`](crate::dat_file::read_content),
/// but returns a `Vec<Macro>` instead of raw bytes. A valid macro file should always contain 100 macros,
/// but this funct... | code_fim | hard | {
"lang": "rust",
"repo": "atrense/libxivdat",
"path": "/src/high_level_modules/macro.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("".parse::<Pattern>().unwrap().0, Vec::new());
assert_eq!("p".parse::<Pattern>().unwrap().0, vec![Hir::Exact(b'p')]);
assert_eq!(".".parse::<Pattern>().unwrap().0, vec![Hir::Glob]);
assert_eq!(
".*".parse::<Pattern>().unwrap().0,
vec![Hir:... | code_fim | hard | {
"lang": "rust",
"repo": "flappyBug/leetcode-rs",
"path": "/src/p0010.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flappyBug/leetcode-rs path: /src/p0010.rs
use std::str::FromStr;
pub struct Solution;
#[derive(Debug, Eq, PartialEq)]
enum Hir {
Exact(u8),
ZeroOrMore(Box<Hir>),
Glob,
}
#[derive(Debug)]
struct Pattern(Vec<Hir>);
impl FromStr for Pattern {
type Err = ();
fn from_str(s: &... | code_fim | hard | {
"lang": "rust",
"repo": "flappyBug/leetcode-rs",
"path": "/src/p0010.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> manager.update_holdings(
"TSLA",
Shares(Decimal::new(-2, 0)),
Price(Decimal::new(80, 0)),
);
assert_eq!(manager.long_market_exposure(), Decimal::new(100, 0));
assert_eq!(manager.short_market_exposure(), Decimal::new(160, 0));
asse... | code_fim | hard | {
"lang": "rust",
"repo": "Overmuse/risk-manager",
"path": "/src/risk_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.