text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> fn get_private_key_2() -> PrivateKey {
let pk_pem = crate::test_files::RSA_2048_PK_2.parse::<Pem>().unwrap();
PrivateKey::from_pkcs8(pk_pem.data()).unwrap()
}
const fn get_strongly_typed_claims() -> MyClaims {
MyClaims {
sub: Cow::Borrowed("1234567890"),
... | code_fim | hard | {
"lang": "rust",
"repo": "ionut-arm/picky-rs",
"path": "/picky/src/jose/jwt.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/action/icon_alarm_off.rs
pub struct IconAlarmOff {
props: crate::Props,
}
impl yew::Component for IconAlarmOff {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelude::Co... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/action/icon_alarm_off.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: khayyamsaleem/advent-of-code path: /2020/src/day_11.rs
use crate::common;
use plotters::prelude::*;
// seats
const FLOOR: char = '.';
const FLOOR_COLOR: &RGBColor = &GREEN;
const EMPTY_SEAT: char = 'L';
const EMPTY_SEAT_COLOR: &RGBColor = &BLUE;
const OCCUPIED_SEAT: char = '#';
const OCCUPIED... | code_fim | hard | {
"lang": "rust",
"repo": "khayyamsaleem/advent-of-code",
"path": "/2020/src/day_11.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let part_two_evolved = evolve_grid(
&grid,
|x| apply_rules(x, count_all_occupied_visible_seats, 5),
&BitMapBackend::gif(
format!("{}/day_11_part_2.gif", RENDER_OUTPUT_DIR),
(CANVAS_SIZE, CANVAS_SIZE),
RENDER_FRAME_DELAY,
)
.un... | code_fim | hard | {
"lang": "rust",
"repo": "khayyamsaleem/advent-of-code",
"path": "/2020/src/day_11.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn need_type_info_err(
&self,
body_id: Option<hir::BodyId>,
span: Span,
ty: Ty<'tcx>
) -> DiagnosticBuilder<'gcx> {
let ty = self.resolve_vars_if_possible(&ty);
let name = self.extract_type_name(&ty, None);
let mut err_span = span;
... | code_fim | hard | {
"lang": "rust",
"repo": "avr-rust/rust-legacy-fork",
"path": "/src/librustc/infer/error_reporting/need_type_info.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let (None, Some(ty)) = (self.found_local_pattern, self.node_matches_type(local.hir_id)) {
self.found_local_pattern = Some(&*local.pat);
self.found_ty = Some(ty);
}
intravisit::walk_local(self, local);
}
fn visit_body(&mut self, body: &'gcx Body) ... | code_fim | hard | {
"lang": "rust",
"repo": "avr-rust/rust-legacy-fork",
"path": "/src/librustc/infer/error_reporting/need_type_info.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avr-rust/rust-legacy-fork path: /src/librustc/infer/error_reporting/need_type_info.rs
use crate::hir::def::Namespace;
use crate::hir::{self, Local, Pat, Body, HirId};
use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
use crate::infer::InferCtxt;
use crate::infer::type_variable::Type... | code_fim | hard | {
"lang": "rust",
"repo": "avr-rust/rust-legacy-fork",
"path": "/src/librustc/infer/error_reporting/need_type_info.rs",
"mode": "psm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nulltone/project-euler path: /problem_004/src/main.rs
#![feature(env)]
#![feature(core)]
use std::env;
use std::num::Int;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("Please enter a number.");
return;
}
let max_digits... | code_fim | medium | {
"lang": "rust",
"repo": "nulltone/project-euler",
"path": "/problem_004/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn calculate_max_palindrome(number: u32) -> u32 {
let mut highest_product = 0;
for left_product in range(0, number + 1).rev() {
for right_product in range(0, number + 1).rev() {
let value: u32 = left_product * right_product;
let value_str = value.to_string();
... | code_fim | hard | {
"lang": "rust",
"repo": "nulltone/project-euler",
"path": "/problem_004/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // however, once it is fused
let mut stream = stream.fuse();
assert_eq!(stream.size_hint(), (0, None));
assert_eq!(stream.next().await, Some(4));
assert_eq!(stream.size_hint(), (0, None));
assert_eq!(stream.next().await, None);
// it will always return `None` after the first... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/tokio",
"path": "/tokio-stream/tests/stream_fuse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tokio-rs/tokio path: /tokio-stream/tests/stream_fuse.rs
use tokio_stream::{Stream, StreamExt};
use std::pin::Pin;
use std::task::{Context, Poll};
// a stream which alternates between Some and None
struct Alternate {
state: i32,
}
impl Stream for Alternate {
type Item = i32;
fn po... | code_fim | medium | {
"lang": "rust",
"repo": "tokio-rs/tokio",
"path": "/tokio-stream/tests/stream_fuse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if it's even, Some(i32), else None
if val % 2 == 0 {
Poll::Ready(Some(val))
} else {
Poll::Ready(None)
}
}
}
#[tokio::test]
async fn basic_usage() {
let mut stream = Alternate { state: 0 };
// the stream goes back and forth
asser... | code_fim | medium | {
"lang": "rust",
"repo": "tokio-rs/tokio",
"path": "/tokio-stream/tests/stream_fuse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icota/legogro16 path: /src/lib.rs
//! An implementation of the [`Groth16`] zkSNARK.
//!
//! [`Groth16`]: https://eprint.iacr.org/2016/260.pdf
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(unused, future_incompatible, nonstandard_style, rust_2018_idioms)]
#![allow(clippy::many_single_char_na... | code_fim | medium | {
"lang": "rust",
"repo": "icota/legogro16",
"path": "/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Verify proofs for the Groth16 zkSNARK construction.
pub mod verifier;
pub mod link;
/// Constraints for the Groth16 verifier.
#[cfg(feature = "r1cs")]
pub mod constraints;
#[cfg(test)]
mod test;
pub use self::data_structures::*;
pub use self::{generator::*, prover::*, verifier::*};
use ark_std::v... | code_fim | medium | {
"lang": "rust",
"repo": "icota/legogro16",
"path": "/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::data_structures::*;
pub use self::{generator::*, prover::*, verifier::*};
use ark_std::vec::Vec;<|fim_prefix|>// repo: icota/legogro16 path: /src/lib.rs
//! An implementation of the [`Groth16`] zkSNARK.
//!
//! [`Groth16`]: https://eprint.iacr.org/2016/260.pdf
#![cfg_attr(not(feature = "st... | code_fim | medium | {
"lang": "rust",
"repo": "icota/legogro16",
"path": "/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PhilippGawlik/naive_langguesser path: /src/main.rs
extern crate naive_langguesser;
#[macro_use] // necessary for yaml config of clap
extern crate clap;
<|fim_suffix|> let yaml = load_yaml!("../cli.yml");
let matches = App::from_yaml(yaml).get_matches();
if let Some(matches) = matches... | code_fim | medium | {
"lang": "rust",
"repo": "PhilippGawlik/naive_langguesser",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let yaml = load_yaml!("../cli.yml");
let matches = App::from_yaml(yaml).get_matches();
if let Some(matches) = matches.subcommand_matches("model") {
let config = ModelConfig::new(matches);
process::exit(match naive_langguesser::model(config) {
Ok(_) => 0,
... | code_fim | medium | {
"lang": "rust",
"repo": "PhilippGawlik/naive_langguesser",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ccyanxyz/portfolio-cli path: /src/lib/paraswap.rs
use serde_json::Value;
use std::error;
use std::io;
use std::thread::sleep;
use std::time::Duration;
#[allow(dead_code)]
pub async fn fetch(url: &String, verbose: bool) -> Result<Value, Box<dyn error::Error>> {
let mut retry: u32 = 0;
le... | code_fim | hard | {
"lang": "rust",
"repo": "ccyanxyz/portfolio-cli",
"path": "/src/lib/paraswap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = fetch(&url, false).await;
assert_eq!(
result.unwrap().to_string(),
"{\"error\":\"Token not found\"}"
);
}
#[tokio::test]
async fn get_token_price_success() {
// AAVE token address
let contract_address = "0x7fc66500c8... | code_fim | hard | {
"lang": "rust",
"repo": "ccyanxyz/portfolio-cli",
"path": "/src/lib/paraswap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[tokio::test]
async fn get_token_price_success() {
// AAVE token address
let contract_address = "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9";
let price = get_token_price(contract_address, "usd", true)
.await
.unwrap();
assert_ne!(price, 0.0)... | code_fim | hard | {
"lang": "rust",
"repo": "ccyanxyz/portfolio-cli",
"path": "/src/lib/paraswap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Szetty/advent_of_code_2020 path: /src/day05.rs
use std::str::Chars;
pub fn part1(inp: String) {
let max_seat_id = inp
.lines()
.map(|l| {
let boarding_pass = decode_boarding_pass(l);
boarding_pass.seat_id
})
.max()
.unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "Szetty/advent_of_code_2020",
"path": "/src/day05.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (encoded_row, encoded_column) = encoded_boarding_pass.split_at(7);
let row = decode_chars((0, 127), encoded_row.chars());
let column = decode_chars((0, 7), encoded_column.chars());
BoardingPass {
row: row,
column: column,
seat_id: row * 8 + column,
}
}
fn d... | code_fim | hard | {
"lang": "rust",
"repo": "Szetty/advent_of_code_2020",
"path": "/src/day05.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
decode_boarding_pass("FBFBBFFRLR"),
BoardingPass {
row: 44,
column: 5,
seat_id: 357
}
);
assert_eq!(
decode_boarding_pass("BFFFBBFRRR"),
BoardingPass {
row: 70,
column: 7,
... | code_fim | hard | {
"lang": "rust",
"repo": "Szetty/advent_of_code_2020",
"path": "/src/day05.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // passed through a position
if !done {
player.movement_route.remove(0);
}
}
}
for (_, mut sprite, mut transform) in (&highlight_tile_storage, &mut sprites, &mut transforms).join() {
sprite.visible... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/agile_archer",
"path": "/src/systems/player_movement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agmcleod/agile_archer path: /src/systems/player_movement.rs
use std::ops::{Deref, DerefMut};
use specs::{Fetch, FetchMut, Join, ReadStorage, WriteStorage, System};
use components::{Input, GameState, HighlightTile, Player, PlayerActionState, Sprite, TileData, Transform};
use math::astar;
use type... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/agile_archer",
"path": "/src/systems/player_movement.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: XUranus/Lua path: /src/state.rs
mod lua_stack;
mod lua_state;
mod closure;
mod lua_value;
mod arith_ops;
mod cmp_ops;
mod math;
mod lua_table;
<|fim_suffix|>pub fn new_lua_state() -> LuaState {
LuaState::new()
}<|fim_middle|>use crate::binary::chunk::Prototype;
pub use self::lua_state::LuaS... | code_fim | medium | {
"lang": "rust",
"repo": "XUranus/Lua",
"path": "/src/state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn new_lua_state() -> LuaState {
LuaState::new()
}<|fim_prefix|>// repo: XUranus/Lua path: /src/state.rs
mod lua_stack;
mod lua_state;
mod closure;
mod lua_value;
mod arith_ops;
mod cmp_ops;
mod math;
mod lua_table;
<|fim_middle|>use crate::binary::chunk::Prototype;
pub use self::lua_state::LuaS... | code_fim | medium | {
"lang": "rust",
"repo": "XUranus/Lua",
"path": "/src/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jayjamesjay/http_req path: /src/request.rs
mut Self
where
HttpVersion: From<T>,
{
self.inner.version(version);
self
}
///Replaces all it's headers with headers passed to the function
///
///# Examples
///```
///use http_req::{request::Requ... | code_fim | hard | {
"lang": "rust",
"repo": "jayjamesjay/http_req",
"path": "/src/request.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>///Creates and sends HEAD request. Returns response for this request.
///
///# Examples
///```
///use http_req::request;
///
///const uri: &str = "https://www.rust-lang.org/learn";
///let response = request::head(uri).unwrap();
///```
pub fn head<T: AsRef<str>>(uri: T) -> Result<Response, error::Error> {
... | code_fim | hard | {
"lang": "rust",
"repo": "jayjamesjay/http_req",
"path": "/src/request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(b) = &self.body {
request_msg.extend(*b);
}
request_msg
}
}
///Relatively higher-level struct for making HTTP requests.
///
///It creates stream (`TcpStream` or `TlsStream`) appropriate for the type of uri (`http`/`https`)
///By default it closes conne... | code_fim | hard | {
"lang": "rust",
"repo": "jayjamesjay/http_req",
"path": "/src/request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadyproject/learn path: /rust/rust-101/src/part11.rs
// Rust-101, Part 11: Trait Objects, Box, Lifetime bounds
// ======================================================
// For now, we just decide that the callbacks have an argument of type `i32`.
struct CallbacksV1<F: FnMut(i32)> {
callba... | code_fim | medium | {
"lang": "rust",
"repo": "shadyproject/learn",
"path": "/rust/rust-101/src/part11.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// **Exercise 11.1**: We made the arbitrary choice of using `i32` for the arguments. Generalize the data structures above
// to work with an arbitrary type `T` that's passed to the callbacks. Since you need to call multiple callbacks with the
// same `t: T`, you will either have to restrict `T` to `Copy`... | code_fim | hard | {
"lang": "rust",
"repo": "shadyproject/learn",
"path": "/rust/rust-101/src/part11.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tkhr0/awskey path: /src/domain/value_objects/profile_name.rs
use regex::Regex;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct ProfileName {
value: String,
}
impl ProfileName {
pub fn new(name: String) -> Result<Self, String> {
let this ... | code_fim | medium | {
"lang": "rust",
"repo": "tkhr0/awskey",
"path": "/src/domain/value_objects/profile_name.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn validate(&self) -> Result<(), String> {
self.validate_value_format()?;
Ok(())
}
fn validate_value_format(&self) -> Result<(), String> {
let result = Regex::new(r"^[[:word:]]{1,100}$")
.unwrap()
.is_match(&self.value);
if result {
... | code_fim | hard | {
"lang": "rust",
"repo": "tkhr0/awskey",
"path": "/src/domain/value_objects/profile_name.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut current_min_distance = std::u32::MAX;
for task in next_queue.iter() {
current_min_distance = std::cmp::min(task.1.iter().fold(0u32, |mut sum, state| {sum += state.distance_travelled; sum}), current_min_distance);
}
// Expand the queued states
f... | code_fim | hard | {
"lang": "rust",
"repo": "asterycs/aoc2019",
"path": "/src/bin/18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check if there already is a state that has obtained the same keys with a lower distance
match queue.get_mut(&(sorted_keys.clone(), positions.clone())) {
Some(other) => {
let rhs_distance = other.iter().fold(0u32, |mut sum, state| {sum += state.distance_travel... | code_fim | hard | {
"lang": "rust",
"repo": "asterycs/aoc2019",
"path": "/src/bin/18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asterycs/aoc2019 path: /src/bin/18.rs
h::PathBuf;
use std::cmp::Ordering;
use std::collections::{HashSet, HashMap, VecDeque};
use std::hash::Hash;
type Map = Vec<Vec<Tile>>;
fn build_map(input: &String) -> Map {
let mut map = Map::new();
for line in input.split('\n') {
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "asterycs/aoc2019",
"path": "/src/bin/18.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sousa99/Apre-2021 path: /gradient-descent/src/lib.rs
use nalgebra::{DVector};
pub type Element = f64;
pub type Vector = DVector<Element>;
#[allow(dead_code)]
#[derive(Copy, Clone)]
enum IterationType {
Predefined,
Stochastic,
}
#[allow(dead_code)]
#[derive(Copy, Clone)]
enum ErrorFunc... | code_fim | hard | {
"lang": "rust",
"repo": "Sousa99/Apre-2021",
"path": "/gradient-descent/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dimension : usize = self.initial_weights.shape().0;
let last_weight : Vector = self.weights.last().unwrap().clone();
let new_weight : Vector = match self.iteration_type {
IterationType::Predefined => {
let mut variation : Vector = Vector::from_eleme... | code_fim | hard | {
"lang": "rust",
"repo": "Sousa99/Apre-2021",
"path": "/gradient-descent/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: N-Multifibra/noc path: /rust/agent/src/collectors/cpu/collector.rs
// ---------------------------------------------------------------------
// cpu collector implementation
// ---------------------------------------------------------------------
// Copyright (C) 2007-2021 The NOC Project
// See L... | code_fim | hard | {
"lang": "rust",
"repo": "N-Multifibra/noc",
"path": "/rust/agent/src/collectors/cpu/collector.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl Collectable for CpuCollector {
async fn collect(&self) -> Result<Status, AgentError> {
let sys = System::new();
let ts = self.get_timestamp();
let delayed_stats = sys
.cpu_load()
.map_err(|e| AgentError::InternalError(e.to_string()))?... | code_fim | hard | {
"lang": "rust",
"repo": "N-Multifibra/noc",
"path": "/rust/agent/src/collectors/cpu/collector.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> match &value.config {
CollectorConfig::Cpu(_) => Ok(Self {
id: value.id.clone(),
interval: value.interval,
labels: value.labels.clone(),
}),
_ => Err(AgentError::ConfigurationError("invalid config".into())),
... | code_fim | medium | {
"lang": "rust",
"repo": "N-Multifibra/noc",
"path": "/rust/agent/src/collectors/cpu/collector.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fiinnnn/sudoku-rs path: /solver/src/parse_error.rs
//! Sudoku parsing errors
use std::error::Error;
use std::fmt;
/// Error while parsing the sudoku
#[derive(Debug)]
pub enum ParseError {
/// Line length didn't match the expected line length
///
/// InvalidLineLength(line nr, expec... | code_fim | hard | {
"lang": "rust",
"repo": "fiinnnn/sudoku-rs",
"path": "/solver/src/parse_error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
InvalidLineLength(line_nr, expected, actual) => write!(
f,
"Line {} didn't match expected line length. Expected: {}, Actual: {}",
line_nr, expected, actual
),
InvalidRowCount(expected, actual) => writ... | code_fim | medium | {
"lang": "rust",
"repo": "fiinnnn/sudoku-rs",
"path": "/solver/src/parse_error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Invalid character encountered
///
/// InvalidCharacter(line nr, character)
InvalidCharacter(usize, char),
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::ParseError::*;
match *self {
InvalidLineLeng... | code_fim | medium | {
"lang": "rust",
"repo": "fiinnnn/sudoku-rs",
"path": "/solver/src/parse_error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn connect_property_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::width",
transmute(notify_width_trampoline::<Self... | code_fim | hard | {
"lang": "rust",
"repo": "EPashkin/webkit2gtk-webextension-rs",
"path": "/src/auto/dom_client_rect.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EPashkin/webkit2gtk-webextension-rs path: /src/auto/dom_client_rect.rs
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use DOMObject;
use ffi;
use glib;
use glib::StaticType;
use glib::Value;
use glib::obje... | code_fim | hard | {
"lang": "rust",
"repo": "EPashkin/webkit2gtk-webextension-rs",
"path": "/src/auto/dom_client_rect.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_property_bottom(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "bottom".to_glib_none().0, value.to_glib_none_mut().0);
value.get().unwrap()
... | code_fim | hard | {
"lang": "rust",
"repo": "EPashkin/webkit2gtk-webextension-rs",
"path": "/src/auto/dom_client_rect.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rainbowtable_path = matches.value_of("rainbowtable").unwrap();
// The validator ensures that the value is an u32 so unwrap should be ok.
let iterations: u32 = matches.value_of("iterations").unwrap().parse().unwrap();
// The validator ensures that the value is an u32 so unwrap should be... | code_fim | hard | {
"lang": "rust",
"repo": "aplein97/Rainbowtable",
"path": "/rust/rainbowtable/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let matches = App::new("RainbowTabler").version("0.1").author("Group 2")
.arg(
Arg::with_name("rainbowtable")
.long("rainbowtable")
.help("Sets the rainbowtable path. Either reads from or writes to, depending on command.")
.takes_value(true)
... | code_fim | hard | {
"lang": "rust",
"repo": "aplein97/Rainbowtable",
"path": "/rust/rainbowtable/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aplein97/Rainbowtable path: /rust/rainbowtable/src/main.rs
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::process;
use std::time::Instant;
use clap::{App, Arg, SubCommand};
use sha3::{Digest, Sha3_224};
mod rainbow_table;
use rainbow_table::reduction::reduction_function1;
use... | code_fim | hard | {
"lang": "rust",
"repo": "aplein97/Rainbowtable",
"path": "/rust/rainbowtable/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Simhyeon/rif path: /src/models.rs
use serde::{Serialize, Deserialize};
use crate::utils;
/// File status of any file.
///
/// Fresh means a file is up to date
/// while stale means referencing file has been updated and the file has not.
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, ... | code_fim | hard | {
"lang": "rust",
"repo": "Simhyeon/rif",
"path": "/src/models.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ListType {
pub fn from(raw : &str) -> Self {
match raw.to_lowercase().as_str() {
"all" => {
Self::All
}
"stale" => {
Self::Stale
}
_ => Self::None,
}
}
}<|fim_prefix|>// repo: Simhyeon/... | code_fim | medium | {
"lang": "rust",
"repo": "Simhyeon/rif",
"path": "/src/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Sanity type to branch sanity check.
///
/// Direct only check self referencing while indirect also checks infinite loop
pub(crate) enum SanityType {
Direct,
Indirect
}
/// Medium variable to check reference status.
///
/// This enumerator is used for sanity checking and determines whether rif... | code_fim | hard | {
"lang": "rust",
"repo": "Simhyeon/rif",
"path": "/src/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndrewGaspar/mpi-session path: /src/collective.rs
use std::marker::PhantomData;
use mpi::topology::Rank;
use mpi::traits::*;
use super::prelude::*;
pub struct AllGather<T: Equivalence, P: ProtocolPart>(PhantomData<(T, P)>);
unsafe impl<T: Equivalence, P: ProtocolPart> ProtocolPart f... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewGaspar/mpi-session",
"path": "/src/collective.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<K: super::key::Key + 'static, P: ProtocolPart, C: Communicator> Session<Publishee<K, P>, C>
where
K::Value: Equivalence,
{
pub fn receive(mut self) -> Session<P, C> {
unsafe {
let mut value: K::Value = std::mem::uninitialized();
self.comm
... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewGaspar/mpi-session",
"path": "/src/collective.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Publishee<K: super::key::Key, P: ProtocolPart>(Rank, PhantomData<(K, P)>);
impl<K: super::key::Key + 'static, P: ProtocolPart, C: Communicator> Session<Publishee<K, P>, C>
where
K::Value: Equivalence,
{
pub fn receive(mut self) -> Session<P, C> {
unsafe {
le... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewGaspar/mpi-session",
"path": "/src/collective.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: czccc/kvstore path: /src/rpc.rs
pub mod kvs_service {
mod include {
tonic::include_proto!("kvs");
}
pub use include::kv_rpc_client::KvRpcClient;
pub use include::kv_rpc_server::{KvRpc, KvRpcServer};
pub use include::{
CommitReply, CommitRequest, GetReply, GetR... | code_fim | hard | {
"lang": "rust",
"repo": "czccc/kvstore",
"path": "/src/rpc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(
f,
"[AppendEntriesReply Term: {} Success: {} Conflict: {} {}]",
self.term, self.success, self.conflict_log_index, self.conflict_log_term
)
}
}
impl std::fmt::Display for InstallSnapshotArgs {
fn fmt(&s... | code_fim | hard | {
"lang": "rust",
"repo": "czccc/kvstore",
"path": "/src/rpc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<domain_models::TodoId> for TodoId {
fn from(v: domain_models::TodoId) -> Self {
TodoId(v.0)
}
}
impl From<domain_models::TodoData> for TodoData {
fn from(v: domain_models::TodoData) -> Self {
TodoData { task: v.task }
}
}
impl From<domain_models::Todo> for Todo ... | code_fim | medium | {
"lang": "rust",
"repo": "micoud/todddo-openapi-rs",
"path": "/api/src/models/todo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: micoud/todddo-openapi-rs path: /api/src/models/todo.rs
use domain::todo as domain_models;
use paperclip::actix::api_v2_schema;
use serde_derive::{Deserialize, Serialize};
#[api_v2_schema(empty)]
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Copy, Clone)]
pub struct TodoId(pub u64);
#[... | code_fim | hard | {
"lang": "rust",
"repo": "micoud/todddo-openapi-rs",
"path": "/api/src/models/todo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> domain_models::Todo {
id: (&v.id).into(),
task: v.task.clone(),
}
}
}
impl From<domain_models::TodoId> for TodoId {
fn from(v: domain_models::TodoId) -> Self {
TodoId(v.0)
}
}
impl From<domain_models::TodoData> for TodoData {
fn from(v: dom... | code_fim | hard | {
"lang": "rust",
"repo": "micoud/todddo-openapi-rs",
"path": "/api/src/models/todo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_bhash() {
struct Test {
hpass: [u8; 64],
hsalt: [u8; 64],
out: [u8; 32],
}
const TEST_VAL: [u8; 64] = hex!(
"000102030405060708090a0b0c0d0e0f"
"101112131415161718191a1b1c1d1e1f"
"202122... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/password-hashes",
"path": "/bcrypt-pbkdf/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustCrypto/password-hashes path: /bcrypt-pbkdf/src/lib.rs
//! This crate implements [bcrypt_pbkdf], a custom derivative of PBKDF2 used in
//! [OpenSSH].
//!
//! [bcrypt_pbkdf]: https://flak.tedunangst.com/post/bcrypt-pbkdf
//! [OpenSSH]: https://flak.tedunangst.com/post/new-openssh-key-format-an... | code_fim | hard | {
"lang": "rust",
"repo": "RustCrypto/password-hashes",
"path": "/bcrypt-pbkdf/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RalfJung/structural_crates path: /structural/src/field_traits.rs
d rev_get_field;
mod multi_fields;
pub use self::rev_get_field::{
RevGetFieldType,
RevGetFieldType_,
RevFieldRefType,
RevFieldMutType,
RevIntoFieldType,
RevGetField,
RevGetFieldMut,
RevIntoField,
}... | code_fim | hard | {
"lang": "rust",
"repo": "RalfJung/structural_crates",
"path": "/structural/src/field_traits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<This,FieldName> IntoFieldMut<FieldName> for This
where
This:IntoField<FieldName>+GetFieldMut<FieldName>
{}
/// A trait defining the primary way to call methods from structural traits.
pub trait GetFieldExt{
/// Gets a reference to a field,determined by `path`.
///
/// This is named... | code_fim | hard | {
"lang": "rust",
"repo": "RalfJung/structural_crates",
"path": "/structural/src/field_traits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RalfJung/structural_crates path: /structural/src/field_traits.rs
rom 1.40 onwards
/// impl<T> GetField<FP!(v a l u e)> for Huh<T>{
/// type Ty=T;
///
/// fn get_field_(&self)->&Self::Ty{
/// &self.value
/// }
/// }
///
///
/// ```
///
pub trait GetField<FieldName>:StructuralD... | code_fim | hard | {
"lang": "rust",
"repo": "RalfJung/structural_crates",
"path": "/structural/src/field_traits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let s = TestInnerStruct::from_hlist(hlist!(1u8, 2u8));
assert_eq!(s.f1, 1u8);
assert_eq!(s.f2, 2u8);
let hlist0 = s.to_hlist();
assert_eq!(hlist0, hlist!(1u8, 2u8));
let hlist1 = s.into_hlist();
assert_eq!(hlist0... | code_fim | hard | {
"lang": "rust",
"repo": "plausiblelabs/hlist-rs",
"path": "/src/hlist.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plausiblelabs/hlist-rs path: /src/hlist.rs
//
// Copyright (c) 2015-2019 Plausible Labs Cooperative, Inc.
// All rights reserved.
//
// This implementation based on List type from:
// https://github.com/epsilonz/shoggoth.rs
//
/// A heterogeneous list that can hold elements of different types... | code_fim | hard | {
"lang": "rust",
"repo": "plausiblelabs/hlist-rs",
"path": "/src/hlist.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<C> linkerd2_retry::NewPolicy<Route> for NewRetry<C> {
type Policy = Retry<C>;
fn new_policy(&self, route: &Route) -> Option<Self::Policy> {
let retries = route.route.retries().cloned()?;
let metrics = self.metrics.get_handle(route.clone());
Some(Retry {
m... | code_fim | hard | {
"lang": "rust",
"repo": "psinghal20/linkerd2-proxy",
"path": "/linkerd/app/core/src/retry.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: psinghal20/linkerd2-proxy path: /linkerd/app/core/src/retry.rs
use super::classify;
use super::dst::Route;
use super::handle_time;
use super::http_metrics::retries::Handle;
use super::transport::tls;
use super::HttpRouteRetry;
use crate::profiles;
use futures::future;
use hyper::body::Payload;
u... | code_fim | hard | {
"lang": "rust",
"repo": "psinghal20/linkerd2-proxy",
"path": "/linkerd/app/core/src/retry.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mes.contains("go.mod") || names.contains("main.go"),
);
tags
}<|fim_prefix|>// repo: ice563102472/coco path: /framework/src/lang/go.rs
use std::collections::{BTreeMap, HashSet};
pub fn light_detect<'a>(n<|fim_middle|>ames: &HashSet<String>) -> BTreeMap<&'a str, bool> {
let mut tags = BTreeMa... | code_fim | medium | {
"lang": "rust",
"repo": "ice563102472/coco",
"path": "/framework/src/lang/go.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ice563102472/coco path: /framework/src/lang/go.rs
use std::collections::{BTreeMap, HashSet};
pub fn light_detect<'a>(n<|fim_suffix|>= BTreeMap::new();
tags.insert(
"workspace.go",
names.contains("go.mod") || names.contains("main.go"),
);
tags
}<|fim_middle|>ames: &Ha... | code_fim | medium | {
"lang": "rust",
"repo": "ice563102472/coco",
"path": "/framework/src/lang/go.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pombredanne/spdx-rs path: /src/external_document_reference.rs
// SPDX-FileCopyrightText: 2020-2021 HH Partners
//
// SPDX-License-Identifier: MIT
<|fim_suffix|> /// Checksum of the external document following the checksum format defined
/// in https://spdx.github.io/spdx-spec/4-file-info... | code_fim | hard | {
"lang": "rust",
"repo": "pombredanne/spdx-rs",
"path": "/src/external_document_reference.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Unique ID for the external document.
#[serde(rename = "spdxDocument")]
pub spdx_document_uri: String,
/// Checksum of the external document following the checksum format defined
/// in https://spdx.github.io/spdx-spec/4-file-information/#44-file-checksum.
pub checksum: Checksu... | code_fim | hard | {
"lang": "rust",
"repo": "pombredanne/spdx-rs",
"path": "/src/external_document_reference.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn trigger_hook(&self, hook: String, data: Value) -> BaseMessage {
BaseMessage::TriggerHookRequest {
request_id: self.generate_request_id(),
hook,
data,
}
}
pub fn declare_function(&self, function: String) -> BaseMessage {
BaseMessage::DeclareFunctionRequest {
request_id: self.ge... | code_fim | hard | {
"lang": "rust",
"repo": "bytesonus/juno-rust",
"path": "/src/protocol/base_protocol.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytesonus/juno-rust path: /src/protocol/base_protocol.rs
use crate::{
connection::Buffer,
models::{BaseMessage, Value},
protocol::json_protocol,
};
use std::{
collections::HashMap,
time::{SystemTime, UNIX_EPOCH},
};
pub enum BaseProtocol {
JsonProtocol { module_id: String, buffer: Vec<u8... | code_fim | hard | {
"lang": "rust",
"repo": "bytesonus/juno-rust",
"path": "/src/protocol/base_protocol.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn encode(&self, req: BaseMessage) -> Buffer {
match self {
BaseProtocol::JsonProtocol { .. } => json_protocol::encode(&self, req),
_ => panic!("Currently, only JsonProtocol is supported"),
}
}
pub fn decode(&self, data: Buffer) -> BaseMessage {
match self {
BaseProtocol::JsonProtoc... | code_fim | hard | {
"lang": "rust",
"repo": "bytesonus/juno-rust",
"path": "/src/protocol/base_protocol.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: borderless-superuser/agora path: /lnd-test-context/src/executables.rs
use cradle::*;
use hex_literal::hex;
use lazy_static::lazy_static;
use pretty_assertions::assert_eq;
use sha2::{Digest, Sha256};
use std::{
env::{self, consts::EXE_SUFFIX},
fs,
io::{self, Write},
path::{Path, PathBuf},... | code_fim | hard | {
"lang": "rust",
"repo": "borderless-superuser/agora",
"path": "/lnd-test-context/src/executables.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn lnd_executables() -> (PathBuf, PathBuf) {
let lnd_itest_filename = format!("lnd-itest{}", EXE_SUFFIX);
let lncli_debug_filename = format!("lncli-debug{}", EXE_SUFFIX);
let lnd_itest = target_dir().join(&lnd_itest_filename);
let lncli_debug = target_dir().join(&lncli_debug_filename);
sta... | code_fim | hard | {
"lang": "rust",
"repo": "borderless-superuser/agora",
"path": "/lnd-test-context/src/executables.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: macpp/impl_inheritance path: /impl_inheritance_macros/src/expand_inherites.rs
use proc_macro2::TokenStream as TokenStream2;
use proc_macro2::{Ident,Span};
use syn::{ItemStruct};
use crate::common::*;
pub(crate) fn expand(item: ItemStruct) -> TokenStream2 {
use syn::Fields::*;
let field... | code_fim | hard | {
"lang": "rust",
"repo": "macpp/impl_inheritance",
"path": "/impl_inheritance_macros/src/expand_inherites.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::impl_inheritance::IsSuperBorrowableTo::get_part(&self.#field_ident)
}
fn super_ref_mut(& mut self) -> & mut T {
::impl_inheritance::IsSuperBorrowableTo::get_part_mut(& mut self.#field_ident)
}
fn super_value(self) -> T {
... | code_fim | hard | {
"lang": "rust",
"repo": "macpp/impl_inheritance",
"path": "/impl_inheritance_macros/src/expand_inherites.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgeisler/gutenberg path: /components/content/src/section.rs
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::result::Result as StdResult;
use tera::{Tera, Context as TeraContext};
use serde::ser::{SerializeStruct, self};
use config::Config;
use front_matter::{SectionFron... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/gutenberg",
"path": "/components/content/src/section.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tmp_dir = tempdir().expect("create temp dir");
let path = tmp_dir.path();
create_dir(&path.join("content")).expect("create content temp dir");
create_dir(&path.join("content").join("posts")).expect("create posts temp dir");
let nested_path = path.join("content")... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/gutenberg",
"path": "/components/content/src/section.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// If the current thread is a Rayon worker thread, then the callback
/// is invoked with a reference to the worker-thread the result of
/// that callback is returned with `Some`. Otherwise, if we are not on
/// a Rayon worker thread, `None` is immediately returned.
pub fn if_in_worker_thread<F,R>(if_true... | code_fim | medium | {
"lang": "rust",
"repo": "Zoxc/rayon",
"path": "/rayon-core/src/internal/worker.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Zoxc/rayon path: /rayon-core/src/internal/worker.rs
use std::fmt;
use latch::LatchProbe;
use registry;
/// Represents the active worker thread.
pub struct WorkerThread<'w> {
thread: &'w registry::WorkerThread
}
<|fim_suffix|> fmt.debug_struct("WorkerThread")
.field("pool... | code_fim | medium | {
"lang": "rust",
"repo": "Zoxc/rayon",
"path": "/rayon-core/src/internal/worker.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fluffypony/tari path: /base_layer/wallet/src/lib.rs
#![recursion_limit = "1024"]
#![feature(drain_filter)]
#![feature(type_alias_impl_trait)]
#[macro_use]
mod macros;
pub mod contacts_service;
pub mod error;
pub mod output_manager_service;
pub mod storage;
pub mod transaction_service;
pub mod t... | code_fim | medium | {
"lang": "rust",
"repo": "fluffypony/tari",
"path": "/base_layer/wallet/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use wallet::Wallet;
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate diesel_migrations;
#[macro_use]
extern crate lazy_static;
pub mod schema;
// pub mod text_message_service;<|fim_prefix|>// repo: fluffypony/tari path: /base_layer/wallet/src/lib.rs
#![recursion_limit = "1024"]
#![featur... | code_fim | hard | {
"lang": "rust",
"repo": "fluffypony/tari",
"path": "/base_layer/wallet/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: afnanenayet/rustchain path: /src/transaction.rs
/// # transaction
/// A struct that represents a transaction. It has fields for
/// a sender, recipient, and an amount indicating how much the
/// transaction was for
use std::hash::{Hash, Hasher};
#[derive(Debug, Clone, Serialize, Deserialize)]
... | code_fim | medium | {
"lang": "rust",
"repo": "afnanenayet/rustchain",
"path": "/src/transaction.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Transaction {
pub sender: String,
pub recipient: String,
pub amount: f64,
}
// Manually implement because float can't be hashed
impl Hash for Transaction {
fn hash<H: Hasher>(&self, state: &mut H) {
self.sender.hash(state)... | code_fim | medium | {
"lang": "rust",
"repo": "afnanenayet/rustchain",
"path": "/src/transaction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emrecelikten/adventofcode2020 path: /d9/src/main.rs
use std::str::FromStr;
fn load_data(filename: &str) -> Vec<String> {
std::fs::read_to_string(filename)
.unwrap()
.split("\n")
.filter_map(|e| if e.is_empty() { None } else { Some(e.to_owned()) })
.collect()
... | code_fim | hard | {
"lang": "rust",
"repo": "emrecelikten/adventofcode2020",
"path": "/d9/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_find_weakness() {
let data: Vec<&str> = DATA.split("\n").collect();
let vec = parse_data(&data);
let invalid = 127;
let result = find_weakness(&vec, invalid);
assert_eq!(result, 62);
}
}<|fim_prefix|>// repo: emrecelikten/adventofcode2020... | code_fim | hard | {
"lang": "rust",
"repo": "emrecelikten/adventofcode2020",
"path": "/d9/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = 3;
let expected = 5;
assert_eq!(Solution::num_trees(input), expected);
}
#[test]
fn test_4() {
let input = 5;
let expected = 42;
assert_eq!(Solution::num_trees(input), expected);
}
}<|fim_prefix|>// repo: hhwyt/leetcode-rs path:... | code_fim | hard | {
"lang": "rust",
"repo": "hhwyt/leetcode-rs",
"path": "/00096.UniqueBinarySearchTrees-Recursive.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hhwyt/leetcode-rs path: /00096.UniqueBinarySearchTrees-Recursive.rs
struct Solution;
// Ω(2^n) ~ O(n * n!)
impl Solution {
pub fn num_trees(n: i32) -> i32 {
if n <= 1 {
return 1;
}
let mut res = 0;
for i in 1..=n {
res += Self::num_t... | code_fim | medium | {
"lang": "rust",
"repo": "hhwyt/leetcode-rs",
"path": "/00096.UniqueBinarySearchTrees-Recursive.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_4() {
let input = 5;
let expected = 42;
assert_eq!(Solution::num_trees(input), expected);
}
}<|fim_prefix|>// repo: hhwyt/leetcode-rs path: /00096.UniqueBinarySearchTrees-Recursive.rs
struct Solution;
// Ω(2^n) ~ O(n * n!)
impl Solution {
pub fn n... | code_fim | hard | {
"lang": "rust",
"repo": "hhwyt/leetcode-rs",
"path": "/00096.UniqueBinarySearchTrees-Recursive.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>de: KeyCode::Enter , ..} => UserCommand::ChooseSite,
Key {printable: 'r' , ..} => UserCommand::RegenMap,
Key {printable: 'c' , ..} => UserCommand::CreateRiver,
_ => handle_input(root),
}
}
else {
UserCommand::Noop
}
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "Pranz/Emperust",
"path": "/src/input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pranz/Emperust path: /src/input.rs
use tcod::console::Root;
use tcod::input::{Key, KeyCode};
use direction::Direction;
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum UserCommand {
Noop,
Exit,
Move(Direction, bool),
RegenMap,
CreateRiver,
ChooseSite,
}
pub fn handle_in... | code_fim | hard | {
"lang": "rust",
"repo": "Pranz/Emperust",
"path": "/src/input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn arbitrary_list() -> Box<dyn Fn(&mut Gen) -> Ipld> {
Box::new(move |g: &mut Gen| {
let mut rng = rand::thread_rng();
let size = rng.gen_range(0..5);
Ipld::List((0..size).map(|_| Arbitrary::arbitrary(g)).collect())
})
}
pub fn arbitrary_stringmap() -> Box<dyn Fn(&mut ... | code_fim | hard | {
"lang": "rust",
"repo": "nothingnesses/yatima",
"path": "/sp_ipld/src/ipld.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nothingnesses/yatima path: /sp_ipld/src/ipld.rs
use cid::Cid;
use sp_std::{
self,
collections::btree_map::BTreeMap,
vec::Vec,
};
#[derive(Clone, PartialEq)]
pub enum Ipld {
/// Represents the absence of a value or the value undefined.
Null,
/// Represents a boolean value.
Bool(boo... | code_fim | hard | {
"lang": "rust",
"repo": "nothingnesses/yatima",
"path": "/sp_ipld/src/ipld.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-search=native={}",lib_base);
println!("cargo:rustc-link-lib=static={}",lib_name);
extern_lib.iter().for_each(|lib|println!("cargo:rustc-link-lib=static={}",lib));
}<|fim_prefix|>// repo: segfo/yarust path: ... | code_fim | hard | {
"lang": "rust",
"repo": "segfo/yarust",
"path": "/build.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.