text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>pub fn get_data_as_ints(path: &str) -> Vec<i64> {
get_data(&path)
.iter()
.map(|s| s.parse::<i64>().unwrap())
.collect()
}<|fim_prefix|>// repo: emptyrivers/advent2019 path: /src/main.rs
use std::env;
// solutions
mod tyranny; // Day 1
mod opcodes; // Day 2
mod wires; // D... | code_fim | hard | {
"lang": "rust",
"repo": "emptyrivers/advent2019",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aurae-runtime/aurae path: /auraed/src/lib.rs
/* -------------------------------------------------------------------------- *\
* Apache 2.0 License Copyright © 2022-2023 The Aurae Authors *
* *
* ... | code_fim | hard | {
"lang": "rust",
"repo": "aurae-runtime/aurae",
"path": "/auraed/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Server::builder()
.tls_config(tls)
.with_context(|| "gRPC server failed to configure tls")?
} else {
Server::builder()
};
// Install eBPF probes in the host Aurae daemon
let (_bpf_handle, perf_events) = if context == ... | code_fim | hard | {
"lang": "rust",
"repo": "aurae-runtime/aurae",
"path": "/auraed/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/bitvec-sgx path: /sgx/bitvec-sgx-test/enclave/src/lib.rs
// Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * ... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/bitvec-sgx",
"path": "/sgx/bitvec-sgx-test/enclave/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Construct a string from &'static string
let mut hello_string = String::from(rust_raw_string);
// Iterate on word array
for c in word.iter() {
hello_string.push(*c as char);
}
// Rust style convertion
hello_string += String::from_utf8(word_vec).expect("Invalid UTF-8... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/bitvec-sgx",
"path": "/sgx/bitvec-sgx-test/enclave/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avranju/kube-rust path: /src/models/mod.rs
use self::io_k8s_kubernetes_pkg_apis_authorization_v1beta1_subject_access_review_spec::AuthorizationV1beta1SubjectAccessReviewSpec;
mod io_k8s_kubernetes_pkg_apis_authorization_v1beta1_subject_access_review_status;
pub use self::io_k8s_kubernetes_pkg_ap... | code_fim | hard | {
"lang": "rust",
"repo": "avranju/kube-rust",
"path": "/src/models/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>api_resource::MetaV1ApiResource;
mod io_k8s_apimachinery_pkg_apis_meta_v1_api_resource_list;
pub use self::io_k8s_apimachinery_pkg_apis_meta_v1_api_resource_list::MetaV1ApiResourceList;
mod io_k8s_apimachinery_pkg_apis_meta_v1_api_versions;
pub use self::io_k8s_apimachinery_pkg_apis_meta_v1_api_versions::... | code_fim | hard | {
"lang": "rust",
"repo": "avranju/kube-rust",
"path": "/src/models/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avranju/kube-rust path: /src/models/mod.rs
api_v1_config_map_volume_source;
pub use self::io_k8s_kubernetes_pkg_api_v1_config_map_volume_source::V1ConfigMapVolumeSource;
mod io_k8s_kubernetes_pkg_api_v1_container;
pub use self::io_k8s_kubernetes_pkg_api_v1_container::V1Container;
mod io_k8s_kube... | code_fim | hard | {
"lang": "rust",
"repo": "avranju/kube-rust",
"path": "/src/models/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: StephanBischoff-Digle/adventofcode path: /2020/day_06/day06_2/src/lib.rs
use std::collections::HashMap;
fn extract(group: &str) -> usize {
let participants: Vec<&str> = group.trim_end().split('\n').collect();
let mut hm = HashMap::new();
for p in participants.iter() {
for c... | code_fim | hard | {
"lang": "rust",
"repo": "StephanBischoff-Digle/adventofcode",
"path": "/2020/day_06/day06_2/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>a
a
a
a
b";
let expected = 6;
let result = solve(input);
assert_eq!(expected, result);
}<|fim_prefix|>// repo: StephanBischoff-Digle/adventofcode path: /2020/day_06/day06_2/src/lib.rs
use std::collections::HashMap;
fn extract(group: &str) -> usize {
let participants: Vec<&str> = group.... | code_fim | medium | {
"lang": "rust",
"repo": "StephanBischoff-Digle/adventofcode",
"path": "/2020/day_06/day06_2/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ab
ac
a
a
a
a
b";
let expected = 6;
let result = solve(input);
assert_eq!(expected, result);
}<|fim_prefix|>// repo: StephanBischoff-Digle/adventofcode path: /2020/day_06/day06_2/src/lib.rs
use std::collections::HashMap;
fn extract(group: &str) -> usize {
let participants: Vec<&str> =... | code_fim | hard | {
"lang": "rust",
"repo": "StephanBischoff-Digle/adventofcode",
"path": "/2020/day_06/day06_2/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Debug for Frac {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match (self.num, self.den) {
(_, 1) | (0, 0) => write!(f, "{}", self.num),
(_, _) => write!(f, "{}/{}", self.num, self.den),
}
}
}
impl PartialEq for Frac {
fn eq(&self, o... | code_fim | hard | {
"lang": "rust",
"repo": "rust-rosetta/rust-rosetta",
"path": "/tasks/arithmetic/rational/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-rosetta/rust-rosetta path: /tasks/arithmetic/rational/src/main.rs
extern crate num;
use std::cmp::Ordering;
use std::fmt;
use std::ops::{Add, Div, Mul, Neg, Sub};
use num::{One, Zero};
fn main() {
for p in perfect_numbers(1 << 19) {
println!("{} is perfect", p);
}
}
fn p... | code_fim | hard | {
"lang": "rust",
"repo": "rust-rosetta/rust-rosetta",
"path": "/tasks/arithmetic/rational/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let size = 2.0;
EffectModule::req(
module_accessor,
Hash40::new("sys_smash_flash_s"),
&pos,
&rotation,
size,
0,
0,
true,
*EFFECT_SUB_ATTRIBUTE_CONCLUDE_STATUS,
);
}<|fim_prefix|>// repo: tawawy/UltimateTrainingModpack pa... | code_fim | hard | {
"lang": "rust",
"repo": "tawawy/UltimateTrainingModpack",
"path": "/src/training/fast_fall.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Can't fastfall in hitstun // tumble // meteor
if is_in_hitstun(module_accessor) {
return;
}
// Already in fast fall, nothing to do
if WorkModule::is_flag(module_accessor, *FIGHTER_STATUS_WORK_ID_FLAG_RESERVE_DIVE) {
return;
}
// Check delay
if frame_cou... | code_fim | hard | {
"lang": "rust",
"repo": "tawawy/UltimateTrainingModpack",
"path": "/src/training/fast_fall.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tawawy/UltimateTrainingModpack path: /src/training/fast_fall.rs
use crate::common::consts::OnOff;
use crate::common::*;
use crate::training::frame_counter;
use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*;
use smash::phx::{Hash40, Vector3f};
static mut FRAME_COUNTER: usize = 0;... | code_fim | hard | {
"lang": "rust",
"repo": "tawawy/UltimateTrainingModpack",
"path": "/src/training/fast_fall.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atouchet/indicatif path: /src/style.rs
t self, s: &str) -> ProgressStyle {
self.progress_chars = segment(s);
// Format bar will panic with some potentially confusing message, better to panic here
// with a message explicitly informing of the problem
assert!(
... | code_fim | hard | {
"lang": "rust",
"repo": "atouchet/indicatif",
"path": "/src/style.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atouchet/indicatif path: /src/style.rs
"msg" => buf.push_str(&self.message),
"prefix" => buf.push_str(&self.prefix),
"pos" => buf.write_fmt(format_args!("{}", state.pos)).unwrap(),
"human_pos" => buf
... | code_fim | hard | {
"lang": "rust",
"repo": "atouchet/indicatif",
"path": "/src/style.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn format_state(
&self,
state: &ProgressState,
lines: &mut Vec<String>,
target_width: u16,
) {
let mut cur = String::new();
let mut buf = String::new();
let mut wide = None;
for part in &self.template.parts {
ma... | code_fim | hard | {
"lang": "rust",
"repo": "atouchet/indicatif",
"path": "/src/style.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RGafiyatullin/tfsi path: /src/macros.rs
/// An utility macro to construct a compound `Require`.
#[macro_export]
macro_rules! Require {
[ $lt_p: lifetime, $lt_d: lifetime ] => { $crate::requirements::RequireNil, };
[ $lt_p: lifetime,<|fim_suffix|>rePair<
$crate::requirements::... | code_fim | hard | {
"lang": "rust",
"repo": "RGafiyatullin/tfsi",
"path": "/src/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rePair<
$crate::requirements::RequireOne<$lt_p, $lt_d, $head>,
$crate::Require![ $lt_p, $lt_d, $($tail), *]
> };
[ $lt_p: lifetime, $lt_d: lifetime, $head: ty, $($tail: ty), *, ] => {
$crate::requirements::RequirePair<
$crate::requirements::RequireOn... | code_fim | hard | {
"lang": "rust",
"repo": "RGafiyatullin/tfsi",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ail: ty), *, ] => {
$crate::requirements::RequirePair<
$crate::requirements::RequireOne<$lt_p, $lt_d, $head>,
$crate::Require![ $lt_p, $lt_d, $($tail), *]
> };
}<|fim_prefix|>// repo: RGafiyatullin/tfsi path: /src/macros.rs
/// An utility macro to construct a compo... | code_fim | medium | {
"lang": "rust",
"repo": "RGafiyatullin/tfsi",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/LocustDB path: /src/engine/operators/comparison_operators.rs
use super::binary_operator::*;
use num::PrimInt;
use crate::engine::data_types::GenericIntVec;
pub struct LessThan;
pub struct LessThanEquals;
pub struct NotEquals;
pub struct Equals;
impl<T, U, V> BinaryOp<T, U, u... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/LocustDB",
"path": "/src/engine/operators/comparison_operators.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl Widen<u16> for u32 {
type Join = u32;
fn widen(self, u: u16) -> (u32, u32) { (self, u as u32) }
}
impl Widen<i64> for u32 {
type Join = i64;
fn widen(self, u: i64) -> (i64, i64) { (self as i64, u) }
}
impl Widen<u8> for i64 {
type Join = i64;
fn widen(self, u: u8) -> (i64... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/LocustDB",
"path": "/src/engine/operators/comparison_operators.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl Widen<u8> for u16 {
type Join = u16;
fn widen(self, u: u8) -> (u16, u16) { (self, u as u16) }
}
impl Widen<u32> for u16 {
type Join = u32;
fn widen(self, u: u32) -> (u32, u32) { (self as u32, u) }
}
impl Widen<i64> for u16 {
type Join = i64;
fn widen(self, u: i64) -> (i64... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/LocustDB",
"path": "/src/engine/operators/comparison_operators.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>TRLB = crate::Reg<u32, _FCTRLB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _FCTRLB;
#[doc = "`read()` method returns [fctrlb::R](fctrlb::R) reader structure"]
impl crate::Readable for FCTRLB {}
#[doc = "`write(|w| ..)` method takes [fctrlb::W](fctrlb::W) writer structure"]
impl crate::Writable for ... | code_fim | hard | {
"lang": "rust",
"repo": "sordfish/atsamc",
"path": "/pac/atsamc21n18a/src/tcc0.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sordfish/atsamc path: /pac/atsamc21n18a/src/tcc0.rs
&mut *(((self as *const Self) as *mut u8).add(112usize) as *mut [CCBUF_DITH5_MODE; 4])
}
}
#[doc = "0x70 - Compare and Capture Buffer"]
#[inline(always)]
pub fn ccbuf_dith4_mode(&self) -> &[CCBUF_DITH4_MODE; 4]... | code_fim | hard | {
"lang": "rust",
"repo": "sordfish/atsamc",
"path": "/pac/atsamc21n18a/src/tcc0.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>d`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available... | code_fim | hard | {
"lang": "rust",
"repo": "sordfish/atsamc",
"path": "/pac/atsamc21n18a/src/tcc0.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trembel/ambiq-apollo3p-pac path: /src/ctimer/cmpra4.rs
#[doc = "Reader of register CMPRA4"]
pub type R = crate::R<u32, super::CMPRA4>;
#[doc = "Writer for register CMPRA4"]
pub type W = crate::W<u32, super::CMPRA4>;
#[doc = "Register CMPRA4 `reset()`'s with value 0"]
impl crate::ResetValue for s... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/ctimer/cmpra4.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub unsafe fn bits(self, value: u16) -> &'a mut W {
self.w.bits = (self.w.bits & !0xffff) | ((value as u32) & 0xffff);
self.w
}
}
impl R {
#[doc = "Bits 16:31 - Counter/Timer A4 Compare Register 1. Holds the upper limit for timer half A."]
#[inline(always)]
pub fn cmpr1a4... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/ctimer/cmpra4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn cmpr0a4(&self) -> CMPR0A4_R {
CMPR0A4_R::new((self.bits & 0xffff) as u16)
}
}
impl W {
#[doc = "Bits 16:31 - Counter/Timer A4 Compare Register 1. Holds the upper limit for timer half A."]
#[inline(always)]
pub fn cmpr1a4(&mut self) -> CMPR1A4_W {
CMPR1A4_W { w: sel... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/ctimer/cmpra4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Error parsing an include directive
#[error("parse error: {file:?} ({line:?})")]
ParseError { file: String, line: usize },
}<|fim_prefix|>// repo: h3r2tic/shader-prepper path: /src/error.rs
pub type BoxedIncludeProviderError = Box<dyn std::error::Error + Send + Sync + 'static>;
#[derive(D... | code_fim | medium | {
"lang": "rust",
"repo": "h3r2tic/shader-prepper",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// File which included the recursively included one
from: String,
/// Line in the `from` file on which the include happened
from_line: usize,
},
/// Error parsing an include directive
#[error("parse error: {file:?} ({line:?})")]
ParseError { file: String,... | code_fim | hard | {
"lang": "rust",
"repo": "h3r2tic/shader-prepper",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: h3r2tic/shader-prepper path: /src/error.rs
pub type BoxedIncludeProviderError = Box<dyn std::error::Error + Send + Sync + 'static>;
#[derive(Debug, thiserror::Error)]
pub enum PrepperError {
/// Any error reported by the user-supplied `IncludeProvider`
#[error("include provider error: \... | code_fim | hard | {
"lang": "rust",
"repo": "h3r2tic/shader-prepper",
"path": "/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn vmaxpd_21() {
run_test(&Instruction { mnemonic: Mnemonic::VMAXPD, operand1: Some(Direct(ZMM6)), operand2: Some(Direct(ZMM6)), operand3: Some(Direct(ZMM3)), operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: true, mask: Some(MaskReg::K4), broadcast: None }, &[9... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/vmaxpd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/vmaxpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn vmaxpd_1() {
run_test(&I... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/vmaxpd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michalhonc/dot-files path: /config/.vim/.cache/.vimrc/.dein/crates/maple_cli/src/paths.rs
use std::convert::TryFrom;
use std::path::{Display, Path, PathBuf};
/// Unit type wrapper of [`PathBuf`] that is absolute path.
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct AbsP... | code_fim | hard | {
"lang": "rust",
"repo": "michalhonc/dot-files",
"path": "/config/.vim/.cache/.vimrc/.dein/crates/maple_cli/src/paths.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::fmt::Display for AbsPathBuf {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0.display())
}
}<|fim_prefix|>// repo: michalhonc/dot-files path: /config/.vim/.cache/.vimrc/.dein/crates/maple_cli/src/paths.rs
use std::convert::TryFrom;
use... | code_fim | hard | {
"lang": "rust",
"repo": "michalhonc/dot-files",
"path": "/config/.vim/.cache/.vimrc/.dein/crates/maple_cli/src/paths.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TryFrom<&str> for AbsPathBuf {
type Error = PathBuf;
fn try_from(path: &str) -> Result<AbsPathBuf, PathBuf> {
Self::try_from(PathBuf::from(path))
}
}
impl std::ops::Deref for AbsPathBuf {
type Target = PathBuf;
fn deref(&self) -> &PathBuf {
&self.0
}
}
impl A... | code_fim | hard | {
"lang": "rust",
"repo": "michalhonc/dot-files",
"path": "/config/.vim/.cache/.vimrc/.dein/crates/maple_cli/src/paths.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(unused)]
pub fn selected_layer(&self) -> Option<&Layer> {
self.selected_layer_id
.and_then(|layer_id| self.get(layer_id))
}
fn next_layer_id(&self) -> rgis_layer_id::LayerId {
rgis_layer_id::LayerId::new()
}
fn add(
&mut self,
u... | code_fim | hard | {
"lang": "rust",
"repo": "frewsxcv/rgis",
"path": "/rgis-layers/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn clear_projected(&mut self) {
for layer in self.data.iter_mut() {
layer.projected_feature_collection = None;
}
}
pub fn iter(&self) -> impl Iterator<Item = &Layer> {
self.data.iter()
}
}
pub type Metadata = serde_json::Map<String, serde_json::Val... | code_fim | hard | {
"lang": "rust",
"repo": "frewsxcv/rgis",
"path": "/rgis-layers/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frewsxcv/rgis path: /rgis-layers/src/lib.rs
#![warn(
clippy::unwrap_used,
clippy::cast_lossless,
clippy::unimplemented,
clippy::indexing_slicing,
clippy::expect_used
)]
use bevy::prelude::*;
use geo::contains::Contains;
use std::sync;
mod systems;
#[derive(Copy, Clone, Deb... | code_fim | hard | {
"lang": "rust",
"repo": "frewsxcv/rgis",
"path": "/rgis-layers/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nalane/hw3 path: /src/knn.rs
use std::cmp::Ordering;
use std::collections::HashMap;
use crate::dataset::Dataset;
// Perform knn classification given a dataset and a test point
pub fn k_nearest_neighbors<'a>(dataset: &'a Dataset, x: &[f64], k: usize) -> Option<&'a str> {
// Get the distance... | code_fim | hard | {
"lang": "rust",
"repo": "nalane/hw3",
"path": "/src/knn.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Count the labels in the region
let mut counts = HashMap::new();
for label in labels {
if let Some(c) = counts.get_mut(label) {
*c += 1;
}
else {
counts.insert(label, 1);
}
}
// Return the most frequent label
let (label, _)... | code_fim | hard | {
"lang": "rust",
"repo": "nalane/hw3",
"path": "/src/knn.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn check_a() {
assert_eq!(2, solve_a(&br#""""#[..]));
assert_eq!(2, solve_a(&br#""abc""#[..]));
assert_eq!(3, solve_a(&br#""aaa\"aaa""#[..]));
assert_eq!(5, solve_a(&br#""\x27""#[..]));
}
#[test]
fn ch... | code_fim | medium | {
"lang": "rust",
"repo": "voivoid/rust-adventofcode",
"path": "/src/year_2015/problem_08.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2, solve_a(&br#""""#[..]));
assert_eq!(2, solve_a(&br#""abc""#[..]));
assert_eq!(3, solve_a(&br#""aaa\"aaa""#[..]));
assert_eq!(5, solve_a(&br#""\x27""#[..]));
}
#[test]
fn check_b() {
assert_eq!(4, solve_b(&br#""""#[..]));
assert_eq!... | code_fim | hard | {
"lang": "rust",
"repo": "voivoid/rust-adventofcode",
"path": "/src/year_2015/problem_08.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: voivoid/rust-adventofcode path: /src/year_2015/problem_08.rs
fn count_str_memory_len(cs: &[u8]) -> usize {
fn count_str_memory_len_impl(cs: &[u8], acc: usize) -> usize {
match cs {
[] => acc,
[b'\\', c, rest @ ..] if *c == b'\\' || *c == b'"' => {
... | code_fim | medium | {
"lang": "rust",
"repo": "voivoid/rust-adventofcode",
"path": "/src/year_2015/problem_08.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Codevka/rurikawa path: /judger/src/tester/spj.rs
//! Special Judge (SPJ) is a pluggable extension to the current judger, backed by
//! a JavaScript script.
//!
//! Read more about SPJ in `/docs/dev-manual/special-judger.md`
use super::{
model::{JudgerPublicConfig, RawStep, TestCase},
Pr... | code_fim | hard | {
"lang": "rust",
"repo": "Codevka/rurikawa",
"path": "/judger/src/tester/spj.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> SpjFeatures {
global_init: false,
transform_exec: false,
case_init: false,
case: false,
}
}
}
impl SpjFeatures {
/// Whether `specialJudgeInit` is declated as a function.
pub fn global_init(&self) -> bool {
self.global_in... | code_fim | hard | {
"lang": "rust",
"repo": "Codevka/rurikawa",
"path": "/judger/src/tester/spj.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeandenis-k/rust-advent-of-code-2020 path: /15/src/main.rs
use std::collections::HashMap;
static PUZZLE_INPUT: [i32; 6] = [2, 0, 1, 9, 5, 19];
struct Recitation<'a> {
starting_numbers: &'a [i32],
count: i32,
spoken: HashMap<i32, i32>,
last_spoken: i32,
}
fn main() {
printl... | code_fim | hard | {
"lang": "rust",
"repo": "jeandenis-k/rust-advent-of-code-2020",
"path": "/15/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", solve_part1(&PUZZLE_INPUT));
println!("{}", solve_part2(&PUZZLE_INPUT));
}
fn solve_part1(input: &[i32]) -> i32 {
Recitation::new(input).nth(2019).unwrap()
}
fn solve_part2(input: &[i32]) -> i32 {
Recitation::new(input).nth(30000000 - 1).unwrap()
}
impl<'a> Recitation<'a>... | code_fim | hard | {
"lang": "rust",
"repo": "jeandenis-k/rust-advent-of-code-2020",
"path": "/15/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut lhs = self.inv();
lhs.auto_op_assign();
&lhs == self
}
}
/// An involution is an [`Automorphism`] that gives the same result when applied
/// twice.
pub trait Involution<Op: UnOpMarker>: Automorphism<Op> {
/// The main operation on an [`Involution`].
fn involut... | code_fim | hard | {
"lang": "rust",
"repo": "vihdzp/nmath",
"path": "/algebra/src/involution/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vihdzp/nmath path: /algebra/src/involution/mod.rs
mod endomorphism;
pub use endomorphism::*;
use crate::{UnOp, UnOpAssign, UnOpMarker, UnOpSet};
/// An [injective function](https://en.wikipedia.org/wiki/Injective_function)
/// is such that `op a = op b` implies `a = b`.
pub trait Injective<Op... | code_fim | hard | {
"lang": "rust",
"repo": "vihdzp/nmath",
"path": "/algebra/src/involution/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
ChannelMessage::FlipperCheck => write!(f, "FL OUT FlipperCheck"),
ChannelMessage::FlipperRefresh => write!(f, "FL OUT FlipperRefresh"),
ChannelMessage::FlipperOutOfDate => write!(f, "FL IN FlipperOutOfDate"),
ChannelMessage::FlipperCompl... | code_fim | medium | {
"lang": "rust",
"repo": "FreeMasen/robohome_switcher",
"path": "/crates/shared/src/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FreeMasen/robohome_switcher path: /crates/shared/src/message.rs
#[derive(Clone, Debug)]
pub enum ChannelMessage {
FlipperCheck,
FlipperRefresh,
FlipperOutOfDate,
FlipperComplete,
FlipperUpdated,
MqUpdateFlip,
Error(String),
Stop,
Tick,
}
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "FreeMasen/robohome_switcher",
"path": "/crates/shared/src/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ogoestcc/broker path: /src/controllers/users/create.rs
use std::sync::{Arc, Mutex};
use validator::Validate;
use actix_web::{error::Error as ActixError, post, web, HttpResponse};
use crate::{
config::Config,
grpc::database::DatabaseService,
middlewares::validation::Validator,
... | code_fim | hard | {
"lang": "rust",
"repo": "ogoestcc/broker",
"path": "/src/controllers/users/create.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(HttpResponse::Created().json(Response {
created: User::from(created),
token: jwt::encode(user_claims, auth.secret_key.as_bytes()).unwrap(),
}))
}<|fim_prefix|>// repo: ogoestcc/broker path: /src/controllers/users/create.rs
use std::sync::{Arc, Mutex};
use validator::Validate;
... | code_fim | hard | {
"lang": "rust",
"repo": "ogoestcc/broker",
"path": "/src/controllers/users/create.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let user_claims = Claims {
id: created.get_id() as u32,
email: created.get_email().into(),
active: created.get_active(),
exp: auth.get_token_exp(),
};
Ok(HttpResponse::Created().json(Response {
created: User::from(created),
token: jwt::encode(us... | code_fim | hard | {
"lang": "rust",
"repo": "ogoestcc/broker",
"path": "/src/controllers/users/create.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(0, Solution::length_of_longest_substring("".to_string()));
assert_eq!(1, Solution::length_of_longest_substring("a".to_string()));
assert_eq!(1, Solution::length_of_longest_substring("aa".to_string()));
assert_eq!(2, Solution::length_of_longest_substring("ab".to_string()));
assert_eq!(3, So... | code_fim | hard | {
"lang": "rust",
"repo": "mrvon/leetcode",
"path": "/0003/0003_longest_substring_without_repeating_characters.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrvon/leetcode path: /0003/0003_longest_substring_without_repeating_characters.rs
struct Solution;
impl Solution {
pub fn length_of_longest_substring(s: String) -> i32 {
use std::collections::HashMap;
let s: Vec<char> = s.chars().collect();
let mut unique: HashMap<ch... | code_fim | hard | {
"lang": "rust",
"repo": "mrvon/leetcode",
"path": "/0003/0003_longest_substring_without_repeating_characters.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pref_iter_0 = <BoxTrait<'_, u8_interface::Interface>>::LAYOUT;
let pref_iter_1 = <BoxTrait<'_, unit_interface::Interface>>::LAYOUT;
assert_eq!(check_layout_compatibility(pref_iter_0, pref_iter_0), Ok(()));
assert_ne!(check_layout_compatibility(pref_iter_0, pref_iter_1), Ok(()));
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable/tests/layout_tests/erased_types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(miri))]
#[test]
fn check_subsets() {
let pref_zero = <DynTrait<'_, RBox<()>, no_iterator_interface::Interface>>::LAYOUT;
let pref_iter_0 = <BoxTrait<'_, rstring_interface::Interface>>::LAYOUT;
let pref_iter_1 = <BoxTrait<'_, rstr_interface::Interface>>::LAYOUT;
let pref_iter_2 =... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable/tests/layout_tests/erased_types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rodrimati1992/abi_stable_crates path: /abi_stable/tests/layout_tests/erased_types.rs
#![allow(dead_code)]
use abi_stable::{
abi_stability::abi_checking::check_layout_compatibility, erased_types::IteratorItem,
std_types::*, DynTrait, StableAbi,
};
macro_rules! mod_iter_ty {
(
... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable/tests/layout_tests/erased_types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: orisano/shakyo-rs path: /1.6/4.18/generic_function.rs
fn main() {
fn takes_anything<T>(x: T) {
// ...
}
fn takes_two_of_the_same_things<T>(x: T, y: T) {
<|fim_suffix|> // ...
}
}<|fim_middle|> // ...
}
fn takew_two_thing<T, U>(x: T, y: U) {
| code_fim | medium | {
"lang": "rust",
"repo": "orisano/shakyo-rs",
"path": "/1.6/4.18/generic_function.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ...
}
}<|fim_prefix|>// repo: orisano/shakyo-rs path: /1.6/4.18/generic_function.rs
fn main() {
fn takes_anything<T>(x: T) {
// ...
}
fn takes_two_of_the_same_things<T>(x: T, y: T) {
<|fim_middle|> // ...
}
fn takew_two_thing<T, U>(x: T, y: U) {
| code_fim | medium | {
"lang": "rust",
"repo": "orisano/shakyo-rs",
"path": "/1.6/4.18/generic_function.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let left_score = digraphs.calculate_score(&sorted_left);
let right_score = digraphs.calculate_score(&sorted_right);
box_letters(Letters {
left: sorted_left,
right: sorted_right,
left_score,
right_score,
version,
... | code_fim | hard | {
"lang": "rust",
"repo": "sgaliamov/ergo-balance",
"path": "/src/bin/genetic_letters/calculation/letters.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgaliamov/ergo-balance path: /src/bin/genetic_letters/calculation/letters.rs
use ed_balance::{format_result, Digraphs, IIndividual, IMutation};
use std::hash::Hash;
pub type LettersPointer = Box<Letters>;
#[derive(Hash, Eq, PartialEq, Clone, Copy)]
pub struct Mutation {
pub left: char,
... | code_fim | hard | {
"lang": "rust",
"repo": "sgaliamov/ergo-balance",
"path": "/src/bin/genetic_letters/calculation/letters.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl FileExt for File {
fn fadvise(&self, offset: off_t, len: off_t, advice: Fadvice) -> io::Result<()> {
match unsafe { libc::posix_fadvise(self.as_raw_fd(), offset, len, advice as c_int) } {
0 => Ok(()),
errno => Err(io::Error::from_raw_os_error(errno))
}
... | code_fim | hard | {
"lang": "rust",
"repo": "idkjs/octopus",
"path": "/src-rs/src/file_ext.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> match unsafe { libc::flock(self.as_raw_fd(), flags.bits()) } {
0 => Ok(()),
_ => Err(io::Error::last_os_error())
}
}
}
#[cfg(test)]
mod test {
use super::*;
fn file() -> File {
let binary = std::env::args().nth(0).unwrap();
File::open(b... | code_fim | hard | {
"lang": "rust",
"repo": "idkjs/octopus",
"path": "/src-rs/src/file_ext.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: idkjs/octopus path: /src-rs/src/file_ext.rs
/*
* Copyright (C) 2020 Yury Vostrikov
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the abov... | code_fim | hard | {
"lang": "rust",
"repo": "idkjs/octopus",
"path": "/src-rs/src/file_ext.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DepthTestFunction {
#[allow(clippy::wrong_self_convention)] // TODO maybe this should be addressed properly.
pub(crate) fn to_gl(self) -> u32 {
use DepthTestFunction::*;
match self {
Never => glow::NEVER,
Less => glow::LESS,
Equal => glow::E... | code_fim | hard | {
"lang": "rust",
"repo": "ryanisaacg/golem",
"path": "/src/depth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryanisaacg/golem path: /src/depth.rs
//! Various options to specify the depth of view volume
//! and how pixels are determined to occlude each other
/// The state of depth test settings
///
/// Depth values (how far from the camera a pixel is) will be linearly mapped from `-1.0..1.0`
/// (norma... | code_fim | hard | {
"lang": "rust",
"repo": "ryanisaacg/golem",
"path": "/src/depth.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bobo1239/wana_kana_rust path: /src/utils/is_char_consonant.rs
/// Tests a character and an english consonant. Returns true if the char is a consonant.
///
/// @param {String} char
///
/<|fim_suffix|>ar: char, includey: bool) -> bool {
match char {
'b' | 'c' | 'd' | 'f' | 'g' | 'h' |... | code_fim | medium | {
"lang": "rust",
"repo": "Bobo1239/wana_kana_rust",
"path": "/src/utils/is_char_consonant.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> | 'p' | 'q' | 'r' | 's' | 't' | 'v' | 'w' | 'x' | 'z' => true,
'y' if includey => true,
_ => false,
}
}<|fim_prefix|>// repo: Bobo1239/wana_kana_rust path: /src/utils/is_char_consonant.rs
/// Tests a character and an english consonant. Returns true if the char is a consonant.
///
///... | code_fim | medium | {
"lang": "rust",
"repo": "Bobo1239/wana_kana_rust",
"path": "/src/utils/is_char_consonant.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ar: char, includey: bool) -> bool {
match char {
'b' | 'c' | 'd' | 'f' | 'g' | 'h' | 'j' | 'k' | 'l' | 'm' | 'n' | 'p' | 'q' | 'r' | 's' | 't' | 'v' | 'w' | 'x' | 'z' => true,
'y' if includey => true,
_ => false,
}
}<|fim_prefix|>// repo: Bobo1239/wana_kana_rust path: /src... | code_fim | medium | {
"lang": "rust",
"repo": "Bobo1239/wana_kana_rust",
"path": "/src/utils/is_char_consonant.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub enum RunAnalysis {}
impl Request for RunAnalysis {
type Params = RunAnalysisParams;
type Result = String;
const METHOD: &'static str = "asm/runAnalysis";
}<|fim_prefix|>// repo: SwapnilGaikwad/lsp-asm path: /crates/lsp/src/handler/ext.rs
use lsp_types::request::Request;
use lsp_types::Ra... | code_fim | hard | {
"lang": "rust",
"repo": "SwapnilGaikwad/lsp-asm",
"path": "/crates/lsp/src/handler/ext.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SwapnilGaikwad/lsp-asm path: /crates/lsp/src/handler/ext.rs
use lsp_types::request::Request;
use lsp_types::Range;
use lsp_types::TextDocumentIdentifier;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SyntaxTreeParams ... | code_fim | hard | {
"lang": "rust",
"repo": "SwapnilGaikwad/lsp-asm",
"path": "/crates/lsp/src/handler/ext.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Error for DatabaseError {}
impl fmt::Display for DatabaseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let printable = match *self {
DatabaseError::NotFound => "not found".to_owned(),
DatabaseError::InvalidData => "invalid data".to_owned(),
... | code_fim | hard | {
"lang": "rust",
"repo": "citahub/cita-database",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: citahub/cita-database path: /src/error.rs
use rocksdb::Error as RocksError;
use std::error::Error;
use std::fmt;
use std::io::Error as IOError;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DatabaseError {
NotFound,
InvalidData,
Internal(String),
}
<|fim_suffix|> DatabaseE... | code_fim | hard | {
"lang": "rust",
"repo": "citahub/cita-database",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>SPEC>;
#[doc = "FLASH Control 3"]
pub mod fctl3;
#[doc = "FCTL4 register accessor: an alias for `Reg<FCTL4_SPEC>`"]
pub type FCTL4 = crate::Reg<fctl4::FCTL4_SPEC>;
#[doc = "FLASH Control 4"]
pub mod fctl4;<|fim_prefix|>// repo: cr1901/msp430f5529 path: /src/flash.rs
#[doc = r"Register block"]
#[repr(C)]
... | code_fim | hard | {
"lang": "rust",
"repo": "cr1901/msp430f5529",
"path": "/src/flash.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cr1901/msp430f5529 path: /src/flash.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - FLASH Control 1"]
pub fctl1: crate::Reg<fctl1::FCTL1_SPEC>,
_reserved1: [u8; 0x02],
#[doc = "0x04 - FLASH C<|fim_suffix|>SPEC>;
#[doc = "FLASH Control 3"]
pub m... | code_fim | hard | {
"lang": "rust",
"repo": "cr1901/msp430f5529",
"path": "/src/flash.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.move_player();
self.move_sea_enemies();
self.move_land_enemies();
if self.board.fill_ratio > 0.8 {
self.delay = Delay::NextLevel(20);
}
Transition::None
}
fn render(&self, renderer: &mut Renderer) {
for (y, row) in self.bo... | code_fim | hard | {
"lang": "rust",
"repo": "czak/retronix.rs",
"path": "/src/game/states/play_state/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.delay = Delay::Death(20);
return Transition::None;
}
self.move_player();
self.move_sea_enemies();
self.move_land_enemies();
if self.board.fill_ratio > 0.8 {
self.delay = Delay::NextLevel(20);
}
Transition::... | code_fim | hard | {
"lang": "rust",
"repo": "czak/retronix.rs",
"path": "/src/game/states/play_state/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: czak/retronix.rs path: /src/game/states/play_state/mod.rs
mod models;
use rand::{thread_rng, Rng};
use game::{Event, State, Transition};
use renderer::{Renderer, Color};
use self::models::{Board, Field};
// TODO: Pass when constructing the state
const BOARD_WIDTH: usize = 80;
const BOARD_HEIGH... | code_fim | hard | {
"lang": "rust",
"repo": "czak/retronix.rs",
"path": "/src/game/states/play_state/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match sub.first() {
Some(&b'.') => {
let (prec, sub) = parse_width(next_char(sub));
(Some(prec), sub)
}
_ => (None, sub),
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
enum Length {
Int,
/// `hh`
Char,
/// `h`
Short,
/// `... | code_fim | hard | {
"lang": "rust",
"repo": "curvelogic/eucalypt",
"path": "/src/eval/stg/printf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: curvelogic/eucalypt path: /src/eval/stg/printf.rs
//! Printf style %-formats
//!
//! This is a stopgap to maintain enough compatibility with the
//! Haskell implementation to pass tests for now.
//!
//! Largely lifted from
//! https://docs.rs/printf-compat/0.1.1/src/printf_compat/parser.rs.html#... | code_fim | hard | {
"lang": "rust",
"repo": "curvelogic/eucalypt",
"path": "/src/eval/stg/printf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl IntoIterator for Fishes {
type Item = Fish;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
impl Fishes {
pub fn from_file(filename: &str) -> Result<Fishes, Box<dyn std::error::Error>> {
let fishes = s... | code_fim | medium | {
"lang": "rust",
"repo": "jj-marinho/fisherman-rust",
"path": "/src/fish.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Getting random number that is between 0 and sum_chances
let rng = rand::thread_rng().gen_range(0, sum_chances - 1);
// Given the rng result, returns Some(Fish)
let mut cur_chance = 0;
for fish in self.clone().into_iter() {
cur_chance += fish.chance;
... | code_fim | hard | {
"lang": "rust",
"repo": "jj-marinho/fisherman-rust",
"path": "/src/fish.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jj-marinho/fisherman-rust path: /src/fish.rs
use rand::Rng;
use serde::{Deserialize, Serialize};
use std::fs::{read, write};
#[derive(Serialize, Deserialize, Debug)]
pub struct Fish {
pub fish_name: String,
pub chance: u32,
pub xp_worth: u32,
pub gold_worth: u32,
}
#[derive(Seri... | code_fim | medium | {
"lang": "rust",
"repo": "jj-marinho/fisherman-rust",
"path": "/src/fish.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut watch_targets = config::WatchTargets::new();
let message = match matches.subcommand() {
("sync", Some(cmd)) => {
let directories = values_t!(cmd.values_of("DIRECTORIES"), String).unwrap_or(vec![]);
let dir_a = directories.get(0).unwrap();
let dir... | code_fim | hard | {
"lang": "rust",
"repo": "kogai/sync-dir",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kogai/sync-dir path: /src/main.rs
extern crate im;
#[macro_use]
extern crate log;
extern crate log4rs;
extern crate log4rs_syslog;
extern crate regex;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
#[macro_use]
extern crate clap;
extern crate libusb;
extern ... | code_fim | hard | {
"lang": "rust",
"repo": "kogai/sync-dir",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern "C" fn mul3(arg: u32) -> u32 { arg * 3 }
#[no_mangle]
pub extern "C" fn add5(arg: u32) -> u32 { arg + 5 }
#[test]
fn hi() {
println!("Hello World");
}
#[cfg(test)]
mod bench {
use extra::test::BenchHarness;
#[bench]
fn b(_bh: &mut BenchHarness) {
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "pnkfelix/rustc2c",
"path": "/smoke_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn hi() {
println!("Hello World");
}
#[cfg(test)]
mod bench {
use extra::test::BenchHarness;
#[bench]
fn b(_bh: &mut BenchHarness) {
let mut _x = 0;
_bh.iter(|| { _x += 1; });
_x += 1;
}
}<|fim_prefix|>// repo: pnkfelix/rustc2c path: /smoke_test.rs
us... | code_fim | hard | {
"lang": "rust",
"repo": "pnkfelix/rustc2c",
"path": "/smoke_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pnkfelix/rustc2c path: /smoke_test.rs
use std::libc::c_char;
use std::c_str::CString;
#[no_mangle]
pub extern "C" fn hello()
{
println!("Hello world from Rust");
}
#[no_mangle]
pub extern "C" fn callee(from: *c_char)
{
let from = unsafe { CString::new(from, false) };
println!("call... | code_fim | hard | {
"lang": "rust",
"repo": "pnkfelix/rustc2c",
"path": "/smoke_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[fail(display = "Error with message {:?}", msg)]
GeneralError { msg: String },
}<|fim_prefix|>// repo: lovesh/signature-schemes path: /ps/src/errors.rs
use failure::Error;
#[derive(Debug, Fail)]
pub enum PSError {
#[fail(
display = "Verkey has unequal number of Y and Y_tilde element... | code_fim | medium | {
"lang": "rust",
"repo": "lovesh/signature-schemes",
"path": "/ps/src/errors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lovesh/signature-schemes path: /ps/src/errors.rs
use failure::Error;
#[derive(Debug, Fail)]
pub enum PSError {
#[fail(
display = "Verkey has unequal number of Y and Y_tilde elements. Y={} and Y_tilde={}",
y, y_tilde
)]
InvalidVerkey { y: usize, y_tilde: usize },
<|f... | code_fim | hard | {
"lang": "rust",
"repo": "lovesh/signature-schemes",
"path": "/ps/src/errors.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ngtkana/aribook path: /crates/chap3_4/blocks/src/main.rs
use proconio::input;
const MODULUS: u32 = 10_007;
fn main() {
input!(n: u64);
fn pow(mut a: [[u32; 3]; 3], mut b: u64) -> [[u32; 3]; 3] {
let mut ans = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
while 0 != b {
... | code_fim | medium | {
"lang": "rust",
"repo": "ngtkana/aribook",
"path": "/crates/chap3_4/blocks/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn sample1() {
test_sample("1\n", "2\n");
}
#[test]
fn sample2() {
test_sample("2\n", "6\n");
}
}<|fim_prefix|>// repo: ngtkana/aribook path: /crates/chap3_4/blocks/src/main.rs
use proconio::input;
const MODULUS: u32 = 10_007;
fn main() {
input!(n: u... | code_fim | medium | {
"lang": "rust",
"repo": "ngtkana/aribook",
"path": "/crates/chap3_4/blocks/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = Value::Keyword(expected);
let result = read_as_keyword_id(value).unwrap();
nia_assert_equal(expected, result);
}
#[test]
fn returns_invalid_argument_when_not_a_symbol_value_were_passed() {
let mut interpreter = Interpreter::new();
let not... | code_fim | hard | {
"lang": "rust",
"repo": "emirayka/nia_interpreter_core",
"path": "/src/interpreter/library/read/read_as_keyword_id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emirayka/nia_interpreter_core path: /src/interpreter/library/read/read_as_keyword_id.rs
use crate::interpreter::error::Error;
use crate::interpreter::value::KeywordId;
use crate::interpreter::value::Value;
pub fn read_as_keyword_id(value: Value) -> Result<KeywordId, Error> {
let symbol_id =... | code_fim | hard | {
"lang": "rust",
"repo": "emirayka/nia_interpreter_core",
"path": "/src/interpreter/library/read/read_as_keyword_id.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.