text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: Noah2610/deathframe path: /deathframe_core/src/components/lifecycle/mod.rs
pub mod prelude {
pub use super::lifecycle::Lifecycle;
pub use super::lifecycle_state::LifecycleState;
}
<|fim_suffix|>use super::component_prelude;<|fim_middle|>mod lifecycle;
mod lifecycle_state;
| code_fim | easy | {
"lang": "rust",
"repo": "Noah2610/deathframe",
"path": "/deathframe_core/src/components/lifecycle/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use super::component_prelude;<|fim_prefix|>// repo: Noah2610/deathframe path: /deathframe_core/src/components/lifecycle/mod.rs
pub mod prelude {
pub use super::lifecycle::Lifecycle;
pub use super::lifecycle_state::LifecycleState;
}
<|fim_middle|>mod lifecycle;
mod lifecycle_state;
| code_fim | easy | {
"lang": "rust",
"repo": "Noah2610/deathframe",
"path": "/deathframe_core/src/components/lifecycle/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adam-mcdaniel/rapture path: /src/input.rs
use std::io::{stdin, stdout, Write};
/// This function prompts the user with a message and returns the user's input.
/// It also pops off trailing carriage returns.
pub fn input<S: ToString>(prompt: S) -> String {
let mut buf = String::new();
pr... | code_fim | hard | {
"lang": "rust",
"repo": "adam-mcdaniel/rapture",
"path": "/src/input.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Used to prompt the user with a yes or no question.
/// If they answer with Y or y, this function returns true.
pub fn yes_or_no<S: ToString>(prompt: S) -> bool {
let response = input(prompt);
response.to_lowercase().trim() == "y"
}<|fim_prefix|>// repo: adam-mcdaniel/rapture path: /src/input... | code_fim | medium | {
"lang": "rust",
"repo": "adam-mcdaniel/rapture",
"path": "/src/input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JamesDevlin5/wc-rs path: /src/lib.rs
use std::cmp;
use std::io::{BufRead, BufReader, Read};
#[derive(Debug)]
pub struct Count {
lines: usize,
words: usize,
chars: usize,
bytes: usize,
line_len: usize,
}
<|fim_suffix|> loop {
line.clear();
let ... | code_fim | hard | {
"lang": "rust",
"repo": "JamesDevlin5/wc-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
line.clear();
let amt_read = buf.read_line(&mut line).expect("Could not read line...");
if amt_read > 0 {
self.lines += 1;
self.bytes += amt_read;
self.line_len = cmp::max(self.line_len, line.len());
... | code_fim | medium | {
"lang": "rust",
"repo": "JamesDevlin5/wc-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Count {
pub fn process<R: Read>(&mut self, reader: R) {
let mut buf = BufReader::new(reader);
let mut line = String::new();
loop {
line.clear();
let amt_read = buf.read_line(&mut line).expect("Could not read line...");
if amt_read > 0 {... | code_fim | medium | {
"lang": "rust",
"repo": "JamesDevlin5/wc-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beatmadsen/rust-chess path: /src/lib.rs
#[cfg(test)]
mod tests {
use chess::core::*;
<|fim_suffix|>
assert_eq!(3, dance(1, 2));
}
}
pub mod chess;<|fim_middle|> #[test]
fn it_works() {
| code_fim | easy | {
"lang": "rust",
"repo": "beatmadsen/rust-chess",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(3, dance(1, 2));
}
}
pub mod chess;<|fim_prefix|>// repo: beatmadsen/rust-chess path: /src/lib.rs
#[cfg(test)]
mod tests {
use chess::core::*;
<|fim_middle|> #[test]
fn it_works() {
| code_fim | easy | {
"lang": "rust",
"repo": "beatmadsen/rust-chess",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> planner.dispatch(());
}
fn teardown(&mut self, planner: &mut specs::Planner<()>) {
planner.systems.clear();
}
}<|fim_prefix|>// repo: lidavidm/jrogue path: /src/screens/title.rs
use bear_lib_terminal;
use specs;
use super::Screen;
<|fim_middle|>pub struct TitleScreen;
impl... | code_fim | hard | {
"lang": "rust",
"repo": "lidavidm/jrogue",
"path": "/src/screens/title.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lidavidm/jrogue path: /src/screens/title.rs
use bear_lib_terminal;
use specs;
use super::Screen;
pub struct TitleScreen;
<|fim_suffix|> fn update(&mut self, planner: &mut specs::Planner<()>) {
planner.dispatch(());
}
fn teardown(&mut self, planner: &mut specs::Planner<()>)... | code_fim | medium | {
"lang": "rust",
"repo": "lidavidm/jrogue",
"path": "/src/screens/title.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tohie/chartrs path: /src/plottable/mod.rs
pub mod axis;
pub mod primitives;
pub mod graphs;
pub mod legend;
pub use self::axis::Axis;
pub use self::legend::Legend;
<|fim_suffix|>}
pub trait HasDataSet {
fn data_set(&self) -> &DataSet;
}<|fim_middle|>use canvas::Canvas;
use graph_dimension... | code_fim | medium | {
"lang": "rust",
"repo": "Tohie/chartrs",
"path": "/src/plottable/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Plottable {
fn plot<C: Canvas>(&self, bounds: &GraphDimensions, canvas: &mut C) -> Result<(), C::Err>;
}
pub trait HasDataSet {
fn data_set(&self) -> &DataSet;
}<|fim_prefix|>// repo: Tohie/chartrs path: /src/plottable/mod.rs
pub mod axis;
pub mod primitives;
pub mod graphs;
pub mod le... | code_fim | medium | {
"lang": "rust",
"repo": "Tohie/chartrs",
"path": "/src/plottable/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn withdraw(program_id: &Pubkey, accounts: &[AccountInfo], amount: u64) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let vault_info = next_account_info(account_info_iter)?;
let pool_info = next_account_info(account_info_iter)?;
let withdraw_authority_info ... | code_fim | hard | {
"lang": "rust",
"repo": "refcell/neodyme-breakpoint-workshop",
"path": "/level3/src/processor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: refcell/neodyme-breakpoint-workshop path: /level3/src/processor.rs
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
program::{invoke, invoke_signed},
program_error::ProgramError,
pu... | code_fim | hard | {
"lang": "rust",
"repo": "refcell/neodyme-breakpoint-workshop",
"path": "/level3/src/processor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> K: OwnedToVariant + ToVariantEq + ToVariant,
V: OwnedToVariant + ToVariant,
{
let mut dict = Dictionary::new();
dict.extend(from.iter());
dict.into_shared()
}<|fim_prefix|>// repo: chjdev/ultreia-rs path: /src/godot/variant/make_dict.rs
use gdnative::prelude::{Dictionary, OwnedToVariant... | code_fim | medium | {
"lang": "rust",
"repo": "chjdev/ultreia-rs",
"path": "/src/godot/variant/make_dict.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chjdev/ultreia-rs path: /src/godot/variant/make_dict.rs
use gdnative::prelude::{Dictionary, OwnedToVariant, ToVariant, ToVariantEq};
use std::collections::HashMap;
pub fn make_dict<K, V>(from: &HashMap<K, V>) -> Dictionary
where
<|fim_suffix|>let mut dict = Dictionary::new();
dict.extend(... | code_fim | medium | {
"lang": "rust",
"repo": "chjdev/ultreia-rs",
"path": "/src/godot/variant/make_dict.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: codeOverFlow/chip8 path: /src/main.rs
mod system;
use system::chip;
use std::time::Duration;
use std::thread;
use std::io;
use std::io::prelude::*;
use std::fs::File;
<|fim_suffix|> let mut chip = chip::init_chip();
let mut f = File::open("/home/adrien/Documents/perso/rust/chip8/games... | code_fim | medium | {
"lang": "rust",
"repo": "codeOverFlow/chip8",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> opcode = chip.cpu.get_op_code();
chip.interpret(opcode);
thread::sleep(Duration::from_millis(FPS as u64));
println!("{}", chip.screen);
}
}<|fim_prefix|>// repo: codeOverFlow/chip8 path: /src/main.rs
mod system;
use system::chip;
use std::time::Duration;
use std::th... | code_fim | hard | {
"lang": "rust",
"repo": "codeOverFlow/chip8",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/zone2021/src/bin/b.rs
use proconio::input;
fn main() {
input! {
n: usize,
d: f64,
h: f6<|fim_suffix|>if x < 0_f64 { 0_f64 } else { x };
}
}
let ans = max;
println!("{}", ans)
}<|fim_middle|>4,
... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/zone2021/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if x < 0_f64 { 0_f64 } else { x };
}
}
let ans = max;
println!("{}", ans)
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/zone2021/src/bin/b.rs
use proconio::input;
fn main() {
input! {
n: usize,
d: f64,
h: f64,
dh: [(f64... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/zone2021/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>) {
let x = h_i - d_i * (h - h_i) / (d - d_i);
if x > max {
max = if x < 0_f64 { 0_f64 } else { x };
}
}
let ans = max;
println!("{}", ans)
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/zone2021/src/bin/b.rs
use proconio::input;... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/zone2021/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FauxFaux/gitgeoff path: /src/grep.rs
use std::path::Path;
use anyhow::anyhow;
use anyhow::Context;
use anyhow::Error;
use grep_regex::RegexMatcher;
use grep_searcher::sinks::Lossy;
use grep_searcher::Searcher;
use rayon::iter::IntoParallelIterator;
use rayon::iter::ParallelIterator;
use super:... | code_fim | hard | {
"lang": "rust",
"repo": "FauxFaux/gitgeoff",
"path": "/src/grep.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let status = Searcher::new().search_slice(
&matcher,
content,
Lossy(|lnum, line| {
let path = provider
.map(|p| href(&path, &p.html_browse_path(None, &path, Some(lnum))))
.unwrap_or_else(|| path.to_string()... | code_fim | hard | {
"lang": "rust",
"repo": "FauxFaux/gitgeoff",
"path": "/src/grep.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut kvpair = KVPair::new();
kvpair.key = TendermintEventKey::CoinMinted.into();
kvpair.value = minted.to_string().as_bytes().to_owned();
event.attributes.push(kvpair);
response.events.push(event);
}
response
}
/// C... | code_fim | hard | {
"lang": "rust",
"repo": "fadlidony/chain",
"path": "/chain-abci/src/app/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref account) = maccount {
let mut kvpair = KVPair::new();
kvpair.key = TendermintEventKey::Account.into();
kvpair.value = Vec::from(format!("{}", &account.address));
event.attributes.push(kvpair);
last_... | code_fim | hard | {
"lang": "rust",
"repo": "fadlidony/chain",
"path": "/chain-abci/src/app/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fadlidony/chain path: /chain-abci/src/app/mod.rs
;
mod rewards;
mod slash_accounts;
mod validate_tx;
use abci::*;
use log::info;
pub use self::app_init::{
compute_accounts_root, get_validator_key, init_app_hash, ChainNodeApp, ChainNodeState,
ValidatorState,
};
use crate::enclave_bridge... | code_fim | hard | {
"lang": "rust",
"repo": "fadlidony/chain",
"path": "/chain-abci/src/app/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rjmholt/mips-disasm-rust path: /src/mips/data.rs
use std::fmt;
// Instruction bit field lengths
pub const INSTR_LEN: u8 = 32;
pub const OPCODE_LEN: u8 = 6;
pub const RS_LEN: u8 = 5;
pub const RT_LEN: u8 = 5;
pub const RD_LEN: u8 = 5;
pub const SHAMT_LEN: u8 = 5;
pub const FUNCT_LE... | code_fim | hard | {
"lang": "rust",
"repo": "rjmholt/mips-disasm-rust",
"path": "/src/mips/data.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
write!(f, "slt ${}, ${}, ${}", self.rd, self.rs, self.rt)
}
}
pub struct SRA
{
pub rt: u8,
pub rd: u8,
pub shamt: u8
}
impl fmt::Display for SRA
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
{
write!(f, "sra ${}, ${}, {}", self.rd, self.rt, se... | code_fim | hard | {
"lang": "rust",
"repo": "rjmholt/mips-disasm-rust",
"path": "/src/mips/data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> queryable_impls! {
Date -> NaiveDate,
Time -> NaiveTime,
Timestamp -> NaiveDateTime,
}
}<|fim_prefix|>// repo: Felmoks/diesel path: /diesel/src/types/impls/date_and_time.rs
#[cfg(feature="chrono")]
mod chrono {
extern crate chrono;
use self::chrono::*;
<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "Felmoks/diesel",
"path": "/diesel/src/types/impls/date_and_time.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Felmoks/diesel path: /diesel/src/types/impls/date_and_time.rs
#[cfg(feature="chrono")]
mod chrono {
extern crate chrono;
use self::chrono::*;
<|fim_suffix|> queryable_impls! {
Date -> NaiveDate,
Time -> NaiveTime,
Timestamp -> NaiveDateTime,
}
}<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "Felmoks/diesel",
"path": "/diesel/src/types/impls/date_and_time.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beamiter/leetcode-rust path: /src/dd_challenge/s00038_count_and_say.rs
use crate::dd_challenge::Solution;
impl Solution {
pub fn count_and_say(n: i32) -> String {
if n <= 1 {
return n.to_string();
}
let prv_res = Self::count_and_say(n - 1).chars().collec... | code_fim | medium | {
"lang": "rust",
"repo": "beamiter/leetcode-rust",
"path": "/src/dd_challenge/s00038_count_and_say.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use crate::dd_challenge::Solution;
#[test]
fn test_count_and_say() {
assert_eq!(Solution::count_and_say(1), "1".to_string());
assert_eq!(Solution::count_and_say(5), "111221".to_string());
assert_eq!(Solution::count_and_say(6), "312211".to_strin... | code_fim | hard | {
"lang": "rust",
"repo": "beamiter/leetcode-rust",
"path": "/src/dd_challenge/s00038_count_and_say.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Wowo10/AdventOfCode2020 path: /day6/src/main.rs
mod functions;
fn main() {
let input = functions::file_utils::get_input();
let mut counter = 0;
for elem in &input {
counter += count_unique_characters(|c| elem.any_answered(c));
}
<|fim_suffix|> if f(c) {
... | code_fim | hard | {
"lang": "rust",
"repo": "Wowo10/AdventOfCode2020",
"path": "/day6/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn count_unique_characters<F>(f: F) -> i32
where
F: Fn(char) -> bool,
{
let mut counter = 0;
for i in 0..26 {
let c = add_char('a', i);
if f(c) {
counter += 1;
}
}
counter
}
fn add_char(c: char, u: u32) -> char {
std::char::from_u32(c as u32 + ... | code_fim | hard | {
"lang": "rust",
"repo": "Wowo10/AdventOfCode2020",
"path": "/day6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dragon1061/MoonZoon path: /crates/zoon/src/style/font/font_line.rs
use crate::*;
#[derive(Default)]
pub struct FontLine<'a> {
pub(crate) static_css_props: StaticCSSProps<'a>,
pub(crate) dynamic_css_props: DynamicCSSProps,
}
impl FontLine<'_> {
pub fn new() -> Self {
Self::d... | code_fim | hard | {
"lang": "rust",
"repo": "dragon1061/MoonZoon",
"path": "/crates/zoon/src/style/font/font_line.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn double(mut self) -> Self {
self.static_css_props
.insert("text-decoration-style", "double");
self
}
pub fn dotted(mut self) -> Self {
self.static_css_props
.insert("text-decoration-style", "dotted");
self
}
pub fn dashed(... | code_fim | hard | {
"lang": "rust",
"repo": "dragon1061/MoonZoon",
"path": "/crates/zoon/src/style/font/font_line.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn width_signal(
mut self,
width: impl Signal<Item = impl Into<Option<HSLuv>>> + Unpin + 'static,
) -> Self {
let width = width.map(|width| width.into().map(|width| px(width)));
self.dynamic_css_props
.insert("text-decoration-thickness".into(), box_c... | code_fim | hard | {
"lang": "rust",
"repo": "dragon1061/MoonZoon",
"path": "/crates/zoon/src/style/font/font_line.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jaic1/xv6-riscv-rust path: /src/process/cpu.rs
use array_macro::array;
use core::ptr;
use crate::register::{tp, sstatus};
use crate::spinlock::SpinLockGuard;
use crate::consts::NCPU;
use super::{Context, PROC_MANAGER, Proc, ProcState, proc::ProcExcl};
pub static mut CPU_MANAGER: CpuManager = ... | code_fim | hard | {
"lang": "rust",
"repo": "Jaic1/xv6-riscv-rust",
"path": "/src/process/cpu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // interrupt is off
if !guard.holding() {
panic!("sched(): not holding proc's lock");
}
// only holding self.proc's lock
if self.noff != 1 {
panic!("sched(): cpu hold multi locks");
}
// proc is not running
if guard.st... | code_fim | hard | {
"lang": "rust",
"repo": "Jaic1/xv6-riscv-rust",
"path": "/src/process/cpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Switch back to scheduler.
/// Passing in and out a guard,
/// beacuse we need to hold the proc lock during this method.
pub unsafe fn sched<'a>(&mut self, guard: SpinLockGuard<'a, ProcExcl>, ctx: *mut Context)
-> SpinLockGuard<'a, ProcExcl>
{
extern "C" {
... | code_fim | hard | {
"lang": "rust",
"repo": "Jaic1/xv6-riscv-rust",
"path": "/src/process/cpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern "C" fn livid_api_raw_write<'a>(api: *mut LividApi<'a>, string: *const i8) -> () {
unsafe {
(*api)
.editor
.write(const_char_cstr(string).to_str().unwrap())
.unwrap()
}
}
impl<'a> LividApi<'a> {
fn new(input: &'a mut CsvInputFile, editor: &'a ... | code_fim | hard | {
"lang": "rust",
"repo": "zbanks/livid",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let log_fd = log_file.as_raw_fd();
Ok(Editor {
workspace: workspace,
vimrc_path: vimrc_path,
script_file: script_file,
script_notify: script_notify,
log_file: log_file,
output_file: output_file,
grid_rows:... | code_fim | hard | {
"lang": "rust",
"repo": "zbanks/livid",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zbanks/livid path: /src/main.rs
self.empty_value()
}
}
}
struct Cell<'col, 'val> {
column: &'col Column,
empty: bool,
value: CellValue<'val>,
}
type Row<'col, 'val> = Vec<Cell<'col, 'val>>;
impl<'val> fmt::Debug for CStrPtr<'val> {
fn fmt(&self, f: &mut... | code_fim | hard | {
"lang": "rust",
"repo": "zbanks/livid",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu/bobbin-stm32/stm32f42x/src/dma2d.rs
self.ceif() != 0 { try!(write!(f, " ceif"))}
if self.ctcif() != 0 { try!(write!(f, " ctcif"))}
if self.caeif() != 0 { try!(write!(f, " caeif"))}
if self.twif() != 0 { try!(write!(f, " twif"))}
if ... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32f42x/src/dma2d.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu/bobbin-stm32/stm32f42x/src/dma2d.rs
odify the BGCMAR register."]
#[inline] pub fn with_bgcmar<F: FnOnce(Bgcmar) -> Bgcmar>(&self, f: F) -> &Self {
self.bgcmar_reg().with(f);
self
}
#[doc="Get the OPFCCR Register."]
#[inline] pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32f42x/src/dma2d.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[doc="Sets the START field."]
#[inline] pub fn set_start<V: Into<::bobbin_bits::U1>>(mut self, value: V) -> Self {
let value: ::bobbin_bits::U1 = value.into();
let value: u32 = value.into();
self.0 &= !(0x1 << 0);
self.0 |= value << 0;
self
}
}
impl F... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32f42x/src/dma2d.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>///
/// Creates a parked future and an unparker that can be used to set its value
///
pub fn park_future<TResult>() -> (ParkedFuture<TResult>, FutureUnparker<TResult>) {
// Create the core that we'll share
let core = Arc::new(Mutex::new(ParkedFutureCore { wait: None, result: None, unparked: false ... | code_fim | hard | {
"lang": "rust",
"repo": "adamnemecek/flowbetween",
"path": "/user_interfaces/http_ui/src/parked_future.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adamnemecek/flowbetween path: /user_interfaces/http_ui/src/parked_future.rs
use futures::*;
use futures::task;
use futures::task::Task;
use std::sync::*;
///
/// A future that will eventually have a value (this seems to be a feature missing from
/// the futures library)
///
pub struct ParkedFu... | code_fim | hard | {
"lang": "rust",
"repo": "adamnemecek/flowbetween",
"path": "/user_interfaces/http_ui/src/parked_future.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_tests(
vec![
TestCase::new("1st Test Case Title", "1st Test Case Criteria", Box::new(|logger: &mut Logger| -> TestCaseStatus {
logger.pass(format!("Good to go"));
TestCaseStatus::PASSED
})),
TestCase::new("2nd Test Case Title", "2nd Test Case... | code_fim | medium | {
"lang": "rust",
"repo": "alshakero/polish",
"path": "/examples/run_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alshakero/polish path: /examples/run_tests.rs
extern crate polish;
use polish::test_case::{TestCaseStatus, TestCase, run_tests};
use polish::logger::{Logger};
<|fim_suffix|> run_tests(
vec![
TestCase::new("1st Test Case Title", "1st Test Case Criteria", Box::new(|logger: &mu... | code_fim | medium | {
"lang": "rust",
"repo": "alshakero/polish",
"path": "/examples/run_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> .iter()
.take_while(|&x| {
coins -= x;
coins >= 0
})
.count() as i32
}
}<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1833-Maximum Ice Cream Bars/Sort.rs
impl Solution {
pub fn max_ice_cream(mut costs: Vec<i32>, mut co... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1833-Maximum Ice Cream Bars/Sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1833-Maximum Ice Cream Bars/Sort.rs
impl Solution {
pub fn max_ice_cream(mut costs: Vec<i32>, mut coins:<|fim_suffix|> coins >= 0
})
.count() as i32
}
}<|fim_middle|> i32) -> i32 {
costs.sort_unstable();
... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1833-Maximum Ice Cream Bars/Sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> coins >= 0
})
.count() as i32
}
}<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1833-Maximum Ice Cream Bars/Sort.rs
impl Solution {
pub fn max_ice_cream(mut costs: Vec<i32>, mut coins: i32) -> i32 {
costs.sort_unstable();
costs
... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1833-Maximum Ice Cream Bars/Sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: capnproto/capnproto-rust path: /capnp/src/capability.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documenta... | code_fim | hard | {
"lang": "rust",
"repo": "capnproto/capnproto-rust",
"path": "/capnp/src/capability.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The return values of a method, written in-place by the method body.
#[cfg(feature = "alloc")]
pub struct Results<T> {
pub marker: PhantomData<T>,
pub hook: Box<dyn ResultsHook>,
}
#[cfg(feature = "alloc")]
impl<T> Results<T>
where
T: Owned,
{
pub fn new(hook: Box<dyn ResultsHook>) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "capnproto/capnproto-rust",
"path": "/capnp/src/capability.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eseraygun/rust-honestintervals path: /src/interval/impl_basic.rs
use super::def::{Interval, ParseIntervalError, SignClass};
use fp::{Float, Sign};
use std::fmt;
use std::fmt::{Display, Formatter, Write};
use std::str::FromStr;
impl SignClass {
/// Whether `self` is `SignClass::Positive(_)... | code_fim | hard | {
"lang": "rust",
"repo": "eseraygun/rust-honestintervals",
"path": "/src/interval/impl_basic.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<BOUND: Float> From<f64> for Interval<BOUND> {
#[inline]
fn from(val: f64) -> Self {
Self::from_with_prec(val, 53)
}
}
impl<BOUND: Float> FromStr for Interval<BOUND> {
type Err = ParseIntervalError;
#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
S... | code_fim | hard | {
"lang": "rust",
"repo": "eseraygun/rust-honestintervals",
"path": "/src/interval/impl_basic.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> for mut slot in &inner.slots {
if let Ok(mut slot) = slot.try_lock() {
// if the slot's instant is in the past
if *slot <= now {
// the slot is expired/free
// set the slot's new expiry instant to be now + rate.duration
*slot = now + inner.rate_duration;
... | code_fim | hard | {
"lang": "rust",
"repo": "bekh6ex/stream-throttle",
"path": "/src/pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bekh6ex/stream-throttle path: /src/pool.rs
use super::ThrottleRate;
use error::{Error, ErrorKind};
use failure::Fail;
use futures::stream;
use futures::{Future, Stream};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use tokio_timer;
/// A clonable object which is used to thro... | code_fim | hard | {
"lang": "rust",
"repo": "bekh6ex/stream-throttle",
"path": "/src/pool.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Produces a future which will resolve once the pool has an available slot.
///
/// Each `Throttled` stream will call this method during polling, once for each item the
/// underlying stream produces. These futures are driven to completion by polling the
/// `Throttled` stream. In the process, thes... | code_fim | hard | {
"lang": "rust",
"repo": "bekh6ex/stream-throttle",
"path": "/src/pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod ports;
pub mod result;<|fim_prefix|>// repo: dmichiels/temp_rustfbp path: /src/lib.rs
// #![feature(alloc_system)]
// extern crate alloc_system;
<|fim_middle|>#[macro_use] extern crate quick_error;
extern crate libloading;
extern crate capnp;
pub mod component;
pub mod scheduler;
| code_fim | medium | {
"lang": "rust",
"repo": "dmichiels/temp_rustfbp",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmichiels/temp_rustfbp path: /src/lib.rs
// #![feature(alloc_system)]
// extern crate alloc_system;
#[macro_use] extern crate quick_error;
extern crate libloading;
extern crate capnp;
<|fim_suffix|>pub mod scheduler;
pub mod ports;
pub mod result;<|fim_middle|>pub mod component;
| code_fim | easy | {
"lang": "rust",
"repo": "dmichiels/temp_rustfbp",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_use] extern crate quick_error;
extern crate libloading;
extern crate capnp;
pub mod component;
pub mod scheduler;
pub mod ports;
pub mod result;<|fim_prefix|>// repo: dmichiels/temp_rustfbp path: /src/lib.rs
// #![feature(alloc_system)]
<|fim_middle|>// extern crate alloc_system;
| code_fim | easy | {
"lang": "rust",
"repo": "dmichiels/temp_rustfbp",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn list_style(mut self, list_style: ListStyle) -> Self {
self.list_style = Some(list_style);
self
}
pub fn no_list_style(mut self) -> Self {
self.list_style = None;
self
}
pub fn build(self) -> Self {
self
}
}
fn get_list_item_prefix(i... | code_fim | hard | {
"lang": "rust",
"repo": "ZeroX-DG/darkside",
"path": "/src/widgets/list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZeroX-DG/darkside path: /src/widgets/list.rs
use super::{util, Renderable, BaseWidget, Location, Size};
use ncurses::{WINDOW, mvwaddstr};
pub struct List {
base: BaseWidget,
items: Vec<ListItem>
}
pub struct ListItem {
list_style: Option<ListStyle>,
content: String
}
pub enum ... | code_fim | hard | {
"lang": "rust",
"repo": "ZeroX-DG/darkside",
"path": "/src/widgets/list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_vsqrtps.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/instr_vsqrtps.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn vsqrtps_13() {
run_test(&Instruction { mnemonic: Mnemonic::VSQRTPS, operand1: Some(Direct(XMM9)), operand2: Some(IndirectDisplaced(RDI, 873683348, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: fa... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/instr_vsqrtps.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl User {
pub fn new() -> User {
User {
id: None,
org_id: None,
global_permissions: None,
display_name: None,
email: None,
auth: None,
sms_number: None,
tokens: None,
}
}
}<|fim_prefix... | code_fim | hard | {
"lang": "rust",
"repo": "grinnan/zeronsd",
"path": "/zerotier-central-api/src/models/user.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grinnan/zeronsd path: /zerotier-central-api/src/models/user.rs
/*
* ZeroTier Central API
*
* ZeroTier Central Network Management Portal API.<p>All API requests must have an API token header specified in the <code>Authorization: Bearer xxxxx</code> format. You can generate your API key by log... | code_fim | hard | {
"lang": "rust",
"repo": "grinnan/zeronsd",
"path": "/zerotier-central-api/src/models/user.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leizy0/AoCInRust path: /2019/day2_5_7_9_11/src/amp.rs
use std::{cell::RefCell, fmt::Display, rc::Rc};
use crate::int_code::com::{Channel, IntCodeComputer, ProcessState};
pub struct AmpSettings {
settings: Vec<Vec<i64>>,
}
impl From<&[i64]> for AmpSettings {
fn from(init_setting: &[i64... | code_fim | hard | {
"lang": "rust",
"repo": "leizy0/AoCInRust",
"path": "/2019/day2_5_7_9_11/src/amp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if res.state() != ProcessState::Halt {
return Err(Error::ProcessBlockInChain(i));
}
amp_res = output_chan
.borrow()
.data()
.get(0)
.cloned()
.ok_or(Error::EmptyAmplifierResult(Vec::from(settings)))?;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "leizy0/AoCInRust",
"path": "/2019/day2_5_7_9_11/src/amp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 3Hren/msgpack-rust path: /rmp/tests/func/decode/mod.rs
mod array;
mod bin;
mod bool;
mod ext;
mod float;
mod map;
mod null;
mod sint;
mod string;
mod uint;
#[cfg(feature = "std")]
pub <|fim_suffix|>"std"))]
pub type Cursor<'a> = crate::msgpack::decode::Bytes<'a>;<|fim_middle|>type Cursor<'a> = ... | code_fim | medium | {
"lang": "rust",
"repo": "3Hren/msgpack-rust",
"path": "/rmp/tests/func/decode/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"std"))]
pub type Cursor<'a> = crate::msgpack::decode::Bytes<'a>;<|fim_prefix|>// repo: 3Hren/msgpack-rust path: /rmp/tests/func/decode/mod.rs
mod array;
mod bin;
mod bool;
mod ext;
mod float;
mod map;
mod null;
mod sint;
mod string;
mod uint;
#[cfg(feature = "std")]
pub <|fim_middle|>type Cursor<'a> = ... | code_fim | medium | {
"lang": "rust",
"repo": "3Hren/msgpack-rust",
"path": "/rmp/tests/func/decode/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brayniac/pelikan path: /src/proxy/momento/src/protocol/resp/hincrby.rs
// Copyright 2023 Pelikan Foundation LLC.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use std::io::Write;
use std::time::Duration;
<|fim_suffix|>use super::update_method_m... | code_fim | hard | {
"lang": "rust",
"repo": "brayniac/pelikan",
"path": "/src/proxy/momento/src/protocol/resp/hincrby.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(response_buf, ":{}\r\n", response.value)?;
klog_1(&"hincrby", &req.key(), Status::Hit, response_buf.len());
Ok(())
})
.await
}<|fim_prefix|>// repo: brayniac/pelikan path: /src/proxy/momento/src/protocol/resp/hincrby.rs
// Copyright 2023 Pelikan Foundation LLC.
// ... | code_fim | hard | {
"lang": "rust",
"repo": "brayniac/pelikan",
"path": "/src/proxy/momento/src/protocol/resp/hincrby.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pclewis/cudd-sys path: /src/lib.rs
//! This crate provides unsafe Rust bindings for the University of Colorado decision diagram
//! package (CUDD), including the DDDMP serialisation library. It uses version `3.0.0` of CUDD
//! available from the unofficial [Github mirror](https://github.com/ivma... | code_fim | hard | {
"lang": "rust",
"repo": "pclewis/cudd-sys",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An opaque C struct used to represent the decision diagram node.
#[repr(C)]
pub struct DdNode {
_data: [u8; 0],
_marker: PhantomData<(*mut u8, PhantomPinned)>,
}
/// An opaque C struct used to represent the CUDD manager.
#[repr(C)]
pub struct DdManager {
_data: [u8; 0],
_marker: Phanto... | code_fim | hard | {
"lang": "rust",
"repo": "pclewis/cudd-sys",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A const-qualified version of `DdApaNumber`.
pub type DdConstApaNumber = *const DdApaDigit;
/// An opaque C struct used to represent the result of the computation of two-literal clauses.
///
/// See `Cudd_FindTwoLiteralClauses`.
#[repr(C)]
pub struct DdTlcInfo {
_data: [u8; 0],
_marker: Phanto... | code_fim | hard | {
"lang": "rust",
"repo": "pclewis/cudd-sys",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use errno::prelude::{Result, *};<|fim_prefix|>// repo: tatetian/ngo2 path: /src/libos/crates/async-io/src/prelude.rs
pub(crate) use std::sync::{Arc, Weak};
#[cfg(feature = "sgx")]
pub(crate) use std::prelude::v1::*;
<|fim_middle|>pub(crate) use spin::{Mutex, MutexGuard};
| code_fim | easy | {
"lang": "rust",
"repo": "tatetian/ngo2",
"path": "/src/libos/crates/async-io/src/prelude.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tatetian/ngo2 path: /src/libos/crates/async-io/src/prelude.rs
pub(crate) use std::sync::{Arc, Weak};
#[cfg(feature = "sgx")]
pub(crate) use std::prelude::v1::*;
<|fim_suffix|>pub use errno::prelude::{Result, *};<|fim_middle|>pub(crate) use spin::{Mutex, MutexGuard};
| code_fim | easy | {
"lang": "rust",
"repo": "tatetian/ngo2",
"path": "/src/libos/crates/async-io/src/prelude.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) use spin::{Mutex, MutexGuard};
pub use errno::prelude::{Result, *};<|fim_prefix|>// repo: tatetian/ngo2 path: /src/libos/crates/async-io/src/prelude.rs
pub(crate) use std::sync::{Arc, Weak};
<|fim_middle|>#[cfg(feature = "sgx")]
pub(crate) use std::prelude::v1::*;
| code_fim | medium | {
"lang": "rust",
"repo": "tatetian/ngo2",
"path": "/src/libos/crates/async-io/src/prelude.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/x509-parser path: /src/x509_parser.rs
::oid::Oid;
use der_parser::*;
fn parse_malformed_string(i: &[u8]) -> DerResult {
let (rem, hdr) = ber_read_element_header(i)?;
let len = hdr.len.primitive()?;
if len > MAX_OBJECT_SIZE {
return Err(nom::Err::Error(BerError::Inval... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/x509-parser",
"path": "/src/x509_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_tbs_cert_list(i: &[u8]) -> X509Result<TbsCertList> {
let start_i = i;
parse_ber_sequence_defined_g(move |_, i| {
let (i, version) = opt(parse_ber_u32)(i).or(Err(X509Error::InvalidVersion))?;
let (i, signature) = parse_algorithm_identifier(i)?;
let (i, issuer) = par... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/x509-parser",
"path": "/src/x509_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/x509-parser path: /src/x509_parser.rs
r.len.primitive()?;
if len > MAX_OBJECT_SIZE {
return Err(nom::Err::Error(BerError::InvalidLength));
}
match hdr.tag {
BerTag::PrintableString => {
// if we are in this function, the PrintableString could not b... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/x509-parser",
"path": "/src/x509_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ekuinox/amane path: /src/main.rs
#[macro_use]
extern crate anyhow;
mod http;
mod bucket;
mod state;
use actix_web::{App, HttpServer};
use http::routes::*;
use state::AppState;
<|fim_suffix|> let server = HttpServer::new(move || App::new()
.data(state.clone())
.service(searc... | code_fim | hard | {
"lang": "rust",
"repo": "ekuinox/amane",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let server = HttpServer::new(move || App::new()
.data(state.clone())
.service(search_files)
.service(put_file)
.service(get_file)
.service(delete_file)
);
server
.bind(matches
.value_of("bind")
.unwrap_or("0.0.0.0:8080")
... | code_fim | hard | {
"lang": "rust",
"repo": "ekuinox/amane",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn pif8(&mut self) -> PIF8_W<PR1_SPEC, 8> {
PIF8_W::new(self)
}
#[doc = "Bit 9 - Configurable event inputs Pending bit"]
#[inline(always)]
#[must_use]
pub fn pif9(&mut self) -> PIF9_W<PR1_SPEC, 9> {
PIF9_W::new(self)
}
#[doc = "Bit 10 - Configurable event i... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32wb/src/stm32wb55/exti/pr1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32wb/src/stm32wb55/exti/pr1.rs
#[doc = "Register `PR1` reader"]
pub type R = crate::R<PR1_SPEC>;
#[doc = "Register `PR1` writer"]
pub type W = crate::W<PR1_SPEC>;
#[doc = "Field `PIF0` reader - Configurable event inputs Pending bit"]
pub type PIF0_R = crate:... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32wb/src/stm32wb55/exti/pr1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for nexts in graph {
total_edges += nexts.len();
new_graph.push(nexts.iter().rev().copied().collect::<Vec<_>>());
}
let mut result = Vec::new();
if dfs(&mut new_graph, 0, 0, &mut result) {
(result.len() == total_edges + 1).then(|| {
result.reverse();
... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/Introduction-to-Algorithms",
"path": "/src/chapter_22_elementary_graph_algorithms/problems/problem_22_3_euler_tour.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result = Vec::new();
if dfs(&mut new_graph, 0, 0, &mut result) {
(result.len() == total_edges + 1).then(|| {
result.reverse();
result.into_boxed_slice()
})
} else {
None
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_euler_to... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/Introduction-to-Algorithms",
"path": "/src/chapter_22_elementary_graph_algorithms/problems/problem_22_3_euler_tour.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/Introduction-to-Algorithms path: /src/chapter_22_elementary_graph_algorithms/problems/problem_22_3_euler_tour.rs
fn dfs(graph: &mut [Vec<usize>], node: usize, target: usize, result: &mut Vec<usize>) -> bool {
let reachable = graph[node].pop().map_or_else(
|| node == target,
... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/Introduction-to-Algorithms",
"path": "/src/chapter_22_elementary_graph_algorithms/problems/problem_22_3_euler_tour.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x: Camera = Camera {
aspect_ratio: 16.0/9.0,
fovy: 3.14/2.0,
pos: Point3::new(7.3, -4.2, 8.6),
lookat: Vector3::new(1.0, 0.2, -1.0),
vup: Vector3::new(0.0, 1.0, 0.0),
.. Default::default()
};
x
}
#[test]
fn test_camera_gen_ray() {
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "lemonteaa/rusty-raytracer",
"path": "/src/scene/camera.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn test_create_camera() -> Camera {
let x: Camera = Camera {
aspect_ratio: 16.0/9.0,
fovy: 3.14/2.0,
pos: Point3::new(7.3, -4.2, 8.6),
lookat: Vector3::new(1.0, 0.2, -1.0),
vup: Vector3::new(0.0, 1.0, 0.0),
.. Default::default()
};
x
}
#[test]
f... | code_fim | hard | {
"lang": "rust",
"repo": "lemonteaa/rusty-raytracer",
"path": "/src/scene/camera.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lemonteaa/rusty-raytracer path: /src/scene/camera.rs
use model::Ray;
use na::{Point3, Vector3, Matrix4, Perspective3};
use alga::linear::Transformation;
pub struct Camera {
pub aspect_ratio: f64,
pub fovy: f64,
pub pos: Point3<f64>,
pub lookat: Vector3<f64>,
pub vup: Vecto... | code_fim | hard | {
"lang": "rust",
"repo": "lemonteaa/rusty-raytracer",
"path": "/src/scene/camera.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn skip_ahead(&mut self, start: u64) -> Option<u64> {
let bitfield_index = &self.bitfield.index;
let tree_end = self.index_end;
let iter = &mut self.bitfield.iterator;
let o = start & 3;
iter.seek(2 * (start / 4));
let mut tree_byte = bitfield_inde... | code_fim | hard | {
"lang": "rust",
"repo": "datrs/hypercore",
"path": "/src/bitfield/iterator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if free == -1 {
pos = self.skip_ahead(pos)?;
self.byte = self.bitfield.data.get_byte(pos as usize);
free = self.bitfield.masks.next_data_0_bit[self.byte as usize];
}
}
self.pos = Some(pos);
self.byte |= self.... | code_fim | hard | {
"lang": "rust",
"repo": "datrs/hypercore",
"path": "/src/bitfield/iterator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: datrs/hypercore path: /src/bitfield/iterator.rs
//! Iterate over a bitfield.
use super::Bitfield;
/// Iterate over a bitfield.
#[derive(Debug)]
pub struct Iterator<'a> {
start: u64,
end: u64,
index_end: u64,
pos: Option<u64>,
byte: u8,
bitfield: &'a mut Bitfield,
}
imp... | code_fim | hard | {
"lang": "rust",
"repo": "datrs/hypercore",
"path": "/src/bitfield/iterator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for t in 0..initial_numbers.len() {
match previous_number {
None => (),
Some(n) => { number_timestamps.insert(n, t); },
}
previous_number = Some(initial_numbers[t]);
}
let mut previous_number: usize = previous_number.unwrap();
for t in init... | code_fim | medium | {
"lang": "rust",
"repo": "Ben-Wormald/advent-of-code-2020",
"path": "/src/solutions/day_15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for t in initial_numbers.len()..TURNS {
let number = match number_timestamps.contains_key(&previous_number) {
true => t - number_timestamps.get(&previous_number).unwrap(),
false => 0,
};
number_timestamps.insert(previous_number, t);
previous_numb... | code_fim | hard | {
"lang": "rust",
"repo": "Ben-Wormald/advent-of-code-2020",
"path": "/src/solutions/day_15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.