text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: dcrewi/typenum-prime-rs path: /tests/larger_primes.rs
// test/larger_primes.rs
//
// Copyright (c) 2018 David Creswick
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.or... | code_fim | medium | {
"lang": "rust",
"repo": "dcrewi/typenum-prime-rs",
"path": "/tests/larger_primes.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jjyr/godwoken path: /crates/mem-pool/src/types.rs
use gw_common::ckb_decimal::CKBCapacity;
use gw_types::{
packed::{L2Transaction, WithdrawalRequestExtra},
prelude::*,
};
#[derive(Default)]
pub struct EntryList {
// txs sorted by nonce
pub txs: Vec<L2Transaction>,
// withdra... | code_fim | hard | {
"lang": "rust",
"repo": "jjyr/godwoken",
"path": "/crates/mem-pool/src/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // remove lower balance withdrawals
if let Some(withdrawal) = self.withdrawals.get(0) {
let withdrawal_capacity: u64 = withdrawal.raw().capacity().unpack();
let capacity = capacity.to_layer1().unwrap();
if withdrawal_capacity > capacity {
... | code_fim | hard | {
"lang": "rust",
"repo": "jjyr/godwoken",
"path": "/crates/mem-pool/src/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn package(args: Args) -> Result<(),crate::Error>
{
let res: Result<_,Error> = try{
let Args{pack_file, oneclick_path} = args;
//copy this executable
let own_path = std::env::args().nth(0).expect("arg 0 should always be available");
crate::util::fs_copy(own_p... | code_fim | hard | {
"lang": "rust",
"repo": "Eroc33/modpack_tool",
"path": "/src/cmds/dev/package.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eroc33/modpack_tool path: /src/cmds/dev/package.rs
use crate::error::prelude::*;
use std::{
path::PathBuf,
io::{Write,Seek},
};
use zip;
use structopt::StructOpt;
use tokio::io::AsyncReadExt;
use snafu::Snafu;
#[derive(Debug, StructOpt)]
#[structopt(name = "add", about = "Adds a mod to ... | code_fim | hard | {
"lang": "rust",
"repo": "Eroc33/modpack_tool",
"path": "/src/cmds/dev/package.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
pub trait Plugin {
async fn run(&self, name: String) -> Result<()>;
async fn heartbeat(&self, name: String) -> Result<()>;
async fn leader_heartbeat(&self, name: String, data: ClusterNodes) -> Result<()>;
async fn process_update(&self, _: Document) -> Result<()> {
Ok... | code_fim | hard | {
"lang": "rust",
"repo": "proctorlabs/corvus",
"path": "/corvus/src/plugins/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: proctorlabs/corvus path: /corvus/src/plugins/mod.rs
use crate::{config::PluginOptions, prelude::*, triggers::Triggers};
use async_trait::async_trait;
use bluetooth::BluetoothPlugin;
use command::CommandPlugin;
use dht::DHTPlugin;
use std::collections::HashMap;
mod bluetooth;
mod command;
mod dh... | code_fim | hard | {
"lang": "rust",
"repo": "proctorlabs/corvus",
"path": "/corvus/src/plugins/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: diegopy/transaction-oxidizer path: /src/account.rs
use crate::{
transaction::{AmountTransaction, Transaction},
Money,
};
use num_traits::Zero;
use std::collections::HashMap;
use thiserror::Error;
#[derive(Debug)]
pub struct ClientAccount {
pub id: u16,
pub available: Money,
... | code_fim | hard | {
"lang": "rust",
"repo": "diegopy/transaction-oxidizer",
"path": "/src/account.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error("locked clients can't process transactions {0:?}")]
ClientLocked(Transaction),
#[error("attemped {attemped_action} on missing transaction: client {client} doesn't have transaction {tx}")]
MissingTransaction {
attemped_action: String,
client: u16,
tx: u32,
... | code_fim | hard | {
"lang": "rust",
"repo": "diegopy/transaction-oxidizer",
"path": "/src/account.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Luminarys/Nishikaku path: /engine/src/entity/component/physics.rs
use nalgebra::{Vector2, Translation};
use ncollide_geometry::shape::ShapeHandle2;
use std::rc::Rc;
use entity::Entity;
use scene::{Scene, PhysicsWorld};
pub struct PhysicsComp {
pub id: usize,
pub velocity: Vector2<f32>,... | code_fim | hard | {
"lang": "rust",
"repo": "Luminarys/Nishikaku",
"path": "/engine/src/entity/component/physics.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update(&mut self, dt: f32) {
self.velocity += self.acceleration * dt;
let delta = self.velocity * dt;
self.translate(delta);
}
}
impl Drop for PhysicsComp {
fn drop(&mut self) {
self.world.remove(&self.id);
}
}
#[derive(Clone, Default)]
pub struct P... | code_fim | hard | {
"lang": "rust",
"repo": "Luminarys/Nishikaku",
"path": "/engine/src/entity/component/physics.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rick68/rust-trace path: /libcore/iter/trait_IntoIterator/into_iter.rs
#![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
struct A<T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Ite... | code_fim | medium | {
"lang": "rust",
"repo": "rick68/rust-trace",
"path": "/libcore/iter/trait_IntoIterator/into_iter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> type I = A<T>;
#[test]
fn into_iter_test1() {
let a: A<T> = A { begin: 0, end: 10 };
let mut n: T = 0;
let iter: I = a.into_iter();
for x in iter {
assert_eq!(x, n);
n += 1;
}
assert_eq!(n, 10);
}
#[test]
fn into_iter_test2() {
let a: A<T> = A { begin: 0, end: ... | code_fim | hard | {
"lang": "rust",
"repo": "rick68/rust-trace",
"path": "/libcore/iter/trait_IntoIterator/into_iter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl NFTContractMetadata {
pub fn assert_valid(&self) {
assert_eq!(&self.spec, NFT_METADATA_SPEC);
assert_eq!(self.reference.is_some(), self.reference_hash.is_some());
if let Some(reference_hash) = &self.reference_hash {
assert_eq!(reference_hash.0.len(), 32, "Hash ... | code_fim | medium | {
"lang": "rust",
"repo": "vmwxrz/Nativo-NFT",
"path": "/blockchain/rust-contract/near-contract-standards-3.2.0/src/non_fungible_token/metadata.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut console = Console::new();
let mut with_callback = adc::with_callback(|channel: usize, value: usize| {
writeln!(console, "channel: {}, value: {}", channel, value).unwrap();
});
let adc = with_callback.init().unwrap();
loop {
adc.sample(0).unwrap();
time... | code_fim | easy | {
"lang": "rust",
"repo": "fhars/libtock-rs",
"path": "/examples/adc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fhars/libtock-rs path: /examples/adc.rs
#![no_std]
use core::fmt::Write;
use libtock::adc;
use libtock::console::Console;
use libtock::timer;
use libtock::timer::Duration;
<|fim_suffix|> let adc = with_callback.init().unwrap();
loop {
adc.sample(0).unwrap();
timer::slee... | code_fim | hard | {
"lang": "rust",
"repo": "fhars/libtock-rs",
"path": "/examples/adc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GopherSecurity/plonky path: /src/circuit_bigint.rs
mbs: Vec<Target<F>>) -> Self {
let bits = LIMB_BITS * limbs.len();
let one = BigUint::one();
let max = (&one << bits) - one;
Self { limbs, max }
}
pub fn zero() -> Self {
Self {
limbs:... | code_fim | hard | {
"lang": "rust",
"repo": "GopherSecurity/plonky",
"path": "/src/circuit_bigint.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> [self.x.limbs.as_slice(), self.y.limbs.as_slice()].concat()
}
fn generate(
&self,
_constants: &[Vec<F>],
witness: &PartialWitness<F>,
) -> PartialWitness<F> {
let x = witness.get_bigint_tar... | code_fim | hard | {
"lang": "rust",
"repo": "GopherSecurity/plonky",
"path": "/src/circuit_bigint.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if nonzero_limbs.len() == 1 {
return nonzero_limbs[0].clone().into();
}
// Convert to a Vec of unbounded limbs.
let nonzero_limbs: Vec<Target<C::ScalarField>> = nonzero_limbs
.iter()
.map(|bounded_limb| bounded_limb.target)
.... | code_fim | hard | {
"lang": "rust",
"repo": "GopherSecurity/plonky",
"path": "/src/circuit_bigint.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust-bindgen path: /bindgen-tests/tests/expectations/tests/class_no_members.rs
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct whatever {
pub _address: u8,
}
#[test]... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-bindgen",
"path": "/bindgen-tests/tests/expectations/tests/class_no_members.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
::std::mem::size_of::<whatever_child>(),
1usize,
concat!("Size of: ", stringify!(whatever_child)),
);
assert_eq!(
::std::mem::align_of::<whatever_child>(),
1usize,
concat!("Alignment of ", stringify!(whatever_child)),
);
}
#[repr(... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-bindgen",
"path": "/bindgen-tests/tests/expectations/tests/class_no_members.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IQ-SCM/cracken path: /src/helpers.rs
use std::io::{BufRead, BufReader, Error, Read};
pub struct RawFileReader<R> {
reader: BufReader<R>,
buffer: Vec<u8>,
}
impl<R: Read> RawFileReader<R> {
pub fn new(reader: R) -> RawFileReader<R> {
RawFileReader {
reader: BufRe... | code_fim | medium | {
"lang": "rust",
"repo": "IQ-SCM/cracken",
"path": "/src/helpers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file = File::open(wordlist_fname("vocab.txt")).unwrap();
let reader = RawFileReader::new(file);
let expected: Vec<_> = vec!["a", "e", "1", "i", "o"]
.iter()
.map(|s| s.as_bytes())
.collect();
let lines = reader.take(5).map(|s| s.unwra... | code_fim | hard | {
"lang": "rust",
"repo": "IQ-SCM/cracken",
"path": "/src/helpers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn as_subject_ref<'b>(&self, db: &'b Store) -> Result<SubjectRef<'b>, Self::Error> {
self.pred.as_subject_ref(db)
}
}
impl<'a> AsObjectRef for Prop<'a> {
type Error = <PredicateRef<'a> as AsObjectRef>::Error;
#[inline]
fn as_object_ref<'b>(&self, db: &'b Store) -> Result<ObjectR... | code_fim | hard | {
"lang": "rust",
"repo": "YoloDev/skorm",
"path": "/crates/store/src/query/schema.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn as_object_ref<'b>(&self, db: &'b Store) -> Result<ObjectRef<'b>, Self::Error> {
self.subj.as_object_ref(db)
}
}
#[derive(Clone)]
pub struct Prop<'a> {
pred: PredicateRef<'a>,
}
impl<'a> Predicate for Prop<'a> {
type Named = <PredicateRef<'a> as Subject>::Named;
#[inline]
... | code_fim | hard | {
"lang": "rust",
"repo": "YoloDev/skorm",
"path": "/crates/store/src/query/schema.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YoloDev/skorm path: /crates/store/src/query/schema.rs
use super::*;
use crate::store::schema::*;
use skorm_core::*;
#[derive(Clone)]
pub struct Class<'a> {
subj: SubjectRef<'a>,
}
impl<'a> Subject for Class<'a> {
type Named = <SubjectRef<'a> as Subject>::Named;
type Blank = <SubjectRef<'... | code_fim | hard | {
"lang": "rust",
"repo": "YoloDev/skorm",
"path": "/crates/store/src/query/schema.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ningsir/GraphScope path: /interactive_engine/executor/store/src/v2/wrapper/wrapper_partition_graph.rs
// Copyright 2020 Alibaba Group Holding Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You ... | code_fim | hard | {
"lang": "rust",
"repo": "Ningsir/GraphScope",
"path": "/interactive_engine/executor/store/src/v2/wrapper/wrapper_partition_graph.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_snapshot(&self, snapshot_id: SnapshotId) -> Self::S {
let multi_version_graph = self.multi_version_graph.clone();
WrapperPartitionSnapshot {
multi_version_graph,
snapshot_id,
}
}
}
pub struct WrapperPartitionSnapshot<G: MultiVersionGraph> {
... | code_fim | hard | {
"lang": "rust",
"repo": "Ningsir/GraphScope",
"path": "/interactive_engine/executor/store/src/v2/wrapper/wrapper_partition_graph.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("request message: {:?}", req_msg);
});
},
Err(e)=>{
println!("couldn't recieve request: {:?}",e);
}
}
}
}<|fim_prefix|>// repo: linuxfirstMint/udp_socket path: /udp_server/src/main.rs
use std::{net::UdpSocket, ... | code_fim | hard | {
"lang": "rust",
"repo": "linuxfirstMint/udp_socket",
"path": "/udp_server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>unwrap();
println!("{:}", "=".repeat(80));
println!("buffer size: {:?}", buf_size);
println!("src address: {:?}", src_addr);
println!("request message: {:?}", req_msg);
});
},
Err(e)=>{
... | code_fim | hard | {
"lang": "rust",
"repo": "linuxfirstMint/udp_socket",
"path": "/udp_server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linuxfirstMint/udp_socket path: /udp_server/src/main.rs
use std::{net::UdpSocket, thread};
fn main() -> std::io::Result<()>{
let socket = UdpSocket::bind("127.0.0.1:3333")?;
let mut buf = [0; 2048];
loop{
match socket.recv_from(&mut <|fim_suffix|> println!("request mes... | code_fim | hard | {
"lang": "rust",
"repo": "linuxfirstMint/udp_socket",
"path": "/udp_server/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: almindor/riscv path: /src/register/utval.rs
//! utval register
<|fim_suffix|>/// Writes the CSR
#[inline]
pub unsafe fn write(bits: usize) {
_write(bits)
}<|fim_middle|>read_csr_as_usize!(0x043, __read_utval);
write_csr!(0x043, __write_utval);
| code_fim | medium | {
"lang": "rust",
"repo": "almindor/riscv",
"path": "/src/register/utval.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> // finished ipc sender reserved before collector takes action
let ipc_send_finished = ipc_send.clone();
// the collector
// but yet this simple bracket to enclose this a little
{
trace!("syncing with 2 other threads");
wait_collector.wait();
trace!("sync with n... | code_fim | hard | {
"lang": "rust",
"repo": "electricherd/audiobookfinder",
"path": "/native/adbflib/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: electricherd/audiobookfinder path: /native/adbflib/src/main.rs
//! A simple first program in rust, actually I plan to do something even
//! useful. Trying to find all my audiobooks on many machines, identify them,
//! find duplicates (later trying to solve the problem, also including their permi... | code_fim | hard | {
"lang": "rust",
"repo": "electricherd/audiobookfinder",
"path": "/native/adbflib/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 2 - Net Future
let net_thread = std::thread::Builder::new()
.name("net".into())
.spawn(move || {
if has_net {
let sender = Some(tx_net);
task::block_on(
async move { shared::net_search(wait_net, sender, ipc_receive)... | code_fim | hard | {
"lang": "rust",
"repo": "electricherd/audiobookfinder",
"path": "/native/adbflib/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (mut cpu, mut bus) = new_cpu(vec![0xff]);
cpu.sp = 0x2000;
cpu.step(&mut bus, 0);
assert_eq!(0x38, cpu.pc);
// assert_eq!(3, bus.m_cycles);
// assert_eq!(11, bus.t_states);
let val = bus.memory_read_word(0x1ffe);
assert_eq!(0x01, val);
... | code_fim | hard | {
"lang": "rust",
"repo": "mnilsson/z80",
"path": "/tests/ops_jump.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnilsson/z80 path: /tests/ops_jump.rs
#[cfg(test)]
mod test_z80 {
// use z80::registers::Reg16;
use z80::bus::Bus;
use z80::cpu::Z80;
struct TestBus {
memory: Vec<u8>,
pub m_cycles: u8,
pub t_states: u8,
}
impl TestBus {
fn new(prg: Ve... | code_fim | hard | {
"lang": "rust",
"repo": "mnilsson/z80",
"path": "/tests/ops_jump.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Drout/rusty-build-light path: /src/config_file.rs
#[derive(Deserialize)]
pub struct Config {
pub allowed_failures: u32,
<|fim_suffix|> pub unity_cloud_api_token: String,
pub unity_base_url: String,
pub unity_led_pins: Vec<u16>,
}<|fim_middle|> pub jenkins_username: String,
... | code_fim | medium | {
"lang": "rust",
"repo": "Drout/rusty-build-light",
"path": "/src/config_file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub unity_cloud_api_token: String,
pub unity_base_url: String,
pub unity_led_pins: Vec<u16>,
}<|fim_prefix|>// repo: Drout/rusty-build-light path: /src/config_file.rs
#[derive(Deserialize)]
pub struct Config {
pub allowed_failures: u32,
<|fim_middle|> pub jenkins_username: String,
... | code_fim | medium | {
"lang": "rust",
"repo": "Drout/rusty-build-light",
"path": "/src/config_file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rbelouin/midi-hub path: /src/midi/devices/launchpadpro/index_selector.rs
use std::error::Error as StdError;
use std::fmt::{Display, Formatter};
use crate::midi::Event;
use crate::midi::features::{R, IndexSelector};
use super::device::LaunchpadProFeatures;
#[derive(Debug)]
struct IndexOutOfBou... | code_fim | hard | {
"lang": "rust",
"repo": "rbelouin/midi-hub",
"path": "/src/midi/devices/launchpadpro/index_selector.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for event in events {
let event = Event::Midi(event);
assert_eq!(None, features.into_index(event).expect("into_index should not fail"));
}
}
#[test]
fn into_index_should_correct_value() {
let features = super::super::LaunchpadProFeatures::new();... | code_fim | hard | {
"lang": "rust",
"repo": "rbelouin/midi-hub",
"path": "/src/midi/devices/launchpadpro/index_selector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: afaucher17/gomoku path: /src/minimax/mod.rs
extern crate time;
use board::{Board, Square, Move};
use std::cmp;
use std::cmp::Ordering;
use std::i32;
use std::collections::HashMap;
use self::time::PreciseTime;
#[derive(PartialEq, Eq, PartialOrd, Debug)]
pub struct Decision
{
score: i32,
... | code_fim | hard | {
"lang": "rust",
"repo": "afaucher17/gomoku",
"path": "/src/minimax/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
unsafe {
match (KILLER_MOVES[depth][0], KILLER_MOVES[depth][1])
{
(None, None) => KILLER_MOVES[depth][0] = pos,
(Some(_), None) => KILLER_MOVES[depth][1] = pos,
(old, Some(_)) => {
KILLER_MOVES[depth][1] = old;
KILLE... | code_fim | hard | {
"lang": "rust",
"repo": "afaucher17/gomoku",
"path": "/src/minimax/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn into_iter(self) -> Self::IntoIter {
self.inner.iter()
}
}
/// Convenience type wrapper for Arc<Item>.
pub type ItemRef = Arc<Item>;
/// An IR item that either expands to a subtype or leaf-record.
#[derive(Debug, Clone, PartialEq)]
pub enum Item {
Map(Map),
List(List),
Valu... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/core/src/response_ir/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> IntoIterator for &'a List {
type Item = &'a Item;
type IntoIter = std::slice::Iter<'a, Item>;
fn into_iter(self) -> Self::IntoIter {
self.inner.iter()
}
}
/// Convenience type wrapper for Arc<Item>.
pub type ItemRef = Arc<Item>;
/// An IR item that either expands to a s... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/core/src/response_ir/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/core/src/response_ir/mod.rs
//! Prisma Response IR (Intermediate Representation).
//!
//! This module takes care of processing query execution results
//! and transforming them into a different AST.
//!
//! This IR is meant for general processing and sto... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/core/src/response_ir/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#
[
cfg
(
limb_width_64
)
]
mod
large_powers64
;
pub
use
self
:
:
parse
:
:
{
parse_concise_float
parse_truncated_float
}
;<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/serde_json/src/lexical/mod.rs
pub
(
crate
)
mod
algorithm
;
mod
bhcomp
;
mod
bignum
;... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/serde_json/src/lexical/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RandomTable {
pub fn new() -> Self {
Self {
entries: Vec::new(),
total_weight: 0,
}
}
pub fn add(mut self, code: i32, weight: i32) -> RandomTable {
self.total_weight += weight;
self.entries.push(RandomEntry::new(code, weight));
... | code_fim | medium | {
"lang": "rust",
"repo": "tnyjhnsn/rust-roguelike",
"path": "/server/src/random_table.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn add(mut self, code: i32, weight: i32) -> RandomTable {
self.total_weight += weight;
self.entries.push(RandomEntry::new(code, weight));
self
}
pub fn roll(&self, rng: &mut RandomNumberGenerator) -> Option<i32> {
if self.total_weight == 0 { return None; }
... | code_fim | hard | {
"lang": "rust",
"repo": "tnyjhnsn/rust-roguelike",
"path": "/server/src/random_table.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tnyjhnsn/rust-roguelike path: /server/src/random_table.rs
use roguelike_common::{RandomNumberGenerator};
pub struct RandomEntry {
code: i32,
weight: i32,
}
impl RandomEntry {
pub fn new(code: i32, weight: i32) -> Self {
Self { code, weight }
}
}
#[derive(Default)]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "tnyjhnsn/rust-roguelike",
"path": "/server/src/random_table.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_get_mut() {
let mut matrix = Matrix::new(3, 3);
if let Some(reference) = matrix.get_mut((1, 0)) {
*reference = 112;
}
assert_eq!(matrix.get((1, 0)), Some(112).as_ref());
}
#[test]
fn test_index() {
let matrix = Matri... | code_fim | hard | {
"lang": "rust",
"repo": "qwercik/edit_dist",
"path": "/src/matrix.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qwercik/edit_dist path: /src/matrix.rs
use std::fmt;
use std::ops::{Index, IndexMut};
/// Type being used for selecting cells from a matrix
pub type Selector = (usize, usize);
/// 2D matrix with given size of T-typed elements
pub struct Matrix<T> {
data: Vec<T>,
width: usize,
heigh... | code_fim | hard | {
"lang": "rust",
"repo": "qwercik/edit_dist",
"path": "/src/matrix.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> IndexMut<Selector> for Matrix<T>
where
T: Default + Clone,
{
/// Return read-only reference to the specific cell or panic in case of error
///
/// # Arguments
/// * `selector` - Selector of the specific cell
///
/// # Examples
/// ```
/// let matrix = Matrix::ne... | code_fim | hard | {
"lang": "rust",
"repo": "qwercik/edit_dist",
"path": "/src/matrix.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> line: &str,
st: usize,
ed: usize,
rules: &Vec<String>,
dp: &mut HashMap<(usize, usize, String), bool>,
r: &HashMap<String, Vec<Vec<String>>>,
c: &HashMap<String, String>,
) -> bool {
if st == ed && rules.len() == 0 {
return true;
} else if st == ed {
ret... | code_fim | hard | {
"lang": "rust",
"repo": "jacobjonsson/advent-of-code-2020",
"path": "/src/day_19/day_19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_part_2() {
assert_eq!(
12,
part_2(
"42: 9 14 | 10 1
9: 14 27 | 1 26
10: 23 14 | 28 1
1: \"a\"
11: 42 31
5: 1 14 | 15 1
19: 14 1 | 14 14
12: 24 14 | 19 1
16: 15 1 | 14 14
31: 14 17 | 1 13
6: 14 14 | 1 14
2: 1 24 | 14 4
0: 8 11
13: 14 3... | code_fim | hard | {
"lang": "rust",
"repo": "jacobjonsson/advent-of-code-2020",
"path": "/src/day_19/day_19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobjonsson/advent-of-code-2020 path: /src/day_19/day_19.rs
extern crate regex;
use regex::Regex;
use std::collections::HashMap;
#[path = "../input_loader/input_loader.rs"]
mod input_loader;
pub fn day19() {
let input = input_loader::read_input("src/day_19/input.txt");
let part_1_re... | code_fim | hard | {
"lang": "rust",
"repo": "jacobjonsson/advent-of-code-2020",
"path": "/src/day_19/day_19.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub enum Type {
Bool,
Integer(Integer),
Named(IdentId),
Number,
Pointer(TypeId),
Unit,
Var(i32),
}
impl Type {
pub fn as_named(&self) -> Option<IdentId> {
if let &Self::Named(ty) = self {
Some(ty)
} e... | code_fim | medium | {
"lang": "rust",
"repo": "1tgr/simplejit-demo",
"path": "/src/ast/ty.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1tgr/simplejit-demo path: /src/ast/ty.rs
use crate::ast::IdentId;
use derive_more::Display;
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Display)]
#[display(fmt = "{}", "_0")]
pub struct TypeId(salsa::InternId);
<|fim_suffix|>#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub enum Type {
... | code_fim | hard | {
"lang": "rust",
"repo": "1tgr/simplejit-demo",
"path": "/src/ast/ty.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigp/lighthouse path: /slasher/tests/backend.rs
#![cfg(feature = "lmdb")]
use slasher::{config::MDBX_DATA_FILENAME, Config, DatabaseBackend, DatabaseBackendOverride};
use std::fs::File;
use tempfile::tempdir;
#[test]
#[cfg(all(feature = "mdbx", feature = "lmdb"))]
fn override_no_existing_db() ... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/slasher/tests/backend.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filename = config.database_path.join(MDBX_DATA_FILENAME);
File::create(&filename).unwrap();
assert_eq!(
config.override_backend(),
DatabaseBackendOverride::Failure(filename)
);
assert_eq!(config.backend, DatabaseBackend::Lmdb);
}<|fim_prefix|>// repo: sigp/lighthou... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/slasher/tests/backend.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let &Some(conditional) = maybe_conditional {
return self.evaluate_conditional(conditional, description)
}
return Ok(());
}
pub fn process_action(
&'m mut self,
game_action: Action,
) -> Result<String, MaeveError> {
let mut descri... | code_fim | hard | {
"lang": "rust",
"repo": "AnotherGroupChat/maeve",
"path": "/src/interpreter/machine.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AnotherGroupChat/maeve path: /src/interpreter/machine.rs
//! Holds definition to wrap and alter game.
use error::MaeveError;
use load::save;
use protos::master::Conditional;
use protos::master::Context;
use protos::master::Game;
use protos::master::State;
use protos::master::branch::Branch;
use... | code_fim | hard | {
"lang": "rust",
"repo": "AnotherGroupChat/maeve",
"path": "/src/interpreter/machine.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: innerr/tikv path: /components/engine_rocks/src/event_listener.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use crate::rocks_metrics::*;
use rocksdb::{
CompactionJobInfo, DBBackgroundErrorReason, FlushJobInfo, IngestionInfo, WriteStallInfo,
};
use tikv_util::set_pani... | code_fim | hard | {
"lang": "rust",
"repo": "innerr/tikv",
"path": "/components/engine_rocks/src/event_listener.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(result.is_err());
if let Err(err) = result {
let r = match reason {
DBBackgroundErrorReason::Flush => "flush",
DBBackgroundErrorReason::Compaction => "compaction",
DBBackgroundErrorReason::WriteCallback => "write_callback"... | code_fim | hard | {
"lang": "rust",
"repo": "innerr/tikv",
"path": "/components/engine_rocks/src/event_listener.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> STORE_ENGINE_EVENT_COUNTER_VEC
.with_label_values(&[&self.db_name, info.cf_name(), "flush"])
.inc();
}
fn on_compaction_completed(&self, info: &CompactionJobInfo) {
STORE_ENGINE_EVENT_COUNTER_VEC
.with_label_values(&[&self.db_name, info.cf_name(... | code_fim | hard | {
"lang": "rust",
"repo": "innerr/tikv",
"path": "/components/engine_rocks/src/event_listener.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn pull(
&mut self,
controller: sys::ReadableByteStreamController,
) -> Result<JsValue, JsValue> {
// The AsyncRead should still exist, since pull() will not be called again
// after the stream has closed or encountered an error.
let async_read = self.... | code_fim | hard | {
"lang": "rust",
"repo": "MattiasBuelens/wasm-streams",
"path": "/src/readable/into_underlying_byte_source.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MattiasBuelens/wasm-streams path: /src/readable/into_underlying_byte_source.rs
use std::cell::RefCell;
use std::pin::Pin;
use std::rc::Rc;
use futures_util::future::{abortable, AbortHandle, TryFutureExt};
use futures_util::io::{AsyncRead, AsyncReadExt};
use js_sys::{Error as JsError, Promise, U... | code_fim | hard | {
"lang": "rust",
"repo": "MattiasBuelens/wasm-streams",
"path": "/src/readable/into_underlying_byte_source.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Inner {
fn new(async_read: Box<dyn AsyncRead>) -> Self {
Inner {
async_read: Some(async_read.into()),
buffer: Vec::new(),
}
}
async fn pull(
&mut self,
controller: sys::ReadableByteStreamController,
) -> Result<JsValue, JsValue>... | code_fim | hard | {
"lang": "rust",
"repo": "MattiasBuelens/wasm-streams",
"path": "/src/readable/into_underlying_byte_source.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bexxmodd/RustDocNotes path: /oReilly/main.rs
fn main() {
let mut primes = vec![2, 3, 5, 7];
primes.push(11);
let product = primes.iter().product::<i32>();
println!("Product = {}", product);
<|fim_suffix|> let mut v1 = Vec::<u32>::with_capacity(20);
v1.push(12);
v1.pu... | code_fim | medium | {
"lang": "rust",
"repo": "bexxmodd/RustDocNotes",
"path": "/oReilly/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut v1 = Vec::<u32>::with_capacity(20);
v1.push(12);
v1.push(15);
println!("Capacity: {}", v1.capacity());
println!("Len: {}", v1.len());
}<|fim_prefix|>// repo: bexxmodd/RustDocNotes path: /oReilly/main.rs
fn main() {
let mut primes = vec![2, 3, 5, 7];
primes.push(11);
<... | code_fim | hard | {
"lang": "rust",
"repo": "bexxmodd/RustDocNotes",
"path": "/oReilly/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn test_rfc_8285_two_byte_extension() -> Result<()> {
let raw_pkt = Bytes::from_static(&[
0x90, 0xe0, 0x69, 0x8f, 0xd9, 0xc2, 0x93, 0xda, 0x1c, 0x64, 0x27, 0x82, 0x10, 0x00, 0x00,
0x07, 0x05, 0x18, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0x... | code_fim | hard | {
"lang": "rust",
"repo": "webrtc-rs/rtc",
"path": "/rtp/src/packet/packet_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: webrtc-rs/rtc path: /rtp/src/packet/packet_test.rs
) -> Result<()> {
let mut empty_bytes = &vec![0u8; 0][..];
let result = Packet::unmarshal(&mut empty_bytes);
assert!(
result.is_err(),
"Unmarshal did not error on zero length packet"
);
let raw_pkt = Bytes::f... | code_fim | hard | {
"lang": "rust",
"repo": "webrtc-rs/rtc",
"path": "/rtp/src/packet/packet_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn test_rfc8285_one_byte_set_extension_should_error_when_payload_too_large() {
let payload = Bytes::from_static(&[0x98u8, 0x36, 0xbe, 0x88, 0x9e]);
let mut p = Packet {
header: Header {
marker: true,
extension: true,
extension_profile: 0xB... | code_fim | hard | {
"lang": "rust",
"repo": "webrtc-rs/rtc",
"path": "/rtp/src/packet/packet_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danieldk/dpar path: /dpar/src/lib.rs
#[macro_use]
mod macros;
pub mod features;
pub mod guide;
pub mod models;
<|fim_suffix|>pub mod systems;
pub mod parser;
pub mod train;<|fim_middle|>mod numberer;
pub use crate::numberer::Numberer;
pub mod system;
| code_fim | medium | {
"lang": "rust",
"repo": "danieldk/dpar",
"path": "/dpar/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod parser;
pub mod train;<|fim_prefix|>// repo: danieldk/dpar path: /dpar/src/lib.rs
#[macro_use]
mod macros;
pub mod features;
pub mod guide;
pub mod models;
mod numberer;
pub use crate::numberer::Numberer;
pub mod system;
<|fim_middle|>pub mod systems;
| code_fim | easy | {
"lang": "rust",
"repo": "danieldk/dpar",
"path": "/dpar/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benjamintoofer/jpeg_encoder.rs path: /src/jpeg.rs
use std::{fmt::{self, Display}, u16};
// const zig_zag_map: [usize; 64] = [
// 0, 1, 8, 16, 9, 2, 3, 10,
// 17, 32, 40, 33, 18, 11, 4, 5,
// 12, 19,
// ]
#[derive(Debug, Clone, Copy)]
pub struct QuantizationTable<'a> {
pub tabl... | code_fim | hard | {
"lang": "rust",
"repo": "benjamintoofer/jpeg_encoder.rs",
"path": "/src/jpeg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // DC Huffman Tables
let mut dht_str = String::from("");
for dht in self.dc_huffman_tables.iter() {
match dht {
Some(table) => {
dht_str.push_str(format!("{}\n", table).as_str())
}
None => {}
... | code_fim | hard | {
"lang": "rust",
"repo": "benjamintoofer/jpeg_encoder.rs",
"path": "/src/jpeg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lauromoura/adventofcode path: /advent2021/src/day_04.rs
use std::collections::HashSet;
use std::fmt;
#[derive(PartialEq)]
enum PickStatus {
Completed,
Marked,
Missed,
}
struct Board {
unmarked_numbers: HashSet<i32>,
rows: Vec<Vec<i32>>,
columns: Vec<Vec<i32>>,
compl... | code_fim | hard | {
"lang": "rust",
"repo": "lauromoura/adventofcode",
"path": "/advent2021/src/day_04.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut current: Vec<Vec<i32>> = Vec::new();
let mut boards: Vec<Board> = Vec::new();
for line in lines.iter().skip(1) {
if line.trim().is_empty() {
continue;
}
let tokens: Vec<i32> = line
.split_whitespace()
.map(|c| c.parse::<i32... | code_fim | hard | {
"lang": "rust",
"repo": "lauromoura/adventofcode",
"path": "/advent2021/src/day_04.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: google/mosaic path: /test/run-make/cc_use/cc_use.rs
// Copyright (c) 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// opti... | code_fim | medium | {
"lang": "rust",
"repo": "google/mosaic",
"path": "/test/run-make/cc_use/cc_use.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut foo = Foo {
a: 1,
b: 2,
c: 0.1,
d: 10.0,
e: '!' as i8,
};
foo.say_hello(42);
let mut bar = Bar { x: 1337 };
bar.say_goodbye(84);
}<|fim_prefix|>// repo: google/mosaic path: /test/run-make/cc_use/cc_use.rs
// Copyright (c) 2021 Google LL... | code_fim | medium | {
"lang": "rust",
"repo": "google/mosaic",
"path": "/test/run-make/cc_use/cc_use.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut foo = Foo {
a: 1,
b: 2,
c: 0.1,
d: 10.0,
e: '!' as i8,
};
foo.say_hello(42);
let mut bar = Bar { x: 1337 };
bar.say_goodbye(84);
}<|fim_prefix|>// repo: google/mosaic path: /test/run-make/cc_use/cc_use.rs
// Copyright (c) 20... | code_fim | medium | {
"lang": "rust",
"repo": "google/mosaic",
"path": "/test/run-make/cc_use/cc_use.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Inky-developer/mc_utils path: /mc_utils/src/lib.rs
use std::{env, path::PathBuf};
pub use rcon;
pub use server;
/// Returns the .minecraft directory path for the current platform
pub fn minecraft_dir() -> PathBuf {
// Original minecraft code:
// public static File getWorkingDirectory()... | code_fim | medium | {
"lang": "rust",
"repo": "Inky-developer/mc_utils",
"path": "/mc_utils/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut user_home = dirs::home_dir().expect("Could not retrieve home directory");
if cfg!(windows) {
let mut dir = env::var("APPDATA").map_or(user_home, PathBuf::from);
dir.push(".minecraft/");
dir
} else if cfg!(macos) {
user_home.push("Library/Application Supp... | code_fim | medium | {
"lang": "rust",
"repo": "Inky-developer/mc_utils",
"path": "/mc_utils/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match matches.subcommand() {
("init", Some(args)) => {
let port = value_t!(args.value_of("PORT NUMBER"), u16).unwrap();
let dir = value_t!(args.value_of("NETWORKS DIRECTORY"), String).unwrap();
cfg.port = port;
cfg.root_dir = PathBuf::from(&dir)... | code_fim | hard | {
"lang": "rust",
"repo": "BTCLTC/rust-cardano",
"path": "/hermes/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BTCLTC/rust-cardano path: /hermes/src/main.rs
#[macro_use]
extern crate clap;
#[macro_use]
extern crate serde_derive;
extern crate serde_yaml;
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate iron;
extern crate router;
extern crate storage;
extern crate wallet_crypto;
exter... | code_fim | hard | {
"lang": "rust",
"repo": "BTCLTC/rust-cardano",
"path": "/hermes/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobhenn/buzzer path: /src/registry.rs
use crate::websockets::Connection;
use actix_web_actors::ws::{CloseCode, CloseReason};
use actix::{Addr, Message};
use log::warn;
use std::collections::HashMap;
use uuid::Uuid;
<|fim_suffix|>// A message to the registry to register a client at Socket with... | code_fim | medium | {
"lang": "rust",
"repo": "jacobhenn/buzzer",
"path": "/src/registry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// A message to the registry to register a client at Socket with id Uuid.
#[derive(Clone, Message)]
#[rtype(result = "()")]
pub struct Connect(pub Uuid, pub Socket);
// A message to the registry to deregister the client at Uuid.
#[derive(Message)]
#[rtype(result = "()")]
pub struct Disconnect(pub Uuid);
... | code_fim | medium | {
"lang": "rust",
"repo": "jacobhenn/buzzer",
"path": "/src/registry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// A message to a Connection to send a close frame.
#[derive(Message)]
#[rtype(result = "()")]
pub struct Close(pub CloseReason);
// The Registry stores a map of client ids to their sockets. Connections relay
// commands they recieve to the registry, which in turn retransmits them to all
// registered cl... | code_fim | medium | {
"lang": "rust",
"repo": "jacobhenn/buzzer",
"path": "/src/registry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(db_conn.count_servers(), initial_server_count + 2);
assert_eq!(db_conn.count_lobby_state(), initial_lobby_state_count + 2);
}
/*
sqlite> .schema
CREATE TABLE server_players (
server_id int NOT NULL REFERENCES game_servers(id),
player_id int NOT NULL REFERENCES p... | code_fim | medium | {
"lang": "rust",
"repo": "Resok/dominions-5-status",
"path": "/src/commands/servers/lobby/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn add_two_lobbies() {
let db_conn = DbConnection::test();
let initial_server_count = db_conn.count_servers();
let initial_lobby_state_count = db_conn.count_lobby_state();
lobby_helper(&db_conn, Era::Early, 5, "foo", UserId(4)).unwrap();
lobby_helper(&db_conn, Era::Early, 5, ... | code_fim | hard | {
"lang": "rust",
"repo": "Resok/dominions-5-status",
"path": "/src/commands/servers/lobby/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Resok/dominions-5-status path: /src/commands/servers/lobby/tests.rs
use super::*;
/*
fn lobby_helper(
db_conn: &DbConnection,
era: Era,
player_count: i32,
alias: &String,
author_id: UserId,
) -> Result<(), CommandError> {
*/
#[test]
fn add_lobby() {
let db_conn = DbConn... | code_fim | medium | {
"lang": "rust",
"repo": "Resok/dominions-5-status",
"path": "/src/commands/servers/lobby/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lyfzero/OS-learning path: /learn_rust_the_hard_way/switch_match/ex13_match/src/main.rs
use::std::env;
use::std::process;
fn main() {
let args: Vec<String> = env::args().collect(); // 命令行参数读取
println!("args: {:?}", args); // 打印参数
if args.len() != 2 {
println!("ERROR: you need... | code_fim | hard | {
"lang": "rust",
"repo": "lyfzero/OS-learning",
"path": "/learn_rust_the_hard_way/switch_match/ex13_match/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'E'", i),
'i' | 'I' => println!("{}: 'I'", i),
'o' | 'O' => println!("{}: 'O'", i),
'u' | 'U' => println!("{}: 'U'", i),
'y' | 'Y' => if i > 2 {
println!("{}: 'Y'\n", i);
},
_ => println!("{}: {} is not a vowel", i, i... | code_fim | hard | {
"lang": "rust",
"repo": "lyfzero/OS-learning",
"path": "/learn_rust_the_hard_way/switch_match/ex13_match/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YangKeao/Diorama path: /diorama-core/src/impl_diorama/request.rs
#[derive(StringStructFromLit)]
pub struct BaseUrl (pub String);
#[derive(StructFromAttrs)]
pub struct ClientMeta {
pub base_url: BaseUrl
}
#[derive(EnumFromLit)]
pub enum Method {
GET,
POST,
DELETE
}
impl Method ... | code_fim | medium | {
"lang": "rust",
"repo": "YangKeao/Diorama",
"path": "/diorama-core/src/impl_diorama/request.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(EnumFromLit)]
pub enum Deserializer {
Json,
Html
}
#[derive(StructFromAttrs)]
pub struct RequestMeta {
pub method: Method,
pub deserializer: Deserializer
}
pub fn impl_request(client_meta: &ClientMeta,
req_meta: &RequestMeta,
ident: &syn::Ident,
... | code_fim | hard | {
"lang": "rust",
"repo": "YangKeao/Diorama",
"path": "/diorama-core/src/impl_diorama/request.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", res);
return Ok(res);
}
}
}
pub fn impl_field_request(_: &ClientMeta,
_: &RequestMeta,
ident: &syn::Ident,
returns: &syn::ReturnType) -> proc_macro2::TokenStream {
quote! ... | code_fim | hard | {
"lang": "rust",
"repo": "YangKeao/Diorama",
"path": "/diorama-core/src/impl_diorama/request.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test() {
assert_eq!(Solution::rob(vec![2, 3, 2]), 3);
assert_eq!(Solution::rob(vec![1, 2, 3, 1]), 4);
assert_eq!(Solution::rob(vec![0]), 0);
}
}<|fim_prefix|>// repo: MDGSF/JustCoding path: /rust-leetcode/leetcode_213/src/solution1.rs
impl Solution {
pub fn rob(nums: Vec<i3... | code_fim | medium | {
"lang": "rust",
"repo": "MDGSF/JustCoding",
"path": "/rust-leetcode/leetcode_213/src/solution1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MDGSF/JustCoding path: /rust-leetcode/leetcode_213/src/solution1.rs
impl Solution {
pub fn rob(nums: Vec<i32>) -> i32 {
if nums.is_empty() {
return 0;
} else if nums.len() == 1 {
return nums[0];
}
let sub1 = Self::rob_198(&nums[1..]);
let sub2 = Self::rob_198(&n... | code_fim | medium | {
"lang": "rust",
"repo": "MDGSF/JustCoding",
"path": "/rust-leetcode/leetcode_213/src/solution1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Signis-bin/tracing-actix-web path: /src/root_span.rs
use actix_web::dev::Payload;
use actix_web::{FromRequest, HttpRequest, ResponseError};
use std::future::{ready, Ready};
use tracing::Span;
#[derive(Clone)]
/// The root span associated to the in-flight current request.
///
/// It can be used ... | code_fim | hard | {
"lang": "rust",
"repo": "Signis-bin/tracing-actix-web",
"path": "/src/root_span.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.