text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> if let Mesh::$variant(inner) = mesh {
Some(inner)
} else {
None
}
}
#[inline]
#[allow(irrefutable_let_patterns)]
fn unwrap_texture(tex... | code_fim | hard | {
"lang": "rust",
"repo": "dee-lers/amethyst",
"path": "/amethyst_rendy/src/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dee-lers/amethyst path: /amethyst_rendy/src/types.rs
//! 'Global' rendering type declarations
use amethyst_assets::Asset;
use serde::{Deserialize, Serialize};
use type_uuid::TypeUuid;
use crate::system::{MeshProcessorSystem, TextureProcessorSystem};
/// Extension of the rendy Backend trait.
pu... | code_fim | hard | {
"lang": "rust",
"repo": "dee-lers/amethyst",
"path": "/amethyst_rendy/src/types.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>amethyst_assets::register_asset_type!(MeshData => Mesh; MeshProcessorSystem<DefaultBackend>);
amethyst_assets::register_asset_type!(TextureData => Texture; TextureProcessorSystem<DefaultBackend>);
impl Asset for Mesh {
fn name() -> &'static str {
"Mesh"
}
type Data = MeshData;
}
impl... | code_fim | hard | {
"lang": "rust",
"repo": "dee-lers/amethyst",
"path": "/amethyst_rendy/src/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A counter per CSS 2.1 § 12.4.
struct Counter {
/// The values at each level.
values: Vec<CounterValue>,
}
impl Counter {
fn new() -> Counter {
Counter {
values: Vec::new(),
}
}
fn reset(&mut self, level: u32, value: i32) {
// Do we have an inst... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/layout/generated_content.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let quotes = &style.get_list().quotes;
if quotes.0.is_empty() {
return String::new()
}
let &(ref open_quote, ref close_quote) =
if self.traversal.quote as usize >= quotes.0.len() {
quotes.0.last().unwrap()
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/layout/generated_content.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/style-servo/components/layout/generated_content.rs
fn mutate_fragment(&mut self, fragment: &mut Fragment) {
// We only reset and/or increment counters once per flow. This avoids double-incrementing
// counters on list item... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/layout/generated_content.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: valarauca/lib_uapi_linux path: /build.rs
extern crate bindgen;
use bindgen::{Bindings,Builder};
use std::io::prelude::*;
use std::fs::{read_dir,DirEntry, File};
use std::path::PathBuf;
//get name+path+metadata
fn get_data(de: DirEntry) -> Option<(String,PathBuf)> {
//path to file
let p... | code_fim | hard | {
"lang": "rust",
"repo": "valarauca/lib_uapi_linux",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
//read kernel include files
let out = match read_dir("/usr/include/linux") {
Ok(dir) => {
let mut s = String::with_capacity(4000);
for x in dir.filter_map(|x| match x { Ok(y) => Some(y), _ => None})
.filter_map(get_data)
... | code_fim | hard | {
"lang": "rust",
"repo": "valarauca/lib_uapi_linux",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h7/src/stm32h747cm7/ethernet_dma/dmasbmr.rs
#[doc = "Register `DMASBMR` reader"]
pub type R = crate::R<DMASBMR_SPEC>;
#[doc = "Register `DMASBMR` writer"]
pub type W = crate::W<DMASBMR_SPEC>;
#[doc = "Field `FB` reader - Fixed Burst Length"]
pub type FB_R ... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h747cm7/ethernet_dma/dmasbmr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn test(_: Lexer::Cursor) {} //~ ERROR mismatched types
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/associated-inherent-types/regionck-2.rs
// Regression test for issue #109299.
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]
<|fim_middle|>struct Lexer<'d>(&... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/associated-inherent-types/regionck-2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/associated-inherent-types/regionck-2.rs
// Regression test for issue #109299.
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]
<|fim_suffix|>impl Lexer<'static> {
type Cursor = ();
}
fn test(_: Lexer::Cursor) {} //~ ERROR mismatched type... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/associated-inherent-types/regionck-2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Lexer<'static> {
type Cursor = ();
}
fn test(_: Lexer::Cursor) {} //~ ERROR mismatched types
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/associated-inherent-types/regionck-2.rs
// Regression test for issue #109299.
<|fim_middle|>#![feature(inherent_associated_types)]
#![... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/associated-inherent-types/regionck-2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rodrigocam/shotcaller path: /src/systems/game_stats_updater.rs
use crate::*;
/// Update the game statistics using the generated game events.
pub fn game_stats_updater_system(
game_events: &Vec<GameEvent>,
game_stats: &mut GameStats,
) -> SystemResult {
for ev in game_events.iter() {... | code_fim | medium | {
"lang": "rust",
"repo": "rodrigocam/shotcaller",
"path": "/src/systems/game_stats_updater.rs",
"mode": "psm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> 1,
GameEvent::TransferedGold(_, gold) => game_stats.earned_gold += gold,
_ => {}
}
}
Ok(())
}<|fim_prefix|>// repo: rodrigocam/shotcaller path: /src/systems/game_stats_updater.rs
use crate::*;
/// Update the game statistics using the generated game events.
pub fn... | code_fim | medium | {
"lang": "rust",
"repo": "rodrigocam/shotcaller",
"path": "/src/systems/game_stats_updater.rs",
"mode": "spm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomocy/rust-algorithm path: /binary_search/src/lib.rs
#[allow(dead_code)]
fn binary_search(set: &Vec<i32>, target: i32) -> Option<usize> {
<|fim_suffix|> let set = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
assert_eq!(5, binary_search(&set, 5).unwrap());
}
#[test]
fn find_no... | code_fim | hard | {
"lang": "rust",
"repo": "tomocy/rust-algorithm",
"path": "/binary_search/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn find_something() {
let set = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
assert_eq!(5, binary_search(&set, 5).unwrap());
}
#[test]
fn find_nothing() {
let set = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
assert_eq... | code_fim | hard | {
"lang": "rust",
"repo": "tomocy/rust-algorithm",
"path": "/binary_search/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let set = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
assert_eq!(5, binary_search(&set, 5).unwrap());
}
#[test]
fn find_nothing() {
let set = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
assert_eq!(true, binary_search(&set, -1).is_none());
}
}<|fim_prefix|>// repo: tomocy/r... | code_fim | hard | {
"lang": "rust",
"repo": "tomocy/rust-algorithm",
"path": "/binary_search/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in numbers.iter_mut(){
*x *= 3;
}
println!("numbers - {:?}",numbers);
}<|fim_prefix|>// repo: venkypolls/Rust-language-learnings path: /src/vectors.rs
use std::mem;
pub fn run(){
let mut numbers: Vec<i32> = vec![1,2,3,4,5];
numbers.push(6);
numbers.push(7);
nu... | code_fim | medium | {
"lang": "rust",
"repo": "venkypolls/Rust-language-learnings",
"path": "/src/vectors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: venkypolls/Rust-language-learnings path: /src/vectors.rs
use std::mem;
pub fn run(){
let mut numbers: Vec<i32> = vec![1,2,3,4,5];
numbers.push(6);
numbers.push(7);
numbers.pop();
println!("the numbers are {:?}",numbers);
println!("the first number is {}",numbers[0]);
... | code_fim | medium | {
"lang": "rust",
"repo": "venkypolls/Rust-language-learnings",
"path": "/src/vectors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonathanfisher/max32650-rs path: /src/rtc/rssa.rs
#[doc = "Reader of register RSSA"]
pub type R = crate::R<u32, super::RSSA>;
#[doc = "Writer for register RSSA"]
pub type W = crate::W<u32, super::RSSA>;
#[doc = "Register RSSA `reset()`'s with value 0"]
impl crate::ResetValue for super::RSSA {
... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanfisher/max32650-rs",
"path": "/src/rtc/rssa.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn rssa(&self) -> RSSA_R {
RSSA_R::new((self.bits & 0xffff_ffff) as u32)
}
}
impl W {
#[doc = "Bits 0:31 - This register contains the reload value for the sub-second alarm."]
#[inline(always)]
pub fn rssa(&mut self) -> RSSA_W {
RSSA_W { w: self }
}
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanfisher/max32650-rs",
"path": "/src/rtc/rssa.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FileReader {
pub fn new(path: PathBuf) -> Result<FileReader, Error> {
let file = File::open(path.as_path())?;
let reader = BufReader::new(file);
return Ok(FileReader { io_reader: reader });
}
pub fn read(&mut self, num_lines: usize) -> Vec<String> {
let mu... | code_fim | medium | {
"lang": "rust",
"repo": "Codezerker/fallout",
"path": "/src/xcode_output/file_reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Codezerker/fallout path: /src/xcode_output/file_reader.rs
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Error;
use std::path::PathBuf;
<|fim_suffix|>impl FileReader {
pub fn new(path: PathBuf) -> Result<FileReader, Error> {
let file = File::open(path.... | code_fim | medium | {
"lang": "rust",
"repo": "Codezerker/fallout",
"path": "/src/xcode_output/file_reader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn read(&mut self, num_lines: usize) -> Vec<String> {
let mut buffer: Vec<String> = vec![];
for _ in 0..num_lines {
let mut line_buffer = String::new();
if let Ok(read_count) = self.io_reader.read_line(&mut line_buffer) {
if read_count > 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "Codezerker/fallout",
"path": "/src/xcode_output/file_reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = include_str!("test_input.txt");
assert_eq!("ABCDEF".to_string(), parse(input));
}
}<|fim_prefix|>// repo: svartalf/rust-advent-of-code-2017 path: /src/days/day19/part1.rs
use std::str::FromStr;
use super::common::{Diagram, Cell};
pub fn parse(data: &str) -> String {
... | code_fim | medium | {
"lang": "rust",
"repo": "svartalf/rust-advent-of-code-2017",
"path": "/src/days/day19/part1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: svartalf/rust-advent-of-code-2017 path: /src/days/day19/part1.rs
use std::str::FromStr;
use super::common::{Diagram, Cell};
pub fn parse(data: &str) -> String {
let diagram = Diagram::from_str(data).unwrap();
println!("{:?}", diagram);
diagram
.inspect(|cell| println!("{:?... | code_fim | medium | {
"lang": "rust",
"repo": "svartalf/rust-advent-of-code-2017",
"path": "/src/days/day19/part1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn day19_part1_test1() {
let input = include_str!("test_input.txt");
assert_eq!("ABCDEF".to_string(), parse(input));
}
}<|fim_prefix|>// repo: svartalf/rust-advent-of-code-2017 path: /src/days/day19/part1.rs
use std::str::FromStr;
use super::common::{Diagram, Cell};
... | code_fim | medium | {
"lang": "rust",
"repo": "svartalf/rust-advent-of-code-2017",
"path": "/src/days/day19/part1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let entry = Entry { min_ip: 0, max_ip: 5, payload: Default::default() };
place_entry(&mut ip_table, &entry, value);
assert!(get_payload_ptr(0, &ip_table).is_some());
assert!(get_payload_ptr(5, &ip_table).is_some());
assert_eq!(get_payload_ptr(0, &ip_table).unwrap(), value);
let en... | code_fim | hard | {
"lang": "rust",
"repo": "dag-andersen/Rust-Memory-Map",
"path": "/src/Table/IpTable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dag-andersen/Rust-Memory-Map path: /src/Table/IpTable.rs
use crate::{u32Size, Entry, FileGenerator, Table, PayloadMap, u64Size};
use crate::Table::{IpTable, PATH, PAYLOAD};
use crate::Utils;
use memmap::MmapMut;
use std::fs;
pub fn place_entry(mmap: &mut MmapMut, entry: &Entry, value: u64) {
... | code_fim | hard | {
"lang": "rust",
"repo": "dag-andersen/Rust-Memory-Map",
"path": "/src/Table/IpTable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = 5;
let entry = Entry { min_ip: 0, max_ip: 5, payload: Default::default() };
place_entry(&mut ip_table, &entry, value);
assert!(get_payload_ptr(0, &ip_table).is_some());
assert!(get_payload_ptr(5, &ip_table).is_some());
assert_eq!(get_payload_ptr(0, &ip_table).unwrap(),... | code_fim | medium | {
"lang": "rust",
"repo": "dag-andersen/Rust-Memory-Map",
"path": "/src/Table/IpTable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yisar/serde_v8 path: /benches/abi.rs
#![feature(test)]
use rusty_v8 as v8;
use serde_v8;
use serde_v8::utils::{v8_do, BasicRuntime, js_exec};
extern crate test;
use test::Bencher;
fn bench_js(b: &mut Bencher, setup_src: &str, loop_src: &str) {
v8_do(|| {
let mut runtime = BasicRu... | code_fim | hard | {
"lang": "rust",
"repo": "yisar/serde_v8",
"path": "/benches/abi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> bench_js_loop(b, $iters, "var with_x = with_void", $jscode);
}
};
}
multibench!("add(with_x, 123, 321)", 100, abi_add_v8, abi_add_json, abi_add_void);
multibench!("promote(with_x, 'Aaron', 'O Mullan', 27)", 100, abi_promote_v8, abi_promote_json, abi_promote_void);
multibench!("su... | code_fim | hard | {
"lang": "rust",
"repo": "yisar/serde_v8",
"path": "/benches/abi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivfranco/baby-rgit path: /src/bin/commit_tree.rs
use std::time::SystemTime;
use argh::FromArgs;
use baby_rgit::cache::{sha256_to_hex, DBEnv, SHA256Output};
use baby_rgit::cmd::*;
fn main() {
<|fim_suffix|> if str.is_empty() {
return Err("empty commit comment".to_string());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ivfranco/baby-rgit",
"path": "/src/bin/commit_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if str.is_empty() {
return Err("empty commit comment".to_string());
}
Ok(str.to_string())
}<|fim_prefix|>// repo: ivfranco/baby-rgit path: /src/bin/commit_tree.rs
use std::time::SystemTime;
use argh::FromArgs;
use baby_rgit::cache::{sha256_to_hex, DBEnv, SHA256Output};
use baby_rgit... | code_fim | hard | {
"lang": "rust",
"repo": "ivfranco/baby-rgit",
"path": "/src/bin/commit_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awelkie/rustfst path: /rustfst/src/proptest_fst.rs
#![cfg(test)]
use proptest::prelude::*;
use crate::fst_impls::VectorFst;
use crate::fst_traits::MutableFst;
use crate::semirings::{Semiring, TropicalWeight};
use crate::Arc;
static MAX_NUM_STATES: usize = 100;
static MAX_ILABEL: usize = 100;
... | code_fim | hard | {
"lang": "rust",
"repo": "awelkie/rustfst",
"path": "/rustfst/src/proptest_fst.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Set final weights.
for (idx, final_weight) in final_weights.into_iter().enumerate() {
if let Some(_final_weight) = final_weight {
unsafe { fst.set_final_unchecked(idx, _final_weight) };
}
}
fst
... | code_fim | hard | {
"lang": "rust",
"repo": "awelkie/rustfst",
"path": "/rustfst/src/proptest_fst.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, M, NRM, C, P, PE, QSE> ExtendRouteMatcher<NRM> for SingleRouteBuilder<'a, M, C, P, PE, QSE>
where
M: RouteMatcher + Send + Sync + 'static,
NRM: RouteMatcher + Send + Sync + 'static,
C: PipelineHandleChain<P> + Send + Sync + 'static,
P: RefUnwindSafe + Send + Sync + 'static,
PE... | code_fim | hard | {
"lang": "rust",
"repo": "gotham-rs/gotham",
"path": "/gotham/src/router/builder/modify.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gotham-rs/gotham path: /gotham/src/router/builder/modify.rs
use hyper::Body;
use std::panic::RefUnwindSafe;
use crate::extractor::{PathExtractor, QueryStringExtractor};
use crate::pipeline::PipelineHandleChain;
use crate::router::builder::single::DefineSingleRoute;
use crate::router::builder::... | code_fim | hard | {
"lang": "rust",
"repo": "gotham-rs/gotham",
"path": "/gotham/src/router/builder/modify.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.coerce()
}
}
/// Describes the operation of extending a `RouteMatcher` on a route. This trait exists to remove
/// type clutter from the documentation of `SingleRouteBuilder::add_route_matcher`.
pub trait ExtendRouteMatcher<NRM>
where
NRM: RouteMatcher + Send + Sync + 'static,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "gotham-rs/gotham",
"path": "/gotham/src/router/builder/modify.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: insanebaba/rbatis path: /rbatis-core/src/postgres/types/point.rs
use geo_types::Point;
use crate::decode::Decode;
use crate::encode::Encode;
use crate::postgres::protocol::TypeId;
use crate::postgres::{PgData, PgRawBuffer, PgTypeInfo, PgValue, Postgres};
use crate::types::Type;
impl Type<Postg... | code_fim | hard | {
"lang": "rust",
"repo": "insanebaba/rbatis",
"path": "/rbatis-core/src/postgres/types/point.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let buf = [40, 48, 46, 48, 44, 49, 46, 48, 41];
let point: Point<f64> = Decode::<Postgres>::decode(PgValue::from_bytes(&buf)).unwrap();
assert_eq!(point, Point::new(0., 1.));
let point_str = r#"(52.0907,5.1214)"#;
let point: Point<f64> = Decode::<Postgres>::decode(PgValue::from_str(... | code_fim | medium | {
"lang": "rust",
"repo": "insanebaba/rbatis",
"path": "/rbatis-core/src/postgres/types/point.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TerminalStudio/nativeshell path: /nativeshell/src/shell/api_model.rs
use std::collections::HashMap;
use crate::codec::Value;
use super::{MenuHandle, Point, Rect, Size};
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub enum GeometryPreference... | code_fim | hard | {
"lang": "rust",
"repo": "TerminalStudio/nativeshell",
"path": "/nativeshell/src/shell/api_model.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PartialEq for MenuItem {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
#[derive(serde::Deserialize, Default, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Menu {
pub role: Option<MenuRole>,
pub items: Vec<MenuItem>,
}
#[derive(serde::Deserialize, Debug)... | code_fim | hard | {
"lang": "rust",
"repo": "TerminalStudio/nativeshell",
"path": "/nativeshell/src/shell/api_model.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laanwj/k210-sdk-stuff path: /rust/k210-console/src/color.rs
use k210_shared::board::lcd_colors::rgb565;
/** Basic color math. */
#[derive(Copy, Clone)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
#[allow(dead_code)]
pub a: u8,
}
impl Color {
pub const fn new(r: ... | code_fim | medium | {
"lang": "rust",
"repo": "laanwj/k210-sdk-stuff",
"path": "/rust/k210-console/src/color.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub const fn from_rgb565(val: u16) -> Color {
let rs = ((val >> 11) & 0x1f) as u8;
let gs = ((val >> 5) & 0x3f) as u8;
let bs = ((val >> 0) & 0x1f) as u8;
Color {
r: (rs << 3) | (rs >> 2),
g: (gs << 2) | (gs >> 4),
b: (bs << 3) | (bs ... | code_fim | hard | {
"lang": "rust",
"repo": "laanwj/k210-sdk-stuff",
"path": "/rust/k210-console/src/color.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tensorbase/tensorbase path: /crates/parquet/src/arrow/levels.rs
ity over emptiness
definition.push(if child_mask { l2 } else { l1 });
repetition.push(parent_rep);
merged_array_mask.push(merged_mask);
... | code_fim | hard | {
"lang": "rust",
"repo": "tensorbase/tensorbase",
"path": "/crates/parquet/src/arrow/levels.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // test "f" levels
let list_level = levels.get(3).unwrap();
let expected_level = LevelInfo {
definition: vec![3, 2, 3, 2, 3],
repetition: None,
array_offsets: vec![0, 1, 2, 3, 4, 5],
array_mask: vec![true, false, true, false, true],
... | code_fim | hard | {
"lang": "rust",
"repo": "tensorbase/tensorbase",
"path": "/crates/parquet/src/arrow/levels.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tensorbase/tensorbase path: /crates/parquet/src/arrow/levels.rs
| DataType::FixedSizeBinary(_) => {
// we return a vector of 1 value to represent the primitive
vec![self.calculate_child_levels(
array_offsets,
array... | code_fim | hard | {
"lang": "rust",
"repo": "tensorbase/tensorbase",
"path": "/crates/parquet/src/arrow/levels.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EVAyo/wt_analytics path: /src/schema.rs
table! {
chapters (id) {
id -> Int4,
relative_path -> Varchar,
visit_count -> Int8,
}
}
table! {
visits (id) {
id -> Int8,
chapter_id -> Int4,
timestamp -> Int8,
}
}
<|fim_suffix|>allow_tabl... | code_fim | easy | {
"lang": "rust",
"repo": "EVAyo/wt_analytics",
"path": "/src/schema.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>joinable!(visits -> chapters (chapter_id));
allow_tables_to_appear_in_same_query!(
chapters,
visits,
);<|fim_prefix|>// repo: EVAyo/wt_analytics path: /src/schema.rs
table! {
chapters (id) {
id -> Int4,
relative_path -> Varchar,
visit_count -> Int8,
}
}
<|fim_mid... | code_fim | medium | {
"lang": "rust",
"repo": "EVAyo/wt_analytics",
"path": "/src/schema.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Encode<'_, Postgres> for Time {
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull {
// TIME is encoded as the microseconds since midnight
let us = (*self - Time::MIDNIGHT).whole_microseconds() as i64;
Encode::<Postgres>::encode(&us, buf)
}
fn size_hint... | code_fim | medium | {
"lang": "rust",
"repo": "launchbadge/sqlx",
"path": "/sqlx-postgres/src/types/time/time.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(match value.format() {
PgValueFormat::Binary => {
// TIME is encoded as the microseconds since midnight
let us = Decode::<Postgres>::decode(value)?;
Time::MIDNIGHT + Duration::microseconds(us)
}
PgValueFormat::... | code_fim | hard | {
"lang": "rust",
"repo": "launchbadge/sqlx",
"path": "/sqlx-postgres/src/types/time/time.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: launchbadge/sqlx path: /sqlx-postgres/src/types/time/time.rs
use crate::decode::Decode;
use crate::encode::{Encode, IsNull};
use crate::error::BoxDynError;
use crate::types::Type;
use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueFormat, PgValueRef, Postgres};
use std::mem;
use ti... | code_fim | hard | {
"lang": "rust",
"repo": "launchbadge/sqlx",
"path": "/sqlx-postgres/src/types/time/time.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kimikan/rust-raft path: /src/define.rs
//1. lead election:
// if not received heartbeat message(with term) from Lead. self become candidate
// then start to lead election, term++, then vote self, self vote message to others.
// every node only be allowed to vote once at one term.
... | code_fim | hard | {
"lang": "rust",
"repo": "kimikan/rust-raft",
"path": "/src/define.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//error scenario
// after combine two partitions into one,
// if one lead received higher term then self, it becomes follower. downgrade
//error handling
pub enum Role {
None,
/*only 1 master in a cluster */
Master,
/* temp state for lead vote */
Candidate,
/* a more gene... | code_fim | hard | {
"lang": "rust",
"repo": "kimikan/rust-raft",
"path": "/src/define.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Add the trailing null byte that kbin has at the end of strings
data.reserve(1);
data.put_u8(0);
data.freeze()
},
node_type => {
let value = Value::from_string(node_type, &data, definition.is_array, ... | code_fim | hard | {
"lang": "rust",
"repo": "mbilker/kbinxml-rs",
"path": "/kbinxml/src/text_reader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbilker/kbinxml-rs path: /kbinxml/src/text_reader.rs
use std::borrow::Cow;
use std::num::ParseIntError;
use std::str::{self, Utf8Error};
use bytes::{BufMut, Bytes, BytesMut};
use quick_xml::events::attributes::Attributes;
use quick_xml::events::{BytesStart, BytesText, Event};
use quick_xml::nam... | code_fim | hard | {
"lang": "rust",
"repo": "mbilker/kbinxml-rs",
"path": "/kbinxml/src/text_reader.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((node_type, count, size, attributes))
}
fn handle_start(
&self,
e: BytesStart,
) -> Result<(NodeCollection, usize, Option<usize>), TextReaderError> {
let (node_type, count, size, attributes) = self.parse_attributes(e.attributes())?;
let is_array = co... | code_fim | hard | {
"lang": "rust",
"repo": "mbilker/kbinxml-rs",
"path": "/kbinxml/src/text_reader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nucleartaxi/raytracer path: /src/main.rs
use rand::*;
use std::rc::Rc;
use material::*;
use color::*;
use vec3::*;
use hittable::*;
mod image;
mod vec3;
mod color;
mod ray;
mod hittable;
mod utils;
mod camera;
mod material;
fn main() {
// println!("{:?}", vec3::Vec3::refract(&vec3::Vec3::n... | code_fim | hard | {
"lang": "rust",
"repo": "Nucleartaxi/raytracer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //render
let mut image_data: Vec<u8> = Vec::new();
// image::create_test_image(&mut image_data, WIDTH, HEIGHT);
for i in (0..(HEIGHT)).rev() {
println!("Lines remaining: {}", i + 1); //progress indicator in case of long renders
for j in 0..WIDTH {
let mut pixel_... | code_fim | hard | {
"lang": "rust",
"repo": "Nucleartaxi/raytracer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // world.add(Sphere::new(Vec3::new(-1.0, 0.0, -1.0), 0.5, Rc::new(Metal::new(Color::new(1.0, 1.0, 1.0), 0.1))));
// world.add(Sphere::new(Vec3::new(1.0, 0.0, -1.0), 0.5, Rc::new(Metal::new(Color::new(0.8, 0.6, 0.2), 0.0))));
let mut rng = rand::thread_rng();
for i in -4..5 {
for j... | code_fim | hard | {
"lang": "rust",
"repo": "Nucleartaxi/raytracer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MetricValues {
pub fn new() -> MetricValues {
MetricValues {
count: None,
metric_value: None,
}
}
}<|fim_prefix|>// repo: ExternalReality/cider-rust path: /teamcity_apis/src/models/metric_values.rs
/*
* TeamCity REST API
*
* No description provided ... | code_fim | hard | {
"lang": "rust",
"repo": "ExternalReality/cider-rust",
"path": "/teamcity_apis/src/models/metric_values.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ExternalReality/cider-rust path: /teamcity_apis/src/models/metric_values.rs
/*
* TeamCity REST API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2018.1
*
* Generated by: https://open... | code_fim | hard | {
"lang": "rust",
"repo": "ExternalReality/cider-rust",
"path": "/teamcity_apis/src/models/metric_values.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
impl PartialEq for Handle {
fn eq(&self, other: &Handle) -> bool {
self.borrow().0 == other.borrow().0
}
}
impl SerializeDocument for Handle {
fn serialize_document<W: Write>(self, s: DocumentSerializer<W>) {
match *self.borrow() {
(Node::D... | code_fim | hard | {
"lang": "rust",
"repo": "martinrlilja/borealis",
"path": "/borealis/src/dom/handle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug)]
pub struct WeakHandle(Weak<RefCell<(Node, Option<WeakHandle>)>>);
impl WeakHandle {
pub fn upgrade(&self) -> Handle {
Handle(self.0.upgrade().unwrap())
}
}
impl Deref for WeakHandle {
type Target = Weak<RefCell<(Node, Option<WeakHandle>)>>;
fn deref(&self... | code_fim | hard | {
"lang": "rust",
"repo": "martinrlilja/borealis",
"path": "/borealis/src/dom/handle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: martinrlilja/borealis path: /borealis/src/dom/handle.rs
use std::cell::RefCell;
use std::io::Write;
use std::ops::Deref;
use std::rc::{Rc, Weak};
use html5ever::tree_builder::TreeSink;
use html5ever::tendril::{StrTendril, TendrilSink};
use string_cache::QualName;
use serializer::{SerializeDo... | code_fim | hard | {
"lang": "rust",
"repo": "martinrlilja/borealis",
"path": "/borealis/src/dom/handle.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsIControllers.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIControllers.idl
//
#[repr(C)]
pub struct nsIControllers {
vtable: *const nsIControllersVTable,
/// This field is a phantomdata to ensure that the VTable type and a... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIControllers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: afilini/kaleidoscope path: /src/kaleidoscope/sync.rs
use std::collections::HashMap;
use bitcoin::network::constants::Network;
use bitcoin::network::serialize::BitcoinHash;
use bitcoin::OutPoint;
use bitcoin::util::hash::Sha256dHash;
use clap::ArgMatches;
use jsonrpc;
use jsonrpc::client::Client... | code_fim | hard | {
"lang": "rust",
"repo": "afilini/kaleidoscope",
"path": "/src/kaleidoscope/sync.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fetch_transactions(client, &needed_tx, &mut needed_map);
let valid = p.verify(&needed_map);
if !valid {
println!(" [INVALID]");
continue;
}
println!(" [VALID]");
datab... | code_fim | hard | {
"lang": "rust",
"repo": "afilini/kaleidoscope",
"path": "/src/kaleidoscope/sync.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !valid {
println!(" [INVALID]");
continue;
}
println!(" [VALID]");
database.save_proof(&p, &outpoint.txid);
}
}
Ok(())
}
}<|fim_prefix|>// repo: afilini/kaleidoscope... | code_fim | hard | {
"lang": "rust",
"repo": "afilini/kaleidoscope",
"path": "/src/kaleidoscope/sync.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fabura/rust-stream-machine path: /tsp-core/src/tsp/partitioners/partitioner.rs
use std::fmt::Debug;
use std::hash::Hash;
use std::marker::PhantomData;
pub trait Partitioner {
type Event;
type T: Debug + Clone + Eq + Hash;
<|fim_suffix|>impl<'a, E, T, F> Partitioner for FunctionPartitio... | code_fim | hard | {
"lang": "rust",
"repo": "fabura/rust-stream-machine",
"path": "/tsp-core/src/tsp/partitioners/partitioner.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn partition_key(&self, _event: &Self::Event) -> Self::T {}
}
impl<'a, E, T, F> Partitioner for FunctionPartitioner<'a, E, T, F>
where
F: Fn(&'a E) -> T,
T: Debug + Clone + Eq + Hash,
{
type Event = &'a E;
type T = T;
fn partition_key(&self, event: &Self::Event) -> Self::T {
... | code_fim | hard | {
"lang": "rust",
"repo": "fabura/rust-stream-machine",
"path": "/tsp-core/src/tsp/partitioners/partitioner.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl<'a, E, T, F> Partitioner for FunctionPartitioner<'a, E, T, F>
where
F: Fn(&'a E) -> T,
T: Debug + Clone + Eq + Hash,
{
type Event = &'a E;
type T = T;
fn partition_key(&self, event: &Self::Event) -> Self::T {
(self.func)(event)
}
}<|fim_prefix|>// repo: fabura/rust... | code_fim | hard | {
"lang": "rust",
"repo": "fabura/rust-stream-machine",
"path": "/tsp-core/src/tsp/partitioners/partitioner.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{: ^1$}", "*", self.width() as usize);
}
fn draw_tree(&self) {
for i in 0..self.height {
let level_width = i * 2 + 1;
println!(
"{: ^1$}",
String::from_utf8(vec![b'X'; level_width as usize]).unwrap(),
... | code_fim | medium | {
"lang": "rust",
"repo": "ChiefGokhlayeh/rust-sandbox",
"path": "/christmastree/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.height * 2 - 1
}
}
fn main() {
let matches = App::new(crate_name!())
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
.arg(
Arg::with_name("withStar")
.short("w")
.long("withS... | code_fim | hard | {
"lang": "rust",
"repo": "ChiefGokhlayeh/rust-sandbox",
"path": "/christmastree/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChiefGokhlayeh/rust-sandbox path: /christmastree/src/main.rs
use clap::{
crate_authors, crate_description, crate_name, crate_version, value_t_or_exit, App, Arg,
};
struct ChristmasTree {
height: u32,
has_star: bool,
}
impl ChristmasTree {
fn draw(&self) {
if self.has_st... | code_fim | medium | {
"lang": "rust",
"repo": "ChiefGokhlayeh/rust-sandbox",
"path": "/christmastree/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PeterDing/aget-rs path: /src/common/time.rs
use std::time::Duration;
use actix_rt::time::sleep;
use futures::{future::ready, stream::repeat, stream::Stream, FutureExt, StreamExt};
/// Inter<|fim_suffix|>= ()> {
repeat(()).then(move |_| sleep(timeout).then(|_| ready(())))
}<|fim_middle|>val... | code_fim | medium | {
"lang": "rust",
"repo": "PeterDing/aget-rs",
"path": "/src/common/time.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>val Stream
pub fn interval_stream(timeout: Duration) -> impl Stream<Item = ()> {
repeat(()).then(move |_| sleep(timeout).then(|_| ready(())))
}<|fim_prefix|>// repo: PeterDing/aget-rs path: /src/common/time.rs
use std::time::Duration;
use actix_rt::time::sleep;
use futures::{future<|fim_middle|>::re... | code_fim | medium | {
"lang": "rust",
"repo": "PeterDing/aget-rs",
"path": "/src/common/time.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
// drawe the cursor as relevant
}
let wl_ctx = self.wl_ctx.borrow();
let mut vk_ctx = self.vk_ctx.borrow_mut();
/*wl_ctx.window_map.borrow().with_windows_from_bottom_to_top(
|toplevel_surface, initial_place| {
... | code_fim | hard | {
"lang": "rust",
"repo": "Ella-0/warvk",
"path": "/src/ctx.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> let wl_ctx = self.wl_ctx.borrow();
let mut vk_ctx = self.vk_ctx.borrow_mut();
/*wl_ctx.window_map.borrow().with_windows_from_bottom_to_top(
|toplevel_surface, initial_place| {
if let Some(wl_surface) = toplevel_surface.get_surface() ... | code_fim | hard | {
"lang": "rust",
"repo": "Ella-0/warvk",
"path": "/src/ctx.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ella-0/warvk path: /src/ctx.rs
use std::cell::RefCell;
use std::rc::Rc;
use crate::vk::VkCtx;
use crate::wl::WlCtx;
pub trait RenderCtx {
fn render_windows(
&mut self,
token: smithay::wayland::compositor::CompositorToken<crate::shell::Roles>,
window_map: Rc<
... | code_fim | hard | {
"lang": "rust",
"repo": "Ella-0/warvk",
"path": "/src/ctx.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> .min_by_key(|x| x.1) {
list.swap(small, i);
}
}
list.iter(): [4, 3, 1, 2]
list.iter().enumerate(): [(0,4), (1, 3), (2,1), (3,2)]<|fim_prefix|>// repo: ryderstanley/rusty-sort path: /algorithim.rs
fn selection_sort<T: Ord>(list: &mut [i64]) {
for i in 0..li... | code_fim | medium | {
"lang": "rust",
"repo": "ryderstanley/rusty-sort",
"path": "/algorithim.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryderstanley/rusty-sort path: /algorithim.rs
fn selection_sort<T: Ord>(list: &mut [i64]) {
for i in 0..list.len() {
if let Some((j, _)) = list.iter()
.enumerate()
.skip(i)
<|fim_suffix|>: [4, 3, 1, 2]
list.iter().enumerate(): [(0,4),... | code_fim | medium | {
"lang": "rust",
"repo": "ryderstanley/rusty-sort",
"path": "/algorithim.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chris-henderson-alation/GHActionsRustTest path: /k8s/library/kind/src/lib.rs
use k8s_openapi::api::core::v1::Pod;
pub use kind_derive::*;
/// A type that implements Kind is capable of describing itself to outside systems, typically
/// by simply returning the name of their type.
///
/// This is... | code_fim | hard | {
"lang": "rust",
"repo": "chris-henderson-alation/GHActionsRustTest",
"path": "/k8s/library/kind/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Kind)]
struct Lol {}
assert_eq!(Lol {}.kind(), "Lol")
}
#[test]
fn unit() {
#[derive(Kind)]
enum AnEnum {
Variant,
}
assert_eq!(AnEnum::Variant.kind(), "AnEnum::Variant")
}
#[test]
fn unary_unnamed() {
... | code_fim | hard | {
"lang": "rust",
"repo": "chris-henderson-alation/GHActionsRustTest",
"path": "/k8s/library/kind/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>reqwest::Error> {
return reqwest::blocking::get(url.as_str())?.json::<Vec<AssetInfos>>();
}<|fim_prefix|>// repo: kuroidoruido/OctoDeps path: /src/http_client.rs
use crate::models::AssetInfos;
pub fn get_asse<|fim_middle|>t_info(url: String) -> Result<Vec<AssetInfos>, | code_fim | easy | {
"lang": "rust",
"repo": "kuroidoruido/OctoDeps",
"path": "/src/http_client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kuroidoruido/OctoDeps path: /src/http_client.rs
use crate::models::AssetInfos;
pub fn get_asset_info(url: String) -> Result<Vec<AssetInfos>, <|fim_suffix|>:get(url.as_str())?.json::<Vec<AssetInfos>>();
}<|fim_middle|>reqwest::Error> {
return reqwest::blocking: | code_fim | easy | {
"lang": "rust",
"repo": "kuroidoruido/OctoDeps",
"path": "/src/http_client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kuroidoruido/OctoDeps path: /src/http_client.rs
use crate::models::AssetInfos;
pub fn get_asse<|fim_suffix|>reqwest::Error> {
return reqwest::blocking::get(url.as_str())?.json::<Vec<AssetInfos>>();
}<|fim_middle|>t_info(url: String) -> Result<Vec<AssetInfos>, | code_fim | easy | {
"lang": "rust",
"repo": "kuroidoruido/OctoDeps",
"path": "/src/http_client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ecreeth/hhvm path: /hphp/hack/src/parser/minimal_syntax.rs
// Copyright (c) 2019, Facebook, Inc.
// All rights reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use ocamlrep_derive::OcamlRep;
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "ecreeth/hhvm",
"path": "/hphp/hack/src/parser/minimal_syntax.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let full_width = variant.iter_children().fold(0, f);
Self { full_width }
}
fn from_children(_: SyntaxKind, _offser: usize, nodes: &[&Self]) -> Self {
let mut full_width = 0;
for node in nodes {
let w = node.full_width;
full_width += w
... | code_fim | hard | {
"lang": "rust",
"repo": "ecreeth/hhvm",
"path": "/hphp/hack/src/parser/minimal_syntax.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joshradin/secure_com path: /src/encryption/generator.rs
use num::bigint::ToBigInt;
use num_bigint::{BigInt, BigUint};
use num_integer::lcm;
use num_traits::{One, Zero};
use rand::Rng;
use crate::encryption::rsa::RSAKeys;
/// Can generate pairs of RSA keys
pub struct RSAKeysGenerator {
key_... | code_fim | hard | {
"lang": "rust",
"repo": "joshradin/secure_com",
"path": "/src/encryption/generator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn egcd(a: BigInt, b: BigInt, x: &mut BigInt, y: &mut BigInt) -> BigInt {
if a == 0.into() {
*x = 0.into();
*y = 1.into();
return b;
}
let mut x1 = BigInt::zero();
let mut y1 = BigInt::zero();
let gcd = egcd(&b % &a, a.clone(), &mut x1, &mut y1);
*x = y1 -... | code_fim | hard | {
"lang": "rust",
"repo": "joshradin/secure_com",
"path": "/src/encryption/generator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_examples() {
assert_eq!(fuel(12), 2);
assert_eq!(fuel(14), 2);
assert_eq!(fuel(1969), 654);
assert_eq!(fuel(100756), 33583);
}
#[test]
fn test_examples_part2() {
assert_eq!(fuel(2), 0);
assert_eq!(recursive_fuel(1969), 96... | code_fim | hard | {
"lang": "rust",
"repo": "robinst/advent-of-code-2019",
"path": "/src/bin/day01.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fuel_mass = fuel(mass);
if fuel_mass > 0 {
fuel_mass + recursive_fuel(fuel_mass)
} else {
fuel_mass
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_examples() {
assert_eq!(fuel(12), 2);
assert_eq!(fuel(14), 2);
assert_eq!... | code_fim | hard | {
"lang": "rust",
"repo": "robinst/advent-of-code-2019",
"path": "/src/bin/day01.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: robinst/advent-of-code-2019 path: /src/bin/day01.rs
//! https://adventofcode.com/2019/day/1
fn main() {
let input = include_str!("../../input/2019/day01.txt");
let numbers: Vec<u64> = input
.lines()
.map(|line| line.parse().expect(&format!("{:?}", line)))
.collec... | code_fim | hard | {
"lang": "rust",
"repo": "robinst/advent-of-code-2019",
"path": "/src/bin/day01.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tower-rs/tower-http path: /tower-http/src/auth/mod.rs
//! Authorization related middleware.
<|fim_suffix|>#[doc(inline)]
pub use self::{
add_authorization::{AddAuthorization, AddAuthorizationLayer},
async_require_authorization::{
AsyncAuthorizeRequest, AsyncRequireAuthorization,... | code_fim | medium | {
"lang": "rust",
"repo": "tower-rs/tower-http",
"path": "/tower-http/src/auth/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[doc(inline)]
pub use self::{
add_authorization::{AddAuthorization, AddAuthorizationLayer},
async_require_authorization::{
AsyncAuthorizeRequest, AsyncRequireAuthorization, AsyncRequireAuthorizationLayer,
},
};<|fim_prefix|>// repo: tower-rs/tower-http path: /tower-http/src/auth/mod.... | code_fim | medium | {
"lang": "rust",
"repo": "tower-rs/tower-http",
"path": "/tower-http/src/auth/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (left, right) in iter {
result.insert(left, right);
}
result
}
}
impl<Left, Right> FromIterator<(Left, Right)> for BidirectionalMap<Left, Right>
where
Left: Ord,
Right: Ord,
{
fn from_iter<Iter: IntoIterator<Item = (Left, Right)>>(iter: Iter) -> Se... | code_fim | hard | {
"lang": "rust",
"repo": "task-rs/task-rs",
"path": "/crates/task-rs/src/utils/bidirectional_map/from_iter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: task-rs/task-rs path: /crates/task-rs/src/utils/bidirectional_map/from_iter.rs
use super::BidirectionalMap;
use core::iter::FromIterator;
use pipe_trait::*;
use std::rc::Rc;
impl<Left, Right> FromIterator<(Rc<Left>, Rc<Right>)> for BidirectionalMap<Left, Right>
where
Left: Ord,
Right: O... | code_fim | hard | {
"lang": "rust",
"repo": "task-rs/task-rs",
"path": "/crates/task-rs/src/utils/bidirectional_map/from_iter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod input {
pub use _core::input::*;
pub use _core::input_integrator::{
InputIntegrator,
InputIntegratorGameData,
InputIntegratorState,
};
pub use _core::input_integrator::input_integrator as integrator;
}
pub mod debug {
pub use _core::debugger::{
... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/snowmew",
"path": "/src/snowmew.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.