text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: placrosse/agildata-zero path: /src/proxy/physical_planner.rs
ncScheme::Inconsequential)
},
Rex::RexUnary { box ref rex, .. } => {
let mut potentials_builder = Some(PotentialsBuilder::new());
let r = self.get_encryption_scheme(rex, builder, ... | code_fim | hard | {
"lang": "rust",
"repo": "placrosse/agildata-zero",
"path": "/src/proxy/physical_planner.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(EncScheme::Potential)
},
// Delegate to the scheme of the enclosed expression
Rex::RexNested(box ref expr) => self.get_encryption_scheme(expr, builder, potentials, literals),
Rex::RexExprList(ref list) => {
for e in list {
... | code_fim | hard | {
"lang": "rust",
"repo": "placrosse/agildata-zero",
"path": "/src/proxy/physical_planner.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: placrosse/agildata-zero path: /src/proxy/physical_planner.rs
// set a default
let enc_plan = EncryptionPlan {
data_type: NativeType::UNKNOWN,
encryption: EncryptionType::NA,
key: None
};
... | code_fim | hard | {
"lang": "rust",
"repo": "placrosse/agildata-zero",
"path": "/src/proxy/physical_planner.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oday0311/imkey-core path: /wallet/coin-tron/src/tronapi.rs
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TronTxInput {
#[prost(string, tag = "2")]
pub raw_data: std::string::String,
}
#[derive(Clone, PartialEq, ::pr<|fim_suffix|> is_tron_header: bool,
}
#[derive(Clone, Partial... | code_fim | hard | {
"lang": "rust",
"repo": "oday0311/imkey-core",
"path": "/wallet/coin-tron/src/tronapi.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> is_tron_header: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TronMessageOutput {
#[prost(string, tag = "1")]
pub signature: std::string::String,
}<|fim_prefix|>// repo: oday0311/imkey-core path: /wallet/coin-tron/src/tronapi.rs
#[derive(Clone, PartialEq, ::prost::Message)]
pu... | code_fim | medium | {
"lang": "rust",
"repo": "oday0311/imkey-core",
"path": "/wallet/coin-tron/src/tronapi.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuilloteauQ/rayon-adaptive path: /src/bin/bench_logs.rs
#[cfg(feature = "logs")]
extern crate rayon_logs as rayon;
use rayon::ThreadPoolBuilder;
use rayon_adaptive::Policy;
use rayon_adaptive::{adaptive_sort, adaptive_sort_with_policies};
use std::env;
extern crate rand;
use rand::Rng;
fn rando... | code_fim | hard | {
"lang": "rust",
"repo": "GuilloteauQ/rayon-adaptive",
"path": "/src/bin/bench_logs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let slice_size: u32 = args[1].parse::<u32>().unwrap();
let num_threads: usize = args[2].parse::<usize>().unwrap();
let runs = 100;
// Reversed Vector
let inverted: Vec<u32> = (0..slice_size).rev().collect();
logs_with_vec(num_threads, runs, &inverted, "logs/inverted.html");
pr... | code_fim | hard | {
"lang": "rust",
"repo": "GuilloteauQ/rayon-adaptive",
"path": "/src/bin/bench_logs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arkamnite/yOShi path: /src/vga_buffer.rs
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)] // Each enum variant is stored as a u8
pub enum Colour {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3,
Red = 4,
Magenta = 5,
Brown = 6,
LightGray = 7,... | code_fim | hard | {
"lang": "rust",
"repo": "arkamnite/yOShi",
"path": "/src/vga_buffer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn new_line(&mut self) { /* TODO */
for row in 1..BUFFER_HEIGHT {
for col in 0..BUFFER_WIDTH {
let character = self.buffer.chars[row][col].read();
self.buffer.chars[row - 1][col].write(character); // Move each character in the rows upwards.
... | code_fim | hard | {
"lang": "rust",
"repo": "arkamnite/yOShi",
"path": "/src/vga_buffer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>har-iterator of
// the string which returns a result-type
// that you can unwrap() afterwards.
println!("{:?}", spam.chars().last()); // Some('!')
let spam = "Hello world!";
let fizz = &spam[..5];
println!("{}", fizz);
// Hello
}<|fim_prefix|>// repo: niilz/Automate-the-Boring... | code_fim | hard | {
"lang": "rust",
"repo": "niilz/Automate-the-Boring-Stuff-with-Rust",
"path": "/ch_06/ex02_indexing_and_slicing/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niilz/Automate-the-Boring-Stuff-with-Rust path: /ch_06/ex02_indexing_and_slicing/src/main.rs
fn main() {
// INDEXING DOES NOT WORK DIRECTLY
// (This has to do with the unicode implementation.
// Not every character in every language or emojis
// just take one index.)
let spa... | code_fim | hard | {
"lang": "rust",
"repo": "niilz/Automate-the-Boring-Stuff-with-Rust",
"path": "/ch_06/ex02_indexing_and_slicing/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DanWizard/rust-practice path: /for-loop/src/main.rs
fn main() {
let range = 1..=100;
let vector = vec!["string", "that", "other"];
for (inde<|fim_suffix|>ln!("number is {}, animal is {}", index, v)
}
}<|fim_middle|>x, v) in vector.iter().enumerate() {
print | code_fim | easy | {
"lang": "rust",
"repo": "DanWizard/rust-practice",
"path": "/for-loop/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ln!("number is {}, animal is {}", index, v)
}
}<|fim_prefix|>// repo: DanWizard/rust-practice path: /for-loop/src/main.rs
fn main() {
let range = 1..=100;
let vect<|fim_middle|>or = vec!["string", "that", "other"];
for (index, v) in vector.iter().enumerate() {
print | code_fim | medium | {
"lang": "rust",
"repo": "DanWizard/rust-practice",
"path": "/for-loop/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl User {
/// Creates a new user that will be authenticated by a FIDO2 token. It is probably
/// preferable to the Into<User> rather than using this function directly.
///
/// # Arguments
/// * `id` - The id of the user
/// * `name` - A user-friendly name to display
/// * `d... | code_fim | hard | {
"lang": "rust",
"repo": "kvnallsn/auth-rs",
"path": "/src/webauthn/user.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvnallsn/auth-rs path: /src/webauthn/user.rs
//! Represents a user to be validated
use serde::{Deserialize, Serialize};
use crate::webauthn::Device;
pub trait WebAuthnUser {
type Conn;
/// User Handle (e.g., user id) that can uniquely identify a user in the service/api.
/// Genera... | code_fim | medium | {
"lang": "rust",
"repo": "kvnallsn/auth-rs",
"path": "/src/webauthn/user.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joonazan/aper path: /aper-yew/src/wire_wrapped.rs
use serde::Deserialize;
use std::fmt::Debug;
use yew::format::{Binary, Bincode, Json, Text};
/// A format (conforming to the spec used by [yew::format]) that
/// dynamically interprets messages as either JSON or bincode, depending
/// on whether... | code_fim | medium | {
"lang": "rust",
"repo": "joonazan/aper",
"path": "/aper-yew/src/wire_wrapped.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: for<'de> Deserialize<'de>> From<Binary> for WireWrapped<T> {
fn from(bin: Binary) -> Self {
let j: Bincode<Result<T, _>> = bin.into();
WireWrapped {
value: j.0.unwrap(),
binary: true,
}
}
}<|fim_prefix|>// repo: joonazan/aper path: /aper-yew... | code_fim | hard | {
"lang": "rust",
"repo": "joonazan/aper",
"path": "/aper-yew/src/wire_wrapped.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theduke/rust path: /src/test/run-pass/specialization/auxiliary/specialization_cross_crate.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License,... | code_fim | hard | {
"lang": "rust",
"repo": "theduke/rust",
"path": "/src/test/run-pass/specialization/auxiliary/specialization_cross_crate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Foo for String {
fn foo(&self) -> &'static str {
"String"
}
}
impl Foo for i32 {
fn foo(&self) -> &'static str {
"i32"
}
}
pub trait MyMarker {}
impl<T: Clone + MyMarker> Foo for T {
default fn foo(&self) -> &'static str {
"generic Clone + MyMarker"
}... | code_fim | hard | {
"lang": "rust",
"repo": "theduke/rust",
"path": "/src/test/run-pass/specialization/auxiliary/specialization_cross_crate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ToTokens for Ident {
fn to_tokens(&self, tokens: &mut TokenStream) {
proc_macro2::Ident::new(&self.0, Span::call_site()).to_tokens(tokens);
}
}<|fim_prefix|>// repo: 8BitMate/reflect path: /src/ident.rs
use proc_macro2::{Span, TokenStream};
use quote::ToTokens;
use std::fmt::{self, D... | code_fim | medium | {
"lang": "rust",
"repo": "8BitMate/reflect",
"path": "/src/ident.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 8BitMate/reflect path: /src/ident.rs
use proc_macro2::{Span, TokenStream};
use quote::ToTokens;
use std::fmt::{self, Display};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Ident(String);
impl Ident {
pub fn new<T: Display>(ident: T) -> Self {
Ident(ident... | code_fim | medium | {
"lang": "rust",
"repo": "8BitMate/reflect",
"path": "/src/ident.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hfcredidio/aoc_2020 path: /src/day10.rs
use std::collections::HashMap;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::iter::Peekable;
use std::path::Path;
pub fn day10(path: &Path) {
let sorted_numbers = || {
let file = File::open(path).unwrap();
l... | code_fim | hard | {
"lang": "rust",
"repo": "hfcredidio/aoc_2020",
"path": "/src/day10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
I: Iterator,
F: Fn(&I::Item) -> bool + Copy,
{
let mut out = Vec::new();
loop {
match peek.next_if(accept) {
None => return out,
Some(value) => out.push(value),
}
}
}
fn combinations<I>(outlet: i64, mut adaptors: Peekable<I>) -> i64
where
... | code_fim | hard | {
"lang": "rust",
"repo": "hfcredidio/aoc_2020",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("You entered {}", num);
if num < 5 && num > 0{
println!("Number is less than 5");
}
else if num < 10 && num > 0 {
println!("Number is greater than 5");
}
else {
println!("Number is out of range 1 - 10");
}
}<|fim_prefix|>// repo: bombadil7/rus... | code_fim | medium | {
"lang": "rust",
"repo": "bombadil7/rust",
"path": "/control_structures/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bombadil7/rust path: /control_structures/src/main.rs
use std::io::stdin;
fn main() {
println!("Enter a number between 1 and 10 ");
let mut num = String::new();
stdin().read_line(&mut num).expect("Failed to read line");
let num: u32 = match num.trim().parse() {
Ok(num) =... | code_fim | medium | {
"lang": "rust",
"repo": "bombadil7/rust",
"path": "/control_structures/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yasukotelin/best_past_questions_100 path: /4_c_karaoke/src/main.rs
fn main() {
let input: Vec<i32> = read_vec();
let students_number: i32 = input[0];
let music_number: i32 = input[1];
let students_scores: Vec<Vec<i32>> = read_vec2(students_number);
<|fim_suffix|>fn get_max(a: i3... | code_fim | hard | {
"lang": "rust",
"repo": "yasukotelin/best_past_questions_100",
"path": "/4_c_karaoke/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_max(a: i32, b: i32) -> i32 {
if a > b {
a
} else {
b
}
}
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<S... | code_fim | hard | {
"lang": "rust",
"repo": "yasukotelin/best_past_questions_100",
"path": "/4_c_karaoke/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: K0bin/SourceRenderer path: /platform/web/lib/src/window.rs
use std::sync::Arc;
use web_sys::{Document, HtmlCanvasElement, Window as HTMLWindow, window};
use sourcerenderer_core::platform::Window;
use sourcerenderer_webgl::{WebGLDevice, WebGLInstance, WebGLSurface, WebGLSwapchain};
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "K0bin/SourceRenderer",
"path": "/platform/web/lib/src/window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Arc::new(WebGLSwapchain::new(&surface, device.sender(), device.handle_allocator()))
}
fn width(&self) -> u32 {
self.canvas.width()
}
fn height(&self) -> u32 {
self.canvas.height()
}
}<|fim_prefix|>// repo: K0bin/SourceRenderer path: /platform/web/lib/src/window.rs
use std::sync::A... | code_fim | hard | {
"lang": "rust",
"repo": "K0bin/SourceRenderer",
"path": "/platform/web/lib/src/window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>abb3<f32>,
BodyPose3<f32>,
>;
pub type MyPhysicalEntityParts<'a> = DefaultPhysicalEntityParts<'a, ObjectType>;*/
pub type CustomTrans<'a, 'b> = Trans<GameData<'a, 'b>, AllEvents>;<|fim_prefix|>// repo: HoppinWorld/runtime path: /src/util/aliases.rs
use amethyst::utils::scene::BasicScenePrefab;
use cr... | code_fim | medium | {
"lang": "rust",
"repo": "HoppinWorld/runtime",
"path": "/src/util/aliases.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HoppinWorld/runtime path: /src/util/aliases.rs
use amethyst::utils::scene::BasicScenePrefab;
use crate::util::AllEvents;
use amethyst::prelude::*;
use amethyst::renderer::rendy::mesh::*;
use crate::component::ObjectType;
pub type<|fim_suffix|>
pub type DefaultPhysicalEntityParts<'a, T> = Physic... | code_fim | medium | {
"lang": "rust",
"repo": "HoppinWorld/runtime",
"path": "/src/util/aliases.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_MouseScrollEvent.rs
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = MouseEvent , extends = UiEvent , extends = Event , extends = :... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_MouseScrollEvent.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rollEvent" , js_name = initMouseScrollEvent)]
#[doc = "The `initMouseScrollEvent()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseScrollEvent/initMouseScrollEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate f... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_MouseScrollEvent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match c {
'|' => Some(Operations::OR),
'*' => Some(Operations::REPETITION),
'.' => Some(Operations::CONCAT),
'(' => Some(Operations::LBRACKET),
')' => Some(Operations::RBRACKET),
'#' => Some(Operations::TERMINATOR),
... | code_fim | medium | {
"lang": "rust",
"repo": "wh75er/compilers",
"path": "/regex2fsm/src/syntax_tree/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn as_string(&self) -> &'static str {
match self {
Operations::OR => "|",
Operations::REPETITION => "*",
Operations::CONCAT => ".",
Operations::LBRACKET => "(",
Operations::RBRACKET => ")",
Operations::TERMINATOR => "#... | code_fim | hard | {
"lang": "rust",
"repo": "wh75er/compilers",
"path": "/regex2fsm/src/syntax_tree/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wh75er/compilers path: /regex2fsm/src/syntax_tree/mod.rs
pub mod parser;
mod utils;
#[derive(Debug)]
pub struct SyntaxTree {
pub entry: GrammarType,
pub left: Option<Box<SyntaxTree>>,
pub right: Option<Box<SyntaxTree>>,
}
#[derive(Debug, PartialEq)]
pub enum GrammarType {
OPERA... | code_fim | hard | {
"lang": "rust",
"repo": "wh75er/compilers",
"path": "/regex2fsm/src/syntax_tree/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antash-mishra/rust-playground path: /string.rs
use std::string;
use std::collections::HashMap;
fn main() {
//creating new string
let mut s = String::new();
let data = "Initial contents";
let s = data.to_string();
//the method works on literal directly
let d = "initial contents".to_string(... | code_fim | hard | {
"lang": "rust",
"repo": "antash-mishra/rust-playground",
"path": "/string.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//updating value
//1. Overwriting values
let mut scores4 = HashMap::new();
scores4.insert(String::from("Blue"), 10);
scores4.insert(String::from("Blue"), 50);
println!("{:?}", scores4); //original value `10` has been overwritten by `50`
//2. Inserting key if they have no value using `entry`
let mut score... | code_fim | hard | {
"lang": "rust",
"repo": "antash-mishra/rust-playground",
"path": "/string.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for b in "नमस्ते".bytes() {
println!("{}", b); // It returns each raw byte
//It returns 18 bytes that make up this string
}
//HashMap<K, V>
//creating New Hash Map
//HashMap can be created by two ways
//1. using `insert` element
let mut scores = HashMap::new();
scores.insert(String::from("Blue"), 10... | code_fim | hard | {
"lang": "rust",
"repo": "antash-mishra/rust-playground",
"path": "/string.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>og::migration(),
},
Migration {
name: "create_step_log".to_string(),
version: 2,
prefix: MigrationPrefix::Versioned,
sql: v2_create_step_log::migration(),
},
Migration {
name: "create_reset_count".to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "andoriyu/gazpacho",
"path": "/src/db/task_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/gazpacho path: /src/db/task_manager.rs
use refinery::{Migration, Runner};
use refinery_migrations::MigrationPrefix;
mod v1_create_task_log;
mod v2_create_step_log;
mod v3_reset_count;
// A hack because intellij-rust doesn't like working on modules that isn't clearly decl<|fim_suffix|>... | code_fim | hard | {
"lang": "rust",
"repo": "andoriyu/gazpacho",
"path": "/src/db/task_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RegisterMethodInvoking {
pub fn into_tokens(self, register_type: &str) -> Tokens {
let register_macro_name = Ident::new(
&format!("register_{}_vec", register_type),
Span::call_site(),
);
let (static_struct_name, arguments) = (self.static_struct_name... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/rust-prometheus",
"path": "/static-metric/src/register_macro.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tikv/rust-prometheus path: /static-metric/src/register_macro.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use proc_macro2::{Span, TokenStream as Tokens};
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::*;
use quote::quote;
<|fim_suffix|... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/rust-prometheus",
"path": "/static-metric/src/register_macro.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Matches `register_static_xxx_vec!(static_struct_name, name, desc, labels, ...)`.
pub struct RegisterMethodInvoking {
static_struct_name: Ident,
arguments: Vec<Expr>,
}
impl Parse for RegisterMethodInvoking {
fn parse(input: ParseStream) -> Result<Self> {
let static_struct_name = i... | code_fim | medium | {
"lang": "rust",
"repo": "tikv/rust-prometheus",
"path": "/static-metric/src/register_macro.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct RegisterProperty {
value: RegisterPropertyValue,
span: proc_macro2::Span,
}
impl RegisterProperty {
#[inline(always)]
fn is_access_modifier(&self) -> bool {
self.value.is_access_modifier()
}
}
impl Parse for RegisterProperty {
fn parse(input: ParseStream) -> syn::R... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/ioreg-proc",
"path": "/ioreg-proc/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcoffin/ioreg-proc path: /ioreg-proc/src/lib.rs
#![recursion_limit="128"]
#![allow(dead_code)]
extern crate proc_macro;
extern crate syn;
extern crate quote;
extern crate proc_macro2;
extern crate heck;
mod builder;
pub(crate) mod util;
use proc_macro::TokenStream;
use syn::{parse_macro_input... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/ioreg-proc",
"path": "/ioreg-proc/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RegisterGroup {
pub(crate) fn count_value(&self) -> u64 {
self.count
.as_ref()
.map(|c| c.value())
.unwrap_or(1)
}
pub(crate) fn byte_length(&self) -> u64 {
let single_size: u64 = self.members
.iter()
.map(|m| m.... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/ioreg-proc",
"path": "/ioreg-proc/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sha1s = chd.track_sha1s();
if let Ok(ref sha1s) = sha1s {
println!("SHA-1 hashes for tracks:");
for (i, sha1) in sha1s.iter().enumerate() {
print!("Track {}: ", i + 1);
for x in sha1.iter() {
print!("{:02x}", ... | code_fim | hard | {
"lang": "rust",
"repo": "Manorhos/imageparse",
"path": "/examples/open_chd_with_parents.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Manorhos/imageparse path: /examples/open_chd_with_parents.rs
use std::env;
use std::path::PathBuf;
use imageparse::Image;
use imageparse::chd::ChdImage;
fn main() {
env_logger::Builder::from_default_env()
.format_timestamp(None)
.filter_level(log::LevelFilter::Info)
... | code_fim | hard | {
"lang": "rust",
"repo": "Manorhos/imageparse",
"path": "/examples/open_chd_with_parents.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day8, part1)]
pub fn part1(program: &[Instruction]) -> i32 {
let (halted, acc) = detect_loop(program);
assert_eq!(halted, false);
acc
}
#[aoc(day8, part2)]
pub fn part2(program: &[Instruction]) -> i32 {
for (i, instruction) in program.iter().enumerate() {
// Swap jmp with no... | code_fim | hard | {
"lang": "rust",
"repo": "MattiasBuelens/advent-of-code-2020",
"path": "/src/day8.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.program[self.pc] {
Instruction::Acc(arg) => {
self.acc += arg;
self.pc += 1;
}
Instruction::Jmp(offset) => {
self.pc = ((self.pc as isize) + (offset as isize)) as usize;
}
Instruc... | code_fim | hard | {
"lang": "rust",
"repo": "MattiasBuelens/advent-of-code-2020",
"path": "/src/day8.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MattiasBuelens/advent-of-code-2020 path: /src/day8.rs
use std::collections::HashSet;
use std::str::FromStr;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Instruction {
Acc(i32),
Jmp(i32),
Nop(i32),
}
impl FromStr for Instruction {
type Err = ();
fn from_str(s: &str... | code_fim | hard | {
"lang": "rust",
"repo": "MattiasBuelens/advent-of-code-2020",
"path": "/src/day8.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Error! Cannot access private module.
// my_mod::private_nested_mod::function();
}<|fim_prefix|>// repo: sabahtalateh/rust_by_example path: /modules/src/bin/split.rs
// This declaration will look for a file named `my_mod.rs` or `my_mod/hello.rs` and will
// insert its contents inside a module ... | code_fim | hard | {
"lang": "rust",
"repo": "sabahtalateh/rust_by_example",
"path": "/modules/src/bin/split.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sabahtalateh/rust_by_example path: /modules/src/bin/split.rs
// This declaration will look for a file named `my_mod.rs` or `my_mod/hello.rs` and will
// insert its contents inside a module named `my` under this scope
mod my_mod;
<|fim_suffix|> my_mod::indirect_access();
my_mod::nested_m... | code_fim | medium | {
"lang": "rust",
"repo": "sabahtalateh/rust_by_example",
"path": "/modules/src/bin/split.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> function();
my_mod::function();
my_mod::indirect_access();
my_mod::nested_mod::function();
my_mod::call_public_function_in_my_mod();
my_mod::public_function_in_crate();
// Error! Visibility restriction.
// my_mod::nested_mod::public_function_in_my_mod();
// Error! C... | code_fim | medium | {
"lang": "rust",
"repo": "sabahtalateh/rust_by_example",
"path": "/modules/src/bin/split.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> true
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn should_be_prime() {
assert!(miller_rabin(&Integer::from(2)));
assert!(miller_rabin(&Integer::from(1000000007)));
}
#[test]
fn shouldnt_be_prime() {
assert!(!miller_rabin(&Integer::from(6)));
... | code_fim | hard | {
"lang": "rust",
"repo": "bkpedrosuper/RSA-Complexidade-Algoritmos",
"path": "/src/rsa/prime_generator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bkpedrosuper/RSA-Complexidade-Algoritmos path: /src/rsa/prime_generator.rs
use std::time::{SystemTime, UNIX_EPOCH};
use rug::Integer;
use rug::rand::{RandState};
use rug::Assign;
use super::utils;
pub fn get_prime(size: u32) -> Integer {
let mut rand = RandState::new();
let seed = Inte... | code_fim | hard | {
"lang": "rust",
"repo": "bkpedrosuper/RSA-Complexidade-Algoritmos",
"path": "/src/rsa/prime_generator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn connection() -> r2d2::Pool<ConnectionManager<MysqlConnection>> {
CONNECTION.clone()
}<|fim_prefix|>// repo: mkc188/clipboard path: /src/database.rs
use std::env;
use diesel::mysql::MysqlConnection;
use r2d2_diesel::ConnectionManager;
use r2d2;
<|fim_middle|>lazy_static! {
static ref CONN... | code_fim | hard | {
"lang": "rust",
"repo": "mkc188/clipboard",
"path": "/src/database.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkc188/clipboard path: /src/database.rs
use std::env;
use diesel::mysql::MysqlConnection;
use r2d2_diesel::ConnectionManager;
use r2d2;
<|fim_suffix|>pub fn connection() -> r2d2::Pool<ConnectionManager<MysqlConnection>> {
CONNECTION.clone()
}<|fim_middle|>lazy_static! {
static ref CONN... | code_fim | hard | {
"lang": "rust",
"repo": "mkc188/clipboard",
"path": "/src/database.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let SparseSet { sparse, dense, .. } = &mut *sparse_set;
// update sparse to reflect the new state of dense and data
sparse.bulk_allocate(dense[old_len], dense[dense.len() - 1]);
for (i, &entity) in dense[old_len..].iter().enumerate() {
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "leudz/shipyard",
"path": "/src/sparse_set/bulk_add_entity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leudz/shipyard path: /src/sparse_set/bulk_add_entity.rs
use crate::all_storages::{AllStorages, CustomStorageAccess};
use crate::component::Component;
use crate::entities::Entities;
use crate::entity_id::EntityId;
use crate::reserve::BulkEntityIter;
use crate::sparse_set::SparseSet;
#[cfg(doc)]
u... | code_fim | hard | {
"lang": "rust",
"repo": "leudz/shipyard",
"path": "/src/sparse_set/bulk_add_entity.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sparse.bulk_allocate(dense[old_len], dense[dense.len() - 1]);
for (i, &entity) in dense[old_len..].iter().enumerate() {
unsafe {
*sparse.get_mut_unchecked(entity) = EntityId::new((old_len + i) as u64);
... | code_fim | hard | {
"lang": "rust",
"repo": "leudz/shipyard",
"path": "/src/sparse_set/bulk_add_entity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ikeikeikeike/rust-gqls path: /src/db.rs
use diesel::prelude::*;
use diesel::r2d2::ConnectionManager;
<|fim_suffix|>pub fn get_db_pool() -> Pool {
let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<MysqlConnection>::new(db_url... | code_fim | medium | {
"lang": "rust",
"repo": "ikeikeikeike/rust-gqls",
"path": "/src/db.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_db_pool() -> Pool {
let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<MysqlConnection>::new(db_url);
r2d2::Pool::new(manager).expect("Failed to create DB Pool")
}<|fim_prefix|>// repo: ikeikeikeike/rust-gqls path: /src... | code_fim | medium | {
"lang": "rust",
"repo": "ikeikeikeike/rust-gqls",
"path": "/src/db.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let mut largest: u64 = 0;
for i in 0..(large_num.len() - buf_size + 1) {
// println!("{}", product_of(&large_num[i..(i + buf_size)]));
let p = product_of(&large_num[i..(i + buf_size)]);
if p > largest {
largest = p;
}
}
println!("The number is {}... | code_fim | hard | {
"lang": "rust",
"repo": "Niedzwiedzw/project_euler_rust",
"path": "/src/largestfactorofdigits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Niedzwiedzw/project_euler_rust path: /src/largestfactorofdigits.rs
//The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.
//Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this p... | code_fim | hard | {
"lang": "rust",
"repo": "Niedzwiedzw/project_euler_rust",
"path": "/src/largestfactorofdigits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kezenator/beam path: /src/exec/mod.rs
mod context;
mod error;
mod exp;
mod inbuilt;
mod func;
mod parser;
mod value;
<|fim_suffix|>pub type ExecResult<T> = std::result::Result<T, ExecError>;<|fim_middle|>#[cfg(test)]
mod tests;
pub use context::Context;
pub use error::ExecError;
pub use exp::E... | code_fim | hard | {
"lang": "rust",
"repo": "kezenator/beam",
"path": "/src/exec/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type ExecResult<T> = std::result::Result<T, ExecError>;<|fim_prefix|>// repo: kezenator/beam path: /src/exec/mod.rs
mod context;
mod error;
mod exp;
mod inbuilt;
mod func;
mod parser;
mod value;
<|fim_middle|>#[cfg(test)]
mod tests;
pub use context::Context;
pub use error::ExecError;
pub use exp::E... | code_fim | hard | {
"lang": "rust",
"repo": "kezenator/beam",
"path": "/src/exec/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Default, Clone)]
pub struct SumHasherBuilder {}
impl core::hash::BuildHasher for SumHasherBuilder {
type Hasher = SumHasher;
fn build_hasher(&self) -> Self::Hasher {
SumHasher { total: 0 }
}
}<|fim_prefix|>// repo: dennisss/dacha path: /pkg/common/src/hash.rs
/// Very simpl... | code_fim | medium | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/common/src/hash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn build_hasher(&self) -> Self::Hasher {
SumHasher { total: 0 }
}
}<|fim_prefix|>// repo: dennisss/dacha path: /pkg/common/src/hash.rs
/// Very simpler Hasher which just sums up the values passed to it.
/// Meant for use-cases such as hashing well defined enum values (where DOS is
/// not... | code_fim | hard | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/common/src/hash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dennisss/dacha path: /pkg/common/src/hash.rs
/// Very simpler Hasher which just sums up the values passed to it.
/// Meant for use-cases such as hashing well defined enum values (where DOS is
/// not a concern).
pub struct SumHasher {
total: u64,
}
impl core::hash::Hasher for SumHasher {
... | code_fim | medium | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/common/src/hash.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> utils::invoke_method(vm, class_path, method_name, method_signature, false);
}
it => panic!("Unexpected constant ref: {:?}", it),
};
Some(pc + 3)
}<|fim_prefix|>// repo: Pfarrer/rust-jvm path: /vm/src/eval/invokestatic.rs
use classfile::constants::Constant;
use model::cla... | code_fim | medium | {
"lang": "rust",
"repo": "Pfarrer/rust-jvm",
"path": "/vm/src/eval/invokestatic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pfarrer/rust-jvm path: /vm/src/eval/invokestatic.rs
use classfile::constants::Constant;
use model::class::*;
use vm::utils;
use crate::{Primitive, VmThread};
pub fn eval(vm_thread: &mut VmThread, jvm_class: &JvmClass, code: &Vec<u8>, pc: u16) -> Option<u16> {
let index = utils::read_u16_cod... | code_fim | medium | {
"lang": "rust",
"repo": "Pfarrer/rust-jvm",
"path": "/vm/src/eval/invokestatic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const EPSILON: f32 = 0.0001;<|fim_prefix|>// repo: ishmeister/rusterizer path: /src/lib.rs
#[macro_use]
extern crate approx;
<|fim_middle|>pub mod camera;
pub mod matrix;
pub mod rasterize;
pub mod shape;
pub mod triangle;
pub mod vector;
| code_fim | medium | {
"lang": "rust",
"repo": "ishmeister/rusterizer",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ishmeister/rusterizer path: /src/lib.rs
#[macro_use]
extern crate approx;
<|fim_suffix|>pub const EPSILON: f32 = 0.0001;<|fim_middle|>pub mod camera;
pub mod matrix;
pub mod rasterize;
pub mod shape;
pub mod triangle;
pub mod vector;
| code_fim | medium | {
"lang": "rust",
"repo": "ishmeister/rusterizer",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn convert_to_rust_type<T>(ref_ty: T) -> DResult<RustTypes>
where
T: Borrow<Type>,
{
let ty = ref_ty.borrow();
match ty {
Type::Reference(ref r) => convert_to_rust_type(r.elem.as_ref()),
Type::Path(ref path) => {
let seg0 = &path.path.segments[0];
le... | code_fim | hard | {
"lang": "rust",
"repo": "mart368b/foreignc",
"path": "/foreignc_derive/src/template.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mart368b/foreignc path: /foreignc_derive/src/template.rs
use super::error::DResult;
use core::borrow::Borrow;
pub use foreignc_template::{RustArgument, RustFunction, RustStructure, RustTypes};
use proc_macro2::Span;
use quote::ToTokens;
use syn::spanned::Spanned;
use syn::*;
pub fn to_rust_func... | code_fim | hard | {
"lang": "rust",
"repo": "mart368b/foreignc",
"path": "/foreignc_derive/src/template.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let ReturnType::Type(_, ref ty) = item.sig.output {
let tty = convert_to_rust_type(ty.as_ref())?;
f.output = Some(tty);
};
Ok(f)
}
pub fn convert_to_rust_type<T>(ref_ty: T) -> DResult<RustTypes>
where
T: Borrow<Type>,
{
let ty = ref_ty.borrow();
match ty {
... | code_fim | hard | {
"lang": "rust",
"repo": "mart368b/foreignc",
"path": "/foreignc_derive/src/template.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args = Args::parse();
let strand: Strand<AminoAcid> = args.strand.parse().unwrap();
println!("{}", strand.weight());
}<|fim_prefix|>// repo: nadrees/RustyRosalind path: /src/bin/prtm.rs
use clap::Parser;
use rusty_rosalind::args::StrandOnlyArgs as Args;
use rusty_rosalind::nucleotides::protein:... | code_fim | easy | {
"lang": "rust",
"repo": "nadrees/RustyRosalind",
"path": "/src/bin/prtm.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nadrees/RustyRosalind path: /src/bin/prtm.rs
use clap::Parser;
use rusty_rosalind::args::StrandOnlyArgs as Args;
use rusty_rosalind::nucleotides::protein::AminoAcid;
use rusty_rosalind::strands::Strand;
<|fim_suffix|> let args = Args::parse();
let strand: Strand<AminoAcid> = args.strand.pars... | code_fim | easy | {
"lang": "rust",
"repo": "nadrees/RustyRosalind",
"path": "/src/bin/prtm.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// 发起请求offer处理
let offer_route = warp::post()
.and(warp::path("offer"))
.and(warp::path::end())
.and(warp::body::json())
.and_then(handler::offer_handler);
let routes = ws_route
.or(offer_route)
.recover(handler::handle_rejection); //错误处理
... | code_fim | hard | {
"lang": "rust",
"repo": "malefooo/webrtc-demo",
"path": "/signal-server-rs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: malefooo/webrtc-demo path: /signal-server-rs/src/main.rs
#[macro_use]
extern crate log;
extern crate log4rs;
mod handler;
mod config;
use warp::{
http::{Response, StatusCode},
Filter,
};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use futures::{FutureExt, TryFutureExt};
use once_cel... | code_fim | hard | {
"lang": "rust",
"repo": "malefooo/webrtc-demo",
"path": "/signal-server-rs/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let routes = ws_route
.or(offer_route)
.recover(handler::handle_rejection); //错误处理
let server = c.server.unwrap();
let socket = SocketAddr::from_str(server.host.as_str()).unwrap();
warp::serve(routes).run(socket).await;
}<|fim_prefix|>// repo: malefooo/webrtc-demo path: ... | code_fim | hard | {
"lang": "rust",
"repo": "malefooo/webrtc-demo",
"path": "/signal-server-rs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makepad/makepad path: /tools/windows_strip/src/main.rs
f, what: &str) -> Option<usize>;
fn after(&self, what: &str) -> Option<&[TokenWithString]>;
fn at(&self, what: &str) -> Option<(&[TokenWithString], &[TokenWithString])>;
fn find_close(&self, delim: Delim) -> Option<&[TokenWithStr... | code_fim | hard | {
"lang": "rust",
"repo": "makepad/makepad",
"path": "/tools/windows_strip/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn generate_outputs_from_file( file: &str, output: &mut Node, cache: &mut Vec<(String, Vec<TokenWithString>)>) {
let source = parse_file(file, cache).unwrap();
let symbols = source.parse_use();
let symbols = filter_symbols(symbols, id!(crate.windows_crate));
fn add_impl(out: &mu... | code_fim | hard | {
"lang": "rust",
"repo": "makepad/makepad",
"path": "/tools/windows_strip/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makepad/makepad path: /tools/windows_strip/src/main.rs
let mut depth = 0;
for i in 0..source.len() {
if source[i].is_open() {
depth += 1;
}
else if source[i].is_close() {
if depth == 0 { // unexpected end
... | code_fim | hard | {
"lang": "rust",
"repo": "makepad/makepad",
"path": "/tools/windows_strip/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Debug for Cluster {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Cluster(0x?{:07x})", self.0)
}
}<|fim_prefix|>// repo: brekhus/fat32-rs path: /fat32/src/vfat/cluster.rs
use std::fmt;
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash)]
pub struct C... | code_fim | hard | {
"lang": "rust",
"repo": "brekhus/fat32-rs",
"path": "/fat32/src/vfat/cluster.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brekhus/fat32-rs path: /fat32/src/vfat/cluster.rs
use std::fmt;
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash)]
pub struct Cluster(u32);
<|fim_suffix|>impl fmt::Debug for Cluster {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Cluster(0x?{:07x})", s... | code_fim | hard | {
"lang": "rust",
"repo": "brekhus/fat32-rs",
"path": "/fat32/src/vfat/cluster.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn lr(scope: Scope) -> Self {
Match {
value: Value::None,
matched: false,
is_lr: true,
start: scope.clone(),
end: scope
}
}
pub fn ok(value: Value, start: Scope, end: Scope) -> Self {
Match {
value,
matched: true,
is_lr: false,
s... | code_fim | hard | {
"lang": "rust",
"repo": "justinmchase/verse-lang",
"path": "/src/runtime/match.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justinmchase/verse-lang path: /src/runtime/match.rs
use super::{
Value,
Scope,
};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Match {
pub value: Value,
pub matched: bool,
pub is_lr: bool,
pub start: Scope,
pub end: Scope
}
impl Match {
<|fim_suffix|> pub fn default(scope:... | code_fim | hard | {
"lang": "rust",
"repo": "justinmchase/verse-lang",
"path": "/src/runtime/match.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut tag_ids = vec![];
for tag in tag_data.to_owned() {
let t = Self {
tag_name: tag.name,
category: tag.category,
is_spoiler: tag.is_spoiler,
description: tag.description,
};
let ... | code_fim | hard | {
"lang": "rust",
"repo": "Egomination/mangapplizer_backend",
"path": "/src/models/tag.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Egomination/mangapplizer_backend path: /src/models/tag.rs
use crate::models::json_manga;
use crate::schema::tags;
use diesel::PgConnection;
#[derive(
Queryable,
QueryableByName,
Identifiable,
Associations,
Debug,
Serialize,
Deserialize,
AsChangeset,
)]
#[table_na... | code_fim | hard | {
"lang": "rust",
"repo": "Egomination/mangapplizer_backend",
"path": "/src/models/tag.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut count = 0_usize;
for (_, v) in map {
if v < 2 {
continue;
}
count += v * (v - 1) / 2;
}
let ans = count;
println!("{}", ans);
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/tessoku-book/src/bin/b54.rs
use std::col... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/tessoku-book/src/bin/b54.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/tessoku-book/src/bin/b54.rs
use std::collections::HashMap;
use proconio::input;
<|fim_suffix|> let mut count = 0_usize;
for (_, v) in map {
if v < 2 {
continue;
}
count += v * (v - 1) / 2;
}
l... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/tessoku-book/src/bin/b54.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rvarago/mini-balancer path: /src/balancing/middleware/route.rs
//! Decides which backend should handle an incoming connection.
use super::{selector, Pipe, PipeError};
use anyhow::Context;
use async_trait::async_trait;
use std::net::SocketAddr;
use tracing::trace;
<|fim_suffix|> async fn thr... | code_fim | hard | {
"lang": "rust",
"repo": "rvarago/mini-balancer",
"path": "/src/balancing/middleware/route.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Constructs a new [Router<R>].
pub fn route<R>(selector: R) -> Router<R> {
Router { selector }
}
#[async_trait]
impl<R, S> Pipe<S> for Router<R>
where
R: selector::Selector + Send + Sync + 'static,
R::Error: std::error::Error + Send + Sync,
S: Send + 'static,
{
type Output = (S, So... | code_fim | medium | {
"lang": "rust",
"repo": "rvarago/mini-balancer",
"path": "/src/balancing/middleware/route.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Logged::new(rayon::prelude::IntoParallelIterator::into_par_iter(self))
}
}
impl<I: rayon::prelude::IntoParallelIterator> IntoParallelIterator for I {}
/// `IntoParallelRefMutIterator` implements the conversion to a
/// [`ParallelIterator`], providing mutable references to the data.
///
/// T... | code_fim | hard | {
"lang": "rust",
"repo": "wagnerf42/rayon-logs",
"path": "/src/prelude.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'data, I: rayon::prelude::IntoParallelRefIterator<'data>> IntoParallelRefIterator<'data>
for I
{
}
/// `IntoParallelIterator` implements the conversion to a [`ParallelIterator`].
///
/// By implementing `IntoParallelIterator` for a type, you define how it will
/// transformed into an iterator. T... | code_fim | hard | {
"lang": "rust",
"repo": "wagnerf42/rayon-logs",
"path": "/src/prelude.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wagnerf42/rayon-logs path: /src/prelude.rs
//! We redefine (not all of them yet) rayon traits.
pub use rayon::prelude::ParallelIterator;
use crate::Logged;
/// `IntoParallelRefIterator` implements the conversion to a
/// [`ParallelIterator`], providing shared references to the data.
///
/// Th... | code_fim | hard | {
"lang": "rust",
"repo": "wagnerf42/rayon-logs",
"path": "/src/prelude.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (path, dst_path)
};
let is_dotfile = |path: &Path| -> bool {
crate::Config::get_dots_dir()
.map(|dir| path.starts_with(dir))
.unwrap()
};
// check to see if src path exists in dotfiles directory, if not: it is invalid input
if !is_dotfile(&src_... | code_fim | hard | {
"lang": "rust",
"repo": "jakeschurch/badm",
"path": "/src/commands.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.