text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: georust/geo path: /geo/src/algorithm/minimum_rotated_rect.rs
use num_traits::Float;
use crate::{
algorithm::{centroid::Centroid, rotate::Rotate, BoundingRect, CoordsIter},
Area, ConvexHull, CoordFloat, GeoFloat, GeoNum, LinesIter, Polygon,
};
/// Return the minimum bounding rectangle(MB... | code_fim | hard | {
"lang": "rust",
"repo": "georust/geo",
"path": "/geo/src/algorithm/minimum_rotated_rect.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[rstest]
#[case("123", BytesNotification {
previous_threshold: 123, threshold: Some(123), byte_multiple: ByteMultiple::B, ..BytesNotification::default() })]
#[case("500k", BytesNotification {
previous_threshold: 500_000, threshold: Some(500_000),byte_multiple: ByteMultiple::KB... | code_fim | hard | {
"lang": "rust",
"repo": "GyulyVGC/sniffnet",
"path": "/src/notifications/types/notifications.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GyulyVGC/sniffnet path: /src/notifications/types/notifications.rs
use serde::{Deserialize, Serialize};
use crate::networking::types::byte_multiple::from_char_to_multiple;
use crate::notifications::types::sound::Sound;
use crate::ByteMultiple;
/// Used to contain the notifications configuration... | code_fim | hard | {
"lang": "rust",
"repo": "GyulyVGC/sniffnet",
"path": "/src/notifications/types/notifications.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>subcommand(
/// App::new("config")
/// .about("Used for configuration")
/// .arg(Arg::with_name("config_file")
/// .help("The configuration file to use")
/// .index(1)))
/// # ;
/// ```
/// [`App`]: ./struct.App.html
/// [arguments]: ./struct... | code_fim | hard | {
"lang": "rust",
"repo": "dfinity-lab/clap",
"path": "/src/parse/matches/subcommand.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dfinity-lab/clap path: /src/parse/matches/subcommand.rs
// Internal
use crate::util::Id;
use crate::ArgMatches;
/// The abstract representation of a command line subcommand.
///
/// This struct describes all the valid options of the subcommand for the program. Subcommands are
/// <|fim_suffix|>... | code_fim | hard | {
"lang": "rust",
"repo": "dfinity-lab/clap",
"path": "/src/parse/matches/subcommand.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msiemens/RusTiny path: /src/util/mod.rs
//! Different helpers & utilities
use std::collections::hash_map::{Entry, HashMap};
use std::hash::BuildHasher;
use std::hash::Hash;
pub use self::io::{read_file, write_file};
mod io;
<|fim_suffix|>impl<K, V, S> TryInsert<K, V> for HashMap<K, V, S>
wher... | code_fim | hard | {
"lang": "rust",
"repo": "msiemens/RusTiny",
"path": "/src/util/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<K, V, S> TryInsert<K, V> for HashMap<K, V, S>
where
K: Eq + Hash,
S: BuildHasher,
{
fn try_insert(&mut self, k: K, v: V) -> Result<(), ()> {
match self.entry(k) {
Entry::Occupied(_) => Err(()),
Entry::Vacant(entry) => {
entry.insert(v);
... | code_fim | hard | {
"lang": "rust",
"repo": "msiemens/RusTiny",
"path": "/src/util/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl<K, V, S> TryInsert<K, V> for HashMap<K, V, S>
where
K: Eq + Hash,
S: BuildHasher,
{
fn try_insert(&mut self, k: K, v: V) -> Result<(), ()> {
match self.entry(k) {
Entry::Occupied(_) => Err(()),
Entry::Vacant(entry) => {
entry.insert(v);
... | code_fim | hard | {
"lang": "rust",
"repo": "msiemens/RusTiny",
"path": "/src/util/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tx = gpioa.pa9.into_af7(&mut gpioa.moder, &mut gpioa.afrh);
let rx = gpioa.pa10.into_af7(&mut gpioa.moder, &mut gpioa.afrh);
let serial = Serial::usart1(dp.USART1, (tx, rx), 9600.bps(), clocks, &mut rcc.apb2);
let (mut tx, _) = serial.split();
//block!(tx.write(34 as u8)).ok(... | code_fim | medium | {
"lang": "rust",
"repo": "dueruen/iot_assignments",
"path": "/assignment_02/transmit-cycle/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dueruen/iot_assignments path: /assignment_02/transmit-cycle/src/main.rs
//#![deny(unsafe_code)]
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
#[allow(unused_extern_crates)]
extern crate panic_itm; // panic handler
// #[allow(unused_imports)]
// use aux6::{entry, iprint, iprint... | code_fim | medium | {
"lang": "rust",
"repo": "dueruen/iot_assignments",
"path": "/assignment_02/transmit-cycle/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: logan-et-alessio/rust-workshop path: /solutions/src/test/_11_collections.rs
#![allow(dead_code)]
fn insert_at_right_place(vec: &mut Vec<i64>, val: i64) {
if let Err(index) = vec.binary_search(&val) {
vec.insert(index, val);
}
}
mod insert_at_right_place_should {
use super::... | code_fim | hard | {
"lang": "rust",
"repo": "logan-et-alessio/rust-workshop",
"path": "/solutions/src/test/_11_collections.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn returns_4n5_when_contains_4_5_9_10() {
assert_eq!(vec![(4, 5)], followed_by_sum(vec![4, 5, 9, 10]));
}
#[test]
fn returns_1n4_4n5_when_contains_1_4_5_9() {
assert_eq!(vec![(1, 4),(4, 5)], followed_by_sum(vec![1, 4, 5, 9]));
}
}<|fim_prefix|>// repo: loga... | code_fim | hard | {
"lang": "rust",
"repo": "logan-et-alessio/rust-workshop",
"path": "/solutions/src/test/_11_collections.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut vec = vec![13, 21, 314, 1337];
insert_at_right_place(&mut vec, 42);
assert_eq!(vec![13, 21, 42, 314, 1337], vec);
}
}
fn followed_by_sum(vec: Vec<u64>) -> Vec<(u64, u64)> {
vec.windows(3)
.filter(|t| t[0] + t[1] == t[2])
.map(|t| (t[0], t[1]))
... | code_fim | hard | {
"lang": "rust",
"repo": "logan-et-alessio/rust-workshop",
"path": "/solutions/src/test/_11_collections.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leroycep/eant2 path: /src/eant.rs
use std::sync::Arc;
use cge::Network;
use cmaes_utils::*;
use generation::initialize_generation;
use mutation::mutate;
use options::EANT2Options;
use select::select;
use fitness::NNFitnessFunction;
/// Returns a neural network with as high a fitness as possib... | code_fim | hard | {
"lang": "rust",
"repo": "leroycep/eant2",
"path": "/src/eant.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for individual in &generation {
for _ in 0..offspring_count {
let mut new = individual.clone();
mutate(&mut new);
new_individuals.push(new);
}
}
//use this for testing
//individuals should stay at a ... | code_fim | hard | {
"lang": "rust",
"repo": "leroycep/eant2",
"path": "/src/eant.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// fixme: 暂时开放用以快速生成tickdata
pub mod sys;
pub(crate) mod tdapi;<|fim_prefix|>// repo: xiehai1983/FlashFunk path: /flashfunk-level/src/ctp/mod.rs
#![allow(
dead_code,
unused_variables,
non_camel_case_types,
non_snake_case,
non_upper_case_globals,
<|fim_middle|>unused_imports
)]
mo... | code_fim | medium | {
"lang": "rust",
"repo": "xiehai1983/FlashFunk",
"path": "/flashfunk-level/src/ctp/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xiehai1983/FlashFunk path: /flashfunk-level/src/ctp/mod.rs
#![allow(
dead_code,
unused_variables,
non_camel_c<|fim_suffix|>// fixme: 暂时开放用以快速生成tickdata
pub mod sys;
pub(crate) mod tdapi;<|fim_middle|>ase_types,
non_snake_case,
non_upper_case_globals,
unused_imports
)]
mo... | code_fim | medium | {
"lang": "rust",
"repo": "xiehai1983/FlashFunk",
"path": "/flashfunk-level/src/ctp/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcls/svd2rust-example path: /psoc6_01/src/csd0/sw_refgen_sel.rs
#[doc = "Register `SW_REFGEN_SEL` reader"]
pub struct R(crate::R<SW_REFGEN_SEL_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<SW_REFGEN_SEL_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
... | code_fim | hard | {
"lang": "rust",
"repo": "rcls/svd2rust-example",
"path": "/psoc6_01/src/csd0/sw_refgen_sel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `SW_IBCB` writer - Set corresponding switch"]
pub struct SW_IBCB_W<'a> {
w: &'a mut W,
}
impl<'a> SW_IBCB_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears th... | code_fim | hard | {
"lang": "rust",
"repo": "rcls/svd2rust-example",
"path": "/psoc6_01/src/csd0/sw_refgen_sel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kira-96/leetcode-record path: /integer-reverse/src/main.rs
fn main() {
println!("Hello, world!");
}
pub fn reverse(x: i32) -> i32 {
let mut y: i32 = x;
let mut r: i32 = 0;
<|fim_suffix|>#[test]
fn reverse_2147483647() {
let expected = 0;
let actual = reverse(2147483647);
... | code_fim | hard | {
"lang": "rust",
"repo": "kira-96/leetcode-record",
"path": "/integer-reverse/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected = 0;
let actual = reverse(2147483647);
assert_eq!(expected, actual);
}
#[test]
fn reverse_neg2147483648() {
let expected = 0;
let actual = reverse(-2147483648);
assert_eq!(expected, actual);
}<|fim_prefix|>// repo: kira-96/leetcode-record path: /integer-reverse/src... | code_fim | hard | {
"lang": "rust",
"repo": "kira-96/leetcode-record",
"path": "/integer-reverse/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> process::exit(match _main() {
Ok(_) => 0,
Err(ref e) => {
eprintln!("{}", e);
1
}
});
}<|fim_prefix|>// repo: peterhuene/sightglass path: /src/main.rs
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate thiserror;
mod bench;
mod conf... | code_fim | medium | {
"lang": "rust",
"repo": "peterhuene/sightglass",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peterhuene/sightglass path: /src/main.rs
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate thiserror;
mod bench;
mod config;
mod cpu_affinity;
mod errors;
mod out;
mod symbols;
use self::bench::bench;
use self::config::Config;
use self::errors::*;
use std::process;
<|fim_suff... | code_fim | medium | {
"lang": "rust",
"repo": "peterhuene/sightglass",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config = Config::parse()?;
let _ = cpu_affinity::tune(&config);
bench(&config)?;
Ok(())
}
fn main() {
process::exit(match _main() {
Ok(_) => 0,
Err(ref e) => {
eprintln!("{}", e);
1
}
});
}<|fim_prefix|>// repo: peterhuene/sightg... | code_fim | medium | {
"lang": "rust",
"repo": "peterhuene/sightglass",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: willy610/fsm2fsm-main path: /tool/src/applic_folder/fsm_folder/gen_folder/genc_folder/c_gen_fsm_h.rs
use crate::applic_folder::fsm_folder::fsm::Fsm;
impl Fsm {
pub fn c_gen_fsm_h(&mut self, prepost: &'static str) -> String {
let all_inmsgs_in_initial_state: Vec<String> = Vec::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "willy610/fsm2fsm-main",
"path": "/tool/src/applic_folder/fsm_folder/gen_folder/genc_folder/c_gen_fsm_h.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>int getfinalstate_{prepost}FSM({prepost}FSM * self);
int isinfinalstate_{prepost}FSM({prepost}FSM * self, int state);
INIT_MESSAGES * get_possible_init_messages_{prepost}FSM({prepost}FSM * self);
int take_event_{prepost}FSM({prepost}FSM * self, int *state, void *business_object);
struct {prepost}FSM {{
... | code_fim | medium | {
"lang": "rust",
"repo": "willy610/fsm2fsm-main",
"path": "/tool/src/applic_folder/fsm_folder/gen_folder/genc_folder/c_gen_fsm_h.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> int (*getinitialstate_{prepost}FSM)({prepost}FSM * self);
int (*getfinalstate_{prepost}FSM)({prepost}FSM * self);
int (*isinfinalstate_{prepost}FSM)({prepost}FSM * self, int state);
INIT_MESSAGES * (*get_possible_init_messages_{prepost}FSM)({prepost}FSM * self);
int (*take_event_{prepost}FSM)({p... | code_fim | hard | {
"lang": "rust",
"repo": "willy610/fsm2fsm-main",
"path": "/tool/src/applic_folder/fsm_folder/gen_folder/genc_folder/c_gen_fsm_h.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = Solution::minimum_size(
vec![
431, 922, 158, 60, 192, 14, 788, 146, 788, 775, 772, 792, 68, 143, 376, 375, 877, 516,
595, 82, 56, 704, 160, 403, 713, 504, 67, 332, 26,
],
80,
);
assert_eq!(129, result);
}<|fim_prefix|>// repo... | code_fim | medium | {
"lang": "rust",
"repo": "CaulyKan/leetcode",
"path": "/袋子里最少数目的球/tests/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = Solution::minimum_size(vec![2, 4, 8, 2], 4);
assert_eq!(2, result);
}
#[test]
fn test3() {
let result = Solution::minimum_size(vec![7, 17], 2);
assert_eq!(7, result);
}
#[test]
fn test4() {
let result = Solution::minimum_size(
vec![
431,... | code_fim | medium | {
"lang": "rust",
"repo": "CaulyKan/leetcode",
"path": "/袋子里最少数目的球/tests/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CaulyKan/leetcode path: /袋子里最少数目的球/tests/tests.rs
extern crate leetcode;
use leetcode::Solution;
#[test]
fn test1() {
let result = Solution::minimum_size(vec![9], 2);
assert_eq!(3, result);
}
<|fim_suffix|>#[test]
fn test3() {
let result = Solution::minimum_size(vec![7, ... | code_fim | medium | {
"lang": "rust",
"repo": "CaulyKan/leetcode",
"path": "/袋子里最少数目的球/tests/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> true
}
}
fn main() {
let nums = vec![0,0,0,0,0];
println!("{}", Solution::is_straight(nums));
}<|fim_prefix|>// repo: Schenk75/Learn-Rust path: /leetcode-by-rust/LCOF/lcof61-扑克牌中的顺子/src/main.rs
struct Solution;
impl Solution {
pub fn is_straight(nums: Vec<i32>) -> bool {
... | code_fim | medium | {
"lang": "rust",
"repo": "Schenk75/Learn-Rust",
"path": "/leetcode-by-rust/LCOF/lcof61-扑克牌中的顺子/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Schenk75/Learn-Rust path: /leetcode-by-rust/LCOF/lcof61-扑克牌中的顺子/src/main.rs
struct Solution;
impl Solution {
pub fn is_straight(nums: Vec<i32>) -> bool {
let mut nums = nums;
nums.sort();
let mut zeros = 0;
let mut cnt = 0;
// 统计0的个数
for i in ... | code_fim | medium | {
"lang": "rust",
"repo": "Schenk75/Learn-Rust",
"path": "/leetcode-by-rust/LCOF/lcof61-扑克牌中的顺子/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> c -= 1;
res.push((s / (2 * k + 1) as i64) as i32);
}
}
while res.len() < l {
res.push(-1);
}
return res;
}
}<|fim_prefix|>// repo: sym233/leetcode_problems path: /2090. K Radius Subarray Averages/2090. K Radius Subarray ... | code_fim | hard | {
"lang": "rust",
"repo": "sym233/leetcode_problems",
"path": "/2090. K Radius Subarray Averages/2090. K Radius Subarray Averages.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ush(-1);
} else if c == 2 * k + 1 {
res.push((s / (2 * k + 1) as i64) as i32);
} else {
s -= nums[i - 2 * k as usize - 1] as i64;
c -= 1;
res.push((s / (2 * k + 1) as i64) as i32);
}
}
while... | code_fim | hard | {
"lang": "rust",
"repo": "sym233/leetcode_problems",
"path": "/2090. K Radius Subarray Averages/2090. K Radius Subarray Averages.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sym233/leetcode_problems path: /2090. K Radius Subarray Averages/2090. K Radius Subarray Averages.rs
impl Solution {
pub fn get_averages(nums: Vec<i32>, k: i32) -> Vec<i32> {
let l = nums.len();
let mut s: i64 = 0;
let mut c = 0;
let mut res: Vec<i32> = Vec<|f... | code_fim | hard | {
"lang": "rust",
"repo": "sym233/leetcode_problems",
"path": "/2090. K Radius Subarray Averages/2090. K Radius Subarray Averages.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub mod drawer2d;
pub mod point2d;
pub mod pointcloud2d;
pub mod tool_trait;
pub mod toolbox;
mod utils;<|fim_prefix|>// repo: germolinal/wasm_2d_drawer path: /src/lib.rs
/// The kind of Floating point number used in the
/// library... the `"float"` feature means it becomes `f32`
/// and `f64` is use... | code_fim | medium | {
"lang": "rust",
"repo": "germolinal/wasm_2d_drawer",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: germolinal/wasm_2d_drawer path: /src/lib.rs
/// The kind of Floating point number used in the
/// library... the `"float"` feature means it becomes `f32`
/// and `f64` is used otherwise.
#[cfg(feature = "float")]
type Float = f32;
<|fim_suffix|>/*
#[cfg(feature = "float")]
const PI : Float = ... | code_fim | easy | {
"lang": "rust",
"repo": "germolinal/wasm_2d_drawer",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t = lex(&"\"hello\" \"world\"".to_string());
let t_vec = match t {
Ok(v) => v,
Err(e) => panic!(e),
};
let first = &t_vec[0];
let second = &t_vec[1];
assert_eq!(Primitive::Str("hello".to_string()), *first);
assert_eq!(Primitive::Str("world".to_string()), *s... | code_fim | medium | {
"lang": "rust",
"repo": "ncatelli/mud",
"path": "/parser/src/lexer/tests/lexer/strings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ncatelli/mud path: /parser/src/lexer/tests/lexer/strings.rs
use lexer::*;
#[test]
fn tokenize_valid_string() {
let t = lex(&"\"hello\"".to_string());
let t_vec = match t {
Ok(v) => v,
Err(e) => panic!(e),
};
let first = &t_vec[0];
assert_eq!(Primitive::Str("... | code_fim | medium | {
"lang": "rust",
"repo": "ncatelli/mud",
"path": "/parser/src/lexer/tests/lexer/strings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imsut/untangled path: /src/main.rs
extern crate argparse;
extern crate classreader;
extern crate regex;
#[macro_use]
extern crate lazy_static;
use argparse::{ArgumentParser, Collect, Store, StoreTrue, StoreOption};
use classreader::{ConstantPoolInfo, Class, ClassReader};
use regex::Regex;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "imsut/untangled",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn canonicalize(name: &String) -> String {
let fqcn = name.replace("/", ".");
match fqcn.find("$") {
// make enclosed class same as its enclosing class
Some(idx) => fqcn.split_at(idx).0.to_string(),
None => fqcn
}
}
fn class_name(cp_info: &ConstantPoolInfo, class: &Cl... | code_fim | hard | {
"lang": "rust",
"repo": "imsut/untangled",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ebottabi/datafuse path: /common/functions/src/scalars/hashes/siphash.rs
// Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
use std::collections::hash_map::DefaultHasher;
use std::fmt;
use common_datavalues::columns::DataColumn;
use common_datavalues::prelud... | code_fim | hard | {
"lang": "rust",
"repo": "ebottabi/datafuse",
"path": "/common/functions/src/scalars/hashes/siphash.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Function for SipHashFunction {
fn name(&self) -> &str {
&*self.display_name
}
fn num_arguments(&self) -> usize {
1
}
fn return_type(&self, args: &[DataType]) -> Result<DataType> {
match args[0] {
DataType::Int8
| DataType::Int16
... | code_fim | hard | {
"lang": "rust",
"repo": "ebottabi/datafuse",
"path": "/common/functions/src/scalars/hashes/siphash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Warhorst/telegram_bot_api_parser path: /src/code_generator/resolve_strategy.rs
use core::fmt;
use std::convert::TryFrom;
use std::fmt::Formatter;
use crate::code_generator::resolve_strategy::ResolveStrategy::{ForAllDTOs, ForEachDTO, ForAllMethods, ForEachMethod};
/// Represents how a template-... | code_fim | medium | {
"lang": "rust",
"repo": "Warhorst/telegram_bot_api_parser",
"path": "/src/code_generator/resolve_strategy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::error::Error for NoValidResolveStrategyError {}
impl std::fmt::Display for NoValidResolveStrategyError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
writeln!(f, "The given value {} is not a valid strategy!", self.value)
}
}<|fim_prefix|>// repo: Warhorst/telegram_bot_a... | code_fim | hard | {
"lang": "rust",
"repo": "Warhorst/telegram_bot_api_parser",
"path": "/src/code_generator/resolve_strategy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n == 0 && a[0] == 1 {
println!("1");
return;
} else if n == 0 {
println!("-1");
return;
}
let mut mx1 = vec![0; n + 2];
for i in 0..n + 1 {
mx1[i + 1] = mx1[i] + a[n - i];
}
mx1.reverse();
let mut ans = 1;
let mut bef = 1;
... | code_fim | medium | {
"lang": "rust",
"repo": "hem6/atcoder-rs",
"path": "/nomura2020/src/bin/c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hem6/atcoder-rs path: /nomura2020/src/bin/c.rs
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;
fn main() {
<|fim_suffix|> if n == 0 && a[0] == 1 {
println!("1");
return;
} e... | code_fim | medium | {
"lang": "rust",
"repo": "hem6/atcoder-rs",
"path": "/nomura2020/src/bin/c.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ans = 1;
let mut bef = 1;
for i in 1..n + 1 {
let mx = (bef - a[i - 1]) * 2;
let node_count = min(mx, mx1[i]);
if node_count < a[i] {
ans = -1;
break;
}
ans += node_count;
bef = node_count;
}
println!("{}... | code_fim | hard | {
"lang": "rust",
"repo": "hem6/atcoder-rs",
"path": "/nomura2020/src/bin/c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/wasmparser/src/readers/component/aliases.rs
use crate::{BinaryReader, ComponentExternalKind, ExternalKind, FromReader, Result};
/// Represents the kind of an outer alias in a WebAssembly component.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum C... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla/gecko-dev",
"path": "/third_party/rust/wasmparser/src/readers/component/aliases.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> byte1: u8,
byte2: Option<u8>,
offset: usize,
) -> Result<ComponentOuterAliasKind> {
Ok(match byte1 {
0x00 => match byte2.unwrap() {
0x10 => ComponentOuterAliasKind::CoreType,
0x11 => ComponentOuterAliasKind::CoreModule,
x => {
ret... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla/gecko-dev",
"path": "/third_party/rust/wasmparser/src/readers/component/aliases.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yutiansut/ocypod path: /src/handlers/health.rs
//! HTTP handlers for the `/health` endpoint.
use futures::Future;
use actix_web::{self, HttpResponse};
use actix_web::web::Data;
use serde_derive::*;
use log::error;
use crate::actors::application;
use crate::models::ApplicationState;
#[derive(S... | code_fim | medium | {
"lang": "rust",
"repo": "yutiansut/ocypod",
"path": "/src/handlers/health.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Handle `GET /health` requests to get a JSON list of all existing queues.
pub fn index(data: Data<ApplicationState>) -> impl Future<Item=HttpResponse, Error=()> {
data.redis_addr.send(application::CheckHealth)
.then(|res| {
match res {
Ok(_) => Ok(HttpResponse... | code_fim | hard | {
"lang": "rust",
"repo": "yutiansut/ocypod",
"path": "/src/handlers/health.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: will07c5/cryptopals-rs path: /src/rsa.rs
use ramp::int::Int;
use crate::prime::gen_prime;
use crate::ops::IntOpsExt;
use crate::asn1::*;
use crate::md4::md4_digest;
const MD4_OID: &[usize] = &[1, 2, 840, 113549, 2, 4];
#[derive(Debug)]
pub struct RSAPubKey {
pub e: Int,
pub n: Int,
}
#[deri... | code_fim | hard | {
"lang": "rust",
"repo": "will07c5/cryptopals-rs",
"path": "/src/rsa.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let digest_info = encode_asn1_sequence(
&[encode_asn1_oid(MD4_OID),
encode_asn1_octet_str(&digest)]);
// calculate length of n in octets
let k = (key.n.bit_length() as usize + 7) / 8;
let pad_len = k - 3 - digest_info.len();
let mut enc_block = Vec::with_capacity... | code_fim | hard | {
"lang": "rust",
"repo": "will07c5/cryptopals-rs",
"path": "/src/rsa.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = &p * &q;
let et = (&p - 1) * (&q - 1);
let d = e.inv_mod(&et).unwrap();
(RSAPubKey { e: e.clone(), n: n.clone() }, RSAPrivKey { p, q, n, e, d })
}
pub fn encrypt_rsa(key: &RSAPubKey, m: &Int) -> Result<Int, ()> {
if m >= &key.n {
Err(())
} else {
Ok(m.pow_mod(&key.e, &ke... | code_fim | hard | {
"lang": "rust",
"repo": "will07c5/cryptopals-rs",
"path": "/src/rsa.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Parser<'a> for ListSeparator {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
map(one_of(",;"), |_: char| Self)(input)
}
}
// 1. The line begins with // or #
// 2. The content between /* and */
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct CommentRef<'a>(&'a str);
impl... | code_fim | hard | {
"lang": "rust",
"repo": "ihciah/thrift-parser",
"path": "/src/basic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ihciah/thrift-parser path: /src/basic.rs
use nom::branch::alt;
use nom::bytes::complete::{tag, take_till, take_until, take_while};
use nom::character::complete::{char as cchar, multispace1, one_of, satisfy};
use nom::combinator::{map, opt, recognize};
use nom::multi::many1;
use nom::sequence::{d... | code_fim | hard | {
"lang": "rust",
"repo": "ihciah/thrift-parser",
"path": "/src/basic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl JsonBuilder {
pub fn new(file_name: String) -> JsonBuilder {
let file = JsonFile { file_name, polygons: Vec::new(), points: Vec::new() };
JsonBuilder {
json: file
}
}
pub fn add_polygon(&mut self, polygon: Vec<(f64, f64)>) -> &mut JsonBuilder {
... | code_fim | hard | {
"lang": "rust",
"repo": "FlxB2/fapra-algorithms-optimizations",
"path": "/osm-tasks/src/export/json_generator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut coords_string = format!("{:?}", temp).replace("(", "[").replace(")", "]");
coords_string = format!("{{
\"type\": \"Feature\",
\"properties\": {{}},
\"geometry\": {{
\"type\": \"Polygon\",
\"co... | code_fim | hard | {
"lang": "rust",
"repo": "FlxB2/fapra-algorithms-optimizations",
"path": "/osm-tasks/src/export/json_generator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FlxB2/fapra-algorithms-optimizations path: /osm-tasks/src/export/json_generator.rs
use std::fs::File;
use std::io::Write;
/*
generates a file following the GeoJSON format https://datatracker.ietf.org/doc/html/rfc7946
*/
pub struct JsonFile {
file_name: String,
polygons: Vec<Vec<(f64, f... | code_fim | hard | {
"lang": "rust",
"repo": "FlxB2/fapra-algorithms-optimizations",
"path": "/osm-tasks/src/export/json_generator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromMemory for Instruction {
fn parse(cell: u16) -> Option<Instruction> {
unimplemented!();
}
}<|fim_prefix|>// repo: nascii/lc3vm path: /src/parser.rs
use crate::{FromMemory, Value, Instruction};
<|fim_middle|>impl FromMemory for Value {
#[inline]
fn parse(cell: u16) -> Opt... | code_fim | medium | {
"lang": "rust",
"repo": "nascii/lc3vm",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nascii/lc3vm path: /src/parser.rs
use crate::{FromMemory, Value, Instruction};
impl FromMemory for Value {
#[inline]
fn parse(cell: u16) -> Option<Value> {
<|fim_suffix|> unimplemented!();
}
}<|fim_middle|> Some(i32::from(cell))
}
}
impl FromMemory for Instruction... | code_fim | medium | {
"lang": "rust",
"repo": "nascii/lc3vm",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nascii/lc3vm path: /src/parser.rs
use crate::{FromMemory, Value, Instruction};
<|fim_suffix|> unimplemented!();
}
}<|fim_middle|>impl FromMemory for Value {
#[inline]
fn parse(cell: u16) -> Option<Value> {
Some(i32::from(cell))
}
}
impl FromMemory for Instruction... | code_fim | hard | {
"lang": "rust",
"repo": "nascii/lc3vm",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PacktPublishing/The-Complete-Rust-Programming-Reference-Guide path: /Chapter07/destructure_struct.rs
// destructure_struct.rs
enum Food {
Pizza,
Salad
}
<|fim_suffix|> // let can pattern match inner fields into new variables
let Order { count, item, .. } = food_order;
}<|fim_mid... | code_fim | hard | {
"lang": "rust",
"repo": "PacktPublishing/The-Complete-Rust-Programming-Reference-Guide",
"path": "/Chapter07/destructure_struct.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Order {
count: u8,
item: Food,
payment: PaymentMode
}
fn main() {
let food_order = Order { count: 2,
item: Food::Salad,
payment: PaymentMode::Credit };
// let can pattern match inner fields into new variables
let Or... | code_fim | easy | {
"lang": "rust",
"repo": "PacktPublishing/The-Complete-Rust-Programming-Reference-Guide",
"path": "/Chapter07/destructure_struct.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for s in read_input().split('\n') {
let seat_id = seat_id(s);
//println!("Seat id for {} is {}", s, seat_id);
// Set the seat id as occupied
bmap.set(seat_id as usize, true);
max_id = cmp::max(max_id, seat_id);
min_id = cmp::min(min_id, seat_id);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "eakst7/adventofcode2020",
"path": "/day5/src/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eakst7/adventofcode2020 path: /day5/src/day5.rs
use std::fs;
use std::cmp;
use bitmaps::Bitmap;
use typenum::U1024;
fn read_input() -> String {
let contents = fs::read_to_string("input.txt")
.expect("IO error reading input data");
return contents
}
fn seat_id(code : &str) -> u... | code_fim | hard | {
"lang": "rust",
"repo": "eakst7/adventofcode2020",
"path": "/day5/src/day5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // For any seats below the min_id found,
// treat as occupied
for i in 0..(min_id+1) {
bmap.set(i as usize, true);
}
// For any seats above the max_id found,
// treat as occupied
for i in max_id..1024 {
bmap.set(i as usize, true);
}
// Invert the bitma... | code_fim | hard | {
"lang": "rust",
"repo": "eakst7/adventofcode2020",
"path": "/day5/src/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yun-cloud/ruder path: /src/archive.rs
use flate2::read::GzDecoder;
use std::io::{self, Cursor, Read};
use std::mem::MaybeUninit;
use std::path::Path;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::AsyncRead;
use zip::ZipArchive;
pub enum Archive<T: AsRef<[u8]>> {
TarGz(ta... | code_fim | hard | {
"lang": "rust",
"repo": "yun-cloud/ruder",
"path": "/src/archive.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use Extract::*;
match self {
TarGz(r) => r.read(buf),
Tar(r) => r.read(buf),
Zip(r) => r.read(buf),
Raw(r) => r.read(buf),
}
}
}
impl<'a, T: AsRef<[u8]>> AsyncRead for Extract<'a, T> {
unsafe fn prepare_uninitialized_buffer(... | code_fim | hard | {
"lang": "rust",
"repo": "yun-cloud/ruder",
"path": "/src/archive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
SortByDir::SORTBY_DEFAULT => "",
SortByDir::SORTBY_ASC => "ASC",
SortByDir::SORTBY_DESC => "DESC",
SortByDir::SORTBY_USING => unimplemented!("SortByDir::SORTBY_USING"),
}
.into()
}
}<|fim_prefix|>// repo: isgasho/pg-s... | code_fim | easy | {
"lang": "rust",
"repo": "isgasho/pg-schema-diff",
"path": "/src/nodes/sort_by_dir.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/pg-schema-diff path: /src/nodes/sort_by_dir.rs
use crate::schema_set::Sql;
use postgres_parser::sys::SortByDir;
<|fim_suffix|> match self {
SortByDir::SORTBY_DEFAULT => "",
SortByDir::SORTBY_ASC => "ASC",
SortByDir::SORTBY_DESC => "DESC",
... | code_fim | easy | {
"lang": "rust",
"repo": "isgasho/pg-schema-diff",
"path": "/src/nodes/sort_by_dir.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oooooba/wasmc path: /src/machineir/module.rs
use context::handle::{FunctionHandle, ModuleHandle, RegionHandle};
use context::Context;
use machineir::region::RegionKind;
use machineir::typ::Type;
use pass::{BasicBlockPass, FunctionPass, ModulePass};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enu... | code_fim | hard | {
"lang": "rust",
"repo": "oooooba/wasmc",
"path": "/src/machineir/module.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_mut_global_regions(&mut self) -> &mut Vec<RegionHandle> {
&mut self.global_regions
}
pub fn create_global_region(&mut self, kind: RegionKind) -> RegionHandle {
let region = Context::create_region(kind);
self.global_regions.push(region);
region
}
... | code_fim | hard | {
"lang": "rust",
"repo": "oooooba/wasmc",
"path": "/src/machineir/module.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: greyhill/dsock path: /examples/simple_worker.rs
extern crate dsock;
use std::io::Write;
pub fn main() -> () {
let (mut stream, id) = dsock::get_master_stream().unwrap();
<|fim_suffix|>rror writing");
stream.flush().ok().expect("error flushing");
}<|fim_middle|>let b: [u8; 1] = [42]... | code_fim | medium | {
"lang": "rust",
"repo": "greyhill/dsock",
"path": "/examples/simple_worker.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rror writing");
stream.flush().ok().expect("error flushing");
}<|fim_prefix|>// repo: greyhill/dsock path: /examples/simple_worker.rs
extern crate dsock;
use std::io::Write;
pub fn main() -> () {
let (mut stream, id) = dsock::get_master_stream().unwrap();
<|fim_middle|>let b: [u8; 1] = [42]... | code_fim | medium | {
"lang": "rust",
"repo": "greyhill/dsock",
"path": "/examples/simple_worker.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: windoze/azure-key-vault-rs path: /src/apis/hsm_security_domain_api.rs
/*
* KeyVaultClient
*
* The key vault client performs cryptographic key operations and vault operations against the Key Vault service.
*
* The version of the OpenAPI document: 7.2
*
* Generated by: https://openapi-gene... | code_fim | hard | {
"lang": "rust",
"repo": "windoze/azure-key-vault-rs",
"path": "/src/apis/hsm_security_domain_api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/securitydomain/upload", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("api_version", &api... | code_fim | hard | {
"lang": "rust",
"repo": "windoze/azure-key-vault-rs",
"path": "/src/apis/hsm_security_domain_api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukasl93/msp430fr59941 path: /src/ta0.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - TimerAx Control Register"]
pub ta0ctl: TA0CTL,
#[doc = "0x02 - Timer_A Capture/Compare Control Register"]
pub ta0cctl0: TA0CCTL0,
#[doc = "0x04 - T... | code_fim | hard | {
"lang": "rust",
"repo": "lukasl93/msp430fr59941",
"path": "/src/ta0.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RReverser/serde-xml-rs path: /src/de/buffer.rs
use crate::debug_expect;
use crate::error::Result;
use std::{collections::VecDeque, io::Read};
use xml::reader::{EventReader, XmlEvent};
/// Retrieve XML events from an underlying reader.
pub trait BufferedXmlReader<R: Read> {
/// Get and "cons... | code_fim | hard | {
"lang": "rust",
"repo": "RReverser/serde-xml-rs",
"path": "/src/de/buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn child_buffer<'root>(&'root mut self) -> ChildXmlBuffer<'root, R> {
let RootXmlBuffer { reader, buffer } = self;
ChildXmlBuffer {
reader,
buffer,
cursor: 0,
}
}
}
pub struct ChildXmlBuffer<'parent, R: Read> {
reader: &'parent mut E... | code_fim | hard | {
"lang": "rust",
"repo": "RReverser/serde-xml-rs",
"path": "/src/de/buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match buffer.get_mut(*index) {
Some(CachedXmlEvent::Unused(_)) => break,
Some(CachedXmlEvent::Used) => {
*index += 1;
}
None => {
let next = next_significant_event(reader)?;
buffer.push_back(... | code_fim | hard | {
"lang": "rust",
"repo": "RReverser/serde-xml-rs",
"path": "/src/de/buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_path_node(&node, c),
_ => {}
};
}
fn transpile_placeholder(_c: &mut Context) {
//
}<|fim_prefix|>// repo: illlust/danube path: /danube-runtime-javascript/src/transpile/pattern_kind.rs
use super::*;
pub(super) fn transpile_pattern_kind(node: &PatternKind, c: &mut Context) {
match node {
P... | code_fim | medium | {
"lang": "rust",
"repo": "illlust/danube",
"path": "/danube-runtime-javascript/src/transpile/pattern_kind.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: illlust/danube path: /danube-runtime-javascript/src/transpile/pattern_kind.rs
use super::*;
pub(super) fn transpile_pattern_kind(node: &PatternKind, c: &mut Context) {
<|fim_suffix|>ral(node) => transpile_literal_value_kind(&node, c),
PatternKind::Path(node) => transpile_path_node(&node, c... | code_fim | medium | {
"lang": "rust",
"repo": "illlust/danube",
"path": "/danube-runtime-javascript/src/transpile/pattern_kind.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZcashFoundation/zebra path: /zebra-chain/src/sapling/spend.rs
//! Sapling spends for `V4` and `V5` `Transaction`s.
//!
//! Zebra uses a generic spend type for `V4` and `V5` transactions.
//! The anchor change is handled using the `AnchorVariant` type trait.
use std::{convert::TryInto, fmt, io};... | code_fim | hard | {
"lang": "rust",
"repo": "ZcashFoundation/zebra",
"path": "/zebra-chain/src/sapling/spend.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(reader.read_64_bytes()?.into())
}
}
/// The size of a spend with a per-spend anchor.
pub(crate) const ANCHOR_PER_SPEND_SIZE: u64 = SHARED_ANCHOR_SPEND_SIZE + 32;
/// The size of a spend with a shared anchor, without associated fields.
///
/// This is the size of spends in the initial arra... | code_fim | hard | {
"lang": "rust",
"repo": "ZcashFoundation/zebra",
"path": "/zebra-chain/src/sapling/spend.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coffeecup-winner/unwind-mc path: /lib/src/flow_analyzer.rs
use either::*;
use common::*;
use il::*;
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct ConditionalBlock<Op: Clone> {
pub condition: Vec<ILInstruction<Op>>,
pub true_branch: Vec<Block<Op>>,
pub fa... | code_fim | hard | {
"lang": "rust",
"repo": "coffeecup-winner/unwind-mc",
"path": "/lib/src/flow_analyzer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn scope(
loop_bounds: &LoopBounds,
list: &[(usize, ILInstruction<ILOperand>, Option<usize>)],
) -> UResult<Vec<Block<ILOperand>>> {
let mut seq = vec![];
sequence(loop_bounds, list, &mut seq)?;
let mut result = vec![];
let mut insns = vec![];
for elem in seq {
if let L... | code_fim | hard | {
"lang": "rust",
"repo": "coffeecup-winner/unwind-mc",
"path": "/lib/src/flow_analyzer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut vsd = VSD::new();
vsd.write::<f32>("test_float_value", 0.5f32);
println!("{:?}", vsd.read::<f32>("test_float_value").unwrap());
}<|fim_prefix|>// repo: tzaeru/vsd-rs path: /examples/no_flushing.rs
extern crate vsd;
use vsd::{VSD, VSDUnlocked};
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "tzaeru/vsd-rs",
"path": "/examples/no_flushing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tzaeru/vsd-rs path: /examples/no_flushing.rs
extern crate vsd;
use vsd::{VSD, VSDUnlocked};
<|fim_suffix|> let mut vsd = VSD::new();
vsd.write::<f32>("test_float_value", 0.5f32);
println!("{:?}", vsd.read::<f32>("test_float_value").unwrap());
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "tzaeru/vsd-rs",
"path": "/examples/no_flushing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: herrerik/granne path: /src/types/mod.rs
use ordered_float::NotNaN;
use std::iter::FromIterator;
mod angular_vector;
mod mmap;
pub use self::angular_vector::*;
pub use self::mmap::*;
#[cfg(test)]
pub const DIST_EPSILON: f32 = 10.0 * ::std::f32::EPSILON;
pub trait ComparableTo<B: ?Sized> {
... | code_fim | medium | {
"lang": "rust",
"repo": "herrerik/granne",
"path": "/src/types/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut data: Vec<f32> = Vec::new();
for _ in 0..dim {
data.push(rng.gen::<f32>() - 0.5);
}
data.into_iter().collect()
}
}<|fim_prefix|>// repo: herrerik/granne path: /src/types/mod.rs
use ordered_float::NotNaN;
use std::iter::FromIterator;
mod angular_v... | code_fim | hard | {
"lang": "rust",
"repo": "herrerik/granne",
"path": "/src/types/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hbowers/sneat path: /src/components/shape.rs
use amethyst::ecs::{Component, DenseVecStorage};
<|fim_suffix|>impl Shape {
pub fn new(width: f32, height: f32) -> Shape {
Shape { width, height }
}
}
impl Component for Shape {
type Storage = DenseVecStorage<Self>;
}<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "Hbowers/sneat",
"path": "/src/components/shape.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Component for Shape {
type Storage = DenseVecStorage<Self>;
}<|fim_prefix|>// repo: Hbowers/sneat path: /src/components/shape.rs
use amethyst::ecs::{Component, DenseVecStorage};
<|fim_middle|>pub struct Shape {
pub width: f32,
pub height: f32,
}
impl Shape {
pub fn new(width: f32, ... | code_fim | medium | {
"lang": "rust",
"repo": "Hbowers/sneat",
"path": "/src/components/shape.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
#[derive(Deserialize)]
pub struct IdRequest {
id: String,
text: Option<String>,
}
async fn get(info: web::Query<IdRequest>, db: web::Data<r2d2::Pool<RedisConnectionManager>>) -> Result<HttpResponse, Error> {
let id = format!("{}",info.id);
let txt = info.text.as_ref().map(|... | code_fim | hard | {
"lang": "rust",
"repo": "sjisjis/rust-actix-web-sample",
"path": "/redis/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sjisjis/rust-actix-web-sample path: /redis/src/main.rs
use actix_web::{http::StatusCode, web, App, HttpResponse, HttpServer, Result};
use log::error;
use r2d2_redis::{r2d2, redis::Commands, RedisConnectionManager};
use serde_derive::Deserialize;
use std::{ops::DerefMut, time::Duration};
use stru... | code_fim | hard | {
"lang": "rust",
"repo": "sjisjis/rust-actix-web-sample",
"path": "/redis/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Set cells
add.set(0, 3, 0);
// Iterate through the matrix (row by row)
for val in add {
print!("{} ", val);
}
```
# Example: Dot product
```
let mat: Matrix<f64> = Matrix::from_iter(2, 4, 0..);
// Construct the transposed matrix
let mat_t = mat.transpose();
// Construct the dot product
let dot ... | code_fim | hard | {
"lang": "rust",
"repo": "ivandardi/simple-matrix",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivandardi/simple-matrix path: /src/lib.rs
/*!
# Matrix-rs: A generic matrix library in Rust
Matrix-rs is a simple matrix library designed to be easy to use.
# Disclaimer
This crate should not be considered mature enough for *professional use*, check alternatives like [cgmath](https://github.com... | code_fim | hard | {
"lang": "rust",
"repo": "ivandardi/simple-matrix",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// OpAssign are also available
sub += &zero;
sub -= zero;
// Get cells
let val: &u32 = add.get(0, 3).unwrap();
// Set cells
add.set(0, 3, 0);
// Iterate through the matrix (row by row)
for val in add {
print!("{} ", val);
}
```
# Example: Dot product
```
let mat: Matrix<f64> = Matrix::from_iter(2... | code_fim | hard | {
"lang": "rust",
"repo": "ivandardi/simple-matrix",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.self_drive_enabled = enable;
}
fn set_tracker_state(&mut self, tracker_state: TrackerState) {
self.tracker_state = tracker_state;
}
fn set_slam_scale(&mut self, slam_scale: f64) {
self.slam_scale = slam_scale;
}
fn is_expired(time: Instant) -> bool {... | code_fim | hard | {
"lang": "rust",
"repo": "CoreTrackProject/good-bug",
"path": "/rust/src/navigator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.