text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>fn range_bench(c: &mut Criterion) {
c.bench_function("lint_test2_range", |b| {
b.iter(|| {
range::foo(
black_box(&mut vec![42; 42069]),
black_box(&vec![42; 42069]),
black_box(42),
)
})
});
}
criterion_group!(b... | code_fim | hard | {
"lang": "rust",
"repo": "flip1995/dirty-bench",
"path": "/benches/lint_test2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: velyan/rust-skia path: /skia-safe/src/effects/matrix_convolution_image_filter.rs
use crate::prelude::*;
use crate::{image_filter::CropRect, image_filters, scalar, IPoint, IRect, ISize, ImageFilter};
use skia_bindings as sb;
use skia_bindings::SkImageFilter;
impl RCHandle<SkImageFilter> {
#[... | code_fim | medium | {
"lang": "rust",
"repo": "velyan/rust-skia",
"path": "/skia-safe/src/effects/matrix_convolution_image_filter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
#[allow(deprecated)]
fn test_tile_mode_naming() {
let _ = TileMode::Clamp;
}
#[deprecated(since = "0.19.0", note = "use image_filters::matrix_convolution")]
#[allow(deprecated)]
#[allow(clippy::too_many_arguments)]
pub fn new<'a>(
kernel_size: impl Into<ISize>,
kernel: &[scalar],
... | code_fim | medium | {
"lang": "rust",
"repo": "velyan/rust-skia",
"path": "/skia-safe/src/effects/matrix_convolution_image_filter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ray-kast/AbsoluteUnity path: /src/aunify/lib.rs
#![feature(generators, generator_trait)]
#[macro_use]
extern crate error_chain; // TODO: this should be able to be removed, somehow
pub mod bind;
pub mod clause;
pub mod env;
pub mod gen_iter;
pub mod list;
pub mod numeric;
pub mod pred;
pub mod ... | code_fim | hard | {
"lang": "rust",
"repo": "ray-kast/AbsoluteUnity",
"path": "/src/aunify/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> PredMismatch(a: RcPred, b: RcPred) {
description("predicate mismatch")
display("predicates {} and {} don't match", a, b)
}
// VarBothSides(var: Var) {
// description("variable on both sides of unify")
// display("unsolvable unify: {} is on both sides", var)
// }
... | code_fim | hard | {
"lang": "rust",
"repo": "ray-kast/AbsoluteUnity",
"path": "/src/aunify/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.id.clone()
}
fn object(&self) -> &'static str {
"line_item"
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TaxAmount {
/// The amount, in %s, of the tax.
pub amount: i64,
/// Whether this tax amount is inclusive or exclusive.
pub inclusive... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/stripe-rs",
"path": "/src/resources/line_item.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wyyerd/stripe-rs path: /src/resources/line_item.rs
// ======================================
// This file was automatically generated.
// ======================================
use crate::ids::InvoiceLineItemId;
use crate::params::{Expandable, Metadata, Object};
use crate::resources::{Currency,... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/stripe-rs",
"path": "/src/resources/line_item.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alanwflood/openbanking-server-rust path: /src/db/models.rs
use super::schema::*;
use crate::db::{Pool, UserRegisterReq};
use crate::errors;
use crate::errors::ServiceError;
use actix_web::web;
use argonautica::{Hasher, Verifier};
use chrono;
use diesel::{prelude::*, PgConnection};
use serde_der... | code_fim | hard | {
"lang": "rust",
"repo": "alanwflood/openbanking-server-rust",
"path": "/src/db/models.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn verify_password(&self, password: &str) -> Result<bool, errors::ServiceError> {
Verifier::default()
.with_hash(&self.hash)
.with_password(password)
.with_secret_key(SECRET_KEY.as_str())
.verify()
.map_err(|err| {
... | code_fim | hard | {
"lang": "rust",
"repo": "alanwflood/openbanking-server-rust",
"path": "/src/db/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("filename: {}", &argv[0]);
println!("arg1: {}", &argv[1]);
println!("arg2: {}", &argv[2]);
}<|fim_prefix|>// repo: Tsuyoshi-Iwanaga/learning_rust path: /003/cmndargs.rs
use std::env;
fn main() {
let argv: Vec<String> = env::args().collect();
let argc = argv.len();
<|fim_middle|> if ... | code_fim | medium | {
"lang": "rust",
"repo": "Tsuyoshi-Iwanaga/learning_rust",
"path": "/003/cmndargs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tsuyoshi-Iwanaga/learning_rust path: /003/cmndargs.rs
use std::env;
fn main() {
let argv: Vec<String> = env::args().collect();
let argc = argv.len();
<|fim_suffix|> println!("filename: {}", &argv[0]);
println!("arg1: {}", &argv[1]);
println!("arg2: {}", &argv[2]);
}<|fim_middle|> if ... | code_fim | medium | {
"lang": "rust",
"repo": "Tsuyoshi-Iwanaga/learning_rust",
"path": "/003/cmndargs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antialize/agrippa path: /examples/verbs_server.rs
use agrippa::runtime::{Priority, Reactor, Result};
use agrippa::tcp::listen;
use agrippa::verbs;
use agrippa::verbs_util;
use log::info;
extern crate simple_logger;
fn main() -> Result<()> {
simple_logger::init().unwrap();
let reactor ... | code_fim | hard | {
"lang": "rust",
"repo": "antialize/agrippa",
"path": "/examples/verbs_server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let buff = conn.recv().await?;
info!("Got message");
verbs::put_buffer(buff).await?;
//r3.device.connect(&addr)?;
//info!("Y");
//r3.device.recv_ping2().await?;
//info!("X");
... | code_fim | hard | {
"lang": "rust",
"repo": "antialize/agrippa",
"path": "/examples/verbs_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct PartOne;
impl Solve<'_> for PartOne {
type Input = BatchFile;
type Solution = usize;
fn solve(input: &Self::Input) -> Result<Self::Solution> {
Ok(input
.passports
.iter()
.filter(|pass| {
FieldName::REQUIRED_FIELDS
... | code_fim | hard | {
"lang": "rust",
"repo": "maxmcc/aoc-2020",
"path": "/src/bin/day04.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxmcc/aoc-2020 path: /src/bin/day04.rs
use anyhow::{bail, ensure};
use aoc::{Error, Parse, Result, Solve};
use parse_display::FromStr;
use std::{collections::HashMap, convert::TryFrom};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, FromStr)]
pub enum FieldName {
#[display("byr")]
B... | code_fim | hard | {
"lang": "rust",
"repo": "maxmcc/aoc-2020",
"path": "/src/bin/day04.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn p3_index(&self) -> usize {
((self.0 >> 30) & 0o777) as usize
}
pub fn p2_index(&self) -> usize {
((self.0 >> 21) & 0o777) as usize
}
pub fn p1_index(&self) -> usize {
((self.0 >> 12) & 0o777) as usize
}
pub fn page_offset(&self) -> usize {
... | code_fim | hard | {
"lang": "rust",
"repo": "Hoshizora96/ailurus",
"path": "/kernel/src/arch/x86_64/memory/address.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hoshizora96/ailurus path: /kernel/src/arch/x86_64/memory/address.rs
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
#[repr(transparent)]
pub struct PhysAddr(u64);
impl PhysAddr {
pub fn new(address: u64) -> Self {
assert_eq!(address & 0xfff8_0000_0000_0000, 0,
... | code_fim | hard | {
"lang": "rust",
"repo": "Hoshizora96/ailurus",
"path": "/kernel/src/arch/x86_64/memory/address.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn p4_index(&self) -> usize {
((self.0 >> 39) & 0o777) as usize
}
pub fn p3_index(&self) -> usize {
((self.0 >> 30) & 0o777) as usize
}
pub fn p2_index(&self) -> usize {
((self.0 >> 21) & 0o777) as usize
}
pub fn p1_index(&self) -> usize {
(... | code_fim | hard | {
"lang": "rust",
"repo": "Hoshizora96/ailurus",
"path": "/kernel/src/arch/x86_64/memory/address.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Den4200/simple-rust-projects path: /adder/src/lib.rs
pub fn add_two(x: i32) -> i32 {
x + 2
}
pub fn add_negatives(x: i32, y: i32) -> i32 {
if x >= 0 || y >= 0 {
panic!("x and y must be less than 0, not {} and/or {}", x, y);
}
x + y
}
#[cfg(test)]
mod tests {
use ... | code_fim | medium | {
"lang": "rust",
"repo": "Den4200/simple-rust-projects",
"path": "/adder/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
#[should_panic(expected = "x and y must be less than 0")]
fn test_add_negatives() {
add_negatives(-1, 32);
}
}<|fim_prefix|>// repo: Den4200/simple-rust-projects path: /adder/src/lib.rs
pub fn add_two(x: i32) -> i32 {
x + 2
}
pub fn add_negatives(x: i32, y: i32) -> i... | code_fim | hard | {
"lang": "rust",
"repo": "Den4200/simple-rust-projects",
"path": "/adder/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let query = WriteQuery::with_org(&bucket, &org);
let result = client.write(point, query).await;
println!("{:?}", result);
}<|fim_prefix|>// repo: xoac/influxdb2 path: /examples/write.rs
use influxdb2::write::WriteQuery;
use influxdb2::Client;
use influxdb_line_protocol::{Field, Point};
use st... | code_fim | hard | {
"lang": "rust",
"repo": "xoac/influxdb2",
"path": "/examples/write.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xoac/influxdb2 path: /examples/write.rs
use influxdb2::write::WriteQuery;
use influxdb2::Client;
use influxdb_line_protocol::{Field, Point};
use std::env;
#[tokio::main]
async fn main() {
let host = env::var("INFLUX_HOST").unwrap_or("http://localhost:9999".into());
let org = env::var("I... | code_fim | medium | {
"lang": "rust",
"repo": "xoac/influxdb2",
"path": "/examples/write.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let constant = graph[constant_idx].state.output_strength;
let max_output = max_input.saturating_sub(constant);
// Now we can go through all the outgoing nodes and remove the ones with a weight that
// is too high.
let mut outgoing = graph.neighb... | code_fim | hard | {
"lang": "rust",
"repo": "MCHPR/MCHPRS",
"path": "/crates/core/src/redpiler/passes/unreachable_output.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MCHPR/MCHPRS path: /crates/core/src/redpiler/passes/unreachable_output.rs
//! # [`UnreachableOutput`]
//!
//! If the side of a comparator in subtract mode is constant, then the maximum output of the
//! comparator is equal to the difference of the maximum side input and the maximum default input... | code_fim | hard | {
"lang": "rust",
"repo": "MCHPR/MCHPRS",
"path": "/crates/core/src/redpiler/passes/unreachable_output.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>atch client.submit(call.clone(), &signer).await {
// Ok(trx_id) => Ok(trx_id.to_string()),
// Err(SubxtErr::Rpc(e)) => {
// // signer.increment_nonce();
// let trx_id = client.submit(call, &signer).await.map_err(|e| {
// println!("error is: {:?}", ... | code_fim | hard | {
"lang": "rust",
"repo": "hsqlu/rs-iost",
"path": "/rpc/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hsqlu/rs-iost path: /rpc/src/lib.rs
// use codec::Encode;
// use core::marker::PhantomData;
// use iost_chain::IostAction;
// use once_cell::sync::Lazy; // sync::OnceCell is thread-safe
// use once_cell::sync::OnceCell; // sync::OnceCell is thread-safe
// use sp_core::{sr25519::Pair, Pair as Tra... | code_fim | hard | {
"lang": "rust",
"repo": "hsqlu/rs-iost",
"path": "/rpc/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!(
"let's make sure bob's inventory grew proportionally \
to the amount of items hatching produced"
);
let starting_inventory = bobstead.inventory.clone();
let new_inventory = Hackstead::fetch(&bobstead).await?.inventory;
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "hackagotchi/backend",
"path": "/src/wormhole/session/item/hatch.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hackagotchi/backend path: /src/wormhole/session/item/hatch.rs
use super::SessSend;
use hcor::{id, item, Item, ItemId};
use std::fmt;
#[derive(Debug)]
pub enum Error {
NoSuch(id::NoSuch),
NotConfigured(Item),
}
use Error::*;
impl From<id::NoSuch> for Error {
fn from(ns: id::NoSuch) ... | code_fim | hard | {
"lang": "rust",
"repo": "hackagotchi/backend",
"path": "/src/wormhole/session/item/hatch.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("time: {:?}", tot_time / (N as u32));
println!("Mean: {:?}", mean(&ts));
println!("Median: {:?} of {} samples", median(&mut ts), ts.len());
println!("Min: {:?}, Max: {:?}", ts[0], ts.last().unwrap());
}<|fim_prefix|>// repo: cxzheng/ndarray-npy path: /tests/stream_perf.rs
use nda... | code_fim | hard | {
"lang": "rust",
"repo": "cxzheng/ndarray-npy",
"path": "/tests/stream_perf.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cxzheng/ndarray-npy path: /tests/stream_perf.rs
use ndarray_npy::NpyOutStreamBuilder;
use std::time::{Duration, Instant};
fn mean(numbers: &Vec<Duration>) -> Duration {
let sum: Duration = numbers.iter().sum();
sum / (numbers.len() as u32)
}
fn median(numbers: &mut Vec<Duration>) -> Du... | code_fim | hard | {
"lang": "rust",
"repo": "cxzheng/ndarray-npy",
"path": "/tests/stream_perf.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut tot_time = Duration::new(0, 0);
for _ in 0..1000 {
let start = Instant::now();
stream.write_slice(&vec).unwrap();
let duration = start.elapsed();
eprintln!("{:?}", duration); //.as_micros());
tot_time += duration;
ts.push(duration);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "cxzheng/ndarray-npy",
"path": "/tests/stream_perf.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (animatable, drawable) in anim_query.iter_mut(&mut world) {
if !animatable.animating && animatable.frame_id % animatable.total_frames == 0 {
animatable.delta_since_change = 0f32;
} else if animatable.delta_since_change >= animatable.frame... | code_fim | hard | {
"lang": "rust",
"repo": "segalll/time-travel-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for drawable in draw_query.iter(&world) {
render_state.add_sprite(drawable.model_matrix(), drawable.texture_id);
}
render_state.update_storage();
match render_state.render() {
Ok(_) => {}
Err(wgpu::SwapChainEr... | code_fim | hard | {
"lang": "rust",
"repo": "segalll/time-travel-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: segalll/time-travel-rs path: /src/main.rs
mod render;
mod systems;
mod input;
use winit::{
event::*,
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use legion::*;
use crate::systems::PrevMove;
fn main() {
env_logger::init();
let event_loop = EventLoop::new... | code_fim | hard | {
"lang": "rust",
"repo": "segalll/time-travel-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asanza/mkm34z7 path: /src/vref/vrefl_trm.rs
#[doc = "Reader of register VREFL_TRM"]
pub type R = crate::R<u8, super::VREFL_TRM>;
#[doc = "Writer for register VREFL_TRM"]
pub type W = crate::W<u8, super::VREFL_TRM>;
#[doc = "Register VREFL_TRM `reset()`'s with value 0x03"]
impl crate::ResetValue ... | code_fim | hard | {
"lang": "rust",
"repo": "asanza/mkm34z7",
"path": "/src/vref/vrefl_trm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `VREFL_SEL`"]
pub type VREFL_SEL_R = crate::R<bool, VREFL_SEL_A>;
impl VREFL_SEL_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> VREFL_SEL_A {
match self.bits {
false => VRE... | code_fim | hard | {
"lang": "rust",
"repo": "asanza/mkm34z7",
"path": "/src/vref/vrefl_trm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stephensong/Formality path: /src/term.rs
s, types and body from a curried `(x : A) => (y : B) => c` expression.
pub fn get_nams_typs_bod(term : &Term) -> (Vec<&Vec<u8>>, Vec<&Term>, &Term) {
let mut term : &Term = term;
let mut nams : Vec<&Vec<u8>> = Vec::new();
let mut typs : Vec<&T... | code_fim | hard | {
"lang": "rust",
"repo": "stephensong/Formality",
"path": "/src/term.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Performs a global parallel reduction step.
pub fn global_reduce_step(term : &mut Term, defs : &Defs, deref : bool) -> bool {
let changed_below = match term {
App{ref mut fun, ref mut arg} => {
let fun = global_reduce_step(fun, defs, deref);
let arg = global_reduce_st... | code_fim | hard | {
"lang": "rust",
"repo": "stephensong/Formality",
"path": "/src/term.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stephensong/Formality path: /src/term.rs
pansion
if deref && global_reduce_step(term, defs, true) {
changed = true;
// If nothing changed, halt
} else {
break;
}
}
changed
}
// Immutable reduce.
pub fn reduced(term : &Term, defs : ... | code_fim | hard | {
"lang": "rust",
"repo": "stephensong/Formality",
"path": "/src/term.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: White-Green/ghfs path: /src/github_filesystem/mod.rs
let FileSystemData { files, children: _, file_cache: _ } = &*resources.read().await;
if let Some(file) = files.get(&ino) {
reply.attr(&Timespec::new(1, 0), &file.attr());
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "White-Green/ghfs",
"path": "/src/github_filesystem/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn create_directory(ino: u64, parent: u64, uid: u32, gid: u32, name: OsString) -> FileData {
let t = time::now().to_timespec();
FileData {
parent,
attr: EditableFileAttr {
ino,
size: 0,
blocks: 0,
atime: std_RwLock::new(t),
... | code_fim | hard | {
"lang": "rust",
"repo": "White-Green/ghfs",
"path": "/src/github_filesystem/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: White-Green/ghfs path: /src/github_filesystem/mod.rs
ome(signal) = signals.next().await {
match signal {
SIGINT | SIGTERM => {
drop(mount_handle.take());
break;
}
_ => unreachable!(),
}
}
handle.close();
... | code_fim | hard | {
"lang": "rust",
"repo": "White-Green/ghfs",
"path": "/src/github_filesystem/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lineCode/lily path: /src/python.rs
use crate::TTS;
use std::path::Path;
use unic_langid::LanguageIdentifier;
use fluent_langneg::negotiate::{negotiate_languages, NegotiationStrategy};
use cpython::{Python, PyList, PyDict, PyString, PythonObject, PyResult, ToPyObject, py_module_initializer, py_fn... | code_fim | hard | {
"lang": "rust",
"repo": "lineCode/lily",
"path": "/src/python.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let in_lang: LanguageIdentifier = input.parse().unwrap();
let available_langs: Vec<LanguageIdentifier> = available.iter().map(|lang_str|{lang_str.parse().unwrap()}).collect();
Ok(negotiate_languages(&[in_lang],&available_langs, None, NegotiationStrategy::Filtering)[0].to_string().into_py_objec... | code_fim | hard | {
"lang": "rust",
"repo": "lineCode/lily",
"path": "/src/python.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexsult/bernard path: /src/entities/relation.rs
use entities::area::Area;
use entities::artist::Artist;
use entities::event::Event;
use entities::instrument::Instrument;
use entities::label::Label;
use entities::place::Place;
use entities::recording::Recording;
use entities::release::Release;
u... | code_fim | hard | {
"lang": "rust",
"repo": "alexsult/bernard",
"path": "/src/entities/relation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn empty() -> Relation {
Relation {
direction: Direction::Backward,
relation_type: String::from(""),
relation_type_id: None,
area: None,
artist: None,
event: None,
instrument: None,
label: None,... | code_fim | hard | {
"lang": "rust",
"repo": "alexsult/bernard",
"path": "/src/entities/relation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: psFried/conrods-game-of-life path: /src/conway/test.rs
use super::*;
#[test]
fn game_should_be_resized_down() {
let mut game = Game{
matrix: vec![
vec![false, false, false, true],
vec![false, false, false, true],
vec![false, false, false, true],
... | code_fim | hard | {
"lang": "rust",
"repo": "psFried/conrods-game-of-life",
"path": "/src/conway/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn game_should_kill_a_cell_with_fewer_than_2_adjacent_live_neighbors() {
let mut game = Game{
matrix: vec![
vec![false, false, false],
vec![false, true, false],
vec![false, true, false]
]
};
game = game.update();
// All cells sho... | code_fim | hard | {
"lang": "rust",
"repo": "psFried/conrods-game-of-life",
"path": "/src/conway/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thopper21/AoC20-RS path: /src/main.rs
mod days;
mod util;
use days::*;
use util::file;
#[allow(dead_code)]
enum Day {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Eleven,
Twelve,
Thirteen,
Fourteen,
Fifteen,
Sixteen,... | code_fim | medium | {
"lang": "rust",
"repo": "thopper21/AoC20-RS",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match day {
Day::One => run_day::<day1::Day1>(1, part),
Day::Two => run_day::<day2::Day2>(2, part),
Day::Three => run_day::<day3::Day3>(3, part),
Day::Four => run_day::<day4::Day4>(4, part),
Day::Five => run_day::<day5::Day5>(5, part),
Day::Six => run_da... | code_fim | hard | {
"lang": "rust",
"repo": "thopper21/AoC20-RS",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Maix0/pixel_engine path: /examples/newton_fractal/src/expr.rs
ken_stream::Token::Ident(w))) if w.len() == 1)
|| matches!(
&next,
Some(Ok(
token_stream::Token::Literal(_) | token_stream::Token::RightParenthesis
... | code_fim | hard | {
"lang": "rust",
"repo": "Maix0/pixel_engine",
"path": "/examples/newton_fractal/src/expr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Maix0/pixel_engine path: /examples/newton_fractal/src/expr.rs
impl Iterator<Item = Result<token_stream::Token<'input>, InvalidToken<'input>>> + 'input,
>,
) -> impl Iterator<Item = Result<token_stream::Token<'input>, InvalidToken<'input>>> + 'input {
let iter = {
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "Maix0/pixel_engine",
"path": "/examples/newton_fractal/src/expr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
mut buf: impl std::fmt::Write,
parent_precedence: Option<u8>,
) -> std::fmt::Result {
use std::fmt::Write;
match self {
Expr::FunctionCall { ident, args } => {
write!(buf, "{ident}(")?;
for arg in args.iter().ta... | code_fim | hard | {
"lang": "rust",
"repo": "Maix0/pixel_engine",
"path": "/examples/newton_fractal/src/expr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let min_x = current_black_tiles_map
.iter()
.map(|(x, _)| x)
.min()
.unwrap();
let max_x = current_black_tiles_map
.iter()
.map(|(x, _)| x)
.max()
.unwrap();
let min_y = current_black_ti... | code_fim | hard | {
"lang": "rust",
"repo": "myOwn12345678/AdventOfCode2020-Rust",
"path": "/src/day24.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: myOwn12345678/AdventOfCode2020-Rust path: /src/day24.rs
// --- Day 24: Lobby Layout ---
// Your raft makes it to the tropical island; it turns out that the small crab was an excellent
// navigator. You make your way to the resort.
//
// As you enter the lobby, you discover a small problem: the f... | code_fim | hard | {
"lang": "rust",
"repo": "myOwn12345678/AdventOfCode2020-Rust",
"path": "/src/day24.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for m in 1..10 {
println!("{:2}! = {}", m, fact(m));
}
}<|fim_prefix|>// repo: fifth-postulate/rustfest.zurich path: /resources/snippets/factorial.rs
pub fn fact(m: u64) -> u64 {
(1..m)
.map(|n| n + 1)
.fold(1u64, |acc, n| acc * n)
}
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "fifth-postulate/rustfest.zurich",
"path": "/resources/snippets/factorial.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fifth-postulate/rustfest.zurich path: /resources/snippets/factorial.rs
pub fn fact(m: u64) -> u64 {
(1..m)
.map(|n| n + 1)
.fold(1u64, |acc, n| acc * n)
}
<|fim_suffix|> for m in 1..10 {
println!("{:2}! = {}", m, fact(m));
}
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "fifth-postulate/rustfest.zurich",
"path": "/resources/snippets/factorial.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Runs `f` with mutable access to the global executor.
pub fn with_global_executor<F, R>(f: F) -> R
where
F: FnOnce(&mut Executor) -> R,
{
Self::RUNTIME.with(move |rt| {
if !rt.enabled.get() {
panic!("Runtime is disabled")
}
... | code_fim | hard | {
"lang": "rust",
"repo": "fgindraud/star",
"path": "/src/runtime.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fgindraud/star path: /src/runtime.rs
use crate::executor::{spawn, Executor};
use crate::reactor::Reactor;
use crate::utils::make_noop_waker;
use std::cell::{Cell, RefCell};
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
/// Main runtime structure.
/// I... | code_fim | hard | {
"lang": "rust",
"repo": "fgindraud/star",
"path": "/src/runtime.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
F: FnOnce() -> R,
{
Self::RUNTIME.with(|rt| {
if rt.enabled.get() {
panic!("global runtime already enabled")
}
rt.enabled.set(true);
let r = f();
if !rt.enabled.get() {
panic!("globa... | code_fim | hard | {
"lang": "rust",
"repo": "fgindraud/star",
"path": "/src/runtime.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cleverhero/Graphics-engine path: /src/main.rs
#[macro_use]
extern crate glium;
extern crate image;
extern crate glutin;
extern crate cgmath;
extern crate rusttype;
<|fim_suffix|> let display = glium::glutin::WindowBuilder::new().
with_depth_buffer(24).
... | code_fim | hard | {
"lang": "rust",
"repo": "cleverhero/Graphics-engine",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use glium::{DisplayBuild, Surface};
const DEFOULD_WINDOW_WIDTH: u32 = 800;
const DEFOULD_WINDOW_HEIGHT: u32 = 600;
fn main() {
let display = glium::glutin::WindowBuilder::new().
with_depth_buffer(24).
with_dimensions(DEFOUL... | code_fim | medium | {
"lang": "rust",
"repo": "cleverhero/Graphics-engine",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen(js_name = changeFile)]
pub fn change_file(&self, params: IChangeFileParams) -> Result<(), Error> {
let params: ChangeFileParams =
serde_wasm_bindgen::from_value(params.into()).map_err(into_error)?;
self.inner.change_file(params).map_err(into_error)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_wasm/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen(js_name = formatRange)]
pub fn format_range(&self, params: IFormatRangeParams) -> Result<JsValue, Error> {
let params: FormatRangeParams =
serde_wasm_bindgen::from_value(params.into()).map_err(into_error)?;
let result = self.inner.format_range(params).map... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_wasm/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rome/tools path: /crates/rome_wasm/src/lib.rs
use js_sys::Error;
use wasm_bindgen::prelude::*;
use rome_service::workspace::{
self, ChangeFileParams, CloseFileParams, FixFileParams, FormatFileParams, FormatOnTypeParams,
FormatRangeParams, GetControlFlowGraphParams, GetFileContentParams,... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_wasm/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.w
}
}
impl W {
#[doc = "Bits 0:31 - Write a value to block quiddikey/PUF all index."]
#[inline(always)]
pub fn key_block(&mut self) -> KEY_BLOCK_W {
KEY_BLOCK_W { w: self }
}
}<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/syscon/key_block.rs
#[doc = "Writer for ... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/syscon/key_block.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/syscon/key_block.rs
#[doc = "Writer for register KEY_BLOCK"]
pub type W = crate::W<u32, super::KEY_BLOCK>;
#[doc = "Register KEY_BLOCK `reset()`'s with value 0x3cc3_5aa5"]
impl crate::ResetValue for super::KEY_BLOCK {
type Type =<|fim_suffix|> self.w
}
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/syscon/key_block.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonathansc/linprog path: /src/solver/mod.rs
#[cfg(test)]
mod tests;
use std::collections::HashMap;
fn is_optimal(tableau: &Vec<Vec<f64>>) -> bool {
return !tableau[0][..tableau[0].len() - 1].iter().any(|&x| x > 0f64);
}
fn is_unbounded(tableau: &Vec<Vec<f64>>, pivot_column: usize) -> bool... | code_fim | hard | {
"lang": "rust",
"repo": "jonathansc/linprog",
"path": "/src/solver/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn prepare_phase_two(
tableau: &mut Vec<Vec<f64>>,
mut phase_two_objective_function: Vec<f64>,
number_artificial_variables: usize,
) {
// Calculate phase two objective function
let last_index = phase_two_objective_function.len() - 1;
for variable in 0..phase_two_objective_function.... | code_fim | hard | {
"lang": "rust",
"repo": "jonathansc/linprog",
"path": "/src/solver/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AbdullahHalari/Rust_Program path: /assignment1/q12/src/main.rs
use std::io;
fn main() {
<|fim_suffix|> let mut to_print = String::new();
io::stdin().read_line(&mut to_print)
.expect("failed to read line");
println!("{}", to_print);
}<|fim_middle|> println!("what do you wa... | code_fim | easy | {
"lang": "rust",
"repo": "AbdullahHalari/Rust_Program",
"path": "/assignment1/q12/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut to_print = String::new();
io::stdin().read_line(&mut to_print)
.expect("failed to read line");
println!("{}", to_print);
}<|fim_prefix|>// repo: AbdullahHalari/Rust_Program path: /assignment1/q12/src/main.rs
use std::io;
fn main() {
<|fim_middle|> println!("what do you wa... | code_fim | easy | {
"lang": "rust",
"repo": "AbdullahHalari/Rust_Program",
"path": "/assignment1/q12/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AbdullahHalari/Rust_Program path: /assignment1/q12/src/main.rs
use std::io;
fn main() {
println!("what do you want to write?");
<|fim_suffix|> println!("{}", to_print);
}<|fim_middle|> let mut to_print = String::new();
io::stdin().read_line(&mut to_print)
.expect("failed ... | code_fim | medium | {
"lang": "rust",
"repo": "AbdullahHalari/Rust_Program",
"path": "/assignment1/q12/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Perform ray-triangle intersection test
// - transform triangle vertices to ray coordinate space
// -- translate vertices based on ray origin
let mut p0t = *p0 - Vector3f::from(ray.o);
let mut p1t = *p1 - Vector3f::from(ray.o);
let mut p2t = *p2 - Vector3f... | code_fim | hard | {
"lang": "rust",
"repo": "abusch/rustracer",
"path": "/rustracer-core/src/shapes/mesh.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abusch/rustracer path: /rustracer-core/src/shapes/mesh.rs
= mesh.object_to_world.swaps_handedness();
let tri = Triangle {
mesh,
v_start_index: tri_number * 3,
reverse_orientation,
swaps_handedness,
};
tri_mesh_bytes::add(::s... | code_fim | hard | {
"lang": "rust",
"repo": "abusch/rustracer",
"path": "/rustracer-core/src/shapes/mesh.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abusch/rustracer path: /rustracer-core/src/shapes/mesh.rs
[self.v(0)], uv[self.v(1)], uv[self.v(2)]]
} else {
[
Point2f::new(0.0, 0.0),
Point2f::new(1.0, 0.0),
Point2f::new(1.0, 1.0),
]
}
}
}
impl Shape ... | code_fim | hard | {
"lang": "rust",
"repo": "abusch/rustracer",
"path": "/rustracer-core/src/shapes/mesh.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: viruscamp/rust-play path: /concurrent/src/main.rs
#![feature(once_cell)]
use std::{borrow::{Borrow, BorrowMut}, cell::Cell, fmt::Display, rc::Rc, time::Duration};
use std::thread::{JoinHandle, ThreadId};
use std::sync::{Arc, Mutex, mpsc};
use std::ops::Deref;
use std::lazy::SyncLazy;
use std::c... | code_fim | hard | {
"lang": "rust",
"repo": "viruscamp/rust-play",
"path": "/concurrent/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::sleep(Duration::new(3, 0));
let a: i32 = *DATA.lock().unwrap();
println!("end a={}", a);
}
fn test7_message_channel() {
// 结果消息
let (tx1, rx1) = mpsc::channel::<i32>();
// 启动消息
let (tx2, rx2) = mpsc::channel::<i32>();
let arx2 = Arc::new(Mutex::new(rx2));
fo... | code_fim | hard | {
"lang": "rust",
"repo": "viruscamp/rust-play",
"path": "/concurrent/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snsvrno/platform-lp-rs path: /src/architecture.rs
use Platform;
/// Architecture Partial, designed for 'fuzzy' comparisons.
///
/// ```rust
/// use platform_lp::{ Platform, Architecture};
///
/// let the_platform = Platform::get_user_platform();
/// # let the_platform = Platform::Win64;
/// a... | code_fim | medium | {
"lang": "rust",
"repo": "snsvrno/platform-lp-rs",
"path": "/src/architecture.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match (self, other) {
(Architecture::X64, Platform::Nix64) => true,
(Architecture::X32, Platform::Nix32) => true,
(Architecture::X64, Platform::Win64) => true,
(Architecture::X32, Platform::Win32) => true,
(Architecture::X64, Platform::Ma... | code_fim | medium | {
"lang": "rust",
"repo": "snsvrno/platform-lp-rs",
"path": "/src/architecture.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>et(x, y)).max().unwrap_or(0);
let right = (x + 1..input.width).into_iter().map(|x| input.get(x, y)).max().unwrap_or(0);
let down = (y + 1..input.height).into_iter().map(|y| input.get(x, y)).max().unwrap_or(0);
if current > up || current > left || current > right || c... | code_fim | hard | {
"lang": "rust",
"repo": "FreeCX/advent-of-code",
"path": "/2022/day08/src/part_one.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FreeCX/advent-of-code path: /2022/day08/src/part_one.rs
use crate::types;
pub fn process(input: &types::Data) -> u16 {
let mut total_count = 2 * (input.width as u16 + input.height as u16 - 2);
for y in 1..input.height - 1 {
for x in 1..i<|fim_suffix|>get(x, y)).max().unwr... | code_fim | hard | {
"lang": "rust",
"repo": "FreeCX/advent-of-code",
"path": "/2022/day08/src/part_one.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ExcavateResult(i32, Option<Building>, (u32, u32)),
ClearExcavate,
ClearBuilding,
UpdateBuildings,
UpdateGrid,
SetBuilding((u32, u32), Building),
RequestQuit,
Quit,
}
pub enum AudioMessage {
Build,
}<|fim_prefix|>// repo: SolidTux/epoch-wars-client-rs path: /src/messag... | code_fim | medium | {
"lang": "rust",
"repo": "SolidTux/epoch-wars-client-rs",
"path": "/src/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SolidTux/epoch-wars-client-rs path: /src/message.rs
use super::game::Building;
#[derive(Debug)]
pub enum FromGuiMessage {
Build((u32, u32), Building),
Excavate(<|fim_suffix|> UpdateGrid,
SetBuilding((u32, u32), Building),
RequestQuit,
Quit,
}
pub enum AudioMessage {
Bui... | code_fim | hard | {
"lang": "rust",
"repo": "SolidTux/epoch-wars-client-rs",
"path": "/src/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mucks/astra-rust path: /astra-model/src/model/body.rs
use super::*;
use std::collections::HashMap;
#[derive(Debug, Default)]
#[cfg_attr(feature = "godot", derive(gdnative::ToVariant))]
pub struct Body {
pub features: BodyFeatures,
pub center_of_mass: Vector3,
#[cfg(not(feature = "go... | code_fim | medium | {
"lang": "rust",
"repo": "mucks/astra-rust",
"path": "/astra-model/src/model/body.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Body {
features: body.features.into(),
center_of_mass: body.centerOfMass.into(),
joints: convert_joints(body.joints),
hand_poses: 0,
id: body.id,
status: body.status.into(),
}
}
}<|fim_prefix|>// repo: mucks/astra-... | code_fim | medium | {
"lang": "rust",
"repo": "mucks/astra-rust",
"path": "/astra-model/src/model/body.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twe4ked/mandelbrot-set path: /src/main.rs
use mandelbrot_set::buffer::Buffer;
use mandelbrot_set::MandelbrotSet;
const WIDTH: usize = 1400;
const HEIGHT: usize = 800;
fn main() {
let mut buffer = Buffer::new(WIDTH, HEIGHT);
<|fim_suffix|> use png::{BitDepth, ColorType, Encoder};
us... | code_fim | hard | {
"lang": "rust",
"repo": "twe4ked/mandelbrot-set",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use png::{BitDepth, ColorType, Encoder};
use std::fs::File;
use std::io::BufWriter;
use std::path::Path;
let path = Path::new(r"out.png");
let file = File::create(path).unwrap();
let w = BufWriter::new(file);
let mut encoder = Encoder::new(w, WIDTH as u32, HEIGHT as u32);... | code_fim | hard | {
"lang": "rust",
"repo": "twe4ked/mandelbrot-set",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silkworm-rs/silkworm path: /silkworm_syn/src/refine/desugar_decorators.rs
use silkworm_err::ErrorCtx;
use crate::ast::visit::VisitMut;
use crate::ast::*;
use crate::parse::ParseCtx;
/// Validation transform that desugars decorator commands like `if`s.
pub struct DesugarDecorators<'a> {
err... | code_fim | hard | {
"lang": "rust",
"repo": "silkworm-rs/silkworm",
"path": "/silkworm_syn/src/refine/desugar_decorators.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected_stmt = Stmt {
span: Span::new(0, 24),
pragmas: Vec::new(),
body: StmtBody {
span: Span::new(0, 24),
kind: StmtKind::If(IfStmt {
span: Span::new(0, 24),
if_clause: IfClause {
... | code_fim | hard | {
"lang": "rust",
"repo": "silkworm-rs/silkworm",
"path": "/silkworm_syn/src/refine/desugar_decorators.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.visit_stmt_body_mut(&mut stmt.body);
}
}
#[cfg(test)]
mod tests {
use super::*;
// Use pretty_assertions for `assert_eq` diffs.
use pretty_assertions::assert_eq;
use silkworm_err::ErrorCtx;
use crate::Span;
#[test]
fn test_desugar_decorators() {
le... | code_fim | hard | {
"lang": "rust",
"repo": "silkworm-rs/silkworm",
"path": "/silkworm_syn/src/refine/desugar_decorators.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pool = ConstantPool::new(vec!["Hello world!".into()]);
let code = Code::from_model(&[LdSS(p(0)), TraceStackValue(s(0))]).unwrap();
let mut vm = Vm::light(pool);
code.interpret(&mut vm)
}<|fim_prefix|>// repo: hunter04d/ngvm path: /src/bin/hello.rs
use ngvm::code::refs::*;
use ngvm::er... | code_fim | easy | {
"lang": "rust",
"repo": "hunter04d/ngvm",
"path": "/src/bin/hello.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hunter04d/ngvm path: /src/bin/hello.rs
use ngvm::code::refs::*;
use ngvm::error::VmContextError;
use ngvm::model::Opcode::*;
use ngvm::{Code, ConstantPool, Vm};
<|fim_suffix|> let pool = ConstantPool::new(vec!["Hello world!".into()]);
let code = Code::from_model(&[LdSS(p(0)), TraceStackV... | code_fim | easy | {
"lang": "rust",
"repo": "hunter04d/ngvm",
"path": "/src/bin/hello.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const TRITIUM : GasDatum = GasDatum {
id: "tritium",
name: "Tritium",
specific_heat: 10.0,
fusion_power: 1.0,
};
pub const BZ : GasDatum = GasDatum {
id: "bz",
name: "BZ",
specific_heat: 20.0,
fusion_power: 8.0,
};
pub const STIMULUM : GasDatum = GasDatum {
id: "s... | code_fim | hard | {
"lang": "rust",
"repo": "Putnam3145/SS13-atmos-rust",
"path": "/src/atmos/gases.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Putnam3145/SS13-atmos-rust path: /src/atmos/gases.rs
pub struct GasDatum {
pub id: &'static str,
pub name: &'static str,
pub specific_heat: f32,
pub fusion_power: f32,
}
impl GasDatum {
pub fn heat_capacity(&self,amount: f32) -> f32 {
return amount * self.specific_he... | code_fim | hard | {
"lang": "rust",
"repo": "Putnam3145/SS13-atmos-rust",
"path": "/src/atmos/gases.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> else if n % 3 == 0 {
total += n
}
},
None => {
break;
},
}
}
println!("{:?}", total)
}
}<|fim_prefix|>// repo: danielpclark/ProjectEuler path: /#1/rust/src/main.rs
#[allow(unused_must_use)]
fn main() {
use std::io;
let mut input... | code_fim | hard | {
"lang": "rust",
"repo": "danielpclark/ProjectEuler",
"path": "/#1/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielpclark/ProjectEuler path: /#1/rust/src/main.rs
#[allow(unused_must_use)]
fn main() {
use std::io;
let mut input = String::new();
io::stdin().read_line(&mut input);
for _ in 0..input.trim_right().parse::<usize>().unwrap() {
let mut input2 = String::new();
io::stdin().read_li... | code_fim | medium | {
"lang": "rust",
"repo": "danielpclark/ProjectEuler",
"path": "/#1/rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xixixao/orbtk path: /crates/widgets/src/behaviors/focus_behavior.rs
use crate::{api::prelude::*, proc_macros::*};
/// The `FocusBehaviorState` handles the `FocusBehavior` widget.
#[derive(Default, AsAny)]
pub struct FocusBehaviorState {
request_focus: bool,
}
<|fim_suffix|> if !self... | code_fim | hard | {
"lang": "rust",
"repo": "xixixao/orbtk",
"path": "/crates/widgets/src/behaviors/focus_behavior.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Sets or shares the focused property.
focused: bool
}
);
impl Template for FocusBehavior {
fn template(self, id: Entity, _: &mut BuildContext) -> Self {
self.name("FocusBehavior")
.focused(true)
.on_mouse_down(move |states, _| {
s... | code_fim | hard | {
"lang": "rust",
"repo": "xixixao/orbtk",
"path": "/crates/widgets/src/behaviors/focus_behavior.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn get_proto(&self, val: &Value) -> &Dictionary {
match val {
Value::String(_) => &self.string_proto,
Value::Integer(_) => &self.integer_proto,
Value::Float(_) => &self.float_proto,
Value::Boolean(_) => &self.boolean_proto,
... | code_fim | hard | {
"lang": "rust",
"repo": "NyxCode/Ketamine",
"path": "/interpreter/src/interpreter/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(statements.eval(self)?.into_value())
}
pub fn prototype_function<O, I, F>(&mut self, ident: I, function: F)
where
O: Object + HasPrototype + HasTypeName + ObjectConversion,
I: Into<String>,
F: Fn(&mut Interpreter, O, Vec<Value>) -> Result<Value, String> + 's... | code_fim | hard | {
"lang": "rust",
"repo": "NyxCode/Ketamine",
"path": "/interpreter/src/interpreter/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.