text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future {
ready(
req.extensions()
.get::<RootSpan>()
.cloned()
.ok_or(RootSpanExtractionError { _priv: () }),
)
}
}
#[derive(Debug)]
/// Error returned by the [`... | code_fim | hard | {
"lang": "rust",
"repo": "Signis-bin/tracing-actix-web",
"path": "/src/root_span.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<RootSpan> for Span {
fn from(r: RootSpan) -> Self {
r.0
}
}
impl FromRequest for RootSpan {
type Error = RootSpanExtractionError;
type Future = Ready<Result<Self, Self::Error>>;
fn from_request(req: &Ht... | code_fim | hard | {
"lang": "rust",
"repo": "Signis-bin/tracing-actix-web",
"path": "/src/root_span.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ReeceStevens/embedded-hal-mock path: /src/gpio.rs
//! A mock for General Purpose Input/Output (GPIO) peripherals.
//!
//! ```
//! use embedded_hal_mock::gpio::{GpioPin, GpioState};
//! use embedded_hal::digital::{OutputPin, InputPin};
//!
//! let mut pin = GpioPin::new();
//! pin.set_low();
//! ... | code_fim | medium | {
"lang": "rust",
"repo": "ReeceStevens/embedded-hal-mock",
"path": "/src/gpio.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn is_low(&self) -> Result<bool, Self::Error> {
Ok(self.state == GpioState::Low)
}
fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.state == GpioState::High)
}
}
impl hal::digital::v2::ToggleableOutputPin for GpioPin {
type Error = Infallible;
fn toggle(&... | code_fim | medium | {
"lang": "rust",
"repo": "ReeceStevens/embedded-hal-mock",
"path": "/src/gpio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_low(&mut self) -> Result<(), Self::Error> {
self.state = GpioState::Low;
Ok(())
}
fn set_high(&mut self) -> Result<(), Self::Error> {
self.state = GpioState::High;
Ok(())
}
}
impl hal::digital::v2::InputPin for GpioPin {
type Error = Infallible;... | code_fim | hard | {
"lang": "rust",
"repo": "ReeceStevens/embedded-hal-mock",
"path": "/src/gpio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Foo {
pub fn baz(self, v: Baz) -> Baz {
(|| v)()
}
}
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/closures/2229_closure_analysis/issue-92724-needsdrop-query-cycle.rs
// ICEs if checking if there is a significant destructor causes a query cycle
// check-pass
<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/closures/2229_closure_analysis/issue-92724-needsdrop-query-cycle.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/closures/2229_closure_analysis/issue-92724-needsdrop-query-cycle.rs
// ICEs if checking if there is a significant destructor causes a query cycle
// check-pass
<|fim_suffix|>impl Foo {
pub fn baz(self, v: Baz) -> Baz {
(|| v)()
}
}
fn main() {}<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/closures/2229_closure_analysis/issue-92724-needsdrop-query-cycle.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wehjin/bittrex_dl path: /src/setup.rs
use std::error::Error;
use super::*;
pub const REPORT_TYPE_DEPOSITS: &str = "deposits";
pub const REPORT_TYPE_WITHDRAWALS: &str = "withdrawals";
pub fn read_report_type() -> Result<ReportType, AppError> {
let args: Vec<String> = std::env::args().collec... | code_fim | medium | {
"lang": "rust",
"repo": "wehjin/bittrex_dl",
"path": "/src/setup.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::fs::File;
use std::io::prelude::*;
if let Some(path_buf) = std::env::home_dir() {
let file_path = path_buf.as_path().join(".bittrex_dl.yaml");
File::open(&file_path)
.map_err(|e| AppError::OpenFileFailed(file_path, e.description().to_owned()))
.... | code_fim | medium | {
"lang": "rust",
"repo": "wehjin/bittrex_dl",
"path": "/src/setup.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let receiver_multiaddr = receiver.local_enr().multiaddr()[1].clone();
// let the two nodes set up listeners
let sender_fut = async {
loop {
if let NetworkEvent::NewListenAddr(_) = sender.next_event().await {
return;
}
}
};
let re... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/beacon_node/lighthouse_network/tests/common.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // wait for either both nodes to listen or a timeout
tokio::select! {
_ = tokio::time::sleep(Duration::from_millis(500)) => {}
_ = joined => {}
}
// sender.dial_peer(peer_id);
match sender.testing_dial(receiver_multiaddr.clone()) {
Ok(()) => {
debu... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/beacon_node/lighthouse_network/tests/common.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigp/lighthouse path: /beacon_node/lighthouse_network/tests/common.rs
#![cfg(test)]
use libp2p::gossipsub;
use lighthouse_network::service::Network as LibP2PService;
use lighthouse_network::Enr;
use lighthouse_network::EnrExt;
use lighthouse_network::Multiaddr;
use lighthouse_network::{NetworkCo... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/beacon_node/lighthouse_network/tests/common.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Copy)]
pub enum NetDetailOrder {
LoginTime,
LogoutTime,
Flux,
}
impl NetDetailOrder {
fn get_query(&self) -> &'static str {
match self {
NetDetailOrder::LoginTime => "user_login_time",
NetDetailOrder::LogoutTime => "user_drop_time",
... | code_fim | hard | {
"lang": "rust",
"repo": "Berrysoft/tunet-rust",
"path": "/tunet-helper/src/usereg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Berrysoft/tunet-rust path: /tunet-helper/src/usereg.rs
use crate::*;
use async_stream::try_stream;
use chrono::Local;
use data_encoding::HEXLOWER;
use futures_core::Stream;
use mac_address2::MacAddress;
use md5::{Digest, Md5};
use select::document::Document;
use select::predicate::*;
use std::ne... | code_fim | hard | {
"lang": "rust",
"repo": "Berrysoft/tunet-rust",
"path": "/tunet-helper/src/usereg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn login(&self, u: &str, p: &str) -> NetHelperResult<String> {
let password_md5 = {
let mut md5 = Md5::new();
md5.update(p.as_bytes());
md5.finalize()
};
let params = [
("action", "login"),
("user_login_name"... | code_fim | hard | {
"lang": "rust",
"repo": "Berrysoft/tunet-rust",
"path": "/tunet-helper/src/usereg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Matthias-Fauconneau/iced path: /core/src/align.rs
/// Alignment on an axis of a container.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Align {
/// Align at the start of the axis.
Start,
/// Align at the center of the axis.
Center,
<|fim_suffix|> /// Verticall... | code_fim | hard | {
"lang": "rust",
"repo": "Matthias-Fauconneau/iced",
"path": "/core/src/align.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Vertically centered
Center,
/// Align bottom
Bottom,
}<|fim_prefix|>// repo: Matthias-Fauconneau/iced path: /core/src/align.rs
/// Alignment on an axis of a container.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Align {
/// Align at the start of the axis.
Star... | code_fim | hard | {
"lang": "rust",
"repo": "Matthias-Fauconneau/iced",
"path": "/core/src/align.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use crate::Signable;
let key = b"secret";
let encoder = signed_token::Encoder::new_from_secret(key);
let decoder = signed_token::Decoder::new_from_secret(key);
let data = PasswordReset { user_id: 42 };
let token = data.sign(&encoder);
let token_stri... | code_fim | medium | {
"lang": "rust",
"repo": "microcluster/devand",
"path": "/devand-crypto/src/password_reset_token.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: microcluster/devand path: /devand-crypto/src/password_reset_token.rs
use crate::signed_token;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct PasswordReset {
pub user_id: i32,
}
impl signed_token::Signable for PasswordReset {
const EXP_SECONDS: i64 = 3... | code_fim | medium | {
"lang": "rust",
"repo": "microcluster/devand",
"path": "/devand-crypto/src/password_reset_token.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = PasswordReset { user_id: 42 };
let token = data.sign(&encoder);
let token_string: String = token.clone().into();
let decoded: PasswordReset = decoder.decode(&token).unwrap();
assert_eq!(data.user_id, decoded.user_id);
assert!(token_string.len() < ... | code_fim | hard | {
"lang": "rust",
"repo": "microcluster/devand",
"path": "/devand-crypto/src/password_reset_token.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let handler = self.scheduler.schedule(task, None);
self.subscription.append($box_unsub::new(handler));
}
#[inline]
fn is_finished(&self) -> bool {
self.observer.is_finished()
}
}
impl<Item, Err, S, SD> ObservableExt<Item, Err> for $op where
S... | code_fim | hard | {
"lang": "rust",
"repo": "rxRust/rxRust",
"path": "/src/ops/observe_on.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rxRust/rxRust path: /src/ops/observe_on.rs
use crate::{
prelude::*,
rc::{MutArc, MutRc},
scheduler::{NormalReturn, OnceTask, Scheduler},
};
#[derive(Clone)]
pub struct ObserveOnOp<S, SD> {
pub(crate) source: S,
pub(crate) scheduler: SD,
}
pub struct ObserveOnObserver<O, SD> {
observ... | code_fim | hard | {
"lang": "rust",
"repo": "rxRust/rxRust",
"path": "/src/ops/observe_on.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: futile/ncollide path: /benches/geometry/algorithm.rs
use geometry::algorithm::{JohnsonSimplex, RecursionTemplate};
use geometry::algorithms::simplex::Simplex;
use na::{Pnt3, Vec3};
use test::Bencher;
use test;
#[bench]
fn bench_johnson_simplex(bh: &mut Bencher) {
<|fim_suffix|>#[bench]
fn bench... | code_fim | hard | {
"lang": "rust",
"repo": "futile/ncollide",
"path": "/benches/geometry/algorithm.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = Pnt3::new(-0.5f32, -0.5, -0.5);
let b = Pnt3::new(0.0, 0.5, 0.0);
let c = Pnt3::new(0.5, -0.5, -0.5);
let d = Pnt3::new(0.0, -0.5, -0.5);
let _ = JohnsonSimplex::<f64, Pnt3<f64>, Vec3<f64>>::new_w_tls();
bh.iter(|| {
let mut spl = JohnsonSimplex::new_w_tls();
... | code_fim | hard | {
"lang": "rust",
"repo": "futile/ncollide",
"path": "/benches/geometry/algorithm.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> bh.iter(|| {
let mut spl = JohnsonSimplex::new_w_tls();
spl.reset(a);
spl.add_point(b);
spl.add_point(c);
spl.add_point(d);
test::black_box(spl.project_origin_and_reduce());
})
}<|fim_prefix|>// repo: futile/ncollide path: /benches/geometry/algor... | code_fim | hard | {
"lang": "rust",
"repo": "futile/ncollide",
"path": "/benches/geometry/algorithm.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn index(&self) -> usize {
self.index
}
pub fn word_size(&self) -> usize {
self.word_size
}
pub fn address_size(&self) -> usize {
self.address_size
}
pub fn highest_offset(&self) -> u64 {
self.highest
}
pub fn wrap_offset(&self, o... | code_fim | hard | {
"lang": "rust",
"repo": "fugue-re/fugue-core",
"path": "/fugue-ir/src/space.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fugue-re/fugue-core path: /fugue-ir/src/space.rs
use crate::bits::calculate_mask;
use crate::deserialise::parse::XmlExt;
use crate::deserialise::Error;
use std::fmt;
use std::mem;
use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Deref, DerefMut, Not};
#[derive(Debug, Copy, Clone, Parti... | code_fim | hard | {
"lang": "rust",
"repo": "fugue-re/fugue-core",
"path": "/fugue-ir/src/space.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_unique(&self) -> bool {
if let Self::Unique(..) = self {
true
} else {
false
}
}
pub fn is_register(&self) -> bool {
matches!(self.kind(), SpaceKind::Register)
}
pub fn is_default(&self) -> bool {
matches!(self... | code_fim | hard | {
"lang": "rust",
"repo": "fugue-re/fugue-core",
"path": "/fugue-ir/src/space.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Skin {
name: String,
skeleton_root: Option<usize>,
pub inverse_bind_matrices: Vec<Mat4>,
pub joints: Vec<usize>,
}<|fim_prefix|>// repo: ericrobolson/Archived_Tremor path: /v1/portia/src/gfx/p_gltf/skin.rs
use game_math::f32::*;
use std::rc::Rc;
<|fim_middle|>use super::node::... | code_fim | easy | {
"lang": "rust",
"repo": "ericrobolson/Archived_Tremor",
"path": "/v1/portia/src/gfx/p_gltf/skin.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ericrobolson/Archived_Tremor path: /v1/portia/src/gfx/p_gltf/skin.rs
use game_math::f32::*;
use std::rc::Rc;
<|fim_suffix|>pub struct Skin {
name: String,
skeleton_root: Option<usize>,
pub inverse_bind_matrices: Vec<Mat4>,
pub joints: Vec<usize>,
}<|fim_middle|>use super::node::... | code_fim | easy | {
"lang": "rust",
"repo": "ericrobolson/Archived_Tremor",
"path": "/v1/portia/src/gfx/p_gltf/skin.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: super-rust-boy/super-rust-boy path: /src/video/vram/sprite.rs
// Dealing with sprites.
use bitflags::bitflags;
use crate::mem::MemDevice;
const SPRITE_SMALL_HEIGHT: u8 = 8;
const SPRITE_LARGE_HEIGHT: u8 = 16;
bitflags! {
#[derive(Default)]
pub struct SpriteFlags: u8 {
const PR... | code_fim | hard | {
"lang": "rust",
"repo": "super-rust-boy/super-rust-boy",
"path": "/src/video/vram/sprite.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn write(&mut self, loc: u16, val: u8) {
let index = (loc / 4) as usize;
match loc % 4 {
0 => self.objects[index].y = val,
1 => self.objects[index].x = val,
2 => self.objects[index].tile_num = val,
_ => self.objects[index].flags = Sprite... | code_fim | hard | {
"lang": "rust",
"repo": "super-rust-boy/super-rust-boy",
"path": "/src/video/vram/sprite.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let index = (loc / 4) as usize;
match loc % 4 {
0 => self.objects[index].y = val,
1 => self.objects[index].x = val,
2 => self.objects[index].tile_num = val,
_ => self.objects[index].flags = SpriteFlags::from_bits_truncate(val)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "super-rust-boy/super-rust-boy",
"path": "/src/video/vram/sprite.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(file.seek(SeekFrom::End(-123)).unwrap(), 6617);
assert_eq!(file.read(&mut buffer).unwrap(), 32);
let str_val = std::str::from_utf8(&buffer[..]).unwrap();
println!("{}", str_val);
assert_eq!(file.seek(SeekFrom::Current(-250)).unwrap(), 6399);
assert_eq!(file.read(&mut bu... | code_fim | hard | {
"lang": "rust",
"repo": "wasmerio/wasmer",
"path": "/tests/wasi-wast/wasi/tests/fseek.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wasmerio/wasmer path: /tests/wasi-wast/wasi/tests/fseek.rs
// WASI:
// mapdir: .:test_fs/hamlet
use std::fs;
use std::io::{Read, Seek, SeekFrom};
use std::path::PathBuf;
fn main() {
#[cfg(not(target_os = "wasi"))]
let mut base = PathBuf::from("test_fs/hamlet");
#[cfg(target_os = "w... | code_fim | hard | {
"lang": "rust",
"repo": "wasmerio/wasmer",
"path": "/tests/wasi-wast/wasi/tests/fseek.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scottschroeder/shirley-raytracing-rs path: /src/raytracer/material/dielectric.rs
use rand::Rng;
use serde::{Deserialize, Serialize};
use super::{Material, Scatter};
use crate::{
core::{math::fmin_one, Color, Ray},
geometry::hittable::HitRecord,
};
#[derive(Debug, Clone, Serialize, Dese... | code_fim | medium | {
"lang": "rust",
"repo": "scottschroeder/shirley-raytracing-rs",
"path": "/src/raytracer/material/dielectric.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(Scatter {
direction: Ray {
orig: record.point,
direction,
},
attenuation: Color::ones(),
})
}
}<|fim_prefix|>// repo: scottschroeder/shirley-raytracing-rs path: /src/raytracer/material/dielectric.rs
use rand::Rng... | code_fim | hard | {
"lang": "rust",
"repo": "scottschroeder/shirley-raytracing-rs",
"path": "/src/raytracer/material/dielectric.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let unit_direction = ray.direction.unit();
let cos_theta = fmin_one(unit_direction.scale(-1.0).dot(&record.normal));
let sin_theta = (1.0 - cos_theta * cos_theta).sqrt();
let direction = if refraction_ratio * sin_theta > 1.0
|| reflectance(cos_theta, refractio... | code_fim | hard | {
"lang": "rust",
"repo": "scottschroeder/shirley-raytracing-rs",
"path": "/src/raytracer/material/dielectric.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The different priorities that can be assigned to a `Task`.
///
/// The default value is `Priority::Normal`.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum Priority {
/// The lowest available priority for a task.
Trivial,
/// A lower priority than `Priority::Normal` ... | code_fim | hard | {
"lang": "rust",
"repo": "ponyloop/batch-rs",
"path": "/batch/src/task.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// The different priorities that can be assigned to a `Task`.
///
/// The default value is `Priority::Normal`.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum Priority {
/// The lowest available priority for a task.
Trivial,
/// A lower priority than `Priority::Norma... | code_fim | hard | {
"lang": "rust",
"repo": "ponyloop/batch-rs",
"path": "/batch/src/task.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ponyloop/batch-rs path: /batch/src/task.rs
//! A trait representing an executable task.
use std::str::FromStr;
use std::time::Duration;
use serde::de::DeserializeOwned;
use serde::Serialize;
use error::{Error, ErrorKind, Result};
/// An executable task and its related metadata (name, queue, ... | code_fim | hard | {
"lang": "rust",
"repo": "ponyloop/batch-rs",
"path": "/batch/src/task.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum Context {
KeyValueContext(String, String),
ListContext(String, Vec<String>),
}<|fim_prefix|>// repo: isgasho/comtrya path: /src/contexts/mod.rs
use serde::{Deserialize, Serialize};
// User context provider: understands the user ... | code_fim | easy | {
"lang": "rust",
"repo": "isgasho/comtrya",
"path": "/src/contexts/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/comtrya path: /src/contexts/mod.rs
use serde::{Deserialize, Serialize};
// User context provider: understands the user running the command
pub mod user;
<|fim_suffix|> fn get_contexts(&self) -> Vec<Context>;
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum Cont... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/comtrya",
"path": "/src/contexts/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kestred/web-analyzer-wip path: /utils/grammar/src/syntax_kind/meta.rs
use rowan::SyntaxKind;
/// Metadata about a syntax kind.
#[derive(Debug)]
pub struct SyntaxKindMeta {
/// The name of the syntax kind (e.g. `IDENT`)
pub name: &'static str,
<|fim_suffix|> /// The canonical source text s... | code_fim | easy | {
"lang": "rust",
"repo": "kestred/web-analyzer-wip",
"path": "/utils/grammar/src/syntax_kind/meta.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The canonical source text string representation (if one exists)
pub canonical: Option<&'static str>,
}<|fim_prefix|>// repo: kestred/web-analyzer-wip path: /utils/grammar/src/syntax_kind/meta.rs
use rowan::SyntaxKind;
/// Metadata about a syntax kind.
#[derive(Debug)]
pub struct SyntaxKindMeta {... | code_fim | easy | {
"lang": "rust",
"repo": "kestred/web-analyzer-wip",
"path": "/utils/grammar/src/syntax_kind/meta.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_success(Rule::let_stmt, "let hoge = let fuga = 2 in 1 + fuga");
assert_success(Rule::let_stmt, "let hoge = let fuga = 2 in let piyo = 3 in fuga + piyo");
}
#[test]
fn bind_stmt() {
assert_success(Rule::bind_stmt, "let hoge = fuga in");
}
#[test]
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "monaqa/satysfi-peg-parser",
"path": "/src/parser/tests/statement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: monaqa/satysfi-peg-parser path: /src/parser/tests/statement.rs
#[cfg(test)]
mod tests {
use crate::parser::Rule;
use super::super::common::{assert_success, assert_fail};
#[test]
fn arg() {
assert_success(Rule::arg, "42");
assert_success(Rule::arg, "()");
... | code_fim | hard | {
"lang": "rust",
"repo": "monaqa/satysfi-peg-parser",
"path": "/src/parser/tests/statement.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn let_math_stmt() {
assert_success(Rule::let_math_stmt, r"let-math \alpha = math-char MathOrd `α`");
assert_fail(Rule::let_math_stmt, r"let-math ctx \alpha = math-char MathOrd `α`");
}
#[test]
fn let_inline_stmt() {
assert_success(Rule::let_inline_stmt... | code_fim | hard | {
"lang": "rust",
"repo": "monaqa/satysfi-peg-parser",
"path": "/src/parser/tests/statement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scarvalhojr/adventofcode2020 path: /day05/src/lib.rs
use std::convert::TryFrom;
use std::str::FromStr;
const ROW_SPLITS: usize = 7;
const COL_SPLITS: usize = 3;
pub struct Seat {
row: u32,
col: u32,
}
impl Seat {
fn id(&self) -> u32 {
self.row * 8 + self.col
}
}
pub f... | code_fim | hard | {
"lang": "rust",
"repo": "scarvalhojr/adventofcode2020",
"path": "/day05/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn from_str(s: &str) -> Result<Self, Self::Err> {
let row = s
.get(..ROW_SPLITS)
.and_then(|r| parse_bin_str(r, 'F', 'B'))
.ok_or_else(|| String::from("Invalid row"))?;
let col = s
.get(ROW_SPLITS..ROW_SPLITS + COL_SPLITS)
.an... | code_fim | hard | {
"lang": "rust",
"repo": "scarvalhojr/adventofcode2020",
"path": "/day05/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn append_img(image_src: String) -> Result<(), JsValue> {
let window = web_sys::window().expect("no global `window` exists");
let document = window.document().expect("should have a document on window");
let body = document.body().expect("document should have a body");
let val = docume... | code_fim | hard | {
"lang": "rust",
"repo": "silencesdg/rust_webAssembly_demo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silencesdg/rust_webAssembly_demo path: /src/lib.rs
extern crate js_sys;
extern crate web_sys;
use std::io::{Cursor,SeekFrom,Seek,Read};
use wasm_bindgen::prelude::*;
use image::{self,DynamicImage,ImageFormat};
use base64::{encode};
#[wasm_bindgen]
pub fn grayscale(_array: &[u8]) -> Result<(), ... | code_fim | medium | {
"lang": "rust",
"repo": "silencesdg/rust_webAssembly_demo",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn append_img(image_src: String) -> Result<(), JsValue> {
let window = web_sys::window().expect("no global `window` exists");
let document = window.document().expect("should have a document on window");
let body = document.body().expect("document should have a body");
let val = documen... | code_fim | hard | {
"lang": "rust",
"repo": "silencesdg/rust_webAssembly_demo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/wrapping_macros path: /src/lib.rs
#![crate_type = "dylib"]
#![feature(plugin_registrar, rustc_private)]
extern crate rustc_plugin;
extern crate syntax;
use rustc_plugin::Registry;
use syntax::ast::{BinOpKind, Expr, ExprKind, Ident, Mac, UnOp};
use syntax::codemap::Span;
use syntax::ext... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/wrapping_macros",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Returns the wrapping version of an operator, if applicable.
fn wrapping_method(op: BinOpKind) -> Option<Ident> {
Some(Ident::from_str(match op {
BinOpKind::Add => "wrapping_add",
BinOpKind::Sub => "wrapping_sub",
BinOpKind::Mul => "wrapping_mul",
BinOpKind::Div => "... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/wrapping_macros",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn example_2() {
assert_eq!("aaabc", Solution::orderly_queue(String::from("baaca"), 3));
}
}<|fim_prefix|>// repo: sugyan/leetcode path: /others/september-leetcoding-challenge-2021/week-1/3964/lib.rs
pub struct Solution;
impl Solution {
pub fn orderly_queue(s: String, k: ... | code_fim | medium | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/september-leetcoding-challenge-2021/week-1/3964/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn example_1() {
assert_eq!("acb", Solution::orderly_queue(String::from("cba"), 1));
}
#[test]
fn example_2() {
assert_eq!("aaabc", Solution::orderly_queue(String::from("baaca"), 3));
}
}<|fim_prefix|>// repo: sugyan/leetcode path: /others/september-leetco... | code_fim | medium | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/september-leetcoding-challenge-2021/week-1/3964/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sugyan/leetcode path: /others/september-leetcoding-challenge-2021/week-1/3964/lib.rs
pub struct Solution;
impl Solution {
pub fn orderly_queue(s: String, k: i32) -> String {
if k == 1 {
let ss = s.chars().chain(s.chars()).collect::<Vec<_>>();
let mut v = ss.w... | code_fim | medium | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/september-leetcoding-challenge-2021/week-1/3964/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EinarSundgren/rust_gol path: /src/main.rs
extern crate rand;
use rand::Rng;
use std::{thread, time};
static ALIVE:u8 = 1;
static DEAD:u8 = 0;
fn main() {
let mut board: Vec<Vec<u8>>;
let ten_millis = time::Duration::from_millis(200);
board = create_board(10,10);
board[4][1]=ALIVE;
board... | code_fim | hard | {
"lang": "rust",
"repo": "EinarSundgren/rust_gol",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let is_alive: bool = board[x][y] != DEAD;
for check_x in -1i8..2i8 {
for check_y in -1i8..2i8 {
// println!("Checking: x:{:?}, y:{:?} Relative from start: ({:?},{:?})", (check_x + (x as i8)) as i8, y as i8 + check_y, check_x, check_y);
... | code_fim | hard | {
"lang": "rust",
"repo": "EinarSundgren/rust_gol",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> label
}
}
/*
This hook fixes a bug in the game where -[SCAppDelegate persistentStoreCoordinator]
calls -[SCAppDelegate managedObjectModel], which crashes the game because it attempts
to call -[NSManagedObjectModel initWithContentsOfURL:] with a nil URL that it gets
from ca... | code_fim | hard | {
"lang": "rust",
"repo": "Shawnqcfr/CLEO-iOS",
"path": "/src/gui.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let text_frame: CGRect = msg_send![text, frame];
let backing_size = CGSize {
width: text_frame.size.width * 2.3,
height: text_frame.size.height * 1.9,
};
let (backing, backing_outer) = {
let outer_frame = CGRect {
origin... | code_fim | hard | {
"lang": "rust",
"repo": "Shawnqcfr/CLEO-iOS",
"path": "/src/gui.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shawnqcfr/CLEO-iOS path: /src/gui.rs
//! Hooks the splash screen to display our "CLEO" numberplate, and also provides a Rust interface for some
//! common UIKit code.
use crate::{call_original, targets};
use log::trace;
use objc::{
runtime::{Object, Sel},
*,
};
use std::os::raw::c_long;... | code_fim | hard | {
"lang": "rust",
"repo": "Shawnqcfr/CLEO-iOS",
"path": "/src/gui.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kenaniah/ruby-parser path: /ruby-parser/src/ast/mod.rs
//! Provides the abstract syntax tree
mod binary_op;
mod conditional;
mod expr;
mod identifier;
mod interpolated;
mod literal;
<|fim_suffix|>e conditional::*;
pub use expr::*;
pub use identifier::*;
pub use interpolated::*;
pub use literal:... | code_fim | medium | {
"lang": "rust",
"repo": "kenaniah/ruby-parser",
"path": "/ruby-parser/src/ast/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e loop_::*;
pub use method::*;
pub use node::*;
pub use object::*;
pub use program::*;
pub use statement::*;
pub use unary_op::*;<|fim_prefix|>// repo: kenaniah/ruby-parser path: /ruby-parser/src/ast/mod.rs
//! Provides the abstract syntax tree
mod binary_op;
mod conditional;
mod expr;
mod identifier;
m... | code_fim | medium | {
"lang": "rust",
"repo": "kenaniah/ruby-parser",
"path": "/ruby-parser/src/ast/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blakesmith/arrow2 path: /src/io/ipc/read/array/mod.rs
mod primitive;
pub use primitive::*;
mod boolean;
pub use boolean::*;
mod utf8;
pub use utf8::*;
mod binary;
pub use binary::*;
mod fixed_size_binary;
pub use fixed_size_binary::*;
mod list;
pub use list:<|fim_suffix|>e null::*;
mod dictionar... | code_fim | medium | {
"lang": "rust",
"repo": "blakesmith/arrow2",
"path": "/src/io/ipc/read/array/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e null::*;
mod dictionary;
pub use dictionary::*;
mod union;
pub use union::*;
mod map;
pub use map::*;<|fim_prefix|>// repo: blakesmith/arrow2 path: /src/io/ipc/read/array/mod.rs
mod primitive;
pub use primitive::*;
mod boolean;
pub use boolean::*;
mod utf8;
pub use utf8::*;
mod binary;
pub use binary::... | code_fim | medium | {
"lang": "rust",
"repo": "blakesmith/arrow2",
"path": "/src/io/ipc/read/array/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/num-integer/src/average.rs
use core::ops::{BitAnd, BitOr, BitXor, Shr};
use Integer;
pub trait Average: Integer {
<|fim_suffix|>#[inline]
pub fn average_floor<T: Average>(x: T, y: T) -> T {
x.average_f... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/num-integer/src/average.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn average_ceil(&self, other: &I) -> I {
(self | other) - ((self ^ other) >> 1)
}
}
#[inline]
pub fn average_floor<T: Average>(x: T, y: T) -> T {
x.average_floor(&y)
}
#[inline]
pub fn average_ceil<T: Average>(x: T, y: T) -> T {
x.average_ceil(&y)
}<|fim_prefix|>... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/num-integer/src/average.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anton-dutov/iata-rs path: /tests/raw_iata_792b.rs
// Copyright (C) 2018 Martin Mroz
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//! Test cases derived from the examples listed in IATA Resolution 792
//! Attachment... | code_fim | hard | {
"lang": "rust",
"repo": "anton-dutov/iata-rs",
"path": "/tests/raw_iata_792b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn appendix_b_3_1_mobile_bcbp_lh_lufthansa_mobile_bcbp() {
const PASS_STR: &str = "M1TEST/HIDDEN E8OQ6FU FRARLGLH 4010 012C004D0001 35C>2180WM6012BLH 2922023642241060 LH *30600000K09 ";
let pass_data = Bcbp::from(PASS_STR).unwrap();
a... | code_fim | hard | {
"lang": "rust",
"repo": "anton-dutov/iata-rs",
"path": "/tests/raw_iata_792b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc239/src/bin/b/main.rs
use scanner_proc_macro::insert_scanner;
<|fim_suffix|> let x = scan!(i64);
let ans = if x >= 0 {
x / 10
} else if x % 10 == 0 {
x / 10
} else {
x / 10 - 1
};
println!("{}", ans);... | code_fim | easy | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/abc239/src/bin/b/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x = scan!(i64);
let ans = if x >= 0 {
x / 10
} else if x % 10 == 0 {
x / 10
} else {
x / 10 - 1
};
println!("{}", ans);
}<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc239/src/bin/b/main.rs
use scanner_proc_macro::insert_scanner;... | code_fim | easy | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/abc239/src/bin/b/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michidk/feather path: /feather/datapacks/src/vanilla.rs
use anyhow::Context;
use std::{
fs::{self, File},
io,
path::Path,
time::Duration,
};
use zip::ZipArchive;
// Taken from https://www.minecraft.net/en-us/download/server
const JAR_URL: &str =
"https://launcher.mojang.com/... | code_fim | hard | {
"lang": "rust",
"repo": "michidk/feather",
"path": "/feather/datapacks/src/vanilla.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::info!("Extracting vanilla JAR");
// We'll create a datapack by copying `pack.mcmeta` and the `data`
// directory to a new datapack called `minecraft`.
let target = base.join("datapacks/minecraft");
fs::create_dir_all(&target)?;
// copy pack.mcmeta
{
let mut pack_m... | code_fim | hard | {
"lang": "rust",
"repo": "michidk/feather",
"path": "/feather/datapacks/src/vanilla.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>::Deficient,
Ordering::Equal => Classification::Perfect,
Ordering::Greater => Classification::Abundant,
})
}
}<|fim_prefix|>// repo: genos/online_problems path: /exercism/rust/perfect-numbers/src/lib.rs
use std::cmp::Ordering;
#[derive(PartialEq, Debug)]
pub enum Clas... | code_fim | hard | {
"lang": "rust",
"repo": "genos/online_problems",
"path": "/exercism/rust/perfect-numbers/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/ 2)
.filter(|i| num % i == 0)
.sum::<u64>()
.cmp(&num)
{
Ordering::Less => Classification::Deficient,
Ordering::Equal => Classification::Perfect,
Ordering::Greater => Classification::Abundant,
})
}
}<|fim_prefix|>... | code_fim | medium | {
"lang": "rust",
"repo": "genos/online_problems",
"path": "/exercism/rust/perfect-numbers/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: genos/online_problems path: /exercism/rust/perfect-numbers/src/lib.rs
use std::cmp::Ordering;
#[derive(PartialEq, Debug)]
pub enum Classification {
Deficient,
Perfect,
Abundant,
}
pub fn classify(num: <|fim_suffix|>/ 2)
.filter(|i| num % i == 0)
.sum::<u64>(... | code_fim | medium | {
"lang": "rust",
"repo": "genos/online_problems",
"path": "/exercism/rust/perfect-numbers/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lunar-mycroft/qr-microservice path: /src/process.rs
use actix_web::web::Bytes;
use actix_web::HttpResponse;
use image::Luma;
use qrcode::render::svg;
use qrcode::QrCode;
use serde::Deserialize;
fn default_ec() -> char {
'm'
}
#[derive(Deserialize, Debug)]
pub struct Request {
b64: Opti... | code_fim | hard | {
"lang": "rust",
"repo": "lunar-mycroft/qr-microservice",
"path": "/src/process.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<base64::DecodeError> for Error {
fn from(err: base64::DecodeError) -> Error {
Error::Base64(err)
}
}
impl From<qrcode::types::QrError> for Error {
fn from(err: qrcode::types::QrError) -> Error {
Error::QR(err)
}
}
impl From<image::ImageError> for Error {
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "lunar-mycroft/qr-microservice",
"path": "/src/process.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_generator(lang: Language) -> CodeGenerator {
match lang {
Language::C | Language::Cpp => c::generate,
Language::Rust => unimplemented!("No Rust code generator is implemented"),
}
}<|fim_prefix|>// repo: DusterTheFirst/pinout path: /src/codegen.rs
use crate::{
args::... | code_fim | medium | {
"lang": "rust",
"repo": "DusterTheFirst/pinout",
"path": "/src/codegen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DusterTheFirst/pinout path: /src/codegen.rs
use crate::{
args::Language,
netlist::{AssociatedComponent, Sheet},
};
use std::io::Write;
<|fim_suffix|>pub fn get_generator(lang: Language) -> CodeGenerator {
match lang {
Language::C | Language::Cpp => c::generate,
Langu... | code_fim | medium | {
"lang": "rust",
"repo": "DusterTheFirst/pinout",
"path": "/src/codegen.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: waonder-rs/geometer path: /src/vertex/mod.rs
mod position;
mod normal;
pub use position::*;
pub use normal::*;
/// Vertex position format.
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum PositionFormat {
F32XYZ
}
/// Vertex layout.
///
/// Describes how to access the data of each vertex
/// ... | code_fim | medium | {
"lang": "rust",
"repo": "waonder-rs/geometer",
"path": "/src/vertex/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Mesh vertex.
pub unsafe trait Vertex: Copy {
const LAYOUT: Layout;
}<|fim_prefix|>// repo: waonder-rs/geometer path: /src/vertex/mod.rs
mod position;
mod normal;
pub use position::*;
pub use normal::*;
<|fim_middle|>/// Vertex position format.
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Positio... | code_fim | hard | {
"lang": "rust",
"repo": "waonder-rs/geometer",
"path": "/src/vertex/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Minhaul/advent-of-code-2020 path: /d02/src/bin/p2.rs
use std::io;
use file_reader;
const INPUT_FILENAME: &str = "input.txt";
#[derive(Debug)]
struct PwData {
i1: usize,
i2: usize,
letter: char,
pw: String,
}
fn main() {
let input_str = match file_reader::file_to_vec(INPUT... | code_fim | hard | {
"lang": "rust",
"repo": "Minhaul/advent-of-code-2020",
"path": "/d02/src/bin/p2.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> // input string looks like: <u32>-<u32> <char>: <String>
let i1: usize = input[0..input.find('-').unwrap()].parse::<usize>().unwrap() - 1;
let i2: usize = input[input.find('-').unwrap() + 1..input.find(' ').unwrap()].parse::<usize>().unwrap() - 1;
let letter: char = input.chars().nth(input... | code_fim | medium | {
"lang": "rust",
"repo": "Minhaul/advent-of-code-2020",
"path": "/d02/src/bin/p2.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let l = bytes.len();
let mut result: Vec<u8> = Vec::new();
let mut maybe_ok: u8 = bytes[0];
for w in bytes.windows(2) {
// The difference between the codes of lowercase and capital letters is 32.
// Using wrapping subtraction logic, 224 indicates a difference of 32 in the other directi... | code_fim | hard | {
"lang": "rust",
"repo": "y6nH/aoc2018",
"path": "/src/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: y6nH/aoc2018 path: /src/day5.rs
use crate::util;
pub fn a() {
let mut s: String = util::read_file_to_string("input5");
unsafe {
let bytes = s.as_mut_vec().to_vec();
let collapsed = collapse_bytes_loop(bytes);
println!("5A: {}", collapsed.len());
}
}
pub fn b() {
let mut s: ... | code_fim | hard | {
"lang": "rust",
"repo": "y6nH/aoc2018",
"path": "/src/day5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn last_name(mut self, last_name: String) -> Self {
self.0.insert("last_name".to_string(), last_name);
self
}
pub fn maiden_name(mut self, maiden_name: String) -> Self {
self.0.insert("maiden_name".to_string(), maiden_name);
self
}
pub fn personal_... | code_fim | hard | {
"lang": "rust",
"repo": "stearnsc/rust-stripe-client",
"path": "/src/model/legal_entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn dob(mut self, dob: DateOfBirth) -> Self {
self.0.extend(UrlEncodable::named("dob", &dob));
self
}
pub fn first_name(mut self, first_name: String) -> Self {
self.0.insert("first_name".to_string(), first_name);
self
}
pub fn gender(mut self, gende... | code_fim | hard | {
"lang": "rust",
"repo": "stearnsc/rust-stripe-client",
"path": "/src/model/legal_entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stearnsc/rust-stripe-client path: /src/model/legal_entity.rs
use serde;
use super::address::Address;
use super::date_of_birth::DateOfBirth;
use super::gender::Gender;
use super::owner::{Owner, NewOwner};
use super::verification::Verification;
use std::collections::BTreeMap;
use std::fmt;
use url... | code_fim | hard | {
"lang": "rust",
"repo": "stearnsc/rust-stripe-client",
"path": "/src/model/legal_entity.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> union_vec_isets_unordered(&mut self.isets, s as usize, tr.nextstate as usize);
true
}
/// Invoked when state finished ('s' is tree root, 'parent' is kNoStateId,
/// and '_tr' is nullptr).
fn finish_state(&mut self, s: StateId, parent: Option<StateId>, _tr: Option<&Tr<W>>) ... | code_fim | hard | {
"lang": "rust",
"repo": "Garvys/rustfst",
"path": "/rustfst/src/algorithms/compose/interval_reach_visitor.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Invoked when tree transition to white/undiscovered state examined.
fn tree_tr(&mut self, _s: StateId, _tr: &Tr<W>) -> bool {
true
}
/// Invoked when back transition to grey/unfinished state examined.
fn back_tr(&mut self, _s: StateId, _tr: &Tr<W>) -> bool {
panic!(... | code_fim | hard | {
"lang": "rust",
"repo": "Garvys/rustfst",
"path": "/rustfst/src/algorithms/compose/interval_reach_visitor.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Garvys/rustfst path: /rustfst/src/algorithms/compose/interval_reach_visitor.rs
use crate::algorithms::compose::{IntInterval, IntervalSet};
use crate::algorithms::dfs_visit::Visitor;
use crate::fst_traits::Fst;
use crate::semirings::Semiring;
use crate::{StateId, Tr};
use std::cmp::Ordering;
sta... | code_fim | hard | {
"lang": "rust",
"repo": "Garvys/rustfst",
"path": "/rustfst/src/algorithms/compose/interval_reach_visitor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(manager) = data.get::<ShardManagerContainer>() {
// Shush, it'll make me feel better when I can't get the bot to work how I want.
if message.contains("^foad") {
let _ = msg.channel_id.send_message(&ctx.http, |m| {
m.embed(|e| {
... | code_fim | medium | {
"lang": "rust",
"repo": "Phate6660/rsPhate",
"path": "/src/commands/quit.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phate6660/rsPhate path: /src/commands/quit.rs
use crate::ShardManagerContainer;
use crate::OWNER_CHECK;
use serenity::{
framework::standard::{macros::command, CommandResult},
http::AttachmentType,
model::channel::Message,
prelude::*,
};
use std::path::Path;
<|fim_suffix|> let... | code_fim | medium | {
"lang": "rust",
"repo": "Phate6660/rsPhate",
"path": "/src/commands/quit.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = ctx.data.read();
let message = &msg.content;
if let Some(manager) = data.get::<ShardManagerContainer>() {
// Shush, it'll make me feel better when I can't get the bot to work how I want.
if message.contains("^foad") {
let _ = msg.channel_id.send_message(... | code_fim | medium | {
"lang": "rust",
"repo": "Phate6660/rsPhate",
"path": "/src/commands/quit.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>se sun_system::SunSystem;
pub use third_person_camera_system::ThirdPersonCameraSystem;
pub use transform_real_lights::TransformRealLights;
pub use update_camera::UpdateCamera;
pub use update_cameras::UpdateCameras;
pub use update_neighbouring_chunks::UpdateNeighbouringChunks;
pub use velocity_system::Velo... | code_fim | hard | {
"lang": "rust",
"repo": "Blugatroff/clone2",
"path": "/src/systems/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Blugatroff/clone2 path: /src/systems/mod.rs
mod block_highlighting;
mod break_blocks;
mod chunk_mesh_generation;
mod first_person_controller;
mod generate_chunks;
mod looking_at;
mod looking_at_marker;
mod place_blocks;
mod remove_chunks;
mod render_flat_meshes;
mod render_models;
mod render_uv_... | code_fim | hard | {
"lang": "rust",
"repo": "Blugatroff/clone2",
"path": "/src/systems/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theatlasroom/advent-of-code path: /rust/src/aoc2015_6.rs
use utils;
#[derive(Clone, Debug)]
struct Light {
x: i32,
y: i32,
lit: bool,
}
impl Light {
fn is_lit(&self) -> bool {
self.lit
}
}
#[derive(Clone)]
struct LightGrid {
width: i32,
height: i32,
lig... | code_fim | hard | {
"lang": "rust",
"repo": "theatlasroom/advent-of-code",
"path": "/rust/src/aoc2015_6.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.