text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> /// Accept trade
/// 0. `[signer]` The account of the person taking the trade
/// 1. `[writable]` The taker's token account for the token they send
/// 2. `[writable]` The taker's token account for the token they will receive should the trade go through
/// 3. `[writable]` The PDA's temp token a... | code_fim | hard | {
"lang": "rust",
"repo": "therobertc/escrow-program",
"path": "/rust/src/instruction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tztail()
.arg("--timezone")
.arg("US/Pacific")
.with_stdin()
.buffer("2018-11-21T22:48:14+0100: This is a log")
.assert()
.success()
.stdout("2018-11-21T13:48:14-0800: This is a log")
.stderr("");
}
#[test]
fn test_read_from_file() {
... | code_fim | hard | {
"lang": "rust",
"repo": "thecasualcoder/tztail",
"path": "/tests/integration_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> CARGO_RUN.command()
}
fn convert_to_localtimezone(input: &str, format: &str) -> String {
let local_timezone = Local::now().timezone();
return DateTime::parse_from_str(input, format)
.unwrap()
.with_timezone(&local_timezone)
.format(format)
.to_string();
}
#[te... | code_fim | hard | {
"lang": "rust",
"repo": "thecasualcoder/tztail",
"path": "/tests/integration_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thecasualcoder/tztail path: /tests/integration_tests.rs
extern crate assert_cmd;
extern crate escargot;
#[macro_use]
extern crate lazy_static;
extern crate chrono;
extern crate chrono_tz;
use assert_cmd::prelude::*;
use chrono::prelude::*;
use chrono::DateTime;
use escargot::CargoRun;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "thecasualcoder/tztail",
"path": "/tests/integration_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> file_path.push_str("-xor");
let mut output_file = File::create(&file_path)?;
loop {
let bytes_read = input_file.read(&mut buffer)?;
if bytes_read == 0 {
break;
}
for byte in buffer.iter_mut() {
*byte ^= XOR_KEY;
}
ou... | code_fim | medium | {
"lang": "rust",
"repo": "FishLakeDev/speedtest",
"path": "/xor/xor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FishLakeDev/speedtest path: /xor/xor.rs
use std::io::prelude::*;
use std::fs::File;
const XOR_KEY: u8 = 0xFF;
const BUFFER_SIZE: usize = 2048;
<|fim_suffix|> output_file.write(&buffer[..bytes_read])?;
}
Ok(())
}<|fim_middle|>fn main() -> std::io::Result<()> {
let mut buffer... | code_fim | hard | {
"lang": "rust",
"repo": "FishLakeDev/speedtest",
"path": "/xor/xor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aiifabbf/kvs path: /src/bin/kvs-client.rs
use clap::App;
use clap::AppSettings;
use clap::Arg;
use kvs::KvsClient;
use kvs::KvsError;
use kvs::Result;
// 从project 2的main.rs搬过来的
// 想把main写成返回Result,是因为担心std::process::exit是不是会导致main里的对象没有drop。结果真的会 <https://doc.rust-lang.org/std/process/fn.exit... | code_fim | hard | {
"lang": "rust",
"repo": "aiifabbf/kvs",
"path": "/src/bin/kvs-client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> .takes_value(true)
.value_name("IP-PORT"),
),
)
.setting(AppSettings::ArgRequiredElseHelp)
.get_matches();
match matches.subcommand() {
("get", Some(app)) => {
let address = app.value_of("IP-PORT"... | code_fim | hard | {
"lang": "rust",
"repo": "aiifabbf/kvs",
"path": "/src/bin/kvs-client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum IntBin {
Add, Sub,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FloatBin {
FAdd, FSub, FMul, FDiv,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CompBin {
Eq, LE,
}
// type.ml
#[derive(Clone, Debug, PartialEq, Eq)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "maekawatoshiki/min-caml-rust",
"path": "/src/syntax.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// type.ml
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Type {
Unit,
Bool,
Int,
Float,
Fun(Box<[Type]>, Box<Type>),
Tuple(Box<[Type]>),
Array(Box<Type>),
Var(usize),
}
impl Type {
fn fmt_sub(&self, f: &mut fmt::Formatter, parens: bool) -> fmt::Result {
use s... | code_fim | hard | {
"lang": "rust",
"repo": "maekawatoshiki/min-caml-rust",
"path": "/src/syntax.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maekawatoshiki/min-caml-rust path: /src/syntax.rs
use ordered_float::OrderedFloat;
use std::fmt;
#[derive(Clone, Debug, PartialEq, Eq)]
// syntax.ml
pub enum Syntax {
Unit,
Bool(bool),
Int(i64),
Float(OrderedFloat<f64>),
Not(Box<Syntax>),
Neg(Box<Syntax>),
IntBin(Int... | code_fim | hard | {
"lang": "rust",
"repo": "maekawatoshiki/min-caml-rust",
"path": "/src/syntax.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// let contents = fs::read_to_string(config.filename)
// .expect("Error reading file");
// println!("Text: \n{}", contents);
// run(config);
if let Err(e) = rustygrep::run(config) {
eprintln!("App error: {}", e);
process::exit(1);
}
}
//fn parse_config(arg... | code_fim | hard | {
"lang": "rust",
"repo": "okazdal/rustygrep",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: okazdal/rustygrep path: /src/main.rs
use std::env;
use std::process;
use rustygrep::Config;
fn main() {
// let args: Vec<String> = env::args().collect();
// println!("{:?}", args);
// let query = &args[1];
// let filename = &args[2];
<|fim_suffix|>}
//fn parse_config(args: &[S... | code_fim | hard | {
"lang": "rust",
"repo": "okazdal/rustygrep",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//fn parse_config(args: &[String]) -> Config {
// let query = args[1].clone();
// let filename = args[2].clone();
//
// Config{query, filename}
//}<|fim_prefix|>// repo: okazdal/rustygrep path: /src/main.rs
use std::env;
use std::process;
use rustygrep::Config;
fn main() {
// let args: Ve... | code_fim | medium | {
"lang": "rust",
"repo": "okazdal/rustygrep",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>_local] //~ ERROR `#[thread_local]` is an experimental feature
static FOO: i32 = 3;
pub fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/feature-gates/feature-gate-thread_local.rs
// Test that `#[thread_local]` attribute is gated by `thread_local`
// feature gate.
//... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/feature-gates/feature-gate-thread_local.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/feature-gates/feature-gate-thread_local.rs
// Test that `#[thread_local]` attribute is gated by `thread_local`
// feature gate.
//
// (Note that the `thread_local!` macro is explicitly *not* gated; it
// is given permission to expand into this u... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/feature-gates/feature-gate-thread_local.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h573/dts/icifr.rs
#[doc = "Register `ICIFR` reader"]
pub type R = crate::R<ICIFR_SPEC>;
#[doc = "Register `ICIFR` writer"]
pub type W = crate::W<ICIFR_SPEC>;
#[doc = "Field `TS1_CITEF` reader - Interrupt clear flag for end of measurement on tem... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h573/dts/icifr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>."]
#[inline(always)]
#[must_use]
pub fn ts1_caitef(&mut self) -> TS1_CAITEF_W<ICIFR_SPEC, 4> {
TS1_CAITEF_W::new(self)
}
#[doc = "Bit 5 - Asynchronous interrupt clear flag for low threshold on temperature sensor 1 Writing 1 to this bit clears the TS1_AITLF flag in the DTS_SR r... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h573/dts/icifr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rosshays/rendy path: /resource/src/buffer/mod.rs
//! Buffer usage, creation-info and wrappers.
mod usage;
pub use {
self::usage::{Usage, *},
gfx_hal::buffer::*,
};
use crate::{
escape::{Escape, KeepAlive, Terminal},
memory::{Block, MappedRange, MemoryBlock},
};
/// Buffer inf... | code_fim | hard | {
"lang": "rust",
"repo": "rosshays/rendy",
"path": "/resource/src/buffer/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<B> Buffer<B>
where
B: gfx_hal::Backend,
{
/// # Disclaimer
///
/// This function is designed to use by other rendy crates.
/// User experienced enough to use it properly can find it without documentation.
///
/// # Safety
///
/// `info` must match information about... | code_fim | hard | {
"lang": "rust",
"repo": "rosshays/rendy",
"path": "/resource/src/buffer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Map range of the buffer to the CPU accessible memory.
pub fn map<'a>(
&'a mut self,
device: &B::Device,
range: std::ops::Range<u64>,
) -> Result<MappedRange<'a, B>, gfx_hal::mapping::Error> {
self.escape.block.map(device, range)
}
// /// Map range o... | code_fim | hard | {
"lang": "rust",
"repo": "rosshays/rendy",
"path": "/resource/src/buffer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_filter_array_string_conditions() {
assert_jsonpath_f64!(
"$.store.books[?(@.author == ['Evelyn Waugh' ])].price",
[12.99]
);
assert_jsonpath_f64!(
"$.store.books[?(@.author == ['Evelyn Waugh', 'Nigel Rees'])].price",
[8.95, 12.99]
);
asse... | code_fim | hard | {
"lang": "rust",
"repo": "frumioj/jsonpath-rs",
"path": "/tests/selector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frumioj/jsonpath-rs path: /tests/selector.rs
extern crate jsonpath;
extern crate serde_json;
use jsonpath::Selector;
use serde_json::Value;
use std::fs::File;
use std::io::Read;
macro_rules! assert_jsonpath_f64 {
($path:expr, $expected:expr) => {
let mut data_struct = String::new()... | code_fim | hard | {
"lang": "rust",
"repo": "frumioj/jsonpath-rs",
"path": "/tests/selector.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_filter() {
assert_jsonpath_f64!("$.store.books[?(@.category == 'reference')].price", [8.95]);
assert_jsonpath_str!(
"$.store.books[?(@.category == 'fiction')].title",
["Sword of Honour", "Moby Dick", "The Lord of the Rings"]
);
assert_jsonpath_str!(
... | code_fim | hard | {
"lang": "rust",
"repo": "frumioj/jsonpath-rs",
"path": "/tests/selector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let matches = App::new("clarity-lint")
.version("0.1.1")
.arg(
Arg::new(file_arg)
.short('f')
.long(file_arg)
.takes_value(true)
.value_name("PATH")
.about("Species the clarity file to be linted... | code_fim | hard | {
"lang": "rust",
"repo": "alexkeating/clarity-linter",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexkeating/clarity-linter path: /src/main.rs
#[macro_use]
extern crate anyhow;
extern crate serde_json;
use std::fs;
use std::path;
use anyhow::Result;
use clap::{App, Arg};
use clarity_repl::{clarity, repl};
#[derive(Debug)]
struct Position {
line: u64,
character: u64,
}
#[derive(... | code_fim | hard | {
"lang": "rust",
"repo": "alexkeating/clarity-linter",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let diags =
match clarity_interpreter.run_analysis(contract_identifier.clone(), &mut contract_ast) {
Ok(_) => Ok(String::from("")),
Err((_, Some(analysis_diag))) => serde_json::to_string_pretty(&analysis_diag),
_ => {
let diag = serde_json::t... | code_fim | hard | {
"lang": "rust",
"repo": "alexkeating/clarity-linter",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: transitorykris/kasm path: /src/instructions.rs
ction_set.insert(
InstructionKey {
mnemonic: Mnemonic::ASL,
address_mode: AddressMode::Zeropage,
},
0x06,
);
instruction_set.insert(
InstructionKey {
mnemonic: Mnemonic::ASL... | code_fim | hard | {
"lang": "rust",
"repo": "transitorykris/kasm",
"path": "/src/instructions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mnemonic: Mnemonic::LDY,
address_mode: AddressMode::AbsoluteX,
},
0xbc,
);
instruction_set.insert(
InstructionKey {
mnemonic: Mnemonic::LSR,
address_mode: AddressMode::Immediate,
},
0x4a,
);
instruction_set.ins... | code_fim | hard | {
"lang": "rust",
"repo": "transitorykris/kasm",
"path": "/src/instructions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
mnemonic: Mnemonic::CPY,
address_mode: AddressMode::Absolute,
},
0xcc,
);
instruction_set.insert(
InstructionKey {
mnemonic: Mnemonic::DEC,
address_mode: AddressMode::Zeropage,
},
0xc6,
);
instruction_... | code_fim | hard | {
"lang": "rust",
"repo": "transitorykris/kasm",
"path": "/src/instructions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns `true` if dax is supported
#[cfg(blkid = "2.36")]
pub fn dax(&self) -> bool {
unsafe { blkid_topology_get_dax(self.0) == 1 }
}
}<|fim_prefix|>// repo: cholcombe973/blkid path: /src/topology.rs
use blkid_sys::*;
/// Device topology information
pub struct Topology(pub(c... | code_fim | hard | {
"lang": "rust",
"repo": "cholcombe973/blkid",
"path": "/src/topology.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cholcombe973/blkid path: /src/topology.rs
use blkid_sys::*;
/// Device topology information
pub struct Topology(pub(crate) blkid_topology);
impl Topology {
/// Alignment offset in bytes or 0.
pub fn alignment_offset(&self) -> u64 {
unsafe { blkid_topology_get_alignment_offset(s... | code_fim | hard | {
"lang": "rust",
"repo": "cholcombe973/blkid",
"path": "/src/topology.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Logical sector size (BLKSSZGET ioctl) in bytes or 0.
pub fn physical_sector_size(&self) -> u64 {
unsafe { blkid_topology_get_physical_sector_size(self.0) }.try_into().unwrap()
}
/// Returns `true` if dax is supported
#[cfg(blkid = "2.36")]
pub fn dax(&self) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "cholcombe973/blkid",
"path": "/src/topology.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mpOp {}));
result.push(Box::new(val_div::ValDivOp {}));
result.push(Box::new(val_lshift::ValLshiftOp {}));
result.push(Box::new(val_max::ValMaxOp {}));
result.push(Box::new(val_min::ValMinOp {}));
result.push(Box::new(val_mod::ValModOp {}));
result.push(Box::new(val_mul::ValMulOp {... | code_fim | hard | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/math/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AustinHaugerud/oxidsys path: /src/language/operations/math/mod.rs
use language::operations::Operation;
pub mod assign;
pub mod conditional;
pub mod fixed_point;
pub mod rng;
pub mod store_acos;
pub mod store_add;
pub mod store_and;
pub mod store_asin;
pub mod store_atan;
pub mod store_atan2;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/math/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>entTree;
pub use self::segment_tree::SegmentTree;
pub mod functions;
mod delta;
mod implicit_tree;
mod segment_tree;
mod lazy_segment_tree;
mod backing_tree;
pub const BINARY_WIDTH: usize = 2;<|fim_prefix|>// repo: Techno-coder/strutters path: /src/tree/mod.rs
pub use self::backing_tree::BackingTree;
p... | code_fim | medium | {
"lang": "rust",
"repo": "Techno-coder/strutters",
"path": "/src/tree/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Techno-coder/strutters path: /src/tree/mod.rs
pub use self::backing_tree::BackingTree;
pub use self::delta::DeltaSifter;
pub use self::delta::D<|fim_suffix|>e;
mod segment_tree;
mod lazy_segment_tree;
mod backing_tree;
pub const BINARY_WIDTH: usize = 2;<|fim_middle|>eltaWrapper;
pub use self::i... | code_fim | medium | {
"lang": "rust",
"repo": "Techno-coder/strutters",
"path": "/src/tree/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn compaction_loop(db: std::sync::Arc<storage::redis::DB>) {
loop {
// TODO: make the compaction more smooth
// TODO: here need some logs
db.compaction().await;
tokio::time::sleep(tokio::time::Duration::from_secs(300)).await;
}
}
// jemalloc : 261% 44ms 39M
/... | code_fim | hard | {
"lang": "rust",
"repo": "Hydrogen5/ruapt_rs",
"path": "/ruapt_tracker/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hydrogen5/ruapt_rs path: /ruapt_tracker/src/main.rs
mod data;
mod error;
mod storage;
mod util;
use bendy::serde::{from_bytes, to_bytes};
use data::AnnounceRequestData;
use futures::prelude::*;
use std::sync::Arc;
use storage::redis::DB;
use storage::Storage;
use tokio::net::TcpListener;
use to... | code_fim | hard | {
"lang": "rust",
"repo": "Hydrogen5/ruapt_rs",
"path": "/ruapt_tracker/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/serde_json/src/lexical/float.rs
/
/
Adapted
from
https
:
/
/
github
.
com
/
Alexhuszagh
/
rust
-
lexical
.
/
/
FLOAT
TYPE
use
super
:
:
num
:
:
*
;
use
super
:
:
rounding
:
:
*
;
use
super
:
:
shift
:
:
*
;
/
/
/
Extended
precision
floating
-
p... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_json/src/lexical/float.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>>
(
mut
self
)
-
>
F
{
self
.
round_to_native
:
:
<
F
_
>
(
round_downward
)
;
into_float
(
self
)
}
}
/
/
FROM
FLOAT
/
/
Import
ExtendedFloat
from
native
float
.
#
[
inline
]
pub
(
crate
)
fn
from_float
<
F
>
(
f
:
F
)
-
>
ExtendedFloat
where
F
:
Float
{
ExtendedFloat
{
mant
:
u64
:
:
as_cast
(
f
.
manti... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_json/src/lexical/float.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>a
modulus
of
pow2
(
which
will
get
optimized
to
a
bitwise
/
/
and
with
0x3F
or
faster
)
is
slightly
slower
than
an
if
/
then
/
/
however
removing
the
if
/
then
will
likely
optimize
more
branched
/
/
code
as
it
removes
conditional
logic
.
/
/
Calculate
the
number
of
leading
zeros
and
then
zero
-
out
/
/
an... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_json/src/lexical/float.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomasmatecki/rblas path: /scabs1.rs
use libc;
pub type real = libc::c_float;
pub type doublereal = libc::c_double;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct complex {
pub r: real,
pub i: real,
}
/* scabs1.f -- translated by f2c (version 20061008).
You must link the resulting objec... | code_fim | hard | {
"lang": "rust",
"repo": "thomasmatecki/rblas",
"path": "/scabs1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
/* .. Scalar Arguments .. */
/* .. */
/* Purpose */
/* ======= */
/* SCABS1 computes absolute value of a complex number */
/* .. Intrinsic Functions .. */
/* .. */
r__1 = (*z__).r;
r__2 = r_imag_0(z__) as real;
ret_val = ((if r__1 >= 0 as li... | code_fim | hard | {
"lang": "rust",
"repo": "thomasmatecki/rblas",
"path": "/scabs1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Garvys/rustfst path: /rustfst/src/tests_openfst/algorithms/weight_pushing.rs
use std::fmt::Display;
use anyhow::Result;
use crate::algorithms::{push_weights, ReweightType};
use crate::fst_traits::{MutableFst, SerializableFst};
use crate::semirings::WeaklyDivisibleSemiring;
use crate::semirings... | code_fim | hard | {
"lang": "rust",
"repo": "Garvys/rustfst",
"path": "/rustfst/src/tests_openfst/algorithms/weight_pushing.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn test_weight_pushing_final<W, F>(test_data: &FstTestData<W, F>) -> Result<()>
where
F: SerializableFst<W> + MutableFst<W> + Display,
W: SerializableSemiring + WeaklyDivisibleSemiring + WeightQuantize,
{
// Weight pushing final
let mut fst_weight_push_final = test_data.raw.clone();
... | code_fim | hard | {
"lang": "rust",
"repo": "Garvys/rustfst",
"path": "/rustfst/src/tests_openfst/algorithms/weight_pushing.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let max:&i32 = numbers.iter().max().unwrap();
println!("Max: {}", max);
}<|fim_prefix|>// repo: PacktPublishing/Building-Reusable-Code-with-Rust path: /1-Basics_of_Code_Reuse/5-Functional_programming_style_loops/4-consuming_adaptors.rs
fn main() {
let numbers = vec![1, 2, 3, 4];
<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "PacktPublishing/Building-Reusable-Code-with-Rust",
"path": "/1-Basics_of_Code_Reuse/5-Functional_programming_style_loops/4-consuming_adaptors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PacktPublishing/Building-Reusable-Code-with-Rust path: /1-Basics_of_Code_Reuse/5-Functional_programming_style_loops/4-consuming_adaptors.rs
fn main() {
let numbers = vec![1, 2, 3, 4];
<|fim_suffix|> let max:&i32 = numbers.iter().max().unwrap();
println!("Max: {}", max);
}<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "PacktPublishing/Building-Reusable-Code-with-Rust",
"path": "/1-Basics_of_Code_Reuse/5-Functional_programming_style_loops/4-consuming_adaptors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: allevo/bravery path: /examples/shared_state.rs
use std::env;
use std::net::SocketAddr;
use bravery::{error_500, App, Handler, HttpError, Request, Response};
use std::collections::HashMap;
use std::sync::MutexGuard;
use std::sync::{Arc, Mutex};
extern crate serde;
extern crate serde_json;
#[ma... | code_fim | hard | {
"lang": "rust",
"repo": "allevo/bravery",
"path": "/examples/shared_state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct MyState {
counter: u32,
}
fn get_app() -> App<Arc<Mutex<MyState>>> {
let state = MyState { counter: 0 };
let state = Arc::new(Mutex::new(state));
let mut app = App::new_with_state(state);
app.get(
"/",
Box::new(TestHandler {
other_counter: Arc::new(... | code_fim | hard | {
"lang": "rust",
"repo": "allevo/bravery",
"path": "/examples/shared_state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iggy-rs/iggy path: /iggy/src/consumer.rs
use crate::bytes_serializable::BytesSerializable;
use crate::error::Error;
use crate::validatable::Validatable;
use bytes::BufMut;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
use std::fmt::Display;
use std::str::FromSt... | code_fim | hard | {
"lang": "rust",
"repo": "iggy-rs/iggy",
"path": "/iggy/src/consumer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parts = input.split('|').collect::<Vec<&str>>();
if parts.len() != 2 {
return Err(Error::InvalidCommand);
}
let kind = parts[0].parse::<ConsumerKind>()?;
let id = parts[1].parse::<u32>()?;
let consumer = Consumer { kind, id };
consum... | code_fim | hard | {
"lang": "rust",
"repo": "iggy-rs/iggy",
"path": "/iggy/src/consumer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>encoding_struct!{
/// Object representing data stored on our platform.
struct Data {
/// Location of the encrypted data.
location: &str,
/// Type of data (e.g. survey data, genomic data).
data_type: &str,
/// The data encryption level.
... | code_fim | medium | {
"lang": "rust",
"repo": "ldsec/ccgd-platform",
"path": "/consent-management/src/encoders.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ldsec/ccgd-platform path: /consent-management/src/encoders.rs
//! Objects that can be encoded in a format that can be stored on the blockchain.
use exonum::crypto::{Hash, PublicKey};
encoding_struct! {
/// Cryptocurrency wallet.
struct Wallet {
/// Public key of the wallet owne... | code_fim | medium | {
"lang": "rust",
"repo": "ldsec/ccgd-platform",
"path": "/consent-management/src/encoders.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unthawedStroma602/tari path: /base_layer/p2p/examples/pingpong.rs
// Copyright 2019 The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code... | code_fim | hard | {
"lang": "rust",
"repo": "unthawedStroma602/tari",
"path": "/base_layer/p2p/examples/pingpong.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let comms_config = CommsConfig {
transport_type,
node_identity,
datastore_path: datastore_path.path().to_path_buf(),
peer_database_name: random_string(8),
max_concurrent_inbound_tasks: 10,
outbound_buffer_size: 10,
... | code_fim | hard | {
"lang": "rust",
"repo": "unthawedStroma602/tari",
"path": "/base_layer/p2p/examples/pingpong.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let main_menu = Menu {
choices: vec![
// TODO all of this stuff
('i', format!("maximaldesign"), |app| {
analysis::synthesis::add_maximal(&mut app.model.inf);
app.integrate(AppAction::Model(ModelAction::Inf(Infrastructure... | code_fim | hard | {
"lang": "rust",
"repo": "luteberget/junction",
"path": "/lib/glrail/src/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luteberget/junction path: /lib/glrail/src/app.rs
use crate::command_builder::*;
use crate::selection::*;
use crate::model::*;
use crate::infrastructure::*;
use crate::schematic::*;
use crate::background::*;
use crate::analysis;
use crate::scenario;
use ordered_float::OrderedFloat;
use serde::{De... | code_fim | hard | {
"lang": "rust",
"repo": "luteberget/junction",
"path": "/lib/glrail/src/app.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub fn load_dialog(&mut self) -> Result<(),()> {
let filename = tinyfiledialogs::open_file_dialog("Open glrail document", "", None)
.ok_or(())?;
use std::fs::File;
use std::path::Path;
let json_path = Path::new(&filename);
let json_f... | code_fim | hard | {
"lang": "rust",
"repo": "luteberget/junction",
"path": "/lib/glrail/src/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::InvalidCert(err.to_string())
}
}
impl From<DeError> for Error {
fn from(err: DeError) -> Self {
Self::InvalidResponse(err.to_string())
}
}
pub type Result<T> = std::result::Result<T, Error>;<|fim_prefix|>// repo: Hakukano/FLP-SAML2 path: /src/error.rs
use openssl::erro... | code_fim | medium | {
"lang": "rust",
"repo": "Hakukano/FLP-SAML2",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<DeError> for Error {
fn from(err: DeError) -> Self {
Self::InvalidResponse(err.to_string())
}
}
pub type Result<T> = std::result::Result<T, Error>;<|fim_prefix|>// repo: Hakukano/FLP-SAML2 path: /src/error.rs
use openssl::error::ErrorStack;
use quick_xml::DeError;
use std::{fmt... | code_fim | medium | {
"lang": "rust",
"repo": "Hakukano/FLP-SAML2",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hakukano/FLP-SAML2 path: /src/error.rs
use openssl::error::ErrorStack;
use quick_xml::DeError;
use std::{fmt, io};
#[derive(Debug)]
pub enum Error {
IOError(String),
InvalidCert(String),
InvalidResponse(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatt... | code_fim | medium | {
"lang": "rust",
"repo": "Hakukano/FLP-SAML2",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sonos/tract path: /cli/src/bench.rs
use crate::Parameters;
use readings_probe::Probe;
use std::time::{Duration, Instant};
use tract_hir::internal::*;
use tract_libcli::terminal;
use tract_libcli::profile::BenchLimits;
pub fn criterion(
params: &Parameters,
_matches: &clap::ArgMatches,
... | code_fim | medium | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/cli/src/bench.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let model =
params.tract_model.downcast_ref::<TypedModel>().context("Can only bench TypedModel")?;
let plan = SimplePlan::new(model)?;
let mut state = SimpleState::new(plan)?;
let progress = probe.and_then(|m| m.get_i64("progress"));
info!("Starting bench itself");
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/cli/src/bench.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let progress = probe.and_then(|m| m.get_i64("progress"));
info!("Starting bench itself");
let mut iters = 0;
let inputs = tract_libcli::tensor::retrieve_or_make_inputs(model, &run_params)?.remove(0);
let start = Instant::now();
while iters < limits.max_iters && start.elapsed() < li... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/cli/src/bench.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ok
let person = Person::new("abc".to_string());
let name = person.get_name();
println!("{}", name);
}<|fim_prefix|>// repo: yubaoquan/minigrep path: /leetcode/src/foo/test1.rs
// https://www.zhihu.com/question/328066906
struct Person {
name: String,
}
impl Person {
#[inline]... | code_fim | hard | {
"lang": "rust",
"repo": "yubaoquan/minigrep",
"path": "/leetcode/src/foo/test1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yubaoquan/minigrep path: /leetcode/src/foo/test1.rs
// https://www.zhihu.com/question/328066906
struct Person {
name: String,
}
<|fim_suffix|> // ok
let person = Person::new("abc".to_string());
let name = person.get_name();
println!("{}", name);
}<|fim_middle|>impl Person {... | code_fim | hard | {
"lang": "rust",
"repo": "yubaoquan/minigrep",
"path": "/leetcode/src/foo/test1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_conv_addo() {
let instr = convert_op(0x7532);
assert_eq!(instr, AddO{reg: 5, byte: 0x32})
}
#[test]
fn test_conv_jmp() {
let instr = convert_op(0x1501);
assert_eq!(instr, Jmp{location: 0x501})
}
#[test]
fn test_conv_binop() ... | code_fim | hard | {
"lang": "rust",
"repo": "Heasummn/Chip8-Rust",
"path": "/src/instruction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Heasummn/Chip8-Rust path: /src/instruction.rs
#[derive(Eq, PartialEq, Debug)]
pub enum Instruction {
// PC = location
Jmp {location: u16},
// Call; pc = nnn, sp++
Call {location: u16},
Ret,
// Skip V[x] == V[y]
Se {x: u8, y: u8},
// V[reg] += byte
AddO {re... | code_fim | hard | {
"lang": "rust",
"repo": "Heasummn/Chip8-Rust",
"path": "/src/instruction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 0xCxkk
0xC => {
Instruction::Random {reg: x(op), byte: kk(op)}
},
// 0xDxyn
0xD => {
let x = x(op);
let y = y(op);
let n = low(op);
Instruction::Draw {x, y, n}
},
0xE => {
... | code_fim | hard | {
"lang": "rust",
"repo": "Heasummn/Chip8-Rust",
"path": "/src/instruction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_solves_array_of_two_unique_elements() {
let mut array: [u8; 4] = [1, 1, 2, 2];
assert_eq!(2, garbage_array_duplicates(&mut array));
assert_eq!(array[0], 1);
assert_eq!(array[1], 2);
}
#[test]
fn it_solves_array_in_example() {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "glongh/algorithms-data-structures-programs",
"path": "/src/problems/garbage_array_duplicates.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: glongh/algorithms-data-structures-programs path: /src/problems/garbage_array_duplicates.rs
//! # Problem
//! Given a sorted array **A**, mutate it in such a way that first **N**
//! elements are unique. All unique elements from **A** must be included in the
//! first **N** elements array slice. ... | code_fim | hard | {
"lang": "rust",
"repo": "glongh/algorithms-data-structures-programs",
"path": "/src/problems/garbage_array_duplicates.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut array: [u8; 1] = [8];
assert_eq!(1, garbage_array_duplicates(&mut array));
}
#[test]
fn it_solves_array_of_one_unique_elements() {
let mut array: [u8; 4] = [8, 8, 8, 8];
assert_eq!(1, garbage_array_duplicates(&mut array));
assert_eq!(array[0],... | code_fim | hard | {
"lang": "rust",
"repo": "glongh/algorithms-data-structures-programs",
"path": "/src/problems/garbage_array_duplicates.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Returns the text that the user entered this tick.
/// This will match the user's keyboard and OS settings.
pub fn get_text_input(ctx: &Context) -> Option<&str> {
ctx.input.current_text_input.as_ref().map(String::as_str)
}
pub(crate) fn set_text_input(ctx: &mut Context, text: Option<String>) {
... | code_fim | medium | {
"lang": "rust",
"repo": "programmeramera/tetra",
"path": "/src/input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: programmeramera/tetra path: /src/input.rs
//! Functions and types relating to handling the player's input.
//!
//! # Gamepads
//!
//! When accessing gamepad state, you specify which gamepad you're interested in via a 'gamepad index'.
//! The first gamepad connected to the system has index 0, the... | code_fim | hard | {
"lang": "rust",
"repo": "programmeramera/tetra",
"path": "/src/input.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> current_mouse_state: HashSet::new(),
previous_mouse_state: HashSet::new(),
mouse_position: Vec2::zero(),
pads: Vec::new(),
}
}
}
pub(crate) fn cleanup_after_state_update(ctx: &mut Context) {
ctx.input.previous_key_state = ctx.input.current_... | code_fim | hard | {
"lang": "rust",
"repo": "programmeramera/tetra",
"path": "/src/input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = state.peek();
// This should probably be "Seen" or something, as it is not removed
Ok(DBResult::Removed(self.command.queue_name().clone(), res))
}
fn postcondition(&self, _: &Journal) -> Result<(), Errors> {
Ok(())
}
}
impl Event<Journal, DBResult> for set::Set {
fn pre... | code_fim | hard | {
"lang": "rust",
"repo": "skade/drossel",
"path": "/src/drossel/events.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Event<Journal, DBResult> for PeekEvent {
fn precondition(&self, _: &Journal) -> Result<(), Errors> {
Ok(())
}
fn action(&self, state: &mut Journal) -> Result<DBResult, Errors> {
let res = state.peek();
// This should probably be "Seen" or something, as it is not removed
Ok(DBRe... | code_fim | hard | {
"lang": "rust",
"repo": "skade/drossel",
"path": "/src/drossel/events.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skade/drossel path: /src/drossel/events.rs
use drossel_journal::Journal;
use strand::mutable::{Event,AsEvent};
use strand::errors::{Errors};
use drossel::types::*;
use commands::ping;
use commands::get;
use commands::set;
use commands::command::*;
struct GetEvent {
command: get::Get
}
struct... | code_fim | hard | {
"lang": "rust",
"repo": "skade/drossel",
"path": "/src/drossel/events.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn parse(reader: &mut Read, module: &mut ParseModule) -> Result<(), ParseError> {
debug!("Parsing memory section");
let count = reader.bytes().read_varuint(32).unwrap();
for _ in 0..count {
let limits = ResizableLimits::parse(reader)?;
let capacity = limits.maximum.unwrap_o... | code_fim | medium | {
"lang": "rust",
"repo": "jawm/jumpjet",
"path": "/jump_jet/src/parser/memory_section.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jawm/jumpjet path: /jump_jet/src/parser/memory_section.rs
use std::io::Read;
use parser::leb::ReadLEB;
use parser::ParseError;
<|fim_suffix|>pub fn parse(reader: &mut Read, module: &mut ParseModule) -> Result<(), ParseError> {
debug!("Parsing memory section");
let count = reader.bytes(... | code_fim | medium | {
"lang": "rust",
"repo": "jawm/jumpjet",
"path": "/jump_jet/src/parser/memory_section.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Napokue/naga path: /src/back/hlsl/mod.rs
/*!
Backend for [HLSL][hlsl] (High-Level Shading Language).
# Supported shader model versions:
- 5.0
- 5.1
- 6.0
# Layout of values in `uniform` buffers
WGSL's ["Internal Layout of Values"][ilov] rules specify how each WGSL
type should be stored in `un... | code_fim | hard | {
"lang": "rust",
"repo": "Napokue/naga",
"path": "/src/back/hlsl/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Shorthand result used internally by the backend
type BackendResult = Result<(), Error>;
#[derive(Clone, Debug, PartialEq, thiserror::Error)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub enum EntryPointError {
#[e... | code_fim | hard | {
"lang": "rust",
"repo": "Napokue/naga",
"path": "/src/back/hlsl/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>is rendered as the HLSL struct type:
```ignore
struct Baz {
float2 m_0; float2 m_1; float2 m_2;
};
```
The `wrapped_struct_matrix` functions in `help.rs` generate HLSL
helper functions to access such members, converting between the stored
form and the HLSL matrix types appropriately. For example, fo... | code_fim | hard | {
"lang": "rust",
"repo": "Napokue/naga",
"path": "/src/back/hlsl/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Playfloor/helix-1 path: /examples/game_of_life/src/lib.rs
#![recursion_limit="1024"]
#[macro_use]
extern crate helix;
extern crate rand;
extern crate termion;
ruby! {
class GameOfLife {
struct {
width: usize,
height: usize,
cells: Vec<bool>,
... | code_fim | hard | {
"lang": "rust",
"repo": "Playfloor/helix-1",
"path": "/examples/game_of_life/src/lib.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (x, y) = self.coordinates();
let game = self.game();
let mut nx = x;
let mut ny = y;
match position {
TopLeft => { nx -= 1; ny -= 1; },
Top => { ny -= 1; },
TopRight => { nx += 1; ny -= 1; },
... | code_fim | hard | {
"lang": "rust",
"repo": "Playfloor/helix-1",
"path": "/examples/game_of_life/src/lib.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::mem::replace(&mut self.next, next)
}
fn size_hint(&self) -> (usize, Option<usize>) {
let remaining = match self.next {
Some(ref cell) => self.size - cell.index(),
None => 0,
};
(remaining, Some(remaining))
}
}
impl<'a> std::iter::... | code_fim | hard | {
"lang": "rust",
"repo": "Playfloor/helix-1",
"path": "/examples/game_of_life/src/lib.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl<Data, F> Middleware<Data> for F
where
F: Send + Sync + Fn(RequestContext<Data>) -> FutureObj<Response>,
{
fn handle<'a>(&'a self, ctx: RequestContext<'a, Data>) -> FutureObj<'a, Response> {
(self)(ctx)
}
}
pub struct RequestContext<'a, Data> {
pub app_data: Data,
pub r... | code_fim | hard | {
"lang": "rust",
"repo": "caulagi/tide",
"path": "/src/middleware/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: caulagi/tide path: /src/middleware/mod.rs
use std::any::Any;
use std::fmt::Debug;
use std::sync::Arc;
use futures::future::FutureObj;
use crate::{configuration::Store, router::EndpointData, Request, Response, RouteMatch};
mod default_headers;
pub mod logger;
pub use self::default_headers::De... | code_fim | hard | {
"lang": "rust",
"repo": "caulagi/tide",
"path": "/src/middleware/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the configuration store for this request.
///
/// This is for debug purposes. `Store` implements `Debug`, so the store can be inspected using
/// `{:?}` formatter.
pub fn store(&self) -> &Store {
&self.endpoint.store
}
/// Consume this context, and run remainin... | code_fim | hard | {
"lang": "rust",
"repo": "caulagi/tide",
"path": "/src/middleware/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "http")]
pub fn try_into(mut self) -> io::Result<::http::Response<Vec<u8>>> {
let mut body = Vec::new();
self.body.read_to_end(&mut body)?;
let headers: Vec<(&str, &[u8])> = self.headers.iter().map(|(k, v)| (&**k, &**v)).collect();
Ok(
... | code_fim | hard | {
"lang": "rust",
"repo": "jD91mZM2/minttp",
"path": "/src/response.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jD91mZM2/minttp path: /src/response.rs
use error::Error;
use std::collections::HashMap;
#[cfg(feature = "http")]
use std::io;
use std::io::{BufRead, BufReader, Read};
/// Response struct
pub struct Response<Stream: Read> {
pub http_version: String,
pub status: u16,
pub description: ... | code_fim | hard | {
"lang": "rust",
"repo": "jD91mZM2/minttp",
"path": "/src/response.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>y (pol = 1 t0 - falling edge, t1 - rising edge)
// Temperature control
pub static XI_PRM_IS_COOLED: &'static str = "iscooled"; // Returns 1 for cameras that support cooling.
pub static XI_PRM_COOLING: &'static str = "cooling"; // Start camera cooling. XI_SWITCH
pub static XI... | code_fim | hard | {
"lang": "rust",
"repo": "erezny/xiapi_sys-rust",
"path": "/src/xiapi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erezny/xiapi_sys-rust path: /src/xiapi.rs
esolution by binning or skipping.
pub static XI_PRM_DOWNSAMPLING_TYPE: &'static str = "downsampling_type"; // Change image downsampling type. XI_DOWNSAMPLING_TYPE
pub static XI_PRM_SHUTTER_TYPE: &'static str = "shutter_type"; // Change s... | code_fim | hard | {
"lang": "rust",
"repo": "erezny/xiapi_sys-rust",
"path": "/src/xiapi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>re/gain ROI Height
pub static XI_PRM_EXP_PRIORITY: &'static str = "exp_priority"; // Exposure priority (0.8 - exposure 80%, gain 20%).
pub static XI_PRM_AE_MAX_LIMIT: &'static str = "ae_max_limit"; // Maximum time (us) used for exposure in AEAG procedure
pub static XI_PRM_AG_MAX_LIMI... | code_fim | hard | {
"lang": "rust",
"repo": "erezny/xiapi_sys-rust",
"path": "/src/xiapi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let first_marker_position = reader
.into_iter()
.enumerate()
.map(|(i, x)| x.unwrap_or_else(|err| panic!("Error reading {filename}:C{i}: {err:?}")))
.filter(|x| x != &'\n') // exclude any newlines
.enumerate() // renumber
.position(|(i, c)| {
... | code_fim | hard | {
"lang": "rust",
"repo": "m000/adventofcode",
"path": "/2022/src/day06.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m000/adventofcode path: /2022/src/day06.rs
use clap::Parser;
use env_logger::Env;
use log::{debug, info};
use rbl_circular_buffer::CircularBuffer;
use std::collections::HashSet;
use std::fs::File;
use std::io::BufReader;
use utf8_read::Reader;
/// Advent of Code 2022, Day 6
#[derive(Parser, Deb... | code_fim | medium | {
"lang": "rust",
"repo": "m000/adventofcode",
"path": "/2022/src/day06.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let marker_size: usize = match args.part {
1 => 4,
2 => 14,
part @ _ => panic!("Don't know how to run part {part}."),
};
let filename = &args.input;
let mut reader = Reader::new(BufReader::new(File::open(filename).unwrap_or_else(|err| {
panic!("Error opening... | code_fim | medium | {
"lang": "rust",
"repo": "m000/adventofcode",
"path": "/2022/src/day06.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct IterPreorder<'a, T: 'a> {
stack: Vec<&'a Tree<T>>, // bind
}
impl<'a, T> IterPreorder<'a, T> {
pub fn new(tree: Option<Box<&'a Tree<T>>>) -> IterPreorder<T> {
let mut pre_out = IterPreorder { stack: Vec::new() }; // init
tree.as_ref().map(|tree| {
pre_out.stack.push(tree); // p... | code_fim | hard | {
"lang": "rust",
"repo": "bryzhao/side_projects",
"path": "/btree_iterative_exercise.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bryzhao/side_projects path: /btree_iterative_exercise.rs
// Bryan Zhao
// Fall 2017
// More advanced b-tree search algorithms in Rust.
// tree definition
#[derive(Debug)]
pub struct Tree<T> {
data: Option<T>,
left: Option<Box<Tree<T>>>, // left child
right: Option<Box<Tree<T>>>, // right ch... | code_fim | hard | {
"lang": "rust",
"repo": "bryzhao/side_projects",
"path": "/btree_iterative_exercise.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.