text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> self.kind = Kind::Moving {
total,
current,
left,
};
}
}
pub fn body(&self) -> Body {
let backwards = match self.kind {
Kind::Idle | Kind::Moving { left: true, .. } => true,
_ => false,
... | code_fim | hard | {
"lang": "rust",
"repo": "nrxus/duck_husky_wedding",
"path": "/src/duck_husky_wedding/cat.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nrxus/duck_husky_wedding path: /src/duck_husky_wedding/cat.rs
use data;
use errors::*;
use duck_husky_wedding::body::Body;
use glm;
use moho;
use moho::animation::{self, Animation};
use moho::renderer::{options, Renderer, Scene, Texture, TextureLoader, TextureManager};
use std::time::Duration;... | code_fim | hard | {
"lang": "rust",
"repo": "nrxus/duck_husky_wedding",
"path": "/src/duck_husky_wedding/cat.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> Cat<T> {
pub fn new(data: &Data<T>) -> Self {
Cat {
body: data.body.clone(),
dst: data.dst,
animation: data.animation.clone().start(),
kind: data.kind,
}
}
pub fn update(&mut self, duration: Duration) {
self.anima... | code_fim | hard | {
"lang": "rust",
"repo": "nrxus/duck_husky_wedding",
"path": "/src/duck_husky_wedding/cat.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tern crate rand; //TODO: Get rid of the allow when actually building
extern crate rustc_serialize;
#[macro_use]
pub mod mapping;
pub mod genetics;
pub mod io;
pub mod collections;
mod tests;<|fim_prefix|>// repo: laitalaj/dwarfitect path: /src/lib.rs
//Unstable features for data structure programming an... | code_fim | medium | {
"lang": "rust",
"repo": "laitalaj/dwarfitect",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laitalaj/dwarfitect path: /src/lib.rs
//Unstable features for data structure programming and benchmark testing
#![feature(alloc, heap<|fim_suffix|>tern crate rand; //TODO: Get rid of the allow when actually building
extern crate rustc_serialize;
#[macro_use]
pub mod mapping;
pub mod genetics;
p... | code_fim | medium | {
"lang": "rust",
"repo": "laitalaj/dwarfitect",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daachi/tezedge path: /tezos/messages/tests/encoding_operations_for_blocks.rs
// Copyright (c) SimpleStaking, Viable Systems and Tezedge Contributors
// SPDX-License-Identifier: MIT
use std::convert::TryInto;
use anyhow::Error;
use crypto::hash::HashType;
use tezos_messages::p2p::encoding::oper... | code_fim | hard | {
"lang": "rust",
"repo": "daachi/tezedge",
"path": "/tezos/messages/tests/encoding_operations_for_blocks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let message_bytes = create_operations_for_blocks_encoded(MAX_PASS_MERKLE_DEPTH as usize + 1);
let result = PeerMessageResponse::from_bytes(message_bytes);
assert!(result.is_err());
Ok(())
}
#[test]
fn can_deserialize_operations_for_blocks_no_stack_overflow() -> Result<(), Error> {
//... | code_fim | hard | {
"lang": "rust",
"repo": "daachi/tezedge",
"path": "/tezos/messages/tests/encoding_operations_for_blocks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DerLando/egui_nodes path: /src/node.rs
use super::*;
use derivative::Derivative;
#[derive(Default, Debug)]
/// The Style of a Node. If feilds are None then the Context style is used
pub struct NodeArgs {
pub background: Option<egui::Color32>,
pub background_hovered: Option<egui::Color32... | code_fim | hard | {
"lang": "rust",
"repo": "DerLando/egui_nodes",
"path": "/src/node.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, 'b> NodeConstructor<'a> {
/// Create a new node to be displayed in a Context.
/// id should be the same accross frames and should not be the same as any other currently used nodes
pub fn new(id: usize, args: NodeArgs) -> Self {
Self {
id,
args,
... | code_fim | hard | {
"lang": "rust",
"repo": "DerLando/egui_nodes",
"path": "/src/node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aosp-riscv/toolchain_rustc path: /src/tools/miri/tests/run-pass/intptrcast.rs
// This returns a miri pointer at type usize, if the argument is a proper pointer
fn transmute_ptr_to_int<T>(x: *const T) -> usize {
unsafe { std::mem::transmute(x) }
}
fn cast() {
// Some casting-to-int with ... | code_fim | hard | {
"lang": "rust",
"repo": "aosp-riscv/toolchain_rustc",
"path": "/src/tools/miri/tests/run-pass/intptrcast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn ptr_bitops1() {
let bytes = [0i8, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let one = bytes.as_ptr().wrapping_offset(1);
let three = bytes.as_ptr().wrapping_offset(3);
let res = (one as usize) | (three as usize);
format!("{}", res);
}
fn ptr_bitops2() {
let val = 13usize;
let addr = &val... | code_fim | hard | {
"lang": "rust",
"repo": "aosp-riscv/toolchain_rustc",
"path": "/src/tools/miri/tests/run-pass/intptrcast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tecywiz121/rocket_template_dir path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
use rocket_contrib::templates::Template;
#[get("/default")]
fn default_template() -> Template {
<|fim_suffix|> Template::render("bar", ())
}
fn main() {
rock... | code_fim | medium | {
"lang": "rust",
"repo": "tecywiz121/rocket_template_dir",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rocket::ignite()
.attach(Template::custom(|engines| {
let extended_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/extended");
engines
.handlebars
.register_templates_directory(".html.hbs", extended_dir)
.unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "tecywiz121/rocket_template_dir",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vabka/poker_calc path: /src/cards/poker.rs
#![allow(dead_code)]
use super::deck::{
Card,
Rank::{self, *},
};
use std::collections::HashMap;
/// 5 Карт
pub struct Hand([Card; 5]);
use core::fmt::{self, Display, Formatter};
impl Display for Hand {
fn fmt(&self, f: &mut Formatter<'_>)... | code_fim | hard | {
"lang": "rust",
"repo": "vabka/poker_calc",
"path": "/src/cards/poker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.flush_rank().is_some()
}
///Получить текущее комбо в руке
pub fn get_combo(&self) -> PokerCombo {
if let Some(straight_rank) = self.straight_rank() {
if self.is_flush() {
StraightFlush(straight_rank)
} else {
Straight... | code_fim | hard | {
"lang": "rust",
"repo": "vabka/poker_calc",
"path": "/src/cards/poker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pairs = self.get_pairs();
if pairs.len() == 2 {
let first_pair_rank = pairs[0];
let second_pair_rank = pairs[1];
Some([first_pair_rank.to_owned(), second_pair_rank.to_owned()])
} else {
None
}
}
fn full_house_rank... | code_fim | hard | {
"lang": "rust",
"repo": "vabka/poker_calc",
"path": "/src/cards/poker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let receipt = DocumentReceipt::new(enc_doc.ts, &enc_doc.pid, &enc_doc.id, &enc_doc.hash);
debug!("storing document ....");
// store document
//TODO store encrypted keys
match db.add_document(enc_doc).await {
Ok(_b) => ApiRespons... | code_fim | hard | {
"lang": "rust",
"repo": "idoiamurua/ids-clearing-house-core",
"path": "/document-api/src/doc_api.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("storing document ....");
// store document
//TODO store encrypted keys
match db.add_document(enc_doc).await {
Ok(_b) => ApiResponse::SuccessCreate(json!(receipt)),
Err(e) => {
error!("Error while ad... | code_fim | hard | {
"lang": "rust",
"repo": "idoiamurua/ids-clearing-house-core",
"path": "/document-api/src/doc_api.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: idoiamurua/ids-clearing-house-core path: /document-api/src/doc_api.rs
use biscuit::Empty;
use rocket::State;
use chrono::Local;
use core_lib::{
api::{
ApiResponse,
auth::ApiKey,
claims::IdsClaims,
client::keyring_api::KeyringApiClient,
DocumentReceipt
... | code_fim | hard | {
"lang": "rust",
"repo": "idoiamurua/ids-clearing-house-core",
"path": "/document-api/src/doc_api.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ptrs=scan((0., 0.), (1.0, 3.0_f64.sqrt()), 0.1 , IMG_SIZE as f64, 30000);
let scan_mat=get_scan_mat_gaussian(&ptrs, 16, 1.5, 5);
let scan_mat_no_deconv=get_scan_mat(&ptrs, 16);
let scan_mat_solve=&scan_mat;
let ata=&scan_mat.transpose_view()*&scan_mat;
let ata_no_deconv=&(sca... | code_fim | hard | {
"lang": "rust",
"repo": "astrojhgu/simscan",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tod=linear_solver::utils::sp_mul_a1(&scan_mat, skymap_flat.view());
fitsimg::write_img("scan.fits".to_string(), &sprs2ndarray(&scan_mat).into_dyn());
fitsimg::write_img("scan_no_conv.fits".to_string(), &sprs2ndarray(&scan_mat_no_deconv).into_dyn());
fitsimg::write_img("ata.fits".to_str... | code_fim | hard | {
"lang": "rust",
"repo": "astrojhgu/simscan",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astrojhgu/simscan path: /src/main.rs
extern crate simscan;
extern crate fitsimg;
extern crate ndarray;
extern crate linear_solver;
use linear_solver::io::RawMM;
use ndarray::array;
use simscan::{scan, get_scan_mat, get_scan_mat_gaussian, sprs2ndarray};
const IMG_SIZE:usize=16;
fn main() {
... | code_fim | medium | {
"lang": "rust",
"repo": "astrojhgu/simscan",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: soerenmartius/coinapi-rs path: /src/exchangerate.rs
use crate::client::Client;
use crate::model::exchangerate::{
ExchangeRates as AllRates,
ExchangeRate as Rate,
};
use failure::Error;
use serde_json::from_str;
use chrono::{DateTime, Utc};
use std::collections::btree_map::BTreeMap;
#[... | code_fim | hard | {
"lang": "rust",
"repo": "soerenmartius/coinapi-rs",
"path": "/src/exchangerate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let response = self.client.get(
format!("/v1/exchangerate/{}/{}",
base_currency,
quote_currency).as_str(), ¶meters)?;
let rate: Rate = from_str(response.as_str())?;
Ok(rate)
}
}<|fim_prefix|>// repo: soerenmartius/coinap... | code_fim | medium | {
"lang": "rust",
"repo": "soerenmartius/coinapi-rs",
"path": "/src/exchangerate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhiburt/tabled path: /tabled/examples/derive/order.rs
//! This example demonstrates using the [attribute macro](https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros)
//! [`order`] to relocate fields to specified indexes in a [`Table`] display.
//!
//! * By default, [`Table... | code_fim | hard | {
"lang": "rust",
"repo": "zhiburt/tabled",
"path": "/tabled/examples/derive/order.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name: &'static str,
national_currency: &'static str,
national_currency_short: &'static str,
capital_city: &'static str,
surface_area_km2: f32,
) -> Self {
Self {
name,
national_currency,
national_currency_short,
... | code_fim | medium | {
"lang": "rust",
"repo": "zhiburt/tabled",
"path": "/tabled/examples/derive/order.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_filter_encodings() {
//let tmp = TempDir::new("tmp").unwrap();
let mut config = RawConfig {
//workdir: tmp.path().to_path_buf(),
collections: vec![Collection {
name: "Col01".to_string(),
kind: CollectionKind::W... | code_fim | hard | {
"lang": "rust",
"repo": "pisa-engine/standard-benchmark",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pisa-engine/standard-benchmark path: /src/main.rs
use failure::ResultExt;
use log::{error, info};
use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
use std::{env, fs, mem, process};
use stdbench::run::{compare_with_baseline, process_run, RunStatus};
use stdbench::{
CMakeVar, ... | code_fim | hard | {
"lang": "rust",
"repo": "pisa-engine/standard-benchmark",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_config(args: Vec<String>, init_log: bool) -> Result<Option<ResolvedPathsConfig>, Error> {
let Opt {
config_file,
verbose,
log,
print_stages,
suppress,
collections,
encodings,
clean,
no_scorer,
cmake_vars,
} = ... | code_fim | hard | {
"lang": "rust",
"repo": "pisa-engine/standard-benchmark",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: phiresky/tantivy path: /src/postings/stacker/term_hashmap.rs
use murmurhash32::murmurhash2;
use super::{Addr, MemoryArena};
use crate::postings::stacker::memory_arena::store;
use crate::postings::UnorderedTermId;
use byteorder::{ByteOrder, NativeEndian};
use std::iter;
use std::mem;
use std::sl... | code_fim | hard | {
"lang": "rust",
"repo": "phiresky/tantivy",
"path": "/src/postings/stacker/term_hashmap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::TermHashMap;
use std::collections::HashMap;
#[test]
fn test_hash_map() {
let mut hash_map: TermHashMap = TermHashMap::new(18);
{
hash_map.mutate_or_create("abc", |opt_val: Option<u32>| {
assert_eq!(opt_val, N... | code_fim | hard | {
"lang": "rust",
"repo": "phiresky/tantivy",
"path": "/src/postings/stacker/term_hashmap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = self.heap.slice_from(addr);
let key_bytes_len = NativeEndian::read_u16(data) as usize;
let key_bytes: &[u8] = &data[2..][..key_bytes_len];
(key_bytes, addr.offset(2u32 + key_bytes_len as u32))
}
#[inline]
fn get_value_addr_if_key_match(&self, target_... | code_fim | hard | {
"lang": "rust",
"repo": "phiresky/tantivy",
"path": "/src/postings/stacker/term_hashmap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.is_root() {
f.write_str("{ROOT}")
} else {
let path = self.parts.join(&self.separator.to_string());
f.write_str(&path)
}
}
}
impl PartialEq for Path {
fn eq(&self, other: &Self) -> bool {
self.parts == other.parts
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "transparencies/oas3-rs",
"path": "/src/validation/path.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: transparencies/oas3-rs path: /src/validation/path.rs
use std::fmt;
#[derive(Debug, Clone)]
pub struct Path {
parts: Vec<String>,
separator: char,
}
impl Path {
pub fn new(sep: char) -> Self {
Self {
parts: vec![],
separator: sep,
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "transparencies/oas3-rs",
"path": "/src/validation/path.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> b.iter(|| {
for i in 1..100 {
black_box(2 * 2);
}
});
}<|fim_prefix|>// repo: pzmarzly/crates-of-many-artifacts path: /test1/benches/bench.rs
#![feature(test)]
extern crate test;
use test::{black_box, Bencher};
<|fim_middle|>#[bench]
fn bench_pow(b: &mut Bencher) {
| code_fim | easy | {
"lang": "rust",
"repo": "pzmarzly/crates-of-many-artifacts",
"path": "/test1/benches/bench.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pzmarzly/crates-of-many-artifacts path: /test1/benches/bench.rs
#![feature(test)]
extern crate test;
use test::{black_box, Bencher};
<|fim_suffix|> b.iter(|| {
for i in 1..100 {
black_box(2 * 2);
}
});
}<|fim_middle|>#[bench]
fn bench_pow(b: &mut Bencher) {
| code_fim | easy | {
"lang": "rust",
"repo": "pzmarzly/crates-of-many-artifacts",
"path": "/test1/benches/bench.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tcharding/snippet path: /ethereum.rs
mod cache;
mod web3_connector;
pub use self::{cache::Cache, web3_connector::Web3Connector};
use crate::{
btsieve::{
find_relevant_blocks, BlockByHash, BlockHash, LatestBlock, Predates, PreviousBlockHash,
},
ethereum::{Address, Bytes, Inpu... | code_fim | hard | {
"lang": "rust",
"repo": "tcharding/snippet",
"path": "/ethereum.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> log.topics.iter().enumerate().all(|(index, tx_topic)| {
let topic = &topics[index];
topic.as_ref().map_or(true, |topic| tx_topic == &topic.0)
})
}),
}
}
pub async fn matching_transaction_and_receipt<C, F>(
connector: &C,
start_of... | code_fim | hard | {
"lang": "rust",
"repo": "tcharding/snippet",
"path": "/ethereum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for n in 2..((limit as f64).sqrt() as usize + 1) {
if is_prime[n] {
let mut multiple = n * n;
while multiple <= limit {
is_prime[multiple] = false;
multiple += n;
}
}
}
is_prime
.into_iter()
.e... | code_fim | hard | {
"lang": "rust",
"repo": "seguidor777/dcoder-solutions",
"path": "/medium/prime_numbers_my_friends.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seguidor777/dcoder-solutions path: /medium/prime_numbers_my_friends.rs
use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).expect("cannot read n");
let n: usize = input.trim().parse().expect("cannot parse n");
let primes: Vec<usize> = sieve(... | code_fim | medium | {
"lang": "rust",
"repo": "seguidor777/dcoder-solutions",
"path": "/medium/prime_numbers_my_friends.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> is_prime
.into_iter()
.enumerate()
.filter_map(|(i, item)| if item { Some(i) } else { None })
.collect()
}<|fim_prefix|>// repo: seguidor777/dcoder-solutions path: /medium/prime_numbers_my_friends.rs
use std::io;
fn main() {
let mut input = String::new();
io::... | code_fim | hard | {
"lang": "rust",
"repo": "seguidor777/dcoder-solutions",
"path": "/medium/prime_numbers_my_friends.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slicebuild/sb path: /impl/rust/src/old_/directory_list.rs
l::RefCell;
use std::cmp::Ordering;
use std::fs;
use std::io::ErrorKind;
use std::path::{Path, PathBuf};
use std::rc::Rc;
use semver::Version;
use helper;
use slice::section::SectionList;
use os::Os;
use version;
#[derive(Debug)]
pub str... | code_fim | hard | {
"lang": "rust",
"repo": "slicebuild/sb",
"path": "/impl/rust/src/old_/directory_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn get_oses_from_correct_slice_directory() {
let mut path = env::current_dir().unwrap().to_path_buf();
path.push("test_slices");
path.push("slices-du-0.0.2");
let os_list = vec![Os { name: "debian".to_string(), version: version::parse("8.2") },
Os { name: "ubuntu"... | code_fim | hard | {
"lang": "rust",
"repo": "slicebuild/sb",
"path": "/impl/rust/src/old_/directory_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slicebuild/sb path: /impl/rust/src/old_/directory_list.rs
al => self.version.partial_cmp(&other.version),
ordering => Some(ordering)
}
}
}
impl Eq for Slice {
}
impl Ord for Slice {
fn cmp(&self, other: &Self) -> Ordering {
match self.name.cmp(&other.name) {
Ordering::Equa... | code_fim | hard | {
"lang": "rust",
"repo": "slicebuild/sb",
"path": "/impl/rust/src/old_/directory_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let buffer = r#"
{
"uuid": "9a49c47d-29e9-4072-be84-3b76c6814743",
}
"#;
let _ = Pattern::from_json(buffer)
.err()
.expect("We created a Pattern without the pattern field");
}
#[test]
fn test_given_json_pattern_when_it_does_not_have_a_name_it_can_be_successfully... | code_fim | hard | {
"lang": "rust",
"repo": "ihrwein/actiondb",
"path": "/src/matcher/pattern/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ihrwein/actiondb path: /src/matcher/pattern/test.rs
use super::Pattern;
use uuid::Uuid;
#[test]
fn test_given_json_document_when_it_does_not_contain_errors_then_pattern_can_be_created_from_it
() {
... | code_fim | hard | {
"lang": "rust",
"repo": "ihrwein/actiondb",
"path": "/src/matcher/pattern/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
max_settings(
&(0..=4),
read_prog(
&"3,23,3,24,1002,24,10,24,1002,23,-1,23,101,5,23,23,1,24,23,23,4,23,99,0,0"
)
),
54321
);
}
#[test]
fn part2_test1() {
... | code_fim | hard | {
"lang": "rust",
"repo": "peterwmwong/aoc2019",
"path": "/d7/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peterwmwong/aoc2019 path: /d7/src/main.rs
use std::cmp::max;
use std::fs::read_to_string;
use std::ops::RangeBounds;
use std::ops::{Add, Mul};
const DEBUG: bool = true;
const NUM_OF_AMPS: usize = 5;
const MAX_AMP_INDEX: usize = NUM_OF_AMPS - 1;
type Opcode = isize;
type Prog = Vec<isize>;
type... | code_fim | hard | {
"lang": "rust",
"repo": "peterwmwong/aoc2019",
"path": "/d7/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t_state = stg.vertex(&ArrayBitVector::from(vec![true, true]));
let f_state = stg.vertex(&ArrayBitVector::from(vec![false, false]));
let sinks = t_state.union(&f_state);
let sink_colors = AsymptoticBehaviour::check_stability(&stg, &sinks);
assert_symbolic_eq!(si... | code_fim | hard | {
"lang": "rust",
"repo": "sybila/biodivine-aeon-server",
"path": "/src/algorithms/asymptotic_behaviour.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stg = SymbolicAsyncGraph::new(bn).unwrap();
let all_colors = stg.mk_unit_colors();
let t_state = stg.vertex(&ArrayBitVector::from(vec![true, true]));
let f_state = stg.vertex(&ArrayBitVector::from(vec![false, false]));
let sinks = t_state.union(&f_state);
... | code_fim | hard | {
"lang": "rust",
"repo": "sybila/biodivine-aeon-server",
"path": "/src/algorithms/asymptotic_behaviour.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sybila/biodivine-aeon-server path: /src/algorithms/asymptotic_behaviour.rs
of the given `SymbolicAsyncGraph`.
fn new(stg: &SymbolicAsyncGraph) -> AsymptoticBehaviourMap {
AsymptoticBehaviourMap([
stg.mk_empty_colors(),
stg.mk_empty_colors(),
stg.m... | code_fim | hard | {
"lang": "rust",
"repo": "sybila/biodivine-aeon-server",
"path": "/src/algorithms/asymptotic_behaviour.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joeldevahl/frienduro path: /src/bin/test.rs
extern crate frienduro;
extern crate getopts;
extern crate postgis;
extern crate postgres;
use self::frienduro::*;
use getopts::Options;
use std::env;
use std::fs;
use std::path::Path;
fn print_usage(program: &str, opts: Options) {
let brief = fo... | code_fim | hard | {
"lang": "rust",
"repo": "joeldevahl/frienduro",
"path": "/src/bin/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filename = user_path.to_str().unwrap();
let gpx_data = read_whole_file(filename).unwrap();
let gpx = read_gpx(&gpx_data).unwrap();
let track = &gpx.tracks[0];
let segment = &track.segments[0];
let points = ... | code_fim | hard | {
"lang": "rust",
"repo": "joeldevahl/frienduro",
"path": "/src/bin/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let event_path = Path::new(&event_dir);
let event_name = event_path.file_name().unwrap().to_str().unwrap();
println!("Processing event: {}", event_name);
let segments_path = event_path.join("segments");
let segment_files = fs::read_dir(segments_path).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "joeldevahl/frienduro",
"path": "/src/bin/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let start = it.start_pos("operation")?;
macro_rules! un_op {
($it:expr, $fun:path, $tok:ident, $ast:ident, $msg:expr) => {{
let factor = $it.parse(&$fun, $msg, &start)?;
let node = Node::$ast { expr: factor.clone() };
Ok(Box::from(AST::new(&start.union(&... | code_fim | hard | {
"lang": "rust",
"repo": "duzhanyuan/mamba",
"path": "/src/parse/operation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duzhanyuan/mamba path: /src/parse/operation.rs
use crate::lex::token::Token;
use crate::parse::ast::Node;
use crate::parse::ast::AST;
use crate::parse::expression::parse_inner_expression;
use crate::parse::iterator::LexIterator;
use crate::parse::result::ParseResult;
macro_rules! inner_bin_op {... | code_fim | hard | {
"lang": "rust",
"repo": "duzhanyuan/mamba",
"path": "/src/parse/operation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use bip39;
pub use validator_path::{KeyType, ValidatorPath, COIN_TYPE, PURPOSE};
pub use wallet::{
recover_validator_secret, recover_validator_secret_from_mnemonic, DerivedKey, Error,
KeystoreError, PlainText, Uuid, ValidatorKeystores, Wallet, WalletBuilder,
};<|fim_prefix|>// repo: sigp/light... | code_fim | easy | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/crypto/eth2_wallet/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigp/lighthouse path: /crypto/eth2_wallet/src/lib.rs
mod validator_path;
mod wallet;
<|fim_suffix|>pub use bip39;
pub use validator_path::{KeyType, ValidatorPath, COIN_TYPE, PURPOSE};
pub use wallet::{
recover_validator_secret, recover_validator_secret_from_mnemonic, DerivedKey, Error,
... | code_fim | easy | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/crypto/eth2_wallet/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match i32_sacola.item {
Some(v) => println!("encontrei {}, na sacola",),
None => println!("não há nada na sacola"),
}
}<|fim_prefix|>// repo: jefersondeff/tourofrust path: /cap_4/35.rs
struct Sacola<T> {
item: Option<T>,
}
fn main() {
let i32_sacola = Sacola::<i32> { item... | code_fim | medium | {
"lang": "rust",
"repo": "jefersondeff/tourofrust",
"path": "/cap_4/35.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jefersondeff/tourofrust path: /cap_4/35.rs
struct Sacola<T> {
item: Option<T>,
}
fn main() {
let i32_sacola = Sacola::<i32> { item: None };
if i32_sacola.item.is_none() {
println!("não há nada na sacola")
} else {
println!("tem alguma coisa na sacola")
}
<|f... | code_fim | medium | {
"lang": "rust",
"repo": "jefersondeff/tourofrust",
"path": "/cap_4/35.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let loc = Arc::new(Mutex::new(None));
let hook = panic::take_hook();
{
let loc = loc.clone();
panic::set_hook(Box::new(move |info| {
*loc.lock().unwrap() = info.location().map(|loc| loc.line())
}));
}
panic::catch_unwind(f).unwrap_err();
panic::... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/async-await/track-caller/panic-track-caller.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/async-await/track-caller/panic-track-caller.rs
// run-pass
// edition:2021
// revisions: afn cls nofeat
// needs-unwind
// gate-test-async_fn_track_caller
#![feature(async_closure, stmt_expr_attributes)]
#![cfg_attr(afn, feature(async_fn_track_caller))]
#![cfg_attr... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/async-await/track-caller/panic-track-caller.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Foo {
#[track_caller]
//[cls]~^ WARN `#[track_caller]` on async functions is a no-op
//[nofeat]~^^ WARN `#[track_caller]` on async functions is a no-op
async fn bar_assoc() {
panic!();
}
}
async fn foo_assoc() {
Foo::bar_assoc().await
}
// Since compilation is expect... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/async-await/track-caller/panic-track-caller.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pereiro/hl21 path: /src/context.rs
use crate::config::Config;
use crate::model::{License, MoneyList, Tile};
use async_std::channel::{bounded, unbounded};
use async_std::channel::{Receiver, Sender};
use core::num::NonZeroU32;
use governor::clock::DefaultClock;
use governor::state::{InMemoryState,... | code_fim | hard | {
"lang": "rust",
"repo": "pereiro/hl21",
"path": "/src/context.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let square = size_x * size_y;
m.explore_price = if square == 0 {
0.0
} else if square < 4 {
0.5
} else if square < 8 {
1.0
} else if square < 16 {
1.5
} else if square < 32 {
2.0
} else if s... | code_fim | hard | {
"lang": "rust",
"repo": "pereiro/hl21",
"path": "/src/context.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: notomo/vimonga path: /src/domain/repository/database.rs
use super::error::RepositoryError;
<|fim_suffix|> fn drop(&self, database_name: &str) -> Result<(), RepositoryError>;
}<|fim_middle|>pub trait DatabaseRepository {
fn get_names(&self) -> Result<Vec<String>, RepositoryError>;
| code_fim | medium | {
"lang": "rust",
"repo": "notomo/vimonga",
"path": "/src/domain/repository/database.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn drop(&self, database_name: &str) -> Result<(), RepositoryError>;
}<|fim_prefix|>// repo: notomo/vimonga path: /src/domain/repository/database.rs
use super::error::RepositoryError;
<|fim_middle|>pub trait DatabaseRepository {
fn get_names(&self) -> Result<Vec<String>, RepositoryError>;
| code_fim | medium | {
"lang": "rust",
"repo": "notomo/vimonga",
"path": "/src/domain/repository/database.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::ops::{Index, IndexMut};
#[derive(Clone, PartialEq, Eq, Debug, $($mapderives,)*)]
pub struct Map<T> {
m_at : [T; $enumname::SIZE],
}
impl<T> Index<$enumname> for Map<T> {
type Ou... | code_fim | hard | {
"lang": "rust",
"repo": "ssk97/Chronox",
"path": "/src/plain_enum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::from_usize(u % Self::SIZE)
}
fn wrapped_difference(self, e_other: Self) -> usize {
(self.to_usize() + Self::SIZE - e_other.to_usize()) % Self::SIZE
}
fn to_usize(self) -> u... | code_fim | hard | {
"lang": "rust",
"repo": "ssk97/Chronox",
"path": "/src/plain_enum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ssk97/Chronox path: /src/plain_enum.rs
//! This crate offers some tools to deal with static enums. It offers a way to declare a simple
//! enum, which then offers e.g. `values()` which can be used to iterate over the values of the enum.
//! In addition, it offers a type `EnumMap` which is an arr... | code_fim | hard | {
"lang": "rust",
"repo": "ssk97/Chronox",
"path": "/src/plain_enum.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("Merge::clone: cloned {:?} to {:?}", state, new_index);
new_index
}
fn patch_links(
&mut self,
predecessor: StateIndex,
original_successor: StateIndex,
cloned_successor: StateIndex,
) {
let replace = |target_state: &mut StateIndex... | code_fim | hard | {
"lang": "rust",
"repo": "lalrpop/lalrpop",
"path": "/lalrpop/src/lr1/lane_table/construct/merge.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lalrpop/lalrpop path: /lalrpop/src/lr1/lane_table/construct/merge.rs
use crate::collections::{Map, Multimap, Set};
use crate::lr1::core::{Action, Lr1State, StateIndex};
use crate::lr1::lane_table::construct::state_set::StateSet;
use crate::lr1::lane_table::table::context_set::ContextSet;
use cra... | code_fim | hard | {
"lang": "rust",
"repo": "lalrpop/lalrpop",
"path": "/lalrpop/src/lr1/lane_table/construct/merge.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // create a new unify key for this new state
let context_set = self.table.context_set(original_index).unwrap();
self.context_sets.new_state(new_index, context_set);
// keep track of the clones of the target state
if original_index == self.target_states[0] {
... | code_fim | hard | {
"lang": "rust",
"repo": "lalrpop/lalrpop",
"path": "/lalrpop/src/lr1/lane_table/construct/merge.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut a = BytesMut::from(LONG);
assert_eq!(LONG, a);
let b = a.split_to(1);
assert_eq!(LONG[1..], a);
drop(b);
let mut a = BytesVec::copy_from_slice(LONG);
assert_eq!(LONG, a);
let b = a.split_to(1);
assert_eq!(LONG[1..], a);
drop(b);
}
#[cfg(not(target_os =... | code_fim | hard | {
"lang": "rust",
"repo": "ntex-rs/ntex",
"path": "/ntex-bytes/tests/test_bytes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ntex-rs/ntex path: /ntex-bytes/tests/test_bytes.rs
assert!(a.is_inline());
let mut a = BytesVec::copy_from_slice(vec![b'*'; 35]).freeze();
let b = a.split_to(8);
assert!(b.is_inline());
}
#[test]
fn index() {
let a = Bytes::from(&b"hello world"[..]);
assert_eq!(a[0..5], *... | code_fim | hard | {
"lang": "rust",
"repo": "ntex-rs/ntex",
"path": "/ntex-bytes/tests/test_bytes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bytes = BytesMut::with_capacity(1000);
bytes.split();
// now bytes is Arc and refcount == 1
assert_eq!(1024, bytes.capacity());
bytes.reserve(1025);
assert_eq!(1056, bytes.capacity());
}
#[test]
fn reserve_in_arc_nonunique_does_not_overallocate() {
let mut bytes = By... | code_fim | hard | {
"lang": "rust",
"repo": "ntex-rs/ntex",
"path": "/ntex-bytes/tests/test_bytes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ogrisel/tract path: /core/src/ops/array/concat.rs
use ndarray::*;
use crate::ops::prelude::*;
#[derive(Debug, Clone, new)]
pub struct Concat {
axis: usize,
}
impl Concat {
/// Evaluates the operation given the input tensors.
fn eval_t<T: Datum>(&self, inputs: TVec<SharedTensor>) -... | code_fim | hard | {
"lang": "rust",
"repo": "ogrisel/tract",
"path": "/core/src/ops/array/concat.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &'s self,
s: &mut Solver<'r>,
inputs: &'p SharedTensorsProxy,
outputs: &'p SharedTensorsProxy,
) -> InferenceResult {
s.equals(&outputs.len, 1)?;
s.equals(&outputs[0].datum_type, &inputs[0].datum_type)?;
s.equals(&outputs[0].rank, &inputs[0].rank... | code_fim | hard | {
"lang": "rust",
"repo": "ogrisel/tract",
"path": "/core/src/ops/array/concat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joho-stop/mars-trie path: /src/entry.rs
use std;
use std::cmp::Ordering;
use iter_util::common_count_eq;
pub struct Entry<'a> {
slice_: &'a [u8],
id_: u32,
}
impl<'a> Entry<'a> {
pub fn new(slice: &'a [u8], id: u32) -> Entry<'a> {
Entry { slice_: slice, id_: id }
}
... | code_fim | medium | {
"lang": "rust",
"repo": "joho-stop/mars-trie",
"path": "/src/entry.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.iter()
}
}
pub fn cmp_slice(l: &Entry, r: &Entry) -> Ordering {
l.slice_.cmp(&r.slice_)
}
pub fn cmp_id(l: &Entry, r: &Entry) -> Ordering {
l.id_.cmp(&r.id_)
}<|fim_prefix|>// repo: joho-stop/mars-trie path: /src/entry.rs
use std;
use std::cmp::Ordering;
use iter_util::common_c... | code_fim | hard | {
"lang": "rust",
"repo": "joho-stop/mars-trie",
"path": "/src/entry.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/iot-identity-service path: /tpm/tss-minimal/types-sys/build.rs
// Copyright (c) Microsoft. All rights reserved.
#![deny(rust_2018_idioms)]
#![warn(clippy::all, clippy::pedantic)]
use std::io::Write;
fn main() {
println!("cargo:rerun-if-changed=wrapper.h.in");
println!("cargo:rer... | code_fim | medium | {
"lang": "rust",
"repo": "Azure/iot-identity-service",
"path": "/tpm/tss-minimal/types-sys/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for path in &lib_cfg.include_paths {
let output = std::process::Command::new("./const_define.sh")
.arg(path)
.arg("TPM2_ALG:TPM2_ALG_ID,TPM2_ECC:TPM2_ECC_CURVE,TPM2_HR:TPM2_HC,TPM2_SE,TPMA_OBJECT,TPMA_SESSION")
.stderr(std::process::Stdio::inherit())
... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/iot-identity-service",
"path": "/tpm/tss-minimal/types-sys/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_empty(&self) -> NapiResult<bool> {
self.len().map(|l| l == 0)
}
pub fn get(&self, index: u32) -> NapiResult<NapiAny<'env>> {
self.as_napi_object().get_element(index)
}
pub fn set<T>(&self, index: u32, value: &T) -> NapiResult<()>
where
T: NapiVal... | code_fim | hard | {
"lang": "rust",
"repo": "amilajack/napi",
"path": "/napi/src/value/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amilajack/napi path: /napi/src/value/array.rs
use std::ptr;
use env::NapiEnv;
use result::{NapiError, NapiResult};
use sys;
use super::{AsNapiObject, NapiAny, NapiString, NapiValue, NapiValueInternal};
#[derive(Clone, Copy, Debug)]
pub struct NapiArray<'env> {
value: sys::napi_value,
... | code_fim | hard | {
"lang": "rust",
"repo": "amilajack/napi",
"path": "/napi/src/value/array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(result)
}
pub fn is_empty(&self) -> NapiResult<bool> {
self.len().map(|l| l == 0)
}
pub fn get(&self, index: u32) -> NapiResult<NapiAny<'env>> {
self.as_napi_object().get_element(index)
}
pub fn set<T>(&self, index: u32, value: &T) -> NapiResult<()>
... | code_fim | hard | {
"lang": "rust",
"repo": "amilajack/napi",
"path": "/napi/src/value/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sanbox-irl/bit-bots path: /src/tick_structs/discord_rpc.rs
use discord_game_sdk::{Activity, Discord};
use std::ffi::CString;
use std::time::SystemTime;
pub struct DiscordSDK<'a> {
discord: Discord<'a>,
}
impl<'a> DiscordSDK<'a> {
const CLIENT_ID: i64 = 646882722068824074;
const LAR... | code_fim | hard | {
"lang": "rust",
"repo": "sanbox-irl/bit-bots",
"path": "/src/tick_structs/discord_rpc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(DiscordSDK { discord })
}
pub fn run(&mut self) {
self.discord.empty_event_receivers();
if let Err(e) = self.discord.run_callbacks() {
log_once::error_once!("DiscordSDK Error on Callbacks: {}", e);
}
}
}<|fim_prefix|>// repo: sanbox-irl/bit-bots... | code_fim | hard | {
"lang": "rust",
"repo": "sanbox-irl/bit-bots",
"path": "/src/tick_structs/discord_rpc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpcsdk/rust.cpclib path: /cpclib-asm/src/assembler/mod.rs
(exp.as_ref().map(|v| v.as_slice())),
Token::Repeat(..) => {
panic!("Should never be called")
}
Token::Run(address, gate_array) => env.visit_run(address, gate_array.as_ref()),
Token::Rorg(ref _e... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-asm/src/assembler/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpcsdk/rust.cpclib path: /cpclib-asm/src/assembler/mod.rs
_res_or_set(
mnemonic,
arg1.as_ref().unwrap(),
arg2.as_ref().unwrap(),
arg3.as_ref(),
env
)
}
Mnemonic::Ret => assemble_ret(arg1),... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-asm/src/assembler/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.included_paths.insert(path);
}
}
/// Error handling
impl Env {
/// If the error has not been raised at the previous pass, store it and do not propagate it. Otherwise, propagate it
pub fn add_error_discardable_one_pass(
&mut self,
e: AssemblerError
) -> Result<... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-asm/src/assembler/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn assemble(&mut self, input: &str, output: &str) {
print!("input: {}, output: {}", input, output);
}
}<|fim_prefix|>// repo: Syphonx/qcpu-rust path: /src/assembler/mod.rs
pub struct Assembler {}
<|fim_middle|>impl Assembler {
pub fn new() -> Assembler {
Assembler ... | code_fim | medium | {
"lang": "rust",
"repo": "Syphonx/qcpu-rust",
"path": "/src/assembler/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Syphonx/qcpu-rust path: /src/assembler/mod.rs
pub struct Assembler {}
<|fim_suffix|> pub fn assemble(&mut self, input: &str, output: &str) {
print!("input: {}, output: {}", input, output);
}
}<|fim_middle|>impl Assembler {
pub fn new() -> Assembler {
Assembler ... | code_fim | medium | {
"lang": "rust",
"repo": "Syphonx/qcpu-rust",
"path": "/src/assembler/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ToonSpin/adventofcode-2019-rust path: /src/bin/day01.rs
use std::io;
use std::io::prelude::*;
fn get_fuel(mass: i32) -> i32 {
mass / 3 - 2
}
<|fim_suffix|> let input: Vec<i32> = input
.split("\n")
.filter(|l| *l != "")
.map(|s| s.parse::<i32>().unwrap())
... | code_fim | hard | {
"lang": "rust",
"repo": "ToonSpin/adventofcode-2019-rust",
"path": "/src/bin/day01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input: Vec<i32> = input
.split("\n")
.filter(|l| *l != "")
.map(|s| s.parse::<i32>().unwrap())
.collect();
let sum: i32 = input.iter().map(|i| get_fuel(*i)).sum();
println!("The fuel required: {}", sum);
let sum: i32 = input.iter().map(|i| get_fuel_par... | code_fim | medium | {
"lang": "rust",
"repo": "ToonSpin/adventofcode-2019-rust",
"path": "/src/bin/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mucaho/shipyard path: /tests/workload/non_send_sync.rs
use shipyard::*;
use std::cell::RefCell;
use std::rc::Rc;
#[test]
fn basic() {
fn push(vecs: NonSendSync<View<Rc<RefCell<Vec<u32>>>>>) {
<|fim_suffix|> world
.run(
|mut entities: EntitiesViewMut,
mut ... | code_fim | medium | {
"lang": "rust",
"repo": "mucaho/shipyard",
"path": "/tests/workload/non_send_sync.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> world
.run(|vecs: NonSendSync<ViewMut<Rc<RefCell<Vec<u32>>>>>| {
assert_eq!(&**vecs.iter().next().unwrap().borrow(), &[0][..]);
})
.unwrap();
}<|fim_prefix|>// repo: mucaho/shipyard path: /tests/workload/non_send_sync.rs
use shipyard::*;
use std::cell::RefCell;
use... | code_fim | medium | {
"lang": "rust",
"repo": "mucaho/shipyard",
"path": "/tests/workload/non_send_sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sig = G1Affine::deserialize(&mut Cursor::new(hex::decode("d5499efe8cdaeb4f43f917671504de242f23444a8a391de130afac4d7bff6da14067fe172f9b532189ad608e79acf498").unwrap()));
let m = b"huitseeker";
verify(pk, m, sig.unwrap());
}<|fim_prefix|>// repo: huitseeker/zkhack-bls-pedersen path: /src/bi... | code_fim | hard | {
"lang": "rust",
"repo": "huitseeker/zkhack-bls-pedersen",
"path": "/src/bin/verify-bls-pedersen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huitseeker/zkhack-bls-pedersen path: /src/bin/verify-bls-pedersen.rs
use bls_pedersen::bls::verify;
use bls_pedersen::data::puzzle_data;
use bls_pedersen::PUZZLE_DESCRIPTION;
use prompt::{puzzle, welcome};
<|fim_suffix|>fn main() {
welcome();
puzzle(PUZZLE_DESCRIPTION);
let (pk, ms,... | code_fim | medium | {
"lang": "rust",
"repo": "huitseeker/zkhack-bls-pedersen",
"path": "/src/bin/verify-bls-pedersen.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This will receive events each time something happens
match event {
WatchEvent::Added(book) => {
info!("Added a book {} with title '{}'", book.metadata.name, book.spec.title);
},
WatchEvent::Deleted(book) => {
info!("Deleted a book {}", book.metada... | code_fim | hard | {
"lang": "rust",
"repo": "nbrandaleone/rust-controller",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nbrandaleone/rust-controller path: /src/main.rs
#[macro_use]
extern crate serde_derive;
extern crate log;
extern crate simple_logger;
use futures::StreamExt;
use kube::{
api::{Object, Void, RawApi, Informer, WatchEvent},
client::APIClient,
config,
};
use log::{info, warn};
// This ... | code_fim | hard | {
"lang": "rust",
"repo": "nbrandaleone/rust-controller",
"path": "/src/main.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.