text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>pub trait ValidateSeqRange<'a,F:?Sized, R,Idx:?Sized>
{
fn validate_seq_range(&'a self, field: &F, range: &R) -> Result<(), error::ValidatorError>;
}
pub trait ValidateLength<F:?Sized, R,Idx:?Sized>
{
fn validate_length(&self, field: &F, range: &R) -> Result<(), error::ValidatorError>;
}<|fim_pre... | code_fim | hard | {
"lang": "rust",
"repo": "zzhengzhuo/zisvalidator",
"path": "/zisvalidator/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub trait ValidateSeqRange<'a,F:?Sized, R,Idx:?Sized>
{
fn validate_seq_range(&'a self, field: &F, range: &R) -> Result<(), error::ValidatorError>;
}
pub trait ValidateLength<F:?Sized, R,Idx:?Sized>
{
fn validate_length(&self, field: &F, range: &R) -> Result<(), error::ValidatorError>;
}<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "zzhengzhuo/zisvalidator",
"path": "/zisvalidator/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mzabaluev/jormungandr path: /testing/jormungandr-integration-tests/src/common/jormungandr/process.rs
use super::{logger::JormungandrLogger, rest, JormungandrError, JormungandrRest};
use crate::common::configuration::{JormungandrParams, TestConfig};
use crate::common::explorer::Explorer;
use crat... | code_fim | hard | {
"lang": "rust",
"repo": "mzabaluev/jormungandr",
"path": "/testing/jormungandr-integration-tests/src/common/jormungandr/process.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let docs = self.rest().stats().unwrap();
docs.stats
.expect("no stats object in response")
.last_block_height
.expect("last_block_height field is missing")
.parse()
.unwrap()
}
fn log_stats(&self) {
println!("{:?}... | code_fim | hard | {
"lang": "rust",
"repo": "mzabaluev/jormungandr",
"path": "/testing/jormungandr-integration-tests/src/common/jormungandr/process.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SyncNode for JormungandrProcess {
fn alias(&self) -> &str {
self.alias()
}
fn last_block_height(&self) -> u32 {
let docs = self.rest().stats().unwrap();
docs.stats
.expect("no stats object in response")
.last_block_height
.expec... | code_fim | hard | {
"lang": "rust",
"repo": "mzabaluev/jormungandr",
"path": "/testing/jormungandr-integration-tests/src/common/jormungandr/process.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(_) = image.open().read_to_end(&mut image_bytes) {
let mut generator = Generator::default();
let name = generator.next().unwrap();
if let Ok(image_path) = images::store_image(name.clone(), image_bytes) {
let _ = images::insert_image_location(name, ima... | code_fim | medium | {
"lang": "rust",
"repo": "Fittings/fittings-site",
"path": "/fittings-server/src/standard/rest/image_loader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if user.username != "cmilsom" { return Err(Status::InternalServerError); }
let mut image_bytes: Vec<u8> = Vec::new();
if let Ok(_) = image.open().read_to_end(&mut image_bytes) {
let mut generator = Generator::default();
let name = generator.next().unwrap();
i... | code_fim | hard | {
"lang": "rust",
"repo": "Fittings/fittings-site",
"path": "/fittings-server/src/standard/rest/image_loader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fittings/fittings-site path: /fittings-server/src/standard/rest/image_loader.rs
use rocket::{Data, Rocket};
use std::io::Read;
use std::fs::File;
use names::Generator;
use fittings_data::images;
use rocket::http::Status;
use standard::rest::authentication::RocketUser;
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "Fittings/fittings-site",
"path": "/fittings-server/src/standard/rest/image_loader.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/molecule.rs path: /src/atom.rs
use crate::spec;
use crate::element::Element;
use crate::bond::Bond;
use crate::error::Error;
use crate::bond_order::BondOrder;
use crate::parity::Parity;
/// Exposes methods to be accessed privately by DefaultMolecule.
pub struct Atom {
element: Eleme... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/molecule.rs",
"path": "/src/atom.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(atom.charge(), 1);
}
#[test]
fn charge_given_methyl_anion() {
let atom = Atom::build(spec::Atom {
element: Element::C, hydrogens: 3, ion: -1, isotope: None,
parity: None
}).unwrap();
assert_eq!(atom.charge(), -1);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/molecule.rs",
"path": "/src/atom.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>able, LPM token will get a handshake response (ACK, STALL, NYET or NAK) A STALL will be sent if the bLinkState is not 0001b A NYET, NAK or ACK response will be sent depending on the NYET_EN and LPM_ACK_RESP bits below"]
#[inline(always)]
pub fn lpm_en(&self) -> LPM_EN_R {
LPM_EN_R::new((se... | code_fim | hard | {
"lang": "rust",
"repo": "mvertescher/psoc6-pac",
"path": "/src/usbfs0/usblpm/lpm_ctl.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvertescher/psoc6-pac path: /src/usbfs0/usblpm/lpm_ctl.rs
#[doc = "Reader of register LPM_CTL"]
pub type R = crate::R<u32, super::LPM_CTL>;
#[doc = "Writer for register LPM_CTL"]
pub type W = crate::W<u32, super::LPM_CTL>;
#[doc = "Register LPM_CTL `reset()`'s with value 0"]
impl crate::ResetVal... | code_fim | hard | {
"lang": "rust",
"repo": "mvertescher/psoc6-pac",
"path": "/src/usbfs0/usblpm/lpm_ctl.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rainysaturday/adventofcode2018 path: /dec16/src/main.rs
extern crate regex;
use regex::Regex;
use std::cmp;
use std::collections::{HashSet, HashMap};
type Imm = i32;
type Reg = usize;
#[derive(Debug)]
struct Sample {
before: [Imm; 4],
insn: [Imm; 4],
after: [Imm; 4],
}
impl Sample... | code_fim | hard | {
"lang": "rust",
"repo": "rainysaturday/adventofcode2018",
"path": "/dec16/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Lets run all the instructions
let mut registers: [Imm; 4] = [0, 0, 0, 0];
for raw_insn in raw_insns {
let insn = parse_insn(*opcode_to_insn_order.get(&raw_insn[0]).unwrap(), raw_insn);
execute(insn, &mut registers);
}
println!("Part2: register 0 contains {}", registe... | code_fim | hard | {
"lang": "rust",
"repo": "rainysaturday/adventofcode2018",
"path": "/dec16/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nzentzis/ysh path: /src/library/mod.rs
pub mod core;
mod operators;
mod sequence;
mod async;
mod filesystem;
mod builtins;
mod io;
fn run_string(s: &'static str) {
use std::io::Cursor;
use data::ValueLike;
use stream::ReadWrapper;
use reader::ParseError;
let mut cursor = C... | code_fim | hard | {
"lang": "rust",
"repo": "nzentzis/ysh",
"path": "/src/library/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> builtins::initialize();
operators::initialize();
sequence::initialize();
async::initialize();
filesystem::initialize();
io::initialize();
// initialize core Lisp library
let lib_sources = include_str!("init.ysh");
run_string(lib_sources);
}<|fim_prefix|>// repo: nzentz... | code_fim | hard | {
"lang": "rust",
"repo": "nzentzis/ysh",
"path": "/src/library/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// HDC2080, HDC2021 and HDC2010 device driver
#[derive(Debug)]
pub struct Hdc20xx<I2C, MODE> {
i2c: I2C,
address: u8,
meas_config: Config,
was_measurement_started: bool,
_mode: PhantomData<MODE>,
}
#[derive(Debug, Default, Clone, Copy)]
struct Config {
bits: u8,
}
/// Mode marke... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/hdc20xx-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eldruin/hdc20xx-rs path: /src/lib.rs
//! This is a platform agnostic Rust driver for the HDC2080, HDC2021 and
//! HDC2010 low-power humidity and temperature digital sensor using
//! the [`embedded-hal`] traits.
//!
//! [`embedded-hal`]: https://github.com/rust-embedded/embedded-hal
//!
//! This ... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/hdc20xx-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> builder_state.salary_cap = Some(contest.salary_cap);
builder_state.roster_slots = Some(contest.slots);
}<|fim_prefix|>// repo: jsmall53/lineup_builder_rs path: /builder/src/contest_reader.rs
use std::fs::{ File };
use std::io::{ BufReader, Read };
use serde::{ Deserialize, Serialize };
use crate... | code_fim | hard | {
"lang": "rust",
"repo": "jsmall53/lineup_builder_rs",
"path": "/builder/src/contest_reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jsmall53/lineup_builder_rs path: /builder/src/contest_reader.rs
use std::fs::{ File };
use std::io::{ BufReader, Read };
use serde::{ Deserialize, Serialize };
use crate::common::{ BuilderState, RosterSlot };
<|fim_suffix|>pub fn load_contest(file_path: &str, builder_state: &mut BuilderState) ... | code_fim | hard | {
"lang": "rust",
"repo": "jsmall53/lineup_builder_rs",
"path": "/builder/src/contest_reader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if online {
let _res = conn.exec_drop(
"UPDATE stars SET status = True WHERE point_name = :star_name",
params! {
"star_name" => &star[..],
},
).unwrap();
println!("pinged {} successfully", star);
} else {
let _res ... | code_fim | hard | {
"lang": "rust",
"repo": "hdzdwlrs/urbit-star-pinger",
"path": "/pinger/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("will ping stars: {:#?}", stars_to_ping);
let star_count = stars_to_ping.len();
// main program loop
// sleep time is calculated by amount of stars in pinging pool
// designed to go through whole pool each hour
let sleep_time = time::Duration::from_secs((3600 / star_c... | code_fim | hard | {
"lang": "rust",
"repo": "hdzdwlrs/urbit-star-pinger",
"path": "/pinger/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hdzdwlrs/urbit-star-pinger path: /pinger/src/main.rs
use std::process::Command;
use std::{thread, time};
use rand::Rng;
use mysql::*;
use mysql::prelude::*;
use std::convert::TryInto;
fn main() {
let mut stars_to_ping: Vec<String> = Vec::new();
let mut pinged_stars: Vec<String> = Vec::n... | code_fim | hard | {
"lang": "rust",
"repo": "hdzdwlrs/urbit-star-pinger",
"path": "/pinger/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: z1queue/smartcore path: /src/api.rs
//! # Common Interfaces and API
//!
//! This module provides interfaces and uniform API with simple conventions
//! that are used in other modules for supervised and unsupervised learning.
use crate::error::Failed;
<|fim_suffix|> where
Self: Sized... | code_fim | hard | {
"lang": "rust",
"repo": "z1queue/smartcore",
"path": "/src/api.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Implements method transform that filters or modifies input data
pub trait Transformer<X> {
/// Transform data by modifying or filtering it
/// * `x` - _NxM_ matrix with _N_ observations and _M_ features in each observation.
fn transform(&self, x: &X) -> Result<X, Failed>;
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "z1queue/smartcore",
"path": "/src/api.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// Implements method transform that filters or modifies input data
pub trait Transformer<X> {
/// Transform data by modifying or filtering it
/// * `x` - _NxM_ matrix with _N_ observations and _M_ features in each observation.
fn transform(&self, x: &X) -> Result<X, Failed>;
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "z1queue/smartcore",
"path": "/src/api.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut c = FnCache::new();
for f in fns {
c.insert(f.0.as_str(), f.1);
}
c
}
}
impl<'a> FromIterator<(&'a str, i64)> for FnCache {
fn from_iter<T: IntoIterator<Item = (&'a str, i64)>>(fns: T) -> Self {
let mut c = FnCache::new();
for f ... | code_fim | hard | {
"lang": "rust",
"repo": "cave-dev/fn-search-backend",
"path": "/web/src/collections/fn_cache.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cave-dev/fn-search-backend path: /web/src/collections/fn_cache.rs
use fn_search_backend_db::models::Function;
use radix_trie::{Trie, TrieCommon};
use std::iter::FromIterator;
pub struct FnCache {
trie: Trie<String, Vec<i64>>,
}
impl FnCache {
fn new() -> Self {
FnCache { trie: ... | code_fim | hard | {
"lang": "rust",
"repo": "cave-dev/fn-search-backend",
"path": "/web/src/collections/fn_cache.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn origin(&self) -> V3 {
self.origin.clone()
}
fn aabb(&self) -> Option<AABB> {
// Find the bounding box for a sphere
Some(AABB::from_min_max(self.origin - self.radius, self.origin + self.radius))
}
}<|fim_prefix|>// repo: deadalusai/raytracer path: /raytracer-imp... | code_fim | hard | {
"lang": "rust",
"repo": "deadalusai/raytracer",
"path": "/raytracer-impl/src/shapes/sphere.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deadalusai/raytracer path: /raytracer-impl/src/shapes/sphere.rs
use crate::types::{ V2, V3, Ray };
use crate::implementation::{ Hitable, HitRecord, AABB, MatId, TexId };
fn intersect_sphere(ray: &Ray, origin: V3, radius: f32) -> Option<[f32; 2]> {
let oc = ray.origin - origin;
let a = V... | code_fim | hard | {
"lang": "rust",
"repo": "deadalusai/raytracer",
"path": "/raytracer-impl/src/shapes/sphere.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: npmccallum/x86_64_types path: /src/registers.rs
use bitflags::bitflags;
bitflags! {
/// Configuration flags of the Cr0 register.
#[derive(Default)]
pub struct Cr0: u64 {
/// Enables protected mode.
const PROTECTED_MODE_ENABLE = 1 << 0;
/// Enables monitoring... | code_fim | hard | {
"lang": "rust",
"repo": "npmccallum/x86_64_types",
"path": "/src/registers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Change page table layout to enables 36-bit physical addresses.
const PHYSICAL_ADDRESS_EXTENSION = 1 << 5;
/// Enables machine check interrupts to occur.
const MACHINE_CHECK_EXTENSION = 1 << 6;
/// Address translations (PDE or PTE records) may be shared between... | code_fim | hard | {
"lang": "rust",
"repo": "npmccallum/x86_64_types",
"path": "/src/registers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Determines the order in which strings are processed.
const DIRECTION_FLAG = 1 << 10;
/// Enable interrupts.
const INTERRUPT_FLAG = 1 << 9;
/// Enable single-step mode for debugging.
const TRAP_FLAG = 1 << 8;
/// Set by hardware if last arithme... | code_fim | hard | {
"lang": "rust",
"repo": "npmccallum/x86_64_types",
"path": "/src/registers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// @dev Stores the sent amount as credit to be withdrawn.
/// @param payee The destination address of the funds.
fn deposit(&mut self, payee: E::AccountId) {
self.ensure_caller_is_owner();
let amount = Self::transferred_balance();
Storage::<E, Data<E>>::get_mut(self)... | code_fim | hard | {
"lang": "rust",
"repo": "bcdevorg/metis",
"path": "/crates/components/utils/escrow/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bcdevorg/metis path: /crates/components/utils/escrow/src/lib.rs
//! Escrow
//! Base escrow contract, holds funds designated for a payee until they
//! withdraw them.
//!
//! Intended usage: This contract (and derived escrow contracts) should be a
//! standalone contract, that only interacts with... | code_fim | hard | {
"lang": "rust",
"repo": "bcdevorg/metis",
"path": "/crates/components/utils/escrow/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.ensure_caller_is_owner();
let payment = Storage::<E, Data<E>>::get(self).get(&payee);
Storage::<E, Data<E>>::get_mut(self).clean(&payee);
let res = Self::transfer(payee.clone(), payment);
assert!(res.is_ok(), "Escrow: transfer to payee error");
self... | code_fim | hard | {
"lang": "rust",
"repo": "bcdevorg/metis",
"path": "/crates/components/utils/escrow/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, (mut position, velocity): Self::SystemData) {
for (position, velocity) in (&mut position, &velocity).join() {
position.vector += velocity.vector;
}
}
}<|fim_prefix|>// repo: tglanz/soez path: /soez_game/src/systems/speed.rs
use specs::prelude::*;
use... | code_fim | medium | {
"lang": "rust",
"repo": "tglanz/soez",
"path": "/soez_game/src/systems/speed.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tglanz/soez path: /soez_game/src/systems/speed.rs
use specs::prelude::*;
use crate::components::*;
<|fim_suffix|> fn run(&mut self, (mut position, velocity): Self::SystemData) {
for (position, velocity) in (&mut position, &velocity).join() {
position.vector += velocity.v... | code_fim | medium | {
"lang": "rust",
"repo": "tglanz/soez",
"path": "/soez_game/src/systems/speed.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn foo(remote: Remote, url: &str) {
let url = url.to_owned();
println!("hi");
remote.spawn(move |h| {
let (c, p) = oneshot::<()>(); // just need to know when the value's in the cache
VALUE_CACHE.with::<_, ()>(|value_cache| {
let mut value_cache = value_cache.borrow_... | code_fim | hard | {
"lang": "rust",
"repo": "donhcd/tokio_test",
"path": "/src/foo/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: donhcd/tokio_test path: /src/foo/main.rs
extern crate curl;
extern crate futures;
#[macro_use]
extern crate lazy_static;
extern crate tokio_core;
extern crate tokio_curl;
use std::cell::RefCell;
use std::collections::HashMap;
use std::io::{self, Write};
use std::io::stdout;
use std::ops::DerefM... | code_fim | hard | {
"lang": "rust",
"repo": "donhcd/tokio_test",
"path": "/src/foo/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let url = url.to_owned();
println!("hi");
remote.spawn(move |h| {
let (c, p) = oneshot::<()>(); // just need to know when the value's in the cache
VALUE_CACHE.with::<_, ()>(|value_cache| {
let mut value_cache = value_cache.borrow_mut();
println!("what's ... | code_fim | hard | {
"lang": "rust",
"repo": "donhcd/tokio_test",
"path": "/src/foo/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wotsushi/competitive-programming path: /agc/001/a.rs
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]
<|fim_suffix|> let N: usize = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse().un... | code_fim | medium | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/agc/001/a.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let N: usize = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse().unwrap()
};
let L: Vec<usize> = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
lin... | code_fim | medium | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/agc/001/a.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let R = {
let mut R = L.clone();
R.sort();
R
};
let ans = (0..N).map(|i| R[2 * i]).sum::<usize>();
println!("{}", ans);
}<|fim_prefix|>// repo: wotsushi/competitive-programming path: /agc/001/a.rs
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead... | code_fim | hard | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/agc/001/a.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FierySwampshire/sessions path: /sessions-core/src/session.rs
use std::{
fmt,
sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Arc, RwLock, RwLockReadGuard, RwLockWriteGuard,
},
time::Duration,
};
use crate::{
anyhow,
data::{from_value, to_value, Deser... | code_fim | hard | {
"lang": "rust",
"repo": "FierySwampshire/sessions",
"path": "/sessions-core/src/session.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Writes the session state
pub fn set_data(&self, data: Data) -> Result<()> {
self.beer_mut()?.data = data;
Ok(())
}
/// Gets the session id
pub fn id(&self) -> Result<String> {
Ok(self.beer()?.id.clone())
}
/// Gets the session id
pub fn set_id(... | code_fim | hard | {
"lang": "rust",
"repo": "FierySwampshire/sessions",
"path": "/sessions-core/src/session.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>b use super::song_key::SongKey;
pub use super::sound_key::SoundKey;
pub use super::zone_progression_mode::ZoneProgressionMode;
pub use super::zone_size::ZoneSize;
pub use super::zones_manager::ZonesManager;
pub use deathframe::resources::prelude::*;
}
mod animation_key;
mod collision_... | code_fim | hard | {
"lang": "rust",
"repo": "graves501/LD48-DriftDown",
"path": "/src/resources/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: graves501/LD48-DriftDown path: /src/resources/mod.rs
pub mod prelude {
pub use super::animation_key::AnimationKey;
pub use super::collision_tag::{CollisionTag, SolidTag};
pub use super::dispatcher_id::DispatcherId;
pub use super::game_over::GameOver;
pub use super::lanes::{La... | code_fim | hard | {
"lang": "rust",
"repo": "graves501/LD48-DriftDown",
"path": "/src/resources/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: habitat-sh/builder path: /components/builder-worker/src/error.rs
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtai... | code_fim | hard | {
"lang": "rust",
"repo": "habitat-sh/builder",
"path": "/components/builder-worker/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<bldr_core::Error> for Error {
fn from(err: bldr_core::Error) -> Error { Error::BuilderCore(err) }
}
impl From<hab_core::Error> for Error {
fn from(err: hab_core::Error) -> Error { Error::HabitatCore(err) }
}
impl From<github_api_client::HubError> for Error {
fn from(err: github_api... | code_fim | hard | {
"lang": "rust",
"repo": "habitat-sh/builder",
"path": "/components/builder-worker/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.memory_limit = Some(limit);
self
}
#[inline]
fn time_limit(mut self, limit: Duration) -> Self {
self.time_limit = Some(limit);
self
}
#[inline]
fn strict_errors(mu... | code_fim | hard | {
"lang": "rust",
"repo": "dylni/process_control",
"path": "/src/control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dylni/process_control path: /src/control.rs
use std::io;
use std::io::Read;
use std::panic;
use std::process::Child;
use std::thread;
use std::thread::JoinHandle;
use std::time::Duration;
use super::imp;
use super::Control;
use super::ExitStatus;
use super::Output;
use super::WaitResult;
macro... | code_fim | hard | {
"lang": "rust",
"repo": "dylni/process_control",
"path": "/src/control.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = ActivitySecrets {
join: Some("a".to_owned()),
match_: Some("b".to_owned()),
spectate: Some("c".to_owned()),
};
serde_test::assert_tokens(
&value,
&[
Token::Struct {
name: "A... | code_fim | hard | {
"lang": "rust",
"repo": "SuperiorJT/twilight",
"path": "/model/src/gateway/presence/activity_secrets.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SuperiorJT/twilight path: /model/src/gateway/presence/activity_secrets.rs
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ActivitySecrets {
#[serde(skip_serializing_if = "Option::is_none")]
pub join: Option<String>,
... | code_fim | hard | {
"lang": "rust",
"repo": "SuperiorJT/twilight",
"path": "/model/src/gateway/presence/activity_secrets.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> return true;
}
let mut ans = 0;
for word2 in words {
if is_subseq(&word2, &s) {
ans += 1;
}
}
ans
}
}
// @lc code=end<|fim_prefix|>// repo: fujiehuang/leetcode-rust path: /792.number-of-matching-subsequences... | code_fim | hard | {
"lang": "rust",
"repo": "fujiehuang/leetcode-rust",
"path": "/792.number-of-matching-subsequences.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some(ch1) = iter1.next() {
loop {
if let Some(ch2) = iter2.next() {
if ch1 == ch2 { break; }
} else {
return false;
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "fujiehuang/leetcode-rust",
"path": "/792.number-of-matching-subsequences.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fujiehuang/leetcode-rust path: /792.number-of-matching-subsequences.rs
/*
* @lc app=leetcode id=792 lang=rust
*
* [792] Number of Matching Subsequences
*/
// @lc code=start
impl Solution {
pub fn num_matching_subseq(s: String, words: Vec<String>) -> i32 {
fn is_subseq(word1: &st... | code_fim | hard | {
"lang": "rust",
"repo": "fujiehuang/leetcode-rust",
"path": "/792.number-of-matching-subsequences.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<Line> for (Point, Point) {
fn from(line: Line) -> (Point, Point) {
(line.start, line.end)
}
}
impl From<(Scalar, Scalar, Scalar, Scalar)> for Line {
fn from((ax, ay, bx, by): (Scalar, Scalar, Scalar, Scalar)) -> Line {
Line {
start: (ax, ay).into(),
... | code_fim | hard | {
"lang": "rust",
"repo": "PistonDevelopers/shapes",
"path": "/src/line.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PistonDevelopers/shapes path: /src/line.rs
use graphics::types;
use graphics::math::Scalar;
use Point;
/// A line.
#[derive(Copy, Clone, Debug)]
pub struct Line {
/// Start point.
pub start: Point,
/// End point.
pub end: Point,
}
impl From<Line> for types::Line {
fn from... | code_fim | hard | {
"lang": "rust",
"repo": "PistonDevelopers/shapes",
"path": "/src/line.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ExpressionType for Infix{}
impl ExpressionType for Postfix{}
impl ExpressionType for Prefix{}<|fim_prefix|>// repo: jmriesen/calculator path: /src/expression/internal_types.rs
#[derive(Clone,Copy)]
pub struct Infix;
#[derive(Clone,Copy)]
pub struct Postfix;
#[derive(Clone,Copy)]
pub struct Prefix;
... | code_fim | medium | {
"lang": "rust",
"repo": "jmriesen/calculator",
"path": "/src/expression/internal_types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmriesen/calculator path: /src/expression/internal_types.rs
#[derive(Clone,Copy)]
pub struct Infix;
#[derive(Clone,Copy)]
pub struct Postfix;
#[derive(Clone,Copy)]
pub struct Prefix;
<|fim_suffix|>impl ExpressionType for Infix{}
impl ExpressionType for Postfix{}
impl ExpressionType for Prefix{}... | code_fim | medium | {
"lang": "rust",
"repo": "jmriesen/calculator",
"path": "/src/expression/internal_types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tpayne84/proxide path: /src/main.rs
#![allow(clippy::match_bool)]
use clap::ArgMatches;
use crossterm::{
cursor,
terminal::{Clear, ClearType},
ExecutableCommand,
};
use log::error;
use snafu::{ResultExt, Snafu};
use std::fs::File;
use std::io::stdout;
use std::io::Read;
use std::net... | code_fim | hard | {
"lang": "rust",
"repo": "tpayne84/proxide",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let target_server = args.value_of("target").map(ToString::to_string);
let mut proxy = match args.value_of("proxy") {
Some(p) => Some(ProxyFilter::parse(p)?),
None => None,
};
if target_server.is_none() && proxy.is_none() {
proxy = Some(v... | code_fim | hard | {
"lang": "rust",
"repo": "tpayne84/proxide",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn remapping_models_with_invalid_characters() {
let res = introspect(|db| async move {
db.create_collection("?A", None).await?;
db.create_collection("A b c", None).await?;
Ok(())
});
let expected = expect![[r#"
model A {
id String @id @defaul... | code_fim | hard | {
"lang": "rust",
"repo": "debragail/prisma-engines",
"path": "/introspection-engine/connectors/mongodb-introspection-connector/tests/remapping_names/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/phaddw.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn phaddw_1() {
run_test(&I... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/phaddw.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::PHADDW, operand1: Some(Direct(MM0)), operand2: Some(IndirectScaledIndexed(EAX, EBX, Two, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 56... | code_fim | medium | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/phaddw.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>her::new();
t.hash(&mut s);
s.finish() as u32
}<|fim_prefix|>// repo: denosaurs/pane path: /src/helpers.rs
use std::collections::hash_map::DefaultHasher;
use std::hash::Hash;
use std::hash::Hasher;
pub fn ha<|fim_middle|>sh<T: Hash>(t: T) -> u32 {
let mut s = DefaultHas | code_fim | easy | {
"lang": "rust",
"repo": "denosaurs/pane",
"path": "/src/helpers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: denosaurs/pane path: /src/helpers.rs
use std::collections::hash_map::DefaultHasher;
use<|fim_suffix|>her::new();
t.hash(&mut s);
s.finish() as u32
}<|fim_middle|> std::hash::Hash;
use std::hash::Hasher;
pub fn hash<T: Hash>(t: T) -> u32 {
let mut s = DefaultHas | code_fim | medium | {
"lang": "rust",
"repo": "denosaurs/pane",
"path": "/src/helpers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidpdrsn/gimme-graphql path: /examples/rocket.rs
#![feature(proc_macro_hygiene, decl_macro)]
extern crate rocket;
#[macro_use]
extern crate diesel;
use diesel::prelude::*;
use gimme_graphql::{
rocket_adapter::{
rocket::{
fairing::AdHoc,
http::Status,
... | code_fim | hard | {
"lang": "rust",
"repo": "davidpdrsn/gimme-graphql",
"path": "/examples/rocket.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GraphqlApp for App {
type Adapter = RocketAdapter;
type Connection = PgConnection;
type Query = Query;
type Mutation = Mutation;
type Context = Context;
}
pub struct Context {
pub db_con: PooledConnection<ConnectionManager<PgConnection>>,
}
impl juniper::Context for Context ... | code_fim | hard | {
"lang": "rust",
"repo": "davidpdrsn/gimme-graphql",
"path": "/examples/rocket.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(ID::from(self.id.to_string()))
}
}
#[derive(Default)]
pub struct Mutation;
impl MutationFields for Mutation {
fn field_noop(&self, _: &juniper::Executor<'_, Context>) -> juniper::FieldResult<&bool> {
Ok(&true)
}
}
pub fn main() {
run_graphql_app(App);
}
struct App;
... | code_fim | hard | {
"lang": "rust",
"repo": "davidpdrsn/gimme-graphql",
"path": "/examples/rocket.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skyformat99/nng-rs path: /nng-rs/src/error.rs
use std::ffi::{CStr, NulError};
use std::os::raw::c_int;
use std::{error, fmt, str};
use raw;
/// Representation of an error that can occur within nng
#[derive(Debug)]
pub struct Error {
code: i32,
msg: &'static str,
}
impl Error {
///... | code_fim | medium | {
"lang": "rust",
"repo": "skyformat99/nng-rs",
"path": "/nng-rs/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.message()
}
}
impl From<NulError> for Error {
fn from(_: NulError) -> Error {
Error::new(
raw::nng_errno_enum_NNG_EINVAL as i32,
"provided data contained a nul byte and could not be used as as string",
)
}
}<|fim_prefix|>// repo: skyformat9... | code_fim | hard | {
"lang": "rust",
"repo": "skyformat99/nng-rs",
"path": "/nng-rs/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rpivo/leetcode-answers path: /how-many-numbers-are-smaller-than-the-current-number-2.rs
// implementation Solution
impl Solution {
// public function smaller_numbers_than_current takes in a vector of
// 32-bit integers called nums, and returns a vector of 32-bit integers.
pub fn smal... | code_fim | hard | {
"lang": "rust",
"repo": "rpivo/leetcode-answers",
"path": "/how-many-numbers-are-smaller-than-the-current-number-2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>index.
// set the value of cnts at index num plus 1 equal to the value of
// cnts at index num plus 1, plus 1.
cnts[num as usize + 1] += 1;
}
// loop from 1 to 102.
for i in 1..102 {
// set the value of cnts at index i equal to the va... | code_fim | hard | {
"lang": "rust",
"repo": "rpivo/leetcode-answers",
"path": "/how-many-numbers-are-smaller-than-the-current-number-2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn mk<Q: ?Sized>(&self, x: &Q) -> Consed<T>
where
T: Borrow<Q>, // T can be borrowed as a Q
// e.g. T as String, and Q as str
// It's very important that T and Q have implementations of
// the Hash and Eq traits that produce identical results
Q: ToOwned<... | code_fim | hard | {
"lang": "rust",
"repo": "shayne-fletcher/zen",
"path": "/rust/intern/src/hash_cons/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shayne-fletcher/zen path: /rust/intern/src/hash_cons/mod.rs
// [Type-Safe Modular Hash-Consing](https://www.lri.fr/~filliatr/ftp/publis/hash-consing2.pdf)
#![allow(dead_code)]
use std::borrow::Borrow;
use std::collections::HashMap;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::ops::Deref... | code_fim | hard | {
"lang": "rust",
"repo": "shayne-fletcher/zen",
"path": "/rust/intern/src/hash_cons/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.tag.hash(state);
}
}
#[derive(Clone, PartialEq, Eq)]
pub struct Consed<T>(Rc<ConsedImpl<T>>);
impl<T> Deref for Consed<T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
impl<T: fmt::Debug> fmt::Debug for Consed<T> {
fn fmt(&self, f: &mut fmt::Formatter<... | code_fim | hard | {
"lang": "rust",
"repo": "shayne-fletcher/zen",
"path": "/rust/intern/src/hash_cons/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coreyja/devicon-lookup path: /benches/benchmark_cli.rs
#[macro_use]
extern crate criterion;
use assert_cmd::Command;
use criterion::Criterion;
fn run_cli_plain() {
Command::cargo_bin("devicon-lookup")
.unwrap()
.pipe_stdin("tests/fixtures/all-types-large.txt")
.unwr... | code_fim | medium | {
"lang": "rust",
"repo": "coreyja/devicon-lookup",
"path": "/benches/benchmark_cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("benchmark_each_file_type_plain_cli", |b| {
b.iter(run_cli_plain)
});
c.bench_function("benchmark_each_file_type_color_cli", |b| {
b.iter(run_cli_color)
});
c.bench_function("benchmark_each_file_type_regex_cli", |b| {
b.iter(run_cli_regex)
}... | code_fim | hard | {
"lang": "rust",
"repo": "coreyja/devicon-lookup",
"path": "/benches/benchmark_cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> test "new partition" {
let partition = Partition::new(String::from("tmp"), 0).unwrap();
assert_eq!(partition.partition, 0);
assert_eq!(partition.topic, "tmp");
}
describe "fill segments" {
test "fill segments" {
let m... | code_fim | hard | {
"lang": "rust",
"repo": "fenimore/latka",
"path": "/src/partition.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fenimore/latka path: /src/partition.rs
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_must_use)]
#![allow(unused_variables)]
use std::{io, fs, thread, env};
use std::cmp::{Ord, Ordering, PartialOrd, PartialEq};
use std::fs::{OpenOptions, File};
use std::io::{Seek, SeekFrom, BufRe... | code_fim | hard | {
"lang": "rust",
"repo": "fenimore/latka",
"path": "/src/partition.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> speculate! {
after {
remove_dir_all("tmp/");
}
test "new partition" {
let partition = Partition::new(String::from("tmp"), 0).unwrap();
assert_eq!(partition.partition, 0);
assert_eq!(partition.topic, "tmp");
}
des... | code_fim | hard | {
"lang": "rust",
"repo": "fenimore/latka",
"path": "/src/partition.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(serde::Deserialize)]
#[serde(tag = "kty", rename_all = "UPPERCASE")]
#[non_exhaustive]
pub enum KeyType {
Rsa {
alg: RsaAlg,
#[serde(deserialize_with = "bignum_from_base64")]
n: BigNum,
#[serde(deserialize_with = "bignum_from_base64")]
e: BigNum,
},... | code_fim | hard | {
"lang": "rust",
"repo": "abonander/reqwest-jwk",
"path": "/src/key.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(serde::Deserialize)]
#[non_exhaustive]
pub enum EcAlg {
ES256,
ES384,
ES512
}
impl Key {
/// Convert this `Key` into a type suitable for consumption by the `jwt` crate.
pub fn into_jwt_key(self) -> Result<PKeyWithDigest<Public>, openssl::error::ErrorStack> {
Ok(match ... | code_fim | hard | {
"lang": "rust",
"repo": "abonander/reqwest-jwk",
"path": "/src/key.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abonander/reqwest-jwk path: /src/key.rs
use serde::{Deserializer, Deserialize};
use openssl::bn::BigNum;
use serde::de::Error;
use jwt::PKeyWithDigest;
use openssl::pkey::{Public, PKey};
use openssl::hash::MessageDigest;
use openssl::rsa::Rsa;
use openssl::ec::{EcKey, EcGroup};
use openssl::nid:... | code_fim | hard | {
"lang": "rust",
"repo": "abonander/reqwest-jwk",
"path": "/src/key.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for index in 0..min_size {
let char = &strs
.first()
.unwrap()
.chars()
.nth(index as usize)
.unwrap();
for str in &strs {
if str.chars().nth(index as usize).unwrap() != *char {
return answer;
... | code_fim | hard | {
"lang": "rust",
"repo": "Skrilltrax/DS",
"path": "/leetcode-rs/src/longest_common_prefix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Skrilltrax/DS path: /leetcode-rs/src/longest_common_prefix.rs
#![allow(dead_code)]
pub fn longest_common_prefix(strs: Vec<String>) -> String {
if strs.len() == 0 { return "".to_string(); }
<|fim_suffix|> for index in 0..min_size {
let char = &strs
.first()
... | code_fim | hard | {
"lang": "rust",
"repo": "Skrilltrax/DS",
"path": "/leetcode-rs/src/longest_common_prefix.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::is_palindrome("".to_string()), true);
assert_eq!(Solution::is_palindrome("t".to_string()), true);
assert_eq!(Solution::is_palindrome("tiat".to_string()), false);
assert_eq!(
Solution::is_palindrome("A man, a plan, a canal: Panama".to_string(... | code_fim | hard | {
"lang": "rust",
"repo": "MichaelHe1125/rust-leetcode",
"path": "/src/p0125_valid_palindrome.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MichaelHe1125/rust-leetcode path: /src/p0125_valid_palindrome.rs
// 125. Valid Palindrome
// Easy
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrom... | code_fim | medium | {
"lang": "rust",
"repo": "MichaelHe1125/rust-leetcode",
"path": "/src/p0125_valid_palindrome.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dfontana/serv path: /devup/src/cmd/branch.rs
use crate::errors::*;
use git2::{BranchType, Repository};
use std::env;
use structopt::StructOpt;
#[derive(StructOpt)]
pub struct List {
#[structopt(help = "Optional. Author's Email to filter branches by (otherwise taken from repo)")]
filter: Opt... | code_fim | hard | {
"lang": "rust",
"repo": "dfontana/serv",
"path": "/devup/src/cmd/branch.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_list(list: Vec<BranchOption>) {
list.iter().for_each(|f| {
let location = match f.b_type {
BranchType::Remote => "Remote",
BranchType::Local => "Local",
};
println!("[{:<6}] {}", location, f.b_name)
})
}<|fim_prefix|>// repo: dfontana/serv path: /devup/src/cmd/branch.... | code_fim | hard | {
"lang": "rust",
"repo": "dfontana/serv",
"path": "/devup/src/cmd/branch.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if *factor != 0 && below_num % factor == 0 {
sum += below_num;
break;
}
}
}
sum
}<|fim_prefix|>// repo: RaymarMonte/rust-exercism-solutions path: /sum-of-multiples/src/lib.rs
pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 ... | code_fim | medium | {
"lang": "rust",
"repo": "RaymarMonte/rust-exercism-solutions",
"path": "/sum-of-multiples/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RaymarMonte/rust-exercism-solutions path: /sum-of-multiples/src/lib.rs
pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 {
let mut sum = 0;
for below_num in 1..limit {
for factor in factors {
<|fim_suffix|>= below_num;
break;
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "RaymarMonte/rust-exercism-solutions",
"path": "/sum-of-multiples/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>= below_num;
break;
}
}
}
sum
}<|fim_prefix|>// repo: RaymarMonte/rust-exercism-solutions path: /sum-of-multiples/src/lib.rs
pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 {
let mut sum = 0;
for below_num in 1..limit {
for factor i... | code_fim | medium | {
"lang": "rust",
"repo": "RaymarMonte/rust-exercism-solutions",
"path": "/sum-of-multiples/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(send_len)
}
fn decrypt_recv_buffer(
&self,
recv_buf: &mut [u8],
user_manager: Option<&ServerUserManager>,
) -> ProtocolResult<(usize, Address, Option<UdpSocketControlData>)> {
match self.socket_type {
UdpSocketType::Client => decrypt_serv... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadowsocks/shadowsocks-rust path: /crates/shadowsocks/src/relay/udprelay/proxy_socket.rs
redContext, svr_cfg: &ServerConfig) -> ProxySocketResult<ProxySocket> {
ProxySocket::connect_with_opts(context, svr_cfg, &DEFAULT_CONNECT_OPTS)
.await
.map_err(Into::into)
... | code_fim | hard | {
"lang": "rust",
"repo": "shadowsocks/shadowsocks-rust",
"path": "/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: udsamani/fluvio-helm path: /src/error.rs
use fluvio_command::CommandError;
use std::io::Error as IoError;
use std::string::FromUtf8Error;
#[derive(thiserror::Error, Debug)]
pub enum HelmError {
#[error(
r#"Unable to find 'h<|fim_suffix|>elm client version: {0}")]
HelmVersionNotF... | code_fim | medium | {
"lang": "rust",
"repo": "udsamani/fluvio-helm",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>elm client version: {0}")]
HelmVersionNotFound(String),
#[error("Failed to connect to Kubernetes")]
FailedToConnect,
#[error("Failed to parse helm output as UTF8")]
Utf8Error(#[from] FromUtf8Error),
#[error("Failed to parse JSON from helm output")]
Serde(#[from] serde_json::Err... | code_fim | medium | {
"lang": "rust",
"repo": "udsamani/fluvio-helm",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sile/cannyls path: /src/storage/data_region.rs
use byteorder::{BigEndian, ByteOrder};
use prometrics::metrics::MetricBuilder;
use std::io::{Read, SeekFrom, Write};
use block::{AlignedBytes, BlockSize};
use metrics::DataRegionMetrics;
use nvm::NonVolatileMemory;
use storage::allocator::DataPorti... | code_fim | hard | {
"lang": "rust",
"repo": "sile/cannyls",
"path": "/src/storage/data_region.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.