text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>pub struct EthereumErc1155EventCallback {}
#[async_trait]
impl Erc1155EventCallback for EthereumErc1155EventCallback {
async fn on_erc1155_event(
&mut self,
event: Erc1155Event,
token_uri: String,
) -> nft_events::Result<()> {
sidekiq_helper::send_erc1155(
... | code_fim | hard | {
"lang": "rust",
"repo": "w3f-grants-archive/evm-nft-tracker",
"path": "/livenets/ethereum-nft-tracker/src/sidekiq_callbacks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: w3f-grants-archive/evm-nft-tracker path: /livenets/ethereum-nft-tracker/src/sidekiq_callbacks.rs
use nft_events::{Erc1155Event, Erc1155EventCallback, Erc721Event, Erc721EventCallback};
use crate::sidekiq_helper;
pub struct EthereumErc721EventCallback {}
#[async_trait]
impl Erc721EventCallback ... | code_fim | medium | {
"lang": "rust",
"repo": "w3f-grants-archive/evm-nft-tracker",
"path": "/livenets/ethereum-nft-tracker/src/sidekiq_callbacks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl Erc721EventCallback for EthereumErc721EventCallback {
async fn on_erc721_event(
&mut self,
event: Erc721Event,
name: String,
symbol: String,
total_supply: Option<u128>,
token_uri: String,
) -> nft_events::Result<()> {
side... | code_fim | medium | {
"lang": "rust",
"repo": "w3f-grants-archive/evm-nft-tracker",
"path": "/livenets/ethereum-nft-tracker/src/sidekiq_callbacks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @@map("User")
}
model Unrelated {
id Int @id @default(autoincrement())
}
"#]];
expected.assert_eq(&api.re_introspect_dml(input_dm).await?);
let expected = expect![[
r#"[{"code":7,"message":"These models were enriched with `@@map` informati... | code_fim | hard | {
"lang": "rust",
"repo": "debragail/prisma-engines",
"path": "/introspection-engine/introspection-engine-tests/tests/re_introspection/mysql.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: debragail/prisma-engines path: /introspection-engine/introspection-engine-tests/tests/re_introspection/mysql.rs
use barrel::types;
use indoc::indoc;
use introspection_engine_tests::test_api::*;
#[test_connector(tags(Mysql), exclude(Vitess), preview_features("referentialIntegrity"))]
async fn re... | code_fim | hard | {
"lang": "rust",
"repo": "debragail/prisma-engines",
"path": "/introspection-engine/introspection-engine-tests/tests/re_introspection/mysql.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> t.inject_custom(
"CONSTRAINT user_id FOREIGN KEY (user_id) REFERENCES `User`(id) ON DELETE RESTRICT ON UPDATE CASCADE",
);
t.inject_custom(
"CONSTRAINT user_id2 FOREIGN KEY (user_id2) REFERENCES `User`(id) ON DELETE RE... | code_fim | hard | {
"lang": "rust",
"repo": "debragail/prisma-engines",
"path": "/introspection-engine/introspection-engine-tests/tests/re_introspection/mysql.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: berdandy/aoc2020 path: /advent1-2/src/main.rs
use std::fs::File;
use std::io::{BufReader, BufRead, Error};
use itertools::Itertools;
<|fim_suffix|> let path = "test.txt";
let input = File::open(path)?;
let buffered = BufReader::new(input);
let v: Vec<i32> = buffered.lines()
... | code_fim | medium | {
"lang": "rust",
"repo": "berdandy/aoc2020",
"path": "/advent1-2/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for result in v
.into_iter()
.combinations(3)
.filter(|tuple| tuple[0] + tuple[1] + tuple[2] == 2020)
.map(|tuple| tuple[0] * tuple[1] * tuple[2])
{
println!("{}", result);
}
Ok(())
}<|fim_prefix|>// repo: berdandy/aoc2020 path: /advent1-2/src/main... | code_fim | hard | {
"lang": "rust",
"repo": "berdandy/aoc2020",
"path": "/advent1-2/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nightmared/threadpool path: /src/tests/messagequeue.rs
use test;
use lib::messagequeue::*;
use std::thread;
use std::time::{Duration, SystemTime};
#[derive(Debug, PartialEq)]
struct TestStruct {
a: usize,
b: String,
c: [usize; 2]
}
fn send_msg(tx: &mut MessageQueueSender<usize>, nu... | code_fim | hard | {
"lang": "rust",
"repo": "nightmared/threadpool",
"path": "/src/tests/messagequeue.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> b.iter(|| MessageQueueSender::<TestStruct>::new(50).unwrap());
}
#[bench]
fn create_message_queue_struct_2048(b: &mut test::Bencher) {
b.iter(|| MessageQueueSender::<TestStruct>::new(2048).unwrap());
}
#[bench]
fn create_message_queue_struct_1m(b: &mut test::Bencher) {
b.iter(|| MessageQueue... | code_fim | hard | {
"lang": "rust",
"repo": "nightmared/threadpool",
"path": "/src/tests/messagequeue.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (mut tx, mut rx) = message_queue(8192).unwrap();
for i in 0..4096 {
assert!(tx.send(i).is_ok());
}
assert!(thread::spawn(move || {
assert_eq!(rx.unread(), 4096);
assert!(rx.is_ready());
for c in 0..4096 {
assert_eq!(rx.is_ready(), true);
... | code_fim | hard | {
"lang": "rust",
"repo": "nightmared/threadpool",
"path": "/src/tests/messagequeue.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/relay path: /compiler/crates/relay-transforms/src/validate_operation_variables.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use common::Di... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/relay-transforms/src/validate_operation_variables.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if has_unused_variable {
let next_variables = operation
.variable_definitions
.iter()
.filter(|var| variables.contains_key(&var.name.item))
.cloned()
.collect();
Transformed::Replace(OperationDe... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/relay-transforms/src/validate_operation_variables.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lsunsi/molde path: /src/parse.rs
use crate::types::{Stmt, Template};
use std::iter::Peekable;
pub(crate) fn parse(ident: syn::Ident, raw: String) -> Template {
let mut chars = raw.chars().peekable();
let mut pos_stmts = Vec::new();
loop {
pos_stmts.push(parse_unopen(&mut c... | code_fim | hard | {
"lang": "rust",
"repo": "lsunsi/molde",
"path": "/src/parse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match word.as_ref() {
IF => {
let (pos_stmts, neg_stmts) = parse_until_close(chars, IF);
Stmt::If(Template {
pos_stmts,
neg_stmts,
ident,
})
}
LET => {
let (pos_stmts, neg_stmts) = p... | code_fim | hard | {
"lang": "rust",
"repo": "lsunsi/molde",
"path": "/src/parse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TYPEmber/nmea-parser path: /src/ais/vdm_t26.rs
/*
Copyright 2020 Timo Saarinen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0... | code_fim | hard | {
"lang": "rust",
"repo": "TYPEmber/nmea-parser",
"path": "/src/ais/vdm_t26.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Data field of length 0-1004 bits.
pub data: BitVec,
/// Radio status
pub radio: u32,
}
// -------------------------------------------------------------------------------------------------
/// AIS VDM/VDO type 26: Multiple Slot Binary Message
#[allow(clippy::collapsible_if)]
pub(crat... | code_fim | hard | {
"lang": "rust",
"repo": "TYPEmber/nmea-parser",
"path": "/src/ais/vdm_t26.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: meddion/maths_programming path: /src/img/functions.rs
use image::{self, DynamicImage, GenericImageView};
use rayon::prelude::*;
use std::{
cmp::min,
sync::{mpsc, Arc, RwLock},
};
use crate::img::types::*;
pub type ImageSender<T> = mpsc::Sender<(T, &'static str)>;
pub type ImageReceiver... | code_fim | hard | {
"lang": "rust",
"repo": "meddion/maths_programming",
"path": "/src/img/functions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// mix_two_images_parallel achieves what it says by
// utilizing channels and rayon (concurrency lib)
pub fn mix_two_images_parallel(
base: DynamicImage,
cover: DynamicImage,
mix_rules: &[Arc<dyn MixRule>],
) -> ImageReceiver<Vec<u8>> {
let (width, height) = get_min_dim(base.dimensions(), ... | code_fim | medium | {
"lang": "rust",
"repo": "meddion/maths_programming",
"path": "/src/img/functions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (sender, receiver) = mpsc::channel();
mix_rules
.par_iter()
.for_each_with((sender, base, cover), |(s, b, c), mix_rule| {
let buf = (0..size)
.into_par_iter()
.map(|i| {
let x = (i / 3) as u32 % width;
... | code_fim | hard | {
"lang": "rust",
"repo": "meddion/maths_programming",
"path": "/src/img/functions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> gl.draw(args.viewport(), |c, gl| {
let transform = c.transform;
graphics::rectangle(BLACK, square, transform, gl)
});
}
}<|fim_prefix|>// repo: muzudho/practice-piston path: /deploy/snake-game/src/res/food.rs
use crate::res::snake::*;
use opengl_graphics::GlGr... | code_fim | hard | {
"lang": "rust",
"repo": "muzudho/practice-piston",
"path": "/deploy/snake-game/src/res/food.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: muzudho/practice-piston path: /deploy/snake-game/src/res/food.rs
use crate::res::snake::*;
use opengl_graphics::GlGraphics;
use piston::input::*;
pub struct Food {
pub x: u32,
pub y: u32,
}
impl Food {
// Return true if snake ate food this update
pub fn update(&mut self, s: &Sn... | code_fim | hard | {
"lang": "rust",
"repo": "muzudho/practice-piston",
"path": "/deploy/snake-game/src/res/food.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asolove/cargo-progress-demo path: /src/main.rs
extern crate rand;
extern crate term;
use std::fmt;
use std::io::prelude::*;
use std::thread;
static UP_LINE: &'static str = "\x1b[1F";
static CLEAR_LINE: &'static str = "\x1b[K";
#[derive(Clone, Copy, Eq, PartialEq)]
enum CompileStatus {
No... | code_fim | hard | {
"lang": "rust",
"repo": "asolove/cargo-progress-demo",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn display(compiles: &Vec<Compilation>) {
let mut t = term::stdout().unwrap();
for c in compiles.iter() {
write!(t, "{}", CLEAR_LINE).unwrap();
let color = if c.status == CompileStatus::Done {
term::color::GREEN
} else {
term::color::YELLOW
};
... | code_fim | hard | {
"lang": "rust",
"repo": "asolove/cargo-progress-demo",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut t = term::stdout().unwrap();
for c in compiles.iter() {
write!(t, "{}", CLEAR_LINE).unwrap();
let color = if c.status == CompileStatus::Done {
term::color::GREEN
} else {
term::color::YELLOW
};
t.fg(color).unwrap();
write... | code_fim | hard | {
"lang": "rust",
"repo": "asolove/cargo-progress-demo",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andydevstic/pet_rescue_backend path: /src/handlers/user_handlers.rs
use actix_web::{web, HttpResponse};
use<|fim_suffix|>create_user(create_user_dto: web::Json<CreateUserDTO>, pool: web::Data<Pool>) {}<|fim_middle|> crate::models::user::user_dtos::*;
fn | code_fim | easy | {
"lang": "rust",
"repo": "andydevstic/pet_rescue_backend",
"path": "/src/handlers/user_handlers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>reateUserDTO>, pool: web::Data<Pool>) {}<|fim_prefix|>// repo: andydevstic/pet_rescue_backend path: /src/handlers/user_handlers.rs
use actix_web::{web, HttpResponse};
use<|fim_middle|> crate::models::user::user_dtos::*;
fn create_user(create_user_dto: web::Json<C | code_fim | medium | {
"lang": "rust",
"repo": "andydevstic/pet_rescue_backend",
"path": "/src/handlers/user_handlers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2892931976/mirdb path: /sstable/src/util.rs
use std::str;
use std::sync::RwLock;
use std::sync::RwLockReadGuard;
use std::sync::RwLockWriteGuard;
pub fn to_str(cs: &[u8]) -> &str {
str::from_utf8(&cs).expect("not a valid utf8")
}
pub fn find_shortest_sep(a: &[u8], b: &[u8]) -> Vec<u8> {
... | code_fim | hard | {
"lang": "rust",
"repo": "2892931976/mirdb",
"path": "/sstable/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> diff_at += 1;
}
// Backup case: either `a` is full of 0xff, or all different places are less than 2
// characters apart.
// The result is not necessarily short, but a good separator: e.g., "abc" vs "abd" ->
// "abc\0", which is greater than "abc" and lesser than "abd".
let ... | code_fim | hard | {
"lang": "rust",
"repo": "2892931976/mirdb",
"path": "/sstable/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = BigInt::from(3_usize);
let b = BigInt::from(26_usize);
let (gcd, x, y) = egcd(a.clone(), b.clone());
assert_eq!(gcd, BigInt::from(1_usize));
assert_eq!(x, BigInt::from(9_usize));
assert_eq!(y, BigInt::from(-1_isize));
assert_eq!(a * x + b * ... | code_fim | hard | {
"lang": "rust",
"repo": "alvaro-cuesta/rustopals",
"path": "/src/util/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alvaro-cuesta/rustopals path: /src/util/mod.rs
//! Various convenience utilities.
pub mod iter;
use ::std::cmp::Ordering;
/// A probability, in the [0, 1] range (although no check is enforced).
#[derive(PartialEq, PartialOrd)]
#[must_use]
pub struct Probability(pub f32);
impl Eq for Probabil... | code_fim | hard | {
"lang": "rust",
"repo": "alvaro-cuesta/rustopals",
"path": "/src/util/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FilterDos2Unix {
#[doc(alias = "g_mime_filter_dos2unix_new")]
pub fn new(ensure_newline: bool) -> FilterDos2Unix {
assert_initialized_main_thread!();
unsafe {
Filter::from_glib_full(ffi::g_mime_filter_dos2unix_new(ensure_newline.into_glib()))
.unsaf... | code_fim | medium | {
"lang": "rust",
"repo": "vhdirk/gmime-rs",
"path": "/src/auto/filter_dos2_unix.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vhdirk/gmime-rs path: /src/auto/filter_dos2_unix.rs
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/vhdirk/gir-files.git)
// DO NOT EDIT
use crate::Filter;
use glib::object::Cast;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
... | code_fim | medium | {
"lang": "rust",
"repo": "vhdirk/gmime-rs",
"path": "/src/auto/filter_dos2_unix.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moyogo/norad path: /src/glyph/builder.rs
hSet::new(),
}
}
/// Return the format version currently set.
pub fn get_format(&self) -> &GlifVersion {
&self.glyph.format
}
/// Set the glyph width.
///
/// Errors when the function is called more than once.... | code_fim | hard | {
"lang": "rust",
"repo": "moyogo/norad",
"path": "/src/glyph/builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Ends the path begun by [`Self::begin_path`] and adds the contour to the glyph's outline, unless
/// it's empty.
///
/// Errors when:
/// 1. [`Self::begin_path`] wasn't called first.
/// 2. the point sequence is forbidden by the specification.
///
/// On error, it drops ... | code_fim | hard | {
"lang": "rust",
"repo": "moyogo/norad",
"path": "/src/glyph/builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vfx-rs/openexr-sys path: /src/imf_chromaticities.rs
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(unused_imports)]
use crate::*;
pub use crate::cppmmabi::*;
use std::os::raw::*;
#[repr(C, align(4))]
#[derive(Clone)]
pub struct Imf_3_0__Chro... | code_fim | hard | {
"lang": "rust",
"repo": "vfx-rs/openexr-sys",
"path": "/src/imf_chromaticities.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn Imf_3_0__Chromaticities_move(this_: *mut Imf_Chromaticities_t, rhs: *mut Imf_Chromaticities_t) -> Exception;
pub fn Imf_3_0__Chromaticities_dtor(this_: *mut Imf_Chromaticities_t) -> Exception;
} // extern "C"<|fim_prefix|>// repo: vfx-rs/openexr-sys path: /src/imf_chromaticities.rs
#![allow(non... | code_fim | medium | {
"lang": "rust",
"repo": "vfx-rs/openexr-sys",
"path": "/src/imf_chromaticities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn Imf_3_0__Chromaticities_ctor(this_: *mut Imf_Chromaticities_t, red: *const Imath_V2f_t, green: *const Imath_V2f_t, blue: *const Imath_V2f_t, white: *const Imath_V2f_t) -> Exception;
pub fn Imf_3_0__Chromaticities__eq(this_: *const Imf_Chromaticities_t, return_: *mut bool, v: *const Imf_Chromaticit... | code_fim | medium | {
"lang": "rust",
"repo": "vfx-rs/openexr-sys",
"path": "/src/imf_chromaticities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: richardwesthaver/demon path: /docs/demon-docs/build.rs
use std::{env, fs, path::Path};
<|fim_suffix|> let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("file_path.txt");
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "richardwesthaver/demon",
"path": "/docs/demon-docs/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("file_path.txt");
}<|fim_prefix|>// repo: richardwesthaver/demon path: /docs/demon-docs/build.rs
use std::{env, fs, path::Path};
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "richardwesthaver/demon",
"path": "/docs/demon-docs/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Finden-Labs/abstreet path: /game/src/ungap/mod.rs
:{nice_map_name, CityPicker, PopupMsg};
use map_gui::ID;
use map_model::{EditCmd, LaneType};
use widgetry::{
lctrl, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State, Text,
TextExt, Toggle, VerticalAlignmen... | code_fim | hard | {
"lang": "rust",
"repo": "Finden-Labs/abstreet",
"path": "/game/src/ungap/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.top_panel.draw(g);
self.legend.draw(g);
if g.canvas.cam_zoom < app.opts.min_zoom_for_detail {
self.network_layer.draw(g, app);
if self.elevation {
if let Some((_, ref draw)) = app.session.elevation_contours.value() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Finden-Labs/abstreet",
"path": "/game/src/ungap/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Finden-Labs/abstreet path: /game/src/ungap/mod.rs
legend: make_legend(ctx, app, false, false),
magnifying_glass: MagnifyingGlass::new(ctx),
network_layer: DrawNetworkLayer::new(),
edits_layer: render_edits(ctx, app),
elevation: false,
... | code_fim | hard | {
"lang": "rust",
"repo": "Finden-Labs/abstreet",
"path": "/game/src/ungap/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_name(&self) -> &'static str {
"bare-earth"
}
}<|fim_prefix|>// repo: Palaxx/rust-polygon-map-generator path: /src/terrains/bare_earth.rs
use crate::terrains::terrain::Terrain;
pub struct BareEarth {
}
impl Terrain for BareEarth {
fn get_color(&self) -> [u8; 3] {
<|fim_middle... | code_fim | easy | {
"lang": "rust",
"repo": "Palaxx/rust-polygon-map-generator",
"path": "/src/terrains/bare_earth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Palaxx/rust-polygon-map-generator path: /src/terrains/bare_earth.rs
use crate::terrains::terrain::Terrain;
pub struct BareEarth {
}
<|fim_suffix|> fn get_name(&self) -> &'static str {
"bare-earth"
}
}<|fim_middle|>impl Terrain for BareEarth {
fn get_color(&self) -> [u8; 3] ... | code_fim | medium | {
"lang": "rust",
"repo": "Palaxx/rust-polygon-map-generator",
"path": "/src/terrains/bare_earth.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: petr7555/Learning-Rust path: /05/dining_philosophers/src/main.rs
use std::sync::{Arc, mpsc, Mutex};
use std::thread;
use std::time::Duration;
use rand::prelude::*;
fn main() {
const NUM_OF_PHILOSOPHERS: usize = 5;
let mut handles = vec![];
let mut sticks = vec![];
for _ in 0..... | code_fim | hard | {
"lang": "rust",
"repo": "petr7555/Learning-Rust",
"path": "/05/dining_philosophers/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // thinking
sender.send(format!("Philosopher {} started thinking", philosopher_num)).unwrap();
thread::sleep(Duration::from_millis(rand::thread_rng().gen_range(20, 50)));
sender.send(format!("Philosopher {} stopped thinking", philosopher_num)... | code_fim | hard | {
"lang": "rust",
"repo": "petr7555/Learning-Rust",
"path": "/05/dining_philosophers/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gravechapa/oxidized_kernel path: /src/acpi/gas.rs
#[derive(Copy, Clone, Debug)]
#[repr(packed)]
pub struct Gas
{
pub address_space_id: u8,
pub re<|fim_suffix|>u8,
pub access_size: u8,
pub address: u64,
}<|fim_middle|>gister_bit_width: u8,
pub register_bit_offset: | code_fim | easy | {
"lang": "rust",
"repo": "Gravechapa/oxidized_kernel",
"path": "/src/acpi/gas.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>u8,
pub access_size: u8,
pub address: u64,
}<|fim_prefix|>// repo: Gravechapa/oxidized_kernel path: /src/acpi/gas.rs
#[derive(Copy, Clone, Debug)]
#[repr(packed)]
pub s<|fim_middle|>truct Gas
{
pub address_space_id: u8,
pub register_bit_width: u8,
pub register_bit_offset: | code_fim | medium | {
"lang": "rust",
"repo": "Gravechapa/oxidized_kernel",
"path": "/src/acpi/gas.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apendleton/static-bushes path: /src/kdbush/mod.rs
use num_traits::NumOps;
use core::borrow::Borrow;
use core::iter::FromIterator;
use crate::util::IndexVec;
mod exact;
mod range;
mod sort;
#[cfg(test)]
mod test;
mod within;
pub trait AllowedNumber: PartialOrd + NumOps + Copy
where
Self: ... | code_fim | hard | {
"lang": "rust",
"repo": "apendleton/static-bushes",
"path": "/src/kdbush/mod.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: AllowedNumber, U: Borrow<[T; 2]>> FromIterator<U> for KDBush<T> {
fn from_iter<I: IntoIterator<Item = U>>(points: I) -> Self {
let mut builder = KDBushBuilder::new();
builder.extend(points);
builder.finish()
}
}<|fim_prefix|>// repo: apendleton/static-bushes path: ... | code_fim | hard | {
"lang": "rust",
"repo": "apendleton/static-bushes",
"path": "/src/kdbush/mod.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: openqrnch/ddmw-util path: /src/lib.rs
//! A library dor common DDMW application utility functions.
pub mod app;
pub mod err;
<|fim_suffix|>// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :<|fim_middle|>pub use err::Error;
| code_fim | easy | {
"lang": "rust",
"repo": "openqrnch/ddmw-util",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :<|fim_prefix|>// repo: openqrnch/ddmw-util path: /src/lib.rs
//! A library dor common DDMW application utility functions.
pub mod app;
pub mod err;
<|fim_middle|>pub use err::Error;
| code_fim | easy | {
"lang": "rust",
"repo": "openqrnch/ddmw-util",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if weekday.is_some() {
Ok((input, DayOfMonthExpr::Last(Last::OffsetWeekday(offset))))
} else {
Ok((input, DayOfMonthExpr::Last(Last::Offset(offset))))
}
}
Some('W') =... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/saffron",
"path": "/saffron/src/parse.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn many_steps() {
assert_eq!(
months_expr("1/2,FEB/3,3/4"),
Ok(("", Expr::Many(exprs(vec![s(1, 2), s(2, 3), s(3, 4)]))))
)
}
#[test]
fn range_step() {
assert_eq!(
months_exp... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/saffron",
"path": "/saffron/src/parse.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/saffron path: /saffron/src/parse.rs
Some('-') => {
let offset = map_digit1::<DayOfMonthOffset>();
let (input, (offset, weekday)) = tuple((offset, opt(char('W'))))(input)?;
if weekday.is_some() {
Ok((in... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/saffron",
"path": "/saffron/src/parse.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod schema;
#[cfg(test)]
mod tests;
#[macro_use]
extern crate diesel;
extern crate dotenv;<|fim_prefix|>// repo: kvtx/rust_demo_api path: /src/lib.rs
mod db;
pub mod demolition;
pub mod models;
p<|fim_middle|>ub mod response_handler;
pub mod routes;
pub | code_fim | easy | {
"lang": "rust",
"repo": "kvtx/rust_demo_api",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvtx/rust_demo_api path: /src/lib.rs
mod db;
pub mod demolition;
pub mod models;
p<|fim_suffix|>mod schema;
#[cfg(test)]
mod tests;
#[macro_use]
extern crate diesel;
extern crate dotenv;<|fim_middle|>ub mod response_handler;
pub mod routes;
pub | code_fim | easy | {
"lang": "rust",
"repo": "kvtx/rust_demo_api",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvtx/rust_demo_api path: /src/lib.rs
mod db;
pub mod demolition;
pub mod models;
pub mod response_handler;
pub mod routes;
pub <|fim_suffix|>se]
extern crate diesel;
extern crate dotenv;<|fim_middle|>mod schema;
#[cfg(test)]
mod tests;
#[macro_u | code_fim | easy | {
"lang": "rust",
"repo": "kvtx/rust_demo_api",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_dep_graph_delta_serialize_non_empty() {
let mut x = DepGraphDelta::new();
x.insert(Dep::new(10), Dep::new(1));
x.insert(Dep::new(10), Dep::new(2));
x.insert(Dep::new(11), Dep::new(2));
x.insert(Dep::new(12), Dep::new(3));
let mut byte... | code_fim | hard | {
"lang": "rust",
"repo": "sbuzonas/hhvm",
"path": "/hphp/hack/src/deps/deps_rust/dep_graph_delta.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbuzonas/hhvm path: /hphp/hack/src/deps/deps_rust/dep_graph_delta.rs
// Copyright (c) Meta Platforms, Inc. and affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use std::collections::HashMap;
use std::c... | code_fim | hard | {
"lang": "rust",
"repo": "sbuzonas/hhvm",
"path": "/hphp/hack/src/deps/deps_rust/dep_graph_delta.rs",
"mode": "psm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_dep_graph_delta_serialize_empty() {
let x = DepGraphDelta::new();
let mut bytes = Vec::new();
x.write_to(&mut bytes).unwrap();
let mut y = DepGraphDelta::new();
let mut bytes_read: &[u8] = &bytes;
let num_loaded = y.read_from(&mut by... | code_fim | hard | {
"lang": "rust",
"repo": "sbuzonas/hhvm",
"path": "/hphp/hack/src/deps/deps_rust/dep_graph_delta.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryanmt95/adventOfCode path: /src/problems/day_two.rs
pub mod password_philosophy {
// this implements the debug trait on the struct
// allows you to print with {:?}
#[derive(Debug)]
struct PasswordConfig<'a> {
min: i32,
max: i32,
chr: char,
passwo... | code_fim | hard | {
"lang": "rust",
"repo": "ryanmt95/adventOfCode",
"path": "/src/problems/day_two.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let min_max: Vec<&str> = vec[0].split("-").collect();
PasswordConfig {
min: min_max[0].parse::<i32>().unwrap(),
max: min_max[1].parse::<i32>().unwrap(),
chr: vec[1].chars().next().unwrap(),
password: vec[2]
}
}
}<|fim_prefix|>// r... | code_fim | hard | {
"lang": "rust",
"repo": "ryanmt95/adventOfCode",
"path": "/src/problems/day_two.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let binary = serialize(injected_module).expect("serialization failed");
self::wabt::wasm2wat(&binary).unwrap();
}
#[test]
fn grow_no_gas_no_track() {
use parity_wasm::elements::Opcode::*;
let module = builder::module()
.global()
.value_type().i32()
.build()
.function()
.sign... | code_fim | hard | {
"lang": "rust",
"repo": "chebykin/wasm-utils",
"path": "/src/gas.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chebykin/wasm-utils path: /src/gas.rs
use parity_wasm::{elements, builder};
use rules;
pub fn update_call_index(opcodes: &mut elements::Opcodes, inserted_index: u32) {
use parity_wasm::elements::Opcode::*;
for opcode in opcodes.elements_mut().iter_mut() {
match opcode {
&mut Call(ref mut... | code_fim | hard | {
"lang": "rust",
"repo": "chebykin/wasm-utils",
"path": "/src/gas.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let module = builder::module()
.global()
.value_type().i32()
.build()
.function()
.signature().param().i32().build()
.body()
.with_opcodes(elements::Opcodes::new(
vec![
GetGlobal(0),
Block(elements::BlockType::NoResult),
GetGlobal(0),
GetGlo... | code_fim | hard | {
"lang": "rust",
"repo": "chebykin/wasm-utils",
"path": "/src/gas.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(IptvExtInf {
duration_secs,
name: name.to_string(),
iptv_props: props_map,
})
}
fn drop_extinf_tag(line: &str) -> Option<&str> {
line.get(8..)
}
mod split;
#[cfg(test)]
mod test;<|fim_prefix|>// repo: praveenperera/m3u path: /src/iptv/parse_extinf.rs
use self::... | code_fim | hard | {
"lang": "rust",
"repo": "praveenperera/m3u",
"path": "/src/iptv/parse_extinf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: praveenperera/m3u path: /src/iptv/parse_extinf.rs
use self::split::{next_closing_mark_index, split_key_val};
use crate::iptv::{IptvExtInf, IptvProps};
/// splits /EXTINF:-1( +[\w-]=".*")*,.*/
/// Example:
/// EXTINF:-1 tvg-id="" tvg-name="TF1",TF1
/// => IptvExtInf{
/// duration_secs:-1... | code_fim | hard | {
"lang": "rust",
"repo": "praveenperera/m3u",
"path": "/src/iptv/parse_extinf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azulus/pwasm-std path: /src/panic.rs
#![cfg(not(feature = "std"))]
extern "C" {
fn panic(payload_ptr: *const u8, payload_len: u32) -> !;
}
/// Overrides the default panic_fmt
#[cfg(not(feature = "panic_with_msg"))]
#[no_mangle]
#[lang = "panic_fmt"]
pub extern fn panic_fmt() -> ! {
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "azulus/pwasm-std",
"path": "/src/panic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dst = &mut self.buf[self.pos..self.pos+len];
self.pos += len;
dst
}
#[inline(always)]
fn write_u32(&mut self, val: u32) {
LittleEndian::write_u32(self.reserve(4), val);
}
#[inline(always)]
fn write_str(&mut self, bytes: &[u8]) {
self.write_u32(bytes.len() as u32);
self.... | code_fim | hard | {
"lang": "rust",
"repo": "azulus/pwasm-std",
"path": "/src/panic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbellani/cadence path: /cadence/examples/sending-tags.rs
// Cadence - An extensible Statsd client for Rust!
//
// To the extent possible under law, the author(s) have dedicated all copyright and
// related and neighboring rights to this file to the public domain worldwide.
// This software is di... | code_fim | medium | {
"lang": "rust",
"repo": "mbellani/cadence",
"path": "/cadence/examples/sending-tags.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> eprintln!("Error sending metrics: {}", err);
}
let client = StatsdClient::builder("my.prefix", NopMetricSink)
.with_error_handler(my_error_handler)
.build();
// In this case we are sending a counter metric with two tag key-value
// pairs. If sending the metric fai... | code_fim | medium | {
"lang": "rust",
"repo": "mbellani/cadence",
"path": "/cadence/examples/sending-tags.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Channels::new");
Channels {
emit: emit,
model: model,
list: vec![ChannelsItem::default(); 10]
}
}
fn emit(&self) -> &ChannelsEmitter {
println!("Channels::emit");
&self.emit
}
fn row_count(&self) -> usize... | code_fim | hard | {
"lang": "rust",
"repo": "waf/quack",
"path": "/rust/src/implementation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Application::emit");
&self.emit
}
fn channels(&self) -> &Channels {
&self.channels
}
fn channels_mut(&mut self) -> &mut Channels {
&mut self.channels
}
}
#[derive(Default, Clone)]
struct ChannelsItem {
name: String,
}
pub struct Channels ... | code_fim | hard | {
"lang": "rust",
"repo": "waf/quack",
"path": "/rust/src/implementation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: waf/quack path: /rust/src/implementation.rs
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use interface::*;
use std::collections::HashMap;
use std::env;
use config;
use failure::Error;
use slack_integration::connection::SlackConnection;
pub struct Application {
... | code_fim | hard | {
"lang": "rust",
"repo": "waf/quack",
"path": "/rust/src/implementation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: inspier/stevia path: /ast/src/formulas/or.rs
use crate::expr::utils::NaryBoolExpr;
mod marker {
use crate::{ExprKind, ExprMarker};
<|fim_suffix|> impl ExprMarker for OrMarker {
const EXPR_KIND: ExprKind = ExprKind::Or;
}
}
/// Or formula expression.
///
/// Represents bool... | code_fim | medium | {
"lang": "rust",
"repo": "inspier/stevia",
"path": "/ast/src/formulas/or.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Or formula expression.
///
/// Represents boolean disjunction for all boolean child expressions.
pub type Or = NaryBoolExpr<marker::OrMarker>;<|fim_prefix|>// repo: inspier/stevia path: /ast/src/formulas/or.rs
use crate::expr::utils::NaryBoolExpr;
mod marker {
use crate::{ExprKind, ExprMarker};... | code_fim | medium | {
"lang": "rust",
"repo": "inspier/stevia",
"path": "/ast/src/formulas/or.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub fn compile(program: &Program, class_name: &str, ctx: &mut JVMContext) -> io::Result<()> {
try!(create_prelude(program, class_name, ctx));
for stmt in &program.0 {
try!(stmt.compile(ctx))
}
try!(create_end(ctx));
Ok(())
}
fn create_prelude(program: &Program, class_name: ... | code_fim | hard | {
"lang": "rust",
"repo": "majeski/MRJ",
"path": "/instant/src/jvm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: majeski/MRJ path: /instant/src/jvm.rs
use std::collections::{HashMap, HashSet};
use std::ops::Deref;
use std::vec::Vec;
use std::{cmp, io, mem, vec};
use ast::{self, Operator};
type VariableMap = HashMap<String, usize>;
type VariableSet = HashSet<String>;
pub struct Program(vec::Vec<Stmt>);
... | code_fim | hard | {
"lang": "rust",
"repo": "majeski/MRJ",
"path": "/instant/src/jvm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wansenai/chassis path: /chassis/tests/singleton_deps.rs
use chassis::integration;
use std::sync::atomic::{AtomicUsize, Ordering};
macro_rules! instance_counter_cls {
($name:ident, $instances_name:ident) => {
static $instances_name: AtomicUsize = AtomicUsize::new(0);
pub str... | code_fim | hard | {
"lang": "rust",
"repo": "wansenai/chassis",
"path": "/chassis/tests/singleton_deps.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
#[test]
fn check_dep() {
use crate::int_mod::TestFactory;
InstanceCounter1::reset();
InstanceCounter2::reset();
let injector = crate::int_mod::TestFactoryImpl::new();
injector.provide_singleton1();
injector.provide_singleton1();
let singleton = injector.provide_singl... | code_fim | hard | {
"lang": "rust",
"repo": "wansenai/chassis",
"path": "/chassis/tests/singleton_deps.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn reset() {
$instances_name.store(0, Ordering::SeqCst)
}
}
};
}
instance_counter_cls!(InstanceCounter1, INSTANCES_1);
instance_counter_cls!(InstanceCounter2, INSTANCES_2);
#[integration]
mod int_mod {
use super::*;
use std::sync::Arc;
... | code_fim | hard | {
"lang": "rust",
"repo": "wansenai/chassis",
"path": "/chassis/tests/singleton_deps.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkachild/androgen path: /src/input.rs
use std::io::{stdout, stdin, Write};
<|fim_suffix|> print!("{}", text);
stdout().flush().expect("Unable to write to stdout");
stdin().read_line(&mut input).expect("Please input some text");
if let Some('\n') = input.chars().next_back() {
... | code_fim | medium | {
"lang": "rust",
"repo": "forkachild/androgen",
"path": "/src/input.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print!("{}", text);
stdout().flush().expect("Unable to write to stdout");
stdin().read_line(&mut input).expect("Please input some text");
if let Some('\n') = input.chars().next_back() {
input.pop();
}
input
}<|fim_prefix|>// repo: forkachild/androgen path: /src/input.rs
u... | code_fim | medium | {
"lang": "rust",
"repo": "forkachild/androgen",
"path": "/src/input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut leds = Leds::new(gpiod);
let mut i = 0;
loop {
for j in 0..leds.len() {
leds[j].off();
}
leds[i].on();
delay.delay_ms(100_u16);
i = (i + 1) % 4;
}
}<|fim_prefix|>// repo: ntr-808/f411 path: /examples/blinky.rs
//! Blinks an LED... | code_fim | hard | {
"lang": "rust",
"repo": "ntr-808/f411",
"path": "/examples/blinky.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[entry]
fn main() -> ! {
let cp = cortex_m::Peripherals::take().unwrap();
// stm32 in this case internally refers to the stm32f411 lib inside the HAL
let peripherals = stm32::Peripherals::take().unwrap();
let rcc = peripherals.RCC.constrain();
let gpiod = peripherals.GPIOD.split();
... | code_fim | medium | {
"lang": "rust",
"repo": "ntr-808/f411",
"path": "/examples/blinky.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ntr-808/f411 path: /examples/blinky.rs
//! Blinks an LED
#![deny(unsafe_code)]
// #![deny(warnings)]
#![no_std]
#![no_main]
// Panic handler
extern crate panic_semihosting;
use cortex_m_rt::entry;
use f411::{
led::{Leds},
hal::{delay::Delay, prelude::*, stm32},
};
<|fim_suffix|> le... | code_fim | hard | {
"lang": "rust",
"repo": "ntr-808/f411",
"path": "/examples/blinky.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mre/slack path: /src/slack_types.rs
//! Slack Response types. These are auto-generated from the response examples of the official API documentation.
// Example entry:
// #[derive(Debug, PartialEq, Serialize, Deserialize)]
// pub struct ImListResponse {}
/// Response type for api_test
#[derive(... | code_fim | hard | {
"lang": "rust",
"repo": "mre/slack",
"path": "/src/slack_types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Response type for groups_unarchive
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct GroupsUnarchiveResponse {}
/// Response type for im_close
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct ImCloseResponse {}
/// Response type for im_history
#[derive(Debug, PartialEq, Ser... | code_fim | hard | {
"lang": "rust",
"repo": "mre/slack",
"path": "/src/slack_types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Implement clockwise ordering.
impl PartialOrd for Direction {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.to_radians()
.partial_cmp(&other.to_radians())
.map(|ord| {
ord.reverse()
.then(self.squared_distance().c... | code_fim | hard | {
"lang": "rust",
"repo": "ocstl/advent-of-code-2019",
"path": "/src/bin/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = std::fs::read_to_string(INPUT_PATH)?;
let asteroids: Vec<Position> = input
.lines()
.enumerate()
.flat_map(|(y, line)| {
line.char_indices().filter_map(move |(x, ch)| {
if ch == ASTEROID {
Some(Position::new(x, y))... | code_fim | hard | {
"lang": "rust",
"repo": "ocstl/advent-of-code-2019",
"path": "/src/bin/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ocstl/advent-of-code-2019 path: /src/bin/day10.rs
use num::integer::Integer;
use std::cmp::Ordering;
use std::collections::{BTreeMap, BTreeSet, HashSet};
const ASTEROID: char = '#';
const INPUT_PATH: &str = "inputs/day10.txt";
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>... | code_fim | hard | {
"lang": "rust",
"repo": "ocstl/advent-of-code-2019",
"path": "/src/bin/day10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0
.get_any_value(i)
.map(|av| av.into_duration(self.time_unit()))
}
unsafe fn get_any_value_unchecked(&self, i: usize) -> AnyValue<'_> {
self.0
.get_any_value_unchecked(i)
.into_duration(self.time_unit())
}
fn cast(&self... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/chunked_array/logical/duration.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-core/src/chunked_array/logical/duration.rs
use super::*;
use crate::prelude::*;
pub type DurationChunked = Logical<DurationType, Int64Type>;
impl Int64Chunked {
pub fn into_duration(self, timeunit: TimeUnit) -> DurationChunked {
let mut dt = Dura... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/chunked_array/logical/duration.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_any_value(&self, i: usize) -> PolarsResult<AnyValue<'_>> {
self.0
.get_any_value(i)
.map(|av| av.into_duration(self.time_unit()))
}
unsafe fn get_any_value_unchecked(&self, i: usize) -> AnyValue<'_> {
self.0
.get_any_value_unchecked(i)... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/chunked_array/logical/duration.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xiuxiu62/engine-q path: /crates/nu-protocol/src/shell_error.rs
use miette::Diagnostic;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use crate::{ast::Operator, Span, Type};
#[derive(Debug, Clone, Error, Diagnostic, Serialize, Deserialize)]
pub enum ShellError {
#[error("Type m... | code_fim | hard | {
"lang": "rust",
"repo": "xiuxiu62/engine-q",
"path": "/crates/nu-protocol/src/shell_error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error("Command not found")]
#[diagnostic(code(nu::shell::command_not_found), url(docsrs))]
CommandNotFound(#[label("command not found")] Span),
#[error("Flag not found")]
#[diagnostic(code(nu::shell::flag_not_found), url(docsrs))]
FlagNotFound(String, #[label("{0} not found")] S... | code_fim | hard | {
"lang": "rust",
"repo": "xiuxiu62/engine-q",
"path": "/crates/nu-protocol/src/shell_error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> b"2positionChanged(Qt3DInput::QMouseEvent*)\0"
}
}
impl<'a> ::qt_core::connection::Signal for PositionChanged<'a> {}
/// Represents a built-in Qt signal `Qt3DInput::QMouseHandler::addedToEntity`.
///
/// An object of this type can be created from `MouseHandler` with `object.signals().a... | code_fim | hard | {
"lang": "rust",
"repo": "aristotle9/qt_generator-output",
"path": "/qt_3d_input/src/mouse_handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> b"1setShareable(bool)\0"
}
}
impl<'a> Slots<'a> {
/// Returns an object representing a built-in Qt slot `Qt3DInput::QMouseHandler::setSourceDevice`.
///
/// Return value of this function can be used for creating Qt connections using `qt_core::connection` API.
pub fn set_sourc... | code_fim | hard | {
"lang": "rust",
"repo": "aristotle9/qt_generator-output",
"path": "/qt_3d_input/src/mouse_handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.