text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>#[get("/{tail:\\d+}*")]
async fn four() -> &'static str {
"malformed resource def"
}
#[get("/{a}/{b}/{c}/{d}/{e}/{f}/{g}/{h}/{i}/{j}/{k}/{l}/{m}/{n}/{o}/{p}/{q}")]
async fn five() -> &'static str {
"malformed resource def"
}
fn main() {}<|fim_prefix|>// repo: actix/actix-web path: /actix-web-co... | code_fim | medium | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-web-codegen/tests/trybuild/route-malformed-path-fail.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[get("/*")]
async fn three() -> &'static str {
"malformed resource def"
}
#[get("/{tail:\\d+}*")]
async fn four() -> &'static str {
"malformed resource def"
}
#[get("/{a}/{b}/{c}/{d}/{e}/{f}/{g}/{h}/{i}/{j}/{k}/{l}/{m}/{n}/{o}/{p}/{q}")]
async fn five() -> &'static str {
"malformed resource... | code_fim | medium | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-web-codegen/tests/trybuild/route-malformed-path-fail.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liurenjie1024/zeus path: /zeus-server/src/rpc/mod.rs
pub mod zeus_data;
pub mod zeus_data_grpc;
pu<|fim_suffix|>mod zeus_plan;
pub mod zeus_expr;
pub mod zeus_simple_format;
pub mod zeus_blizard_format;<|fim_middle|>b mod zeus_meta;
pub mod zeus_meta_grpc;
pub | code_fim | easy | {
"lang": "rust",
"repo": "liurenjie1024/zeus",
"path": "/zeus-server/src/rpc/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s_simple_format;
pub mod zeus_blizard_format;<|fim_prefix|>// repo: liurenjie1024/zeus path: /zeus-server/src/rpc/mod.rs
pub mod zeus_data;
pub mod zeus_data_grpc;
pu<|fim_middle|>b mod zeus_meta;
pub mod zeus_meta_grpc;
pub mod zeus_plan;
pub mod zeus_expr;
pub mod zeu | code_fim | medium | {
"lang": "rust",
"repo": "liurenjie1024/zeus",
"path": "/zeus-server/src/rpc/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LinkTed/doh-client path: /src/cmd/mod.rs
mod app;
mod listen_config;
mod remote_host;
pub use app::get_command;
pub use liste<|fim_suffix|>e_host::{get_remote_host, RemoteHostError};<|fim_middle|>n_config::get_listen_config;
pub use remot | code_fim | easy | {
"lang": "rust",
"repo": "LinkTed/doh-client",
"path": "/src/cmd/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>e_host::{get_remote_host, RemoteHostError};<|fim_prefix|>// repo: LinkTed/doh-client path: /src/cmd/mod.rs
mod app;
mod listen_config;
mod remote_hos<|fim_middle|>t;
pub use app::get_command;
pub use listen_config::get_listen_config;
pub use remot | code_fim | medium | {
"lang": "rust",
"repo": "LinkTed/doh-client",
"path": "/src/cmd/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = u32::decode(data);
let (a, b) = data.split_at(n as usize);
*data = b;
let r = str::from_utf8(a).unwrap();
log::trace!("decoded string {:?}", r);
r
}
}
impl<'src> Decode<'src> for String {
fn decode(data: &mut &'src [u8]) -> String {
... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/cli-support/src/decode.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/cli-support/src/decode.rs
use std::str;
pub trait Decode<'src>: Sized {
fn decode(data: &mut &'src [u8]) -> Self;
fn decode_all(mut data: &'src [u8]) -> Self {
let ret = Self::decode(&mut data);
assert!(data.is_empty());
ret
... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/cli-support/src/decode.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (@arms $data:ident $dst:ident ($cnt:expr) ($($arms:tt)*) $name:ident($t:ty), $($rest:tt)*) => (
decode_enum!(
@arms
$data
$dst
($cnt+1)
($($arms)* n if n == $cnt => $name(Decode::decode($data)), )
$($rest)*
)
)... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/cli-support/src/decode.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilsso/quadratic-sieve-rs path: /src/conjugate.rs
pub trait Conjugate: Clone {
type Output;
<|fim_suffix|>impl Conjugate for u32 {
type Output = u32;
fn conj(&self) -> u32 {
*self
}
}<|fim_middle|> fn conj(&self) -> Self::Output;
}
| code_fim | easy | {
"lang": "rust",
"repo": "nilsso/quadratic-sieve-rs",
"path": "/src/conjugate.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl Conjugate for u32 {
type Output = u32;
fn conj(&self) -> u32 {
*self
}
}<|fim_prefix|>// repo: nilsso/quadratic-sieve-rs path: /src/conjugate.rs
pub trait Conjugate: Clone {
type Output;
<|fim_middle|> fn conj(&self) -> Self::Output;
| code_fim | easy | {
"lang": "rust",
"repo": "nilsso/quadratic-sieve-rs",
"path": "/src/conjugate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wmvanvliet/advent_of_code_in_rust path: /2019/day1/src/main.rs
use std::io::{self, Read};
use std::iter;
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
println!("Part 1 answer: {}", part1(strip_bom(&input)));
println!("Part 2 answer: ... | code_fim | hard | {
"lang": "rust",
"repo": "wmvanvliet/advent_of_code_in_rust",
"path": "/2019/day1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Compute fuel to transport both a module and its required fuel
fn rocket_eq(weight:i64) -> i64 {
iter::successors(Some(required_fuel(weight)), |&weight| {
if weight <= 0 {
None
} else {
Some(required_fuel(weight))
}
}).sum()
}
#[cfg(test)]
mod t... | code_fim | hard | {
"lang": "rust",
"repo": "wmvanvliet/advent_of_code_in_rust",
"path": "/2019/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_part1() {
assert_eq!(part1("12"), 2);
assert_eq!(part1("14"), 2);
assert_eq!(part1("1969"), 654);
assert_eq!(part1("100756"), 33583);
}
#[test]
fn test_part2() {
assert_eq!(part2("14"), 2);
assert_eq!(part2("1969"), 966);... | code_fim | hard | {
"lang": "rust",
"repo": "wmvanvliet/advent_of_code_in_rust",
"path": "/2019/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn push(&mut self, hittable: Box<dyn Hittable>) {
self.vec.push(hittable);
}
}
impl Hittable for HittableVec {
fn hit(&self, ray: &Rayf, t_min: f32, t_max: f32) -> Option<HitRecord> {
let mut result = None;
let t_closest = t_max;
for hittable in &self.vec {... | code_fim | hard | {
"lang": "rust",
"repo": "shessel/raybert",
"path": "/src/math/intersections.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shessel/raybert path: /src/math/intersections.rs
use super::{dot, Rayf, Vec3f};
pub struct HitRecord {
pub point: Vec3f,
pub normal: Vec3f,
pub t: f32,
pub front_face: bool,
}
impl HitRecord {
pub fn new(point: Vec3f, normal: Vec3f, t: f32, ray: &Rayf) -> HitRecord {
... | code_fim | hard | {
"lang": "rust",
"repo": "shessel/raybert",
"path": "/src/math/intersections.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let project1 = Project { name: "Project1".to_string(),
ident: "core/project1/1.0.0/20180101000000".to_string(),
state: "Success".to_string(),
job_id: "12345678".to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "habitat-sh/habitat",
"path": "/components/hab/src/command/bldr/job/promote.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: habitat-sh/habitat path: /components/hab/src/command/bldr/job/promote.rs
use crate::{api_client,
common::ui::{Status,
UIReader,
UIWriter,
UI},
error::{Error,
Result},
... | code_fim | hard | {
"lang": "rust",
"repo": "habitat-sh/habitat",
"path": "/components/hab/src/command/bldr/job/promote.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> tops &= tops - 1;
}
false
}
}
pub fn pyramid_transition(bottom: String, allowed: Vec<String>) -> bool {
let mut allowed_map = [0; MAX_PAIRS];
for triple in &allowed {
let [left, right, top]: [u8; 3] = triple.as_bytes().... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0756_pyramid_transition_matrix/block_by_block_backtracking.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = bottom.len();
let mut blocks = [0; MAX_BLOCKS];
let last_row_start = (n - 1) * n / 2;
for (target, c) in blocks[last_row_start..].iter_mut().zip(bottom.bytes()) {
*target = c - b'A';
}
Self::helper(&mut blocks, last_row_start - 1, &allo... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0756_pyramid_transition_matrix/block_by_block_backtracking.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0756_pyramid_transition_matrix/block_by_block_backtracking.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::convert::TryInto;
const MAX_BOTTOM_LENGTH: us... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0756_pyramid_transition_matrix/block_by_block_backtracking.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GabrielRavier/doukutsu-rs path: /src/weapon/fireball.rs
use crate::caret::CaretType;
use crate::common::Direction;
use crate::player::{Player, TargetPlayer};
use crate::shared_game_state::SharedGameState;
use crate::weapon::bullet::BulletManager;
use crate::weapon::{Weapon, WeaponLevel};
impl W... | code_fim | hard | {
"lang": "rust",
"repo": "GabrielRavier/doukutsu-rs",
"path": "/src/weapon/fireball.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self.consume_ammo(1) {
// todo switch to first weapon
return;
}
match player.direction {
Direction::Left if player.up => {
bullet_manager.create_bullet(player.x - 0x800, player.y - 0x1000, btype, player_id, Direction::Up, &st... | code_fim | hard | {
"lang": "rust",
"repo": "GabrielRavier/doukutsu-rs",
"path": "/src/weapon/fireball.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LiveSplit/livesplit-core path: /src/analysis/tests/empty_run.rs
use super::super::sum_of_segments::{calculate_best, calculate_worst};
use super::super::total_playtime;
use crate::{Run, TimeSpan, TimingMethod};
#[test]
fn sum_of_best() {
<|fim_suffix|>#[test]
fn sum_of_worst() {
let run = Ru... | code_fim | hard | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/src/analysis/tests/empty_run.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let run = Run::new();
assert_eq!(
calculate_best(run.segments(), false, false, TimingMethod::RealTime),
Some(TimeSpan::zero())
);
assert_eq!(
calculate_best(run.segments(), false, true, TimingMethod::RealTime),
Some(TimeSpan::zero())
);
assert_eq!(
... | code_fim | medium | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/src/analysis/tests/empty_run.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yeslogic/allsorts path: /src/woff2/lut.rs
NAME, OS_2, POST, CVT, FPGM, GLYF, LOCA, PREP, CFF, VORG, EBDT,
EBLC, GASP, HDMX, KERN, LTSH, PCLT, VDMX, VHEA, VMTX, BASE, GDEF, GPOS, GSUB, EBSC, JSTF, MATH,
CBDT, CBLC, COLR, CPAL, SVG, SBIX, ACNT, AVAR, BDAT, BLOC, BSLN, CVAR, FDSC, FEAT, FMT... | code_fim | hard | {
"lang": "rust",
"repo": "yeslogic/allsorts",
"path": "/src/woff2/lut.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yeslogic/allsorts path: /src/woff2/lut.rs
Triplet { byte_count: 1, x_bits: 0, y_bits: 8, delta_x: 0, delta_y: 256, x_is_negative: false, y_is_negative: false },
XYTriplet { byte_count: 1, x_bits: 0, y_bits: 8, delta_x: 0, delta_y: 512, x_is_negative: false, y_is_negative: true }... | code_fim | hard | {
"lang": "rust",
"repo": "yeslogic/allsorts",
"path": "/src/woff2/lut.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Lookup table for decoding transformed glyf table point coordinates
// https://www.w3.org/TR/WOFF2/#glyf_table_format
#[rustfmt::skip]
pub static COORD_LUT: [XYTriplet; 128] = [
XYTriplet { byte_count: 1, x_bits: 0, y_bits: 8, delta_x: 0, delta_y: 0, x_is_negative: false, y_is_negative: true... | code_fim | hard | {
"lang": "rust",
"repo": "yeslogic/allsorts",
"path": "/src/woff2/lut.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ro_flags = ParameterFlags::default();
ro_flags.set_read_only(true);
let mut bcast_flags = ParameterFlags::default();
bcast_flags.set_broadcast(true);
let p1 = Parameter::new_with_value(ParameterId::new(1), flags, ParameterValue::U8(123));
let p2 = ... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/home-network-old",
"path": "/template-box-controller/src/params.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonlamb-gh/home-network-old path: /template-box-controller/src/params.rs
// TODO - should bind value type to ID at code-gen time?
use crate::error::Error;
use crate::sys_clock;
use crate::PARAM_EVENT_Q;
use heapless::Vec;
use log::debug;
use params::{MaxParamsPerOp, Parameter, ParameterId, Para... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/home-network-old",
"path": "/template-box-controller/src/params.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let p1 = Parameter::new_with_value(ParameterId::new(1), flags, ParameterValue::U8(123));
let p2 = Parameter::new_with_value(ParameterId::new(2), flags, ParameterValue::U8(123));
let p3 =
Parameter::new_with_value(ParameterId::new(3), ro_flags, ParameterValue::Bool(false... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/home-network-old",
"path": "/template-box-controller/src/params.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Celti/dust path: /src/utils/mod.rs
use jwalk::DirEntry;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::HashSet;
use jwalk::WalkDir;
mod platform;
use self::platform::*;
#[derive(Debug, Default, Eq)]
pub struct Node {
pub name: String,
pub size: u64,
p... | code_fim | hard | {
"lang": "rust",
"repo": "Celti/dust",
"path": "/src/utils/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut correct = HashSet::new();
correct.insert("a/b".to_string());
correct.insert("c".to_string());
assert_eq!(simplify_dir_names(vec!["a/b", "a/b//", "c", "c/"]), correct);
}
#[test]
fn test_simplify_dir_rm_subdir_and_not_substrings() {
let mut correc... | code_fim | hard | {
"lang": "rust",
"repo": "Celti/dust",
"path": "/src/utils/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut correct = HashSet::new();
correct.insert("a/b".to_string());
assert_eq!(simplify_dir_names(vec!["a/b", "a/b/c", "a/b/d/f"]), correct);
}
#[test]
fn test_simplify_dir_duplicates() {
let mut correct = HashSet::new();
correct.insert("a/b".to_string... | code_fim | hard | {
"lang": "rust",
"repo": "Celti/dust",
"path": "/src/utils/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luteberget/junction path: /src/document/model.rs
use nalgebra_glm as glm;
use crate::document::objects::*;
use crate::document::infview::*;
use crate::util::*;
use ordered_float::OrderedFloat;
use serde::{Serialize,Deserialize};
use std::sync::Arc;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
... | code_fim | hard | {
"lang": "rust",
"repo": "luteberget/junction",
"path": "/src/document/model.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Undoable<T, C> {
stack :Vec<T>,
pointer: usize,
class :Option<C>,
}
impl<T : Clone + Default, C : Eq> Undoable<T,C> {
pub fn info(&self) -> String {
format!("Undo stack {}/{}", self.pointer, self.stack.len()-1)
}
pub fn new() -> Undoable<T,C> {
Self::fr... | code_fim | hard | {
"lang": "rust",
"repo": "luteberget/junction",
"path": "/src/document/model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
expr: &defs::Expression,
ns: &defs::Namespace,
) -> Result<(), ResolveError> {
match expr {
defs::Expression::BinaryOp(bin_op_expr) => {
self.resolve_expr(&bin_op_expr.lhs, ns)?;
self.resolve_expr(&bin_op_expr.rhs, ... | code_fim | hard | {
"lang": "rust",
"repo": "psychon/x11rb",
"path": "/xcbgen-rs/src/resolver/type_resolver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: psychon/x11rb path: /xcbgen-rs/src/resolver/type_resolver.rs
Ok(())
}
defs::EventDef::Copy(event_copy_def) => {
self.resolve_named_event(&event_copy_def.ref_, ns)?;
Ok(())
}
}
}
fn resolve_error_def(
... | code_fim | hard | {
"lang": "rust",
"repo": "psychon/x11rb",
"path": "/xcbgen-rs/src/resolver/type_resolver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: psychon/x11rb path: /xcbgen-rs/src/resolver/type_resolver.rs
fn resolve_reply_def(
&mut self,
reply_def: &defs::ReplyDef,
ns: &defs::Namespace,
) -> Result<(), ResolveError> {
let fields = reply_def.fields.borrow();
Self::check_repeated_fields(&fie... | code_fim | hard | {
"lang": "rust",
"repo": "psychon/x11rb",
"path": "/xcbgen-rs/src/resolver/type_resolver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marhoily/chess_rust path: /src/mask/masks.rs
use super::Mask;
pub const EMPTY: Mask = Mask(0);
pub const A: Mask = Mask(0x101010101010101);
pub const B: Mask = Mask(0x202020202020202);
pub const C: Mask = Mask(0x404040404040404);
pub const D: Mask = Mask(0x808080808080808);
pub const E: Mask =... | code_fim | hard | {
"lang": "rust",
"repo": "marhoily/chess_rust",
"path": "/src/mask/masks.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(H.single_bits().collect_vec(),
[H8, H7, H6, H5, H4, H3, H2, H1]);
}
#[test]
fn ranks() {
assert_eq!(_8.single_bits().collect_vec(),
[A8, B8, C8, D8, E8, F8, G8, H8]);
assert_eq!(_7.single_bits().collect_vec(),
... | code_fim | hard | {
"lang": "rust",
"repo": "marhoily/chess_rust",
"path": "/src/mask/masks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t : &Trait = &get_function()();
//~^ ERROR cannot move a value of type dyn Trait
}<|fim_prefix|>// repo: ciniml/rust path: /src/test/ui/issues/issue-41139.rs
trait Trait {}
fn get_function<'a>() -> &'a Fn() -> Trait { panic!("") }
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "ciniml/rust",
"path": "/src/test/ui/issues/issue-41139.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ciniml/rust path: /src/test/ui/issues/issue-41139.rs
trait Trait {}
fn get_function<'a>() -> &'a Fn() -> Trait { panic!("") }
<|fim_suffix|> let t : &Trait = &get_function()();
//~^ ERROR cannot move a value of type dyn Trait
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "ciniml/rust",
"path": "/src/test/ui/issues/issue-41139.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nus-cs4215/sourceror path: /lib-frontend-estree/src/func/pre_parse.rs
es_node.loc.into_sl(filename).to_owned(),
ParseProgramError::ESTreeError(
"Statement, Import or Export node expected at top-level",
),
... | code_fim | hard | {
"lang": "rust",
"repo": "nus-cs4215/sourceror",
"path": "/lib-frontend-estree/src/func/pre_parse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> es_expr: &mut Node,
name_ctx: &mut HashMap<String, PreVar>,
depth: usize,
filename: Option<&str>,
) -> Result<BTreeMap<VarLocId, Usage>, CompileMessage<ParseProgramError>> {
match &mut es_expr.kind {
NodeKind::Identifier(identifier) => {
pre_parse_identifier_use(ide... | code_fim | hard | {
"lang": "rust",
"repo": "nus-cs4215/sourceror",
"path": "/lib-frontend-estree/src/func/pre_parse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nus-cs4215/sourceror path: /lib-frontend-estree/src/func/pre_parse.rs
en(|a| Ok(varusage::merge_series(a, curr?)))
})
}
fn pre_parse_import_decl(
es_import_decl: &mut ImportDeclaration,
_loc: &Option<esSL>,
name_ctx: &mut HashMap<String, PreVar>, // contains all names refere... | code_fim | hard | {
"lang": "rust",
"repo": "nus-cs4215/sourceror",
"path": "/lib-frontend-estree/src/func/pre_parse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loganfsmyth/jsparse-rs path: /src/tokenizer/slice.rs
if len > 2 && bytes[2] == b'>' {
punc(PunctuatorToken::MinusMinusAngle, 3, token)
} else {
punc(PunctuatorToken::MinusMinus, 2, token)
}
} else if len > 1 && ... | code_fim | hard | {
"lang": "rust",
"repo": "loganfsmyth/jsparse-rs",
"path": "/src/tokenizer/slice.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bytes = code.as_bytes();
if hint.template {
let mut break_curly = false;
for (i, &b) in bytes.iter().enumerate().skip(1) {
match b {
b'{' if break_curly => {
template(code[1..i - 1].into(), code[1..i - 1].into(), TemplateFormat:... | code_fim | hard | {
"lang": "rust",
"repo": "loganfsmyth/jsparse-rs",
"path": "/src/tokenizer/slice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loganfsmyth/jsparse-rs path: /src/tokenizer/slice.rs
as f64;
}
b'8' | b'9' => {
unimplemented!("invalid number error")
}
_ => break,
}
i += 1;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "loganfsmyth/jsparse-rs",
"path": "/src/tokenizer/slice.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sleibrock/waddler.rs path: /src/structs/lump.rs
// structs/lump.rs
use std::fmt;
use utils::*;
use structs::constants::*;
pub struct Lump {
pub name: String,
pub posn: usize,
pub size: usize,
pub start: usize,
pub end: usize,
pub is_level: bool,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "sleibrock/waddler.rs",
"path": "/src/structs/lump.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// debug printer for a Lump
impl fmt::Debug for Lump {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} <0x{:X} .. 0x{:X}>",
self.name, self.posn,
self.posn+self.size)
}
}
// end structs/lump.rs<|fim_prefix|>// repo: sleibrock/waddler.rs path: /src/s... | code_fim | hard | {
"lang": "rust",
"repo": "sleibrock/waddler.rs",
"path": "/src/structs/lump.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Lump {
is_level: is_level_lump,
posn: p,
size: s,
start: p_h,
end: p_h + s,
name: u8_to_string(&dat[8..(first_zero+1)]),
})
},
// If invalid bytes, error out
bytes => Err(format!("Invalid amount of bytes (given {})", bytes)),
... | code_fim | hard | {
"lang": "rust",
"repo": "sleibrock/waddler.rs",
"path": "/src/structs/lump.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Safety: `avr` lives as long as `uart`
let uart = unsafe { Uart::new(uart_id, &mut avr) };
if let Some(uart) = uart {
uarts.insert(uart_id, uart);
} else {
break;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/avr-tester",
"path": "/avr-simulator/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cycle = self.avr.cycle();
let state = self.avr.run();
let tt = (self.avr.cycle() - cycle).max(1);
let tt = AvrDuration::new(self.avr.frequency(), tt);
for spi in self.spis.values_mut() {
spi.tick(tt.as_cycles());
}
StepOutcome { sta... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/avr-tester",
"path": "/avr-simulator/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Patryk27/avr-tester path: /avr-simulator/src/lib.rs
//! Bare-bones wrapper for simavr.
//!
//! The main purpose of this crate is to serve as a building block for
//! AvrTester - so while this crate does provide a somewhat high-level interface
//! over simavr, this interface is limited and curate... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/avr-tester",
"path": "/avr-simulator/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let byte = 1;
assert_eq!(to_bits(byte, 3), [false, false, true]);
let byte = 0b000_0000;
assert_eq!(
to_bits(byte, 7),
[false, false, false, false, false, false, false]
);
}
#[test]
fn test_fixed() {
// See https://www.w3.org/Graphics/PNG/RFC-1951#fixed
let ... | code_fim | hard | {
"lang": "rust",
"repo": "bantic/gziprust",
"path": "/src/deflate/huffman.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bantic/gziprust path: /src/deflate/huffman.rs
#[derive(Clone, Debug)]
pub struct TreeNode {
len: u32,
code: u32,
}
#[derive(Default, Debug, PartialOrd, PartialEq)]
pub struct HuffmanNode {
code: Option<u32>,
one: Option<Box<HuffmanNode>>,
zero: Option<Box<HuffmanNode>>,
}
#[derive(De... | code_fim | hard | {
"lang": "rust",
"repo": "bantic/gziprust",
"path": "/src/deflate/huffman.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mersinvald/bn path: /tests/serialization.rs
extern crate rand;
extern crate bn;
extern crate bincode;
extern crate serde;
extern crate hex;
#[macro_use] extern crate lazy_static;
mod test_data;
use bn::*;
use hex::{ToHex, FromHex};
use bincode::{serialize, deserialize};
use serde::{Serialize, ... | code_fim | hard | {
"lang": "rust",
"repo": "mersinvald/bn",
"path": "/tests/serialization.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> acc = acc * by + acc;
}
}
#[test]
fn fr_serialization_and_deserialization() {
let mut a = Fr::one();
let b = Fr::from_str("17").unwrap();
for _ in 0..10000 {
a = a * b;
assert!(reserialize(a) == a);
}
}
#[test]
fn fr_test_invalid_representations() {
// m... | code_fim | hard | {
"lang": "rust",
"repo": "mersinvald/bn",
"path": "/tests/serialization.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZhuanzhiAI/rustling path: /ml/src/lib.rs
#[macro_use]
extern crate failure;
extern crate fnv;
#[macro_use]
extern crate serde_derive;
use std::hash;
use std::fmt::Debug;
use fnv::FnvHashMap;
use fnv::FnvHashSet;
pub type MLResult<T> = Result<T, ::failure::Error>;
pub trait ClassifierId: Eq ... | code_fim | hard | {
"lang": "rust",
"repo": "ZhuanzhiAI/rustling",
"path": "/ml/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Classifier {
classes: hmap!(
Species::Cat => ClassInfo {
class_probalog: -1.0986123,
unk_probalog: -2.3978953,
example_count: 4,
feat_probalog: hmap!(
Friend::Cat => ... | code_fim | hard | {
"lang": "rust",
"repo": "ZhuanzhiAI/rustling",
"path": "/ml/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ntex-rs/ntex path: /ntex-service/src/map_init_err.rs
use std::{future::Future, marker::PhantomData, pin::Pin, task::Context, task::Poll};
use super::ServiceFactory;
/// `MapInitErr` service combinator
pub struct MapInitErr<A, R, C, F, E> {
a: A,
f: F,
e: PhantomData<fn(R, C) -> E>,... | code_fim | hard | {
"lang": "rust",
"repo": "ntex-rs/ntex",
"path": "/ntex-service/src/map_init_err.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(factory.create(&true).await.is_err());
assert!(factory.create(&false).await.is_ok());
}
#[ntex::test]
async fn map_init_err2() {
let factory = fn_factory_with_config(|err: &bool| {
let err = *err;
async move {
if err {
... | code_fim | hard | {
"lang": "rust",
"repo": "ntex-rs/ntex",
"path": "/ntex-service/src/map_init_err.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'f, A, R, C, F, E> Future for MapInitErrFuture<'f, A, R, C, F, E>
where
A: ServiceFactory<R, C>,
F: Fn(A::InitError) -> E,
{
type Output = Result<A::Service, E>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.as_mut().project()... | code_fim | hard | {
"lang": "rust",
"repo": "ntex-rs/ntex",
"path": "/ntex-service/src/map_init_err.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match unit {
// If cm, the number must be at least 150 and at most 193.
"cm" => if !validate_number_field(Some(val), 150..=193) {
return false;
},
// If in, the number must be at least 59 and at most 76... | code_fim | hard | {
"lang": "rust",
"repo": "Sfera-IT/adventofcode2020",
"path": "/xanathar/day4b/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sfera-IT/adventofcode2020 path: /xanathar/day4b/src/main.rs
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use std::iter::Iterator;
use regex::Regex;
use lazy_static::lazy_static;
use std::ops::RangeInclusive;
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufR... | code_fim | hard | {
"lang": "rust",
"repo": "Sfera-IT/adventofcode2020",
"path": "/xanathar/day4b/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut current: Vec<String> = Vec::new();
let mut passports: Vec<Passport> = Vec::new();
for l in passport_codes {
if l.trim().is_empty() {
passports.push(Passport::new(current));
current = Vec::new();
} else {
current.push(l);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Sfera-IT/adventofcode2020",
"path": "/xanathar/day4b/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn buf_from_utf8_str<const N: usize>(s: &str) -> Option<[u8; N]> {
let mut retval = [0; N];
if s.len() >= N {
None
} else {
retval
.iter_mut()
.zip(s.as_bytes().iter())
.for_each(|(x, y)| *x = *y);
Some(retval)
}
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "shadow/shadow",
"path": "/src/lib/shmem/src/util.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadow/shadow path: /src/lib/shmem/src/util.rs
// The standard path length limit on Linux.
pub const PATH_MAX_NBYTES: usize = 255;
// One extra byte for the null terminator.
pub(crate) type PathBuf = [u8; PATH_MAX_NBYTES + 1];
pub(crate) const NULL_PATH_BUF: PathBuf = [0; PATH_MAX_NBYTES + 1];... | code_fim | hard | {
"lang": "rust",
"repo": "shadow/shadow",
"path": "/src/lib/shmem/src/util.rs",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> if s.len() >= N {
None
} else {
retval
.iter_mut()
.zip(s.as_bytes().iter())
.for_each(|(x, y)| *x = *y);
Some(retval)
}
}<|fim_prefix|>// repo: shadow/shadow path: /src/lib/shmem/src/util.rs
// The standard path length limit on Linu... | code_fim | hard | {
"lang": "rust",
"repo": "shadow/shadow",
"path": "/src/lib/shmem/src/util.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Wizdave97/rust-handbook path: /collections/src/main.rs
mod help;
use help::helpers;
<|fim_suffix|> println!("{}", helpers::to_pig_latin("The quick (\"brown\") fox can't jump 32.3 feet, right?"));
helpers::dept()
}<|fim_middle|>fn main() {
let mut list = vec![34, 21, 49, 5, 33, 10];
... | code_fim | medium | {
"lang": "rust",
"repo": "Wizdave97/rust-handbook",
"path": "/collections/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", helpers::to_pig_latin("The quick (\"brown\") fox can't jump 32.3 feet, right?"));
helpers::dept()
}<|fim_prefix|>// repo: Wizdave97/rust-handbook path: /collections/src/main.rs
mod help;
use help::helpers;
<|fim_middle|>fn main() {
let mut list = vec![34, 21, 49, 5, 33, 10];
... | code_fim | medium | {
"lang": "rust",
"repo": "Wizdave97/rust-handbook",
"path": "/collections/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MatiF100/YAALC path: /src/main.rs
mod anilist;
mod app;
mod terminal;
#[tokio::main]
async fn main() {
//dbg!(&test);
let mut app = app::App::new("Lista anime".to_owned());
app.authorize().await;
app.set_legend(vec![
("I".to_owned(), "Enter search".to_owned()),
... | code_fim | medium | {
"lang": "rust",
"repo": "MatiF100/YAALC",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut terminal = terminal::create_terminal();
terminal::draw_frame(&mut terminal, &mut app);
let event = terminal::events_test();
while !app.should_exit {
let ev = event.recv().unwrap();
app.handle_input(ev).await;
terminal::draw_frame(&mut terminal, &mut app);
... | code_fim | hard | {
"lang": "rust",
"repo": "MatiF100/YAALC",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apmaros/s3sync path: /src/utils.rs
use std::io::{Stdout, Write};
use crate::GenError;
use crossterm::{QueueableComman<|fim_suffix|>())?;
stdout.queue(cursor::RestorePosition)?;
stdout.flush()?;
Ok(())
}<|fim_middle|>d, cursor};
pub fn rewrite_message(mut stdout: Stdout, msg: String)... | code_fim | medium | {
"lang": "rust",
"repo": "apmaros/s3sync",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>GenError> {
stdout.queue(cursor::SavePosition)?;
stdout.write(msg.as_bytes())?;
stdout.queue(cursor::RestorePosition)?;
stdout.flush()?;
Ok(())
}<|fim_prefix|>// repo: apmaros/s3sync path: /src/utils.rs
use std::io::{Stdout, Write};
use crate::GenError;
use crossterm::{QueueableComman... | code_fim | medium | {
"lang": "rust",
"repo": "apmaros/s3sync",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(result, -24.0);
}
#[test]
fn roundf32_test4() {
let x: f32 = -24.5;
let result: f32 = unsafe { roundf32(x) };
assert_eq!(result, -25.0);
}
}<|fim_prefix|>// repo: rick68/rust-trace path: /libcore/intrinsics/roundf32.rs
#![feature(core, core_intrinsics)]
extern crate core;... | code_fim | hard | {
"lang": "rust",
"repo": "rick68/rust-trace",
"path": "/libcore/intrinsics/roundf32.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rick68/rust-trace path: /libcore/intrinsics/roundf32.rs
#![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::roundf32;
// pub fn roundf32(x: f32) -> f32;
// Round half away from zero:
//
// The other tie-breaking method commo... | code_fim | medium | {
"lang": "rust",
"repo": "rick68/rust-trace",
"path": "/libcore/intrinsics/roundf32.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let params = glium::DrawParameters {
depth: glium::Depth {
test: glium::draw_parameters::DepthTest::IfLessOrEqual,
write: true,
clamp: glium::draw_parameters::DepthClamp::Clamp,
.. Default::default()
},
... | code_fim | hard | {
"lang": "rust",
"repo": "qezz/glium-shadowmapping-test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let read_back: Vec<Vec<(u8, u8, u8, u8)>> = depth_texture.read();
// println!("read_back: {:?}", read_back[0].len());
// println!("depth tex: {} by {}", depth_texture.get_height().unwrap(), depth_texture.get_width());
// panic!();
let sh_uniforms = uniform! {
... | code_fim | hard | {
"lang": "rust",
"repo": "qezz/glium-shadowmapping-test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qezz/glium-shadowmapping-test path: /src/main.rs
#![feature(slice_patterns)]
#[macro_use]
extern crate glium;
extern crate image;
#[cfg(feature = "genmesh")]
extern crate genmesh;
extern crate obj;
#[cfg(feature = "genmesh")]
use obj::{Obj, SimplePolygon};
extern crate wavefront_obj;
// use ... | code_fim | hard | {
"lang": "rust",
"repo": "qezz/glium-shadowmapping-test",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tech-paws/druid-frontend path: /src/ui/ui_state.rs
use druid::{Data, Lens};
use crate::ui::scheme_editor::SchemeEditorState;
use crate::ui::debug::DebugState;
<|fim_suffix|>impl UiState {
pub fn new() -> Self {
UiState {
debug: DebugState::new(),
scheme_edit... | code_fim | medium | {
"lang": "rust",
"repo": "tech-paws/druid-frontend",
"path": "/src/ui/ui_state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl UiState {
pub fn new() -> Self {
UiState {
debug: DebugState::new(),
scheme_editor: SchemeEditorState::new(),
}
}
}<|fim_prefix|>// repo: tech-paws/druid-frontend path: /src/ui/ui_state.rs
use druid::{Data, Lens};
use crate::ui::scheme_editor::SchemeE... | code_fim | medium | {
"lang": "rust",
"repo": "tech-paws/druid-frontend",
"path": "/src/ui/ui_state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Liu-WeiHu/learn-rust path: /wasm-bindgen/console_log/src/lib.rs
use wasm_bindgen::prelude::*;
#[wasm_bindgen(start)]
pub fn run() {
bare_bones();
using_a_macro();
using_web_sys();
}
//首先让我们看一下绑定' console.log',而不使用
// web_sys的帮助。这里我们正在编写' #[wasm_bindgen] '注释
//程序的正确性依赖于
//这些注释的正确性!
... | code_fim | hard | {
"lang": "rust",
"repo": "Liu-WeiHu/learn-rust",
"path": "/wasm-bindgen/console_log/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn bare_bones() {
log("Hello from Rust!");
log_u32(43);
log_many("Logging", "many values!");
}
//下面我们定义一个类似println!,只是它有用
//“console.log”。请注意,“println !实际上对wasm目标不起作用
//因为标准库目前只接收所有的输出。得到
//“println !'类似的行为在你的应用程序,你可能需要一个这样的宏。
macro_rules! console_log {
//注意这里使用的是上面导入的' log '函数
//“... | code_fim | medium | {
"lang": "rust",
"repo": "Liu-WeiHu/learn-rust",
"path": "/wasm-bindgen/console_log/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn alert(s: &str);
}
fn bare_bones() {
log("Hello from Rust!");
log_u32(43);
log_many("Logging", "many values!");
}
//下面我们定义一个类似println!,只是它有用
//“console.log”。请注意,“println !实际上对wasm目标不起作用
//因为标准库目前只接收所有的输出。得到
//“println !'类似的行为在你的应用程序,你可能需要一个这样的宏。
macro_rules! console_log {
//注意这里使用的... | code_fim | medium | {
"lang": "rust",
"repo": "Liu-WeiHu/learn-rust",
"path": "/wasm-bindgen/console_log/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pixunil/phint-animations path: /src/utils/deserialize.rs
use std::fmt;
use serde::de::{self, Error, Unexpected, Deserialize, Deserializer, Visitor, MapAccess};
use graphics::{Style, Point};
mod grammar {
include!(concat!(env!("OUT_DIR"), "/deserialize.rs"));
}
struct LineWidthVisitor;
im... | code_fim | hard | {
"lang": "rust",
"repo": "pixunil/phint-animations",
"path": "/src/utils/deserialize.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'de> Visitor<'de> for AngleVisitor {
type Value = f64;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("an angle in radians or degrees")
}
fn visit_i64<E>(self, value: i64) -> Result<f64, E>
where E: de::Error
{
//... | code_fim | hard | {
"lang": "rust",
"repo": "pixunil/phint-animations",
"path": "/src/utils/deserialize.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x = match x {
Some(x) => x,
None => return Err(M::Error::missing_field("x"))
};
let y = match y {
Some(y) => y,
None => return Err(M::Error::missing_field("y"))
};
Ok(Point::new(x, y))
}
}
impl<'de> Deserial... | code_fim | hard | {
"lang": "rust",
"repo": "pixunil/phint-animations",
"path": "/src/utils/deserialize.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hardik-satasiya/makepad path: /platform/src/os/apple/apple_util.rs
//let image = NSImage::alloc(nil).initByReferencingFile_(pdf_path);
// let info = NSDictionary::dictionaryWithContentsOfFile_(nil, info_path);
let x: ObjcId = msg_send![info, valueForKey: key_x]; //info.... | code_fim | hard | {
"lang": "rust",
"repo": "hardik-satasiya/makepad",
"path": "/platform/src/os/apple/apple_util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub unsafe fn superclass<'a>(this: &'a Object) -> &'a Class {
let superclass: ObjcId = msg_send![this, superclass];
&*(superclass as *const _)
}
pub fn bottom_left_to_top_left(rect: NSRect) -> f64 {
let height = unsafe {CGDisplayPixelsHigh(CGMainDisplayID())};
height as f64 - (rect.origin... | code_fim | hard | {
"lang": "rust",
"repo": "hardik-satasiya/makepad",
"path": "/platform/src/os/apple/apple_util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self::kombisensor::Kombisensor;
pub use self::led::LED;
pub use self::relais::RELAIS;
pub use self::server::Server;
pub use self::shift_register::ShiftRegister;
pub use self::sensor::Sensor;
pub use self::sensor_co::SensorCO;
pub use self::sensor_no2::SensorNO2;<|fim_prefix|>// repo: zzeroo/xMZ-Mod-Touch... | code_fim | hard | {
"lang": "rust",
"repo": "zzeroo/xMZ-Mod-Touch-Prototypes",
"path": "/exceptions_and_traits/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zzeroo/xMZ-Mod-Touch-Prototypes path: /exceptions_and_traits/src/lib.rs
#![doc(html_logo_url = "https://raw.githubusercontent.com/Kliemann-Service-GmbH/xMZ-Mod-Touch-Server/master/share/xmz-logo.png",
html_favicon_url = "https://raw.githubusercontent.com/Kliemann-Service-GmbH/xMZ-Mod-Touc... | code_fim | hard | {
"lang": "rust",
"repo": "zzeroo/xMZ-Mod-Touch-Prototypes",
"path": "/exceptions_and_traits/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.uid
}
fn accept(&self, visitor: &mut dyn Visitor) {
visitor.visit_leaf(&self);
}
}<|fim_prefix|>// repo: Geraet/kompositum-rs path: /src/leaf.rs
// Copyright(c) 2021 René Hansen.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
use crate::{Compo... | code_fim | medium | {
"lang": "rust",
"repo": "Geraet/kompositum-rs",
"path": "/src/leaf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Geraet/kompositum-rs path: /src/leaf.rs
// Copyright(c) 2021 René Hansen.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
use crate::{Component, IDType, Visitor};
pub struct Leaf {
uid: IDType,
}
impl Leaf {
pub fn new(uid: IDType) -> Self {
Self { ui... | code_fim | medium | {
"lang": "rust",
"repo": "Geraet/kompositum-rs",
"path": "/src/leaf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Graphics/Printing/PrintSupport/mod.rs
RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::w... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Graphics/Printing/PrintSupport/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PrintSupportPrintTicketValidationRequestedEventArgs {}
unsafe impl ::core::marker::Sync for PrintSupportPrintTicketValidationRequestedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: co... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Graphics/Printing/PrintSupport/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<String> for Error {
fn from(error: String) -> Self {
Error::UnknownError(error)
}
}<|fim_prefix|>// repo: henryweng03/karl path: /karl-common/src/error.rs
//! Custom karl-related errors.
use std::io;
#[derive(Debug)]
pub enum Error {
/// I/O error.
IoError(io::Error),
... | code_fim | medium | {
"lang": "rust",
"repo": "henryweng03/karl",
"path": "/karl-common/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Error::IoError(error)
}
}
impl From<String> for Error {
fn from(error: String) -> Self {
Error::UnknownError(error)
}
}<|fim_prefix|>// repo: henryweng03/karl path: /karl-common/src/error.rs
//! Custom karl-related errors.
use std::io;
#[derive(Debug)]
pub enum Error {
/... | code_fim | medium | {
"lang": "rust",
"repo": "henryweng03/karl",
"path": "/karl-common/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: henryweng03/karl path: /karl-common/src/error.rs
//! Custom karl-related errors.
use std::io;
#[derive(Debug)]
pub enum Error {
/// I/O error.
IoError(io::Error),
/// Something is not found,
NotFound,
NotFoundInfo(String),
BadRequest,
BadRequestInfo(String),
Alre... | code_fim | medium | {
"lang": "rust",
"repo": "henryweng03/karl",
"path": "/karl-common/src/error.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.