text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>fn _f(f: Foo) {
match f {
A | B(_) | C { .. } => {}
}
}
mod nest {
pub use self::Bar::*;
pub enum Bar {
D,
E(isize),
F { a: isize },
}
impl Bar {
pub fn foo() {}
}
}
fn _f2(f: Bar) {
match f {
D | E(_) | F { .. } => {}
... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/structs-enums/namespaced-enum-emulate-flat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> session.run(&mut run_args).unwrap();
let x_output = run_args.fetch::<f32>(x_fetch).unwrap();
assert_eq!(x_output.len(), 1);
assert!(
x_output[0] >= 2.99990 && x_output[0] <= 2.99992,
"x_output[0] = {}",
x_output[0]
);
ses... | code_fim | hard | {
"lang": "rust",
"repo": "tensorflow/rust",
"path": "/src/train.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tensorflow/rust path: /src/train.rs
ut>, Variable)]) -> Self {
Self { grads_and_vars }
}
}
/// An optimizer adjusts variables to minimize some specified value.
///
/// Basic usage only requires calling `minimize`, which calls
/// `compute_gradients` and `apply_gradients` internally.... | code_fim | hard | {
"lang": "rust",
"repo": "tensorflow/rust",
"path": "/src/train.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tensorflow/rust path: /src/train.rs
}
}
/// Options for `Optimizer::compute_gradients`.
#[derive(Default, Debug, Clone)]
pub struct ComputeGradientsOptions<'a> {
variables: &'a [Variable],
}
impl<'a> ComputeGradientsOptions<'a> {
/// Sets the variables whose gradients need to be co... | code_fim | hard | {
"lang": "rust",
"repo": "tensorflow/rust",
"path": "/src/train.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devyn/kit path: /kernel/memory/region_math.rs
/*******************************************************************************
*
* kit/kernel/memory/region_math.rs
*
* vim:ft=rust:ts=4:sw=4:et:tw=80
*
* Copyright (C) 2015-2021, Devyn Cairns
* Redistribution of this file is permitted under... | code_fim | hard | {
"lang": "rust",
"repo": "devyn/kit",
"path": "/kernel/memory/region_math.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> remove_test!((1000..6000, 8000..9000) - (0..2000)
=> (2000..6000, 8000..9000));
}
#[test]
fn region_remove_cut_end() {
remove_test!((1000..6000, 8000..9000) - (3000..7000)
=> (1000..3000, 8000..9000));
}
#[test]
fn region_remove_encompassing() {
remove_test!((1000..6000, 8000... | code_fim | hard | {
"lang": "rust",
"repo": "devyn/kit",
"path": "/kernel/memory/region_math.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Image {
fn offset(&self, i: i32, j: i32) -> isize {
(i * self.width + j) as isize
}
unsafe fn pixel(&self, i: i32, j: i32) -> &Pixel {
&*self.pixels.offset(self.offset(i, j))
}
}
impl MutImage {
fn offset(&self, i: i32, j: i32) -> isize {
(i * self.width ... | code_fim | hard | {
"lang": "rust",
"repo": "denzp/rust-inline-cuda-tutorial",
"path": "/chapter-1/device/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dst_image.mut_pixel(i, j).r = (r_value / r_accum) as u8;
dst_image.mut_pixel(i, j).g = (g_value / g_accum) as u8;
dst_image.mut_pixel(i, j).b = (b_value / b_accum) as u8;
}
unsafe fn w_kernel(
source: &Image,
i: i32,
j: i32,
k: i32,
l: i32,
sigma_d: f64,
sigma_r: f... | code_fim | hard | {
"lang": "rust",
"repo": "denzp/rust-inline-cuda-tutorial",
"path": "/chapter-1/device/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: denzp/rust-inline-cuda-tutorial path: /chapter-1/device/src/lib.rs
#![feature(abi_ptx, intrinsics)]
#![deny(warnings)]
#![no_std]
#[cfg(not(target_os = "cuda"))]
compile_error!("This is a CUDA crate. Building it with host toolchain is not possible.");
use core::cmp::{max, min};
extern crate n... | code_fim | hard | {
"lang": "rust",
"repo": "denzp/rust-inline-cuda-tutorial",
"path": "/chapter-1/device/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MozPhoenixClubJUET/Rust path: /Programs/loop/for.rs
fn main() {
// `n` will take the values: 1, 2, ..., 100 in each iteration
for n in 1..101 {
i<|fim_suffix|>else {
println!("{}", n);
}
}
}<|fim_middle|>f n % 2 == 0 {
println!("even");
... | code_fim | easy | {
"lang": "rust",
"repo": "MozPhoenixClubJUET/Rust",
"path": "/Programs/loop/for.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>else {
println!("{}", n);
}
}
}<|fim_prefix|>// repo: MozPhoenixClubJUET/Rust path: /Programs/loop/for.rs
fn main() {
// `n` will take the values: 1, 2, ...<|fim_middle|>, 100 in each iteration
for n in 1..101 {
if n % 2 == 0 {
println!("even");
... | code_fim | medium | {
"lang": "rust",
"repo": "MozPhoenixClubJUET/Rust",
"path": "/Programs/loop/for.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Sum of all digits that match the next digit
let mut first_sum: u32 = 0;
for i in 1..digits.len() {
if digits[i - 1] == digits[i] {
first_sum += digits[i];
}
}
// Last is compared with the first
if digits.first() == digits.last() {
first_sum +=... | code_fim | medium | {
"lang": "rust",
"repo": "sndels/aoc17",
"path": "/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sndels/aoc17 path: /day1/src/main.rs
// https://adventofcode.com/2017/day/1
use std::fs::File;
use std::io::prelude::*;
fn main() {
// Read input to string
let mut f = File::open("input.txt").expect("Opening input.txt failed");
let mut input = String::new();
f.read_to_string(&m... | code_fim | hard | {
"lang": "rust",
"repo": "sndels/aoc17",
"path": "/day1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Roboadam/economy_sim path: /src/sprites.rs
use macroquad::prelude::{load_texture, FilterMode, Texture2D};
<|fim_suffix|>impl Sprites {
pub async fn add_sprite_from_path(&mut self, path: &str) -> usize {
let texture = load_texture(path).await.unwrap();
texture.set_filter(Filt... | code_fim | medium | {
"lang": "rust",
"repo": "Roboadam/economy_sim",
"path": "/src/sprites.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn texture(&self, texture_index: usize) -> &Texture2D {
self.0.get(texture_index).expect("Oh no!")
}
}<|fim_prefix|>// repo: Roboadam/economy_sim path: /src/sprites.rs
use macroquad::prelude::{load_texture, FilterMode, Texture2D};
#[derive(Default)]
pub struct Sprites(Vec<Texture2D>)... | code_fim | hard | {
"lang": "rust",
"repo": "Roboadam/economy_sim",
"path": "/src/sprites.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe fn device_memory_barrier() {
spirv_std::arch::device_memory_barrier();
}
#[spirv(compute(threads(1, 1, 1)))]
pub fn main() {
unsafe {
device_memory_barrier();
}
}<|fim_prefix|>// repo: EmbarkStudios/rust-gpu path: /tests/ui/arch/device_memory_barrier.rs
// build-pass
// compil... | code_fim | easy | {
"lang": "rust",
"repo": "EmbarkStudios/rust-gpu",
"path": "/tests/ui/arch/device_memory_barrier.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[spirv(compute(threads(1, 1, 1)))]
pub fn main() {
unsafe {
device_memory_barrier();
}
}<|fim_prefix|>// repo: EmbarkStudios/rust-gpu path: /tests/ui/arch/device_memory_barrier.rs
// build-pass
// compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memor... | code_fim | medium | {
"lang": "rust",
"repo": "EmbarkStudios/rust-gpu",
"path": "/tests/ui/arch/device_memory_barrier.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EmbarkStudios/rust-gpu path: /tests/ui/arch/device_memory_barrier.rs
// build-pass
// compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model
// compile-flags: -C llvm-args=--disassemble-fn=device_memory_barrier::device_memory_barrier
use spirv_std::sp... | code_fim | medium | {
"lang": "rust",
"repo": "EmbarkStudios/rust-gpu",
"path": "/tests/ui/arch/device_memory_barrier.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Pose {
fn default() -> Pose {
Pose::new(Vector::new(0.0, 0.0), 0.0)
}
}
impl Pose {
pub fn new(position: Vector, heading: Angle) -> Pose {
Pose { position, heading }
}
}<|fim_prefix|>// repo: rovangju/vacuum-robot-simulator path: /src/geometry/pose.rs
use... | code_fim | medium | {
"lang": "rust",
"repo": "rovangju/vacuum-robot-simulator",
"path": "/src/geometry/pose.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rovangju/vacuum-robot-simulator path: /src/geometry/pose.rs
use super::Vector;
use math::Angle;
<|fim_suffix|> Pose::new(Vector::new(0.0, 0.0), 0.0)
}
}
impl Pose {
pub fn new(position: Vector, heading: Angle) -> Pose {
Pose { position, heading }
}
}<|fim_middle|>#[d... | code_fim | medium | {
"lang": "rust",
"repo": "rovangju/vacuum-robot-simulator",
"path": "/src/geometry/pose.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobmcwhirter/defmt path: /macros/src/function_like/log/env_filter/parse.rs
use defmt_parser::Level;
#[cfg(not(test))]
use proc_macro_error::abort_call_site as panic;
use std::fmt;
use syn::Ident;
// None = "off" pseudo-level
pub(crate) type LogLevelOrOff = Option<Level>;
// NOTE this is simple... | code_fim | hard | {
"lang": "rust",
"repo": "bobmcwhirter/defmt",
"path": "/macros/src/function_like/log/env_filter/parse.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn accepts_raw_identifier() {
ModulePath::parse("krate::r#mod");
}
#[rstest]
#[case::has_module("krate::module")]
#[case::no_module("krate")]
fn modpath_crate_name(#[case] input: &str) {
let modpath = ModulePath::parse(input);
assert_eq!("krate"... | code_fim | hard | {
"lang": "rust",
"repo": "bobmcwhirter/defmt",
"path": "/macros/src/function_like/log/env_filter/parse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if client_token_account.owner != *client_info.key {
return Err(ProgramError::InvalidArgument);
}
if client_info.key == market_settings_info.key {
return Err(MarketError::SelfTransaction.into());
}
if client_token_account.mint != market_token_account.mint {
ret... | code_fim | hard | {
"lang": "rust",
"repo": "LLDay/token-market",
"path": "/src/processor/buy_sell.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if tokens_number == 0 {
return Err(ProgramError::InvalidArgument);
}
if client_token_account.owner != *client_info.key {
return Err(ProgramError::InvalidArgument);
}
if client_info.key == market_settings_info.key {
return Err(MarketError::SelfTransaction.into(... | code_fim | hard | {
"lang": "rust",
"repo": "LLDay/token-market",
"path": "/src/processor/buy_sell.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LLDay/token-market path: /src/processor/buy_sell.rs
use crate::{
error::MarketError,
instruction::TokensNumber,
state::{MarketSettings, LAMPORTS_SEED, SETTINGS_SEED},
};
use borsh::BorshDeserialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypo... | code_fim | hard | {
"lang": "rust",
"repo": "LLDay/token-market",
"path": "/src/processor/buy_sell.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Run on the normal port for Gotham examples, passing the handler as the only function for the gotham web server.
pub fn main() {
let addr = "127.0.0.1:7878";
println!("Listening at {}", addr);
gotham::start(addr, || Ok(index)).unwrap();
}
#[cfg(test)]
mod tests {
use super::*;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "gotham-rs/gotham",
"path": "/examples/templating/askama/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gotham-rs/gotham path: /examples/templating/askama/src/main.rs
use askama::Template;
use gotham::helpers::http::response::{create_empty_response, create_response};
use gotham::hyper::{Body, Response, StatusCode};
use gotham::mime::TEXT_HTML_UTF_8;
use gotham::state::State;
pub const MESSAGE: &s... | code_fim | medium | {
"lang": "rust",
"repo": "gotham-rs/gotham",
"path": "/examples/templating/askama/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> method getAddress(mut cx) {
let address = parse_address(cx.argument::<JsString>(0)?.value()).expect("invalid address");
let this = cx.this();
let id = cx.borrow(&this, |r| r.0.clone());
crate::block_on(async move {
let account_handle ... | code_fim | hard | {
"lang": "rust",
"repo": "lein1013/wallet.rs",
"path": "/bindings/nodejs/native/src/classes/account/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> method listSpentAddresses(mut cx) {
let this = cx.this();
let id = cx.borrow(&this, |r| r.0.clone());
crate::block_on(async move {
let account_handle = crate::get_account(&id).await;
let account = account_handle.read().await;
... | code_fim | hard | {
"lang": "rust",
"repo": "lein1013/wallet.rs",
"path": "/bindings/nodejs/native/src/classes/account/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lein1013/wallet.rs path: /bindings/nodejs/native/src/classes/account/mod.rs
Some(_arg) => {
let js_object = cx.argument::<JsObject>(1)?;
let address = js_object.get(&mut cx, "username")?.downcast::<JsString>().or_throw(&mut cx)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "lein1013/wallet.rs",
"path": "/bindings/nodejs/native/src/classes/account/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.rows
}
fn get_cols(&self) -> usize {
self.cols
}
}
impl CpuMatrix {
pub fn get_data(&self) -> &Vec<f32> {
&self.data
}
pub fn get_data_mut(&mut self) -> &mut Vec<f32> {
&mut self.data
}
}<|fim_prefix|>// repo: bumzack/rust-cuda-matrix pa... | code_fim | hard | {
"lang": "rust",
"repo": "bumzack/rust-cuda-matrix",
"path": "/backend/src/cpu_matrix/cpu_matrix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // mut is required for CudaMatrix
fn get(& self, row: usize, col: usize) -> f32 {
self.data[row * self.cols + col]
}
fn get_rows(&self) -> usize {
self.rows
}
fn get_cols(&self) -> usize {
self.cols
}
}
impl CpuMatrix {
pub fn get_data(&self) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "bumzack/rust-cuda-matrix",
"path": "/backend/src/cpu_matrix/cpu_matrix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bumzack/rust-cuda-matrix path: /backend/src/cpu_matrix/cpu_matrix.rs
use crate::matrix::matrix::Matrix;
use std::fmt;
#[derive(Debug)]
pub struct CpuMatrix {
data: Vec<f32>,
rows: usize,
cols: usize,
}
impl fmt::Display for CpuMatrix {
// This trait requires `fmt` with this exa... | code_fim | hard | {
"lang": "rust",
"repo": "bumzack/rust-cuda-matrix",
"path": "/backend/src/cpu_matrix/cpu_matrix.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kimundi/snowmew path: /src/snowmew-render-gfx/lib.rs
#![crate_id = "github.com/csherratt/snowmew#snowmew-render-gfx:0.1"]
#![license = "ASL2"]
#![crate_type = "lib"]
#![comment = "A game engine in rust"]
#![allow(dead_code)]
//extern crate debug;
extern crate std;
extern crate glfw;
extern crat... | code_fim | hard | {
"lang": "rust",
"repo": "Kimundi/snowmew",
"path": "/src/snowmew-render-gfx/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let proj = camera.projection_matrix(16. / 9.);
self.client.set_env_uniform(
env.env,
env.proj_mat,
gfx::ValueF32Matrix(
[[proj.x.x, proj.x.y, proj.x.z, proj.x.w],
[proj.y.x, proj.y.y, proj.y.z, proj.y.w],
... | code_fim | hard | {
"lang": "rust",
"repo": "Kimundi/snowmew",
"path": "/src/snowmew-render-gfx/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let circle=Circle{radius:34.432};
assert_eq!("Circle of radius: 34.432",circle.to_string() );
}<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-VitalyAnkh-daily path: /Rust/code_of_rust_by_example/examples/conversion/to_string.rs
use std::string::ToString;
#[derive(Debug)]
struct Circle{
ra... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-VitalyAnkh-daily",
"path": "/Rust/code_of_rust_by_example/examples/conversion/to_string.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> format!("Circle of radius: {:?}",
self.radius)
}
}
#[test]
fn test_to_string(){
let circle=Circle{radius:34.432};
assert_eq!("Circle of radius: 34.432",circle.to_string() );
}<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-VitalyAnkh-daily path: /Rust/code_of_rust_by_example... | code_fim | easy | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-VitalyAnkh-daily",
"path": "/Rust/code_of_rust_by_example/examples/conversion/to_string.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: philipdaquin/Browser-Engine-on-Rust path: /src/css.rs
use std::fmt;
use std::default::Default;
#[derive(PartialEq)]
pub struct Stylesheet {
pub rules: Vec<Rule>,
}
#[derive(PartialEq)]
pub struct Rule {
pub selectors: Vec<Selector>,
pub declarations: Vec<Declaration>,
}
#[der... | code_fim | hard | {
"lang": "rust",
"repo": "philipdaquin/Browser-Engine-on-Rust",
"path": "/src/css.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result = String::new();
if let Some(ref t) = self.tag_name {
result.push_str(t)
}
if let Some(ref s) = self.id {
result.push('#');
result.push_str(s);
}
for class in &self.classes {
res... | code_fim | hard | {
"lang": "rust",
"repo": "philipdaquin/Browser-Engine-on-Rust",
"path": "/src/css.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Debug for Stylesheet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut rule_result = String::new();
for rule in &self.rules {
if rule_result.len() > 0 {
rule_result.push_str("\n\n");
}
rule_result.push_st... | code_fim | hard | {
"lang": "rust",
"repo": "philipdaquin/Browser-Engine-on-Rust",
"path": "/src/css.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match iter.next() {
Some(' ') => {
if !current_param.is_empty() {
parameters.push(current_param.clone());
current_param.clear();
} else {
continue;
... | code_fim | hard | {
"lang": "rust",
"repo": "timothybrink/oak",
"path": "/src/expressions/parsers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: timothybrink/oak path: /src/expressions/parsers.rs
use super::*;
use crate::common::EvalError;
use crate::stdlib::NativeExpression;
// Generic expression parser function, used whenever any expression has
// sub expressions to evaluate: decides which expression is there, and calls
// the respect... | code_fim | hard | {
"lang": "rust",
"repo": "timothybrink/oak",
"path": "/src/expressions/parsers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fn_obj = Function {
parameters,
body,
closure: None,
};
Ok(Rc::new(Value::Function(fn_obj)))
}
pub fn array_parser(iter: &mut StringIterator) -> Result<Rc<Value>, EvalError> {
// consume opening bracket
iter.next();
let mut expressions = Vec::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "timothybrink/oak",
"path": "/src/expressions/parsers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Unpack to ChunkedArray of dtype `[DataType::Date]`
#[cfg(feature = "dtype-date")]
pub fn date(&self) -> PolarsResult<&DateChunked> {
unpack_chunked!(self, DataType::Date => DateChunked, "Date")
}
/// Unpack to ChunkedArray of dtype `[DataType::Datetime]`
#[cfg(feature ... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/series/ops/downcast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-core/src/series/ops/downcast.rs
use crate::prelude::*;
macro_rules! unpack_chunked {
($series:expr, $expected:pat => $ca:ty, $name:expr) => {
match $series.dtype() {
$expected => unsafe {
Ok(&*($series.as_ref() as *cons... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/series/ops/downcast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Unpack to ChunkedArray of dtype `[DataType::Datetime]`
#[cfg(feature = "dtype-datetime")]
pub fn datetime(&self) -> PolarsResult<&DatetimeChunked> {
unpack_chunked!(self, DataType::Datetime(_, _) => DatetimeChunked, "Datetime")
}
/// Unpack to ChunkedArray of dtype `[DataT... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/series/ops/downcast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Eq, PartialEq)]
pub enum SymbolType {
FunctionSymbol,
ImportAddressSymbol,
ImportedFunctionSymbol,
DataSymbol,
ImportedDataSymbol
}
// Send for rayon
unsafe impl Send for SymbolType {}
impl SymbolType {
pub fn from_bnsymboltype(n: BNSymbolType) -> Option<SymbolType> {
... | code_fim | hard | {
"lang": "rust",
"repo": "ctfhacker/binja-rs",
"path": "/src/symbol.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Full name of the symbol as provided by the core
pub fn full_name(&self) -> BinjaStr {
let binjastr = unsafe { BNGetSymbolFullName(self.handle()) };
BinjaStr::new(binjastr)
}
/// Address of the symbol as provided by the core
pub fn address(&self) -> u64 {
un... | code_fim | hard | {
"lang": "rust",
"repo": "ctfhacker/binja-rs",
"path": "/src/symbol.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ctfhacker/binja-rs path: /src/symbol.rs
//! Provides `Symbol`
use core::*;
use std::sync::Arc;
use crate::wrappers::BinjaSymbol;
use crate::binjastr::BinjaStr;
/// Symbol of an address from binary ninja
#[derive(Clone)]
pub struct Symbol {
handle: Arc<BinjaSymbol>
}
impl Symbol {
pu... | code_fim | hard | {
"lang": "rust",
"repo": "ctfhacker/binja-rs",
"path": "/src/symbol.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>type pat_id_map = std::map::hashmap<str, node_id>;
// This is used because same-named variables in alternative patterns need to
// use the node_id of their namesake in the first pattern.
fn pat_id_map(tcx: ty::ctxt, pat: @pat) -> pat_id_map {
let map = std::map::new_str_hash::<node_id>();
pat_bin... | code_fim | hard | {
"lang": "rust",
"repo": "kevina/rust",
"path": "/src/comp/middle/pat_util.rs",
"mode": "spm",
"license": "BSD-1-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kevina/rust path: /src/comp/middle/pat_util.rs
import syntax::ast::*;
import syntax::ast_util;
import syntax::ast_util::respan;
import syntax::fold;
import syntax::fold::*;
export normalize_arms;
export normalize_pat;
export normalize_pat_def_map;
export pat_binding_ids;
export pat_bindings;
ex... | code_fim | hard | {
"lang": "rust",
"repo": "kevina/rust",
"path": "/src/comp/middle/pat_util.rs",
"mode": "psm",
"license": "BSD-1-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio/tests/udp.rs
#
!
[
warn
(
rust_2018_idioms
)
]
#
!
[
cfg
(
feature
=
"
full
"
)
]
use
futures
:
:
future
:
:
poll_fn
;
use
std
:
:
io
;
use
std
:
:
sync
:
:
Arc
;
use
tokio
:
:
{
io
:
:
ReadBuf
net
:
:
UdpSocket
}
;
use
tokio_test
:
:
ass... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/udp.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
)
)
.
await
?
;
let
mut
recv_buf
=
[
0u8
;
32
]
;
let
mut
read
=
ReadBuf
:
:
new
(
&
mut
recv_buf
)
;
let
_
=
poll_fn
(
|
cx
|
sender
.
poll_recv_from
(
cx
&
mut
read
)
)
.
await
?
;
assert_eq
!
(
read
.
filled
(
)
MSG
)
;
Ok
(
(
)
)
}
/
/
#
Note
/
/
/
/
This
test
is
purposely
written
such
that
each
time... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/udp.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(e) = aoc_2020::run(lines, config.day, config.part) {
eprintln!("Application error: {}", e);
process::exit(1);
}
}<|fim_prefix|>// repo: jbkerry/aoc_2020 path: /src/main.rs
use std::env;
use std::process;
use aoc_2020::RunConfig;
fn main() {
<|fim_middle|> let confi... | code_fim | hard | {
"lang": "rust",
"repo": "jbkerry/aoc_2020",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbkerry/aoc_2020 path: /src/main.rs
use std::env;
use std::process;
use aoc_2020::RunConfig;
fn main() {
<|fim_suffix|> let line_break = match config.day {
4 | 6 => "\n\n",
_ => "\n",
};
let lines = aoc_2020::get_lines_from_file(&config.filepath, line_break)
... | code_fim | medium | {
"lang": "rust",
"repo": "jbkerry/aoc_2020",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: youssefhabri/starship path: /src/modules/haskell.rs
use super::{Context, Module, RootModuleConfig, SegmentConfig};
use crate::configs::haskell::HaskellConfig;
use crate::utils;
/// Creates a module with the current Haskell Stack version
///
/// Will display the Haskell version if any of the fo... | code_fim | medium | {
"lang": "rust",
"repo": "youssefhabri/starship",
"path": "/src/modules/haskell.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> module.create_segment("symbol", &config.symbol);
module.create_segment("version", &SegmentConfig::new(&formatted_version));
Some(module)
}
fn format_haskell_version(haskell_version: &str) -> Option<String> {
let formatted_version = format!("v{}", haskell_version.trim());
Some(formatt... | code_fim | hard | {
"lang": "rust",
"repo": "youssefhabri/starship",
"path": "/src/modules/haskell.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn format_haskell_version(haskell_version: &str) -> Option<String> {
let formatted_version = format!("v{}", haskell_version.trim());
Some(formatted_version)
}<|fim_prefix|>// repo: youssefhabri/starship path: /src/modules/haskell.rs
use super::{Context, Module, RootModuleConfig, SegmentConfig};
... | code_fim | medium | {
"lang": "rust",
"repo": "youssefhabri/starship",
"path": "/src/modules/haskell.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tari-project/tari path: /integration_tests/tests/cucumber.rs
// Copyright 2022. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/integration_tests/tests/cucumber.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // After each test we flush the stdout to the logs.
info!(
target: LOG_TARGET_STDOUT,
"{}",
str::from_utf8(&buffer.lock().unwrap()).unwrap()
);
buffer.lock().unwrap().clear();
}
fn main() {
initialize_logging(
&PathBuf::from("log4rs/cucumber.yml"),
... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/integration_tests/tests/cucumber.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> world.before(feature, scenario).await;
})
});
let file = fs::File::create("cucumber-output-junit.xml").unwrap();
world
// .fail_on_skipped()
// .fail_fast() - Not yet supported in 0.18
.with_writer(writer::Tee::new(wri... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/integration_tests/tests/cucumber.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn proxy_done() -> u32;
}
#[no_mangle]
pub extern "C" fn proxy_abi_version_0_2_0() {}
#[no_mangle]
pub extern "C" fn proxy_on_memory_allocate(size: usize) -> *mut u8 {
let mut vec: Vec<MaybeUninit<u8>> = Vec::with_capacity(size);
unsafe {
vec.set_len(size);
}
match size {
... | code_fim | medium | {
"lang": "rust",
"repo": "proxy-wasm/proxy-wasm-cpp-host",
"path": "/test/test_data/bad_malloc.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: proxy-wasm/proxy-wasm-cpp-host path: /test/test_data/bad_malloc.rs
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://w... | code_fim | medium | {
"lang": "rust",
"repo": "proxy-wasm/proxy-wasm-cpp-host",
"path": "/test/test_data/bad_malloc.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tu2607/Rust_Hangman path: /src/main.rs
mod game;
fn main () {
let x = game::create_word();
let m<|fim_suffix|>ring into array
let mut array_Guess = vec!['_'; actual_Word.len()-2];
game::game_menu(&mut actual_Word, &mut array_Guess);
}<|fim_middle|>ut actual_Word: Vec<char> = x.... | code_fim | medium | {
"lang": "rust",
"repo": "Tu2607/Rust_Hangman",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ring into array
let mut array_Guess = vec!['_'; actual_Word.len()-2];
game::game_menu(&mut actual_Word, &mut array_Guess);
}<|fim_prefix|>// repo: Tu2607/Rust_Hangman path: /src/main.rs
mod game;
fn main () {
let x = game::create_word();
let m<|fim_middle|>ut actual_Word: Vec<char> = x.... | code_fim | medium | {
"lang": "rust",
"repo": "Tu2607/Rust_Hangman",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: innerr/tikv path: /src/server/mod.rs
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
pub(crate) mod metrics;
mod raft_client;
<|fim_suffix|>pub use self::config::{Config, DEFAULT_CLUSTER_ID, DEFAULT_LISTENING_ADDR};
pub use self::errors::{Error, Result};
pub use self::metric... | code_fim | hard | {
"lang": "rust",
"repo": "innerr/tikv",
"path": "/src/server/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::config::{Config, DEFAULT_CLUSTER_ID, DEFAULT_LISTENING_ADDR};
pub use self::errors::{Error, Result};
pub use self::metrics::CONFIG_ROCKSDB_GAUGE;
pub use self::metrics::CPU_CORES_QUOTA_GAUGE;
pub use self::node::{create_raft_storage, Node};
pub use self::raft_client::RaftClient;
pub use self... | code_fim | hard | {
"lang": "rust",
"repo": "innerr/tikv",
"path": "/src/server/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn publish() -> RrResult<()> {
let output = Command::new("cargo")
.arg("publish")
.output()?;
check_output(&output)?;
Ok(())
}<|fim_prefix|>// repo: dan-t/rusty-release path: /src/cargo.rs
use std::process::Command;
use rr_result::RrResult;
use utils::check_output;
pub f... | code_fim | medium | {
"lang": "rust",
"repo": "dan-t/rusty-release",
"path": "/src/cargo.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dan-t/rusty-release path: /src/cargo.rs
use std::process::Command;
use rr_result::RrResult;
use utils::check_output;
<|fim_suffix|> check_output(&output)?;
Ok(())
}
pub fn test() -> RrResult<()> {
let output = Command::new("cargo")
.arg("test")
.output()?;
check... | code_fim | medium | {
"lang": "rust",
"repo": "dan-t/rusty-release",
"path": "/src/cargo.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> check_output(&output)?;
Ok(())
}
pub fn publish() -> RrResult<()> {
let output = Command::new("cargo")
.arg("publish")
.output()?;
check_output(&output)?;
Ok(())
}<|fim_prefix|>// repo: dan-t/rusty-release path: /src/cargo.rs
use std::process::Command;
use rr_result:... | code_fim | medium | {
"lang": "rust",
"repo": "dan-t/rusty-release",
"path": "/src/cargo.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hukumka/capnproto-rust path: /capnp/benches/other.rs
#[macro_use]
extern crate criterion;
extern crate capnp;
use criterion::{Criterion, ParameterizedBenchmark};
use capnp::Word;
fn word_alloc_zeroed_current(len: usize) -> Vec<Word> {
Word::allocate_zeroed_vec(len)
}
fn word_alloc_zeroed... | code_fim | hard | {
"lang": "rust",
"repo": "hukumka/capnproto-rust",
"path": "/capnp/benches/other.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result: Vec<Word> = Vec::with_capacity(length);
unsafe {
result.set_len(length);
let p: *mut u8 = result.as_mut_ptr() as *mut u8;
::std::ptr::write_bytes(p, 0u8, length * ::std::mem::size_of::<Word>());
}
result
}
fn bench_word_alloc(c: &mut Criterion) {
... | code_fim | medium | {
"lang": "rust",
"repo": "hukumka/capnproto-rust",
"path": "/capnp/benches/other.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davehorner/playwright-rust path: /src/api/browser.rs
pub use crate::imp::browser_type::{RecordHar, RecordVideo};
use crate::{
api::BrowserContext,
imp::{
self,
browser::NewContextArgs,
core::*,
playwright::DeviceDescriptor,
prelude::*,
util... | code_fim | hard | {
"lang": "rust",
"repo": "davehorner/playwright-rust",
"path": "/src/api/browser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // new_browser_cdp_session
// start_tracing
// stop_tracing
}
// TODO: async drop
/// [`Browser::context_builder`]
pub struct ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k> {
inner: Weak<imp::browser::Browser>,
args: NewContextArgs<'e, 'f, 'g, 'h, 'i, 'j, 'k>
}
impl<'e, 'f, 'g, 'h, 'i, ... | code_fim | hard | {
"lang": "rust",
"repo": "davehorner/playwright-rust",
"path": "/src/api/browser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lambdaxymox/fontview path: /build.rs
extern crate gl_generator;
use gl_generator::{Registry, Api, Profile, Fallbacks, GlobalGenerator};
use std::env;
use std::fs::File;
use std::path::Path;
#[cfg(target_os = "macos")]
fn register_gl_api(file: &mut File) {
<|fim_suffix|>fn main() {
let des... | code_fim | hard | {
"lang": "rust",
"repo": "lambdaxymox/fontview",
"path": "/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Registry::new(Api::Gl, (3, 3), Profile::Core, Fallbacks::All, [])
.write_bindings(GlobalGenerator, file)
.unwrap();
}
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
fn register_gl_api(file: &mut File) {
Registry::new(Api::Gl, (4, 6), Profile::Core, Fallbacks::All, []... | code_fim | hard | {
"lang": "rust",
"repo": "lambdaxymox/fontview",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZeProf10T/Subnet-calculator path: /src/ipv4.rs
use std::net::Ipv4Addr;
pub mod address {
use super::*;
pub fn network(ip: &Ipv4Addr, mask: &Ipv4Addr) -> Ipv4Addr {
let mut network: Vec<u8> = Vec::with_capacity(4);
let ip = ip.octets();
let mask = mask.octets();... | code_fim | hard | {
"lang": "rust",
"repo": "ZeProf10T/Subnet-calculator",
"path": "/src/ipv4.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _i in 0..cidr {
mask += n;
n = n / 2;
}
let res = num_to_vec(mask as u32);
return Ipv4Addr::new(res[0],res[1],res[2],res[3]);
}
pub fn vec_to_num(vec: [u8; 4]) -> u32 {
let a: u32 = (vec[0] as u32 * 16_777_216) as u32;
l... | code_fim | hard | {
"lang": "rust",
"repo": "ZeProf10T/Subnet-calculator",
"path": "/src/ipv4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>1 {
fib = num1 + num2;
num1 = num2;
num2 = fib;
}
fib
}<|fim_prefix|>// repo: amotz/rust-for-life path: /src/fibonacci.rs
pub fn fibonacci(n: i32) -> i32 {
match n {
0 => 0,
1 => 1,
_ => (fibonacci(n-2) + fibonacci(n-1)),
}
}
pub fn fibonac... | code_fim | medium | {
"lang": "rust",
"repo": "amotz/rust-for-life",
"path": "/src/fibonacci.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amotz/rust-for-life path: /src/fibonacci.rs
pub fn fibonacci(n: i32) -> i32 {
match n {
0 => 0,
1 => 1,
<|fim_suffix|>1 {
fib = num1 + num2;
num1 = num2;
num2 = fib;
}
fib
}<|fim_middle|> _ => (fibonacci(n-2) + fibonacci(n-1)),
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "amotz/rust-for-life",
"path": "/src/fibonacci.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jiyilanzhou/chw path: /book/rust_program_lang/chp17/0_objecct_oriented_programming.rs
// homogengeous[ˌhɒməˈdʒiːniəs]adj.均匀的,同质的
/*
0. Rust 的面向对象编程特性
面向对象编程(Object-Oriented Programming,OOP)是一种对程序建模的方法
1. 使用 trait 对象来存储不同类型的值(p502[*])
a. 为共有行为定义一个 Draw trait(内含 draw 方法),接着便可定义一个持有 trait 对... | code_fim | hard | {
"lang": "rust",
"repo": "jiyilanzhou/chw",
"path": "/book/rust_program_lang/chp17/0_objecct_oriented_programming.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>3. trait 对象必须保证对象安全(p510[?])
a. 需要注意的是,只能把满足对象安全(object-safe)的 trait 转换为 trait 对象。Rust 采用
一套较为复杂的规则来决定某个 trait 是否对象安全。但在实际开发中,只需要关注其中两条
规则即可。若一个 trait 中定义的所有方法满足以下两条规则那么此 trait 就是对象安全的:
(0). 方法的返回类型不是 Self
(1). 方法中不包含任何泛型参数
// 关键字 Self 是一个别名,它指向了实现当前 trait 或方法的具体类型
... | code_fim | hard | {
"lang": "rust",
"repo": "jiyilanzhou/chw",
"path": "/book/rust_program_lang/chp17/0_objecct_oriented_programming.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn grad_log(&self, input: &I, a: &Self::Action) -> Array2<f64> {
let mean = self.compute_mean(input);
let stddev = self.compute_stddev(input);
let gl_mean = self.mean.grad_log(input, &a, stddev);
let gl_stddev = self.stddev.grad_log(input, &a, mean);
if gl_std... | code_fim | hard | {
"lang": "rust",
"repo": "clumsy/rsrl",
"path": "/rsrl/src/policies/gaussian/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let gl_mean = self.mean.grad_log(input, &a, stddev);
let gl_stddev = self.stddev.grad_log(input, &a, mean);
if gl_stddev.len() == 0 {
gl_mean
} else {
stack![Axis(0), gl_mean, gl_stddev]
}
}
}
impl<M, S> Parameterised for Gaussian<M, S>... | code_fim | hard | {
"lang": "rust",
"repo": "clumsy/rsrl",
"path": "/rsrl/src/policies/gaussian/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clumsy/rsrl path: /rsrl/src/policies/gaussian/mod.rs
use crate::{
fa::{Parameterised, StateFunction, Weights, WeightsView, WeightsViewMut},
policies::{DifferentiablePolicy, Policy},
spaces::Space,
};
use ndarray::{Array2, ArrayView2, Axis};
use rand::Rng;
use rstat::{ContinuousDistri... | code_fim | hard | {
"lang": "rust",
"repo": "clumsy/rsrl",
"path": "/rsrl/src/policies/gaussian/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dlunch/account path: /client/wasm/src/router.rs
use yew_router::{
agent::{RouteAgentDispatcher, RouteRequest},
components::RouterAnchor,
route::Route,
Switch,
};
<|fim_suffix|>pub fn change_route(route: AppRoute) {
let mut router = RouteAgentDispatcher::<()>::new();
rout... | code_fim | medium | {
"lang": "rust",
"repo": "dlunch/account",
"path": "/client/wasm/src/router.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn change_route(route: AppRoute) {
let mut router = RouteAgentDispatcher::<()>::new();
router.send(RouteRequest::ChangeRoute(Route::from(route)));
}<|fim_prefix|>// repo: dlunch/account path: /client/wasm/src/router.rs
use yew_router::{
agent::{RouteAgentDispatcher, RouteRequest},
com... | code_fim | easy | {
"lang": "rust",
"repo": "dlunch/account",
"path": "/client/wasm/src/router.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SnefDenGames/math_sd path: /src/lib.rs
i => 'Φ',
GreekAlphabet::Chi => 'Χ',
GreekAlphabet::Psi => 'Ψ',
GreekAlphabet::Omega => 'Ω',
_ => panic!("charackter not exist in GreekAlphabet")
... | code_fim | hard | {
"lang": "rust",
"repo": "SnefDenGames/math_sd",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SnefDenGames/math_sd path: /src/lib.rs
i => "ph, f",
GreekAlphabet::Chi => "ch",
GreekAlphabet::Psi => "ps",
GreekAlphabet::Omega => "ō",
_ => panic!("charackter not exist in GreekAlphabe... | code_fim | hard | {
"lang": "rust",
"repo": "SnefDenGames/math_sd",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if p > 0 && p < u8::MAX as i64 {
return GreekAlphabet::from(p as u8)
}
GreekAlphabet::Empty
}
}
impl std::convert::From<i128> for GreekAlphabet {
fn from(p: i128) -> Self {
if p > 0 && p < u8::MAX as i128 {
... | code_fim | hard | {
"lang": "rust",
"repo": "SnefDenGames/math_sd",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hybras/protonvpn path: /src/main.rs
use anyhow::Result;
use confy::load;
use console::Term;
use protonvpn::{cli::CliOptions, constants::APP_NAME, main as main_cli, vpn::util::Config};
<|fim_suffix|> main_cli(args, config, &mut terminal)
}<|fim_middle|>#[paw::main]
fn main(args: CliOptions) -> R... | code_fim | medium | {
"lang": "rust",
"repo": "hybras/protonvpn",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config = load::<Config>(APP_NAME);
main_cli(args, config, &mut terminal)
}<|fim_prefix|>// repo: hybras/protonvpn path: /src/main.rs
use anyhow::Result;
use confy::load;
use console::Term;
use protonvpn::{cli::CliOptions, constants::APP_NAME, main as main_cli, vpn::util::Config};
#[paw::main]
fn ... | code_fim | medium | {
"lang": "rust",
"repo": "hybras/protonvpn",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> main_cli(args, config, &mut terminal)
}<|fim_prefix|>// repo: hybras/protonvpn path: /src/main.rs
use anyhow::Result;
use confy::load;
use console::Term;
use protonvpn::{cli::CliOptions, constants::APP_NAME, main as main_cli, vpn::util::Config};
<|fim_middle|>#[paw::main]
fn main(args: CliOptions) -> R... | code_fim | medium | {
"lang": "rust",
"repo": "hybras/protonvpn",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ExecError::Io(e)
}
}
impl warp::reject::Reject for ExecError {}
#[derive(Deserialize)]
#[serde(untagged)]
enum ClientMessage {
Resize { cols: u16, rows: u16 },
Init { command: Vec<String>, tty: bool },
}
#[derive(Serialize)]
enum ServerMessage {
Exit {
code: Option<i32>,... | code_fim | hard | {
"lang": "rust",
"repo": "ttys3/init-snapshot",
"path": "/src/api/exec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttys3/init-snapshot path: /src/api/exec.rs
use std::io;
use std::os::unix::{process::ExitStatusExt};
use std::pin::Pin;
use std::task::{Context, Poll};
use std::collections::HashMap;
use std::sync::Arc;
use warp::reject::Rejection;
use futures::{SinkExt, StreamExt};
use pin_project::pin_project... | code_fim | hard | {
"lang": "rust",
"repo": "ttys3/init-snapshot",
"path": "/src/api/exec.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heilmoli/eTinte path: /epdriver/src/lib.rs
#![no_std]
#[macro_use]
extern crate bitflags;
<|fim_suffix|>pub use epd7in5_tri_v1::EPaper75TriColour;
pub use epd7in5_tri_v2::EPaper75TriColourV2;
pub use display::EPaperDisplay;
pub use display::DisplayError;
pub use controller::display_connector;
p... | code_fim | medium | {
"lang": "rust",
"repo": "heilmoli/eTinte",
"path": "/epdriver/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use epd7in5_tri_v1::EPaper75TriColour;
pub use epd7in5_tri_v2::EPaper75TriColourV2;
pub use display::EPaperDisplay;
pub use display::DisplayError;
pub use controller::display_connector;
pub use controller::gd7965;
pub use controller::il0371;
#[cfg(test)]
#[macro_use]
extern crate std;
// define empty... | code_fim | medium | {
"lang": "rust",
"repo": "heilmoli/eTinte",
"path": "/epdriver/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Stefan99353/advent-of-code-2020 path: /day_04/src/main.rs
use std::fs::File;
use std::io::Read;
use std::str::FromStr;
use anyhow::Result;
use regex::Regex;
const DAY: &str = "04";
fn main() -> Result<()> {
println!("----- Advent of Code -- Day {} -----", DAY);
println!("-----------... | code_fim | hard | {
"lang": "rust",
"repo": "Stefan99353/advent-of-code-2020",
"path": "/day_04/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_part_2() {
let input: &str = "pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980
hcl:#623a2f
eyr:2029 ecl:blu cid:129 byr:1989
iyr:2014 pid:896056539 hcl:#a97842 hgt:165cm
hcl:#888785
hgt:164cm byr:2001 iyr:2015 cid:88
pid:545766238 ecl:hzl
eyr:2022
iyr:2010 hgt:1... | code_fim | hard | {
"lang": "rust",
"repo": "Stefan99353/advent-of-code-2020",
"path": "/day_04/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn serialize_operation_create_stack_instances(
input: &crate::input::CreateStackInstancesInput,
) -> Result<smithy_http::body::SdkBody, std::convert::Infallible> {
let mut out = String::new();
#[allow(unused_mut)]
let mut writer = smithy_query::QueryWriter::new(&mut out, "CreateStackIn... | code_fim | hard | {
"lang": "rust",
"repo": "cht-cloud/aws-sdk-rust",
"path": "/sdk/cloudformation/src/operation_ser.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.