text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: 71/styx-history path: /styx.rs/src/symbols.rs
//! Styx symbols are global identifiers for `Member`s, such as types or functions.
//!
//! This module provides the `Symbol` trait, useful for symbol lookup,
//! the `Sym` struct, its main implementation, and the `SymbolTree`, used to
//! efficiently... | code_fim | hard | {
"lang": "rust",
"repo": "71/styx-history",
"path": "/styx.rs/src/symbols.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mem::replace(&mut self.node, node.map(|s| s as &_))
}
}
}
}
/// An `Iterator` over every node of a `SymbolTree`.
pub enum TreeIterator<'a, T: 'a> {
/// Iterating over a single child.
Child(&'a SymbolTree<T>),
/// Iterating over children of a node.
... | code_fim | hard | {
"lang": "rust",
"repo": "71/styx-history",
"path": "/styx.rs/src/symbols.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jkcomment/anonify path: /modules/anonify-enclave/src/config.rs
pub const MY_ROSTER_IDX: usize = 0;
pub const MAX_ROSTER_IDX: usize = 2;
pub const TEST_SPID:<|fim_suffix|>dev/attestation/v3/report";
pub const TEST_SUB_KEY: &str = "77e2533de0624df28dc3be3a5b9e50d9";<|fim_middle|> &str = "2C149BFC9... | code_fim | medium | {
"lang": "rust",
"repo": "jkcomment/anonify",
"path": "/modules/anonify-enclave/src/config.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>dev/attestation/v3/report";
pub const TEST_SUB_KEY: &str = "77e2533de0624df28dc3be3a5b9e50d9";<|fim_prefix|>// repo: jkcomment/anonify path: /modules/anonify-enclave/src/config.rs
pub const MY_ROSTER_IDX: usize = 0;
pub const MAX_ROSTER_IDX: usize = 2;
pub const TEST_SPID:<|fim_middle|> &str = "2C149BFC9... | code_fim | medium | {
"lang": "rust",
"repo": "jkcomment/anonify",
"path": "/modules/anonify-enclave/src/config.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmarov/img-uploader path: /src/controller/img_uploader.rs
use actix_web::{web, HttpResponse, Error};
use futures::future::{ok, Future};
use serde::Deserialize;
use crate::core::img_processing::UploadWithThumbnailFuture;
#[derive(Deserialize)]
pub struct RequestModel {
urls: Vec<String>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "dmarov/img-uploader",
"path": "/src/controller/img_uploader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Box::new(ok::<_, Error>(
HttpResponse::NoContent()
.finish()
))
}<|fim_prefix|>// repo: dmarov/img-uploader path: /src/controller/img_uploader.rs
use actix_web::{web, HttpResponse, Error};
use futures::future::{ok, Future};
use serde::Deserialize;
use crate::core::img_processi... | code_fim | medium | {
"lang": "rust",
"repo": "dmarov/img-uploader",
"path": "/src/controller/img_uploader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cssivision/awak path: /src/parking.rs
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
use std::sync::{Arc, Condvar, Mutex};
use std::time::Duration;
pub fn pair() -> (Parker, Unparker) {
let p = Parker::new();
let u = p.unparker();
(p, u)
}
pub struct Parker {
unparker:... | code_fim | hard | {
"lang": "rust",
"repo": "cssivision/awak",
"path": "/src/parking.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Unparker {
inner: self.inner.clone(),
}
}
}
pub struct Unparker {
inner: Arc<Inner>,
}
const EMPTY: usize = 0;
const PARKED: usize = 1;
const NOTIFIED: usize = 2;
struct Inner {
state: AtomicUsize,
lock: Mutex<()>,
cvar: Condvar,
}
impl Inner {
fn pa... | code_fim | hard | {
"lang": "rust",
"repo": "cssivision/awak",
"path": "/src/parking.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn unpark(&self) -> bool {
// To ensure the unparked thread will observe any writes we made before this call, we must
// perform a release operation that `park` can synchronize with. To do that we must write
// `NOTIFIED` even if `state` is already `NOTIFIED`. That is why this ... | code_fim | hard | {
"lang": "rust",
"repo": "cssivision/awak",
"path": "/src/parking.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match variant {
RESERVED7_A::RESERVED7_0 => false,
RESERVED7_A::RESERVED7_1 => true,
}
}
}
#[doc = "Reader of field `Reserved7`"]
pub type RESERVED7_R = crate::R<bool, RESERVED7_A>;
impl RESERVED7_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&s... | code_fim | hard | {
"lang": "rust",
"repo": "rv32m1-rust/rv32m1_ri5cy-pac",
"path": "/src/llwu0/de.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rv32m1-rust/rv32m1_ri5cy-pac path: /src/llwu0/de.rs
E0_A {
match self.bits {
false => WUDE0_A::WUDE0_0,
true => WUDE0_A::WUDE0_1,
}
}
#[doc = "Checks if the value of the field is `WUDE0_0`"]
#[inline(always)]
pub fn is_wude0_0(&self) -> bool {
*self == WUDE0_A::WU... | code_fim | hard | {
"lang": "rust",
"repo": "rv32m1-rust/rv32m1_ri5cy-pac",
"path": "/src/llwu0/de.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rv32m1-rust/rv32m1_ri5cy-pac path: /src/llwu0/de.rs
r super::DE {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "DMA/Trigger wakeup enable for module n\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum WUDE0_A {
#[doc = "0:... | code_fim | hard | {
"lang": "rust",
"repo": "rv32m1-rust/rv32m1_ri5cy-pac",
"path": "/src/llwu0/de.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn compute_hyperparameter_grid(
config: &Option<Config>,
task: &Task,
target_column_index: usize,
train_column_stats: &[stats::ColumnStatsOutput],
) -> Vec<grid::GridItem> {
config
.as_ref()
.and_then(|config| config.grid.as_ref())
.map(|grid| match &task {
Task::Regression => grid::compute... | code_fim | hard | {
"lang": "rust",
"repo": "draftedus/tangram",
"path": "/core/train.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: draftedus/tangram path: /core/train.rs
tions {
let mut linear_options = tangram_linear::TrainOptions::default();
linear_options.compute_losses = true;
if let Some(l2_regularization) = options.l2_regularization {
linear_options.l2_regularization = l2_regularization;
}
if let Some(learning_... | code_fim | hard | {
"lang": "rust",
"repo": "draftedus/tangram",
"path": "/core/train.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct TreeRegressionModel {
pub model: tangram_tree::Regressor,
pub train_options: tangram_tree::TrainOptions,
pub feature_groups: Vec<tangram_features::FeatureGroup>,
pub losses: Option<Vec<f32>>,
pub feature_importances: Vec<f32>,
}
enum RegressionComparisonMetric {
MeanAbsoluteError,
MeanSquar... | code_fim | hard | {
"lang": "rust",
"repo": "draftedus/tangram",
"path": "/core/train.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkmik/influxdb_iox path: /object_store/src/gcp.rs
//! This module contains the IOx implementation for using Google Cloud Storage
//! as the object store.
use crate::{
path::{cloud::CloudConverter, ObjectStorePath},
DataDoesNotMatchLength, Result, UnableToDeleteDataFromGcs, UnableToGetDat... | code_fim | hard | {
"lang": "rust",
"repo": "mkmik/influxdb_iox",
"path": "/object_store/src/gcp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Error::UnableToDeleteDataFromGcs {
source,
bucket,
location,
} = err
{
assert!(matches!(source, cloud_storage::Error::Google(_)));
assert_eq!(bucket, bucket_name);
assert_eq!(location, NON_EXISTENT_NAME)... | code_fim | hard | {
"lang": "rust",
"repo": "mkmik/influxdb_iox",
"path": "/object_store/src/gcp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn init(ctx: &PyContext) {
let ref memoryview_type = ctx.memoryview_type;
ctx.set_attr(
&memoryview_type,
"__new__",
ctx.new_rustfunc(new_memory_view),
);
}<|fim_prefix|>// repo: cwlseu/RustPython path: /vm/src/obj/objmemory.rs
use super::objtype;
use super::super... | code_fim | hard | {
"lang": "rust",
"repo": "cwlseu/RustPython",
"path": "/vm/src/obj/objmemory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cwlseu/RustPython path: /vm/src/obj/objmemory.rs
use super::objtype;
use super::super::pyobject::{
PyContext, PyFuncArgs, PyObject, PyObjectPayload, PyObjectRef, PyResult, TypeProtocol,
};
use super::super::vm::VirtualMachine;
<|fim_suffix|>pub fn init(ctx: &PyContext) {
let ref memory... | code_fim | hard | {
"lang": "rust",
"repo": "cwlseu/RustPython",
"path": "/vm/src/obj/objmemory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foresterre/advent-of-code-2018 path: /day_01a/src/main.rs
const INPUT: &str = include_str!("../../input/01");
fn solution(input: &str) -> i32 {
input.lines().filter_map(|x| x.parse::<i32>().ok()).sum()
}
<|fim_suffix|> println!("Solution: {}", solution(INPUT));
}
#[cfg(test)]
mod tests... | code_fim | easy | {
"lang": "rust",
"repo": "foresterre/advent-of-code-2018",
"path": "/day_01a/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn chronal_calibration_part_1() {
assert_eq!(574, solution(INPUT));
}
}<|fim_prefix|>// repo: foresterre/advent-of-code-2018 path: /day_01a/src/main.rs
const INPUT: &str = include_str!("../../input/01");
fn solution(input: &str) -> i32 {
input.lines().filter_map(|x| x.par... | code_fim | medium | {
"lang": "rust",
"repo": "foresterre/advent-of-code-2018",
"path": "/day_01a/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Swaps parameters
parameter_types! {
pub const ExitFee: Balance = 0;
pub const MaxAssets: usize = MaxCategories::get() as usize + 1;
pub const MaxInRatio: Balance = BASE / 2;
pub const MaxOutRatio: Balance = (BASE / 3) + 1;
pub const MaxTotalWeight: Balance = 50 * BASE;
pub const... | code_fim | medium | {
"lang": "rust",
"repo": "alipostaci2001/zeitgeist",
"path": "/primitives/src/constants.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alipostaci2001/zeitgeist path: /primitives/src/constants.rs
pub mod ztg;
use crate::types::{Balance, BlockNumber};
use frame_support::{parameter_types, PalletId};
// General
pub const BLOCK_HASH_COUNT: BlockNumber = 250;
// Definitions for time
pub const BLOCKS_PER_DAY: BlockNumber = BLOCKS_P... | code_fim | hard | {
"lang": "rust",
"repo": "alipostaci2001/zeitgeist",
"path": "/primitives/src/constants.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parasyte/gfx path: /src/warden/src/lib.rs
//! Data-driven reference test framework for warding
//! against breaking changes.
<|fim_suffix|>pub mod gpu;
pub mod raw;<|fim_middle|>#[macro_use]
extern crate log;
#[macro_use]
extern crate serde;
| code_fim | medium | {
"lang": "rust",
"repo": "parasyte/gfx",
"path": "/src/warden/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod gpu;
pub mod raw;<|fim_prefix|>// repo: parasyte/gfx path: /src/warden/src/lib.rs
//! Data-driven reference test framework for warding
//! against breaking changes.
<|fim_middle|>#[macro_use]
extern crate log;
#[macro_use]
extern crate serde;
| code_fim | medium | {
"lang": "rust",
"repo": "parasyte/gfx",
"path": "/src/warden/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
device: &Device,
color_target: &TextureView,
(width, height): (f32, f32),
encoder: &mut CommandEncoder,
text: &str,
position: (f32, f32),
) {
let prompt_text = Text::new(text)
.with_color([0.0, 0.0, 0.0, 1.0])
... | code_fim | hard | {
"lang": "rust",
"repo": "coderthetyler/wafer",
"path": "/src/paint/overlay/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coderthetyler/wafer path: /src/paint/overlay/mod.rs
mod widgets;
use futures::{
executor::{LocalPool, LocalSpawner},
task::SpawnExt,
};
use wgpu::{
util::StagingBelt, CommandBuffer, CommandEncoder, CommandEncoderDescriptor, Device,
TextureFormat, TextureView,
};
use wgpu_glyph::... | code_fim | hard | {
"lang": "rust",
"repo": "coderthetyler/wafer",
"path": "/src/paint/overlay/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/compile-fail/issue-52443.rs
fn main() {
[(); & { loop { continue } } ]; //~ ERROR mismatched types
[(); loop { break }]; //~ ERROR mismatched types
[(); {while true {break}; 0}];
//~^ ERROR constant contains unimplemented expression... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/compile-fail/issue-52443.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>~| ERROR constant contains unimplemented expression type
//~| ERROR constant contains unimplemented expression type
//~| ERROR evaluation of constant value failed
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/compile-fail/issue-52443.rs
fn main() {
[(); & { loop { co... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/compile-fail/issue-52443.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0389.rs
//! @ After parameter scanning is complete, the parameters are moved to the
//! |param_stack|. Then the macro body is fed to the scanner; in other words,
//! |macro_call| places the defined text of the control sequence at the
//! top of... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_0389.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // warning_index:=cur_cs; ref_count:=cur_chr; r:=link(ref_count); n:=0;
globals.warning_index = globals.cur_cs;
ref_count = globals.cur_chr.get() as _;
r = link!(globals, ref_count);
n = small_number::new(0);
// if tracing_macros>0 then @<Show the text of t... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_0389.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = r#"{"value":{"unauthorized":true}}"#;
let output = r#"{"value":"{\"unauthorized\":true}"}"#;
let exception = Annotated::new(Exception {
value: Annotated::new(r#"{"unauthorized":true}"#.to_string().into()),
..Default::default()
});
assert_eq_dbg!(exception,... | code_fim | hard | {
"lang": "rust",
"repo": "exhorder/semaphore",
"path": "/general/src/protocol/exception.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exhorder/semaphore path: /general/src/protocol/exception.rs
use crate::protocol::{JsonLenientString, Mechanism, Stacktrace, ThreadId};
use crate::types::{Annotated, Object, Value};
/// A single exception.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, ToValue, ProcessValue)]
#[met... | code_fim | hard | {
"lang": "rust",
"repo": "exhorder/semaphore",
"path": "/general/src/protocol/exception.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for y in 0..height {
for x in 0..width {
if y == 0 && x == 0 {
map_str.push_str("O ");
} else if y == self.height - 1 && x == 0 {
map_str.push_str("Y ");
} else if y == 0 && x == self.width - 1 {
... | code_fim | hard | {
"lang": "rust",
"repo": "ypc2e55orj/maze",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ypc2e55orj/maze path: /src/main.rs
extern crate rand;
use rand::Rng;
use std::env;
use std::process;
type Coords = Vec<Coord>;
struct Coord {
y: usize,
x: usize,
}
impl Coord {
fn new(y: usize, x: usize) -> Coord {
Coord { y: y, x: x }
}
}
enum Direction {
Up,
... | code_fim | hard | {
"lang": "rust",
"repo": "ypc2e55orj/maze",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T> ToIdent for &'a T
where T: ToIdent
{
fn to_ident(&self) -> Ident {
(**self).to_ident()
}
}
impl<'a, T> ToIdent for &'a mut T
where T: ToIdent
{
fn to_ident(&self) -> Ident {
(**self).to_ident()
}
}<|fim_prefix|>// repo: mesalock-linux/crates-sgx path: ... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-sgx",
"path": "/vendor/syn-0.11.11/src/aster/ident.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (**self).into()
}
}
impl ToIdent for String {
fn to_ident(&self) -> Ident {
self.clone().into()
}
}
impl<'a, T> ToIdent for &'a T
where T: ToIdent
{
fn to_ident(&self) -> Ident {
(**self).to_ident()
}
}
impl<'a, T> ToIdent for &'a mut T
where T: ToIde... | code_fim | medium | {
"lang": "rust",
"repo": "mesalock-linux/crates-sgx",
"path": "/vendor/syn-0.11.11/src/aster/ident.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/crates-sgx path: /vendor/syn-0.11.11/src/aster/ident.rs
use Ident;
pub trait ToIdent {
fn to_ident(&self) -> Ident;
}
<|fim_suffix|>impl<'a> ToIdent for &'a str {
fn to_ident(&self) -> Ident {
(**self).into()
}
}
impl ToIdent for String {
fn to_ident(&se... | code_fim | medium | {
"lang": "rust",
"repo": "mesalock-linux/crates-sgx",
"path": "/vendor/syn-0.11.11/src/aster/ident.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lambrosi/rust-pocs path: /playground/lifetimes/src/main.rs
use std::env;
const MINIMUM_PARAMETERS: usize = 2;
fn main() {
let args: Vec<String> = get_args();
let arg1 = &args[1];
let arg2 = &args[2];
let longest = longest(arg1, arg2);
println!("Informed parameters: '{}' ... | code_fim | hard | {
"lang": "rust",
"repo": "lambrosi/rust-pocs",
"path": "/playground/lifetimes/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if text.len() > another.len() {
return text
}
another
}
fn get_args() -> Vec<String> {
let args: Vec<String> = env::args().collect();
if (args.len() - 1) < MINIMUM_PARAMETERS {
panic!("Two args must be informed.");
}
args
}<|fim_prefix|>// repo: lambrosi/rust-p... | code_fim | hard | {
"lang": "rust",
"repo": "lambrosi/rust-pocs",
"path": "/playground/lifetimes/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Peter-JanGootzen/doem path: /src/ecs/resources/doem_events.rs
use luminance_glfw::WindowEvent;
<|fim_suffix|>impl Default for DoemEvents {
fn default() -> DoemEvents {
DoemEvents(Vec::<WindowEvent>::new())
}
}<|fim_middle|>pub struct DoemEvents(pub Vec<WindowEvent>);
| code_fim | easy | {
"lang": "rust",
"repo": "Peter-JanGootzen/doem",
"path": "/src/ecs/resources/doem_events.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> DoemEvents(Vec::<WindowEvent>::new())
}
}<|fim_prefix|>// repo: Peter-JanGootzen/doem path: /src/ecs/resources/doem_events.rs
use luminance_glfw::WindowEvent;
pub struct DoemEvents(pub Vec<WindowEvent>);
<|fim_middle|>impl Default for DoemEvents {
fn default() -> DoemEvents {
| code_fim | medium | {
"lang": "rust",
"repo": "Peter-JanGootzen/doem",
"path": "/src/ecs/resources/doem_events.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for DoemEvents {
fn default() -> DoemEvents {
DoemEvents(Vec::<WindowEvent>::new())
}
}<|fim_prefix|>// repo: Peter-JanGootzen/doem path: /src/ecs/resources/doem_events.rs
use luminance_glfw::WindowEvent;
<|fim_middle|>pub struct DoemEvents(pub Vec<WindowEvent>);
| code_fim | easy | {
"lang": "rust",
"repo": "Peter-JanGootzen/doem",
"path": "/src/ecs/resources/doem_events.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dhackz/td_placerholder path: /src/game_components/monsters/monster.rs
use crate::{
asset_system::AssetManager,
game_components::{Block, GoldPile, Player},
};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
pub enum MonsterType {
Chicken,
CoolChicken,
}
#[derive(Co... | code_fim | medium | {
"lang": "rust",
"repo": "dhackz/td_placerholder",
"path": "/src/game_components/monsters/monster.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_current_state(&self) -> MonsterState;
fn update(&mut self, elapsed: f32, path_blocks: &Vec<Block>, player: &mut Player);
}<|fim_prefix|>// repo: dhackz/td_placerholder path: /src/game_components/monsters/monster.rs
use crate::{
asset_system::AssetManager,
game_components::{Block, ... | code_fim | medium | {
"lang": "rust",
"repo": "dhackz/td_placerholder",
"path": "/src/game_components/monsters/monster.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ysoftman/test_code path: /rust/function_pointer/function_pointer.rs
// ysoftman
// function pointer test
fn main() {
// 함수포인터 리턴 받아 사용하기
let fp = get_add_ten_function();
println!("result: {}", fp(10));
// compute 의 첫번째 인자는 함수명이다.
let result = compute(add_one, 10);
print... | code_fim | medium | {
"lang": "rust",
"repo": "ysoftman/test_code",
"path": "/rust/function_pointer/function_pointer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// 클로저 리턴
// 클로저는 구체적인 타입이 없어 클로저를 저장하기 위한 사이즈을 알 수 없어
// 아래와 같이 함수 포인터를 std::ops::Fn trait 으로 반환을 허용하지 않는다.
// fn return_closure() -> (dyn Fn(i32) -> i32) {
// |x| x + 1
// }
// 대신 Box 에 담아 이용하면 된다.
fn return_closure() -> Box<dyn Fn(i32) -> i32> {
Box::new(|x| x + 1)
}<|fim_prefix|>// repo: ysof... | code_fim | hard | {
"lang": "rust",
"repo": "ysoftman/test_code",
"path": "/rust/function_pointer/function_pointer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DavidPartouche/R2R2 path: /src/input_manager.rs
use std::collections::HashSet;
use winit::event::{DeviceEvent, ElementState, VirtualKeyCode};
pub struct InputManager {
key_inputs: HashSet<VirtualKeyCode>,
mouse_delta: (f64, f64),
left_button_down: bool,
right_button_down: bool,
... | code_fim | hard | {
"lang": "rust",
"repo": "DavidPartouche/R2R2",
"path": "/src/input_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_key_pressed(&self, keycode: VirtualKeyCode) -> bool {
self.key_inputs.contains(&keycode)
}
pub fn mouse_movement(&self) -> (f64, f64) {
self.mouse_delta
}
pub fn is_right_button_down(&self) -> bool {
self.right_button_down
}
}<|fim_prefix|>// rep... | code_fim | hard | {
"lang": "rust",
"repo": "DavidPartouche/R2R2",
"path": "/src/input_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut tf2 = TextFormat::default();
tf2.font = Some("Difference!".to_string());
tf2.size = Some(12.0);
let mut fs = FormatSpans::from_str_and_spans(
"abcdefghi",
&[
TextSpan::with_length_and_format(5, tf1.clone()),
TextSpan::with_length_and_format(... | code_fim | hard | {
"lang": "rust",
"repo": "acidburn0zzz/ruffle",
"path": "/core/src/html/test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn formatspans_resolve_position() {
let fs = FormatSpans::from_str_and_spans(
"abcdefghi",
&[
TextSpan::with_length_and_format(2, Default::default()),
TextSpan::with_length_and_format(3, Default::default()),
TextSpan::with_length_and_format(1... | code_fim | hard | {
"lang": "rust",
"repo": "acidburn0zzz/ruffle",
"path": "/core/src/html/test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acidburn0zzz/ruffle path: /core/src/html/test.rs
ld, None);
assert_eq!(merged.italic, None);
}
#[test]
fn textformat_mix() {
let mut tf1 = TextFormat::default();
tf1.font = Some("First".to_string());
tf1.size = Some(10.0);
tf1.bold = None;
tf1.italic = None;
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "acidburn0zzz/ruffle",
"path": "/core/src/html/test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: winksaville/fuchsia path: /third_party/rust_crates/vendor/bytes/tests/test_from_buf.rs
extern crate bytes;
use bytes::{Buf, Bytes, BytesMut};
use std::io::Cursor;
const LONG: &'static [u8] = b"mary had a little lamb, little lamb, little lamb";
const SHORT: &'static [u8] = b"hello world";
<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/third_party/rust_crates/vendor/bytes/tests/test_from_buf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn collect_to_bytes_mut() {
let buf: BytesMut = Cursor::new(SHORT).collect();
assert_eq!(buf, SHORT);
let buf: BytesMut = Cursor::new(LONG).collect();
assert_eq!(buf, LONG);
}<|fim_prefix|>// repo: winksaville/fuchsia path: /third_party/rust_crates/vendor/bytes/tests/test_from_bu... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/third_party/rust_crates/vendor/bytes/tests/test_from_buf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/itoa/v1/crate/src/udiv128.rs
/// Multiply unsigned 128 bit integers, return upper 128 bits of the result
#[inline]
fn u128_mulhi(x: u128, y: u128) -> u128 {
let x_lo = x as u64;
let x_hi = (x >> 64) as u64;
let y_lo = y as u64;
let y_hi =... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/itoa/v1/crate/src/udiv128.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rem = (n - quot * d as u128) as u64;
debug_assert_eq!(quot, n / d as u128);
debug_assert_eq!(rem as u128, n % d as u128);
(quot, rem)
}<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/itoa/v1/crate/src/udiv128.rs
/// Multiply unsigned 128 bit integers, return upper 12... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/itoa/v1/crate/src/udiv128.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn recreate_surface(&mut self) {
self.surface
.configure(&self.device_wrapper.device, &self.surface_configuration);
self.multisampled_frame_buffer = self.device_wrapper.create_multisampled_frame_buffer(
self.surface_configuration.width,
se... | code_fim | hard | {
"lang": "rust",
"repo": "D0liphin/og2",
"path": "/src/render_state/render_state_struct.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn create_image_texture_from_buffer(
&self,
label: Option<&str>,
image_buffer: &[u8],
dimensions: (u32, u32),
) -> Result<wgpu::Texture> {
let texture_extent_3d = wgpu::Extent3d {
width: dimensions.0,
height: dimensions.1,
... | code_fim | hard | {
"lang": "rust",
"repo": "D0liphin/og2",
"path": "/src/render_state/render_state_struct.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: D0liphin/og2 path: /src/render_state/render_state_struct.rs
use crate::*;
pub(crate) struct RenderState {
pub(crate) surface: wgpu::Surface,
pub(crate) surface_configuration: wgpu::SurfaceConfiguration,
pub(crate) device_wrapper: crate::DeviceWrapper,
pub(crate) queue: wgpu::Que... | code_fim | hard | {
"lang": "rust",
"repo": "D0liphin/og2",
"path": "/src/render_state/render_state_struct.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>vec![Box::new(Root::Comment(c))],
Root::Variable(..) => unreachable!(), // variables get evaluated before optimization
}
}<|fim_prefix|>// repo: carols10cents/sassers path: /src/optimizer.rs
use ast::root::Root;
use sass::output_style::Streamable;
pub fn optimize(root: Root) -> Vec<Box<Strea... | code_fim | hard | {
"lang": "rust",
"repo": "carols10cents/sassers",
"path": "/src/optimizer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: carols10cents/sassers path: /src/optimizer.rs
use ast::root::Root;
use sass::output_style::Streamable;
pub fn optimize(root: Root) -> Vec<Box<Streamable>> {
match root {
Root::Rule(rule) => {
let mut result: Vec<Box<Streamable>> = Vec::new();
for r in rule.op... | code_fim | medium | {
"lang": "rust",
"repo": "carols10cents/sassers",
"path": "/src/optimizer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for n in 0..(MAX_ITER + 1) {
let mut an = (a * a) - (b * b);
let mut bn = 2.0 * a * b;
a = an + ca;
b = bn + cb;
i = n;
if ((a*a) + (b*b) > 4.0){
break;
}
}
return i;
}<|fim_prefix|>// repo: cpared/tdl path: /src/lib.rs
#... | code_fim | hard | {
"lang": "rust",
"repo": "cpared/tdl",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in 0..width{
for y in 0..height{
let xi = x1 - (x1 - x);
let yi = y1 - (y1 - y);
let mandelbrot_point = calculateSet(xi, yi, width, height, rss, rse, iss, ise);
if(mandelbrot_point == MAX_ITER){
ctx.set_fill_style(&"#000"... | code_fim | hard | {
"lang": "rust",
"repo": "cpared/tdl",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpared/tdl path: /src/lib.rs
#![allow(warnings)]
mod utils;
use wasm_bindgen::prelude::*;
use wasm_bindgen::Clamped;
use std::convert::TryInto;
use wasm_bindgen::JsCast;
//con web_sys podemos interactuar con las clases que manejan el DOM
use web_sys::{CanvasRenderingContext2d};
const MAX_ITER:... | code_fim | hard | {
"lang": "rust",
"repo": "cpared/tdl",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args: Vec<_> = env::args().skip(1).collect();
if args.is_empty() {
println!("Missing files to work on...\nExample: ./minifier file.js\n");
print_help();
return
}
for arg in &args {
let p = Path::new(arg);
if !p.is_file() {
writeln!(... | code_fim | hard | {
"lang": "rust",
"repo": "indy/minifier-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: indy/minifier-rs path: /src/main.rs
// MIT License
//
// Copyright (c) 2017 Guillaume Gomez
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, ... | code_fim | hard | {
"lang": "rust",
"repo": "indy/minifier-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct SdList(bitbox02_sys::sd_list_t);
impl Drop for SdList {
fn drop(&mut self) {
unsafe { bitbox02_sys::sd_free_list(&mut self.0) }
}
}
pub fn list_subdir(subdir: Option<&str>) -> Result<Vec<String>, ()> {
let mut list = SdList(bitbox02_sys::sd_list_t {
num_files: 0,
... | code_fim | hard | {
"lang": "rust",
"repo": "digitalbitbox/bitbox02-firmware",
"path": "/src/rust/bitbox02/src/sd.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/bitbox02/src/sd.rs
// Copyright 2021 Shift Crypto AG
//
// 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
//
// htt... | code_fim | hard | {
"lang": "rust",
"repo": "digitalbitbox/bitbox02-firmware",
"path": "/src/rust/bitbox02/src/sd.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn load_bin(filename: &str, dir: &str) -> Result<zeroize::Zeroizing<Vec<u8>>, ()> {
let mut contents = zeroize::Zeroizing::new([0u8; SD_MAX_FILE_SIZE as _]);
let mut contents_len: usize = 0;
match unsafe {
bitbox02_sys::sd_load_bin(
str_to_cstr_vec(filename).unwrap().as... | code_fim | hard | {
"lang": "rust",
"repo": "digitalbitbox/bitbox02-firmware",
"path": "/src/rust/bitbox02/src/sd.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Matrix-Zhang/cargo-tarball path: /build.rs
#[macro_use]
extern crate clap;
#[macro_use]
extern crate structopt;
use std::env;
use std::fs;
use std::io::Write;
use std::path;
use std::process;
use structopt::StructOpt;
use structopt::clap::Shell;
#[allow(dead_code)]
#[path = "src/format.rs"]
m... | code_fim | hard | {
"lang": "rust",
"repo": "Matrix-Zhang/cargo-tarball",
"path": "/build.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Use clap to build completion files.
let completions_dir = path::Path::new(&outdir).join("completions");
fs::create_dir_all(&completions_dir).unwrap();
let bin = env!("CARGO_PKG_NAME");
let mut clap = args::Arguments::clap();
clap.gen_completions(bin, Shell::Bash, &completions_di... | code_fim | hard | {
"lang": "rust",
"repo": "Matrix-Zhang/cargo-tarball",
"path": "/build.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: limelier/simulator-2d path: /src/main.rs
use simulator_2d::sim::{ Simulation, Instruction, TurnDirection };
fn main() {
<|fim_suffix|> let mut simulation = Simulation::new(2, &instructions);
simulation.run();
println!("{:?}", simulation.board);
}<|fim_middle|> let instructions = ... | code_fim | hard | {
"lang": "rust",
"repo": "limelier/simulator-2d",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut simulation = Simulation::new(2, &instructions);
simulation.run();
println!("{:?}", simulation.board);
}<|fim_prefix|>// repo: limelier/simulator-2d path: /src/main.rs
use simulator_2d::sim::{ Simulation, Instruction, TurnDirection };
<|fim_middle|>fn main() {
let instructions = ... | code_fim | hard | {
"lang": "rust",
"repo": "limelier/simulator-2d",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create a server which will manage the battle.
let battle = Battle::builder(CustomRules::new()).build();
let mut server = Server::builder(battle).build();
// Fire two MakePizza events.
MakePizza::trigger(&mut server, "margherita".to_string())
.fire()
.unwrap();
Ma... | code_fim | medium | {
"lang": "rust",
"repo": "Trisfald/weasel",
"path": "/examples/user_event/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Trisfald/weasel path: /examples/user_event/main.rs
use crate::rules::*;
use weasel::{Battle, BattleController, EventTrigger, FlatVersionedEvent, Server};
mod rules;
<|fim_suffix|> // Create a server which will manage the battle.
let battle = Battle::builder(CustomRules::new()).build();
... | code_fim | medium | {
"lang": "rust",
"repo": "Trisfald/weasel",
"path": "/examples/user_event/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in &v{
println!("{}",i);
}
// vec中只能存储一种类型的数据。如果要存储不同类型的数据,可以存储枚举元素
let row = vec![
SpreadsheetCell::Int(3),
SpreadsheetCell::Text(String::from("blue")),
SpreadsheetCell::Float(10.12),
];
for i in &row{
println!("{:?}",i);
}
... | code_fim | medium | {
"lang": "rust",
"repo": "Jamsa/trpl",
"path": "/collections/src/vector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jamsa/trpl path: /collections/src/vector.rs
#[derive(Debug)]
enum SpreadsheetCell{
Int(i32),
Float(f64),
Text(String),
}
fn main() {
// vector 只能存储相同的类型,在内存中相邻排列
let v:Vec<i32> = Vec::new();
println!("{:?}",v);
let v = vec![1,2,3]; //vec!宏
println!("{:?}",v);
<|... | code_fim | hard | {
"lang": "rust",
"repo": "Jamsa/trpl",
"path": "/collections/src/vector.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // vec中只能存储一种类型的数据。如果要存储不同类型的数据,可以存储枚举元素
let row = vec![
SpreadsheetCell::Int(3),
SpreadsheetCell::Text(String::from("blue")),
SpreadsheetCell::Float(10.12),
];
for i in &row{
println!("{:?}",i);
}
}<|fim_prefix|>// repo: Jamsa/trpl path: /coll... | code_fim | medium | {
"lang": "rust",
"repo": "Jamsa/trpl",
"path": "/collections/src/vector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(
!found.is_none(),
format!("{} failed to find process name", self.command)
);
return found.unwrap().as_str().to_string();
}
}<|fim_prefix|>// repo: colwynmyself/rust_learning path: /process_monitor/src/process.rs
use regex::Regex;
use sysinfo::... | code_fim | medium | {
"lang": "rust",
"repo": "colwynmyself/rust_learning",
"path": "/process_monitor/src/process.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_name(&self) -> String {
let re = Regex::new(r"^\S+").unwrap();
let found = re.find(&self.command);
assert!(
!found.is_none(),
format!("{} failed to find process name", self.command)
);
return found.unwrap().as_str().to_string... | code_fim | hard | {
"lang": "rust",
"repo": "colwynmyself/rust_learning",
"path": "/process_monitor/src/process.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: colwynmyself/rust_learning path: /process_monitor/src/process.rs
use regex::Regex;
use sysinfo::ProcessExt;
pub struct Process {
pub pid: i32,
pub command: String,
pub memory: u64,
pub cpu_usage: f32,
}
impl Process {
pub fn new(pid: &i32, proc_: &sysinfo::Process) -> Proce... | code_fim | medium | {
"lang": "rust",
"repo": "colwynmyself/rust_learning",
"path": "/process_monitor/src/process.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> output
.into_iter()
.zip(lerp)
.for_each(|(i, rgb)| *i = C::from(ColorRGB::from(rgb)));
}
#[cfg(test)]
mod test {
use crate::color_util::*;
use crate::HSV;
#[test]
fn gradient_sweep_test() {
let start: HSV = HSV::new(0, 100, 50);
let end: HSV =... | code_fim | hard | {
"lang": "rust",
"repo": "sfleischman105/cichlid",
"path": "/src/color_util/gradient.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn gradient_sweep_test() {
let start: HSV = HSV::new(0, 100, 50);
let end: HSV = HSV::new(100, 200, 100);
let mut out: [HSV; 5] = [HSV::BLANK; 5];
let dir = GradientDirection::Shortest;
out.gradient_fill(start, end, dir);
assert_eq!(*out.las... | code_fim | hard | {
"lang": "rust",
"repo": "sfleischman105/cichlid",
"path": "/src/color_util/gradient.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sfleischman105/cichlid path: /src/color_util/gradient.rs
//! Color gradient functions and impls.
//!
//! Creates smooth transitions between any two colors for any number of steps.
//#![allow(unused_imports)]
#[cfg(feature = "no-std")]
use core::iter::ExactSizeIterator;
#[cfg(not(feature = "no-s... | code_fim | hard | {
"lang": "rust",
"repo": "sfleischman105/cichlid",
"path": "/src/color_util/gradient.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get(&self) -> GetRequestBuilder {
GetRequestBuilder::new(self)
}
#[deprecated(since="3.0.0", note="please use `create()` instead")]
pub fn post(&self) -> PostRequestBuilder {
PostRequestBuilder::new(self, "{}")
}
pub fn create(&self) -> PostRequestBuilder {... | code_fim | hard | {
"lang": "rust",
"repo": "iLert/ilert-rust",
"path": "/src/ilert.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iLert/ilert-rust path: /src/ilert.rs
use reqwest::blocking::Client;
use reqwest::redirect::Policy;
use reqwest::ClientBuilder;
use reqwest::header;
use std::time::Duration;
use log::{debug};
use crate::ilert_builders::{DeleteRequestBuilder, GetRequestBuilder, PostRequestBuilder, PutRequestBuild... | code_fim | hard | {
"lang": "rust",
"repo": "iLert/ilert-rust",
"path": "/src/ilert.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> http_client_result
}
pub fn auth_via_token(&mut self, api_token: &str) -> ILertResult<&mut ILert> {
self.api_token = Some(api_token.to_string());
Ok(self)
}
pub fn auth_via_user(&mut self, auth_user: &str, auth_psw: &str) -> ILertResult<&mut ILert> {
self.... | code_fim | hard | {
"lang": "rust",
"repo": "iLert/ilert-rust",
"path": "/src/ilert.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wistic/POS-Tagging path: /rust_preprocessor/src/corpus.rs
use xml::reader::XmlEvent;
use xml::attribute::OwnedAttribute;
use std::fs::File;
use std::io::{Write, BufWriter, BufReader};
use xml::{ParserConfig, EventReader};
use std::error::Error;
struct Token {
tag: String,
token: Option<... | code_fim | hard | {
"lang": "rust",
"repo": "wistic/POS-Tagging",
"path": "/rust_preprocessor/src/corpus.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if lowercase {
token.to_lowercase()
} else {
token
}
}
fn process_token(writer: &mut BufWriter<File>, token: Token) -> std::io::Result<()> {
let tag = token.tag;
if let Some(token) = token.token {
writer.write_all(token.as_ref())?;
writer.write_all(b"_"... | code_fim | hard | {
"lang": "rust",
"repo": "wistic/POS-Tagging",
"path": "/rust_preprocessor/src/corpus.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tex-other/tex-rs path: /src/section_0891.rs
//! @* \[40] Pre-hyphenation.
//! When the line-breaking routine is unable to find a feasible sequence of
//! breakpoints, it makes a second pass over the paragraph, attempting to
//! hyphenate the hyphenatable words. The goal of hyphenation is to inse... | code_fim | hard | {
"lang": "rust",
"repo": "tex-other/tex-rs",
"path": "/src/section_0891.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>//! of the way it has been taken out of \TeX's inner loop. For example, when
//! the second edition of the author's 700-page book {\sl Seminumerical
//! Algorithms} was typeset by \TeX, only about 1.2 hyphenations needed to be
//! @^Knuth, Donald Ervin@>
//! tried per paragraph, since the line breaking al... | code_fim | hard | {
"lang": "rust",
"repo": "tex-other/tex-rs",
"path": "/src/section_0891.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl IORegister for DIVCNT {
fn read(&self, byte: usize) -> u8 {
match byte {
0 => self.mode,
1 => (self.busy as u8) << 7 | (self.div_by_0 as u8) << 6,
2 ..= 3 => 0,
_ => unreachable!(),
}
}
fn write(&mut self, _scheduler: &mut s... | code_fim | hard | {
"lang": "rust",
"repo": "siraben/NDS-Emulator",
"path": "/core/src/hw/math.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siraben/NDS-Emulator path: /core/src/hw/math.rs
use super::{HW, mem::IORegister, scheduler::Scheduler};
use num_integer::Roots;
pub struct Div {
pub cnt: DIVCNT,
numer: MathParam,
denom: MathParam,
quot: MathParam,
rem: MathParam,
}
impl Div {
pub fn new() -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "siraben/NDS-Emulator",
"path": "/core/src/hw/math.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct MathParam {
value: u64,
}
impl MathParam {
pub fn new() -> Self {
MathParam {
value: 0,
}
}
}
impl IORegister for MathParam {
fn read(&self, byte: usize) -> u8 {
assert!(byte < 8);
HW::read_byte_from_value(&self.value, byte)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "siraben/NDS-Emulator",
"path": "/core/src/hw/math.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[link(name = "rust_test_helpers", kind = "static")]
extern {
pub fn rust_dbg_extern_identity_u32(u: u32) -> u32;
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/auxiliary/issue-25185-1.rs
// no-prefer-dynamic
<|fim_middle|>#![crate_type = "rlib"]
| code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/auxiliary/issue-25185-1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/auxiliary/issue-25185-1.rs
// no-prefer-dynamic
<|fim_suffix|>#[link(name = "rust_test_helpers", kind = "static")]
extern {
pub fn rust_dbg_extern_identity_u32(u: u32) -> u32;
}<|fim_middle|>#![crate_type = "rlib"]
| code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/auxiliary/issue-25185-1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eolu/dfb path: /src/lib.rs
#[cfg(test)]
mod test;
use core::any::*;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::iter::FromIterator;
/// A macro to create a Dfb containing passed-in elements.
#[macro_export]
macro_rules! dfb
{
() => { $crate::Dfb::new() };
($... | code_fim | hard | {
"lang": "rust",
"repo": "Eolu/dfb",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Wrapper for [HashMap::iter_mut]
#[inline]
pub fn iter_mut(&mut self) -> std::collections::hash_map::IterMut<'_, TypeId, VecDeque<Box<dyn Any>>>
{
self.0.iter_mut()
}
/// Wrapper for [HashMap::len]
#[inline]
pub fn len(&self) -> usize
{
self.0.len()
... | code_fim | hard | {
"lang": "rust",
"repo": "Eolu/dfb",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>app! {
device: stm32f429x,
tasks: {
TIM2: {
path: tim2,
resources: [TIM2],
},
TIM3: {
path: tim3,
resources: [TIM3],
},
},
}
fn init(p: init::Peripherals) {
// Set system clock in order to test that it works
... | code_fim | medium | {
"lang": "rust",
"repo": "robroyx3m/f4",
"path": "/examples/timer-interrupt.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Set system clock in order to test that it works
clock::set_84_mhz(&p.RCC, &p.FLASH);
led::init(p.GPIOA, p.RCC);
let timer = Timer(&*p.TIM2);
timer.init(FREQUENCY1.invert(), p.RCC);
timer.resume();
let timer = Timer(&*p.TIM3);
timer.init(FREQUENCY2.invert(), p.RCC);
... | code_fim | hard | {
"lang": "rust",
"repo": "robroyx3m/f4",
"path": "/examples/timer-interrupt.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.