text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> fn current_state(&self, at: i32) -> Vec<Pot> {
let mut state = vec![];
for i in at - 2..=at + 2 {
state.push(self.pot(i));
}
state
}
fn next_state(&self, current: &[Pot]) -> Pot {
for t in &self.transitions {
if t.is_match(curren... | code_fim | hard | {
"lang": "rust",
"repo": "phucloc8697/advent-of-code-2018-rust",
"path": "/day12/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.from == state
}
}
impl FromStr for Transition {
type Err = Box<dyn Error>;
fn from_str(s: &str) -> Result<Transition> {
lazy_static! {
static ref RE: Regex = Regex::new(r"^(?P<from>[#.]{5}) => (?P<to>[#.])$",).unwrap();
}
let caps = match RE.... | code_fim | hard | {
"lang": "rust",
"repo": "phucloc8697/advent-of-code-2018-rust",
"path": "/day12/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fzgregor/compose_yml path: /src/v2/true_or_struct.rs
//! Tools for working with fields that might contain true, or might
//! contain a struct.
use serde::de::{self, Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use std::marker::PhantomData;
/// Handle a value which may e... | code_fim | hard | {
"lang": "rust",
"repo": "fzgregor/compose_yml",
"path": "/src/v2/true_or_struct.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn visit_some<D>(&mut self,
deserializer: &mut D)
-> Result<Self::Value, D::Error>
where D: Deserializer
{
deserialize_true_or_struct(deserializer).map(Some)
}
}
d.deserialize_option(OptTrueOrStruct(... | code_fim | hard | {
"lang": "rust",
"repo": "fzgregor/compose_yml",
"path": "/src/v2/true_or_struct.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> deserializer: &mut D)
-> Result<Self::Value, D::Error>
where D: Deserializer
{
deserialize_true_or_struct(deserializer).map(Some)
}
}
d.deserialize_option(OptTrueOrStruct(PhantomData))
}
/// Serialize the s... | code_fim | hard | {
"lang": "rust",
"repo": "fzgregor/compose_yml",
"path": "/src/v2/true_or_struct.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: krishan147/rust_helloworld path: /hello_world/src/main.rs
// use piston_window::*;
use std::net::TcpListener;
fn main() {
let x = 1; // integer
let y = 2.0; //floating point number
let dynamic = 8 * 8;
let myarray = [1,2,3,4,5,6,7,8];
// let tuple = (1,2,"up");
// let (hi... | code_fim | hard | {
"lang": "rust",
"repo": "krishan147/rust_helloworld",
"path": "/hello_world/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("hello your {}",name)
}
fn add(a:i8, b:i8){
println!("{}",a + b)
}<|fim_prefix|>// repo: krishan147/rust_helloworld path: /hello_world/src/main.rs
// use piston_window::*;
use std::net::TcpListener;
fn main() {
let x = 1; // integer
let y = 2.0; //floating point number
... | code_fim | hard | {
"lang": "rust",
"repo": "krishan147/rust_helloworld",
"path": "/hello_world/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lloydmeta/aoc2017-rs path: /src/day_19.rs
use day_19::Direction::*;
const DAY_19_INPUT: &'static str = include_str!("../data/day_19_real_input");
pub fn run() -> Result<(), &'static str> {
println!("*** Day 19: A Series of Tubes ***");
println!("Input: {}", DAY_19_INPUT);
println!(... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/aoc2017-rs",
"path": "/src/day_19.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pivot: Coord,
dir_char: Option<char>,
dir: Direction,
found_cursor: &mut Option<Cursor>,
this_dir_coord: &mut Option<Coord>,
other_dir_coord: &mut Option<Coord>,
) {
fn set_cursor_fo... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/aoc2017-rs",
"path": "/src/day_19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Iterator for MazeRunner<'a> {
type Item = Cursor;
fn next(&mut self) -> Option<Self::Item> {
let next = self.next_cursor();
self.cursor = next;
next
}
}
fn find_entry(maze: &Maze) -> Result<Coord, &'static str> {
match maze.get_row(0) {
Some(row_1... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/aoc2017-rs",
"path": "/src/day_19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output = vm.call(["main"], (External { value: 42 },))?;
let output: External = rune::from_value(output)?;
println!("{:?}", output);
assert_eq!(output.value, 42);
Ok(())
}<|fim_prefix|>// repo: rune-rs/rune path: /examples/examples/simple_external.rs
use std::sync::Arc;
use rune::... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/examples/examples/simple_external.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rune-rs/rune path: /examples/examples/simple_external.rs
use std::sync::Arc;
use rune::runtime::Vm;
use rune::termcolor::{ColorChoice, StandardStream};
use rune::{Any, ContextError, Diagnostics, Module};
#[derive(Debug, Any)]
struct External {
value: u32,
}
pub fn module() -> Result<Modul... | code_fim | medium | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/examples/examples/simple_external.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = rune::prepare(&mut sources)
.with_context(&context)
.with_diagnostics(&mut diagnostics)
.build();
if !diagnostics.is_empty() {
let mut writer = StandardStream::stderr(ColorChoice::Always);
diagnostics.emit(&mut writer, &sources)?;
}
le... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/examples/examples/simple_external.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dextero/irc-bot.rs path: /src/util/lock.rs
use core::ErrorKind;
use core::Result;
use std::borrow::Cow;
use std::sync::Mutex;
use std::sync::MutexGuard;
use std::sync::PoisonError;
use std::sync::RwLock;
use std::sync::RwLockReadGuard;
use std::sync::RwLockWriteGuard;
pub(crate) trait RwLockExt... | code_fim | medium | {
"lang": "rust",
"repo": "dextero/irc-bot.rs",
"path": "/src/util/lock.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn write_clean<Desc>(&self, description: Desc) -> Result<RwLockWriteGuard<T>>
where
Desc: Into<Cow<'static, str>>,
{
self.write()
.map_err(|PoisonError { .. }| ErrorKind::LockPoisoned(description.into().into()).into())
}
}
pub(crate) trait MutexExt<T> {
///... | code_fim | medium | {
"lang": "rust",
"repo": "dextero/irc-bot.rs",
"path": "/src/util/lock.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>packet_struct! {
/// Play a legacy sound.
///
/// Direction: Server -> Client.
pub struct PlayLegacySound {
const TAG = 132;
pub pos: Vec2,
pub sound_id: u16,
pub mode: SoundMode,
}
}<|fim_prefix|>// repo: Lonami/terry path: /terraria-protocol/src/pack... | code_fim | medium | {
"lang": "rust",
"repo": "Lonami/terry",
"path": "/terraria-protocol/src/packets/play_legacy_sound.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lonami/terry path: /terraria-protocol/src/packets/play_legacy_sound.rs
use crate::serde::{packet_struct, serializable_enum};
use crate::structures::Vec2;
<|fim_suffix|> pub pos: Vec2,
pub sound_id: u16,
pub mode: SoundMode,
}
}<|fim_middle|>serializable_enum! {
pu... | code_fim | hard | {
"lang": "rust",
"repo": "Lonami/terry",
"path": "/terraria-protocol/src/packets/play_legacy_sound.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub pos: Vec2,
pub sound_id: u16,
pub mode: SoundMode,
}
}<|fim_prefix|>// repo: Lonami/terry path: /terraria-protocol/src/packets/play_legacy_sound.rs
use crate::serde::{packet_struct, serializable_enum};
use crate::structures::Vec2;
<|fim_middle|>serializable_enum! {
pu... | code_fim | hard | {
"lang": "rust",
"repo": "Lonami/terry",
"path": "/terraria-protocol/src/packets/play_legacy_sound.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nvzqz/uncon-rs path: /derive/src/lib.rs
//! Support for deriving traits found in [`uncon`].
//!
//! # Usage
//!
//! This crate is available [on crates.io][crate] and can be used by adding the
//! following to your project's `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! uncon_derive = "1.1... | code_fim | hard | {
"lang": "rust",
"repo": "nvzqz/uncon-rs",
"path": "/derive/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let impl_from = uncon_items.iter().flat_map(|i| i.iter()).filter_map(|item| {
if let NestedMetaItem::MetaItem(MetaItem::Word(ref ident)) = *item {
if ident == "impl_from" { return Some(true); }
}
None
}).next().unwrap_or(false);
let (ty, init, from_impl) = ... | code_fim | hard | {
"lang": "rust",
"repo": "nvzqz/uncon-rs",
"path": "/derive/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reitermarkus/dockworker path: /src/models/swarm_info.rs
use serde_aux::prelude::*;
use models::{Cluster, RemoteManager};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct SwarmInfo {
#[serde(rename = "NodeID")]
pub node_id: String,
pub node_ad... | code_fim | medium | {
"lang": "rust",
"repo": "reitermarkus/dockworker",
"path": "/src/models/swarm_info.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>g,
#[serde(default, deserialize_with = "deserialize_default_from_null")]
pub remote_managers: Vec<RemoteManager>,
#[serde(default, deserialize_with = "deserialize_default_from_null")]
pub nodes: u64,
#[serde(default, deserialize_with = "deserialize_default_from_null")]
pub managers: u64,
pub... | code_fim | medium | {
"lang": "rust",
"repo": "reitermarkus/dockworker",
"path": "/src/models/swarm_info.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e_default_from_null")]
pub nodes: u64,
#[serde(default, deserialize_with = "deserialize_default_from_null")]
pub managers: u64,
pub cluster: Option<Cluster>,
}<|fim_prefix|>// repo: reitermarkus/dockworker path: /src/models/swarm_info.rs
use serde_aux::prelude::*;
use models::{Cluster, RemoteMan... | code_fim | hard | {
"lang": "rust",
"repo": "reitermarkus/dockworker",
"path": "/src/models/swarm_info.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Mark the task as unscheduled.
(*(raw.header as *mut Header)).state &= !SCHEDULED;
// Notify the awaiter that the future has been dropped.
(*(raw.header as *mut Header)).notify(None);
// Drop the task reference.
Self::drop_task(pt... | code_fim | hard | {
"lang": "rust",
"repo": "DataDog/glommio",
"path": "/glommio/src/task/raw.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DataDog/glommio path: /glommio/src/task/raw.rs
sk.
pub(crate) layout: Layout,
/// Offset into the task at which the schedule function is stored.
pub(crate) offset_s: usize,
/// Offset into the task at which the future is stored.
pub(crate) offset_f: usize,
/// Offset i... | code_fim | hard | {
"lang": "rust",
"repo": "DataDog/glommio",
"path": "/glommio/src/task/raw.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns a pointer to the output inside a task.
unsafe fn get_output(ptr: *const ()) -> *const () {
let raw = Self::from_ptr(ptr);
raw.output as *const ()
}
/// Cleans up task's resources and deallocates it.
///
/// The schedule function will be dropped, and the... | code_fim | hard | {
"lang": "rust",
"repo": "DataDog/glommio",
"path": "/glommio/src/task/raw.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evgenykuzyakov/near-cli path: /src/commands/construct_transaction_command/transaction_actions/mod.rs
/// Go to transaction signing
Skip(CliSkipAction),
}
#[derive(Debug, clap::Clap)]
pub enum CliSkipNextAction {
/// Go to transaction signing
Skip(CliSkipAction),
}
#[derive(Debug... | code_fim | hard | {
"lang": "rust",
"repo": "evgenykuzyakov/near-cli",
"path": "/src/commands/construct_transaction_command/transaction_actions/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Send a non-version message.
synthetic_node
.send_direct_message(node.addr(), message)
.await?;
// Expect the node to ignore the previous message, verify by completing the handshake.
// Send Version.
synthetic_node
.send_direct... | code_fim | hard | {
"lang": "rust",
"repo": "defuse/ziggurat",
"path": "/src/tests/conformance/handshake/ignore_message_inplace_of_version.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: defuse/ziggurat path: /src/tests/conformance/handshake/ignore_message_inplace_of_version.rs
//! Contains test cases which cover ZG-CONFORMANCE-003 and ZG-CONFORMANCE-004.
//!
//! The node ignores non-version messages sent inplace of version.
use crate::{
protocol::{
message::Message... | code_fim | hard | {
"lang": "rust",
"repo": "defuse/ziggurat",
"path": "/src/tests/conformance/handshake/ignore_message_inplace_of_version.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(DiskHarvest {
name,
mount_point,
free_space: Some(free_space),
used_space: Some(used_space),
total_space: Some(total_space),
})
} else {
None... | code_fim | hard | {
"lang": "rust",
"repo": "ClementTsang/bottom",
"path": "/src/app/data_harvester/disks/other.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ClementTsang/bottom path: /src/app/data_harvester/disks/other.rs
//! Fallback disk info using sysinfo.
use sysinfo::{DiskExt, SystemExt};
use crate::app::data_harvester::DataCollector;
use super::{keep_disk_entry, DiskHarvest};
pub(crate) fn get_disk_usage(collector: &DataCollector) -> anyho... | code_fim | hard | {
"lang": "rust",
"repo": "ClementTsang/bottom",
"path": "/src/app/data_harvester/disks/other.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x0_whole = xfloor.to_int().unwrap();
let y0_whole = yfloor.to_int().unwrap();
let z0_whole = zfloor.to_int().unwrap();
let w0_whole = wfloor.to_int().unwrap();
let x1_whole = x0_whole + 1;
let y1_whole = y0_whole + 1;
let z1_whole = z0_whole + 1;
let w1_whole = w0_whol... | code_fim | hard | {
"lang": "rust",
"repo": "emberian/noise-rs",
"path": "/src/perlin.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn perlin3_best<T: Float>(seed: &Seed, point: &::Point3<T>) -> T {
perlin3(seed, point, math::scurve5)
}
fn perlin4<T, F>(seed: &Seed, point: &::Point4<T>, scurve: F) -> T where
T: Float,
F: Fn(T) -> T,
{
fn gradient<T: Float>(seed: &Seed, x_whole: int, y_whole: int, z_whole: int, w_w... | code_fim | hard | {
"lang": "rust",
"repo": "emberian/noise-rs",
"path": "/src/perlin.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emberian/noise-rs path: /src/perlin.rs
// Copyright 2013 The noise-rs developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file ex... | code_fim | hard | {
"lang": "rust",
"repo": "emberian/noise-rs",
"path": "/src/perlin.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for event in self
.sdl
.event_pump()
.map_err(anyhow::Error::msg)?
.poll_iter()
{
// println!("Event: {:?}", event);
match event {
Event::Quit { .. } => return Err(anyhow!("Quit")),
Even... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/rosettaboy",
"path": "/rs/src/buttons.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LaplaceKorea/rosettaboy path: /rs/src/buttons.rs
extern crate sdl2;
use crate::consts::*;
use crate::cpu;
use crate::ram;
use anyhow::{anyhow, Result};
use sdl2::controller::{Button, GameController};
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
bitflags! {
pub struct Joypad: u8 {
... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/rosettaboy",
"path": "/rs/src/buttons.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>https://github.com/LukeMathWalker/clustering-benchmarks) for extensive benchmarks against `scikit-learn`'s K-means implementation.
mod appx_dbscan;
mod dbscan;
mod gaussian_mixture;
#[allow(clippy::new_ret_no_self)]
mod k_means;
mod optics;
mod utils;
pub use appx_dbscan::*;
pub use dbscan::*;
pub use ga... | code_fim | hard | {
"lang": "rust",
"repo": "Sauro98/linfa",
"path": "/algorithms/linfa-clustering/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sauro98/linfa path: /algorithms/linfa-clustering/src/lib.rs
//! `linfa-clustering` aims to provide pure Rust implementations
//! of popular clustering algorithms.
//!
//! ## The big picture
//!
//! `linfa-clustering` is a crate in the `linfa` ecosystem, a wider effort to
//! bootstrap a toolkit ... | code_fim | hard | {
"lang": "rust",
"repo": "Sauro98/linfa",
"path": "/algorithms/linfa-clustering/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/phf/src/map.rs
/
/
!
An
immutable
map
constructed
at
compile
time
.
use
core
:
:
fmt
;
use
core
:
:
iter
:
:
FusedIterator
;
use
core
:
:
iter
:
:
IntoIterator
;
use
core
:
:
ops
:
:
Index
;
use
core
:
:
slice
;
use
phf_shared
:
:
{
self
HashKe... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/phf/src/map.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>a
K
;
fn
next
(
&
mut
self
)
-
>
Option
<
&
'
a
K
>
{
self
.
iter
.
next
(
)
.
map
(
|
e
|
e
.
0
)
}
fn
size_hint
(
&
self
)
-
>
(
usize
Option
<
usize
>
)
{
self
.
iter
.
size_hint
(
)
}
}
impl
<
'
a
K
V
>
DoubleEndedIterator
for
Keys
<
'
a
K
V
>
{
fn
next_back
(
&
mut
self
)
-
>
Option
<
&
'
a
K
>
{
sel... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/phf/src/map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kbz/beatmap-repo path: /datafiles/m_023_hard.rs
value":2.0,"position":6},{"timing_sec":35.942,"effect":17,"effect_value":2.0,"position":4},{"timing_sec":36.342,"effect":8,"effect_value":2.0,"position":8},{"timing_sec":36.742,"effect":4,"effect_value":0.4,"position":2},{"timing_sec":37.342,"effec... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_023_hard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kbz/beatmap-repo path: /datafiles/m_023_hard.rs
7.542,"effect":52,"effect_value":0.4,"position":8},{"timing_sec":27.542,"effect":52,"effect_value":0.4,"position":2},{"timing_sec":28.342,"effect":8,"effect_value":2.0,"position":5},{"timing_sec":28.742,"effect":17,"effect_value":2.0,"position":3},... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_023_hard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>":2},{"timing_sec":84.743,"effect":4,"effect_value":0.4,"position":7},{"timing_sec":85.743,"effect":4,"effect_value":1.0,"position":9},{"timing_sec":86.343,"effect":4,"effect_value":0.8,"position":1},{"timing_sec":87.34,"effect":52,"effect_value":0.6,"position":7},{"timing_sec":87.34,"effect":52,"effect_v... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_023_hard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZTzTopia/enet-rs path: /src/enet.rs
KET_THROTTLE_INTERVAL = 5000,
ENET_PEER_PACKET_LOSS_SCALE = (1 << 16),
ENET_PEER_PACKET_LOSS_INTERVAL = 10000,
ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024,
ENET_PEER_TIMEOUT_LIMIT = 32,
ENET_PEER_TIMEOUT_MINIMUM = 5000,
ENET_PEER_TIMEOUT_MA... | code_fim | hard | {
"lang": "rust",
"repo": "ZTzTopia/enet-rs",
"path": "/src/enet.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>/** Callback for intercepting received raw UDP packets. Should return 1 to intercept, 0 to ignore, or -1 to propagate an error. */
pub type ENetInterceptCallback = Option<unsafe extern "C" fn(host: *mut ENetHost, event: *mut ENetHost) -> c_int>;
/**
* An ENet host for communicating with peers.
*
* No ... | code_fim | hard | {
"lang": "rust",
"repo": "ZTzTopia/enet-rs",
"path": "/src/enet.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn enet_packet_create(data: *const c_void, dataLength: size_t, flags: enet_uint32) -> *mut ENetPacket;
pub fn enet_packet_destroy(packet: *mut ENetPacket);
pub fn enet_packet_resize(packet: *mut ENetPacket, dataLength: size_t) -> c_int;
pub fn enet_crc32(buffers: *const ENetBuffer, bu... | code_fim | hard | {
"lang": "rust",
"repo": "ZTzTopia/enet-rs",
"path": "/src/enet.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trox667/aoc-2019 path: /day5/rust/src/main.rs
use baselib::io;
fn main() {
let lines: Vec<String> = io::read_file("../input");
if lines.len() > 0 {
let sample = &lines[0];
let sample = string_to_num_vec(sample);
let mut output = vec![];
run(0, &mut sample... | code_fim | hard | {
"lang": "rust",
"repo": "trox667/aoc-2019",
"path": "/day5/rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> s.chars()
.skip(start)
.take(count)
.collect::<String>()
.parse::<i32>()
.unwrap_or(0)
}
fn combined(instruction: i32) -> (i32, i32, i32, i32) {
let i = instruction.to_string();
match i.len() as i32 {
5 => {
let p3 = get_value(&i, 0,... | code_fim | hard | {
"lang": "rust",
"repo": "trox667/aoc-2019",
"path": "/day5/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uuhan/Accepted path: /src/lsp.rs
use std::collections::HashMap;
use std::io::Write;
use std::process;
use anyhow::Context;
use jsonrpc_core;
use jsonrpc_core::Output;
use lsp_types;
use serde;
use serde_json;
use tokio::prelude::*;
use crate::core::Cursor;
#[derive(Debug)]
pub struct LSPCompl... | code_fim | hard | {
"lang": "rust",
"repo": "uuhan/Accepted",
"path": "/src/lsp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some((src, cursor)) = c_rx.recv().await {
let open = lsp_types::DidOpenTextDocumentParams {
text_document: lsp_types::TextDocumentItem {
uri: file_url.clone(),
language_id: extension.clone(),
... | code_fim | hard | {
"lang": "rust",
"repo": "uuhan/Accepted",
"path": "/src/lsp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m0dulo/Wispha path: /src/layouter.rs
use libwispha::core::*;
use std::error;
pub struct LayoutInfo {
pub name: String,
pub version: String
}
/// Layout template
pub trait Layout {
fn info() -> LayoutInfo;
<|fim_suffix|> node_path: &NodePath,
depth: usiz... | code_fim | hard | {
"lang": "rust",
"repo": "m0dulo/Wispha",
"path": "/src/layouter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Display a tree layout relative to `node_path` in `depth` with `keys`.
///
/// `depth`: the `node_path` itself is at depth 0. All its children whose depth <= `depth` will be displayed
/// `keys`: the property keys that will be displayed
/// `hide_key`: if `keys` only has one elemen... | code_fim | medium | {
"lang": "rust",
"repo": "m0dulo/Wispha",
"path": "/src/layouter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run_import(matches: &ArgMatches) -> Result<(), GenericError> {
let input_format = matches.get_one::<String>(FORMAT_ARG_NAME).unwrap();
let input_files = matches
.get_many::<String>(INPUT_ARG_NAME)
.map(|paths| paths.map(|path| BufReader::new(open_file(path, "input"))).collec... | code_fim | hard | {
"lang": "rust",
"repo": "reinterpretcat/vrp",
"path": "/vrp-cli/src/commands/import.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reinterpretcat/vrp path: /vrp-cli/src/commands/import.rs
#[cfg(test)]
#[path = "../../tests/unit/commands/import_test.rs"]
mod import_test;
use super::*;
use std::io::BufReader;
use vrp_cli::extensions::import::import_problem;
use vrp_core::prelude::GenericError;
use vrp_pragmatic::format::prob... | code_fim | hard | {
"lang": "rust",
"repo": "reinterpretcat/vrp",
"path": "/vrp-cli/src/commands/import.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let arr = vec![17, 18, 5, 4, 6, 1];
let expect = vec![18, 6, 6, 6, 1, -1];
assert_eq!(Solution::replace_elements(arr), expect);
}<|fim_prefix|>// repo: pipi32167/LeetCode path: /rust/src/problem_1299.rs
#[derive(Debug)]
struct Solution {}
impl Solution {
pub fn replace_elements(mut arr: Vec<i32>... | code_fim | medium | {
"lang": "rust",
"repo": "pipi32167/LeetCode",
"path": "/rust/src/problem_1299.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pipi32167/LeetCode path: /rust/src/problem_1299.rs
#[derive(Debug)]
struct Solution {}
impl Solution {
pub fn replace_elements(mut arr: Vec<i32>) -> Vec<i32> {
// let mut max = -1;
// arr
// .iter()
// .rev()
// .map(|x| {
// println!("{}", *x);
// le... | code_fim | medium | {
"lang": "rust",
"repo": "pipi32167/LeetCode",
"path": "/rust/src/problem_1299.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test() {
let arr = vec![17, 18, 5, 4, 6, 1];
let expect = vec![18, 6, 6, 6, 1, -1];
assert_eq!(Solution::replace_elements(arr), expect);
}<|fim_prefix|>// repo: pipi32167/LeetCode path: /rust/src/problem_1299.rs
#[derive(Debug)]
struct Solution {}
impl Solution {
pub fn replace_elemen... | code_fim | medium | {
"lang": "rust",
"repo": "pipi32167/LeetCode",
"path": "/rust/src/problem_1299.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma-common/src/canonical_json/value.rs
use std::{collections::BTreeMap, fmt};
use as_variant::as_variant;
use js_int::{Int, UInt};
use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize};
use serde_json::{to_string as to_json_string, Value as JsonValue};
... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-common/src/canonical_json/value.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>variant_impls!(Bool(bool));
variant_impls!(Integer(Int));
variant_impls!(String(String));
variant_impls!(String(&str));
variant_impls!(Array(Vec<CanonicalJsonValue>));
variant_impls!(Object(CanonicalJsonObject));
impl From<UInt> for CanonicalJsonValue {
fn from(value: UInt) -> Self {
Self::In... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-common/src/canonical_json/value.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
input!{
n: usize,
k: usize,
aa: [usize; n],
}
let mut dp = vec![BIT::new(k+1); n+1];
dp[0].add(k+1, 1);
for i in 0..n {
for j in 1..k+2 {
let upper = min(j+aa[i], k+1);
let val = dp[i].sum(upper) + MOD - dp[i].sum(j-1);
... | code_fim | hard | {
"lang": "rust",
"repo": "arizuk/programming-contest-solutions",
"path": "/atcoder/dp/M/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arizuk/programming-contest-solutions path: /atcoder/dp/M/main.rs
#[allow(unused_macros)]
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
let mut next = || { iter.next().unwrap() };
input_inner!{next, $($r)*}
};
($(... | code_fim | hard | {
"lang": "rust",
"repo": "arizuk/programming-contest-solutions",
"path": "/atcoder/dp/M/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let gpioa = dp.GPIOA.split(&mut rcc);
let channels = cortex_m::interrupt::free(move |cs| {
(
gpioa.pa8.into_alternate_af2(cs),
gpioa.pa9.into_alternate_af2(cs),
)
});
let pwm = pwm::tim1(dp.TIM1, channels, &mut rcc, 2... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32f0xx-hal",
"path": "/examples/pwm.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32f0xx-hal path: /examples/pwm.rs
#![deny(unsafe_code)]
#![no_main]
#![no_std]
// Halt on panic
use panic_halt as _;
use cortex_m_rt::entry;
use stm32f0xx_hal as hal;
<|fim_suffix|> if let Some(mut dp) = pac::Peripherals::take() {
// Set up the system clock.
le... | code_fim | medium | {
"lang": "rust",
"repo": "stm32-rs/stm32f0xx-hal",
"path": "/examples/pwm.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(mut dp) = pac::Peripherals::take() {
// Set up the system clock.
let mut rcc = dp.RCC.configure().sysclk(8.mhz()).freeze(&mut dp.FLASH);
let gpioa = dp.GPIOA.split(&mut rcc);
let channels = cortex_m::interrupt::free(move |cs| {
(
... | code_fim | medium | {
"lang": "rust",
"repo": "stm32-rs/stm32f0xx-hal",
"path": "/examples/pwm.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> //wait(txDes = ⊥ ∨ hasTerminated(txDes));
// self.wait_until_operation_has_terminated();
// //return reg
// let reg = self.reg.lock().unwrap();
// *reg
// }
//
// pub fn write(&self, r: Int, v: Int) {
// let sync_message = SYNC { sender_identifier: self.own_id ... | code_fim | hard | {
"lang": "rust",
"repo": "eladschiller/self-stabilizing-cloud",
"path": "/self-stabilizing-communication-abstractions/application/src/scd/algorithm5.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if turn == 30000000 || turn == 2020 {
println!("Turn {} Number {}", turn, number);
}
// Update memory according to last spoken number
if let Some(&(turn_last_spoken, _)) = memory.get(&number) {
memory.insert(number, (turn, Some(turn_last_spoken)));
... | code_fim | hard | {
"lang": "rust",
"repo": "akiross/aoc2020",
"path": "/examples/r15/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akiross/aoc2020 path: /examples/r15/main.rs
use std::collections::HashMap;
type Number = usize;
type Turn = usize;
fn main() {
let input = &[16, 11, 15, 0, 1, 7];
//let input = &[0, 3, 6];
let mut memory: HashMap<Number, (Turn, Option<Turn>)> = HashMap::new();
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "akiross/aoc2020",
"path": "/examples/r15/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while turn <= 30000000 {
match memory.get(&number) {
// This is the memory of spoken numbers: can't recall a number never spoken
None => unreachable!(),
// First time the number was spoken
Some((_, None)) => number = 0,
// Number was ... | code_fim | hard | {
"lang": "rust",
"repo": "akiross/aoc2020",
"path": "/examples/r15/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Self { socket: sck })
}
pub fn receive<V: DeserializeOwned + Debug>(&self) -> Result<V> {
let evp = self.socket.recv_bytes(0)?;
let payload = serde_json::from_slice(&self.socket.recv_bytes(0)?)?;
debug!("receive [{}] {:?}", std::str::from_utf8(&evp)?, payload);
... | code_fim | hard | {
"lang": "rust",
"repo": "baitcenter/arete",
"path": "/src/queue/zeromq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: baitcenter/arete path: /src/queue/zeromq.rs
use std::fmt::Debug;
use serde::{de::DeserializeOwned, ser::Serialize};
use super::super::errors::Result;
pub struct Publisher {
socket: zmq::Socket,
}
impl Publisher {
pub const ALL: &'static str = "*";
pub fn new(host: &str, port: u16... | code_fim | medium | {
"lang": "rust",
"repo": "baitcenter/arete",
"path": "/src/queue/zeromq.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create a new alert
pub fn create_alert(
&mut self,
alert_type: AlertType,
auto_renew: bool,
) -> Result<(), AppError> {
let symbol_res = block_on(api::get_symbol_price(&self.symbol.name))?;
self.symbol_alerts.push(SimpleAlert {
id: utils:... | code_fim | hard | {
"lang": "rust",
"repo": "NajeebTyson/krypto-alert",
"path": "/src/core/alert.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Alert {
/// Create new alert against symbol
pub fn new(pair_name: &str, alert_type: AlertType, auto_renew: bool) -> Result<Self, AppError> {
let symbol_res = block_on(api::get_symbol_price(pair_name))?;
Ok(Alert {
symbol: Symbol::new(pair_name),
symbol_... | code_fim | medium | {
"lang": "rust",
"repo": "NajeebTyson/krypto-alert",
"path": "/src/core/alert.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NajeebTyson/krypto-alert path: /src/core/alert.rs
use crate::core::api;
use crate::core::symbol::Symbol;
use crate::error::AppError;
use crate::types::*;
use crate::utils;
use futures::executor::block_on;
/// Enum for alert types
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AlertTy... | code_fim | hard | {
"lang": "rust",
"repo": "NajeebTyson/krypto-alert",
"path": "/src/core/alert.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>it} else {digit * 2 })
.map(|digit| if digit > 9 {digit - 9} else {digit})
.sum::<u32>() % 10 == 0
}<|fim_prefix|>// repo: nceglia/Rust-Exercism path: /luhn/src/lib.rs
pub fn is_valid(number: &str) -> bool {
if number.chars().filter(|c| c.is_digit(10)).take(2).count() <= 1 ||
... | code_fim | medium | {
"lang": "rust",
"repo": "nceglia/Rust-Exercism",
"path": "/luhn/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nceglia/Rust-Exercism path: /luhn/src/lib.rs
pub fn is_valid(number: &str) -> bool {
if number.chars().filter(|c| c.is_digit(10)).take(2).count() <= 1 ||
<|fim_suffix|>it} else {digit * 2 })
.map(|digit| if digit > 9 {digit - 9} else {digit})
.sum::<u32>() % 10 == 0... | code_fim | hard | {
"lang": "rust",
"repo": "nceglia/Rust-Exercism",
"path": "/luhn/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akmaljalilov/rust_tutorial path: /src/alloc_spec.rs
#[test]
fn test1() {
use std::alloc::{GlobalAlloc, System, Layout};
<|fim_suffix|> fn test() {
let mut v = Vec::new();
v.push(1);
v.push(1);
}
test()
}<|fim_middle|> struct MyAllocator;
unsafe imp... | code_fim | hard | {
"lang": "rust",
"repo": "akmaljalilov/rust_tutorial",
"path": "/src/alloc_spec.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
System.dealloc(ptr, layout);
}
}
#[global_allocator]
static GLOBAL: MyAllocator = MyAllocator;
fn test() {
let mut v = Vec::new();
v.push(1);
v.push(1);
}
test()
}<|fim_p... | code_fim | medium | {
"lang": "rust",
"repo": "akmaljalilov/rust_tutorial",
"path": "/src/alloc_spec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> "-port" => {
let val: usize = match argv.next() {
Some(s) => s.parse().expect("port value err"),
None => return ParseResponse::BadOpt
};
config.port = val as u16;
},
"-names" => {
... | code_fim | hard | {
"lang": "rust",
"repo": "cjschneider2/re_epmd",
"path": "/src/parse_args.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> "-delay_accept" => {
let val: usize = match argv.next() {
Some(s) => s.parse().expect("delay_accept value err"),
None => return ParseResponse::BadOpt
};
config.delay_accept = val;
},
... | code_fim | hard | {
"lang": "rust",
"repo": "cjschneider2/re_epmd",
"path": "/src/parse_args.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cjschneider2/re_epmd path: /src/parse_args.rs
use std::env;
use std::time::Duration;
use epmd::EpmdConfig;
use epmd::EpmdReq;
use usage::display_usage;
pub enum ParseResponse {
Ok,
ShouldExit,
BadOpt,
Call(EpmdReq),
}
pub fn parse_args(config: &mut EpmdConfig) -> ParseResponse... | code_fim | hard | {
"lang": "rust",
"repo": "cjschneider2/re_epmd",
"path": "/src/parse_args.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_quality(&self) -> &Option<String> {
&self.quality
}
pub fn get_price(&self) -> &Option<String> {
&self.price
}
pub fn get_price_change(&self) -> &Option<String> {
&self.price_change
}
}
impl Listing for SkelbiuLtListing {
fn get_url(&self) ... | code_fim | hard | {
"lang": "rust",
"repo": "zexa/diginet-scraper",
"path": "/skelbiu-lt-scraper/src/skelbiu_lt_listing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_views(&self) -> &str {
&self.views
}
pub fn get_updated_at(&self) -> &str {
&self.updated_at
}
pub fn get_liked_amount(&self) -> &str {
&self.liked_amount
}
pub fn get_location(&self) -> &str {
&self.location
}
pub fn get_q... | code_fim | hard | {
"lang": "rust",
"repo": "zexa/diginet-scraper",
"path": "/skelbiu-lt-scraper/src/skelbiu_lt_listing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zexa/diginet-scraper path: /skelbiu-lt-scraper/src/skelbiu_lt_listing.rs
use common_scraper::Listing;
use rocket_okapi::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
pub struct SkelbiuLtListing {
url: String,
id: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "zexa/diginet-scraper",
"path": "/skelbiu-lt-scraper/src/skelbiu_lt_listing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaderNoob/art_gallery_scanner path: /src/main.rs
use async_recursion::async_recursion;
use futures::StreamExt;
use reqwest::{Method, Response};
use std::{
collections::{hash_map::Entry, HashMap},
sync::{Arc, Mutex},
};
const PATH_CHARACTERS: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK... | code_fim | hard | {
"lang": "rust",
"repo": "MaderNoob/art_gallery_scanner",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dir.truncate(dir.len() - 1 - 2 * depth);
}
#[async_recursion]
async fn search_dirs_recursive(
base_directory: String,
cur_dir: String,
max_depth: usize,
cur_depth: Option<usize>,
filesystem: Arc<Mutex<FileSystemEntry>>,
) -> reqwest::Result<bool> {
async fn try_url(
cl... | code_fim | hard | {
"lang": "rust",
"repo": "MaderNoob/art_gallery_scanner",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn prepare_dir_for_search(dir: &mut String, new_char: char, depth: usize) {
dir.push(new_char);
for _ in 0..depth {
dir.push_str("*/");
}
}
fn restore_dir_after_search(dir: &mut String, depth: usize) {
dir.truncate(dir.len() - 1 - 2 * depth);
}
#[async_recursion]
async fn search_... | code_fim | hard | {
"lang": "rust",
"repo": "MaderNoob/art_gallery_scanner",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use std::io::Result;
#[test]
fn duration() {
let metadata = WavMetadata {
frames: 48000,
lpcm_kind: LpcmKind::F32LE,
channels: 1,
samples_per_sec: 48000.0,
list: vec![],
};
... | code_fim | hard | {
"lang": "rust",
"repo": "kurotakazuki/floaout",
"path": "/src/wav/metadata.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kurotakazuki/floaout path: /src/wav/metadata.rs
// File size - 8
reader.read_array::<4>()?;
check_fourcc(reader, "WAVE")?;
// Other chunk
let other_chunk = |reader: &mut R| -> Result<()> {
let chunk_size: u32 = reader.read_le()?;
le... | code_fim | hard | {
"lang": "rust",
"repo": "kurotakazuki/floaout",
"path": "/src/wav/metadata.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn read() -> Result<()> {
let lpcm_kind = LpcmKind::F32LE;
let mut data: &[u8] = &[
0x52, 0x49, 0x46, 0x46, 0x44, 0x62, 0x05, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D,
0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x44, 0xAC, 0x00, 0x0... | code_fim | hard | {
"lang": "rust",
"repo": "kurotakazuki/floaout",
"path": "/src/wav/metadata.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match range3.next() {
Some((found_r, _)) => {
assert_eq!(found_r.end(), 20usize.into());
assert_eq!(found_r.start(), 15usize.into());
}
None => assert!(false),
};
// Iterate in interval in both items are Included ... | code_fim | hard | {
"lang": "rust",
"repo": "willfindlay/rd",
"path": "/src/session/address_space/memory_range.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match range2.next() {
Some((found_r, _)) => {
assert_eq!(found_r.end(), 10usize.into());
assert_eq!(found_r.start(), 0usize.into());
}
None => assert!(false),
};
// MemoryRangeKeys that are greater than or equal t... | code_fim | hard | {
"lang": "rust",
"repo": "willfindlay/rd",
"path": "/src/session/address_space/memory_range.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: willfindlay/rd path: /src/session/address_space/memory_range.rs
use crate::remote_ptr::{RemotePtr, Void};
use core::cmp::Ordering;
use std::{
cmp::{max, min},
fmt::{Display, Formatter, Result},
ops::{Deref, DerefMut},
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, De... | code_fim | hard | {
"lang": "rust",
"repo": "willfindlay/rd",
"path": "/src/session/address_space/memory_range.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swift-school/google-cloud-rs path: /google-cloud-derive/tests/01-simple.rs
use google_cloud::datastore::{FromValue, IntoValue};
use google_cloud::error::ConvertError;
<|fim_suffix|>fn main() {
let foo = Foo {
bar: String::from("test"),
baz: 63,
qux: true,
};
... | code_fim | medium | {
"lang": "rust",
"repo": "swift-school/google-cloud-rs",
"path": "/google-cloud-derive/tests/01-simple.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let foo = Foo {
bar: String::from("test"),
baz: 63,
qux: true,
};
println!("original: {:?}", foo);
let converted = foo.into_value();
println!("converted: {:?}", converted);
let recovered: Result<Foo, ConvertError> = Foo::from_value(converted);
println!... | code_fim | medium | {
"lang": "rust",
"repo": "swift-school/google-cloud-rs",
"path": "/google-cloud-derive/tests/01-simple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let seed = b"12345678901234567890";
let t = Otp::new(seed, 6, Some(Algorithm::SHA1), None, None).unwrap();
assert_eq!(t.hotp(0), "755224");
assert_eq!(t.hotp(1), "287082");
assert_eq!(t.hotp(2), "359152");
assert_eq!(t.hotp(3), "969429");
assert_eq!(t.hotp(4), "338314");
as... | code_fim | medium | {
"lang": "rust",
"repo": "lolo32/lesspass-otp",
"path": "/tests/otp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lolo32/lesspass-otp path: /tests/otp.rs
use lesspass_otp::{Algorithm, Otp};
#[test]
fn totp() {
let seed = b"12345678901234567890";
let t = Otp::new(seed, 8, Some(Algorithm::SHA1), Some(30), Some(0)).unwrap();
assert_eq!(t.totp_from_ts(20000000000), "65353130");
}
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "lolo32/lesspass-otp",
"path": "/tests/otp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sile/fibers_transport path: /src/peer_addr.rs
use std::fmt::Debug;
use std::hash::Hash;
use s<|fim_suffix|>t PeerAddr: Clone + Eq + Hash + Debug {}
impl PeerAddr for () {}
impl PeerAddr for SocketAddr {}<|fim_middle|>td::net::SocketAddr;
/// Peer address.
pub trai | code_fim | easy | {
"lang": "rust",
"repo": "sile/fibers_transport",
"path": "/src/peer_addr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>erAddr for () {}
impl PeerAddr for SocketAddr {}<|fim_prefix|>// repo: sile/fibers_transport path: /src/peer_addr.rs
use std::fmt::Debug;
use std::hash::Hash;
use std::net::SocketAddr;
/// Peer address.
pub trai<|fim_middle|>t PeerAddr: Clone + Eq + Hash + Debug {}
impl Pe | code_fim | easy | {
"lang": "rust",
"repo": "sile/fibers_transport",
"path": "/src/peer_addr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dimkar3000/exercism path: /rust/robot-name/src/lib.rs
#[derive(Default)]
pub struct Robot {
name: String,
}
static ALPHABET: [char; 26] = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
fn gen_na... | code_fim | medium | {
"lang": "rust",
"repo": "Dimkar3000/exercism",
"path": "/rust/robot-name/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Robot {
pub fn new() -> Self {
Robot { name: gen_name() }
}
pub fn name(&self) -> &str {
&self.name
}
pub fn reset_name(&mut self) {
self.name = gen_name();
}
}<|fim_prefix|>// repo: Dimkar3000/exercism path: /rust/robot-name/src/lib.rs
#[derive(Defa... | code_fim | hard | {
"lang": "rust",
"repo": "Dimkar3000/exercism",
"path": "/rust/robot-name/src/lib.rs",
"mode": "spm",
"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.