text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
fn set_extranonce1(&mut self, extranonce1: HexBytes);
fn extranonce1(&self) -> HexBytes;
fn set_extranonce2_size(&mut self, extra_nonce2_size: usize);
fn extranonce2_size(&self) -> usize;
fn version_rolling_mask(&self) -> Option<HexU32Be>;
fn set_version_rolling_mask(&mut sel... | code_fim | hard | {
"lang": "rust",
"repo": "Fi3/stratum",
"path": "/protocols/v1/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fi3/stratum path: /protocols/v1/src/lib.rs
tandard requests
//! Mmessage ID must be an unique identifier of request during current transport session. It may be
//! integer or some unique string, like UUID. ID must be unique only from one side (it means, both
//! server and clients can initiate r... | code_fim | hard | {
"lang": "rust",
"repo": "Fi3/stratum",
"path": "/protocols/v1/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fi3/stratum path: /protocols/v1/src/lib.rs
! json-rpc has two types of messages: **request** and **response**.
//! A request message can be either a **notification** or a **standard message**.
//! Standard messegaes expect a response notifications no. A typical example of a notification
//! is t... | code_fim | hard | {
"lang": "rust",
"repo": "Fi3/stratum",
"path": "/protocols/v1/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for index in 0..ones.len() {
let one_count: i32 = match ones.get(&(index as i32)) {
Some(val) => *val,
_ => 0,
};
let zero_count = match zero.get(&(index as i32)) {
Some(val) => *val,
_ => 0,
};
if one_count >= z... | code_fim | hard | {
"lang": "rust",
"repo": "ousbots/AdventOfCode",
"path": "/archive/2021/day3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if one_count >= zero_count {
gamma += "1";
epsilon += "0";
} else {
gamma += "0";
epsilon += "1";
}
}
(gamma, epsilon)
}
// Determine the oxygen and CO2 scrubber rates from the diagnostic codes. The rates are determined
// b... | code_fim | hard | {
"lang": "rust",
"repo": "ousbots/AdventOfCode",
"path": "/archive/2021/day3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ousbots/AdventOfCode path: /archive/2021/day3/src/main.rs
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::HashMap;
use std::fs::File;
use std::io::{self, BufRead};
fn main() {
let path = "assets/input.txt";
let file = match File::open(path) {
Ok... | code_fim | hard | {
"lang": "rust",
"repo": "ousbots/AdventOfCode",
"path": "/archive/2021/day3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the task's name.
///
/// ```rust,no_run
/// # use altos_core::{TaskHandle, Priority};
/// # use altos_core::syscall::new_task;
/// # use altos_core::args::Args;
///
/// let handle = new_task(test_task, Args::empty(), 512, Priority::Normal, "new_task_name");
///
/// match h... | code_fim | hard | {
"lang": "rust",
"repo": "dnseitz/CortexM0Rust",
"path": "/altos-core/src/task/control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dnseitz/CortexM0Rust path: /altos-core/src/task/control.rs
nst INVALID_TASK: usize = 0x0;
type HandleResult<T> = Result<T, ()>;
mod tid {
use atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
static CURRENT_TID: AtomicUsize = ATOMIC_USIZE_INIT;
/// Atomically increment the task id ... | code_fim | hard | {
"lang": "rust",
"repo": "dnseitz/CortexM0Rust",
"path": "/altos-core/src/task/control.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dnseitz/CortexM0Rust path: /altos-core/src/task/control.rs
fetch_next_tid() -> usize {
CURRENT_TID.fetch_add(1, Ordering::Relaxed)
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Delay {
Timeout,
Sleep,
Overflowed,
Invalid,
}
/// Priorities that a task can have.
///
/// Pr... | code_fim | hard | {
"lang": "rust",
"repo": "dnseitz/CortexM0Rust",
"path": "/altos-core/src/task/control.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fhaynes/rendy path: /memory/src/mapping/range.rs
use std::{
mem::{align_of, size_of},
ops::Range,
ptr::NonNull,
slice::{from_raw_parts, from_raw_parts_mut},
};
/// Get sub-range of memory mapping.
/// `range` is in memory object space.
pub(crate) fn mapped_fitting_range(
ptr... | code_fim | hard | {
"lang": "rust",
"repo": "fhaynes/rendy",
"path": "/memory/src/mapping/range.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// # Safety
///
/// User must ensure that:
/// * this function won't create aliasing slices.
/// * returned slice doesn't outlive mapping.
pub(crate) unsafe fn mapped_slice_mut<'a, T>(ptr: NonNull<u8>, range: Range<u64>) -> &'a mut [T] {
let size = (range.end - range.start) as usize;
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "fhaynes/rendy",
"path": "/memory/src/mapping/range.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// # Safety
///
/// User must ensure that:
/// * returned slice doesn't outlive mapping.
pub(crate) unsafe fn mapped_slice<'a, T>(ptr: NonNull<u8>, range: Range<u64>) -> &'a [T] {
let size = (range.end - range.start) as usize;
assert_eq!(
size % size_of::<T>(),
0,
"Range l... | code_fim | hard | {
"lang": "rust",
"repo": "fhaynes/rendy",
"path": "/memory/src/mapping/range.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn write(&self, addr: u8, bytes: &[u8]) {
// Send a START condition
self.cr1.modify(|_, w| w.start().start());
// Wait until the START condition is generated
while self.sr1.read().sb().is_no_start() {}
// Wait until back in Master mode (MSL = 1) and communicatio... | code_fim | hard | {
"lang": "rust",
"repo": "yusefkarim/stm32f4-playground",
"path": "/without_hal/src/bin/adxl345.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yusefkarim/stm32f4-playground path: /without_hal/src/bin/adxl345.rs
#![no_std]
#![no_main]
/// ADXL345 via I2C
/// Make sure the CS and SDO pins are tied high
///
/// Dear reader: This is horrible code. Solely for learning purposes. It is not supposed to
/// represent a proper driver in any way.... | code_fim | hard | {
"lang": "rust",
"repo": "yusefkarim/stm32f4-playground",
"path": "/without_hal/src/bin/adxl345.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// if admin is true, then the predecessor account is granted admin permission.
fn test<F>(admin: bool, permissions: ContractPermissions, f: F)
where
F: FnOnce(VMContext, AccountManager),
{
let mut ctx = new_context(PREDECESSOR_ACCOUNT);
ctx.predecessor_account_id =... | code_fim | hard | {
"lang": "rust",
"repo": "oysterpack/oysterpack-smart-near",
"path": "/near/oysterpack-smart-account-management/src/components/account_management.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oysterpack/oysterpack-smart-near path: /near/oysterpack-smart-account-management/src/components/account_management.rs
.ops_permissions_contains(to_valid_account_id(bob), PERM_0.into()));
assert!(!account_manager
.ops_permissions_contains(... | code_fim | hard | {
"lang": "rust",
"repo": "oysterpack/oysterpack-smart-near",
"path": "/near/oysterpack-smart-account-management/src/components/account_management.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let account = service.registered_account_near_data(ACCOUNT_ID);
assert_eq!(account.near_balance(), service.storage_balance_bounds().min);
// AccountStorageEvent:Registered event should have been published to update stats
... | code_fim | hard | {
"lang": "rust",
"repo": "oysterpack/oysterpack-smart-near",
"path": "/near/oysterpack-smart-account-management/src/components/account_management.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dfriedenberger/Prellblock path: /prellblock/src/consensus/praftbft/view_change/state.rs
use super::RingBuffer;
use crate::consensus::{LeaderTerm, SignatureList};
use pinxit::{PeerId, Signature};
use std::{collections::HashMap, time::Instant};
#[derive(Debug)]
pub struct State {
pub leader_t... | code_fim | medium | {
"lang": "rust",
"repo": "dfriedenberger/Prellblock",
"path": "/prellblock/src/consensus/praftbft/view_change/state.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.future_signatures
.increment_to(new_leader_term, HashMap::new());
self.leader_term = new_leader_term;
self.new_view_time = Some(Instant::now());
self.current_signatures = Some(
self.future_signatures
.increment(HashMap::new())
... | code_fim | medium | {
"lang": "rust",
"repo": "dfriedenberger/Prellblock",
"path": "/prellblock/src/consensus/praftbft/view_change/state.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Rotate a sprite
///
/// Rotation does not mutate the model-space of a sprite.
pub fn rotate<T: Copy + Into<Rad<f32>>>(&mut self, handle: &Handle, angle: T) {
self.vx.strtexs[handle.0].rotbuf_touch = self.vx.swapconfig.image_count;
for rot in &mut self.vx.strtexs[handle.... | code_fim | hard | {
"lang": "rust",
"repo": "Omen-of-Aecio/vxdraw",
"path": "/src/strtex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Omen-of-Aecio/vxdraw path: /src/strtex.rs
clude_bytes!["../target/spirv/strtex.vert.spirv"];
const FRAGMENT_SOURCE_TEXTURE: &[u8] = include_bytes!["../target/spirv/strtex.frag.spirv"];
let vertex_source_texture = match options.vertex_shader {
VertexShader::Standard =... | code_fim | hard | {
"lang": "rust",
"repo": "Omen-of-Aecio/vxdraw",
"path": "/src/strtex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set the translation on all strtexs
///
/// Applies [Strtex::set_translation] to each dynamic texture.
pub fn set_translation_all(
&mut self,
layer: &Layer,
mut delta: impl FnMut(usize) -> (f32, f32),
) {
self.vx.strtexs[layer.0].tranbuf_touch = self.... | code_fim | hard | {
"lang": "rust",
"repo": "Omen-of-Aecio/vxdraw",
"path": "/src/strtex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let err = from_json_value::<LocationContent>(json_data).unwrap_err();
assert!(err.is_data());
assert_eq!(err.to_string(), ZoomLevelError::TooHigh.to_string());
}
#[test]
fn message_event_deserialization() {
let json_data = json!({
"content": {
"org.matrix.msc1767.text"... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-events/tests/it/location.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn room_message_unstable_serialization() {
let message_event_content =
RoomMessageEventContent::new(MessageType::Location(LocationMessageEventContent::new(
"Alice was at geo:51.5008,0.1247;u=35".to_owned(),
"geo:51.5008,0.1247;u=35".to_owned(),
)));
... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-events/tests/it/location.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma-events/tests/it/location.rs
#![cfg(feature = "unstable-msc3488")]
use assert_matches2::assert_matches;
use assign::assign;
use js_int::uint;
use ruma_common::{
event_id, owned_event_id, room_id, serde::CanBeEmpty, user_id, MilliSecondsSinceUnixEpoch,
};
use ruma... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-events/tests/it/location.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Volland/steel path: /steel/src/compiler/passes/mod.rs
pub mod begin;
pub mod manager;
use crate::parser::ast::ExprKind;
use crate::parser::ast::*;
pub trait Folder {
fn fold(&mut self, ast: Vec<ExprKind>) -> Vec<ExprKind> {
ast.into_iter().map(|x| self.visit(x)).collect()
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Volland/steel",
"path": "/steel/src/compiler/passes/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn visit_syntax_rules(&mut self, l: SyntaxRules) -> ExprKind {
ExprKind::SyntaxRules(l)
}
#[inline]
fn visit_set(&mut self, mut s: Box<Set>) -> ExprKind {
s.variable = self.visit(s.variable);
s.expr = self.visit(s.expr);
ExprKind::Set(s)
}... | code_fim | hard | {
"lang": "rust",
"repo": "Volland/steel",
"path": "/steel/src/compiler/passes/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn sorted_records(&self) -> Vec<(bool, Record)> {
let is_first_iter = std::iter::once(true).chain(std::iter::repeat(false).take(self.records.len() - 1));
let mut records_with_marker: Vec<_> = is_first_iter.zip(self.records.clone().into_iter()).collect();
records_with_marker... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/crossarena",
"path": "/src/records.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlterionX/crossarena path: /src/records.rs
use gdnative::{
FromVariant,
Instance,
NativeClass,
Node,
ToVariant,
};
#[derive(ToVariant, FromVariant)]
#[derive(Debug, Clone)]
pub struct Record {
pub wave_num: u64,
}
#[derive(Default, Debug)]
#[derive(NativeClass)]
#[inher... | code_fim | medium | {
"lang": "rust",
"repo": "AlterionX/crossarena",
"path": "/src/records.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variables.insert(name.clone(), *stack_index);
*stack_index -= 4;
}
Statement::Expr(expr) => output.push_str(&generate_expression(expr, variables, stack_index)),
}
output
}
pub fn generate(ast: &Program) -> String {
let mut output = String::new();
ma... | code_fim | hard | {
"lang": "rust",
"repo": "tangyiyong/ox",
"path": "/src/generator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tangyiyong/ox path: /src/generator.rs
use std::collections::HashMap;
use ast::*;
use scanner::*;
type VariableMap = HashMap<String, isize>;
fn generate_expression(expression: &Expr, variables: &mut VariableMap, stack_index: &mut isize) -> String {
match expression {
Expr::Const(nu... | code_fim | hard | {
"lang": "rust",
"repo": "tangyiyong/ox",
"path": "/src/generator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(expr) = value {
output.push_str(&generate_expression(expr, variables, stack_index));
output.push_str(" pushl %eax\n");
} else {
output.push_str(" pushl $0\n");
}
variables.insert(name.clone(), *s... | code_fim | hard | {
"lang": "rust",
"repo": "tangyiyong/ox",
"path": "/src/generator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erickt/stateful path: /src/analysis/gather_moves.rs
, to
// ensure that other code does not accidentally access `index.0`
// (which is likely to yield a subtle off-by-one error).
mod indexes {
use std::fmt;
use data_structures::indexed_vec::Idx;
macro_rules! new_index {
($In... | code_fim | hard | {
"lang": "rust",
"repo": "erickt/stateful",
"path": "/src/analysis/gather_moves.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn create_move_path(&mut self, lval: &Lvalue) {
// This is an assignment, not a move, so this not being a valid
// move path is OK.
let _ = self.move_path_for(lval);
}
/*
fn move_path_for_projection(&mut self,
lval: &Lvalue,
... | code_fim | hard | {
"lang": "rust",
"repo": "erickt/stateful",
"path": "/src/analysis/gather_moves.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn finalize(self) -> MoveData {
debug!("{}", {
debug!("moves for {:?}:", self.mir.span);
for (j, mo) in self.data.moves.iter_enumerated() {
debug!(" {:?} = {:?}", j, mo);
}
debug!("move paths for {:?}:", self.mir.span);
... | code_fim | hard | {
"lang": "rust",
"repo": "erickt/stateful",
"path": "/src/analysis/gather_moves.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BigTuna08/par_lgp2 path: /src/anal/mod.rs
use evo_sys::*;
use data::DataSet;
use std::collections::{HashMap, HashSet};
use params;
pub struct DecompSet{
pub branches: Vec<Instruction>,
pub progs: Vec<Program>,
pub original: Program,
}
pub struct SomeResult{
correc... | code_fim | hard | {
"lang": "rust",
"repo": "BigTuna08/par_lgp2",
"path": "/src/anal/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for record in data.records.iter() {
let mut regs = eval::registers::PROG_REG.clone();
for (i, feature) in genome.features.iter().enumerate() { //load features
regs[params::params::MAX_REGS - 1 - i] = record.features[*feature as usize]
}
let (pro... | code_fim | hard | {
"lang": "rust",
"repo": "BigTuna08/par_lgp2",
"path": "/src/anal/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: massand/libiothsm2 path: /cert/aziot-certd/src/error.rs
#[derive(Debug)]
pub enum Error {
Internal(InternalError),
InvalidParameter(&'static str, Box<dyn std::error::Error + Send + Sync>),
}
impl Error {
pub(crate) fn invalid_parameter<E>(name: &'static str, err: E) -> Self where E: Into<Box... | code_fim | hard | {
"lang": "rust",
"repo": "massand/libiothsm2",
"path": "/cert/aziot-certd/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::error::Error for InternalError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
InternalError::CreateCert(err) => Some(&**err),
InternalError::CreateFile(err) => Some(err),
InternalError::DeleteFile(err) => Some(err),
InternalError::GetPath(err) => S... | code_fim | hard | {
"lang": "rust",
"repo": "massand/libiothsm2",
"path": "/cert/aziot-certd/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hw0lff/tab-rs path: /tab-daemon/src/message/tab.rs
use crate::state::{assignment::Assignment, pty::PtyScrollback};
use std::sync::Arc;
use tab_api::{
chunk::{InputChunk, OutputChunk},
client::RetaskTarget,
tab::{TabId, TabMetadata},
};
/// An input (stdin) event for tab, identified ... | code_fim | hard | {
"lang": "rust",
"repo": "hw0lff/tab-rs",
"path": "/tab-daemon/src/message/tab.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TabScrollback {
#[cfg(test)]
pub fn empty(id: TabId) -> Self {
Self {
id,
scrollback: PtyScrollback::empty(),
}
}
#[cfg(test)]
pub async fn push(&self, chunk: OutputChunk) {
self.scrollback.push(chunk).await;
}
pub async fn... | code_fim | hard | {
"lang": "rust",
"repo": "hw0lff/tab-rs",
"path": "/tab-daemon/src/message/tab.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brunodea/mypaste-infra path: /src/content.rs
use base64;
use md5;
use serde::{Deserialize, Serialize};
/// The Content trait specify a hash function in order to uniquely represent
/// some Content.
pub(crate) trait Content {
fn hash(&self) -> String;
}
<|fim_suffix|>#[cfg(test)]
mod tests... | code_fim | hard | {
"lang": "rust",
"repo": "brunodea/mypaste-infra",
"path": "/src/content.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn paste_content_hash_has_size_hashlen() {
assert_eq!(
HASHLEN,
PasteContent::PlainText("ABCDEFGHIKLMNOP".to_string())
.hash()
.len()
);
assert_eq!(
HASHL... | code_fim | hard | {
"lang": "rust",
"repo": "brunodea/mypaste-infra",
"path": "/src/content.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> StatHolder {
kurt: Kurtosis::new(),
perc: CKMS::new(ERROR),
}
}
fn add(&mut self, a: f64) {
self.perc.insert(a);
self.kurt.add(a);
}
}
#[pyfunction]
/// Generate features for the given numpy array.
fn generate_features(input: &PyArrayDy... | code_fim | hard | {
"lang": "rust",
"repo": "mantasbandonis/CoMTE",
"path": "/fast_features/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mantasbandonis/CoMTE path: /fast_features/src/lib.rs
// Contains the code for SC'20 paper "Counterfactual Explanations for Machine
// Learning on Multivariate HPC Time Series Data"
// Authors:
// Emre Ates (1), Burak Aksar (1), Vitus J. Leung (2), Ayse K. Coskun (1)
// Affiliations:
// ... | code_fim | hard | {
"lang": "rust",
"repo": "mantasbandonis/CoMTE",
"path": "/fast_features/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl StatHolder {
fn new() -> StatHolder {
StatHolder {
kurt: Kurtosis::new(),
perc: CKMS::new(ERROR),
}
}
fn add(&mut self, a: f64) {
self.perc.insert(a);
self.kurt.add(a);
}
}
#[pyfunction]
/// Generate features for the given nump... | code_fim | hard | {
"lang": "rust",
"repo": "mantasbandonis/CoMTE",
"path": "/fast_features/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thisismana/actix-slog path: /src/field_names.rs
pub struct FieldNames {
pub http_version: &'static str,
pub http_host: &'static str,
pub referer: &'static str,
pub remote_address: &'static str,
pub user_agent: &'static str,
pub request_method: &'static str,
pub correl... | code_fim | medium | {
"lang": "rust",
"repo": "thisismana/actix-slog",
"path": "/src/field_names.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> FieldNames {
http_version: "http_version",
http_host: "http_host",
referer: "referer",
remote_address: "remote_address",
user_agent: "agent",
request_method: "request_method",
correlation_id: "correlation-id",
... | code_fim | medium | {
"lang": "rust",
"repo": "thisismana/actix-slog",
"path": "/src/field_names.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// The cases become obvious when you look at the binary representation
pub fn some_examples(x: i32) -> bool {
x & 0b0101 > 0b0101 // x & 0101 will never be larger than 0101
&& x & 0b0101 == 0b0110 // x & 0101 will never equal 0110
&& x | 0b01 == 0b00 // x | 01 will never be equal to 00
&& ... | code_fim | medium | {
"lang": "rust",
"repo": "Rust-Wroclaw/rust-wroclaw",
"path": "/talk-archive/2022-07-can-you-trigger-all-clippy-lints-and-live-to-tell-the-tale/src/more_than_trivial/bad_bit_mask.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns a reference to the value associate with key in the cache
/// or `None` if it the key is not
/// present
/// # Arguments
/// * `key` - Key to look for the value
#[inline]
pub fn get(&mut self, key: &SynthesizerCacheKey) -> Option<&T> {
self.cache.get(key)
... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/synthetic-data-showcase",
"path": "/packages/core/src/processing/generator/synthesizers/cache.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: microsoft/synthetic-data-showcase path: /packages/core/src/processing/generator/synthesizers/cache.rs
use fnv::FnvBuildHasher;
use lru::LruCache;
use std::{num::NonZeroUsize, sync::Arc};
use crate::data_block::{CsvRecordRef, DataBlockValue};
/// Represents a key that will be stored in the cach... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/synthetic-data-showcase",
"path": "/packages/core/src/processing/generator/synthesizers/cache.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Inserts the value associate with key in the cache.
/// If the key already exists in the cache, it is updated with the new value
/// and the old value is returned. Otherwise, `None` is returned.
/// # Arguments
/// * `key` - Key to be inserted
/// * `value` - Value to associated... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/synthetic-data-showcase",
"path": "/packages/core/src/processing/generator/synthesizers/cache.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.fd == 0 { return }
// TODO: warn? Do something better?
let _ = unsafe { std::fs::File::from_raw_fd(self.fd) };
}
}<|fim_prefix|>// repo: zthompson47/tokio-uring path: /src/fs/file.rs
use crate::BufResult;
use crate::driver::Op;
use crate::buf::{IoBuf, Slice};
use std... | code_fim | medium | {
"lang": "rust",
"repo": "zthompson47/tokio-uring",
"path": "/src/fs/file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zthompson47/tokio-uring path: /src/fs/file.rs
use crate::BufResult;
use crate::driver::Op;
use crate::buf::{IoBuf, Slice};
use std::io;
use std::os::unix::io::RawFd;
use std::path::Path;
pub struct File {
/// Open file descriptor
fd: RawFd,
}
impl File {
/// Attempts to open a fil... | code_fim | medium | {
"lang": "rust",
"repo": "zthompson47/tokio-uring",
"path": "/src/fs/file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: waynr/qsk path: /src/entrypoint.rs
use std::error;
use std::thread::sleep;
use std::time::Duration;
use async_compat::Compat;
use async_std::prelude::FutureExt;
use async_std::task;
use clap::ArgMatches;
use qsk_types::layer_composer::{
LayerComposer, InputTransformer, Passthrough,
};
use... | code_fim | hard | {
"lang": "rust",
"repo": "waynr/qsk",
"path": "/src/entrypoint.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match matches.subcommand() {
Some(("listen", submatches)) => task::block_on(Compat::new(listen(submatches)))?,
Some(("list-devices", _)) => linux_evdev::Device::list()?,
Some(("remap", submatches)) => task::block_on(remap(lc, submatches))?,
_ => (),
};
Ok(())
}
... | code_fim | medium | {
"lang": "rust",
"repo": "waynr/qsk",
"path": "/src/entrypoint.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hannes-hochreiner/backup-remote-rs path: /src/aws/aws_vault.rs
use anyhow::Result;
use chrono::{DateTime, FixedOffset};
use serde::Deserialize;
use std::convert::TryFrom;
use tokio_postgres::Row;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct AwsVault {
pub cre... | code_fim | medium | {
"lang": "rust",
"repo": "hannes-hochreiner/backup-remote-rs",
"path": "/src/aws/aws_vault.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(AwsVault {
creation_date: value.try_get("creation_date")?,
last_inventory_date: value.try_get("last_inventory_date")?,
number_of_archives: value.try_get("number_of_archives")?,
size_in_bytes: value.try_get("size_in_bytes")?,
vault_arn:... | code_fim | hard | {
"lang": "rust",
"repo": "hannes-hochreiner/backup-remote-rs",
"path": "/src/aws/aws_vault.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let land = parse::parse(include_str!("../data/input"));
assert_eq!(part_two::process(&land), 5522401584);
}<|fim_prefix|>// repo: FreeCX/advent-of-code path: /2020/day03/src/tests.rs
use crate::parse;
use crate::part_one;
use crate::part_two;
#[test]
fn part_one() {
<|fim_middle|> let land = ... | code_fim | medium | {
"lang": "rust",
"repo": "FreeCX/advent-of-code",
"path": "/2020/day03/src/tests.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FreeCX/advent-of-code path: /2020/day03/src/tests.rs
use crate::parse;
use crate::part_one;
use crate::part_two;
<|fim_suffix|>#[test]
fn part_two() {
let land = parse::parse(include_str!("../data/input"));
assert_eq!(part_two::process(&land), 5522401584);
}<|fim_middle|>#[test]
fn part... | code_fim | medium | {
"lang": "rust",
"repo": "FreeCX/advent-of-code",
"path": "/2020/day03/src/tests.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: james9909/revm path: /vmtests/tests/test_log.rs
#![allow(non_snake_case)]
#[macro_use]
extern crate lazy_static;
extern crate serde_json;
extern crate vmtests;
use serde_json::Value;
use std::collections::HashMap;
use vmtests::{load_tests, run_test};
lazy_static! {
static ref TESTS: HashM... | code_fim | hard | {
"lang": "rust",
"repo": "james9909/revm",
"path": "/vmtests/tests/test_log.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(run_test(&TESTS["log2_nonEmptyMem_logMemSize1"]));
}
#[test]
fn test_log2_nonEmptyMem_logMemSize1_logMemStart31() {
assert!(run_test(
&TESTS["log2_nonEmptyMem_logMemSize1_logMemStart31"]
));
}
#[test]
fn test_log3_Caller() {
assert!(run_test(&TESTS["log3_Caller"]));
}
#[tes... | code_fim | hard | {
"lang": "rust",
"repo": "james9909/revm",
"path": "/vmtests/tests/test_log.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(run_test(&TESTS["log4_logMemsizeZero"]));
}
#[test]
fn test_log4_nonEmptyMem() {
assert!(run_test(&TESTS["log4_nonEmptyMem"]));
}
#[test]
fn test_log4_nonEmptyMem_logMemSize1() {
assert!(run_test(&TESTS["log4_nonEmptyMem_logMemSize1"]));
}
#[test]
fn test_log4_nonEmptyMem_logMemSize1_l... | code_fim | hard | {
"lang": "rust",
"repo": "james9909/revm",
"path": "/vmtests/tests/test_log.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: palfrey/milli path: /milli/src/search/facet/mod.rs
pub use self::facet_distribution::FacetDistribution;
pub use self::facet_number::{FacetNumberIter, FacetNumberRange, FacetNumberRevRange};
pub use self::facet_string::FacetStringIter;
pub use se<|fim_suffix|>e;
mod facet_distribution;
mod facet... | code_fim | medium | {
"lang": "rust",
"repo": "palfrey/milli",
"path": "/milli/src/search/facet/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e;
mod facet_distribution;
mod facet_number;
mod facet_string;
mod filter_condition;
mod parser;<|fim_prefix|>// repo: palfrey/milli path: /milli/src/search/facet/mod.rs
pub use self::facet_distribution::FacetDistribution;
pub use self::facet_number::{FacetNumberIter, FacetNumberRange, FacetNumberRevRan... | code_fim | medium | {
"lang": "rust",
"repo": "palfrey/milli",
"path": "/milli/src/search/facet/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Sets source for a shader version.
pub fn set(&mut self, version: V, source: &'a S) -> &mut Self {
self.0.insert(version, source);
self
}
/// Get the closest shader to a shader version.
pub fn get(&self, version: V) -> Option<&S> {
version.pick_shader(self)
... | code_fim | medium | {
"lang": "rust",
"repo": "PistonDevelopers/shader_version",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PistonDevelopers/shader_version path: /src/lib.rs
#![deny(missing_docs)]
#![deny(missing_copy_implementations)]
//! A helper library for detecting and picking compatible shaders.
<|fim_suffix|>/// Shader picker.
pub struct Shaders<'a, V, S: 'a + ?Sized>(BTreeMap<V, &'a S>);
impl<'a, V, S: ?Si... | code_fim | medium | {
"lang": "rust",
"repo": "PistonDevelopers/shader_version",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nemo157/cbor-diag-rs path: /src/syntax.rs
mod tags;
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
/// How many additional bytes are used to encode this integer (in bits).
///
/// See [RFC 7049 § 2][RFC 2].
///
/// [RFC 2]: https://tools.ietf.org/html/rfc7049#section-2
pub enum IntegerWidth {
... | code_fim | hard | {
"lang": "rust",
"repo": "Nemo157/cbor-diag-rs",
"path": "/src/syntax.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// A series of [`TextString`] chunks encoded as an indefinite length text
/// string.
///
/// See [RFC 7049 § 2.2.2][RFC 2.2.2].
///
/// [RFC 2.2.2]: https://tools.ietf.org/html/rfc7049#section-2.2.2
IndefiniteTextString(Vec<TextString>),
/// An array of data items.
/... | code_fim | hard | {
"lang": "rust",
"repo": "Nemo157/cbor-diag-rs",
"path": "/src/syntax.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The bitwidth used for encoding this integer.
bitwidth: IntegerWidth,
},
/// A string of raw bytes with no direct attached meaning.
///
/// See the docs for [`ByteString`] for more details.
ByteString(ByteString),
/// A UTF-8 encoded text string.
///
//... | code_fim | hard | {
"lang": "rust",
"repo": "Nemo157/cbor-diag-rs",
"path": "/src/syntax.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tiannian/net-hal-tokio path: /src/lib.rs
use addr_hal::SocketAddressV4;
use addr_hal::SocketAddressV6;
use addr_hal::Ipv4Address;
use std::net::SocketAddrV4;
use std::net::Ipv4Addr;
<|fim_suffix|> }
fn set_ip(&mut self, ip: Ipv4Addr<Self::IpAddress>) {
}
fn port(&self) -> u16... | code_fim | hard | {
"lang": "rust",
"repo": "tiannian/net-hal-tokio",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct SocketV4Inner {
inner: SocketAddrV4,
}
impl SocketAddressV4 for SocketV4Inner {
type IpAddress = IpAddressV4Inner;
fn new(ip: addr_hal::Ipv4Addr<Self::IpAddress>, port: u16) -> Self {
let oct = ip.octets();
let std_ipv4 = Ipv4Addr::new(oct[0], oct[1], oct[2], oct[3... | code_fim | medium | {
"lang": "rust",
"repo": "tiannian/net-hal-tokio",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
}
fn set_ip(&mut self, ip: Ipv4Addr<Self::IpAddress>) {
}
fn port(&self) -> u16 {
}
fn set_port(&mut self, port: u16) {
}
}<|fim_prefix|>// repo: tiannian/net-hal-tokio path: /src/lib.rs
use addr_hal::SocketAddressV4;
use addr_hal::SocketAddressV6;
use addr_hal::Ipv4Add... | code_fim | hard | {
"lang": "rust",
"repo": "tiannian/net-hal-tokio",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: machunter/mongo-rust-driver-prototype path: /src/libmongo/test/add_user.rs
/* Copyright 2013 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:... | code_fim | medium | {
"lang": "rust",
"repo": "machunter/mongo-rust-driver-prototype",
"path": "/src/libmongo/test/add_user.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_add_user() {
let client = @Client::new();
match client.connect(~"127.0.0.1", MONGO_DEFAULT_PORT) {
Ok(_) => (),
Err(e) => fail!("%s", e.to_str())
}
// drop users first
let db = DB::new(~"rust_add_user", client);
let coll = db.get_collection(~"system... | code_fim | medium | {
"lang": "rust",
"repo": "machunter/mongo-rust-driver-prototype",
"path": "/src/libmongo/test/add_user.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // drop users first
let db = DB::new(~"rust_add_user", client);
let coll = db.get_collection(~"system.users");
coll.remove(None, None, None, None);
match db.add_user(~"testuser", ~"testpassword", ~[]) {
Ok(_) => (),
Err(e) => fail!("%s", e.to_str())
};
let mut ... | code_fim | medium | {
"lang": "rust",
"repo": "machunter/mongo-rust-driver-prototype",
"path": "/src/libmongo/test/add_user.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!("session closed!");
let _ = handle.close2().await;
// let (h1, h2) = handle.split();
// match async_std::io::copy(h1, h2).await {
// Ok(n) => {
// error!("io-copy exited @len={}", n);
... | code_fim | hard | {
"lang": "rust",
"repo": "NDNLink/NDNProtocol",
"path": "/libp2p/protocols/secio/examples/secio_simple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn server() {
let key = Keypair::generate_secp256k1();
let config = Config::new(key);
task::block_on(async move {
let listener = async_std::net::TcpListener::bind("127.0.0.1:1337").await.unwrap();
while let Ok((socket, _)) = listener.accept().await {
let config = ... | code_fim | hard | {
"lang": "rust",
"repo": "NDNLink/NDNProtocol",
"path": "/libp2p/protocols/secio/examples/secio_simple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NDNLink/NDNProtocol path: /libp2p/protocols/secio/examples/secio_simple.rs
// Copyright 2020 Netwarps Ltd.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software withou... | code_fim | hard | {
"lang": "rust",
"repo": "NDNLink/NDNProtocol",
"path": "/libp2p/protocols/secio/examples/secio_simple.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fullstop000/abstreet path: /editor/src/common/mod.rs
mod agent;
mod associated;
mod navigate;
mod route_explorer;
mod route_viewer;
mod shortcuts;
mod speed;
mod time;
mod trip_explorer;
mod turn_cycler;
mod warp;
pub use self::agent::AgentTools;
pub use self::route_explorer::RouteExplorer;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "Fullstop000/abstreet",
"path": "/editor/src/common/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn draw_custom_osd(g: &mut GfxCtx, mut osd: Text) {
let keys = g.get_active_context_menu_keys();
if !keys.is_empty() {
osd.append(" Hotkeys: ".to_string(), None);
for (idx, key) in keys.into_iter().enumerate() {
if idx != 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "Fullstop000/abstreet",
"path": "/editor/src/common/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn draw_osd(g: &mut GfxCtx, ui: &UI, id: &Option<ID>) {
let map = &ui.primary.map;
let id_color = ui.cs.get_def("OSD ID color", Color::RED);
let name_color = ui.cs.get_def("OSD name color", Color::CYAN);
let mut osd = Text::new();
match id {
None... | code_fim | hard | {
"lang": "rust",
"repo": "Fullstop000/abstreet",
"path": "/editor/src/common/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ///////////////////////////////////////////////////////////
// ##### ##### ##### ##### ##### ##### #### ##### //
// # # # # # # # # # # //
// # ##### ##### # # # # # # ##### //
// # # # # ... | code_fim | hard | {
"lang": "rust",
"repo": "thealexhoar/ligeia",
"path": "/src/game/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thealexhoar/ligeia path: /src/game/core.rs
ndow),
_world: World::new(),
_master_deconstructor: MasterDeconstructor::new(),
_master_fabricator: MasterFabricator::new()
};
{
let mut t_h = texture_handler.borrow_mut();
let... | code_fim | hard | {
"lang": "rust",
"repo": "thealexhoar/ligeia",
"path": "/src/game/core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let dt = {
//borrow window inside a smaller scope, to drop the borrow at the end
let mut window = self._window.borrow_mut();
let shader_handler = self._shader_handler.borrow();
let shader = shader_handler.get_default().unwrap();
let text... | code_fim | hard | {
"lang": "rust",
"repo": "thealexhoar/ligeia",
"path": "/src/game/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JMurph2015/rs_ws281x path: /src/util/util.rs
use errors::*;
use bindings;
use bindings::{ws2811_t, ws2811_return_t};
fn ws2811_init(c_struct: *mut ws2811_t) -> Result<(), WS281xError> {
<|fim_suffix|> unsafe {
let ret = bindings::ws2811_render(c_struct);
if ret == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "JMurph2015/rs_ws281x",
"path": "/src/util/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
let ret = bindings::ws2811_wait(c_struct);
if ret == 0 {
Ok();
} else {
Err(ret as WS281xError);
}
}
}<|fim_prefix|>// repo: JMurph2015/rs_ws281x path: /src/util/util.rs
use errors::*;
use bindings;
use bindings::{ws2811_t, ws2811_r... | code_fim | hard | {
"lang": "rust",
"repo": "JMurph2015/rs_ws281x",
"path": "/src/util/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: natboehm/os_info path: /src/version.rs
use std::fmt::{self, Display, Formatter, Write};
/// Operating system version including version number and optional edition.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Version {
pub(crate) version: VersionType,
pub(cra... | code_fim | hard | {
"lang": "rust",
"repo": "natboehm/os_info",
"path": "/src/version.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref edition) = self.edition {
write!(f, "{}", edition)?;
}
write!(f, "{}", self.version)
}
}
impl Display for VersionType {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self {
VersionType::Unknown => f.write_char('?')... | code_fim | medium | {
"lang": "rust",
"repo": "natboehm/os_info",
"path": "/src/version.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns optional (can be absent) operation system edition.
pub fn edition(&self) -> &Option<String> {
&self.edition
}
}
impl Display for Version {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
if let Some(ref edition) = self.edition {
write!(f, "{}", ed... | code_fim | hard | {
"lang": "rust",
"repo": "natboehm/os_info",
"path": "/src/version.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: singulared/swayipc-rs path: /src/sync/common.rs
use crate::{ensure, Fallible, MAGIC};
use std::io::Read;
use std::os::unix::net::UnixStream;
pub(crate) fn receive_from_stream(stream: &mut UnixStream) -> Fallible<(u32, Vec<u8>)> {
let mut magic_data = [0_u8; 6];
stream.read_exact(&mut ma... | code_fim | hard | {
"lang": "rust",
"repo": "singulared/swayipc-rs",
"path": "/src/sync/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e_buf)?;
let message_type = u32::from_ne_bytes(message_type_buf);
let mut payload_data = vec![0_u8; payload_len as usize];
stream.read_exact(&mut payload_data[..])?;
Ok((message_type, payload_data))
}<|fim_prefix|>// repo: singulared/swayipc-rs path: /src/sync/common.rs
use crate::{ensure... | code_fim | hard | {
"lang": "rust",
"repo": "singulared/swayipc-rs",
"path": "/src/sync/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use schema::authors::dsl::*;
use diesel::pg::upsert::*;
let maybe_inserted = insert(&new_author.on_conflict_do_nothing())
.into(authors)
.get_result(conn)
.optional()?;
if let Some(author) = maybe_inserted {
return Ok(author);
}
authors.filter(nam... | code_fim | hard | {
"lang": "rust",
"repo": "boxtown/thanks",
"path": "/src/authors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> authors.filter(name.eq(any(names)))
.filter(email.eq(any(emails)))
.load(conn)
}
fn find_or_create(conn: &PgConnection, new_author: NewAuthor) -> QueryResult<Author> {
use schema::authors::dsl::*;
use diesel::pg::upsert::*;
let maybe_inserted = insert(&new_author.on_confl... | code_fim | medium | {
"lang": "rust",
"repo": "boxtown/thanks",
"path": "/src/authors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boxtown/thanks path: /src/authors.rs
use models::{Author, NewAuthor};
use diesel::*;
use diesel::pg::PgConnection;
pub fn load_or_create(conn: &PgConnection, author_name: &str, author_email: &str) -> Author {
let new_author = NewAuthor {
name: author_name,
email: author_ema... | code_fim | hard | {
"lang": "rust",
"repo": "boxtown/thanks",
"path": "/src/authors.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlterionX/minesweeper path: /src/opts.rs
use structopt::StructOpt;
#[derive(Debug)]
pub struct PresetDoesNotExist;
impl std::fmt::Display for PresetDoesNotExist {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Requested preset does not exist.")
... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/minesweeper",
"path": "/src/opts.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<PresetDoesNotExist> for ParseDefError {
fn from(e: PresetDoesNotExist) -> Self {
Self::Preset(e)
}
}
impl std::fmt::Display for ParseDefError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Int(e) => e.fmt(f),
... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/minesweeper",
"path": "/src/opts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Self::Preset(p) => {
write!(f, "Minesweeper preset {}", p)
}
Self::Descrip { width, height: Some(height), mines } => {
write!(f, "Minesweeper {}x{} with {} mines", width, height, mines)
}
Self:... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/minesweeper",
"path": "/src/opts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, AtatCmd)]
#[at_cmd(
"",
WriteSocketDataResponse,
value_sep = false,
cmd_prefix = "",
termination = "",
force_receive_state = true
)]
pub struct WriteSocketDataBinary<'a> {
// FIXME:
// #[at_arg(position = 0, len = EgressChunkSize::to_usize())]
#[at_arg(p... | code_fim | hard | {
"lang": "rust",
"repo": "BlackbirdHQ/ublox-cellular-rs",
"path": "/ublox-cellular/src/command/ip_transport_layer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BlackbirdHQ/ublox-cellular-rs path: /ublox-cellular/src/command/ip_transport_layer/mod.rs
//! ### 25 - Internet protocol transport layer Commands
//!
pub mod responses;
pub mod types;
pub mod urc;
use atat::atat_derive::AtatCmd;
use embedded_nal::IpAddr;
use responses::{
CreateSocketRespon... | code_fim | hard | {
"lang": "rust",
"repo": "BlackbirdHQ/ublox-cellular-rs",
"path": "/ublox-cellular/src/command/ip_transport_layer/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.