text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> println!("Looking for features within {:?}", rect);
let resp = client.list_features(grpc::RequestOptions::new(), rect);
// Stream of features
let mut stream = resp.drop_metadata();
while let Some(feature) = executor::block_on(stream.next()) {
let feature = feature.expect("featu... | code_fim | hard | {
"lang": "rust",
"repo": "perdumonocle/grpc-rust",
"path": "/grpc-examples/route_guide/src/bin/route_guide_client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(values_slice.len() == next_values.len() * 2);
worker.scope(next_values.len(), |scope, chunk| {
for (i, v) in next_values.chunks_mut(chunk).enumerate() {
scope.spawn(move |_| {
let initial_k = i*chunk;
... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/plonk/commitments/transparent/fri/naive_fri/naive_fri.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<F: PrimeField, I: IOP<F>> FriProofPrototype<F, I> for FRIProofPrototype<F, I> {
fn get_roots(&self) -> Vec< < <I::Tree as IopTree<F> >::TreeHasher as IopTreeHasher<F>>::HashOutput> {
let mut roots = vec![];
roots.push(self.l0_commitment.get_root().clone());
for c in self.i... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/plonk/commitments/transparent/fri/naive_fri/naive_fri.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matter-labs/bellman path: /src/plonk/commitments/transparent/fri/naive_fri/naive_fri.rs
use crate::pairing::ff::PrimeField;
use crate::plonk::commitments::transparent::iop::*;
use crate::plonk::polynomials::*;
use crate::worker::*;
use crate::SynthesisError;
use crate::plonk::commitments::transp... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/plonk/commitments/transparent/fri/naive_fri/naive_fri.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: naokirin/logian path: /src/main.rs
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate tera;
use std::fs::create_dir_all;
use std::env;
mod file;
mod template;
mod schema;
mod json;
mod parser;
mod option;
mod output;
mod plugin;
fn unwrap_result<T, U: std::fmt::Debug>(result: R... | code_fim | hard | {
"lang": "rust",
"repo": "naokirin/logian",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = unwrap_result(file::write(&format!("{}/logs/{}.json", param.schema_dir, param.name)[..], &s[..]));
}
else if args.is_default_log_generate() {
let param = unwrap_result(args.as_default_log_generate());
let _ = unwrap_result(create_dir_all(&format!("{}", param.schema_... | code_fim | hard | {
"lang": "rust",
"repo": "naokirin/logian",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = unwrap_result(file::write(&format!("{}/default.json", param.schema_dir)[..], &s[..]));
}
else if args.is_output() {
let param = unwrap_result(args.as_output());
let schema_config = schema::config::parse(&file::read(&format!("{}/schema.config", param.schema_dir)[..])... | code_fim | hard | {
"lang": "rust",
"repo": "naokirin/logian",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(s) = std::env::var_os(tool.to_uppercase().replace("-", "_")) {
(s.into(), true)
} else {
let mut cache_path = self.cache().root().join(tool);
if let Some(v) = version {
cache_path.push(v);
cache_path.push(tool)... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/cargo-wasi",
"path": "/src/config.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/cargo-wasi path: /src/config.rs
use crate::{Cache, ToolPath};
use anyhow::Result;
use std::path::PathBuf;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
pub struct Config {
cache: Option<Cache>,
verbose: bool,
choice: ColorChoice,
}
imp... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/cargo-wasi",
"path": "/src/config.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Sort pair to interact with the correct pool.
let (is_inverted, base_asset, quote_asset) =
Self::get_upper_currency(input_token, output_token);
// If the pool exists, update pool base_amount and quote_amount by trade amounts
Pools::<T, I>::try_mutate(
... | code_fim | hard | {
"lang": "rust",
"repo": "DiamondNetwork/parallel",
"path": "/pallets/amm/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ownership = base_amount.saturating_mul(quote_amount).integer_sqrt();
let amm_pool = PoolLiquidityAmount {
base_amount,
quote_amount,
pool_assets: currency_asset,
};
*pool_liquidity_amount = Some(amm_pool);
Self::insert_into_l... | code_fim | hard | {
"lang": "rust",
"repo": "DiamondNetwork/parallel",
"path": "/pallets/amm/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DiamondNetwork/parallel path: /pallets/amm/src/lib.rs
truct Pallet<T, I = ()>(_);
#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, RuntimeDebug, PartialOrd, Ord)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct PoolLiquidityAmount<CurrencyId, Balance> {
... | code_fim | hard | {
"lang": "rust",
"repo": "DiamondNetwork/parallel",
"path": "/pallets/amm/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self.cb.is_null() {
unsafe {
trigger_cb();
}
}
}
}
impl Drop for Closure {
fn drop(&mut self) {
self.dealloc_cb();
}
}
fn main() {
let mut closure = Closure::new();
closure.register(|| {
println!("Hello from ... | code_fim | hard | {
"lang": "rust",
"repo": "oblique/c-callback-rust-closure",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oblique/c-callback-rust-closure path: /src/main.rs
use libc::c_void;
use std::mem;
use std::ptr;
extern "C" {
pub fn register_cb(cb: extern "C" fn(_: *mut c_void), arg: *mut c_void);
pub fn trigger_cb();
}
struct Closure {
cb: *mut *mut dyn FnMut(),
}
impl Closure {
fn new() -... | code_fim | hard | {
"lang": "rust",
"repo": "oblique/c-callback-rust-closure",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn trigger(&self) {
if !self.cb.is_null() {
unsafe {
trigger_cb();
}
}
}
}
impl Drop for Closure {
fn drop(&mut self) {
self.dealloc_cb();
}
}
fn main() {
let mut closure = Closure::new();
closure.register(|| {
... | code_fim | hard | {
"lang": "rust",
"repo": "oblique/c-callback-rust-closure",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duvallj/facestuff-rust path: /src/mwi.rs
// Code inspired by https://social.msdn.microsoft.com/Forums/en-US/4f731541-1819-4391-bd66-d026b629b786/detect-keypress-in-the-background
// This code doesn't work, having trouble reading actual keycode from l_param (mostly boilerplate until line 120)
... | code_fim | hard | {
"lang": "rust",
"repo": "duvallj/facestuff-rust",
"path": "/src/mwi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
extern "system" fn hook_fn(code: c_int, w_param: WPARAM, l_param: LPARAM) -> LRESULT {
// See https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644985(v=vs.85)
// for how Windows should be calling this method
eprintln!("code: {} w_param: {} l_param: {... | code_fim | hard | {
"lang": "rust",
"repo": "duvallj/facestuff-rust",
"path": "/src/mwi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hoangpq/edit-text path: /oatie/src/core/compose.rs
} else {
a.next();
b.next();
}
}
AddWithGroup(..) => {
res.push(a.next().unwrap());
if b... | code_fim | hard | {
"lang": "rust",
"repo": "hoangpq/edit-text",
"path": "/oatie/src/core/compose.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !b.is_done() {
res.place(&b.get_head());
res.place_all(&b.rest);
}
if !a.is_done() {
res.place(&a.get_head());
res.place_all(&a.rest);
}
res
}
pub fn compose_add_del<S: Schema>(avec: &AddSpan<S>, bvec: &DelSpan<S>) -> Op<S> {
let mut delres: De... | code_fim | hard | {
"lang": "rust",
"repo": "hoangpq/edit-text",
"path": "/oatie/src/core/compose.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hoangpq/edit-text path: /oatie/src/core/compose.rs
Some(AddText(styles, a_right));
b.next();
} else if b_count > value.char_len() {
styles.extend(&b_styles);
b.head = Some(AddStyles(b_count - value.char_... | code_fim | hard | {
"lang": "rust",
"repo": "hoangpq/edit-text",
"path": "/oatie/src/core/compose.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn calculate_ability(
player_ability: &PlayerAbility,
item_mods: &ItemMods,
current_buff_damage_mod: f32,
current_buff_damage: i32,
current_buff_per_tick_damage: i32,
current_vulnerability_damage_mod: f32,
current_vulnerability_damage: i32,
) -> (i32, DamageType, Vec<Buff>, Vec... | code_fim | hard | {
"lang": "rust",
"repo": "orakulam/pgsim",
"path": "/src/sim/systems.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let item_mods = parser.calculate_item_mods(&vec![], &vec![]);
let (calculated_damage, _, _, calculated_debuffs) =
calculate_ability(&player_ability, &item_mods, 0.0, 0, 0, 0.0, 0);
assert_eq!(calculated_damage, 189);
assert_eq!(calculated_debuffs.len(), 0);
... | code_fim | hard | {
"lang": "rust",
"repo": "orakulam/pgsim",
"path": "/src/sim/systems.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: orakulam/pgsim path: /src/sim/systems.rs
Some(damage) =
current_damage_type_vulnerabilities_to_damage.get(&player_ability.damage_type)
{
current_vulnerability_damage += damage;
}
if let Some(damage_mod) =
current... | code_fim | hard | {
"lang": "rust",
"repo": "orakulam/pgsim",
"path": "/src/sim/systems.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/cloud9/src/input.rs
user_arn: self.user_arn,
permissions: self.permissions,
})
}
}
}
#[doc(hidden)]
pub type CreateEnvironmentMembershipInputOperationOutputAlias =
crate::operation::CreateEnvironmentMember... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/cloud9/src/input.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/cloud9/src/input.rs
nvironment_ec2_input {
/// A builder for [`CreateEnvironmentEc2Input`](crate::input::CreateEnvironmentEc2Input)
#[non_exhaustive]
#[derive(std::default::Default, std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struc... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/cloud9/src/input.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/semaphore path: /general/src/store/normalize.rs
*)$").unwrap();
}
if exception.ty.value().is_empty() {
if let Some(value_str) = exception.value.value_mut() {
let new_values = TYPE_VALUE_RE
.captures(value_str)
... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/semaphore",
"path": "/general/src/store/normalize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/semaphore path: /general/src/store/normalize.rs
s
let has_exceptions = event
.exceptions
.value()
.and_then(|exceptions| exceptions.values.value())
.filter(|values| !values.is_empty())
.is_some();
if has_except... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/semaphore",
"path": "/general/src/store/normalize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_rejects_empty_exception_fields() {
let mut processor = NormalizeProcessor::new(Arc::new(StoreConfig::default()), None);
let mut exception = Annotated::new(Exception {
value: Annotated::new("".to_string().into()),
ty: Annotated::new("".to_string()),
..Defaul... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/semaphore",
"path": "/general/src/store/normalize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..grid.len() {
let mut alive_neighbors = 0;
let width_signed = *width as i32;
let neighbor_positions = [-1, -1 - width_signed, 0 - width_signed, 1 - width_signed, 1, 1 + width_signed, width_signed, -1 + width_signed];
for neighbor_pos in &ne... | code_fim | hard | {
"lang": "rust",
"repo": "Panadero1/game-of-life",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Panadero1/game-of-life path: /src/main.rs
use winit::{
event::{Event, WindowEvent, VirtualKeyCode},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
dpi::PhysicalSize,
};
use pixels::{Pixels, Error, SurfaceTexture};
use winit_input_helper::WinitInputHelper;
use random... | code_fim | hard | {
"lang": "rust",
"repo": "Panadero1/game-of-life",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lovesh/signature-schemes path: /ps/src/pok_sig.rs
// Proof of knowledge of signature
use crate::errors::PSError;
use crate::keys::Verkey;
use crate::signature::Signature;
use crate::{ate_2_pairing, OtherGroup, OtherGroupVec, SignatureGroup, SignatureGroupVec};
use amcl_wrapper::field_elem::{Fie... | code_fim | hard | {
"lang": "rust",
"repo": "lovesh/signature-schemes",
"path": "/ps/src/pok_sig.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let count_msgs = 10;
let (sk, vk) = keygen(count_msgs, "test".as_bytes());
let msgs = FieldElementVector::random(count_msgs);
let sig = Signature::new(msgs.as_slice(), &sk, &vk).unwrap();
assert!(sig.verify(msgs.as_slice(), &vk).unwrap());
let mut revealed_... | code_fim | hard | {
"lang": "rust",
"repo": "lovesh/signature-schemes",
"path": "/ps/src/pok_sig.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fredmorcos/attic path: /Snippets/Rust/ownership.rs
use std::process;
use std::collections::HashMap;
#[derive(Debug)]
struct Band {
a: isize,
id: String,
}
type BandMap<'a> = HashMap<&'a String, &'a Band>;
impl Band {
fn new(id: String) -> Self {
Self { a: 0, id: id }
}
fn from_... | code_fim | hard | {
"lang": "rust",
"repo": "fredmorcos/attic",
"path": "/Snippets/Rust/ownership.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> // for b in &v {
// match m.insert(&b.id, b) {
// None => {}
// Some(_) => return Err(format!("Duplicate key: {}", b.id)),
// }
// }
// Ok((m, v))
// }
// fn bad_single_entry<'a>() -> Result<(BandMap<'a>, Vec<Band>), String> {
// let v = Band::from_json();... | code_fim | hard | {
"lang": "rust",
"repo": "fredmorcos/attic",
"path": "/Snippets/Rust/ownership.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beningodfrey4/rusting path: /vector/src/main.rs
fn main() {
let v: Vec<i32> = Vec::new();
v.push(5);
v.push(6);
v.push(7);
v.push(8);
<|fim_suffix|> for i in &v {
println!("{}", i);
}
for i in &mut v {
*i += 50;
}
enum SpreadsheetCell {
... | code_fim | medium | {
"lang": "rust",
"repo": "beningodfrey4/rusting",
"path": "/vector/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn check_edge(&mut self) {
if self.pos_x < 0.0 || self.pos_x > self.canv_width as f64 - self.radius {
self.vel_x *= -1.0;
}
if self.pos_y < 0.0 || self.pos_y > self.canv_height as f64 - self.radius {
self.vel_y *= -1.0;
}
}
}<|fim_prefix|... | code_fim | medium | {
"lang": "rust",
"repo": "Jack-Sim/rust_ray_casting",
"path": "/src/spare/circle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update(&mut self) {
self.pos_x += self.vel_x;
self.pos_y += self.vel_y;
self.check_edge();
}
pub fn check_edge(&mut self) {
if self.pos_x < 0.0 || self.pos_x > self.canv_width as f64 - self.radius {
self.vel_x *= -1.0;
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "Jack-Sim/rust_ray_casting",
"path": "/src/spare/circle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jack-Sim/rust_ray_casting path: /src/spare/circle.rs
pub struct Circle {
pub pos_x: f64,
pub pos_y: f64,
pub radius: f64,
pub vel_x: f64,
pub vel_y: f64,
canv_width: u32,
canv_height: u32,
}
<|fim_suffix|> pub fn check_edge(&mut self) {
if self.pos_x < 0.0... | code_fim | hard | {
"lang": "rust",
"repo": "Jack-Sim/rust_ray_casting",
"path": "/src/spare/circle.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub trait Indexable3DMut<'a>: Indexable3D<'a> {
type OutputMut: 'a;
fn element_mut(&'a mut self, c: Coords) -> Self::OutputMut;
}
pub trait Fillable<T> {
fn fill(&mut self, default: T);
}<|fim_prefix|>// repo: rxcompile/fluid_simulation_rs path: /src/math/mod.rs
pub mod coords;
pub mod it... | code_fim | medium | {
"lang": "rust",
"repo": "rxcompile/fluid_simulation_rs",
"path": "/src/math/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rxcompile/fluid_simulation_rs path: /src/math/mod.rs
pub mod coords;
pub mod iterator;
pub mod sized_array;
pub mod swapchain;
<|fim_suffix|>}
pub trait Indexable3D<'a>: Sizeable3D {
type Output: 'a;
fn element(&'a self, c: Coords) -> Self::Output;
}
pub trait Indexable3DMut<'a>: Inde... | code_fim | hard | {
"lang": "rust",
"repo": "rxcompile/fluid_simulation_rs",
"path": "/src/math/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = [0; 1024];
loop {
let count = reader.read(&mut buffer)?;
if count == 0 {
break;
}
context.update(&buffer[..count]);
}
Ok(hex::encode(context.finish()))
}<|fim_prefix|>// repo: samfatoks/util-server path: /src/util/hash_util.rs
... | code_fim | medium | {
"lang": "rust",
"repo": "samfatoks/util-server",
"path": "/src/util/hash_util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samfatoks/util-server path: /src/util/hash_util.rs
use ring::digest::{Context, SHA1_FOR_LEGACY_USE_ONLY, SHA256, SHA512};
use std::io::Read;
pub fn sha1_digest(data: &str) -> Result<String, std::io::Error> {
let context = Context::new(&SHA1_FOR_LEGACY_USE_ONLY);
sha_digest(data.as_bytes... | code_fim | hard | {
"lang": "rust",
"repo": "samfatoks/util-server",
"path": "/src/util/hash_util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>d experiment;
mod experiment_store;
mod logger;
mod runner;
mod runner_store;<|fim_prefix|>// repo: Patryk27/cr8r path: /apps/controller/src/system/modules.rs
pub use self::{
attachment::*,
attachment_store::*,
compiler::*,<|fim_middle|>
experiment::*,
experiment_store::*,
logger:... | code_fim | medium | {
"lang": "rust",
"repo": "Patryk27/cr8r",
"path": "/apps/controller/src/system/modules.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> runner_store::*,
};
mod attachment;
mod attachment_store;
mod compiler;
mod experiment;
mod experiment_store;
mod logger;
mod runner;
mod runner_store;<|fim_prefix|>// repo: Patryk27/cr8r path: /apps/controller/src/system/modules.rs
pub use self::{
attachment::*,
attachment_store::*,
compi... | code_fim | medium | {
"lang": "rust",
"repo": "Patryk27/cr8r",
"path": "/apps/controller/src/system/modules.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Patryk27/cr8r path: /apps/controller/src/system/modules.rs
pub use self::{
attachment::*,
attachment_store::*,
compiler::*,
experiment::*,
experiment_store::*,
logger::*,
runner::*,
<|fim_suffix|>d experiment;
mod experiment_store;
mod logger;
mod runner;
mod runner... | code_fim | medium | {
"lang": "rust",
"repo": "Patryk27/cr8r",
"path": "/apps/controller/src/system/modules.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mstruebing/cron-job-as-a-service path: /shared/src/models/user.rs
// modules
use diesel::{prelude::*, AsChangeset, Insertable, Queryable};
use juniper;
// internal
use crate::models::job::Job;
use crate::schema::jobs;
use crate::schema::users;
use crate::Context;
#[derive(Queryable)]
pub struc... | code_fim | medium | {
"lang": "rust",
"repo": "mstruebing/cron-job-as-a-service",
"path": "/shared/src/models/user.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> jobs::dsl::jobs
.filter(jobs::dsl::user_id.eq(self.id))
.load::<Job>(&connection)
.expect("Error loading jobs for user")
}
}<|fim_prefix|>// repo: mstruebing/cron-job-as-a-service path: /shared/src/models/user.rs
// modules
use diesel::{prelude::*, AsChange... | code_fim | hard | {
"lang": "rust",
"repo": "mstruebing/cron-job-as-a-service",
"path": "/shared/src/models/user.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kitao/pyxel path: /crates/pyxel-core/src/tilemap.rs
use std::fmt::Write as _;
use crate::canvas::{Canvas, ToIndex};
use crate::image::SharedImage;
use crate::resource::ResourceItem;
use crate::settings::{RESOURCE_ARCHIVE_DIRNAME, TILEMAP_SIZE};
use crate::types::Tile;
use crate::utils::{as_u32,... | code_fim | hard | {
"lang": "rust",
"repo": "kitao/pyxel",
"path": "/crates/pyxel-core/src/tilemap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn data_ptr(&mut self) -> *mut Tile {
self.canvas.data_ptr()
}
pub fn set(&mut self, x: i32, y: i32, data_str: &[&str]) {
let width = simplify_string(data_str[0]).len() as u32 / 4;
let height = data_str.len() as u32;
let tilemap = Self::new(width, height, s... | code_fim | hard | {
"lang": "rust",
"repo": "kitao/pyxel",
"path": "/crates/pyxel-core/src/tilemap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.cls((0, 0));
}
fn serialize(&self) -> String {
let mut output = String::new();
for y in 0..self.height() {
for x in 0..self.width() {
let tile = self.canvas.read_data(x as usize, y as usize);
let _guard = write!(output, "{:0... | code_fim | hard | {
"lang": "rust",
"repo": "kitao/pyxel",
"path": "/crates/pyxel-core/src/tilemap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bergmann89/asparit path: /src/misc/try_.rs
pub trait Try {
type Ok;
type Error;
fn into_result(self) -> Result<Self::Ok, Self::Error>;
<|fim_suffix|> fn from_error(v: Self::Error) -> Self;
}
impl<T> Try for Option<T> {
type Ok = T;
type Error = ();
fn into_result(se... | code_fim | medium | {
"lang": "rust",
"repo": "Bergmann89/asparit",
"path": "/src/misc/try_.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn into_result(self) -> Result<T, E> {
self
}
fn from_ok(v: T) -> Self {
Ok(v)
}
fn from_error(v: E) -> Self {
Err(v)
}
}<|fim_prefix|>// repo: Bergmann89/asparit path: /src/misc/try_.rs
pub trait Try {
type Ok;
type Error;
fn into_result(sel... | code_fim | hard | {
"lang": "rust",
"repo": "Bergmann89/asparit",
"path": "/src/misc/try_.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn from_error(_: ()) -> Self {
None
}
}
impl<T, E> Try for Result<T, E> {
type Ok = T;
type Error = E;
fn into_result(self) -> Result<T, E> {
self
}
fn from_ok(v: T) -> Self {
Ok(v)
}
fn from_error(v: E) -> Self {
Err(v)
}
}<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "Bergmann89/asparit",
"path": "/src/misc/try_.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[structopt(name = "POLL", short = "p", long = "poll", default_value = "250", help = "the websocket polling interval in milliseconds")]
poll: u64,
#[structopt(name = "SINKS", short = "s", long = "sinks", default_value = "10", help = "The number of sounds that can play at the same ... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/midibase",
"path": "/src/command.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vengarioth/midibase path: /src/command.rs
use structopt::*;
use std::path::PathBuf;
#[derive(Debug, StructOpt)]
pub enum Command {
#[structopt(about = "Lists the available midi devices")]
List,
#[structopt(about = "Runs midibase")]
Run {
#[structopt(name = "CONFIG", sh... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/midibase",
"path": "/src/command.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[structopt(name = "URL", short = "u", long = "url", default_value = "ws://localhost:4444", help = "the url to reach the obs-websocket plugin")]
url: String,
#[structopt(name = "POLL", short = "p", long = "poll", default_value = "250", help = "the websocket polling interval in mil... | code_fim | hard | {
"lang": "rust",
"repo": "Vengarioth/midibase",
"path": "/src/command.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn input() {
parse_instructions(&"set a 1
add a 2
mul a a
mod a 5
snd a
set a 0
rcv a
jgz a -1
set a 1
jgz a -2");
}
#[test]
fn day18ex1() {
assert_eq!(day18_part1(&parse_instructions(&"set a 1
add a 2
mul a a
mod... | code_fim | hard | {
"lang": "rust",
"repo": "HomoCodens/adventofcode_2017_rust",
"path": "/src/day18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HomoCodens/adventofcode_2017_rust path: /src/day18.rs
use std::collections::HashMap;
use regex::Regex;
use std::thread;
use std::sync::mpsc;
use std::time::Duration;
#[derive(Debug, Clone)]
enum Value {
Register(String),
Constant(i64)
}
/*
snd X plays a sound with a frequency equal to ... | code_fim | hard | {
"lang": "rust",
"repo": "HomoCodens/adventofcode_2017_rust",
"path": "/src/day18.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{:?}", instructions);
let (tx, rx) = mpsc::channel();
let mut s = State::new(tx, rx, 0, true);
loop {
//for _k in (0..10) {
let i = instructions[s.ptr].clone();
// I've had it!.clone()
match i.clone() {
Instruction::Rcv(_x) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "HomoCodens/adventofcode_2017_rust",
"path": "/src/day18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Strum355/lsp-types path: /src/lib.rs
change event.
pub event: WorkspaceFoldersChangeEvent,
}
/// The workspace folder change event.
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct WorkspaceFoldersChangeEvent {
/// Th... | code_fim | hard | {
"lang": "rust",
"repo": "Strum355/lsp-types",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Strum355/lsp-types path: /src/lib.rs
on<bool>,
/// The location of this symbol.
pub location: Location,
/// The name of the symbol containing this symbol.
#[serde(skip_serializing_if = "Option::is_none")]
pub container_name: Option<String>,
}
/// A symbol kind.
#[derive(De... | code_fim | hard | {
"lang": "rust",
"repo": "Strum355/lsp-types",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Capabilities specific to the `textDocument/documentColor` and the
/// `textDocument/colorPresentation` request.
#[serde(skip_serializing_if = "Option::is_none")]
pub color_provider: Option<GenericCapability>,
/// Capabilities specific to the `textDocument/rename`
#[serde(skip_... | code_fim | hard | {
"lang": "rust",
"repo": "Strum355/lsp-types",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let commands = r#"
Add 2017-03-08 Holiday
Last 2016-12-31
Last 2017-03-08
Last 2017-03-07
Del
Last 2016-12-31
"#;
let expect = "\
No entries\n\
2017-03-08 Holiday\n\
No entries\n\
... | code_fim | hard | {
"lang": "rust",
"repo": "sakateka/course_project_yellow_test",
"path": "/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sakateka/course_project_yellow_test path: /test.rs
use std::io::Write;
use std::process::{Command, Stdio};
use std::sync::Once;
static START: Once = Once::new();
pub fn setup() {
let mut clang = Command::new("make");
let status = clang.status().expect("Failed to compile!");
let ok ... | code_fim | hard | {
"lang": "rust",
"repo": "sakateka/course_project_yellow_test",
"path": "/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_print() {
let commands = "
Add 2017-01-01 Holiday
Add 2017-03-08 Holiday
Add 2017-1-1 New Year
Add 2017-1-1 New Year
Print
";
let expect = "2017-01-01 Holiday\n\
2017-01-01 New Year\n\
2017-03-08 Holida... | code_fim | hard | {
"lang": "rust",
"repo": "sakateka/course_project_yellow_test",
"path": "/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(color) = self.image.get_pixel_rgb((sprite_x, sprite_y)) {
canvas.set_pixel(x, y, color).ok();
}
}
}
}
}<|fim_prefix|>// repo: Rene-Ulmer/Tropical-Frency path: /src/gfx/sprite.rs
use common::ScreenPosition;
use gfx::ca... | code_fim | hard | {
"lang": "rust",
"repo": "Rene-Ulmer/Tropical-Frency",
"path": "/src/gfx/sprite.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rene-Ulmer/Tropical-Frency path: /src/gfx/sprite.rs
use common::ScreenPosition;
use gfx::canvas::Canvas;
use gfx::Drawable;
use gfx::ImageSource;
/// Single, static image.
pub struct Sprite<'a> {
image: &'a ImageSource,
}
<|fim_suffix|> if let Some(color) = self.image.get_pi... | code_fim | hard | {
"lang": "rust",
"repo": "Rene-Ulmer/Tropical-Frency",
"path": "/src/gfx/sprite.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brockelmore/ethabi path: /ethabi/src/decoder.rs
to bytes32. These values
// are padded with trailing zeros to fill 32 bytes.
let bytes = take_bytes(data, offset, len)?;
let result = DecodeResult { token: Token::FixedBytes(bytes), new_offset: offset + 32 };
Ok(result)
}
ParamType:... | code_fim | hard | {
"lang": "rust",
"repo": "brockelmore/ethabi",
"path": "/ethabi/src/decoder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brockelmore/ethabi path: /ethabi/src/decoder.rs
ement
let result = DecodeResult {
token: Token::Tuple(tokens),
new_offset: if is_dynamic { offset + 32 } else { new_offset },
};
Ok(result)
}
}
}
#[cfg(test)]
mod tests {
use hex_literal::hex;
#[cfg(not(feature = "std"))]
... | code_fim | hard | {
"lang": "rust",
"repo": "brockelmore/ethabi",
"path": "/ethabi/src/decoder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn decode_params_containing_static_tuple() {
let encoded = hex!(
"
0000000000000000000000001111111111111111111111111111111111111111
0000000000000000000000002222222222222222222222222222222222222222
0000000000000000000000000000000000000000000000000000000000000001
00000000000000000... | code_fim | hard | {
"lang": "rust",
"repo": "brockelmore/ethabi",
"path": "/ethabi/src/decoder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uutils/coreutils path: /src/uu/dd/src/conversion_tables.rs
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0... | code_fim | hard | {
"lang": "rust",
"repo": "uutils/coreutils",
"path": "/src/uu/dd/src/conversion_tables.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uutils/coreutils path: /src/uu/dd/src/conversion_tables.rs
, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a,... | code_fim | hard | {
"lang": "rust",
"repo": "uutils/coreutils",
"path": "/src/uu/dd/src/conversion_tables.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const ASCII_TO_IBM_LCASE_TO_UCASE: ConversionTable = [
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0... | code_fim | hard | {
"lang": "rust",
"repo": "uutils/coreutils",
"path": "/src/uu/dd/src/conversion_tables.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ity {
entity,
mouse_button: MouseButton::Right,
})
} else if mouse_button_input.just_pressed(MouseButton::Left) {
pressed_on_ent_events.send(PressedOnEntity {
entity,
... | code_fim | hard | {
"lang": "rust",
"repo": "TheLeonsver1/grand_strategy",
"path": "/src/common/map/systems.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheLeonsver1/grand_strategy path: /src/common/map/systems.rs
use super::input::resources::MouseWorldPosition;
use super::{
data_components::RectFromTransform, events::PressedOnEntity, marker_components::Pickable,
};
use bevy::prelude::*;
pub fn clicked_pickable_entity_system(
mouse_butto... | code_fim | hard | {
"lang": "rust",
"repo": "TheLeonsver1/grand_strategy",
"path": "/src/common/map/systems.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sandy20140407/tikv path: /components/engine_traits/src/metrics_flusher.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
<|fim_suffix|> fn start(&mut self) -> Result<(), io::Error>;
fn stop(&mut self);
}<|fim_middle|>use crate::*;
use std::io;
use std::result::Result;... | code_fim | medium | {
"lang": "rust",
"repo": "sandy20140407/tikv",
"path": "/components/engine_traits/src/metrics_flusher.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn start(&mut self) -> Result<(), io::Error>;
fn stop(&mut self);
}<|fim_prefix|>// repo: sandy20140407/tikv path: /components/engine_traits/src/metrics_flusher.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
<|fim_middle|>use crate::*;
use std::io;
use std::result::Result;... | code_fim | medium | {
"lang": "rust",
"repo": "sandy20140407/tikv",
"path": "/components/engine_traits/src/metrics_flusher.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MightyGoldenOctopus/FlipperTheDolphin path: /PSO/src/particle.rs
use ndarray_rand::RandomExt;
use ndarray::Array1;
use ndarray_rand::rand_distr::Uniform;
use crate::pso::{PSOConstraints, PSOHyperparameters};
use std::cmp::Ordering;
#[derive(Clone)]
pub struct Particle {
pub position: Arra... | code_fim | hard | {
"lang": "rust",
"repo": "MightyGoldenOctopus/FlipperTheDolphin",
"path": "/PSO/src/particle.rs",
"mode": "psm",
"license": "Beerware",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.best_fitness.partial_cmp(&other.best_fitness).unwrap_or(Ordering::Equal)
}
}
impl Particle {
pub fn create_random_particle(constraints: &PSOConstraints) -> Particle {
let mut position = Array1::random((constraints.n_var,), Uniform::new(constraints.var_min, constraints.var_max... | code_fim | medium | {
"lang": "rust",
"repo": "MightyGoldenOctopus/FlipperTheDolphin",
"path": "/PSO/src/particle.rs",
"mode": "spm",
"license": "Beerware",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn random_move(&self, n_var: usize, best_position: &Array1<f64>, hp: &PSOHyperparameters, disabled_particules: &Array1<f64>) -> (Array1<f64>, Array1<f64>) {
let dv1 = hp.social_acceleration * Array1::random((n_var,), Uniform::new(0., 1.));
let dv2 = hp.cognitive_acceleration * Arra... | code_fim | hard | {
"lang": "rust",
"repo": "MightyGoldenOctopus/FlipperTheDolphin",
"path": "/PSO/src/particle.rs",
"mode": "spm",
"license": "Beerware",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let socket_addr = enr.udp_socket().unwrap();
let mut discv5: Discv5 = Discv5::new(enr, enr_key, config).unwrap();
let table_limit: usize = 10;
// Generate `table_limit + 2` nodes in the same subnet.
let enrs: Vec<Enr<CombinedKey>> = (1..=table_limit + 1)
.map(|i| {
... | code_fim | hard | {
"lang": "rust",
"repo": "quilt/discv5",
"path": "/src/discv5/test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"Query found {} peers. Total peers were: {}",
found_nodes.len(),
total_nodes,
);
println!("Nodes expected to pass predicate search {}", num_nodes);
assert!(found_nodes.len() == num_nodes);
}
// The kbuckets table can have maximum 10 nodes in the same /24 ... | code_fim | hard | {
"lang": "rust",
"repo": "quilt/discv5",
"path": "/src/discv5/test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quilt/discv5 path: /src/discv5/test.rs
r_key = CombinedKey::generate_secp256k1();
let config = Discv5Config::default();
let enr = EnrBuilder::new("v4")
.ip(ip)
.udp(port)
.build(&enr_key)
.unwrap();
// transport for buildin... | code_fim | hard | {
"lang": "rust",
"repo": "quilt/discv5",
"path": "/src/discv5/test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>case
)]
include!("spine_bindings.rs");<|fim_prefix|>// repo: jaynus/spine path: /spine-sys/src/ffi.rs
#![allow(
clippy::all,
clippy::<|fim_middle|>pedantic,
non_upper_case_globals,
non_camel_case_types,
non_snake_ | code_fim | medium | {
"lang": "rust",
"repo": "jaynus/spine",
"path": "/spine-sys/src/ffi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> non_camel_case_types,
non_snake_case
)]
include!("spine_bindings.rs");<|fim_prefix|>// repo: jaynus/spine path: /spine-sys/src/ffi.rs
#![allow(
clippy::all,
clippy::<|fim_middle|>pedantic,
non_upper_case_globals,
| code_fim | easy | {
"lang": "rust",
"repo": "jaynus/spine",
"path": "/spine-sys/src/ffi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jaynus/spine path: /spine-sys/src/ffi.rs
#![allow(
clippy::all,
clippy::<|fim_suffix|>case
)]
include!("spine_bindings.rs");<|fim_middle|>pedantic,
non_upper_case_globals,
non_camel_case_types,
non_snake_ | code_fim | medium | {
"lang": "rust",
"repo": "jaynus/spine",
"path": "/spine-sys/src/ffi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niklasha/adventofcode2020 path: /src/day21.rs
use crate::day::*;
use regex::Regex;
use std::collections::{HashMap, HashSet};
pub struct Day21 {}
impl Day for Day21 {
fn tag(&self) -> &str { "21" }
fn part1(&self, input: &dyn Fn() -> Box<dyn io::Read>) {
println!("{:?}", self.p... | code_fim | hard | {
"lang": "rust",
"repo": "niklasha/adventofcode2020",
"path": "/src/day21.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lines = &mut io::BufReader::new(input).lines();
lazy_static! {
static ref RE: Regex = Regex::new("^((.+) )*(.*) \\(contains ((.+), )*(.*)\\)$").unwrap();
}
let foods = lines.map(|l| {
let l = l.unwrap();
let cap = RE.captures(&l).unwr... | code_fim | hard | {
"lang": "rust",
"repo": "niklasha/adventofcode2020",
"path": "/src/day21.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Microsvuln/gamozo-emu path: /src/emulator.rs
// Reset register state
self.registers = other.registers;
// Reset program break
self.break_min = other.break_min;
self.break_current = other.break_current;
self.break_max = other.break_max;
... | code_fim | hard | {
"lang": "rust",
"repo": "Microsvuln/gamozo-emu",
"path": "/src/emulator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match inst.funct3 {
0b000 => {
// BEQ
if rs1 == rs2 {
return Ok(pc.wrapping_add(inst.imm as i64 as u64));
}
}
0b001 => {
... | code_fim | hard | {
"lang": "rust",
"repo": "Microsvuln/gamozo-emu",
"path": "/src/emulator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Microsvuln/gamozo-emu path: /src/emulator.rs
// AUIPC
let inst = Utype::from(inst);
self.set_reg(inst.rd, (inst.imm as i64 as u64).wrapping_add(pc))
}
0b1101111 => {
// JAL
let inst = Jtype::from(inst);
... | code_fim | hard | {
"lang": "rust",
"repo": "Microsvuln/gamozo-emu",
"path": "/src/emulator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Insertable)]
pub struct WishedGame {
pub id: uuid::Uuid,
pub title: String,
pub igdb_id: i32,
pub igdb_info: serde_json::Value,
pub added_on: chrono::NaiveDateTime,
pub user_id: uuid::Uuid,
pub pc_release_date: i64,
}<|f... | code_fim | hard | {
"lang": "rust",
"repo": "smurfpandey/playday",
"path": "/playday/src/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smurfpandey/playday path: /playday/src/models.rs
use super::schema::{game_stores, users, wished_games};
use diesel::{Insertable, Queryable};
use serde::{Deserialize, Serialize};
<|fim_suffix|>#[derive(Debug, Clone, Serialize, Deserialize, Queryable, Insertable)]
pub struct User {
pub id: uu... | code_fim | hard | {
"lang": "rust",
"repo": "smurfpandey/playday",
"path": "/playday/src/models.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> -> B1225_W<VCTR38_SPEC, 9> {
B1225_W::new(self)
}
#[doc = "Bit 10 - B1226"]
#[inline(always)]
#[must_use]
pub fn b1226(&mut self) -> B1226_W<VCTR38_SPEC, 10> {
B1226_W::new(self)
}
#[doc = "Bit 11 - B1227"]
#[inline(always)]
#[must_use]
pub fn b1227... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/gtzc_mpcbb2/vctr38.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l5/src/stm32l552/gtzc_mpcbb2/vctr38.rs
ader - B1219"]
pub type B1219_R = crate::BitReader;
#[doc = "Field `B1219` writer - B1219"]
pub type B1219_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `B1220` reader - B1220"]
pub type B1220... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/gtzc_mpcbb2/vctr38.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>new(((self.bits >> 12) & 1) != 0)
}
#[doc = "Bit 13 - B1229"]
#[inline(always)]
pub fn b1229(&self) -> B1229_R {
B1229_R::new(((self.bits >> 13) & 1) != 0)
}
#[doc = "Bit 14 - B1230"]
#[inline(always)]
pub fn b1230(&self) -> B1230_R {
B1230_R::new(((self.bit... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/gtzc_mpcbb2/vctr38.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: klutzy/rust-encoding path: /src/index/iso_8859_13.rs
// AUTOGENERATED FROM index-iso-8859-13.txt, ORIGINAL COMMENT FOLLOWS:
//
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
//
// For details on index-iso-8859-13.txt see the Encoding Stan... | code_fim | medium | {
"lang": "rust",
"repo": "klutzy/rust-encoding",
"path": "/src/index/iso_8859_13.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> res.render(req.params_mut().remove("id").unwrap());
}
#[tokio::main]
async fn main() {
let router = Router::new().get(index).push(
Router::with_path("user")
.post(index)
.push(Router::with_path("<id>").filter(get()).handle(get_user)),
);
let acceptor = TcpLi... | code_fim | medium | {
"lang": "rust",
"repo": "the-benchmarker/web-frameworks",
"path": "/rust/salvo/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: the-benchmarker/web-frameworks path: /rust/salvo/src/main.rs
use salvo::prelude::*;
use salvo::routing::*;
#[handler]
fn index(res: &mut Response) {
<|fim_suffix|> res.render(req.params_mut().remove("id").unwrap());
}
#[tokio::main]
async fn main() {
let router = Router::new().get(index)... | code_fim | medium | {
"lang": "rust",
"repo": "the-benchmarker/web-frameworks",
"path": "/rust/salvo/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonlamb-gh/oxcc path: /src/dac_mcp4922.rs
//! A driver to interface with the MCP4922 (12-bit, dual channel DAC)
//!
//! This driver was built using [`embedded-hal`] traits.
//!
//! This is a minimal port of the Arduino implementation
//! used in OSCC. You can find the original source here:
//! h... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/oxcc",
"path": "/src/dac_mcp4922.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.