text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let is_paused_int = control
.ctx
.b
.build_load(
&unsafe {
control
.ctx
.b
.build_struct_gep(&control.data_ptr, 2, "paused.int.ptr")
},
"paused.int",
).into_i... | code_fim | hard | {
"lang": "rust",
"repo": "AudioBucket/axiom",
"path": "/compiler/src/codegen/controls/graph_control.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f32::EPSILON
}
}
impl MachineEpsilon for f64 {
fn epsilon() -> f64 {
f64::EPSILON
}
}<|fim_prefix|>// repo: tafia/rulinalg path: /src/epsilon.rs
use libnum::Float;
use std::f32;
use std::f64;
/// Expose the machine epsilon of floating point numbers.
/// This trait should onl... | code_fim | medium | {
"lang": "rust",
"repo": "tafia/rulinalg",
"path": "/src/epsilon.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tafia/rulinalg path: /src/epsilon.rs
use libnum::Float;
use std::f32;
use std::f64;
/// Expose the machine epsilon of floating point numbers.
/// This trait should only need to exist for a short time,
/// until the Float trait from the Num crate has the same
/// capabilities.
pub trait MachineE... | code_fim | medium | {
"lang": "rust",
"repo": "tafia/rulinalg",
"path": "/src/epsilon.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> HttpResponse::build(self.status_code()).body(self.to_string())
}
}
impl From<ServingError> for std::io::Error {
fn from(e: ServingError) -> Self {
std::io::Error::new(std::io::ErrorKind::Other, e.to_string())
}
}<|fim_prefix|>// repo: massquantity/LibRecommender path: /libser... | code_fim | medium | {
"lang": "rust",
"repo": "massquantity/LibRecommender",
"path": "/libserving/actix_serving/src/utils/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: massquantity/LibRecommender path: /libserving/actix_serving/src/utils/errors.rs
use actix_web::http::StatusCode;
use actix_web::HttpResponse;
pub type ServingResult<T> = std::result::Result<T, ServingError>;
#[derive(thiserror::Error, Debug)]
pub enum ServingError {
#[error("error: failed ... | code_fim | hard | {
"lang": "rust",
"repo": "massquantity/LibRecommender",
"path": "/libserving/actix_serving/src/utils/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn error_response(&self) -> HttpResponse {
HttpResponse::build(self.status_code()).body(self.to_string())
}
}
impl From<ServingError> for std::io::Error {
fn from(e: ServingError) -> Self {
std::io::Error::new(std::io::ErrorKind::Other, e.to_string())
}
}<|fim_prefix|>// r... | code_fim | hard | {
"lang": "rust",
"repo": "massquantity/LibRecommender",
"path": "/libserving/actix_serving/src/utils/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fnl-Africa/neutron-qx86-hypervisor path: /src/lib.rs
extern crate struct_deser;
#[macro_use]
extern crate struct_deser_derive;
pub mod hypervisor;
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct NeutronAddress{
pub version: u32,
pub data: Vec<u8>
}
#[derive(Clone, Debug, E... | code_fim | hard | {
"lang": "rust",
"repo": "fnl-Africa/neutron-qx86-hypervisor",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// This is the primary NeutronAPI interface. It is loosely based on the C Neutron API, but uses Rust paradigms and features
/// This will require a heavier translation layer, but makes Rust usage significantly simpler
pub trait NeutronAPI{
fn get_context(&self) -> &NeutronContext;
fn push_sccs(... | code_fim | hard | {
"lang": "rust",
"repo": "fnl-Africa/neutron-qx86-hypervisor",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'i> FromPair<'i> for Line<TypedefClause> {
const RULE: Rule = Rule::TypedefClauseLine;
unsafe fn from_pair_unchecked(
pair: Pair<'i, Rule>,
cache: &Cache,
) -> Result<Self, SyntaxError> {
let mut inner = pair.into_inner();
let clause = TypedefClause::from_p... | code_fim | hard | {
"lang": "rust",
"repo": "fastobo/fastobo",
"path": "/src/ast/typedef/clause.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fastobo/fastobo path: /src/ast/typedef/clause.rs
use fastobo_derive_internal::FromStr;
use fastobo_derive_internal::OboClause;
use crate::ast::*;
use crate::error::SyntaxError;
use crate::parser::Cache;
use crate::parser::FromPair;
use crate::semantics::OboClause;
use crate::syntax::pest::itera... | code_fim | hard | {
"lang": "rust",
"repo": "fastobo/fastobo",
"path": "/src/ast/typedef/clause.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FauxFaux/gitgeoff path: /src/status.rs
use std::path::Path;
use anyhow::anyhow;
use anyhow::Context;
use anyhow::Error;
use rayon::iter::IntoParallelIterator;
use rayon::iter::ParallelIterator;
use super::config;
use super::git;
use super::infect;
use config::Spec;
#[derive(PartialEq, Eq, Clo... | code_fim | hard | {
"lang": "rust",
"repo": "FauxFaux/gitgeoff",
"path": "/src/status.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let variance = git::variance_from_origin_head(&repo)?;
let some_statuses = git::first_statuses(&repo)?;
Ok(
if !some_statuses.is_empty() || variance != git::Variance::Equal {
Status::Changes(some_statuses, variance)
} else {
Status::Clean
},
... | code_fim | hard | {
"lang": "rust",
"repo": "FauxFaux/gitgeoff",
"path": "/src/status.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn find_variance(repo: &git2::Repository) -> Result<Status, Error> {
let variance = git::variance_from_origin_head(&repo)?;
let some_statuses = git::first_statuses(&repo)?;
Ok(
if !some_statuses.is_empty() || variance != git::Variance::Equal {
Status::Changes(some_statuses,... | code_fim | hard | {
"lang": "rust",
"repo": "FauxFaux/gitgeoff",
"path": "/src/status.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub p: Vector3<f64>,
pub normal: Vector3<f64>,
pub material: &'a dyn Material,
}<|fim_prefix|>// repo: fbergen/rays path: /src/hitrecord.rs
use na::Vector3;
use material::Material;
pu<|fim_middle|>b struct HitRecord<'a>{
pub t: f64,
| code_fim | easy | {
"lang": "rust",
"repo": "fbergen/rays",
"path": "/src/hitrecord.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fbergen/rays path: /src/hitrecord.rs
use na::Vector3;
use material::Material;
pu<|fim_suffix|>pub p: Vector3<f64>,
pub normal: Vector3<f64>,
pub material: &'a dyn Material,
}<|fim_middle|>b struct HitRecord<'a>{
pub t: f64,
| code_fim | easy | {
"lang": "rust",
"repo": "fbergen/rays",
"path": "/src/hitrecord.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|><f64>,
pub material: &'a dyn Material,
}<|fim_prefix|>// repo: fbergen/rays path: /src/hitrecord.rs
use na::Vector3;
use material::Material;
pu<|fim_middle|>b struct HitRecord<'a>{
pub t: f64,
pub p: Vector3<f64>,
pub normal: Vector3 | code_fim | medium | {
"lang": "rust",
"repo": "fbergen/rays",
"path": "/src/hitrecord.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>]@ @hspacept(6)@ @reply[3]@ @hspacept(6)@ @reply[4]@
@vspace@
@/repeat@<|fim_prefix|>// repo: bradunov/shkola path: /questions/data_2/q00026/text.rs
Odredi tri broja u zadatom intervalu @"[a,b]"@ tako da je od svaka tri<|fim_middle|> uzastopna broja srednji aritmetička sredina krajnjih.
@repeat(2)@
@c... | code_fim | medium | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/data_2/q00026/text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bradunov/shkola path: /questions/data_2/q00026/text.rs
Odredi tri broja u zadatom intervalu @"[a,b]"@ tako da je od svaka tri<|fim_suffix|>ter@ a = @reply[1]@ @hspacept(140)@ @"b"@ = @reply[5]@
@center@ @reply[2]@ @hspacept(6)@ @reply[3]@ @hspacept(6)@ @reply[4]@
@vspace@
@/repeat@<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/data_2/q00026/text.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tagged_response = ImapResponse::Response(TaggedResponse {
tag: Tag::new('a', 17),
resp: RespCond {
status: ImapResult::Ok,
text: resp_text("CAPABILITY completed"),
},
});
assert_eq(result, tagged_response);
}
#[test]
fn parse_continue_req()... | code_fim | hard | {
"lang": "rust",
"repo": "filtsin/rimap",
"path": "/src/parser/tests/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filtsin/rimap path: /src/parser/tests/mod.rs
use crate::{
parser::{
parse,
types::{
ContinueReq, Greeting, GreetingStatus, ImapResponse, ImapResult, RespCond, RespText,
TaggedResponse,
},
},
tag::Tag,
};
fn resp_text(s: &str) -> RespTe... | code_fim | hard | {
"lang": "rust",
"repo": "filtsin/rimap",
"path": "/src/parser/tests/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>x01) != 0)
}
#[doc = "Bit 5 - EMITRANGE"]
#[inline(always)]
pub fn emitrange(&self) -> EMITRANGE_R {
EMITRANGE_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bits 0:3 - FUNCTION"]
#[inline(always)]
pub fn function(&self) -> FUNCTION_R {
FUNCTION_R::new((s... | code_fim | hard | {
"lang": "rust",
"repo": "DanielMena399/cc1312take3",
"path": "/cc1312/src/cpu_dwt/function3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DanielMena399/cc1312take3 path: /cc1312/src/cpu_dwt/function3.rs
#[doc = "Reader of register FUNCTION3"]
pub type R = crate::R<u32, super::FUNCTION3>;
#[doc = "Writer for register FUNCTION3"]
pub type W = crate::W<u32, super::FUNCTION3>;
#[doc = "Register FUNCTION3 `reset()`'s with value 0"]
imp... | code_fim | hard | {
"lang": "rust",
"repo": "DanielMena399/cc1312take3",
"path": "/cc1312/src/cpu_dwt/function3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Orca-bit/DataStructureAndAlgorithm path: /src/other/_643_maximum_average_subarray_1.rs
struct Solution;
impl Solution {
pub fn find_max_average(nums: Vec<i32>, k: i32) -> f64 {
let mut sum = nums[0..k as usize].iter().sum::<i32>();
let mut res = sum;
for i in k as us... | code_fim | medium | {
"lang": "rust",
"repo": "Orca-bit/DataStructureAndAlgorithm",
"path": "/src/other/_643_maximum_average_subarray_1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nums = vec![1, 12, -5, -6, 50, 3];
let k = 4;
assert_eq!(Solution::find_max_average(nums, k), 12.75);
}<|fim_prefix|>// repo: Orca-bit/DataStructureAndAlgorithm path: /src/other/_643_maximum_average_subarray_1.rs
struct Solution;
impl Solution {
pub fn find_max_average(nums: Vec<i32>... | code_fim | medium | {
"lang": "rust",
"repo": "Orca-bit/DataStructureAndAlgorithm",
"path": "/src/other/_643_maximum_average_subarray_1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jiyilanzhou/chw path: /web/rust_web/src/main.rs
/*
0. 读取配置文件
# 引入依赖
1. config 依赖(" https://crates.io/crates/config ")
[dependencies]
config = "0.10.1" # 可用于加载环境配置
*/
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
extern crate dotenv;
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "jiyilanzhou/chw",
"path": "/web/rust_web/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 调用 handler 下的 get_list
.route("/todos{_:/?}",web::get().to(query_lists))
.route("/todos/{list_id}/items",web::get().to(query_items))
// 插入数据
.route("/todos{_:/?}",web::post().to(create_list))
.route("/todos/{list_id}/items/{item_id... | code_fim | hard | {
"lang": "rust",
"repo": "jiyilanzhou/chw",
"path": "/web/rust_web/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pomettini/impostor path: /src/tests.rs
use {Address, AddressBusIO, Data};
struct TestAddressBusIO<T: Address, U: Data> {
_address: T,
_data: U,
}
impl<T: Address, U: Data> Default for TestAddressBusIO<T, U> {
fn default() -> TestAddressBusIO<T, U> {
TestAddressBusIO {
... | code_fim | hard | {
"lang": "rust",
"repo": "Pomettini/impostor",
"path": "/src/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bus: TestAddressBusIO<u16, u32> = TestAddressBusIO::default();
bus.write(0xffff, 0xaabbccdd);
assert_eq!(bus.read(0xabcd), 0);
}
#[test]
fn address_bus_io_u64_u32() {
let mut bus: TestAddressBusIO<u64, u32> = TestAddressBusIO::default();
bus.write(0xffffffffaabbccdd, 0xaabbccd... | code_fim | hard | {
"lang": "rust",
"repo": "Pomettini/impostor",
"path": "/src/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub fn compress_next_token<'a, F: Fn(u8) -> bool>(
s: &mut ByteSection<'a>,
compressed_whitespace: F,
) -> TokenizeResult<Token<'a>> {
// TODO use this?
// Should I mark the start of a token?
// let recovery_point = s.n;
let start = s.n... | code_fim | hard | {
"lang": "rust",
"repo": "norcalli/kjson-parser",
"path": "/src/tokenizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (input, err) in vec![
("1ea", invalid_input_err(Some(&'a'))),
("1Ea", invalid_input_err(Some(&'a'))),
// TODO hmmm
// ("01", invalid_input_err(Some(&'1'))),
("0.", invalid_input_err(None)), // TODO should I mak... | code_fim | hard | {
"lang": "rust",
"repo": "norcalli/kjson-parser",
"path": "/src/tokenizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: norcalli/kjson-parser path: /src/tokenizer.rs
#[inline]
fn expect(&mut self) -> TokenizeResult<u8> {
self.next().ok_or(TokenizeError::UnexpectedEndOfInput)
}
#[inline]
fn expect_next_pattern<F: Fn(u8) -> bool>(&mut self, f: F) -> TokenizeResult<u8> {
match self... | code_fim | hard | {
"lang": "rust",
"repo": "norcalli/kjson-parser",
"path": "/src/tokenizer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mr-glt/sx127x_lora path: /examples/stm32f4_receive.rs
#![no_std]
#![no_main]
extern crate cortex_m;
extern crate panic_semihosting;
extern crate stm32f429_hal as hal;
extern crate sx127x_lora;
use cortex_m_semihosting::*;
use hal::delay::Delay;
use hal::flash::FlashExt;
use hal::gpio::GpioExt;... | code_fim | hard | {
"lang": "rust",
"repo": "mr-glt/sx127x_lora",
"path": "/examples/stm32f4_receive.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut lora =
sx127x_lora::LoRa::new(spi, cs, reset, FREQUENCY, Delay::new(cp.SYST, clocks)).unwrap();
loop {
let poll = lora.poll_irq(Some(30)); //30 Second timeout
match poll {
Ok(size) => {
hprintln!(
"New Packet with siz... | code_fim | hard | {
"lang": "rust",
"repo": "mr-glt/sx127x_lora",
"path": "/examples/stm32f4_receive.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msvbg/legion path: /codegen/tests/failures/par_mut_command.rs
#![allow(unused_imports)]
<|fim_suffix|>#[system(par_for_each)]
fn for_each(_: &Entity, _: &mut CommandBuffer) {}
fn main() {}<|fim_middle|>use legion::{systems::CommandBuffer, Entity};
use legion_codegen::system;
| code_fim | medium | {
"lang": "rust",
"repo": "msvbg/legion",
"path": "/codegen/tests/failures/par_mut_command.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn val(&self, idx: uint) -> S { self[idx] }
}
macro_rules! impl_dsp_buffer(
($len:expr) => (
impl<S> DspBuffer<S> for [S, ..$len] where S: Sample {
fn get_mut(&mut self, idx: uint) -> &mut S { &mut self[idx] }
fn val(&self, idx: uint) -> S { self[idx] }
}
... | code_fim | hard | {
"lang": "rust",
"repo": "bvssvni/dsp-chain",
"path": "/src/buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bvssvni/dsp-chain path: /src/buffer.rs
//!
//! buffer.rs
//!
//! Created by Mitchell Nordine at 07:27AM on November 29, 2014.
//!
//!
use sound_stream::{AudioBuffer, Sample};
<|fim_suffix|> }
)
)
impl_dsp_buffer!(2)
impl_dsp_buffer!(4)
impl_dsp_buffer!(8)
impl_dsp_buffer!(16)
imp... | code_fim | hard | {
"lang": "rust",
"repo": "bvssvni/dsp-chain",
"path": "/src/buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.as_handle_ref().signal(
zx::Signals::empty(),
USER_SIGNALS[event] | USER_SIGNALS[EVENT_SET_INTERRUPT as usize],
)
}
pub fn signal_queue(&self) -> Result<(), zx::Status> {
self.signal(EVENT_SET_QUEUE as usize)
}
pub fn signal_config(&... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/virtualization/lib/machina-virtio-device/src/notify.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/virtualization/lib/machina-virtio-device/src/notify.rs
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
fidl_fuchsia_virtualization_hardware::... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/virtualization/lib/machina-virtio-device/src/notify.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn download_cli() -> Result<()> {
// Create a temporary directory. When this is dropped the directory is deleted.
let tmp_dir = tempfile::TempDir::new().context("Failed to create temporary directory")?;
info!("Downloading installer.");
let installer_path = super::ge... | code_fim | hard | {
"lang": "rust",
"repo": "jamiebrynes7/spatialos-sdk-rs",
"path": "/cargo-spatial/src/download.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamiebrynes7/spatialos-sdk-rs path: /cargo-spatial/src/download.rs
// Conditionally re-export the correct version of download_cli dependent on platform.
#[cfg(target_os = "linux")]
pub use self::linux::*;
#[cfg(target_os = "macos")]
pub use self::macos::*;
#[cfg(target_os = "windows")]
pub use s... | code_fim | hard | {
"lang": "rust",
"repo": "jamiebrynes7/spatialos-sdk-rs",
"path": "/cargo-spatial/src/download.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /bls/tests/cache.rs
use std::cmp;
use nimiq_bls::{cache::PublicKeyCache, lazy::LazyPublicKey, KeyPair};
use nimiq_test_utils::test_rng::test_rng;
use nimiq_utils::key_rng::SecureGenerate;
#[test]
fn removes_items_on_low_capacity() {
let mut cache = PublicKeyCa... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/bls/tests/cache.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(cache.len(), 0, "should start empty");
let rng = &mut test_rng(false);
let keypair = KeyPair::generate(rng);
assert_eq!(
cache
.get_or_uncompress(&keypair.public_key.compress())
.unwrap(),
keypair.public_key
);
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/bls/tests/cache.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn insert(&mut self, account: UserAccount) {
self.accounts.insert(account.address, account);
}
pub fn num_accounts(&self) -> usize {
self.accounts.len()
}
pub fn accounts_mut(&mut self) -> impl Iterator<Item = &mut UserAccount> {
self.accounts.values_mut()... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/fastpay",
"path": "/fastpay/src/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gdanezis/fastpay path: /fastpay/src/config.rs
// Copyright (c) Facebook, Inc. and its affiliates.
// SPDX-License-Identifier: Apache-2.0
use crate::transport::NetworkProtocol;
use fastpay_core::{
base_types::*,
client::ClientState,
messages::{Address, CertifiedTransferOrder},
};
us... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/fastpay",
"path": "/fastpay/src/config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juarezr/rsfbclient path: /src/tests/transaction.rs
//!
//! Rust Firebird Client
//!
//! Transaction struct tests
//!
mk_tests_default! {
use crate::{FbError, Connection, Transaction, query::Queryable, EngineVersion, SystemInfos};
use rsfbclient_core::*;
macro_rules! recreate_tbl_fm... | code_fim | hard | {
"lang": "rust",
"repo": "juarezr/rsfbclient",
"path": "/src/tests/transaction.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> drop(transaction2);
drop(transaction1);
conn2.close()?;
teardown(conn, TABLE_NAME)
}
#[test]
fn select_readcommited_with_record_version() -> Result<(), FbError> {
const TABLE_NAME: &str = "RSFBCLIENT_TEST_TRANS8";
let mut conn = cbuilder().conn... | code_fim | hard | {
"lang": "rust",
"repo": "juarezr/rsfbclient",
"path": "/src/tests/transaction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut conn = cbuilder().connect()?;
if conn.server_engine()? != EngineVersion::V3 {
return Ok(());
}
setup(&mut conn, TABLE_NAME)?;
let mut transaction1 = Transaction::new(&mut conn, TransactionConfiguration::default())?;
let _ = transaction1.... | code_fim | hard | {
"lang": "rust",
"repo": "juarezr/rsfbclient",
"path": "/src/tests/transaction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //let b = app::models::buildings::Building::new("fea".to_owned(), "segvr".to_owned());
//HttpResponse::Ok().json(b)
}
fn main() {
let mut listenfd = ListenFd::from_env();
let mut server = HttpServer::new(|| App::new()
.route("/", web::get().to(index))
.route("/again", web:... | code_fim | medium | {
"lang": "rust",
"repo": "benoxoft/bep",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benoxoft/bep path: /src/main.rs
// systemfd --no-pid -s http::8080 -- cargo watch -x run
#[macro_use]
extern crate diesel;
extern crate dotenv;
#[macro_use]
extern crate lazy_static;
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder, get};
use listenfd::ListenFd;
pub m... | code_fim | medium | {
"lang": "rust",
"repo": "benoxoft/bep",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "Hello World!"
}
fn index2() -> impl Responder {
//let b = app::models::buildings::Building::new("fea".to_owned(), "segvr".to_owned());
//HttpResponse::Ok().json(b)
}
fn main() {
let mut listenfd = ListenFd::from_env();
let mut server = HttpServer::new(|| App::new()
.route("/... | code_fim | hard | {
"lang": "rust",
"repo": "benoxoft/bep",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Find the max lengths of the initial column
for (stem, _) in templates.iter() {
if stem.len() > max_length {
max_length = stem.len()
}
}
// Print headers for the template table to be displayed
... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/cli/src/action/circuit/template.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cargill/splinter path: /cli/src/action/circuit/template.rs
// Copyright 2018-2022 Cargill Incorporated
//
// 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
//
// ht... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/cli/src/action/circuit/template.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhouzyue/cs140e path: /os/pi/src/interrupt/interrupt.rs
use common::IO_BASE;
use volatile::prelude::*;
use volatile::{Volatile, ReadVolatile};
const INT_BASE: usize = IO_BASE + 0xB000 + 0x200;
#[derive(Copy, Clone, PartialEq)]
pub enum Interrupt {
Timer1 = 1,
Timer3 = 3,
Usb = 9,
... | code_fim | hard | {
"lang": "rust",
"repo": "zhouzyue/cs140e",
"path": "/os/pi/src/interrupt/interrupt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Disables the interrupt `int`.
pub fn disable(&mut self, int: Interrupt) {
let bit = int as u32;
if bit < 32 {
self.registers.INTERRUPT_DISABLE_1.or_mask(1 << bit);
} else {
self.registers.INTERRUPT_DISABLE_2.or_mask(1 << (bit - 32));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "zhouzyue/cs140e",
"path": "/os/pi/src/interrupt/interrupt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cmisenas/nand2tetris path: /stack_vm/src/parser_module.rs
/**
* Handles the parsing of a single .vm file and encapsulates access to the input code.
* It reads VM commands, prases them and provides convenient access to their components.
* It also removes all white space and comments.
*/
pub s... | code_fim | hard | {
"lang": "rust",
"repo": "cmisenas/nand2tetris",
"path": "/stack_vm/src/parser_module.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Returns the second argument of the current command. Should only be called
// if the current command is C_Push, C_Pop, C_Function or C_Call.
pub fn get_arg2(&self) -> String {
match self.get_command_type() {
CommandType::C_Push
| CommandType::C_Pop
... | code_fim | hard | {
"lang": "rust",
"repo": "cmisenas/nand2tetris",
"path": "/stack_vm/src/parser_module.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TyOverby/current path: /examples/text.rs
extern crate current;
use current::Current;
use std::cell::RefCell;
pub struct Foo {
text: String
}
pub trait TextProperty {
fn get_text(&self) -> &str;
fn set_text(&mut self, text: String);
}
<|fim_suffix|> let bar = RefCell::new(Foo {... | code_fim | hard | {
"lang": "rust",
"repo": "TyOverby/current",
"path": "/examples/text.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: TextProperty> current::Get<Text> for T {
fn get(&self) -> Text {
Text(self.get_text().to_string())
}
}
impl<T: TextProperty> current::Modifier<T> for Text {
fn modify(self, obj: &mut T) {
let Text(text) = self;
obj.set_text(text)
}
}
fn print_text<T: TextP... | code_fim | hard | {
"lang": "rust",
"repo": "TyOverby/current",
"path": "/examples/text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /*
Current::with_current_unwrap(|val: &RefCell<T>| {
let mut val = val.borrow_mut();
println!("{}", val.get_text());
val.set_text("world!".to_string());
});
*/
}
fn bar() {
let bar = RefCell::new(Foo { text: "good bye".to_string() });
let guard = bar.set_cu... | code_fim | hard | {
"lang": "rust",
"repo": "TyOverby/current",
"path": "/examples/text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (mut a, mut b): (A, B) = Default::default();
for (t, u) in iter {
a.extend([t]);
b.extend([u]);
}
Unzip(a, b)
}
}<|fim_prefix|>// repo: teloxide/teloxide path: /crates/teloxide-macros/src/unzip.rs
use std::iter::FromIterator;
pub(crate) s... | code_fim | medium | {
"lang": "rust",
"repo": "teloxide/teloxide",
"path": "/crates/teloxide-macros/src/unzip.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: teloxide/teloxide path: /crates/teloxide-macros/src/unzip.rs
use std::iter::FromIterator;
pub(crate) struct Unzip<A, B>(pub A, pub B);
impl<A, B, T, U> FromIterator<(T, U)> for Unzip<A, B>
where
A: Default + Extend<T>,
B: Default + Extend<U>,
{
fn from_iter<I: IntoIterator<Item = (... | code_fim | easy | {
"lang": "rust",
"repo": "teloxide/teloxide",
"path": "/crates/teloxide-macros/src/unzip.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: takemyoxygen/playground path: /rust/types/src/lib.rs
mod cells;
mod fun;
use std::f32;
use std::num;
#[derive(Debug)]
pub enum Error {
Input(String),
Parsing(num::ParseIntError)
}
impl PartialEq for Error {
fn eq(&self, another: &Self) -> bool {
match (self, another){
... | code_fim | hard | {
"lang": "rust",
"repo": "takemyoxygen/playground",
"path": "/rust/types/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn error_equality_tests() {
assert_eq!(Error::Input("foo".to_string()), Error::Input("foo".to_string()));
let error1 = "foo".parse::<i32>().err().unwrap();
let error2 = "foo".parse::<i32>().err().unwrap();
assert_eq!(Error::Parsing(error1), Error::Parsing(e... | code_fim | hard | {
"lang": "rust",
"repo": "takemyoxygen/playground",
"path": "/rust/types/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heartyhardy/aoc2015 path: /src/day_14.rs
use std::env;
use std::fs;
use std::path::Path;
#[derive(Copy,Clone,Debug)]
struct Raindeer<'a>{
name:&'a str,
speed:i32,
runtime:i32,
sleep:i32,
distance:i32,
points:i32,
}
fn read_racer_stats(filename:&str)->String{
let fpa... | code_fim | hard | {
"lang": "rust",
"repo": "heartyhardy/aoc2015",
"path": "/src/day_14.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn let_it_race_dep(racers:Vec<Raindeer>,dt:i32)->(String, i32){
let (mut max, mut winner) = (0, String::new());
for i in 0..racers.len(){
let mut next = racers[i].runtime;
let (mut distance,mut t) = (0,0);
while t < dt{
if t == next{
t += ra... | code_fim | hard | {
"lang": "rust",
"repo": "heartyhardy/aoc2015",
"path": "/src/day_14.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simonsan/semeion path: /examples/wireworld/entity/cell.rs
use ggez::graphics;
use ggez::nalgebra::Point2;
use ggez::{Context, GameError};
use std::any::Any;
use super::Kind;
use crate::{env, Meshes};
use semeion::*;
/// Enumerate each possible cell state (Empty will be encoded as the absence
/... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/semeion",
"path": "/examples/wireworld/entity/cell.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
ctx: &mut Self::Context,
transform: Transform,
) -> Result<(), Error> {
// Draw the shape of the Cell without taking into consideration the
// given transformation (that is always going to be equal to the Identity
// matrix) since for the purposes... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/semeion",
"path": "/examples/wireworld/entity/cell.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if count == 1 || count == 2 {
State::ElectronHead
} else {
State::Conductor
}
}
};
Ok(())
}
fn react(
&mut self,
_: Option<Neighborhood<Self::Kind, Self::Context>>,... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/semeion",
"path": "/examples/wireworld/entity/cell.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn execute_mut(command: &mut Command) -> std::io::Result<ExitStatus> {
match command.spawn() {
Ok(mut subprocess) => subprocess.wait(),
_ => {
println!("Failed to run process!");
exit(1)
}
}
}
pub fn handle_exit_status(result: std::io::Result<Ex... | code_fim | hard | {
"lang": "rust",
"repo": "bearlikelion/valheim-docker",
"path": "/src/executable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bearlikelion/valheim-docker path: /src/executable.rs
use std::process::{Command, exit, ExitStatus};
use std::path::Path;
pub fn find_command(executable: &str) -> Option<Command> {
let script_file = Path::new(executable);
if script_file.exists() {
println!("Executing: {} .....",... | code_fim | hard | {
"lang": "rust",
"repo": "bearlikelion/valheim-docker",
"path": "/src/executable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match (e1, e2) {
(Op2(op1, l1, r1), Op2(op2, l2, r2)) => {
op1 == op2 && cmp_op(vmap.clone(), l1, l2) && cmp_op(vmap, r1, r2)
}
(MkArray(sz1, n1), MkArray(sz2, n2)) => {
cmp_imm(vmap.clone(), sz1, sz2) && cmp_imm(vmap, n1, n2)
}
(GetArray... | code_fim | hard | {
"lang": "rust",
"repo": "bpowers/liquid-types",
"path": "/src/lambdal.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bpowers/liquid-types path: /src/lambdal.rs
micUsize, Ordering};
use crate::common::{self, Const, Id, Op2};
use crate::env;
use crate::explicit::{self, Type};
use crate::hindley_milner;
use crate::implicit;
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone)]
pub enum Imm {
Bool(bool),
... | code_fim | hard | {
"lang": "rust",
"repo": "bpowers/liquid-types",
"path": "/src/lambdal.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bpowers/liquid-types path: /src/lambdal.rs
t::{self, Type};
use crate::hindley_milner;
use crate::implicit;
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone)]
pub enum Imm {
Bool(bool),
Int(i64),
Var(Id),
Fun(Id, Box<Expr>),
Fix(Id, Box<Expr>),
Star,
V,
}
#[deri... | code_fim | hard | {
"lang": "rust",
"repo": "bpowers/liquid-types",
"path": "/src/lambdal.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fengalin/media-toc path: /application/src/lib.rs
use once_cell::sync::Lazy;
pub const TLD: &str = "org";
pub const SLD: &str = "fengalin";
// Remove "-application" from `CARGO_PKG_NAME`
pub static APP_NAME: Lazy<String> = Lazy::new(|| {
env!("CARGO_PKG_NAME")
.rsplitn(2, '-')
... | code_fim | medium | {
"lang": "rust",
"repo": "fengalin/media-toc",
"path": "/application/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod configuration;
pub use self::configuration::CONFIG;
cfg_if::cfg_if! {
if #[cfg(feature = "gettext")] {
pub use gettext::{gettext, ngettext};
mod locale;
pub use self::locale::init_locale;
} else {
use log::warn;
pub fn gettext(msg: impl Into<String>) ... | code_fim | hard | {
"lang": "rust",
"repo": "fengalin/media-toc",
"path": "/application/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jenix21/buildrun path: /src/main.rs
extern crate regex;
use std::collections::HashMap;
use std::process;
trait Formattable {
fn format(&self, args: &[&str]) -> Self;
}
impl Formattable for String {
fn format(&self, args: &[&str]) -> String {
let place_holder = "{}";
if !self.contai... | code_fim | medium | {
"lang": "rust",
"repo": "jenix21/buildrun",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for cmd_arg in &cmd_to_run {
let args: Vec<&str> = cmd_arg.1.split(',').collect();
let output = process::Command::new(cmd_arg.0)
.args(build_cmd.args_of(cmd_arg.0, &args))
.output()
.expect(&format!("{} failed", &cmd_arg.0));
if !output.status.success() {
println!("{}... | code_fim | medium | {
"lang": "rust",
"repo": "jenix21/buildrun",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mockersf/rust path: /src/test/codegen/debug-vtable.rs
// This test checks the debuginfo for the expected 3 vtables is generated for correct names and number
// of entries.
// Use the v0 symbol mangling scheme to codegen order independent of rustc version.
// Unnamed items like shims are generat... | code_fim | hard | {
"lang": "rust",
"repo": "mockersf/rust",
"path": "/src/test/codegen/debug-vtable.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Constructing the debuginfo name for the FnOnce vtable below initially caused an ICE on MSVC
// because the trait type contains a late bound region that needed to be erased before the type
// layout for the niche enum `Option<&dyn Fn()>` could be computed.
pub fn bar() -> Box<dyn FnOnce(Option<&dyn Fn()... | code_fim | hard | {
"lang": "rust",
"repo": "mockersf/rust",
"path": "/src/test/codegen/debug-vtable.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spacemeshos/svm path: /crates/host/gas/src/pricing/resolver.rs
use svm_program::Op;
/// Pricing an `Op` or an import function should be part of the consensus protocol.
/// (It's crucial since otherwise, different network peers will give the same function a different price).
pub trait PriceResol... | code_fim | medium | {
"lang": "rust",
"repo": "spacemeshos/svm",
"path": "/crates/host/gas/src/pricing/resolver.rs",
"mode": "psm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn import_price(&self, import: (&str, &str)) -> usize {
R::import_price(&self, import)
}
}<|fim_prefix|>// repo: spacemeshos/svm path: /crates/host/gas/src/pricing/resolver.rs
use svm_program::Op;
/// Pricing an `Op` or an import function should be part of the consensus protocol.
/// (It... | code_fim | medium | {
"lang": "rust",
"repo": "spacemeshos/svm",
"path": "/crates/host/gas/src/pricing/resolver.rs",
"mode": "spm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: willcrichton/psiop path: /src/infer.rs
use crate::dist::{Dist, Dist::*};
use crate::dparse;
use crate::lang::{v, Expr, Stmt, Var};
use lazy_static::lazy_static;
use maplit::hashmap;
use std::collections::HashMap;
fn rec(d: Dist, s: Var, v: Var) -> Box<Dist> {
box Pdf(box App(box d, box DVar(s... | code_fim | hard | {
"lang": "rust",
"repo": "willcrichton/psiop",
"path": "/src/infer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Func(state, box Distr(arg, box body))
}
}
impl Stmt {
pub fn infer(&self) -> Dist {
use Dist::*;
let state = v("σ");
let (arg, body) = match self {
Stmt::Seq(box s1, box s2) => (
v("σ2"),
dparse!("∫dσ1 ({})(σ)⟦σ1⟧ · ({})(σ1)⟦σ2⟧", s1.infer(), s2.infer()),
... | code_fim | hard | {
"lang": "rust",
"repo": "willcrichton/psiop",
"path": "/src/infer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RoyRin/opendp path: /rust/opendp-ffi/src/data/mod.rs
if element_ids.len() != 2 {
return fallible!(FFI, "Only tuples of length 2 are supported").into();
}
let types = try_!(element_ids.iter().map(Type::of_id).collect::<Fallible<Vec<_>>>());
... | code_fim | hard | {
"lang": "rust",
"repo": "RoyRin/opendp",
"path": "/rust/opendp-ffi/src/data/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::*;
#[test]
fn test_slice_as_object_number() -> Fallible<()> {
let raw_ptr = util::into_raw(999) as *mut c_void;
let raw_len = 1;
let raw = util::into_raw(FfiSlice::new(raw_ptr, raw_len));
let res = opendp_data__slice_as_object(raw, "i32".to_char_p())... | code_fim | hard | {
"lang": "rust",
"repo": "RoyRin/opendp",
"path": "/rust/opendp-ffi/src/data/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if raw.len != 2 {
return fallible!(FFI, "The slice length must be two when creating a tuple from FfiSlice");
}
let slice = unsafe { slice::from_raw_parts(raw.ptr as *const *const c_void, 2) };
let tuple = util::as_ref(slice[0] as *const T0).cloned()
... | code_fim | hard | {
"lang": "rust",
"repo": "RoyRin/opendp",
"path": "/rust/opendp-ffi/src/data/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Devolutions/devolutions-crypto path: /devolutions-crypto/fuzz/fuzz_targets/secret_sharing/generate_shared_key.rs
#![no_main]
use arbitrary::Arbitrary;
use libfuzzer_sys::fuzz_target;
<|fim_suffix|>fuzz_target!(|data: Input| {
let _ = generate_shared_key(
data.n_shares,
data.... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/devolutions-crypto",
"path": "/devolutions-crypto/fuzz/fuzz_targets/secret_sharing/generate_shared_key.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fuzz_target!(|data: Input| {
let _ = generate_shared_key(
data.n_shares,
data.threshold,
data.length as usize,
data.version,
);
});<|fim_prefix|>// repo: Devolutions/devolutions-crypto path: /devolutions-crypto/fuzz/fuzz_targets/secret_sharing/generate_shared_key.r... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/devolutions-crypto",
"path": "/devolutions-crypto/fuzz/fuzz_targets/secret_sharing/generate_shared_key.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iambotHQ/zalando-api-client path: /src/models/article_attribute.rs
/*
* Zalando Shop API
*
* The shop API empowers developers to build amazing new apps or websites using Zalando shop data and services.
*
* OpenAPI spec version: v1.0
*
* Generated by: https://github.com/swagger-api/swagg... | code_fim | hard | {
"lang": "rust",
"repo": "iambotHQ/zalando-api-client",
"path": "/src/models/article_attribute.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_values(&mut self, values: Vec<String>) {
self.values = values;
}
pub fn with_values(mut self, values: Vec<String>) -> ArticleAttribute {
self.values = values;
self
}
pub fn values(&self) -> &Vec<String> {
&self.values
}
}<|fim_prefix|>// repo: iambotHQ/zalando-api... | code_fim | hard | {
"lang": "rust",
"repo": "iambotHQ/zalando-api-client",
"path": "/src/models/article_attribute.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ArticleAttribute {
/// Zalando API Article Attribute Schema
pub fn new(name: String, values: Vec<String>) -> ArticleAttribute {
ArticleAttribute {
name: name,
values: values
}
}
pub fn set_name(&mut self, name: String) {
self.name = name;
}
pub fn with_name(mut s... | code_fim | hard | {
"lang": "rust",
"repo": "iambotHQ/zalando-api-client",
"path": "/src/models/article_attribute.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nakazono0424/bomberhuman path: /src/models/bomb.rs
use crate::geometry::Point;
use crate::models::{Fire, Item, SoftBlock, Wall};
use std::f64;
const GRID: f64 = 40.0;
#[derive(Default)]
pub struct Bomb {
pub player_id: i32,
pub position: Point,
pub ttl: f64,
pub condition: i32,... | code_fim | hard | {
"lang": "rust",
"repo": "nakazono0424/bomberhuman",
"path": "/src/models/bomb.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn check_items(&mut self, items: &Vec<Item>, x: f64, y: f64) -> bool {
if items.iter().any(|item| item.x() == x && item.y() == y) {
true
} else {
false
}
}
pub fn check_sblocks(&mut self, sblocks: &Vec<SoftBlock>, x: f64, y: f64) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "nakazono0424/bomberhuman",
"path": "/src/models/bomb.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> block_field
.listed::<block::Property>(props)
.map(|(_, prop)| match prop.value() {
block::property::Value::Children(children) => vec![
Html::span(
Attributes::new(),
Events::new(),
vec![Html::text(... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/orgs/component.org/room/render/canvas_container/character_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SoundRabbit/soldoresol path: /src/orgs/component.org/room/render/canvas_container/character_list.rs
use super::super::common;
use crate::{
block::{self, chat::item::Icon, BlockId},
Resource,
};
use kagura::prelude::*;
pub fn render<'a>(
block_field: &block::Field,
characters: im... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/orgs/component.org/room/render/canvas_container/character_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn selected_property(block_field: &block::Field, props: Vec<&BlockId>) -> Vec<BlockId> {
let props = block_field.listed::<block::Property>(props);
let mut selected = vec![];
for (prop_id, prop) in props {
if prop.is_selected() {
selected.push(prop_id);
} else if le... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/orgs/component.org/room/render/canvas_container/character_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Spanfile/X52-Spotify path: /src/x52/mod.rs
#![allow(non_upper_case_globals)]
mod libx52;
mod line;
use libx52::*;
use line::Line;
use std::cell::RefCell;
use std::ptr;
pub struct X52 {
device: RefCell<*mut libx52_device>,
lines: [Option<Line>; 3],
}
#[derive(Debug, Clone)]
pub struct... | code_fim | hard | {
"lang": "rust",
"repo": "Spanfile/X52-Spotify",
"path": "/src/x52/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let error = unsafe {
libx52_set_text(
*self.device.borrow(),
index as u8,
line.as_ptr() as *const std::os::raw::c_char,
line.len() as u8,
)
};
... | code_fim | hard | {
"lang": "rust",
"repo": "Spanfile/X52-Spotify",
"path": "/src/x52/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn is_signature_valid_works() {
let secret = "test";
let sig = "sha1=a3ad816405dec2204d9a1c4159ae51c8b030f463";
let json = "{\"test\": true}";
assert!(is_signature_valid(
String::from(secret),
... | code_fim | medium | {
"lang": "rust",
"repo": "BaconSoap/github-webhook-receiver",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BaconSoap/github-webhook-receiver path: /src/lib.rs
mod from_hex;
extern crate hmac;
extern crate sha_1;
use hmac::{Hmac, Mac};
use sha_1::Sha1;
use from_hex::FromHex;
#[derive(Debug)]
pub enum WebhookEventType {
PullRequest(PullRequestEventType),
Push,
}
#[derive(Debug)]
pub enum Pu... | code_fim | hard | {
"lang": "rust",
"repo": "BaconSoap/github-webhook-receiver",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.