text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
/// Prepare to draw and construct a [`ThemeDraw`] object
///
/// This is called once per window per frame and should do any necessary
/// preparation such as loading fonts and textures which are loaded on
/// demand.
///
/// Drawing via this [`ThemeDraw`] object is restricted ... | code_fim | hard | {
"lang": "rust",
"repo": "kas-gui/kas",
"path": "/crates/kas-core/src/theme/traits.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gfx-rs/metal-rs path: /examples/caps/main.rs
// Copyright 2017 GFX developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file m... | code_fim | medium | {
"lang": "rust",
"repo": "gfx-rs/metal-rs",
"path": "/examples/caps/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "private")]
{
println!("Vendor: {:?}", unsafe { device.vendor() });
println!("Family: {:?}", unsafe { device.family_name() });
}
println!(
"Max threads per threadgroup: {:?}",
device.max_threads_per_threadgroup()
);
#[cfg(target_os = ... | code_fim | medium | {
"lang": "rust",
"repo": "gfx-rs/metal-rs",
"path": "/examples/caps/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let device = Device::system_default().expect("no device found");
#[cfg(feature = "private")]
{
println!("Vendor: {:?}", unsafe { device.vendor() });
println!("Family: {:?}", unsafe { device.family_name() });
}
println!(
"Max threads per threadgroup:... | code_fim | medium | {
"lang": "rust",
"repo": "gfx-rs/metal-rs",
"path": "/examples/caps/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use panic_semihosting as _;
use cortex_m::asm;
use cortex_m_rt::entry;
use cortex_m_semihosting::{hprint, hprintln};
use stm32f3xx_hal::{self as hal, pac, prelude::*};
const VALID_ADDR_RANGE: Range<u8> = 0x08..0x78;
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
let mut... | code_fim | medium | {
"lang": "rust",
"repo": "IamfromSpace/stm32f3xx-hal",
"path": "/examples/i2c_scanner.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IamfromSpace/stm32f3xx-hal path: /examples/i2c_scanner.rs
//! Example of using I2C.
//! Scans available I2C devices on bus and print the result.
//! Appropriate pull-up registers should be installed on I2C bus.
//! Target board: STM32F3DISCOVERY
#![no_std]
#![no_main]
<|fim_suffix|>use panic_s... | code_fim | medium | {
"lang": "rust",
"repo": "IamfromSpace/stm32f3xx-hal",
"path": "/examples/i2c_scanner.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foresterre/advent-of-code-2018 path: /day_04b/src/main.rs
use std::collections::HashMap;
use lazy_static::lazy_static;
use regex::Regex;
const INPUT: &str = include_str!("../../input/04");
type GuardID = usize;
// At first I stored ranges instead, but this is much simpler when the guards slee... | code_fim | hard | {
"lang": "rust",
"repo": "foresterre/advent-of-code-2018",
"path": "/day_04b/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn example_given() {
let input = "[1518-11-01 00:00] Guard #10 begins shift
[1518-11-01 00:05] falls asleep
[1518-11-01 00:25] wakes up
[1518-11-01 00:30] falls asleep
[1518-11-01 00:55] wakes up
[1518-11-01 23:58] Guard #99 begins shift
[1518-11-02 00:40] falls asleep
[1518-11-02 ... | code_fim | hard | {
"lang": "rust",
"repo": "foresterre/advent-of-code-2018",
"path": "/day_04b/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> entry[i] += 1;
}
}
look_a_guard => {
for cap in GUARD_ID_MATCH.captures_iter(look_a_guard) {
let guard = &cap[1].parse::<GuardID>().expect(
"Is this guard an ... | code_fim | hard | {
"lang": "rust",
"repo": "foresterre/advent-of-code-2018",
"path": "/day_04b/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-skia/rust-skia path: /skia-safe/src/core/image_info.rs
use crate::{prelude::*, AlphaType, ColorSpace, ColorType, IPoint, IRect, ISize};
use skia_bindings::{self as sb, SkColorInfo, SkImageInfo};
use std::{fmt, mem};
pub use skia_bindings::SkYUVColorSpace as YUVColorSpace;
variant_name!(YUV... | code_fim | hard | {
"lang": "rust",
"repo": "rust-skia/rust-skia",
"path": "/skia-safe/src/core/image_info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_gamma_close_to_srgb(&self) -> bool {
self.color_info().is_gamma_close_to_srgb()
}
#[must_use]
pub fn with_dimensions(&self, new_dimensions: impl Into<ISize>) -> Self {
Self::from_color_info(new_dimensions, self.color_info().clone())
}
#[must_use]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "rust-skia/rust-skia",
"path": "/skia-safe/src/core/image_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: age-rs/fast_image_resize path: /src/lib.rs
#![doc = include_str!("../README.md")]
pub use alpha::{MulDiv, MulDivImageError, MulDivImagesError};
pub use convolution::FilterType;
pub use errors::*;
pub use image_view::{CropBox, ImageRows, ImageRowsMut, ImageView, ImageViewMut};
pub use pixels::Pi... | code_fim | easy | {
"lang": "rust",
"repo": "age-rs/fast_image_resize",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod alpha;
mod convolution;
mod errors;
mod image;
mod image_view;
mod pixels;
mod resizer;
#[cfg(target_arch = "x86_64")]
mod simd_utils;<|fim_prefix|>// repo: age-rs/fast_image_resize path: /src/lib.rs
#![doc = include_str!("../README.md")]
pub use alpha::{MulDiv, MulDivImageError, MulDivImagesError};... | code_fim | easy | {
"lang": "rust",
"repo": "age-rs/fast_image_resize",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blargg/game-theory path: /src/lib.rs
l Iterator<Item=Strategy> {
0..self.num_strats(player)
}
fn num_strats(&self, player: Player) -> usize {
self.grid.shape()[player]
}
pub fn util(&self, player: Player, strat_index: &Vec<Strategy>) -> f32 {
let mut pla... | code_fim | hard | {
"lang": "rust",
"repo": "blargg/game-theory",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blargg/game-theory path: /src/lib.rs
}
}
pub fn from_util_array(util_array: ArrayD<Util>) -> Game {
let util_axis = util_array.shape().len();
let mut exp_shape: Vec<_> = util_array.shape().iter().cloned().collect();
exp_shape.push(util_array.shape().len()... | code_fim | hard | {
"lang": "rust",
"repo": "blargg/game-theory",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_strictly_dominates() {
let pd = prisoners_dilemma();
assert!(pd.strictly_dominates(0,0,1), "Action 0 (telling) should strictly dominate action 1");
assert!(!pd.strictly_dominates(0,1,0), "Action 1 (keeping quiet) should not strictly dominate action 0");
... | code_fim | hard | {
"lang": "rust",
"repo": "blargg/game-theory",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Harnesser/arm-stm32 path: /valuelinediscovery/src/rotary_encoder.rs
//! examples/rotary-encoder.rs
//!
//! Driver to decode an incremental rotary encoder
//!
//! ## Pin connections
//!
//! +-------+
//! (in, pullup) | |
//! PA1 <---- o o ----> PA2, input with pullup.
... | code_fim | hard | {
"lang": "rust",
"repo": "Harnesser/arm-stm32",
"path": "/valuelinediscovery/src/rotary_encoder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl <'a> RotaryEncoder<'a> {
/// Initialise the pins for the rotary encoder
pub fn init(self, rcc: &Rcc) {
let gpioa = self.0;
// Power up GPIOA peripheral
rcc.apb2enr.modify(|_,w| w.iopaen().enabled());
// set up the pin directions
gpioa
.cr... | code_fim | hard | {
"lang": "rust",
"repo": "Harnesser/arm-stm32",
"path": "/valuelinediscovery/src/rotary_encoder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>static GPIOA_MASK : u32 = 0x0000_000C;
///
/// # Rotary Encoder
///
#[derive(Clone,Copy)]
pub struct RotaryEncoder<'a>(pub &'a Gpioa);
impl <'a> RotaryEncoder<'a> {
/// Initialise the pins for the rotary encoder
pub fn init(self, rcc: &Rcc) {
let gpioa = self.0;
// Power up GP... | code_fim | hard | {
"lang": "rust",
"repo": "Harnesser/arm-stm32",
"path": "/valuelinediscovery/src/rotary_encoder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // We should never drop below minimum
hi.difficulty = Difficulty::zero();
assert_eq!(
next_difficulty(1, repeat(90, hi, just_enough, None)).difficulty,
Difficulty::min()
);
}
// Builds an iterator for next difficulty calculation with the provided
// constant time interval, difficulty and total le... | code_fim | hard | {
"lang": "rust",
"repo": "mwcproject/mwc-node",
"path": "/core/tests/consensus_automated.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mwcproject/mwc-node path: /core/tests/consensus_automated.rs
// Copyright 2020 The Grin Developers
// 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://ww... | code_fim | hard | {
"lang": "rust",
"repo": "mwcproject/mwc-node",
"path": "/core/tests/consensus_automated.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agerasev/hypertrace path: /objects/src/macros/choice.rs
#[macro_export]
macro_rules! entity_choice {
{ $self:ident { $( $variant:ident($vtype:ty) ),* $(,)? } } => {
#[derive(Clone, type_macros::EntityId, type_macros::Entity, type_macros::SizedEntity, type_macros::EntitySource)]
... | code_fim | hard | {
"lang": "rust",
"repo": "agerasev/hypertrace",
"path": "/objects/src/macros/choice.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> $self::$variant(var)
}
}
)*
};
}<|fim_prefix|>// repo: agerasev/hypertrace path: /objects/src/macros/choice.rs
#[macro_export]
macro_rules! entity_choice {
{ $self:ident { $( $variant:ident($vtype:ty) ),* $(,)? } } => {
#[derive(Clon... | code_fim | hard | {
"lang": "rust",
"repo": "agerasev/hypertrace",
"path": "/objects/src/macros/choice.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::partition_labels("ababcbacadefegdehijhklij".to_string()), vec![9,7,8]);
}
#[test]
fn tast_2() {
assert_eq!(Solution::partition_labels("eccbbbbdec".to_string()), vec![10]);
}<|fim_prefix|>// repo: dmitry-pechersky/algorithms path: /leetcode/763_Partition_Labels.rs
struct Solu... | code_fim | medium | {
"lang": "rust",
"repo": "dmitry-pechersky/algorithms",
"path": "/leetcode/763_Partition_Labels.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmitry-pechersky/algorithms path: /leetcode/763_Partition_Labels.rs
struct Solution {}
impl Solution {
pub fn partition_labels(s: String) -> Vec<i32> {
let s = s.as_bytes();
let mut idx = [0; 26];
let mut res = vec![];
for (i, ch) in s.iter().map(|v| v - b'a'... | code_fim | medium | {
"lang": "rust",
"repo": "dmitry-pechersky/algorithms",
"path": "/leetcode/763_Partition_Labels.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> enum Human {
// c-like
Student { major: str, school: str, age: u8 },
Parent { children: u8, married: bool },
// unit-like
Dead,
// tuple-struct
Retired(retired_years, age),
}
// enums essentially represent an a set possible struc... | code_fim | hard | {
"lang": "rust",
"repo": "chaseguy15/bc",
"path": "/notes/9_15/custom_types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chaseguy15/bc path: /notes/9_15/custom_types.rs
fn main() {
//there are two custom types in Rust: structs and enums
// STRUCT
// a struct is declared with a name and fields
struct Student {
name: String,
age: u8,
}
// a structs fields can be ... | code_fim | hard | {
"lang": "rust",
"repo": "chaseguy15/bc",
"path": "/notes/9_15/custom_types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // METHODS
// methods are functions attached to objects
// methods are called by implementing the object
impl Student {
fn new(name: String, age: u8) -> (Student) {
Student{name, age}
}
fn display(&self) -> (String) {
format!("{},... | code_fim | hard | {
"lang": "rust",
"repo": "chaseguy15/bc",
"path": "/notes/9_15/custom_types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ompactionPriority, CompactOptions,
EINSTEINDB, DBBottommostLevelCompaction, DBCompactionFilter, DBCompactionStyle,
DBCompressionType, DBEntryType, DBInfoLogLevel, DBIterator, DBOptions,
DBRateLimiterMode, DBRecoveryMode, DBStatisticsTickerType, DBTitanDBBlobRunMode, Env,
EventListener, Ing... | code_fim | hard | {
"lang": "rust",
"repo": "CavHack/EinsteinDB",
"path": "/ einsteindb_core(0).einsteindb_core/fdb_lsh-tree/src/primitive_causet.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CavHack/EinsteinDB path: / einsteindb_core(0).einsteindb_core/fdb_lsh-tree/src/primitive_causet.rs
// Copyright 2020 EinsteinDB Project Authors. Licensed under Apache-2.0.
//! Reexports from the foundationdb crate
//!
//! This is a temporary artifact of refactoring. It exists to provide downstr... | code_fim | hard | {
"lang": "rust",
"repo": "CavHack/EinsteinDB",
"path": "/ einsteindb_core(0).einsteindb_core/fdb_lsh-tree/src/primitive_causet.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<P: Backoff + Clone> Backoff for RandomizedBackoff<P> {
fn time(&self, request: &mut HttpRequestParts, opts: BackoffOptions) -> GotBackoffDuration {
let duration = self.base_backoff().time(request, opts).duration();
let minification: Ratio<u128> = Ratio::new_raw(
self.m... | code_fim | hard | {
"lang": "rust",
"repo": "qiniu/rust-sdk",
"path": "/http-client/src/client/backoff/randomized.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qiniu/rust-sdk path: /http-client/src/client/backoff/randomized.rs
use super::{Backoff, BackoffOptions, GotBackoffDuration};
use qiniu_http::RequestParts as HttpRequestParts;
use rand::{thread_rng, Rng};
use std::{convert::TryInto, fmt::Debug, time::Duration, u64};
pub use num_rational::Ratio;
... | code_fim | hard | {
"lang": "rust",
"repo": "qiniu/rust-sdk",
"path": "/http-client/src/client/backoff/randomized.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mareknetusil/git-summary path: /src/main.rs
use std::process::Command;
use std::str;
// TUI
use std::io;
use termion::raw::IntoRawMode;
use tui::{Frame, Terminal};
use tui::style::{Style, Color, Modifier};
use tui::text::{Span, Spans};
use tui::backend::{Backend, TermionBackend};
use tui::widget... | code_fim | hard | {
"lang": "rust",
"repo": "mareknetusil/git-summary",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ntex-rs/ntex path: /ntex/src/web/error_default.rs
//! Web error
use std::{fmt, io, io::Write, str::Utf8Error};
use serde::de::value::Error as DeError;
use serde_json::error::Error as JsonError;
use serde_urlencoded::ser::Error as FormError;
use crate::http::body::Body;
use crate::http::helpers... | code_fim | hard | {
"lang": "rust",
"repo": "ntex-rs/ntex",
"path": "/ntex/src/web/error_default.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "openssl")]
/// `InternalServerError` for `openssl::ssl::HandshakeError`
impl<T: fmt::Debug + 'static> WebResponseError<DefaultError>
for tls_openssl::ssl::HandshakeError<T>
{
}
/// Return `BAD_REQUEST` for `de::value::Error`
impl WebResponseError<DefaultError> for DeError {
fn st... | code_fim | hard | {
"lang": "rust",
"repo": "ntex-rs/ntex",
"path": "/ntex/src/web/error_default.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>f index query (such as by timestamp).
///
/// 2) A filter. Currently this is just an annotation post-filter.
///
/// 3) Options. This includes behavior such as a maximum number of messages to return.
pub struct LogQuery;<|fim_prefix|>// repo: Xorlev/cascade path: /service/src/storage/query.rs
/// LogQuer... | code_fim | medium | {
"lang": "rust",
"repo": "Xorlev/cascade",
"path": "/service/src/storage/query.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>//
/// 3) Options. This includes behavior such as a maximum number of messages to return.
pub struct LogQuery;<|fim_prefix|>// repo: Xorlev/cascade path: /service/src/storage/query.rs
/// LogQuery is a Rust representation of a log query. A log query has three primary parts:
///
/// 1) A starting offset. ... | code_fim | medium | {
"lang": "rust",
"repo": "Xorlev/cascade",
"path": "/service/src/storage/query.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xorlev/cascade path: /service/src/storage/query.rs
/// LogQuery is a Rust representation of a log query. A log query has three primary parts:
///
/// 1) A starting offset. This can be either a special offset (earliest, latest), an actual u64
/// offset, or some kind o<|fim_suffix|>//
/// 3) O... | code_fim | medium | {
"lang": "rust",
"repo": "Xorlev/cascade",
"path": "/service/src/storage/query.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fredyw/leetcode path: /src/main/rust/src/bin/problem2500.rs
// https://leetcode.com/problems/delete-greatest-value-in-each-row/
pub fn delete_greatest_value(mut grid: Vec<Vec<i32>>) -> i32 {
for row in grid.iter_mut() {
row.sort_by(|a, b| b.cmp(a));
}
let mut answer = 0;
... | code_fim | medium | {
"lang": "rust",
"repo": "fredyw/leetcode",
"path": "/src/main/rust/src/bin/problem2500.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"{}",
delete_greatest_value(vec![vec![1, 2, 4], vec![3, 3, 1]])
); // 8
println!("{}", delete_greatest_value(vec![vec![10]])); // 10
}<|fim_prefix|>// repo: fredyw/leetcode path: /src/main/rust/src/bin/problem2500.rs
// https://leetcode.com/problems/delete-greatest-v... | code_fim | medium | {
"lang": "rust",
"repo": "fredyw/leetcode",
"path": "/src/main/rust/src/bin/problem2500.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl A for B {
type X = u8;
fn get_x() -> u8 { 0 }
}
fn underspecified_bound() -> u8
where
B: A
{
B::get_x()
}
fn inconsistent_bound() -> i32
where
B: A<X = i32>
{
B::get_x()
}
fn redundant_bound() -> u8
where
B: A<X = u8>
{
B::get_x()
}
fn inconsistent_dup_bound() -... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.rs
// run-pass
// Check that global bounds result in the expected choice of associated type
#![feature(trivial_bounds)]
#![allow(unused)]
struct B;
trait A {
type X;
fn get_x() -> ... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn underspecified_bound() -> u8
where
B: A
{
B::get_x()
}
fn inconsistent_bound() -> i32
where
B: A<X = i32>
{
B::get_x()
}
fn redundant_bound() -> u8
where
B: A<X = u8>
{
B::get_x()
}
fn inconsistent_dup_bound() -> i32
where
B: A<X = i32> + A
{
B::get_x()
}
fn redundan... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/elide-errors-on-mismatched-tuple.rs
// Hide irrelevant E0277 errors (#50333)
trait T {}
<|fim_suffix|>fn main() {
let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
//~^ ERROR mismatched types
let ts... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/elide-errors-on-mismatched-tuple.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {}
}
}
fn main() {
let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
//~^ ERROR mismatched types
let ts: Vec<&dyn T> = vec![&a, &b, &c];
// There is no E0277 error above, as `a`, `b` and `c` are `TyErr`
}<|fim_prefix|>// repo: IThawk/rust-... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/elide-errors-on-mismatched-tuple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bestra/lox-rs path: /src/lib.rs
pub mod scanner;
pub mod token;
pub mod ast;
pub mod parser;
pub mod interpreter;
pub mod en<|fim_suffix|>d lox_callable;
mod lox_function;
mod runtime;<|fim_middle|>vironment;
pub mod resolver;
mod lox_value;
mo | code_fim | easy | {
"lang": "rust",
"repo": "Bestra/lox-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>d lox_callable;
mod lox_function;
mod runtime;<|fim_prefix|>// repo: Bestra/lox-rs path: /src/lib.rs
pub mod scanner;
pub mod token;
pub mod ast;
pub mod parser;
pub mod interpreter;
pub mod en<|fim_middle|>vironment;
pub mod resolver;
mod lox_value;
mo | code_fim | easy | {
"lang": "rust",
"repo": "Bestra/lox-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bestra/lox-rs path: /src/lib.rs
pub mod scanner;
pub mod token;
pub mod ast;
p<|fim_suffix|>vironment;
pub mod resolver;
mod lox_value;
mod lox_callable;
mod lox_function;
mod runtime;<|fim_middle|>ub mod parser;
pub mod interpreter;
pub mod en | code_fim | easy | {
"lang": "rust",
"repo": "Bestra/lox-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KISSMonX/happyrust path: /HelloTrait/src/main.rs
use hello_trait::Summary;
use hello_trait::NewsArticle;
<|fim_suffix|> let na = NewsArticle {
headline: String::from("Hello headling"),
content: String::from("jkfad;gjask;gj;dslkajgdl;skagjds;lkahjdsklah😊... | code_fim | easy | {
"lang": "rust",
"repo": "KISSMonX/happyrust",
"path": "/HelloTrait/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("1 weibo reply: {}", na.summarize());
}<|fim_prefix|>// repo: KISSMonX/happyrust path: /HelloTrait/src/main.rs
use hello_trait::Summary;
use hello_trait::NewsArticle;
<|fim_middle|>
fn main() {
let na = NewsArticle {
headline: String::from("Hello headling"),
... | code_fim | hard | {
"lang": "rust",
"repo": "KISSMonX/happyrust",
"path": "/HelloTrait/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> };
println!("1 weibo reply: {}", na.summarize());
}<|fim_prefix|>// repo: KISSMonX/happyrust path: /HelloTrait/src/main.rs
use hello_trait::Summary;
use hello_trait::NewsArticle;
<|fim_middle|>
fn main() {
let na = NewsArticle {
headline: String::from("Hello hea... | code_fim | hard | {
"lang": "rust",
"repo": "KISSMonX/happyrust",
"path": "/HelloTrait/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(duration) = elapsed_time {
println!("Elapsed time:\t{}s", duration.num_seconds());
}
Ok(())
}
Self::CheckBad { cid } => {
let cid: Cid = cid.parse()?;
let response = sync... | code_fim | hard | {
"lang": "rust",
"repo": "0xb10ckdev/forest",
"path": "/src/cli/subcommands/sync_cmd.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xb10ckdev/forest path: /src/cli/subcommands/sync_cmd.rs
// Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use std::{
io::{stdout, Write},
time::Duration,
};
use crate::chain_sync::SyncStage;
use crate::json::cid::CidJson;
use crate::rpc_client::*;
us... | code_fim | hard | {
"lang": "rust",
"repo": "0xb10ckdev/forest",
"path": "/src/cli/subcommands/sync_cmd.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if response.is_empty() {
println!("Block \"{cid}\" is not marked as a bad block");
} else {
println!("response");
}
Ok(())
}
Self::MarkBad { cid } => {
let cid: C... | code_fim | hard | {
"lang": "rust",
"repo": "0xb10ckdev/forest",
"path": "/src/cli/subcommands/sync_cmd.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Texture {
name: name.into(),
image_buffer,
sampler,
}
}
/// Returns name of this texture.
pub fn name(&self) -> &str {
&self.name
}
/// Returns image buffer used by this texture.
pub fn image_buffer(&self) -> Arc<Immutab... | code_fim | hard | {
"lang": "rust",
"repo": "weclaw1/ketch",
"path": "/ketch-core/src/resource/texture.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: weclaw1/ketch path: /ketch-core/src/resource/texture.rs
use image::DynamicImage;
use vulkano::device::Device;
use std::sync::Arc;
use vulkano::device::Queue;
use vulkano::image::{ImmutableImage, Dimensions};
use vulkano::sampler::{Sampler, SamplerAddressMode, Filter, MipmapMode};
use vulkano::fo... | code_fim | hard | {
"lang": "rust",
"repo": "weclaw1/ketch",
"path": "/ketch-core/src/resource/texture.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Texture::new(name, loaded_image, upload_queue, device)
}
/// Creates new texture from loaded image.
pub fn new<S: Into<String>>(name: S, image: DynamicImage, upload_queue: Arc<Queue>, device: Arc<Device>) -> Self {
let image = image.flipv().to_rgba();
let (image_buffer... | code_fim | hard | {
"lang": "rust",
"repo": "weclaw1/ketch",
"path": "/ketch-core/src/resource/texture.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnmerritt/nphysics path: /examples2d/nphysics_testbed2d/src/objects/box_node.rs
use sfml::graphics;
use sfml::graphics::{RectangleShape, Color, RenderTarget, Shape, Transformable};
use sfml::system::Vector2f;
use na::{Point3, Isometry2};
use nphysics2d::object::WorldObject;
use objects;
use draw... | code_fim | hard | {
"lang": "rust",
"repo": "gnmerritt/nphysics",
"path": "/examples2d/nphysics_testbed2d/src/objects/box_node.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Box<'a> {
pub fn update(&mut self) {
objects::update_scene_node(&mut self.gfx, &self.object, &self.color, &self.delta)
}
pub fn draw(&self, rw: &mut graphics::RenderWindow) {
rw.draw(&self.gfx);
}
pub fn set_color(&mut self, color: Point3<u8>) {
self.... | code_fim | medium | {
"lang": "rust",
"repo": "gnmerritt/nphysics",
"path": "/examples2d/nphysics_testbed2d/src/objects/box_node.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x = ((self.opcode & 0x0f00) >> 8) as usize;
match self.opcode & 0x00ff {
0x07 => self.v[x] = self.delay,
0x15 => self.delay = self.v[x],
0x18 => self.sound = self.v[x],
0x1E => {
self.i += self.v[x] as u16;
println!("{:?}", self.i);
},
0x29 => {
self.i = (self.v[x] as... | code_fim | hard | {
"lang": "rust",
"repo": "queirosa/chip8",
"path": "/src/cpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: queirosa/chip8 path: /src/cpu.rs
use std::fs::File;
use std::io::Read;
use std::iter::Enumerate;
use rand;
use rand::Rng;
use display::Display;
use std::mem::transmute;
const FONT: [u8; 80] = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0... | code_fim | hard | {
"lang": "rust",
"repo": "queirosa/chip8",
"path": "/src/cpu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn treat_opcode(&mut self) {
println!("{:?}", (self.opcode, self.pc));
match (self.opcode & 0xf000) >> 12{
0x0 => self.treat_0_opcode(),
0x1 => self.treat_1_opcode(),
0x2 => self.treat_2_opcode(),
0x3 => self.treat_3_opcode(),
0x4 => self.treat_4_opcode(),
0x5 => self.treat_5_o... | code_fim | hard | {
"lang": "rust",
"repo": "queirosa/chip8",
"path": "/src/cpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(8, offsets.vmctx_runtime_limits());
assert_eq!(24, offsets.ptr.vmruntime_limits_last_wasm_exit_fp());
assert_eq!(32, offsets.ptr.vmruntime_limits_last_wasm_exit_pc());
assert_eq!(8, offset_of!(VMHostFuncContext, host_func));
}
}
#[rustfmt::skip]
macro_rules!... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/wasmtime",
"path": "/crates/runtime/src/trampolines/riscv64.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Store the last Wasm PC into the `last_wasm_exit_pc` in the limits.
sd ra, 32(t0)
// Tail call to the actual implementation of this libcall.
j {}
.cfi_endproc
",
),
... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/wasmtime",
"path": "/crates/runtime/src/trampolines/riscv64.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexcrichton/wasmtime path: /crates/runtime/src/trampolines/riscv64.rs
use wasmtime_asm_macros::asm_func;
#[rustfmt::skip]
asm_func!(
"host_to_wasm_trampoline",
r#"
.cfi_startproc
// Load the pointer to `VMRuntimeLimits` in `t0`.
ld t0, 8(a1)
// Check t... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/wasmtime",
"path": "/crates/runtime/src/trampolines/riscv64.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: taritom/bn-api path: /api/src/extractors/user.rs
use actix_web::error::*;
use actix_web::{FromRequest, HttpRequest};
use auth::claims;
use auth::user::User;
use bigneon_db::models::User as DbUser;
use errors::*;
use jwt::{decode, Validation};
use middleware::RequestConnection;
use server::AppSta... | code_fim | hard | {
"lang": "rust",
"repo": "taritom/bn-api",
"path": "/api/src/extractors/user.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> match parts.next() {
Some(access_token) => {
let token = decode::<claims::AccessToken>(
&access_token,
(*req.state()).config.token_secret.as_bytes(),
&Validation:... | code_fim | hard | {
"lang": "rust",
"repo": "taritom/bn-api",
"path": "/api/src/extractors/user.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /bt/nsIAutoCompleteSimpleResult.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIAutoCompleteSimpleResult.idl
//
{static D: &'static [Interface] = &[
Interface {
name: "nsIAutoCompleteSimpleResult",
base: So... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/bt/nsIAutoCompleteSimpleResult.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ]),
},
Interface {
name: "nsIAutoCompleteSimpleResultListener",
base: Some("nsISupports"),
methods: Some(&[
/* void onValueRemoved (in nsIAutoCompleteSimpleResult aResult, in AString aValue, in boolean aRemoveFro... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/bt/nsIAutoCompleteSimpleResult.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* nsIAutoCompleteSimpleResultListener getListener (); */
Method {
name: "getListener",
abi: "C",
params: &[Param { name: "_retval", ty: "*mut *const nsIAutoCompleteSimpleResultListener" }],
... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/bt/nsIAutoCompleteSimpleResult.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imalsogreg/covid-tracing-sim path: /src/params.rs
use serde::Deserialize;
<|fim_suffix|>#[derive(Debug, PartialEq, Deserialize)]
pub struct Params {
pub step_size_seconds : u32,
pub simulation_length_seconds : u32,
pub environment : Vec<environment::Element>,
}<|fim_middle|>use crat... | code_fim | easy | {
"lang": "rust",
"repo": "imalsogreg/covid-tracing-sim",
"path": "/src/params.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq, Deserialize)]
pub struct Params {
pub step_size_seconds : u32,
pub simulation_length_seconds : u32,
pub environment : Vec<environment::Element>,
}<|fim_prefix|>// repo: imalsogreg/covid-tracing-sim path: /src/params.rs
use serde::Deserialize;
<|fim_middle|>use crat... | code_fim | easy | {
"lang": "rust",
"repo": "imalsogreg/covid-tracing-sim",
"path": "/src/params.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nical/pathfinder path: /pathfinder-classic/examples/lorem-ipsum.rs
(RECT_INDICES.len() * mem::size_of::<u32>()) as GLsizeiptr,
RECT_INDICES.as_ptr() as *const GLvoid,
gl::STATIC_DRAW);
}
// FIXME(pcwalt... | code_fim | hard | {
"lang": "rust",
"repo": "nical/pathfinder",
"path": "/pathfinder-classic/examples/lorem-ipsum.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.rasterizer.queue().flush().unwrap();
unsafe {
if self.shading_language == ShadingLanguage::Glsl {
gl::MemoryBarrier(gl::SHADER_IMAGE_ACCESS_BARRIER_BIT |
gl::TEXTURE_FETCH_BARRIER_BIT);
}
gl::Viewp... | code_fim | hard | {
"lang": "rust",
"repo": "nical/pathfinder",
"path": "/pathfinder-classic/examples/lorem-ipsum.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nical/pathfinder path: /pathfinder-classic/examples/lorem-ipsum.rs
}
}
fn determine_visible_glyphs(&self,
atlas_builder: &mut AtlasBuilder,
font: &Font,
glyph_store: &GlyphStore,
... | code_fim | hard | {
"lang": "rust",
"repo": "nical/pathfinder",
"path": "/pathfinder-classic/examples/lorem-ipsum.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(non_camel_case_types)]
pub struct #struct_ident;
impl crate::host_function::NativeHostFunction for #struct_ident {
fn to_function_pointer(self) -> usize {
// Safety: see the Nomicon: https://rust-lang.github.io/unsafe-code-guidelines/layout/func... | code_fim | hard | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/plugin-host/macros/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: feather-rs/feather path: /feather/plugin-host/macros/src/lib.rs
use quote::{format_ident, quote};
use syn::{FnArg, GenericArgument, PathSegment};
/// Annotates a function so that it implements
/// the NativeHostFunction trait.
#[proc_macro_attribute]
pub fn host_function(
_args: proc_macro:... | code_fim | hard | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/plugin-host/macros/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ischeinkman/chip8-emu path: /src/chip8_mod/interpretted_cpu.rs
use chip8_mod::cpu::{OpcodeExecuter, InstructionSet};
use chip8_mod::display::{ScreenBuffer, SCREEN_HEIGHT, SCREEN_WIDTH};
use chip8_mod::audio::AudioTimer;
use chip8_mod::input::InputReciever;
use chip8_mod::default_fontset::*;
use... | code_fim | hard | {
"lang": "rust",
"repo": "ischeinkman/chip8-emu",
"path": "/src/chip8_mod/interpretted_cpu.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.instruction_set {
InstructionSet::COWGOD => {
self.registerV[0xF] = self.registerV[acc] >> 7;
self.registerV[acc] = self.registerV[acc] << 1;
}
InstructionSet::LEGACY => {
self.registerV[0xF] = self.regi... | code_fim | hard | {
"lang": "rust",
"repo": "ischeinkman/chip8-emu",
"path": "/src/chip8_mod/interpretted_cpu.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Java byte code parser starts!");
for argument in env::args() {
println!("*** args = {}", argument);
}
let mut java_class = JavaClass::new();
java_class.load("resources/hi.class");
java_class.print_info();
}<|fim_prefix|>// repo: pombredanne/java-bytecode-parser ... | code_fim | easy | {
"lang": "rust",
"repo": "pombredanne/java-bytecode-parser",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pombredanne/java-bytecode-parser path: /src/main.rs
mod class_loader;
use std::env;
use class_loader::JavaClass;
/*
* Author: Tenton Lien
* Date: 10/9/2020
*/
<|fim_suffix|> println!("Java byte code parser starts!");
for argument in env::args() {
println!("*** args = {}", ar... | code_fim | easy | {
"lang": "rust",
"repo": "pombredanne/java-bytecode-parser",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if response string length equals result and callback length plus 12 characters then it is correct.
reslen == rlen + clen + 12
}
// If Err, get length of Err and Error callback
Err(err) => {
let eclen = ec.len();
let errlen = err.len();
// pass e... | code_fim | hard | {
"lang": "rust",
"repo": "liusong1111/tauri",
"path": "/tauri-api/src/rpc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liusong1111/tauri path: /tauri-api/src/rpc.rs
pub fn format_callback(function_name: String, arg: String) -> String {
let formatted_string = &format!("window[\"{}\"]({})", function_name, arg);
formatted_string.to_string()
}
pub fn format_callback_result(
result: Result<String, String>,
c... | code_fim | hard | {
"lang": "rust",
"repo": "liusong1111/tauri",
"path": "/tauri-api/src/rpc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //slices
let s3 = String::from("I love me!")
}
//user defined functions
fn takes_ownership(s :String){
println!("{}", s);
}
fn makes_copy(x :u32) {
println!("{}", x);
}
fn get_length(s: String) -> (String,usize) {
let len = s.len();
(s, len)
}
fn calculate_length(s: &String) -> u... | code_fim | medium | {
"lang": "rust",
"repo": "niranjana687/rust_book",
"path": "/ownership/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niranjana687/rust_book path: /ownership/src/main.rs
fn main() {
let s = String::from("Hello");
takes_ownership(s);
let x = 5;
makes_copy(x);
let s1 = String::from("Helloiiii");
let (st, len) = get_length(s1);
println!("{} {}", st, len);
let mut s2 = String::from("I ... | code_fim | medium | {
"lang": "rust",
"repo": "niranjana687/rust_book",
"path": "/ownership/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn makes_copy(x :u32) {
println!("{}", x);
}
fn get_length(s: String) -> (String,usize) {
let len = s.len();
(s, len)
}
fn calculate_length(s: &String) -> usize {
s.len()
}
fn change(some_string: &mut String) {
some_string.push_str(". Yesss I am goingggg");
}
fn first_word(s: &Stri... | code_fim | medium | {
"lang": "rust",
"repo": "niranjana687/rust_book",
"path": "/ownership/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn async_main() -> Result<(), MyError> {
// Create a connection pool
let pool = MySqlPool::builder()
.max_size(5) // maximum number of connections in the pool
.build(&env::var("TOKENSERVER_DATABASE_URL")?).await?;
// Make a simple query to return the given parameter
... | code_fim | hard | {
"lang": "rust",
"repo": "fzzzy/use-sqlx",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Make a simple query to return the given parameter
let mut rows = sqlx::query("SELECT uid, service, email, generation, client_state, created_at, replaced_at, nodeid, keys_changed_at from users")
.map(|row: MySqlRow| {
// map the row into a user-defined domain type
... | code_fim | hard | {
"lang": "rust",
"repo": "fzzzy/use-sqlx",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fzzzy/use-sqlx path: /src/main.rs
use std::env;
use sqlx::prelude::*;
use sqlx::{Cursor, mysql::{MySqlPool, MySqlRow}};
use async_std::task;
use futures::TryStreamExt;
#[derive(Debug)]
enum MyError {
SqlXError(sqlx::Error),
EnvError(env::VarError),
}
impl From<sqlx::Error> for MyError ... | code_fim | hard | {
"lang": "rust",
"repo": "fzzzy/use-sqlx",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args: Vec<String> = std::env::args().collect();
if args.len() != 2 {
println!("Provide one argument with the path to the input");
return;
}
let file = std::fs::File::open(&args[1]).unwrap();
let reader = std::io::BufReader::new(file);
let module_masses: Vec<i64>... | code_fim | hard | {
"lang": "rust",
"repo": "CattleProdigy/advent-of-code-2019",
"path": "/01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CattleProdigy/advent-of-code-2019 path: /01/src/main.rs
use std::io::prelude::*;
fn fuel_mass_for_module(module_mass: &i64) -> i64 {
std::cmp::max(0, (*module_mass / 3) - 2)
}
fn fuel_mass_for_module_with_fuel_for_fuel(module_mass: &i64) -> i64 {
if *module_mass <= 0 {
return 0... | code_fim | hard | {
"lang": "rust",
"repo": "CattleProdigy/advent-of-code-2019",
"path": "/01/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cart/amethyst-bunnymark path: /src/bunnymark/move_bunnies_system.rs
use amethyst::ecs::ReadExpect;
use bunnymark::BunnyResource;
use amethyst::{
core::{Time, Transform},
ecs::prelude::{Join, Read, System, WriteStorage},
utils::fps_counter::FPSCounter,
};
use bunnymark::Bunny;
use rand::random... | code_fim | hard | {
"lang": "rust",
"repo": "cart/amethyst-bunnymark",
"path": "/src/bunnymark/move_bunnies_system.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.elapsed += time.delta_seconds();
if self.elapsed > 2.0 {
println!("{}", fps_counter.sampled_fps());
self.elapsed = 0.0;
}
for (bunny, transform) in (&mut bunnies, &mut transforms).join() {
let translation = transform.translation;
let mut new_translation = transform.translation;
... | code_fim | hard | {
"lang": "rust",
"repo": "cart/amethyst-bunnymark",
"path": "/src/bunnymark/move_bunnies_system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl hsm::State<Context, Event> for TheState {
fn parent(&self) -> Option<&'static dyn hsm::State<Context, Event>> {
Some(&ROOT_STATE)
}
fn entry(&self, context: &mut Context) {
context.the_entry += 1;
}
fn transition(&self, context: &mut Context, event: &Event) -> Tr... | code_fim | hard | {
"lang": "rust",
"repo": "tagunil/hsm-rs",
"path": "/tests/suite_0.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn multi_self() {
let mut context = Context {
the_entry: 0,
internal_action: 0,
external_action: 0,
the_exit: 0,
};
let mut machine = create_machine();
assert!(core::ptr::eq(machine.active(), &INITIAL_STATE));
initial_step(&mut machine, &mut con... | code_fim | hard | {
"lang": "rust",
"repo": "tagunil/hsm-rs",
"path": "/tests/suite_0.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tagunil/hsm-rs path: /tests/suite_0.rs
use hsm;
struct Context {
the_entry: usize,
internal_action: usize,
external_action: usize,
the_exit: usize,
}
enum Event {
Initial,
Internal,
External,
}
type Transition = hsm::Transition<Context, Event>;
type StateMachine =... | code_fim | hard | {
"lang": "rust",
"repo": "tagunil/hsm-rs",
"path": "/tests/suite_0.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
debug!("Iteration for block: {}", head_hash);
let children = match self.children.get(&head_hash) {
Some(children) => children,
// we have found the head, exit
None => break,
};
// if we only ha... | code_fim | hard | {
"lang": "rust",
"repo": "mluluz/lighthouse",
"path": "/eth2/fork_choice/src/slow_lmd_ghost.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let latest_votes = self.get_latest_votes(&start_state_root, start.slot, spec)?;
let mut head_hash = *justified_block_start;
loop {
debug!("Iteration for block: {}", head_hash);
let children = match self.children.get(&head_hash) {
Some(chil... | code_fim | hard | {
"lang": "rust",
"repo": "mluluz/lighthouse",
"path": "/eth2/fork_choice/src/slow_lmd_ghost.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mluluz/lighthouse path: /eth2/fork_choice/src/slow_lmd_ghost.rs
extern crate db;
use crate::{ForkChoice, ForkChoiceError};
use db::{
stores::{BeaconBlockStore, BeaconStateStore},
ClientDB,
};
use log::{debug, trace};
use std::collections::HashMap;
use std::sync::Arc;
use types::{BeaconB... | code_fim | hard | {
"lang": "rust",
"repo": "mluluz/lighthouse",
"path": "/eth2/fork_choice/src/slow_lmd_ghost.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: micaww/ch8-rs path: /src/disassembler.rs
// opcode definitions here: https://en.wikipedia.org/wiki/CHIP-8
#[derive(Debug)]
pub enum OpCode {
ClearDisplay, // 00E0
Return, // 00EE
Jump(u16), // 1NNN
Call(u16), // 2NNN
SkipEqVal(u8, u8), // 3XNN
SkipNotEqVal(u8, u8), // 4X... | code_fim | hard | {
"lang": "rust",
"repo": "micaww/ch8-rs",
"path": "/src/disassembler.rs",
"mode": "psm",
"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.