text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: tari-project/tari path: /infrastructure/tari_script/src/stack.rs
g
// disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/infrastructure/tari_script/src/stack.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tari-project/tari path: /infrastructure/tari_script/src/stack.rs
ex, HexError},
ByteArray,
};
use crate::{
error::ScriptError,
op_codes::{HashValue, ScalarValue},
};
pub const MAX_STACK_SIZE: usize = 255;
#[macro_export]
macro_rules! inputs {
($($input:expr),+) => {{
u... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/infrastructure/tari_script/src/stack.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Hex for ExecutionStack {
fn from_hex(hex: &str) -> Result<Self, HexError>
where Self: Sized {
let b = from_hex(hex)?;
ExecutionStack::from_bytes(&b).map_err(|_| HexError::HexConversionError {})
}
fn to_hex(&self) -> String {
to_hex(&self.to_bytes())
}
}
/... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/infrastructure/tari_script/src/stack.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libp2p/rust-libp2p path: /protocols/relay/src/lib.rs
// Copyright 2019 Parity Technologies (UK) Ltd.
// Copyright 2021 Protocol Labs.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to ... | code_fim | hard | {
"lang": "rust",
"repo": "libp2p/rust-libp2p",
"path": "/protocols/relay/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Everything related to the relay protocol from a client's perspective.
pub mod client {
pub use crate::priv_client::{new, transport::Transport, Behaviour, Connection, Event};
pub mod transport {
pub use crate::priv_client::transport::Error;
}
}
// Check that we can safely cast a `... | code_fim | hard | {
"lang": "rust",
"repo": "libp2p/rust-libp2p",
"path": "/protocols/relay/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub mod transport {
pub use crate::priv_client::transport::Error;
}
}
// Check that we can safely cast a `usize` to a `u64`.
static_assertions::const_assert! {
std::mem::size_of::<usize>() <= std::mem::size_of::<u64>()
}
/// The ID of an outgoing / incoming, relay / destination reque... | code_fim | hard | {
"lang": "rust",
"repo": "libp2p/rust-libp2p",
"path": "/protocols/relay/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rfesi/broot path: /src/verb/verb.rs
use {
super::*,
crate::{
app::{Selection, SelectionType, Status},
errors::ConfError,
keys,
path,
path_anchor::PathAnchor,
},
crossterm::event::{KeyCode, KeyEvent, KeyModifiers},
std::path::PathBuf,
};... | code_fim | hard | {
"lang": "rust",
"repo": "rfesi/broot",
"path": "/src/verb/verb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn internal(internal: Internal) -> Self {
let name = Some(internal.name().to_string());
let execution = VerbExecution::Internal(InternalExecution::from_internal(internal));
let description = VerbDescription::from_text(internal.description().to_string());
Self::new(n... | code_fim | hard | {
"lang": "rust",
"repo": "rfesi/broot",
"path": "/src/verb/verb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mw = ErrorHandlers::new().handler(StatusCode::INTERNAL_SERVER_ERROR, render_500);
let mw = Condition::new(true, mw)
.new_transform(srv.into_service())
.await
.unwrap();
let resp = test::call_service(&mw, TestRequest::default().to_srv_request... | code_fim | hard | {
"lang": "rust",
"repo": "getong/actix-web",
"path": "/src/middleware/condition.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: getong/actix-web path: /src/middleware/condition.rs
//! For middleware documentation, see [`Condition`].
use std::task::{Context, Poll};
use actix_service::{Service, Transform};
use actix_utils::future::Either;
use futures_core::future::LocalBoxFuture;
use futures_util::future::FutureExt as _;... | code_fim | hard | {
"lang": "rust",
"repo": "getong/actix-web",
"path": "/src/middleware/condition.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use actix_service::IntoService;
use actix_utils::future::ok;
use super::*;
use crate::{
dev::{ServiceRequest, ServiceResponse},
error::Result,
http::{
header::{HeaderValue, CONTENT_TYPE},
StatusCode,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "getong/actix-web",
"path": "/src/middleware/condition.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Torkilso/open-ended-coevolution path: /src/mcc/agent/agent_species.rs
use crate::mcc::agent::agent_queue::AgentQueue;
use crate::mcc::agent::mcc_agent::MCCAgent;
#[derive(Clone)]
pub struct AgentSpeciesStatistics {
average_sizes: Vec<f64>,
maximum_sizes: Vec<u32>,
minimum_sizes: Vec... | code_fim | hard | {
"lang": "rust",
"repo": "Torkilso/open-ended-coevolution",
"path": "/src/mcc/agent/agent_species.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn distance(&self, other: &MCCAgent) -> f64 {
self.centroid.distance(other)
}
pub fn save_state(&mut self) {
let last_average_size = self.statistics.average_sizes.last();
if last_average_size.is_some() {
let new_average_increase =
self.a... | code_fim | hard | {
"lang": "rust",
"repo": "Torkilso/open-ended-coevolution",
"path": "/src/mcc/agent/agent_species.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niklasbuechner/parser-experiments path: /slr-parser/src/grammar/follow.rs
use super::First;
use super::Grammar;
use super::GrammarSymbol;
use super::Production;
use super::Token;
use std::collections::HashMap;
pub(crate) struct Follow {
follow_of_non_terminal: HashMap<String, Vec<Token>>,
}... | code_fim | hard | {
"lang": "rust",
"repo": "niklasbuechner/parser-experiments",
"path": "/slr-parser/src/grammar/follow.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
production: &Production,
symbol: &GrammarSymbol,
) -> Vec<GrammarSymbol> {
let position = production
.get_elements()
.iter()
.position(|element| element == symbol);
if position == None {
return Vec::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "niklasbuechner/parser-experiments",
"path": "/slr-parser/src/grammar/follow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tailhook/rotor-http path: /src/client/parser.rs
F(hint) => {
let ln = inp.len();
let m = machine.response_chunk(
&inp[..ln], &mut req, scope);
(m, ProgressiveEOF(hint))
... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/rotor-http",
"path": "/src/client/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> end: usize, scope: &mut Scope<Self::Context>)
-> Intent<Self>
{
use self::ParserImpl::*;
use self::BodyProgress::*;
use super::ResponseError::*;
match self.1 {
ReadHeaders { machine, request, is_head } => {
let (inb, outb) = t... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/rotor-http",
"path": "/src/client/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tailhook/rotor-http path: /src/client/parser.rs
match parse_chunk_size(
&inp[lenstart..lenstart + end + 2])
{
Ok(Complete((_, 0))) => {
inp.remove_range(off..lensta... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/rotor-http",
"path": "/src/client/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakoberzar/advent-of-code-2020 path: /day-01-rust/src/main.rs
const INPUT: &str = include_str!("./../../inputs/day-01.txt");
fn main() {
// Star 1
let result = star1(INPUT);
println!("The product of two numbers multiplied is {}", result);
// Star 2
let result = star2(INPUT)... | code_fim | hard | {
"lang": "rust",
"repo": "jakoberzar/advent-of-code-2020",
"path": "/day-01-rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut low_iter = numbers.iter();
let mut high_iter = numbers.iter().rev();
let mut low = low_iter.next().expect("No numbers in input!");
let mut high = high_iter.next().expect("No numbers in input!");
while low <= high {
let sum = low + high;
if sum == wanted_sum {
... | code_fim | hard | {
"lang": "rust",
"repo": "jakoberzar/advent-of-code-2020",
"path": "/day-01-rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: distransient/specs-physics path: /src/systems/batch.rs
use crate::{nalgebra::RealField, stepper::StepperRes};
use specs::{
AccessorCow, BatchAccessor, BatchController, BatchUncheckedWorld, Dispatcher, RunningTime,
System, World, WriteExpect,
};
use std::{marker::PhantomData, ops::Deref... | code_fim | hard | {
"lang": "rust",
"repo": "distransient/specs-physics",
"path": "/src/systems/batch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> AccessorCow::Ref(&self.accessor)
}
fn setup(&mut self, world: &mut World) {
self.dispatcher.setup(world);
}
}
unsafe impl<N: RealField> Send for PhysicsBatchSystem<'_, '_, N> {}<|fim_prefix|>// repo: distransient/specs-physics path: /src/systems/batch.rs
use crate::{nalgebra... | code_fim | medium | {
"lang": "rust",
"repo": "distransient/specs-physics",
"path": "/src/systems/batch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> RunningTime::VeryLong
}
fn accessor<'c>(&'c self) -> AccessorCow<'s, 'c, Self> {
AccessorCow::Ref(&self.accessor)
}
fn setup(&mut self, world: &mut World) {
self.dispatcher.setup(world);
}
}
unsafe impl<N: RealField> Send for PhysicsBatchSystem<'_, '_, N> {}<... | code_fim | hard | {
"lang": "rust",
"repo": "distransient/specs-physics",
"path": "/src/systems/batch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hudson-ayers/tock path: /boards/components/src/hmac.rs
//! Components for collections of HMACs.
//!
//! Usage
//! -----
//! ```rust
//! let hmac_data_buffer = static_init!([u8; 64], [0; 64]);
//! let hmac_dest_buffer = static_init!([u8; 32], [0; 32]);
//!
//! let mux_hmac = components::... | code_fim | hard | {
"lang": "rust",
"repo": "hudson-ayers/tock",
"path": "/boards/components/src/hmac.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let virtual_hmac_user = static_init_half!(
s.0,
VirtualMuxHmac<'static, A, L>,
VirtualMuxHmac::new(self.mux_hmac, self.key_buffer)
);
let hmac = static_init_half!(
s.1,
capsules::hmac::HmacDriver<'static, VirtualMuxHmac<'... | code_fim | hard | {
"lang": "rust",
"repo": "hudson-ayers/tock",
"path": "/boards/components/src/hmac.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: torresashjian/x path: /examples/my_simple_trigger/src/lib.rs
// Developer Code
use dovetail_derive::trigger_settings;
#[trigger_settings()]
pub struct Settings {
/*
// This is what trigger_settings macro generates
pub setting_foo: String,
pub setting_bar: String,
*/}
/*
// This is what tri... | code_fim | hard | {
"lang": "rust",
"repo": "torresashjian/x",
"path": "/examples/my_simple_trigger/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// Developer code
#[derive(Debug)]
pub struct TriggerInput{
pub name: String,
}
// Generated code
#[derive(Debug)]
pub struct TriggerReply {
}
#[trigger_settings()]
pub struct settings {
my_settings_field: String,
}
// Generated Code ENPOINT OPTION 2
#[no_mangle]
//#[triggger()]
pub fn start... | code_fim | hard | {
"lang": "rust",
"repo": "torresashjian/x",
"path": "/examples/my_simple_trigger/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait GraphicsRenderable {
fn render_graphics(&mut self, engine: &mut GraphicsEngine, context: &RenderContext) -> Result<()>;
}<|fim_prefix|>// repo: maxjoehnk/terminal-ui-rs path: /src/graphics/mod.rs
use crate::{Result, RenderContext};
<|fim_middle|>pub struct GraphicsEngine;
| code_fim | easy | {
"lang": "rust",
"repo": "maxjoehnk/terminal-ui-rs",
"path": "/src/graphics/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxjoehnk/terminal-ui-rs path: /src/graphics/mod.rs
use crate::{Result, RenderContext};
<|fim_suffix|>pub trait GraphicsRenderable {
fn render_graphics(&mut self, engine: &mut GraphicsEngine, context: &RenderContext) -> Result<()>;
}<|fim_middle|>pub struct GraphicsEngine;
| code_fim | easy | {
"lang": "rust",
"repo": "maxjoehnk/terminal-ui-rs",
"path": "/src/graphics/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/noqa.rs
s exempted, don't add any noqa directives.
continue;
}
Some(FileExemption::Codes(codes)) => {
// If the diagnostic is ignored by a global exemption, don't add a noqa directive.
i... | code_fim | hard | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/noqa.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut chars = line.chars();
if chars.next() == Some(c) {
Some(chars.as_str())
} else {
None
}
}
/// Lex the "flake8" prefix of a `noqa` directive.
#[inline]
fn lex_flake8(line: &str) -> Option<&str> {
line.strip_prefix("fla... | code_fim | hard | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/noqa.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let source = "#flake8:noqa";
assert_debug_snapshot!(ParsedFileExemption::try_extract(source));
}
#[test]
fn ruff_exemption_all_no_space() {
let source = "#ruff:noqa";
assert_debug_snapshot!(ParsedFileExemption::try_extract(source));
}
#[test]
fn fl... | code_fim | hard | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/noqa.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
let a = OwnedArray::<f32, _>::zeros(16);
let b = OwnedArray::<f32, _>::zeros(16);
bench.iter(|| a.dot(&b));
}
#[bench]
fn dot_f32_20(bench: &mut test::Bencher)
{
let a = OwnedArray::<f32, _>::zeros(20);
let b = OwnedArray::<f32, _>::zeros(20);
bench.iter(|| a.dot(&b));
}
#[benc... | code_fim | hard | {
"lang": "rust",
"repo": "daniel-vainsencher/rust-ndarray",
"path": "/benches/bench1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daniel-vainsencher/rust-ndarray path: /benches/bench1.rs
#![feature(test)]
#![allow(unused_imports)]
extern crate test;
#[macro_use(s)]
extern crate ndarray;
#[cfg(feature = "rblas")]
extern crate rblas;
#[cfg(feature = "rblas")]
use rblas::matrix::Matrix;
use ndarray::{
OwnedArray,
Ax... | code_fim | hard | {
"lang": "rust",
"repo": "daniel-vainsencher/rust-ndarray",
"path": "/benches/bench1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pest-parser/pest path: /pest/src/unicode/script.rs
, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, ... | code_fim | hard | {
"lang": "rust",
"repo": "pest-parser/pest",
"path": "/pest/src/unicode/script.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const DEVANAGARI: &'static ::ucd_trie::TrieSet = &::ucd_trie::TrieSet {
tree1_level1: &[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
],
tree2_level1: &[
0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... | code_fim | hard | {
"lang": "rust",
"repo": "pest-parser/pest",
"path": "/pest/src/unicode/script.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pest-parser/pest path: /pest/src/unicode/script.rs
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
... | code_fim | hard | {
"lang": "rust",
"repo": "pest-parser/pest",
"path": "/pest/src/unicode/script.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeikabu/runng path: /runng/src/dialer.rs
//! Dialers connect to listeners.
use crate::*;
use runng_derive::{NngGetOpts, NngSetOpts};
use runng_sys::*;
/// Wraps `nng_dialer`. See [nng_dialer](https://nng.nanomsg.org/man/v1.2.2/nng_dialer.5).
#[derive(Debug, NngGetOpts, NngSetOpts)]
#[prefix =... | code_fim | hard | {
"lang": "rust",
"repo": "jeikabu/runng",
"path": "/runng/src/dialer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// "Unsafe" version of `NngDialer`. Merely wraps `nng_dialer` and makes no attempt to manage the underlying resources.
/// May be invalid, close unexpectedly, etc.
#[derive(Debug)]
pub struct UnsafeDialer {
dialer: nng_dialer,
}
impl UnsafeDialer {
pub fn new(dialer: nng_dialer) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "jeikabu/runng",
"path": "/runng/src/dialer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /*let r2d2_config = config.get_table("postgresql")
.and_then(|table| table.get("pool")
.and_then(|p| p.clone().into_table()))
.and_then(|pool| {
let builder = Config::builder();
... | code_fim | hard | {
"lang": "rust",
"repo": "themadprofessor/riostu",
"path": "/src/providers/database.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: themadprofessor/riostu path: /src/providers/database.rs
use iron::prelude::*;
use iron::{typemap, BeforeMiddleware};
use r2d2::{Config, Pool};
use r2d2_postgres::{TlsMode, PostgresConnectionManager};
use std::sync::Arc;
use errors::*;
pub struct Database {
pool: Arc<Pool<PostgresConnectio... | code_fim | hard | {
"lang": "rust",
"repo": "themadprofessor/riostu",
"path": "/src/providers/database.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct EdgeClipperIter<'a> {
edge_iter: PathEdgeIter<'a>,
clip: Rect,
can_cull_to_the_right: bool,
}
impl<'a> EdgeClipperIter<'a> {
pub fn new(path: &'a Path, clip: Rect, can_cull_to_the_right: bool) -> Self {
EdgeClipperIter {
edge_iter: edge_iter(path),
... | code_fim | hard | {
"lang": "rust",
"repo": "RazrFalcon/tiny-skia",
"path": "/src/edge_clipper.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RazrFalcon/tiny-skia path: /src/edge_clipper.rs
let count_x = path_geometry::chop_quad_at_x_extrema(&y_points, &mut mono_x);
for x in 0..=count_x {
let x_points: [Point; 3] = copy_3_points!(mono_x, x * 2);
self.clip_mono_quad(... | code_fim | hard | {
"lang": "rust",
"repo": "RazrFalcon/tiny-skia",
"path": "/src/edge_clipper.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !quick_reject(&bounds, &self.clip) {
let mut mono_y = [Point::zero(); 5];
let count_y = path_geometry::chop_quad_at_y_extrema(&pts, &mut mono_y);
for y in 0..=count_y {
let mut mono_x = [Point::zero(); 5];
let y_points: [Point;... | code_fim | hard | {
"lang": "rust",
"repo": "RazrFalcon/tiny-skia",
"path": "/src/edge_clipper.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use crate::permutation::{make_permutation, write_permutation, read_permutation};
use std::io;
#[test]
fn test_size() {
let perm = make_permutation(10);
assert_eq!(10, perm.len());
}
#[test]
fn test_file() -> io::Result<()> {
le... | code_fim | hard | {
"lang": "rust",
"repo": "gjf2a/flairs33",
"path": "/src/permutation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gjf2a/flairs33 path: /src/permutation.rs
#[cfg(test)]
use rand::thread_rng;
#[cfg(test)]
use rand::seq::SliceRandom;
use std::io;
use std::fs::File;
#[cfg(test)]
use std::io::Write;
use std::io::Read;
#[cfg(test)]
pub fn make_permutation(n: usize) -> Vec<usize> {
let mut rng = thread_rng();... | code_fim | hard | {
"lang": "rust",
"repo": "gjf2a/flairs33",
"path": "/src/permutation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
serial_print!("IRQ: DA:{},TE:{},E:{},S:{} | BL: {} | BR: {}",
self.data_avail_irq,
self.transmitter_empty_irq,
self.error_irq,
self.status_change_irq,
self.baud_rate_divisor_latch,
115200 / (self.baud_rate_divisor as u32));
serial_print!("WL: {} | SB: {} | PAR: {} | DTR: {} | RTS... | code_fim | hard | {
"lang": "rust",
"repo": "ynben/riapyx",
"path": "/src/hw/serial.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.baud_rate_divisor_latch
{
val |= 0x80
}
serial_print!("Read line control: {:02x}", val);
val
}
pub fn write_lc(&mut self, val: u8)
{
serial_print!("Write line control: {:02x}", val);
self.word_length =
match val & 0x3
{
0 => 5,
1 => 6,
2 => 7,
3 => 8,
... | code_fim | hard | {
"lang": "rust",
"repo": "ynben/riapyx",
"path": "/src/hw/serial.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ynben/riapyx path: /src/hw/serial.rs
use std::collections::vec_deque::VecDeque;
use super::super::cpu::CPU;
pub trait SerialDevice<DeviceType>
{
fn new() -> DeviceType;
fn read(&mut self) -> Option<u8>;
fn on_rts_enabled(&mut self);
}
enum SerialIrq
{
DataAvail,
//TransmitterEmpty,
//Err... | code_fim | hard | {
"lang": "rust",
"repo": "ynben/riapyx",
"path": "/src/hw/serial.rs",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neosam/textgame path: /src/main.rs
#![feature(proc_macro)]
#![feature(conservative_impl_trait)]
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
pub mod lang;
pub mod gameerror;
#[macro_use]
pub mod holder;
pub mod base;
pub mod fight;
pub mod item;
pub mod actor;
pub mod room;... | code_fim | medium | {
"lang": "rust",
"repo": "neosam/textgame",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut game = Game::new();
{
let room_ref = game.room_ref;
let mut game_room = game.room_mut(room_ref);
game_room.title = "Test Room".to_string();
game_room.description = "This is a room".to_string();
let mut actor = Actor::default();
ac... | code_fim | medium | {
"lang": "rust",
"repo": "neosam/textgame",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
}
fn insert(&mut self, val: T, index: usize) -> bool {
true
}
fn remove(&mut self, val: T, index: usize) -> bool {
true
}
fn search(&self, val: T) -> bool {
true
}
}<|fim_prefix|>// repo: Pana/rs-data-structures path: /linked_list/src/linked_list.rs... | code_fim | hard | {
"lang": "rust",
"repo": "Pana/rs-data-structures",
"path": "/linked_list/src/linked_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn clear(&self) {
}
fn len(&self) -> usize {
0
}
fn print(&self) {
}
fn insert(&mut self, val: T, index: usize) -> bool {
true
}
fn remove(&mut self, val: T, index: usize) -> bool {
true
}
fn search(&self, val: T) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "Pana/rs-data-structures",
"path": "/linked_list/src/linked_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pana/rs-data-structures path: /linked_list/src/linked_list.rs
use crate::LinkedList;
struct Node<T> {
val: T,
next: Box<Option<Node<T>>>,
}
struct BasicLinkedList<T> {
head: Option<Node<T>>,
}
impl <T> BasicLinkedList<T> {
fn new() -> Self {
BasicLinkedList{
... | code_fim | medium | {
"lang": "rust",
"repo": "Pana/rs-data-structures",
"path": "/linked_list/src/linked_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{} * {} = {}", mat, vec, mat * vec);
}<|fim_prefix|>// repo: SolarLiner/rs-rational path: /examples/complex_algebra.rs
use nalgebra::{Matrix2, Vector2};
use num_complex::Complex;
use num_traits::{One, Zero};
use rational::{Eval, Rational};
fn main() {
<|fim_middle|> let mat: Matrix2<Complex<R... | code_fim | hard | {
"lang": "rust",
"repo": "SolarLiner/rs-rational",
"path": "/examples/complex_algebra.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SolarLiner/rs-rational path: /examples/complex_algebra.rs
use nalgebra::{Matrix2, Vector2};
use num_complex::Complex;
use num_traits::{One, Zero};
use rational::{Eval, Rational};
<|fim_suffix|> let mat: Matrix2<Complex<Rational<_>>> = Matrix2::new(Complex::one(), Complex::zero(), Complex::i(), ... | code_fim | easy | {
"lang": "rust",
"repo": "SolarLiner/rs-rational",
"path": "/examples/complex_algebra.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> proxy.local_partition().get_reporter().report_progress(
&((slow_lineages.len() as u64) + (fast_lineages.len() as u64)).into(),
);
}
// Fast lineages are now slow again
std::mem::swap(&mut slow_... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/necsim-rust",
"path": "/rustcoalescence/algorithms/cuda/src/parallelisation/monolithic.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/necsim-rust path: /rustcoalescence/algorithms/cuda/src/parallelisation/monolithic.rs
use std::{
collections::VecDeque,
convert::TryInto,
num::{NonZeroU64, NonZeroUsize},
};
use anyhow::{Context, Result};
use rust_cuda::{
rustacuda::{
function::{BlockSize, GridS... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/necsim-rust",
"path": "/rustcoalescence/algorithms/cuda/src/parallelisation/monolithic.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Fetch the completion of the tasks
for ((spec_sample, next_event_time), task) in min_spec_sample_buffer
.iter_mut()
.zip(next_event_time_buffer.iter_mut())
.zip(task_list.iter_mut())
... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/necsim-rust",
"path": "/rustcoalescence/algorithms/cuda/src/parallelisation/monolithic.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/drop_through_owned_slice.rs
struct Bar;
static mut DROP_COUNT: usize = 0;
impl Drop for Bar {
fn drop(&mut self) {
unsafe {
DROP_COUNT += 1;
}
}
}
<|fim_suffix|> let b: Box<[Bar]> = vec![Bar, Bar, Bar, Bar].into_boxed_sli... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/miri",
"path": "/tests/pass/drop_through_owned_slice.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let b: Box<[Bar]> = vec![Bar, Bar, Bar, Bar].into_boxed_slice();
assert_eq!(unsafe { DROP_COUNT }, 0);
drop(b);
assert_eq!(unsafe { DROP_COUNT }, 4);
}<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/drop_through_owned_slice.rs
struct Bar;
static mut DROP_COUNT: usize ... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/miri",
"path": "/tests/pass/drop_through_owned_slice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b: Box<[Bar]> = vec![Bar, Bar, Bar, Bar].into_boxed_slice();
assert_eq!(unsafe { DROP_COUNT }, 0);
drop(b);
assert_eq!(unsafe { DROP_COUNT }, 4);
}<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/drop_through_owned_slice.rs
struct Bar;
static mut DROP_COUNT: usize = 0;
<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/miri",
"path": "/tests/pass/drop_through_owned_slice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ummon/AdventOfCode2019 path: /src/day14.rs
use std::collections::HashMap;
#[derive(Debug)]
pub struct Chemical {
quantity: i64,
name: String,
}
type Reactions = HashMap<String, (i64, Vec<Chemical>)>;
fn parse_chemical(input: &str) -> Chemical {
let quantity_and_name: Vec<&str> = i... | code_fim | hard | {
"lang": "rust",
"repo": "Ummon/AdventOfCode2019",
"path": "/src/day14.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input =
"2 VPVL, 7 FWMGM, 2 CXFTF, 11 MNCFX => 1 STKFG
17 NVRVD, 3 JNWZP => 8 VPVL
53 STKFG, 6 MNCFX, 46 VJHF, 81 HVMC, 68 CXFTF, 25 GNMV => 1 FUEL
22 VJHF, 37 MNCFX => 5 FWMGM
139 ORE => 4 NVRVD
144 ORE => 7 JNWZP
... | code_fim | hard | {
"lang": "rust",
"repo": "Ummon/AdventOfCode2019",
"path": "/src/day14.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matklad/fall path: /lang/fall/src/analysis/query/all_syn_rules.rs
use std::collections::hash_map::{self, HashMap};
use std::sync::Arc;
use fall_tree::Text;
use crate::analysis::diagnostics::DiagnosticSink;
use crate::analysis::db::{self, DB};
use crate::syntax::{SynRule};
impl<'f> db::OnceQExe... | code_fim | hard | {
"lang": "rust",
"repo": "matklad/fall",
"path": "/lang/fall/src/analysis/query/all_syn_rules.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result = HashMap::new();
for rule in file.syn_rules() {
if let Some(ident) = rule.name_ident() {
match result.entry(ident.text()) {
hash_map::Entry::Vacant(vacant) => {
vacant.insert(rule);
... | code_fim | hard | {
"lang": "rust",
"repo": "matklad/fall",
"path": "/lang/fall/src/analysis/query/all_syn_rules.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn part2(lines: &[i32]) -> usize {
lines
.array_windows()
.map(|[a, b, c]| a + b + c)
.collect::<Vec<_>>()
.array_windows()
.filter(|[a, b]| b > a)
.count()
}<|fim_prefix|>// repo: akofke/adventofcode path: /aoc/src/y2021/day01.rs
pub fn parse(inp... | code_fim | medium | {
"lang": "rust",
"repo": "akofke/adventofcode",
"path": "/aoc/src/y2021/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akofke/adventofcode path: /aoc/src/y2021/day01.rs
pub fn parse(input: &str) -> Vec<i32> {
input.lines()
.map(|line| str::parse(line).unwrap())
.collect()
}
<|fim_suffix|>pub fn part2(lines: &[i32]) -> usize {
lines
.array_windows()
.map(|[a, b, c]| a + b + c)
... | code_fim | medium | {
"lang": "rust",
"repo": "akofke/adventofcode",
"path": "/aoc/src/y2021/day01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azertyfun/dcpu path: /src/computer.rs
use cpu;
use device::*;
#[derive(Default)]
pub struct Computer {
cpu: cpu::Cpu,
devices: Vec<Box<Device>>,
current_tick: u64,
}
impl Computer {
pub fn new(cpu: cpu::Cpu) -> Computer {
Computer {
cpu: cpu,
..D... | code_fim | medium | {
"lang": "rust",
"repo": "azertyfun/dcpu",
"path": "/src/computer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn tick(&mut self) -> Result<(), cpu::Error> {
try!(self.cpu.tick(&mut self.devices));
for device in self.devices.iter_mut() {
match device.tick(&mut self.cpu, self.current_tick) {
TickResult::Nothing => (),
TickResult::Interrupt(msg) =>... | code_fim | medium | {
"lang": "rust",
"repo": "azertyfun/dcpu",
"path": "/src/computer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>od reporter;
pub mod sourcer;
pub mod styler;
pub mod suiter;
pub mod tester;
pub mod timer;<|fim_prefix|>// repo: iCodeIN/qutonium path: /src/core/mod.rs
pub mod container;
pub mod expecter;
pub mod <|fim_middle|>hooker;
pub mod marker;
pub mod matcher;
pub m | code_fim | easy | {
"lang": "rust",
"repo": "iCodeIN/qutonium",
"path": "/src/core/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/qutonium path: /src/core/mod.rs
pub mod container;
pub mod expecter;
pub mod hooker;
pub mod marker;
pub mod matcher;
pub m<|fim_suffix|>pub mod suiter;
pub mod tester;
pub mod timer;<|fim_middle|>od reporter;
pub mod sourcer;
pub mod styler;
| code_fim | easy | {
"lang": "rust",
"repo": "iCodeIN/qutonium",
"path": "/src/core/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: timdestan/advent-of-code-2020 path: /src/bin/day02p1.rs
use aoc_2020::*;
use regex::Regex;
use std::str::FromStr;
use std::fs;
fn main() -> Result<(), GenError> {
<|fim_suffix|> for line in fs::read_to_string("data/day02input.txt")?.lines() {
for cap in re.captures_iter(line.trim()) {
... | code_fim | medium | {
"lang": "rust",
"repo": "timdestan/advent-of-code-2020",
"path": "/src/bin/day02p1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in fs::read_to_string("data/day02input.txt")?.lines() {
for cap in re.captures_iter(line.trim()) {
// eprintln!("{}, {:?}", line, &cap);
// cap[0] is the whole thing.
let min = usize::from_str(&cap[1])?;
let max = usize::from_str(&cap[2])?;
let required_char = ... | code_fim | medium | {
"lang": "rust",
"repo": "timdestan/advent-of-code-2020",
"path": "/src/bin/day02p1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn convert_l_to_50() {
assert_eq!(roman_to_integer("L").unwrap(), 50);
}
#[test]
fn convert_c_to_100() {
assert_eq!(roman_to_integer("C").unwrap(), 100);
}
#[test]
fn convert_d_to_500() {
assert_e... | code_fim | hard | {
"lang": "rust",
"repo": "riversoforion/numeris-rs",
"path": "/numeris/src/rtoi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: riversoforion/numeris-rs path: /numeris/src/rtoi.rs
use itertools::fold;
use lazy_static::lazy_static;
use regex::Regex;
use super::{ATOMS, Result, RomanNumeral, RomanNumeralError};
/// Converts a string representing a Roman numeral into an integer.
///
/// The input must be a valid Roman nume... | code_fim | hard | {
"lang": "rust",
"repo": "riversoforion/numeris-rs",
"path": "/numeris/src/rtoi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
mod eval;
pub fn run(ast: &NodeRc) {
let _ = eval::script::script_evaluation(&mut runtime::Runtime::new(), ast);
}<|fim_prefix|>// repo: facebook/hermes path: /unsupported/juno/crates/juno_eval/src/lib.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source ... | code_fim | easy | {
"lang": "rust",
"repo": "facebook/hermes",
"path": "/unsupported/juno/crates/juno_eval/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run(ast: &NodeRc) {
let _ = eval::script::script_evaluation(&mut runtime::Runtime::new(), ast);
}<|fim_prefix|>// repo: facebook/hermes path: /unsupported/juno/crates/juno_eval/src/lib.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT ... | code_fim | medium | {
"lang": "rust",
"repo": "facebook/hermes",
"path": "/unsupported/juno/crates/juno_eval/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/hermes path: /unsupported/juno/crates/juno_eval/src/lib.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
<|fim_suffix|>#[allow(dead_code)]
mod... | code_fim | easy | {
"lang": "rust",
"repo": "facebook/hermes",
"path": "/unsupported/juno/crates/juno_eval/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rthomas/lookr path: /lookr-bin/src/main.rs
use clap::{App, AppSettings, Arg};
use lookrd::proto::rpc::lookr_client::LookrClient;
use lookrd::proto::rpc::QueryReq;
use std::error;
use tonic::Request;
static DEFAULT_SERVER: &str = "[::1]:50051";
<|fim_suffix|> let req = Request::new(QueryReq ... | code_fim | hard | {
"lang": "rust",
"repo": "rthomas/lookr",
"path": "/lookr-bin/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let req = Request::new(QueryReq {
secret: String::new(),
query: query.to_string(),
count: 0,
offset: 0,
});
let resp = client.query(req).await?;
for r in &resp.get_ref().results {
println!("{}", r);
}
Ok(())
}<|fim_prefix|>// repo: rthomas... | code_fim | hard | {
"lang": "rust",
"repo": "rthomas/lookr",
"path": "/lookr-bin/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod b {
#[derive(Clone)]
pub enum P {
A
}
}
pub use b::P;
mod c {
use crate::*;
pub struct S(Vec<P>);
}
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/imports/import-after-macro-expand-8.rs
// check-pass
// https://github.com/rust-lang/rust/pull/113242#iss... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/imports/import-after-macro-expand-8.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/imports/import-after-macro-expand-8.rs
// check-pass
// https://github.com/rust-lang/rust/pull/113242#issuecomment-1616034904
mod a {
pub trait P {}
}
pub use a::*;
<|fim_suffix|>mod c {
use crate::*;
pub struct S(Vec<P>);
}
fn main() {}<|fim_middle|... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/imports/import-after-macro-expand-8.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1aim/media-type path: /benches/parse.rs
#![feature(test)]
extern crate mime;
extern crate test;
use mime::MediaType;
use mime::spec::{HttpSpec, Obs};
use test::Bencher;
//TODO check wtf. StrictSpec is SLOWER then HttpSpec<Obs> by MUTCH in the extended case??
#[bench]
fn from_str(b: &mut Ben... | code_fim | hard | {
"lang": "rust",
"repo": "1aim/media-type",
"path": "/benches/parse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn validate_extended(b: &mut Bencher) {
let s = "text/plain; charset=utf-8; foo=bar";
b.bytes = s.as_bytes().len() as u64;
b.iter(|| <MediaType<HttpSpec<Obs>>>::validate(s))
}<|fim_prefix|>// repo: 1aim/media-type path: /benches/parse.rs
#![feature(test)]
extern crate mime;
extern c... | code_fim | hard | {
"lang": "rust",
"repo": "1aim/media-type",
"path": "/benches/parse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonmsawyer/rust-book path: /chapter17/averaged-collection/src/lib.rs
pub struct AveragedCollection {
list: Vec<i32>,
average: f64,
}
impl AveragedCollection {
pub fn new() -> AveragedCollection {
AveragedCollection {
list: vec![],
average: 0.0f64,
... | code_fim | hard | {
"lang": "rust",
"repo": "jonmsawyer/rust-book",
"path": "/chapter17/averaged-collection/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut avg = AveragedCollection::new();
avg.add(1);
avg.add(2);
avg.add(3);
assert_eq!(2.0f64, avg.average());
avg.add(4);
assert_eq!(2.5f64, avg.average());
if let Some(num) = avg.remove() {
... | code_fim | hard | {
"lang": "rust",
"repo": "jonmsawyer/rust-book",
"path": "/chapter17/averaged-collection/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> avg.add(4);
assert_eq!(2.5f64, avg.average());
if let Some(num) = avg.remove() {
assert_eq!(num, 4);
assert_eq!(2.0f64, avg.average());
}
else {
panic!("Some(num) != 4");
}
}
}<|fim_prefix|>// repo: j... | code_fim | hard | {
"lang": "rust",
"repo": "jonmsawyer/rust-book",
"path": "/chapter17/averaged-collection/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main(){
for i in 0..16{
let mut type_params=String::new();
for j in 0..i {
let _=write!(type_params,"L{0},",j);
}
{
let mut buffer=String::new();
let _=writeln!(buffer,"impl<{}Value> PushFront_<Value>",type_params);
le... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/type_level",
"path": "/type_level_values/src/std_types/tuples/tuple_impls/scripts.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rodrimati1992/type_level path: /type_level_values/src/std_types/tuples/tuple_impls/scripts.rs
//////////////////////////////////////////////////////////////////////////////////////////
//// Map_ script
////////////////////////////////////////////////////////////////////////... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/type_level",
"path": "/type_level_values/src/std_types/tuples/tuple_impls/scripts.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn try_from(value: u64) -> Result<Self, Self::Error> {
let dv = if value > u32::MAX as u64 {
DataValue::I64(value as i64)
} else {
DataValue::I32(value as i32)
};
Address::try_from(dv)
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum Address... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/interpreter/src/address.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/interpreter/src/address.rs
//! Virtual Addressing Scheme for the Interpreter
//!
//! The interpreter uses virtual memory addresses for its memory operations. These addresses
//! are obtained by the various `_addr` instructions (e.g. `stack_addr`) and ca... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/interpreter/src/address.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CGMossa/epibox path: /src/game_of_life.rs
//! Source: [Assignment 3](http://prac.im.pwr.wroc.pl/~szwabin/assets/abm/labs/l3.pdf)
struct Grid2D;
type Grid2DIdx = i32;
struct Universe {
grid2d: Grid2D,
}
enum State {
Alive,
Dead,
}
enum Transitions {
Underpopulation,
Overpo... | code_fim | hard | {
"lang": "rust",
"repo": "CGMossa/epibox",
"path": "/src/game_of_life.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_state(x: Grid2DIdx, y: Grid2DIdx, state: State) {
todo!()
}
}
mod patterns {
mod still_life {
fn create_beehive() {
todo!()
}
fn create_loaf() {
todo!()
}
fn create_boat() {
todo!()
}
... | code_fim | hard | {
"lang": "rust",
"repo": "CGMossa/epibox",
"path": "/src/game_of_life.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: natepisarski/Quill path: /libquill/src/atoms/mod.rs
//! The data model for the quill langua<|fim_suffix|>//! the representation of the data.
pub mod atom;
pub mod list;
pub mod table;<|fim_middle|>ge. This branch of libquill deals with
| code_fim | easy | {
"lang": "rust",
"repo": "natepisarski/Quill",
"path": "/libquill/src/atoms/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: natepisarski/Quill path: /libquill/src/atoms/mod.rs
//! The data model for the quill language. This branch of libquill deals with
<|fim_suffix|>b mod atom;
pub mod list;
pub mod table;<|fim_middle|>//! the representation of the data.
pu | code_fim | easy | {
"lang": "rust",
"repo": "natepisarski/Quill",
"path": "/libquill/src/atoms/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>b mod atom;
pub mod list;
pub mod table;<|fim_prefix|>// repo: natepisarski/Quill path: /libquill/src/atoms/mod.rs
//! The data model for the quill langua<|fim_middle|>ge. This branch of libquill deals with
//! the representation of the data.
pu | code_fim | medium | {
"lang": "rust",
"repo": "natepisarski/Quill",
"path": "/libquill/src/atoms/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write_pattern_state(&mut self, key: &str, data: &[u8]) {
for l in &mut self.links {
for step in &mut l.link.lock().unwrap().steps {
let nk = l.name.clone() + "_" + &step.pattern.name();
if &nk == key {
step.pattern.set_stat... | code_fim | hard | {
"lang": "rust",
"repo": "coral/twocb",
"path": "/twocb/src/layers/compositor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coral/twocb path: /twocb/src/layers/compositor.rs
use crate::layers::{self, blending};
use crate::layers::{Link, LinkAllocation, LinkResult};
use crate::producer;
use atomic_counter::AtomicCounter;
use log::error;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::mem;... | code_fim | hard | {
"lang": "rust",
"repo": "coral/twocb",
"path": "/twocb/src/layers/compositor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn render(&mut self, frame: producer::Frame) -> Vec<vecmath::Vector4<f64>> {
let f = Arc::new(frame);
self.buffer.clear();
let mut handles = vec![];
for la in &self.links {
let cid = la.id;
let link = la.link.clone();
let fr... | code_fim | hard | {
"lang": "rust",
"repo": "coral/twocb",
"path": "/twocb/src/layers/compositor.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.