text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> #[test]
fn test_calculate_when_two_events() {
let end_period = DateTime::parse_from_rfc3339("2021-02-02T02:02:00-00:00")
.unwrap()
.with_timezone(&Utc);
let metadata = DataPointMetadata::new(Period::new(PeriodUnit::Days, 1), end_period);
let screen_r... | code_fim | hard | {
"lang": "rust",
"repo": "r2gnl/xaynet",
"path": "/rust/xaynet-analytics/src/data_combination/data_points/screen_enter_count.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub static MAX_NUM_DEVICES: u8 = 50;
//
// Modem Status Flags
//
// #define MS_CTS_ON ((DWORD)0x0010)
// #define MS_DSR_ON ((DWORD)0x0020)
// #define MS_RING_ON ((DWORD)0x0040)
// #define MS_RLSD_ON ((DWORD)0x0080)
//
// Error Flags
//
// #define CE_RXOVER ... | code_fim | hard | {
"lang": "rust",
"repo": "masche842/rust-ftd2xx",
"path": "/src/constants.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: masche842/rust-ftd2xx path: /src/constants.rs
///
/// FTDI D2XX Driver Constants
/// as defined in ftd2xx.h
///
/// Implements "Show" trait for FT_STATUS
/// in order to format Errors nicely
///
extern crate core;
use core::fmt;
use typedefs::*;
#[allow(dead_code)]
#[allow(non_camel_case_types... | code_fim | hard | {
"lang": "rust",
"repo": "masche842/rust-ftd2xx",
"path": "/src/constants.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//
// Bit Modes
//
pub static FT_BITMODE_RESET: u8 = 0x00;
pub static FT_BITMODE_ASYNC_BITBANG: u8 = 0x01;
pub static FT_BITMODE_MPSSE: u8 = 0x02;
pub static FT_BITMODE_SYNC_BITBANG: u8 = 0x04;
pub static FT_BITMODE_MCU_HOST: u8 = 0x08;
pub static FT_BITMODE_FAST_SERIAL: u8 ... | code_fim | hard | {
"lang": "rust",
"repo": "masche842/rust-ftd2xx",
"path": "/src/constants.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: salman079/rust path: /chap_9/recoverable_error/src/main.rs
use std::fs::File;
fn main() {
<|fim_suffix|> let o = match f {
Result::Ok(T) => println!("file mil gaee hai "),
Result::Err(E) => {
panic!("File nahee milee");
},
};
}<|fim_middle|> let f =... | code_fim | easy | {
"lang": "rust",
"repo": "salman079/rust",
"path": "/chap_9/recoverable_error/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let o = match f {
Result::Ok(T) => println!("file mil gaee hai "),
Result::Err(E) => {
panic!("File nahee milee");
},
};
}<|fim_prefix|>// repo: salman079/rust path: /chap_9/recoverable_error/src/main.rs
use std::fs::File;
fn main() {
<|fim_middle|> let f =... | code_fim | easy | {
"lang": "rust",
"repo": "salman079/rust",
"path": "/chap_9/recoverable_error/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: addityasingh/sknife path: /src/collection/flatmap.rs
#![crate_name = "sknife"]
/// Flatten and map on a list
///
/// # Arguments
///
/// * `f` - the map function
/// * `list` - A slice of elements to flatten and map
///
/// # Example
///
/// ```
/// use sknife::collection::flatmap;
/// let mut ... | code_fim | medium | {
"lang": "rust",
"repo": "addityasingh/sknife",
"path": "/src/collection/flatmap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut list: Vec<i32> = (1..4).collect();
let slice: &mut [i32] = list.as_mut_slice();
assert_eq!(
flatmap(slice, |x: &mut i32| vec![*x]),
vec![1, 2, 3]
);
}
}<|fim_prefix|>// repo: addityasingh/sknife path: /src/collection/flatmap.rs
#![crate_... | code_fim | medium | {
"lang": "rust",
"repo": "addityasingh/sknife",
"path": "/src/collection/flatmap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b = Ballot(5, 0);
assert!(Ballot(2, 0).lt(&b));
assert!(Ballot(8, 0).gt(&b));
assert_eq!(Ballot(5, 0), b);
assert!(b.ge(&b));
assert!(b.le(&b));
assert!(Ballot(5, 1).gt(&b));
}
#[test]
fn quorumset() {
let mut qs = QuorumSet:... | code_fim | hard | {
"lang": "rust",
"repo": "qdequele/paxos-rs",
"path": "/src/paxos/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> qs.remove(5);
assert!(!qs.contains(5));
assert!(qs.contains(7));
assert!(qs.contains(2));
assert!(qs.contains(6));
assert!(!qs.has_quorum());
assert!(!qs.is_empty());
assert_eq!(&[Some(2), Some(6), Some(7), None], qs.values.as_ref());
... | code_fim | hard | {
"lang": "rust",
"repo": "qdequele/paxos-rs",
"path": "/src/paxos/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qdequele/paxos-rs path: /src/paxos/mod.rs
mod instance;
mod messages;
pub use self::instance::PaxosInstance;
pub use self::messages::*;
use config::NodeId;
use std::cmp::Ordering;
/// Ballot numbering is an increasing number in order to order proposals
/// across multiple nodes. Ballots are un... | code_fim | hard | {
"lang": "rust",
"repo": "qdequele/paxos-rs",
"path": "/src/paxos/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromAttributes for Polyline{
fn from_attributes(
attributes: std::collections::HashMap<String, svg::node::Value>,
) -> Result<Self, crate::DocumentError> {
Ok(Polyline {
stroke: {
let color: &str = attributes
.get("stroke")
... | code_fim | hard | {
"lang": "rust",
"repo": "ModProg/SVGNotesLib",
"path": "/src/elements/polygon.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ModProg/SVGNotesLib path: /src/elements/polygon.rs
use std::fmt;
use std::str::FromStr;
use svg::node::element;
use DocumentError::InvalidAttribute;
use DocumentError::InvalidPoint;
use DocumentError::MissingAttribute;
use crate::colors::Color;
use crate::elems_eq;
use crate::DocumentError;
u... | code_fim | hard | {
"lang": "rust",
"repo": "ModProg/SVGNotesLib",
"path": "/src/elements/polygon.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Drakota/dns-rs path: /crates/server/src/main.rs
mod cli;
mod root_servers;
mod traits;
use clap::Clap;
use cli::Opts;
use parser::header::flags::{DnsHeaderFlags, ReplyCode};
use parser::packet::DnsPacket;
use parser::resources::query::DnsQuery;
use parser::resources::record::DnsRecord;
use pars... | code_fim | hard | {
"lang": "rust",
"repo": "Drakota/dns-rs",
"path": "/crates/server/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let mut buffer = [0; 512];
let (size, src) = socket.recv_from(&mut buffer)?;
if opts.verbose {
println!("{} bytes received from {}", size, src);
}
let request = match DnsPacket::parse(&buffer[..size]) {
Ok(packet) => packet,
... | code_fim | hard | {
"lang": "rust",
"repo": "Drakota/dns-rs",
"path": "/crates/server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> type Request = ();
type Response = ();
type Future = Box<Future<Item = (), Error = Error>>;
}
impl<T: DeleteRelated<R>, R: Relationship> ResourceMethod<T> for DeleteRelated<R, Identifier = T::Identifier> {
fn call(id: T::Identifier, _: Self::Request, env: Environment) -> Self::Future {
... | code_fim | hard | {
"lang": "rust",
"repo": "skade/cargonauts",
"path": "/src/mainsail/src/methods/delete_related.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skade/cargonauts path: /src/mainsail/src/methods/delete_related.rs
use futures::Future;
use rigging::{Error, http};
use rigging::resource::{Relationship, Resource};
use rigging::method::{ResourceMethod, Method};
use rigging::environment::Environment;
use rigging::routes::{Route, Kind};
<|fim_s... | code_fim | hard | {
"lang": "rust",
"repo": "skade/cargonauts",
"path": "/src/mainsail/src/methods/delete_related.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makepad/glui path: /src/cxdrawing.rs
use crate::math::*;
use crate::shader::*;
use crate::cx::*;
use crate::cxshaders::*;
pub enum Ev{
Redraw,
Animate,
FingerMove{x:f32, y:f32},
FingerDown{x:f32, y:f32},
FingerUp{x:f32, y:f32},
}
#[derive(Clone, Default)]
pub struct CxDrawi... | code_fim | hard | {
"lang": "rust",
"repo": "makepad/glui",
"path": "/src/cxdrawing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn uvec3(&mut self, _name: &str, v:&Vec3){
self.uniforms.push(v.x);
self.uniforms.push(v.y);
self.uniforms.push(v.z);
}
pub fn uvec4(&mut self, _name: &str, v:&Vec4){
self.uniforms.push(v.x);
self.uniforms.push(v.y);
self.uniforms.push(v.z);... | code_fim | hard | {
"lang": "rust",
"repo": "makepad/glui",
"path": "/src/cxdrawing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = fs::read_to_string("input/day10").unwrap();
let asteroids = parse_asteroids(&input);
let ans = find_station(&asteroids);
assert_eq!(ans.1, 280);
let base = ans.0;
let ans2 = shoot_asteroids(base, asteroids, 200);
assert_eq!(ans2, (7, 6));... | code_fim | hard | {
"lang": "rust",
"repo": "kalleakerblom/AdventOfCode2019",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::find_station;
use super::parse_asteroids;
use super::shoot_asteroids;
use std::fs;
#[test]
fn day10_part1_and_2() {
let input = fs::read_to_string("input/day10").unwrap();
let asteroids = parse_asteroids(&input);
let ans =... | code_fim | hard | {
"lang": "rust",
"repo": "kalleakerblom/AdventOfCode2019",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kalleakerblom/AdventOfCode2019 path: /src/day10.rs
use num::integer::gcd;
use std::collections::HashMap;
use std::collections::HashSet;
fn parse_asteroids(input: &str) -> HashSet<(i32, i32)> {
let mut map = HashSet::new();
for (y, line) in input.lines().enumerate() {
for (x, c) i... | code_fim | hard | {
"lang": "rust",
"repo": "kalleakerblom/AdventOfCode2019",
"path": "/src/day10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffered = BufReader::with_capacity(buf_sz, Cursor::new(&mut source));
let mut sink = WriteObserver { observed_buffer: 0 };
assert_eq!(crate::io::copy(&mut buffered, &mut sink).unwrap(), source.len() as u64);
assert_eq!(
sink.observed_buffer, buf_sz,
"expected a lar... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/library/std/src/io/copy/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /library/std/src/io/copy/tests.rs
use crate::cmp::{max, min};
use crate::collections::VecDeque;
use crate::io;
use crate::io::*;
#[test]
fn copy_copies() {
let mut r = repeat(0).take(4);
let mut w = sink();
assert_eq!(copy(&mut r, &mut w).unwrap(), 4);
let ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/library/std/src/io/copy/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use test::Bencher;
#[bench]
fn bench_copy_buf_reader(b: &mut Bencher) {
let mut file_in = File::open("/dev/zero").expect("opening /dev/zero failed");
// use dyn to avoid specializations unrelated to readbuf
let dyn_in = &mut file_in as &mut dyn Read;
let mut re... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/library/std/src/io/copy/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Hello, world!");
println!("Value of quarter: {}", value_in_cents(Coin::Quarter(UsState::California)));
let some_u8_value = 3u8;
match some_u8_value {
1 => println!("one"),
3 => println!("three"),
5 => println!("five"),
7 => println!("seven"),
... | code_fim | medium | {
"lang": "rust",
"repo": "abissell/rust-programming-language",
"path": "/ch-6/enums/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abissell/rust-programming-language path: /ch-6/enums/src/main.rs
#![allow(dead_code)]
#[derive(Debug)]
enum UsState {
California,
Montana,
Washington,
}
enum Coin {
Penny,
Nickel,
Dime,
Quarter(UsState),
}
<|fim_suffix|>fn main() {
println!("Hello, world!");
... | code_fim | medium | {
"lang": "rust",
"repo": "abissell/rust-programming-language",
"path": "/ch-6/enums/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: t-smirnov/xi-editor path: /rust/core-lib/src/plugins/manifest.rs
// Copyright 2017 Google Inc. All rights reserved.
//
// 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... | code_fim | hard | {
"lang": "rust",
"repo": "t-smirnov/xi-editor",
"path": "/rust/core-lib/src/plugins/manifest.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Describes attributes and capabilities of a plugin.
///
/// Note: - these will eventually be loaded from manifest files.
#[derive(Debug, Clone)]
pub struct PluginDescription {
pub name: String,
pub version: String,
//scope: PluginScope,
// more metadata ...
/// path to plugin execut... | code_fim | hard | {
"lang": "rust",
"repo": "t-smirnov/xi-editor",
"path": "/rust/core-lib/src/plugins/manifest.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![
PluginDescription::new("syntect", "0.0", make_path("xi-syntect-plugin"),
vec![Autorun]),
PluginDescription::new("braces", "0.0", make_path("bracket_example.py"),
Vec::new()),
PluginDescription::new("spellcheck", "0.0", make_path("spellcheck.py"),
V... | code_fim | hard | {
"lang": "rust",
"repo": "t-smirnov/xi-editor",
"path": "/rust/core-lib/src/plugins/manifest.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(binexp(3, 21), vec![10460353203, 59049, 243, 9, 3, 1]);
assert_eq!(binexp(1000, 0), vec![1]);
assert_eq!(binexp(2, 15), vec![32768, 128, 8, 2, 1]);
assert_eq!(
binexp(1, 40000),
vec![1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
);
assert_eq!(binexp(... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/codegolf/implement-binary-exponentiation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Task
Notice how at each step in the example above, we have a value which resulted from reducing the original number. Your task is to return a list of these numbers, given a non-zero integer base x != -1 and a non-negative integer exponent n.
The list should always contain the initial value as the first el... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/codegolf/implement-binary-exponentiation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qeedquan/challenges path: /codegolf/implement-binary-exponentiation.rs
/*
Background
In programming, there is a recursive algorithm called binary exponentiation, which allows for large integer powers to be calculated in a faster way. Given a non-zero base x and a non-negative exponent n, the al... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/codegolf/implement-binary-exponentiation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guydunton/rust-gb path: /src/gameboy/tests/add_test.rs
use crate::{
gameboy::{
cpu::CPU,
memory_adapter::MemoryAdapter,
opcodes::{Argument, Category},
read_flag,
tests::decode_util::decode,
Flags, OpCode, RegisterLabel16, RegisterLabel8,
},... | code_fim | hard | {
"lang": "rust",
"repo": "guydunton/rust-gb",
"path": "/src/gameboy/tests/add_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cycles = opcode.run(&mut cpu, MemoryAdapter::new(&mut memory));
assert_eq!(cpu.read_8_bits(RegisterLabel8::A), 0x06);
assert_eq!(cpu.read_16_bits(RegisterLabel16::ProgramCounter), 0x02);
assert_eq!(cycles, 8);
}
#[test]
fn decode_add_instructions() {
let add_a_r8 = |register| {
... | code_fim | hard | {
"lang": "rust",
"repo": "guydunton/rust-gb",
"path": "/src/gameboy/tests/add_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmai/webtarot path: /webtarot_client/src/sound_player.rs
use std::collections::HashMap;
use web_sys::HtmlAudioElement;
// use js_sys;
<|fim_suffix|> // pub fn play(self, slug: &str) -> Result<js_sys::Promise, wasm_bindgen::JsValue> {
pub fn play(&self, slug: &str) {
if let Some(s... | code_fim | hard | {
"lang": "rust",
"repo": "mmai/webtarot",
"path": "/webtarot_client/src/sound_player.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SoundPlayer {
pub fn new(sound_paths: HashMap<String, &str>) -> Self {
let mut sounds = HashMap::new();
for (k, p) in sound_paths {
if let Ok(sound) = HtmlAudioElement::new_with_src(p) {
sounds.insert(k, sound);
}
}
Self { so... | code_fim | medium | {
"lang": "rust",
"repo": "mmai/webtarot",
"path": "/webtarot_client/src/sound_player.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if system.eth_intfs.is_some() {
let mut eths = ethernet_get(&config, &system.eth_intfs.unwrap().uri)?;
print_ethernet_intfs(eths.as_mut_slice());
}
}
Ok(())
}
fn show_version(config: &Config) -> Result<(), Box<dyn Error>> {
let uri = "/redfish/v1";
... | code_fim | hard | {
"lang": "rust",
"repo": "TritonDataCenter/redfish-util",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let req_url = format!("https://{}{}", config.host, uri);
let client = reqwest::Client::builder()
.danger_accept_invalid_certs(config.insecure)
.build()?;
if config.debug {
eprintln!("Sending {} Request: {}", req_type.to_string(), req_url);
if data.is_some() {
... | code_fim | hard | {
"lang": "rust",
"repo": "TritonDataCenter/redfish-util",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TritonDataCenter/redfish-util path: /src/lib.rs
}
}
}
#[derive(Debug)]
pub struct RedfishUtilCmd {
pub cmd: String,
pub arg: Option<String>,
}
impl RedfishUtilCmd {
pub fn new(cmd: String, arg: Option<String>) -> RedfishUtilCmd {
RedfishUtilCmd { cmd, arg }
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "TritonDataCenter/redfish-util",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bls_key =
match txn.txn.data.data.blskey {
Some(ref blskey) => {
let key = base58::decode(blskey.as_str()).map_input_err(|| {
format!("Node '{}': invalid base58 in field blskey", node_alias)
... | code_fim | hard | {
"lang": "rust",
"repo": "hyperledger/indy-vdr",
"path": "/libindy_vdr/src/pool/genesis.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hyperledger/indy-vdr path: /libindy_vdr/src/pool/genesis.rs
:{
NodeTransaction, NodeTransactionV0, NodeTransactionV1, ProtocolVersion, VerifierInfo,
VerifierKey, Verifiers,
};
use crate::common::error::prelude::*;
use crate::common::merkle_tree::MerkleTree;
use crate::utils::{
base58... | code_fim | hard | {
"lang": "rust",
"repo": "hyperledger/indy-vdr",
"path": "/libindy_vdr/src/pool/genesis.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hyperledger/indy-vdr path: /libindy_vdr/src/pool/genesis.rs
NodeTransactionMap = HashMap<String, NodeTransactionV1>;
/// A collection of pool genesis transactions.
#[derive(Clone, PartialEq, Eq)]
pub struct PoolTransactions {
inner: Vec<Vec<u8>>, // stored in msgpack format
}
impl PoolTra... | code_fim | hard | {
"lang": "rust",
"repo": "hyperledger/indy-vdr",
"path": "/libindy_vdr/src/pool/genesis.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>const SUM: u32 = add(44, 22);
const DIFF: u32 = sub(44, 22);
const DIV: u32 = unsafe{div(44, 22)};
fn main() {
assert_eq!(SUM, 66);
assert!(SUM != 88);
assert_eq!(DIFF, 22);
assert_eq!(DIV, 2);
let _: [&'static str; sub(100, 99) as usize] = ["hi"];
let _: [&'static str; generic(... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/consts/const-fn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/consts/const-fn.rs
// run-pass
#![allow(stable_features)]
// A very basic test of const fn functionality.
<|fim_suffix|> let _: [&'static str; sub(100, 99) as usize] = ["hi"];
let _: [&'static str; generic(1)] = ["hi"];
let _:... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/consts/const-fn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let three = match has_exactly_n_letter(&counter, 3) {
true => three + 1,
false => three,
};
(two, three)
}
fn has_exactly_n_letter(counter: &HashMap<char, u32>, n: u32) -> bool {
for (_, count) in counter {
if count == &n {
return true;
}
}... | code_fim | medium | {
"lang": "rust",
"repo": "abadi199/adventofcode2018",
"path": "/day2/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abadi199/adventofcode2018 path: /day2/src/main.rs
use std::{
collections::HashMap,
fs::File,
io::{BufRead, BufReader},
};
fn main() {
let product_ids = read_product_ids();
let (twos, threes) = product_ids
.iter()
.map(|id| count_letters(id))
.fold((0,... | code_fim | medium | {
"lang": "rust",
"repo": "abadi199/adventofcode2018",
"path": "/day2/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let two = match has_exactly_n_letter(&counter, 2) {
true => two + 1,
false => two,
};
let three = match has_exactly_n_letter(&counter, 3) {
true => three + 1,
false => three,
};
(two, three)
}
fn has_exactly_n_letter(counter: &HashMap<char, u32>, n: u... | code_fim | hard | {
"lang": "rust",
"repo": "abadi199/adventofcode2018",
"path": "/day2/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[instrument(skip(runner))]
pub fn on_update(mut runner: ResMut<WasmRunner>) {
runner.on_update(&[]).unwrap();
}<|fim_prefix|>// repo: TehPers/BevyGame path: /engine/crates/game_wasi/src/systems.rs
use crate::runner::WasmRunner;
use game_lib::{
bevy::prelude::*,
tracing::{self, instrument},
}... | code_fim | hard | {
"lang": "rust",
"repo": "TehPers/BevyGame",
"path": "/engine/crates/game_wasi/src/systems.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TehPers/BevyGame path: /engine/crates/game_wasi/src/systems.rs
use crate::runner::WasmRunner;
use game_lib::{
bevy::prelude::*,
tracing::{self, instrument},
};
use std::path::Path;
<|fim_suffix|>#[instrument(skip(runner))]
pub fn on_update(mut runner: ResMut<WasmRunner>) {
runner.on... | code_fim | hard | {
"lang": "rust",
"repo": "TehPers/BevyGame",
"path": "/engine/crates/game_wasi/src/systems.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Robthebuilder07/open-cleverpad path: /src/hal.rs
#[derive(Clone, Copy, Debug)]
pub enum ButtonType {
Pad { x: u8, y: u8 },
Master(u8),
Arrow(Direction),
Mode(ModeType),
Parameter(ParameterType),
}
#[derive(Clone, Copy, Debug)]
pub enum Direction {
Up = 0,
Down,
L... | code_fim | hard | {
"lang": "rust",
"repo": "Robthebuilder07/open-cleverpad",
"path": "/src/hal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if s {
new_banks[bank] |= 1 << bit;
} else {
new_banks[bank] &= !(1 << bit);
}
}
(LedEventType::SwitchColor(color), ButtonType::Pad { x, y }) => {
let (bank_r, bank_g, bank_b) = ... | code_fim | hard | {
"lang": "rust",
"repo": "Robthebuilder07/open-cleverpad",
"path": "/src/hal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[component]
pub fn ModelSideNav(repo_id: String, model_id: String, selected_item: ModelSideNavItem) {
html! {
<ui::SideNav>
<ui::SideNavSection>
<ui::SideNavItem
href={format!("/repos/{}/models/{}/", repo_id, model_id)}
selected={Some(selected_item == ModelSideNavItem::Overview)}
... | code_fim | hard | {
"lang": "rust",
"repo": "draftedus/tangram",
"path": "/app/layouts/model_layout.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn download(
context: &Context,
request: http::Request<hyper::Body>,
model_id: &str,
) -> Result<http::Response<hyper::Body>> {
let mut db = match context.pool.begin().await {
Ok(db) => db,
Err(_) => return Ok(service_unavailable()),
};
let user = match authorize_user(&request, &mut db... | code_fim | hard | {
"lang": "rust",
"repo": "draftedus/tangram",
"path": "/app/layouts/model_layout.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: draftedus/tangram path: /app/layouts/model_layout.rs
use super::document::{Document, PageInfo};
use html::{component, html};
use tangram_app_common::{
error::{bad_request, not_found, redirect_to_login, service_unavailable},
repos::get_model_version_ids,
topbar,
user::{authorize_user, authori... | code_fim | hard | {
"lang": "rust",
"repo": "draftedus/tangram",
"path": "/app/layouts/model_layout.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> warp::serve(hello)
.run(([0, 0, 0, 0], 8080))
.await;
}<|fim_prefix|>// repo: seriva/container-test path: /HelloWorldApi/Rust/src/main.rs
use serde_json::json;
use warp::Filter;
<|fim_middle|>#[tokio::main]
async fn main() {
let hello = warp::path("hello")
.map(|| json!( ... | code_fim | medium | {
"lang": "rust",
"repo": "seriva/container-test",
"path": "/HelloWorldApi/Rust/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seriva/container-test path: /HelloWorldApi/Rust/src/main.rs
use serde_json::json;
use warp::Filter;
<|fim_suffix|> warp::serve(hello)
.run(([0, 0, 0, 0], 8080))
.await;
}<|fim_middle|>#[tokio::main]
async fn main() {
let hello = warp::path("hello")
.map(|| json!( ... | code_fim | medium | {
"lang": "rust",
"repo": "seriva/container-test",
"path": "/HelloWorldApi/Rust/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Max-Meldrum/britt-marie path: /src/hint.rs
// Copyright (c) 2016 Amanieu d'Antras
// SPDX-License-Identifier: MIT
<|fim_suffix|>#[cfg(feature = "nightly")]
pub(crate) use core::intrinsics::{likely, unlikely};
#[cfg(not(feature = "nightly"))]
#[inline]
pub(crate) fn likely(b: bool) -> bool {
... | code_fim | easy | {
"lang": "rust",
"repo": "Max-Meldrum/britt-marie",
"path": "/src/hint.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "nightly")]
pub(crate) use core::intrinsics::{likely, unlikely};
#[cfg(not(feature = "nightly"))]
#[inline]
pub(crate) fn likely(b: bool) -> bool {
b
}
#[cfg(not(feature = "nightly"))]
#[inline]
pub(crate) fn unlikely(b: bool) -> bool {
b
}<|fim_prefix|>// repo: Max-Meldrum/britt-m... | code_fim | easy | {
"lang": "rust",
"repo": "Max-Meldrum/britt-marie",
"path": "/src/hint.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/parser/recover-tuple.rs
fn main() {
// no complaints about the tuple not matching the expected type
le<|fim_suffix|>
// no complaints about the type
foo(x);
}
fn foo(_: (usize, usize, usize)) {}<|fim_middle|>t x: (usize, usize, ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/parser/recover-tuple.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // verify that the parser recovers:
let y: usize = ""; //~ ERROR mismatched types
// no complaints about the type
foo(x);
}
fn foo(_: (usize, usize, usize)) {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/parser/recover-tuple.rs
fn main() {
// no complaints ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/parser/recover-tuple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// no complaints about the type
foo(x);
}
fn foo(_: (usize, usize, usize)) {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/parser/recover-tuple.rs
fn main() {
// no complaints about the tuple not matching the expected type
le<|fim_middle|>t x: (usize, usize, ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/parser/recover-tuple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForestCSharp/gfx path: /src/backend/gl/src/state.rs
#![allow(dead_code)] //TODO: remove
use crate::hal::pso;
use crate::hal::ColorSlot;
use smallvec::SmallVec;
use crate::{gl, GlContainer};
pub(crate) fn bind_polygon_mode(
gl: &GlContainer,
mode: pso::PolygonMode,
bias: Option<pso:... | code_fim | hard | {
"lang": "rust",
"repo": "ForestCSharp/gfx",
"path": "/src/backend/gl/src/state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operation: pso::BlendOp,
) -> (gl::types::GLenum, gl::types::GLenum, gl::types::GLenum) {
match operation {
pso::BlendOp::Add { src, dst } => (gl::FUNC_ADD, map_factor(src), map_factor(dst)),
pso::BlendOp::Sub { src, dst } => (gl::FUNC_SUBTRACT, map_factor(src), map_factor(dst)),
... | code_fim | hard | {
"lang": "rust",
"repo": "ForestCSharp/gfx",
"path": "/src/backend/gl/src/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SnoozeTime/r3dtest path: /src/gameplay/pickup.rs
//! Pick up items on the floor. Can be health, ammo, weapons and so on :)
use crate::event::GameEvent;
use crate::gameplay::gun::{GunInventory, GunType};
use crate::gameplay::player::Player;
use crate::net::snapshot::Deltable;
use crate::physics:... | code_fim | hard | {
"lang": "rust",
"repo": "SnoozeTime/r3dtest",
"path": "/src/gameplay/pickup.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn new_component(delta: &Self::Delta) -> Self {
*delta
}
}
pub struct PickUpSystem;
impl PickUpSystem {
pub fn update(&self, world: &hecs::World, physics: &PhysicWorld, resources: &mut Resources) {
let mut chan = resources.fetch_mut::<EventChannel<GameEvent>>().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "SnoozeTime/r3dtest",
"path": "/src/gameplay/pickup.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Op {
pub fn decode(rd: &mut untrusted::Reader) -> Result<Op, CodecError> {
let op = codec::read_u8(rd)?;
println!("op {:02x}", op);
match op {
0x00 => Ok(Op::Unreachable),
0x01 => Ok(Op::Nop),
0x02 => Ok(Op::Block(BlockType::decode(rd)?)... | code_fim | hard | {
"lang": "rust",
"repo": "ctz/wasmrs",
"path": "/src/expr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ctz/wasmrs path: /src/expr.rs
use untrusted;
use error::CodecError;
use ty::BlockType;
use codec;
#[derive(Debug)]
pub struct MemoryImmed {
pub align: u8,
pub offset: u32
}
impl MemoryImmed {
pub fn decode(rd: &mut untrusted::Reader) -> Result<MemoryImmed, CodecError> {
let... | code_fim | hard | {
"lang": "rust",
"repo": "ctz/wasmrs",
"path": "/src/expr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let index = codec::read_varu32(rd)?;
if codec::read_varu1(rd)? != 0 {
Err(CodecError::BadOpArgs)
} else {
Ok(index)
}
}
impl Op {
pub fn decode(rd: &mut untrusted::Reader) -> Result<Op, CodecError> {
let op = codec::read_u8(rd)?;
println!("op {:02x}", o... | code_fim | hard | {
"lang": "rust",
"repo": "ctz/wasmrs",
"path": "/src/expr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let kernel =
self.program
.create_kernel("hash_preimages", global_work_size, Some(local_work_size));
let mut preimages_buffer = self
.program
.create_buffer::<GenericArray<Fr, A>>(num_hashes)
.map_err(|e| Error::GPUError(form... | code_fim | hard | {
"lang": "rust",
"repo": "filestar-project/neptune",
"path": "/src/proteus/gpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filestar-project/neptune path: /src/proteus/gpu.rs
use super::sources::generate_program;
use crate::error::{ClError, Error};
use crate::hash_type::HashType;
use crate::poseidon::PoseidonConstants;
use crate::{Arity, BatchHasher, Strength, DEFAULT_STRENGTH};
use bellperson::bls::{Bls12, Fr, FrRep... | code_fim | hard | {
"lang": "rust",
"repo": "filestar-project/neptune",
"path": "/src/proteus/gpu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // rotation
let mut file_write_new = {
rename(&file_path, temp_dir.path().join("test.log.bk")).unwrap();
OpenOptions::new()
.write(true)
.append(true)
.create(true)
.open(&file_path)
.un... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/chase-rs",
"path": "/src/async/stream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let temp_dir = TempDir::new("chase-test-stream").unwrap();
let file_path = temp_dir.path().join("test.log");
let chaser = Chaser::new(&file_path);
let mut file_write = OpenOptions::new()
.write(true)
.append(true)
.create(true)
... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/chase-rs",
"path": "/src/async/stream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lloydmeta/chase-rs path: /src/async/stream.rs
//! Holds an implementation of file following as a Futures Stream, with back-pressure
//! taken into consideration.
use data::*;
use control::*;
use super::{thread_namer, SendData};
use std::thread::{Builder, JoinHandle};
use futures::{Future, Sin... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/chase-rs",
"path": "/src/async/stream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isSerge/exercism-rust path: /protein-translation/src/lib.rs
use std::str;
use std::collections::HashMap;
pub struct CodonsInfo<'a> {
pairs: HashMap<&'a str, &'a str>,
}
<|fim_suffix|>pub fn parse<'a>(pairs: Vec<(&'a str, &'a str)>) -> CodonsInfo<'a> {
CodonsInfo {
pairs: pairs.... | code_fim | hard | {
"lang": "rust",
"repo": "isSerge/exercism-rust",
"path": "/protein-translation/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_both() {
let mut input = [0, 2, 7, 0];
assert_eq!(redistribute(&mut input), (5, 4));
}
}<|fim_prefix|>// repo: foo-jin/adventofcode path: /src/seventeen/day6.rs
use fnv::FnvHashMap;
use super::Result;
pub fn parse_memory(s: &str) -> Result<Vec<u32>> {
s.t... | code_fim | medium | {
"lang": "rust",
"repo": "foo-jin/adventofcode",
"path": "/src/seventeen/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foo-jin/adventofcode path: /src/seventeen/day6.rs
use fnv::FnvHashMap;
use super::Result;
pub fn parse_memory(s: &str) -> Result<Vec<u32>> {
s.trim()
.split_whitespace()
.map(|s| s.parse().map_err(Into::into))
.collect::<Result<_>>()
}
<|fim_suffix|> for i in 0.... | code_fim | medium | {
"lang": "rust",
"repo": "foo-jin/adventofcode",
"path": "/src/seventeen/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn lines_test() {
let input = |text: &str| parse_lines(&mut text.chars().peekable());
let s = |text: &str| Ok(text.to_string());
assert_eq!(input("hello\nworld\n"), vec![s("hello"), s("world")]);
assert_eq!(input(" hello\nworld\n"), vec![s("hello"), s("wo... | code_fim | hard | {
"lang": "rust",
"repo": "memorysafety/sudo-rs",
"path": "/src/sudoers/basic_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: memorysafety/sudo-rs path: /src/sudoers/basic_parser.rs
//! Building blocks for a recursive descent LL(1) parsing method.
//!
//! The general idea is that a grammar (without left recursion) is translated to a series of
//! conditional and unconditional 'acceptance' methods.
//!
//! For example, ... | code_fim | hard | {
"lang": "rust",
"repo": "memorysafety/sudo-rs",
"path": "/src/sudoers/basic_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: assapir/shorelark path: /libs/simulation/src/animal_individual.rs
use ga::{chromosome::Chromosome, Individual};
use lib_genetic_algorithm as ga;
use rand::RngCore;
use crate::Animal;
pub struct AnimalIndividual {
fitness: f32,
chromosome: Chromosome,
}
<|fim_suffix|> fn chromosome(... | code_fim | hard | {
"lang": "rust",
"repo": "assapir/shorelark",
"path": "/libs/simulation/src/animal_individual.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.chromosome
}
fn from_chromosome(chromosome: Chromosome) -> Self {
Self {
fitness: 0.0,
chromosome,
}
}
}<|fim_prefix|>// repo: assapir/shorelark path: /libs/simulation/src/animal_individual.rs
use ga::{chromosome::Chromosome, Individual};... | code_fim | medium | {
"lang": "rust",
"repo": "assapir/shorelark",
"path": "/libs/simulation/src/animal_individual.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stepa2/webrtc-rs-mdns path: /src/message/question.rs
use super::name::*;
use super::*;
use std::collections::HashMap;
use std::fmt;
use util::Error;
// A question is a DNS query.
#[derive(Default, Debug, PartialEq, Clone)]
pub struct Question {
pub name: Name,
pub typ: DnsType,
pu... | code_fim | medium | {
"lang": "rust",
"repo": "stepa2/webrtc-rs-mdns",
"path": "/src/message/question.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Question {
// pack appends the wire format of the question to msg.
pub fn pack(
&self,
mut msg: Vec<u8>,
compression: &mut Option<HashMap<String, usize>>,
compression_off: usize,
) -> Result<Vec<u8>, Error> {
msg = self.name.pack(msg, compression, c... | code_fim | medium | {
"lang": "rust",
"repo": "stepa2/webrtc-rs-mdns",
"path": "/src/message/question.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Bootstrap peer ids.
pub const DEFAULT_BOOTSTRAP: &[&str] = &[
"/dns4/bootstrap-0.calibration.fildev.network/tcp/1347/p2p/12D3KooWJkikQQkxS58spo76BYzFt4fotaT5NpV2zngvrqm4u5ow",
"/dns4/bootstrap-1.calibration.fildev.network/tcp/1347/p2p/12D3KooWLce5FDHR4EX4CrYavphA5xS3uDsX6aoowXh5tzDUxJav",
... | code_fim | hard | {
"lang": "rust",
"repo": "lyswifter/forest",
"path": "/types/networks/src/calibnet/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lyswifter/forest path: /types/networks/src/calibnet/mod.rs
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use super::{drand::DRAND_MAINNET, DrandPoint, Height, HeightInfo};
/// Default genesis car file bytes.
pub const DEFAULT_GENESIS: &[u8] = include_byte... | code_fim | hard | {
"lang": "rust",
"repo": "lyswifter/forest",
"path": "/types/networks/src/calibnet/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Height epochs.
pub const HEIGHT_INFOS: [HeightInfo; 18] = [
HeightInfo {
height: Height::Breeze,
epoch: -1,
},
HeightInfo {
height: Height::Smoke,
epoch: -2,
},
HeightInfo {
height: Height::Ignition,
epoch: -3,
},
HeightInfo {... | code_fim | hard | {
"lang": "rust",
"repo": "lyswifter/forest",
"path": "/types/networks/src/calibnet/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seveibar/confidis path: /src/equalifier/numeric_equalifier.rs
use crate::equalifier::{Answer, Equalifier};
use num::clamp;
pub struct NumericEqualifier {
pub max_distance: f64,
}
<|fim_suffix|>impl Equalifier for NumericEqualifier {
fn get_distance(&self, a: &Answer, b: &Answer) -> f64... | code_fim | medium | {
"lang": "rust",
"repo": "seveibar/confidis",
"path": "/src/equalifier/numeric_equalifier.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let af = a.content.parse::<f64>().unwrap();
let bf = b.content.parse::<f64>().unwrap();
clamp((af - bf).abs() / self.max_distance, 0.0, 1.0)
}
fn is_valid_answer(&self, a: &Answer) -> bool {
a.content.parse::<f64>().is_ok()
}
}
#[test]
fn numeric_distance_test(... | code_fim | medium | {
"lang": "rust",
"repo": "seveibar/confidis",
"path": "/src/equalifier/numeric_equalifier.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where F: Fn((usize, Option<T::Native>)) -> Option<T::Native> + Copy {
self.into_iter()
.enumerate()
.map(f)
.trust_my_length(self.len())
.collect_trusted()
}
}
impl<'a> ArrayApply<'a, bool, bool> for DFBooleanArray {
fn apply_cast_numeri... | code_fim | hard | {
"lang": "rust",
"repo": "lvheyang/databend",
"path": "/common/datavalues/src/arrays/ops/apply.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lvheyang/databend path: /common/datavalues/src/arrays/ops/apply.rs
// Copyright 2020 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http:... | code_fim | hard | {
"lang": "rust",
"repo": "lvheyang/databend",
"path": "/common/datavalues/src/arrays/ops/apply.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vain0x/text-position-rs path: /src/position/composite_position.rs
// LICENSE: CC0-1.0
use crate::{TextPosition, Utf16Position, Utf8Index, Utf8Position};
use std::{
cmp::Ordering,
fmt::{self, Display, Formatter},
hash::{Hash, Hasher},
ops::{Add, AddAssign},
};
/// Text position ... | code_fim | hard | {
"lang": "rust",
"repo": "vain0x/text-position-rs",
"path": "/src/position/composite_position.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_saturating_sub_minus_row() {
assert_eq!(
pos_of("\n\n\n\n123456").saturating_sub(pos_of("\n\n\n\n\n1")),
ZERO
);
}
#[test]
fn test_saturating_sub_minus_column() {
assert_eq!(
pos_of("\n\n\n\n123456").saturatin... | code_fim | hard | {
"lang": "rust",
"repo": "vain0x/text-position-rs",
"path": "/src/position/composite_position.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PartialOrd<CompositePosition> for Utf8Position {
fn partial_cmp(&self, other: &CompositePosition) -> Option<Ordering> {
self.partial_cmp(&Utf8Position::from(*other))
}
}
// Compare to Utf16Position:
impl PartialEq<Utf16Position> for CompositePosition {
fn eq(&self, other: &Utf16... | code_fim | hard | {
"lang": "rust",
"repo": "vain0x/text-position-rs",
"path": "/src/position/composite_position.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::adapted_verifier::{
verify_proofs,
verify_aggregate
};
pub use self::adapted_helper::{
create_aggregate
};<|fim_prefix|>// repo: matter-labs/bellman path: /src/sonic/helped/mod.rs
use crate::pairing::ff::{Field};
use crate::pairing::{Engine, CurveProjective};
use std::marker::P... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/sonic/helped/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matter-labs/bellman path: /src/sonic/helped/mod.rs
use crate::pairing::ff::{Field};
use crate::pairing::{Engine, CurveProjective};
use std::marker::PhantomData;
pub mod batch;
pub mod poly;
pub mod prover;
pub mod verifier;
pub mod helper;
pub mod parameters;
pub mod generator;
mod adapted_prov... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/sonic/helped/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::generator::{
CircuitParameters,
generate_parameters,
generate_parameters_on_srs,
generate_parameters_on_srs_and_information,
generate_random_parameters,
generate_srs,
get_circuit_parameters,
get_circuit_parameters_for_succinct_sonic
};
pub use self::param... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/sonic/helped/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let devices = device::attached_devices(&ctx)?;
info!("Attached devices:");
for device in &devices {
info!(" {:?}", device);
}
info!("");
let backends = ctx.cfg.backends();
info!("Configured backends:");
for backend in &backends... | code_fim | medium | {
"lang": "rust",
"repo": "richo/stokepile",
"path": "/src/bin/enumerate-media.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ctx = if is_cron {
Ctx::create(cfg?)?
} else {
Ctx::create_without_lock(cfg?)?
};
let devices = device::attached_devices(&ctx)?;
info!("Attached devices:");
for device in &devices {
info!(" {:?}", device);
}... | code_fim | hard | {
"lang": "rust",
"repo": "richo/stokepile",
"path": "/src/bin/enumerate-media.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: richo/stokepile path: /src/bin/enumerate-media.rs
#[macro_use]
extern crate log;
use clap::{App, Arg};
use stokepile::cli;
use stokepile::config;
use stokepile::ctx::Ctx;
use stokepile::device;
use stokepile::mailer::MailReport;
use stokepile::mountable::Mountable;
use stokepile::staging::Stag... | code_fim | hard | {
"lang": "rust",
"repo": "richo/stokepile",
"path": "/src/bin/enumerate-media.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// for r in y - k..=y + k {
// if r >= yy || r < 0 {
// continue;
// }
// result.push((c, r))
// }
// }
// result
// }
fn around2(x: i32, y: i32, xx: i32, yy: i32, k: i32) -> impl Iterator<Item = (i32, i32)> {
(x - k..=x + k)... | code_fim | hard | {
"lang": "rust",
"repo": "ccqpein/Arithmetic-Exercises",
"path": "/Matrix-Block-Sum/MBS.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.