text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let a = "kitten";
let b = "sitting";
println!("distance between 'kitten' and 'sitting' is {}", levenshtein_distance(&a, &b));
}
// based on https://en.wikipedia.org/wiki/Levenshtein_distance#Iterative_with_full_matrix
fn levenshtein_distance(a: &str, b: &str) -> u32 {
let mut m = Levensh... | code_fim | hard | {
"lang": "rust",
"repo": "beneills/rust-in-a-week",
"path": "/day2/levenshtein_distance/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beneills/rust-in-a-week path: /day2/levenshtein_distance/src/main.rs
use std::cmp;
struct LevenshteinMatrix {
size_a: usize,
size_b: usize,
elements: Vec<u32>
}
impl LevenshteinMatrix {
fn element(&self, i: usize, j: usize) -> u32 {
if self.size_a <= i || self.size_b <=... | code_fim | hard | {
"lang": "rust",
"repo": "beneills/rust-in-a-week",
"path": "/day2/levenshtein_distance/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use gameloop::{game_loop, LoopAction};<|fim_prefix|>// repo: TheNeikos/rpg path: /shared/src/lib.rs
extern crate clock_ticks;
extern crate rustc_serialize;
extern crate bincode;
<|fim_middle|>mod gameloop;
pub mod net;
pub mod packets;
| code_fim | easy | {
"lang": "rust",
"repo": "TheNeikos/rpg",
"path": "/shared/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheNeikos/rpg path: /shared/src/lib.rs
extern crate clock_ticks;
extern crate rustc_serialize;
extern crate bincode;
<|fim_suffix|>pub use gameloop::{game_loop, LoopAction};<|fim_middle|>mod gameloop;
pub mod net;
pub mod packets;
| code_fim | easy | {
"lang": "rust",
"repo": "TheNeikos/rpg",
"path": "/shared/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarcKloter/bulletproofs_gadgets path: /src/set_membership/set_membership_gadget.rs
ert!(self.value_assignment.is_some(), "missing value assignment");
assert!(self.instance_vars_assignments.is_some(), "missing instance vars assignments");
let instance_vars_assignments = self.inst... | code_fim | hard | {
"lang": "rust",
"repo": "MarcKloter/bulletproofs_gadgets",
"path": "/src/set_membership/set_membership_gadget.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let witness_value = VALUE1.to_vec();
let witness_set = vec![
VALUE3.to_vec(),
VALUE1.to_vec(),
VALUE5.to_vec()
];
let instance_set = vec![
be_to_scalar(&VALUE4.to_vec()),
be_to_scalar(&VALUE2.to_vec()),
... | code_fim | hard | {
"lang": "rust",
"repo": "MarcKloter/bulletproofs_gadgets",
"path": "/src/set_membership/set_membership_gadget.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut verifier_transcript = Transcript::new(b"SetMembership");
let mut verifier = Verifier::new(&mut verifier_transcript);
let witness_vars: Vec<Variable> = verifier_commit(&mut verifier, vec![witness_commitment]);
let gadget_verifier = SetMembership::new(witness_vars[0].... | code_fim | hard | {
"lang": "rust",
"repo": "MarcKloter/bulletproofs_gadgets",
"path": "/src/set_membership/set_membership_gadget.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn description(&self) -> &str {
&self.description.as_str()
}
pub fn tags(&self) -> &HashSet<Rc<Tag>> {
&self.tags
}
}
impl Transaction {
/// Create new transaction based on money value from this previous transaction.
/// The transaction will relate to the sam... | code_fim | hard | {
"lang": "rust",
"repo": "max-ym/homeBudgetCore",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn money_total(&self) -> MoneyType {
self.total
}
pub fn time_instant(&self) -> &Instant {
&self.time_instant
}
pub fn name(&self) -> Ref<String> {
let b: &RefCell<_> = self.name.borrow();
b.borrow()
}
pub fn description(&self) -> Ref<Stri... | code_fim | hard | {
"lang": "rust",
"repo": "max-ym/homeBudgetCore",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: max-ym/homeBudgetCore path: /src/lib.rs
ns that use this tag automatically derive this set of tags.
derived_tags: HashSet<Rc<Tag>>,
}
/// Registry that contains all tags of the system in use.
pub struct TagRegistry {
set: RefCell<HashSet<Rc<Tag>>>,
count: Cell<TagId>,
fee_tag: ... | code_fim | hard | {
"lang": "rust",
"repo": "max-ym/homeBudgetCore",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexreg/rust path: /src/test/ui/did_you_mean/issue-39544.rs
// Copyright 2017 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, Version 2.0 <LICENSE-APACHE or
/... | code_fim | hard | {
"lang": "rust",
"repo": "alexreg/rust",
"path": "/src/test/ui/did_you_mean/issue-39544.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = &mut self.x; //~ ERROR cannot borrow
let _ = &mut other.x; //~ ERROR cannot borrow
}
fn foo4(other: &Z) {
let _ = &mut other.x; //~ ERROR cannot borrow
}
}
pub fn with_arg(z: Z, w: &Z) {
let _ = &mut z.x; //~ ERROR cannot borrow
let _ = &mut w.x; //~ ... | code_fim | hard | {
"lang": "rust",
"repo": "alexreg/rust",
"path": "/src/test/ui/did_you_mean/issue-39544.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ys)]
pub fn sys_timer_target0_period_mode(&self) -> SYS_TIMER_TARGET0_PERIOD_MODE_R {
SYS_TIMER_TARGET0_PERIOD_MODE_R::new(((self.bits >> 30) & 0x01) != 0)
}
#[doc = "Bits 0:25"]
#[inline(always)]
pub fn sys_timer_target0_period(&self) -> SYS_TIMER_TARGET0_PERIOD_R {
SY... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/sys_timer/sys_timer_systimer_target0_conf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/sys_timer/sys_timer_systimer_target0_conf.rs
#[doc = "Reader of register SYS_TIMER_SYSTIMER_TARGET0_CONF"]
pub type R = crate::R<u32, super::SYS_TIMER_SYSTIMER_TARGET0_CONF>;
#[doc = "Writer for register SYS_TIMER_SYSTIMER_TARGET0_CONF"]
pub type W = crate:... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/sys_timer/sys_timer_systimer_target0_conf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haata/atsam4s8b-pac path: /src/crccu/sr.rs
#[doc = "Reader of register SR"]
pub type R = crate::R<u32, super::SR>;
#[doc = <|fim_suffix|>rc(&self) -> CRC_R {
CRC_R::new((self.bits & 0xffff_ffff) as u32)
}
}<|fim_middle|>"Reader of field `CRC`"]
pub type CRC_R = crate::R<u32, u32>;
im... | code_fim | medium | {
"lang": "rust",
"repo": "haata/atsam4s8b-pac",
"path": "/src/crccu/sr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>= "Bits 0:31 - Cyclic Redundancy Check Value"]
#[inline(always)]
pub fn crc(&self) -> CRC_R {
CRC_R::new((self.bits & 0xffff_ffff) as u32)
}
}<|fim_prefix|>// repo: haata/atsam4s8b-pac path: /src/crccu/sr.rs
#[doc = "Reader of register SR"]
pub type R = crate::R<u32, super::SR>;
#[doc... | code_fim | medium | {
"lang": "rust",
"repo": "haata/atsam4s8b-pac",
"path": "/src/crccu/sr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let f = File::open(filename).expect("Cannot read the input file");
let lines = io::BufReader::new(f).lines();
let mut result = Vec::new();
for line in lines {
if let Ok(l) = line {
let num: i32 = l.parse().unwrap();
result.push(num);
}
}
re... | code_fim | hard | {
"lang": "rust",
"repo": "trinnguyen/advent-of-code-2020",
"path": "/day01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let max_x = numbers.len() - 3;
let max_y = max_x + 1;
let max_z = max_y + 1;
for x in 0..=max_x {
let val_x = numbers[x];
if val_x > YEAR {
continue;
}
for y in (x + 1)..=max_y {
let val_y = numbers[y];
if val_y > YEAR {
... | code_fim | hard | {
"lang": "rust",
"repo": "trinnguyen/advent-of-code-2020",
"path": "/day01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trinnguyen/advent-of-code-2020 path: /day01/src/main.rs
use std::env;
use std::fs::File;
use std::io::{self, BufRead};
const YEAR: i32 = 2020;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
panic!("missing input file")
}
let filename = &... | code_fim | hard | {
"lang": "rust",
"repo": "trinnguyen/advent-of-code-2020",
"path": "/day01/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AspecScire/gdal path: /src/vector/driver.rs
use crate::utils::_last_null_pointer_err;
use crate::vector::Dataset;
use gdal_sys::{self, OGRSFDriverH};
use std::ffi::CString;
use std::path::Path;
use std::ptr::null_mut;
use std::sync::Once;
<|fim_suffix|>pub struct Driver {
c_driver: OGRSFDri... | code_fim | medium | {
"lang": "rust",
"repo": "AspecScire/gdal",
"path": "/src/vector/driver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mikee385/RustRayTracer path: /src/geometry/point.rs
use super::{Vector3D, AsVector, Direction3D};
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Point3D {
pub x: f32,
pub y: f32,
pub z: f32
}
static POINT3D_ORIGIN: Point3D = Point3D {
x: 0.0,
y: 0.0,
z: 0.0... | code_fim | hard | {
"lang": "rust",
"repo": "mikee385/RustRayTracer",
"path": "/src/geometry/point.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn distance(point1: &Point3D, point2: &Point3D) -> f32
{
Vector3D::from_xyz(
point1.x - point2.x,
point1.y - point2.y,
point1.z - point2.z).magnitude()
}
pub fn midpoint(point1: &Point3D, point2: &Point3D) -> Point3D
{
Point3D::f... | code_fim | hard | {
"lang": "rust",
"repo": "mikee385/RustRayTracer",
"path": "/src/geometry/point.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn reference_lifetmes_good_example() {
println!("__reference_lifetmes_good_example");
{
let r;
{
let x = 1;
r = &x;
assert_eq!(*r, 1);
}
}
}
static mut STASH: &i32 = &128;
static WORTH_POINTING_AT: i32 = 69;
pub fn store_globall... | code_fim | hard | {
"lang": "rust",
"repo": "teo-mateo/rusty",
"path": "/cookbook/src/book/chapter5_references.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: teo-mateo/rusty path: /cookbook/src/book/chapter5_references.rs
use std::collections::HashMap;
pub fn hashmap_with_mutable_references(){
println!("__hashmap");
type Table = HashMap<String, Vec<String>>;
let mut table = Table::new();
table.insert("brancusi".to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "teo-mateo/rusty",
"path": "/cookbook/src/book/chapter5_references.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let r;
{
let x = 1;
r = &x;
assert_eq!(*r, 1);
}
}
}
static mut STASH: &i32 = &128;
static WORTH_POINTING_AT: i32 = 69;
pub fn store_globally(p: &'static i32){
println!("__store_globally");
unsafe {
STASH = p;
p... | code_fim | hard | {
"lang": "rust",
"repo": "teo-mateo/rusty",
"path": "/cookbook/src/book/chapter5_references.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: connor-lennox/rust_chip path: /src/keypad.rs
pub struct Keypad {
pub state: [bool; 16],
pub last_released: usize,
pub just_released: bool,
}
<|fim_suffix|> // Calculate which key (if any) was released this cycle
self.just_released = false;
for old in 0..15 {
... | code_fim | hard | {
"lang": "rust",
"repo": "connor-lennox/rust_chip",
"path": "/src/keypad.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_state(&mut self, idx: Vec<usize>) {
let mut new_state = [false; 16];
for id in idx {
new_state[id] = true;
}
// Calculate which key (if any) was released this cycle
self.just_released = false;
for old in 0..15 {
if sel... | code_fim | medium | {
"lang": "rust",
"repo": "connor-lennox/rust_chip",
"path": "/src/keypad.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::ace::{Ace, AceBasic, AceData, AceObject, AceType};
pub use self::acl::Acl;
pub use self::authority::{Authority, SubAuthority, SubAuthorityList};
pub use self::sec_desc::{SecDescHeader, SecurityDescriptor};
pub use self::sid::Sid;<|fim_prefix|>// repo: omerbenamram/winstructs path: /src/secu... | code_fim | easy | {
"lang": "rust",
"repo": "omerbenamram/winstructs",
"path": "/src/security/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: omerbenamram/winstructs path: /src/security/mod.rs
//! Utilities for reading security identifiers.
//! https://docs.microsoft.com/en-us/windows/desktop/secauthz/security-identifiers
<|fim_suffix|>pub use self::ace::{Ace, AceBasic, AceData, AceObject, AceType};
pub use self::acl::Acl;
pub use se... | code_fim | easy | {
"lang": "rust",
"repo": "omerbenamram/winstructs",
"path": "/src/security/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacktuck/rpc-perf path: /src/client/config.rs
// rpc-perf - RPC Performance Testing
// Copyright 2017 Twitter, Inc
//
// 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 Licens... | code_fim | hard | {
"lang": "rust",
"repo": "jacktuck/rpc-perf",
"path": "/src/client/config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// turn the `Config` into a `Client`
pub fn build(mut self) -> Client {
self.validate();
Client::configured(self)
}
/// give the client a stats sender
pub fn set_stats(&mut self, stats: Sender<Stat>) -> &mut Self {
self.stats = Some(stats);
self
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jacktuck/rpc-perf",
"path": "/src/client/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// sets the tx buffer size in bytes
pub fn set_tx_buffer_size(&mut self, bytes: usize) -> &mut Self {
self.tx_buffer_size = bytes;
self
}
/// get the tx buffer size in bytes
pub fn tx_buffer_size(&self) -> usize {
self.tx_buffer_size
}
/// turn the `C... | code_fim | hard | {
"lang": "rust",
"repo": "jacktuck/rpc-perf",
"path": "/src/client/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match req {
Request::SetCS(state) => self.pins.cs.set_state(state),
Request::SetFPGA(state) => self.pins.fpga_rst.set_state(state),
Request::SetTPwr(state) => self.pins.tpwr_en.set_state(state),
Request::SetLED(state) => self.pins.led.set_state(state... | code_fim | hard | {
"lang": "rust",
"repo": "ironsteel/ffp",
"path": "/firmware/src/app.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ironsteel/ffp path: /firmware/src/app.rs
// Copyright 2019 Adam Greig
// Dual licensed under the Apache 2.0 and MIT licenses.
use crate::hal;
#[derive(Copy, Clone)]
pub enum PinState {
Low = 0,
High = 1,
}
#[derive(Copy, Clone)]
pub enum Mode {
HighImpedance = 0,
Flash = 1,
... | code_fim | hard | {
"lang": "rust",
"repo": "ironsteel/ffp",
"path": "/firmware/src/app.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = client.list_state_machines(&request).unwrap();
println!("{:#?}", result);
}<|fim_prefix|>// repo: asyade/rusoto-seedup path: /integration_tests/tests/stepfunctions.rs
#![cfg(feature = "stepfunctions")]
extern crate rusoto_core;
extern crate rusoto_stepfunctions;
use rusoto_stepfunc... | code_fim | hard | {
"lang": "rust",
"repo": "asyade/rusoto-seedup",
"path": "/integration_tests/tests/stepfunctions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let credentials = DefaultCredentialsProvider::new().unwrap();
let client = StepFunctionsClient::new(default_tls_client().unwrap(), credentials, Region::UsEast1);
let request = ListStateMachinesInput::default();
let result = client.list_state_machines(&request).unwrap();
println!("{:#?... | code_fim | medium | {
"lang": "rust",
"repo": "asyade/rusoto-seedup",
"path": "/integration_tests/tests/stepfunctions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asyade/rusoto-seedup path: /integration_tests/tests/stepfunctions.rs
#![cfg(feature = "stepfunctions")]
extern crate rusoto_core;
extern crate rusoto_stepfunctions;
use rusoto_stepfunctions::{StepFunctions, StepFunctionsClient, ListStateMachinesInput};
use rusoto_core::{DefaultCredentialsProvi... | code_fim | hard | {
"lang": "rust",
"repo": "asyade/rusoto-seedup",
"path": "/integration_tests/tests/stepfunctions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joseluis/oddio path: /src/sine.rs
use std::{cell::Cell, f32::consts::TAU};
use crate::{Sample, Signal};
/// A trivial [`Signal`] that produces a sine wave of a particular frequency, forever
pub struct Sine {
phase: Cell<f32>,
/// Radians per second
frequency: f32,
}
impl Sine {
... | code_fim | medium | {
"lang": "rust",
"repo": "joseluis/oddio",
"path": "/src/sine.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, x) in out.iter_mut().enumerate() {
let t = interval * i as f32;
*x = (t * self.frequency + self.phase.get()).sin();
}
self.seek_to(interval * out.len() as f32);
}
}<|fim_prefix|>// repo: joseluis/oddio path: /src/sine.rs
use std::{cell::Cell, f3... | code_fim | hard | {
"lang": "rust",
"repo": "joseluis/oddio",
"path": "/src/sine.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (code.execute(value), code.execute(!value))
}
}
impl<'a> Decoder for CxDec<'a> {
fn decrypt(&mut self, mut buffer: &mut [u8], key: u32, mut offset: usize) {
let boundary = ((key & 0x17c) + 0x77) as usize;
// decode the first chunk of the buffer
if offset < boundar... | code_fim | hard | {
"lang": "rust",
"repo": "3c1u/xp3",
"path": "/lib/cxdec/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let code = if let Some(code) = &mut self.code[index as usize] {
code
} else {
let code = Code::new(index, self.scheme);
self.code[index as usize] = Some(code);
self.code[index as usize].as_mut().unwrap()
};
(code.execute(valu... | code_fim | hard | {
"lang": "rust",
"repo": "3c1u/xp3",
"path": "/lib/cxdec/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 3c1u/xp3 path: /lib/cxdec/mod.rs
/// x-code executor.
mod code;
use crate::Decoder;
/// Generates the control block from `tempBlock` (or `TEMP_BLOCK`).
fn generate_control_block(block: &[u8]) -> Vec<u32> {
let total_len = block.len() >> 2;
let mut ctrl_block = Vec::with_capacity(total_... | code_fim | hard | {
"lang": "rust",
"repo": "3c1u/xp3",
"path": "/lib/cxdec/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: finkmoritz/rustExamples path: /src/mutability.rs
pub fn mutability() {
println!("\n--- mutability() ---");
let immutable = 1;
println!("immutable={}", immutable);
//immutable = 2; //not allowed because immutable by default
let immutable = 2; //allowed because a is shadowed
... | code_fim | medium | {
"lang": "rust",
"repo": "finkmoritz/rustExamples",
"path": "/src/mutability.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mutable = 2;
println!("mutable={}", mutable);
//mutable = "Mutable"; //mutation of type is not allowed!
}<|fim_prefix|>// repo: finkmoritz/rustExamples path: /src/mutability.rs
pub fn mutability() {
println!("\n--- mutability() ---");
let immutable = 1;
println!("immutable={}", ... | code_fim | medium | {
"lang": "rust",
"repo": "finkmoritz/rustExamples",
"path": "/src/mutability.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: debragail/prisma-engines path: /query-engine/request-handlers/src/transactions/mod.rs
use serde::Deserialize;
<|fim_suffix|> /// Time in milliseconds after which the transaction rolls back automatically.
pub timeout: u64,
}<|fim_middle|>#[derive(Debug, Deserialize)]
pub struct TxInput {
... | code_fim | medium | {
"lang": "rust",
"repo": "debragail/prisma-engines",
"path": "/query-engine/request-handlers/src/transactions/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Time in milliseconds after which the transaction rolls back automatically.
pub timeout: u64,
}<|fim_prefix|>// repo: debragail/prisma-engines path: /query-engine/request-handlers/src/transactions/mod.rs
use serde::Deserialize;
<|fim_middle|>#[derive(Debug, Deserialize)]
pub struct TxInput {
... | code_fim | medium | {
"lang": "rust",
"repo": "debragail/prisma-engines",
"path": "/query-engine/request-handlers/src/transactions/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dfontana/serv path: /devup/src/errors.rs
mod errors {
use confy;
use git2;
use std::io;
use s<|fim_suffix|> Confy(confy::ConfyError);
}
}
}
pub use errors::*;<|fim_middle|>td::str;
error_chain! {
foreign_links {
Io(io::Error);
Utf8(str::Utf8Error);
Git2(... | code_fim | medium | {
"lang": "rust",
"repo": "dfontana/serv",
"path": "/devup/src/errors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ror);
Utf8(str::Utf8Error);
Git2(git2::Error);
Confy(confy::ConfyError);
}
}
}
pub use errors::*;<|fim_prefix|>// repo: dfontana/serv path: /devup/src/errors.rs
mod errors {
use confy;
use git2;
use std::io;
use s<|fim_middle|>td::str;
error_chain! {
foreign_links {... | code_fim | medium | {
"lang": "rust",
"repo": "dfontana/serv",
"path": "/devup/src/errors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Confy(confy::ConfyError);
}
}
}
pub use errors::*;<|fim_prefix|>// repo: dfontana/serv path: /devup/src/errors.rs
mod errors {
use confy;
use git2;
use std::io;
use std::str;
error_chain! {
foreign_links {
Io(io::Er<|fim_middle|>ror);
Utf8(str::Utf8Error);
Git2(... | code_fim | medium | {
"lang": "rust",
"repo": "dfontana/serv",
"path": "/devup/src/errors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustAudio/rimd path: /src/bin/test.rs
extern crate rimd;
use rimd::{SMF,SMFError};
use std::env::{args,Args};
use std::path::Path;
fn main() {
let mut args: Args = args();
args.next();
let pathstr = match args.next() {
Some(s) => s,
None => { panic!("Please pass a p... | code_fim | hard | {
"lang": "rust",
"repo": "RustAudio/rimd",
"path": "/src/bin/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
match e {
SMFError::InvalidSMFFile(s) => {println!("{}",s);}
SMFError::Error(e) => {println!("io: {}",e);}
SMFError::MidiError(e) => {println!("Midi Error: {}",e);}
SMFError::MetaError(_) => {println!("Meta Error");}
... | code_fim | hard | {
"lang": "rust",
"repo": "RustAudio/rimd",
"path": "/src/bin/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn view(&self) -> Element<Message> {
Row::new()
.push(Text::new("TODO: Settings page").size(16))
.into()
}
}<|fim_prefix|>// repo: goller/Fuzzr path: /src/page/settings.rs
use iced::{text_input, Element, Row, Text};
use crate::message::Message;
#[derive(Debug... | code_fim | medium | {
"lang": "rust",
"repo": "goller/Fuzzr",
"path": "/src/page/settings.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: goller/Fuzzr path: /src/page/settings.rs
use iced::{text_input, Element, Row, Text};
use crate::message::Message;
#[derive(Debug, Clone)]
pub struct SettingsPage {
input_state: text_input::State,
input_value: String,
}
<|fim_suffix|> pub fn view(&self) -> Element<Message> {
... | code_fim | hard | {
"lang": "rust",
"repo": "goller/Fuzzr",
"path": "/src/page/settings.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quebin31/ez-lang path: /src/error.rs
use std::error::Error;
use std::fmt;
use crate::lex::token::Token;
#[derive(Debug, Clone)]
pub struct SyntaxError {
pub got: Token,
pub expected: Vec<Token>,
}
impl Error for SyntaxError {}
<|fim_suffix|> let mut expected = "".to_owned();
... | code_fim | medium | {
"lang": "rust",
"repo": "quebin31/ez-lang",
"path": "/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "expected {}\ngot {}", expected, self.got)
}
}<|fim_prefix|>// repo: quebin31/ez-lang path: /src/error.rs
use std::error::Error;
use std::fmt;
use crate::lex::token::Token;
<|fim_middle|>#[derive(Debug, Clone)]
pub struct SyntaxError {
pub got: Token,
pub expected: Vec<Tok... | code_fim | hard | {
"lang": "rust",
"repo": "quebin31/ez-lang",
"path": "/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alorel/yewdux path: /yewdux/src/service.rs
//! Wrapper for components with shared state.
use std::collections::HashSet;
use std::rc::Rc;
use yew::{
agent::{Agent, AgentLink, Context, Dispatcher, HandlerId},
prelude::*,
};
use crate::store::{Reduction, ReductionOnce, Store, StoreLink};
... | code_fim | hard | {
"lang": "rust",
"repo": "Alorel/yewdux",
"path": "/yewdux/src/service.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Send message to service.
pub fn send_service(&mut self, msg: ServiceRequest<H>) {
self.bridge.send(ServiceInput::Service(msg));
}
/// Send message to handler.
pub fn send_store(&mut self, msg: H::Input) {
self.bridge.send(ServiceInput::Store(msg));
}
}
impl<H>... | code_fim | hard | {
"lang": "rust",
"repo": "Alorel/yewdux",
"path": "/yewdux/src/service.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/digest/src/dev/mac.rs
/
/
/
Define
MAC
test
#
[
macro_export
]
#
[
cfg
(
feature
=
"
mac
"
)
]
#
[
cfg_attr
(
docsrs
doc
(
cfg
(
all
(
feature
=
"
dev
"
feature
=
"
mac
"
)
)
)
)
]
macro_rules
!
new_mac_test
{
(
name
:
ident
test_name
:
expr
ma... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/digest/src/dev/mac.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
macro_rules
!
new_resettable_mac_test
{
(
name
:
ident
test_name
:
expr
mac
:
ty
(
)
?
)
=
>
{
digest
:
:
new_resettable_mac_test
!
(
name
test_name
mac
"
"
)
;
}
;
(
name
:
ident
test_name
:
expr
mac
:
ty
trunc_left
(
)
?
)
=
>
{
digest
:
:
new_resettable_mac_test
!
(
name
test_name
mac
"
left
"
)
;
}
;... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/digest/src/dev/mac.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Clone)]
pub struct Setting {
pub server: Server,
pub database: Database,
}
impl Setting {
pub fn new(name: &str) -> Result<Setting, ConfigError> {
let mut s = Config::default();
let filename = format!("./config/{}", name);
s.merge(File... | code_fim | hard | {
"lang": "rust",
"repo": "wowiwj/story-rs",
"path": "/src/common/src/setting/setting.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wowiwj/story-rs path: /src/common/src/setting/setting.rs
use config::{Config, File, ConfigError};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone)]
pub struct Server {
pub host: String,
pub port: u16,
pub domain: String,
pub jwt_secret: String,
}
im... | code_fim | hard | {
"lang": "rust",
"repo": "wowiwj/story-rs",
"path": "/src/common/src/setting/setting.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thepowersgang/rust_os path: /Kernel/Core/async-v3/buffer.rs
// "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/async-v3/buffer.rs
//! Asynchronous buffer handles
/*
/// Buffer providing a location for read data (incoming / mutable)
pub struct ReadBuffer<'a> {
}
/// Buffer providi... | code_fim | medium | {
"lang": "rust",
"repo": "thepowersgang/rust_os",
"path": "/Kernel/Core/async-v3/buffer.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
impl ReadBuffer<'a>
{
// UNSAFE: If this is leaked while borrowed, the borrow will access invalidated memory
pub unsafe fn new_borrow(data: &mut [u8]) -> ReadBuffer
{
todo!("ReadBuffer::new_borrow");
}
pub fn new_user(data: FreezeMut<[u8]>) -> ReadBuffer<'static>
{
todo!("ReadBuffer::new_user... | code_fim | hard | {
"lang": "rust",
"repo": "thepowersgang/rust_os",
"path": "/Kernel/Core/async-v3/buffer.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Not enough samples in the queue to fill the buffer, but take what we can
queued_samples
.consume_into(&out_buffer[buffer_index..buffer_index + queued_elements_remaining]);
buffer_index += queued_elements_remaining;
match chunk_receiver.recv() {
... | code_fim | hard | {
"lang": "rust",
"repo": "ajyoon/spectrophoner",
"path": "/src/portaudio_streamer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ajyoon/spectrophoner path: /src/portaudio_streamer.rs
use std::cell::RefCell;
use std::sync::mpsc::{channel, Receiver};
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use portaudio;
use stopwatch::Stopwatch;
use audio_streamer::AudioStreamer;
use sample_buffer::SampleBu... | code_fim | hard | {
"lang": "rust",
"repo": "ajyoon/spectrophoner",
"path": "/src/portaudio_streamer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LarsHachmeister/plantex path: /base/src/gen/plant/mod.rs
mod tree;
use self::tree::TreeGen;
use prop::Plant;
use rand::{Rand, Rng};
<|fim_suffix|>impl PlantGenerator {
pub fn generate<R: Rng>(self, rng: &mut R) -> Plant {
match self {
PlantGenerator::Tree(treegen) => P... | code_fim | medium | {
"lang": "rust",
"repo": "LarsHachmeister/plantex",
"path": "/base/src/gen/plant/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PlantGenerator {
pub fn generate<R: Rng>(self, rng: &mut R) -> Plant {
match self {
PlantGenerator::Tree(treegen) => Plant::Tree { branches: treegen.generate(rng) },
}
}
}
impl Rand for PlantGenerator {
fn rand<R: Rng>(rng: &mut R) -> Self {
PlantGener... | code_fim | medium | {
"lang": "rust",
"repo": "LarsHachmeister/plantex",
"path": "/base/src/gen/plant/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tosteiner/thoth path: /thoth-app/src/models/contribution/create_contribution_mutation.rs
use serde::Deserialize;
use serde::Serialize;
use thoth_api::contribution::model::ContributionType;
use super::Contribution;
const CREATE_CONTRIBUTION_MUTATION: &str = "
mutation CreateContribution(
... | code_fim | hard | {
"lang": "rust",
"repo": "tosteiner/thoth",
"path": "/thoth-app/src/models/contribution/create_contribution_mutation.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let m = self.ncols();
(0..m).map(|j| self.column_vector(j)).collect()
}
pub fn nullspace_basis(&self) -> Vec<Vec<Fmpz>> {
let mut b = FmpzMat::new(
self.ncols() as mp_limb_signed_t,
self.ncols() as mp_limb_signed_t,
);
let r = unsafe... | code_fim | hard | {
"lang": "rust",
"repo": "stakemori/flint-rust",
"path": "/src/fmpz_mat.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stakemori/flint-rust path: /src/fmpz_mat.rs
extern crate libc;
extern crate gmp;
use self::gmp::mpz::mp_limb_t;
use std::ops::{Shl, Shr, ShlAssign, ShrAssign};
use std::mem::uninitialized;
use bindings::*;
use self::libc::{c_ulong, c_long};
use fmpz::Fmpz;
use std::fmt;
use traits::*;
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "stakemori/flint-rust",
"path": "/src/fmpz_mat.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrisliebert/frustum_query path: /src/query.rs
// Copyright (C) 2017 Chris Liebert
use frustum::Frustum;
/// `FrustumQueryObject`
///
/// A data structure describing an object's local center and bounding radius
///
#[derive(Copy, Clone, Debug)]
pub struct FrustumQueryObject {
pub x: f32,
... | code_fim | hard | {
"lang": "rust",
"repo": "chrisliebert/frustum_query",
"path": "/src/query.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Query if a list of objects are in the frustum (in parallel) with Rayon
///
#[cfg(feature = "multithreaded_rayon")]
pub fn execute_parallel_rayon(&self, frustum: &Frustum, result: &mut Vec<bool>) {
use rayon::prelude::*;
self.objects.par_iter().map(|&o| {
fru... | code_fim | hard | {
"lang": "rust",
"repo": "chrisliebert/frustum_query",
"path": "/src/query.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Query if a list of objects are in the frustum
///
pub fn execute(&self, frustum: &Frustum, result: &mut Vec<bool>) {
for i in 0 .. self.objects.len() {
let o = &self.objects[i];
result[i] = frustum.sphere_intersecting(&o.x, &o.y, &o.z, &o.r);
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "chrisliebert/frustum_query",
"path": "/src/query.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dora-gt/tower-web path: /src/util/buf_stream.rs
//! Asynchronous stream of bytes.
//!
//! This module contains the `BufStream` trait and a number of combinators for
//! this trait. The trait is similar to `Stream` in the `futures` library, but
//! instead of yielding arbitrary values, it only yi... | code_fim | medium | {
"lang": "rust",
"repo": "dora-gt/tower-web",
"path": "/src/util/buf_stream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::buf_stream::BufStream;
pub use self::chain::Chain;
pub use self::collect::Collect;
pub use self::empty::{empty, Empty};
pub use self::from::FromBufStream;
pub use self::size_hint::SizeHint;
pub use self::std::StdStream;<|fim_prefix|>// repo: dora-gt/tower-web path: /src/util/buf_stream.rs
/... | code_fim | medium | {
"lang": "rust",
"repo": "dora-gt/tower-web",
"path": "/src/util/buf_stream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lokathor/bytemuck path: /tests/offset_of_tests.rs
#![allow(clippy::disallowed_names)]
use bytemuck::{offset_of, Zeroable};
#[test]
fn test_offset_of_vertex() {
#[repr(C)]
struct Vertex {
pos: [f32; 2],
uv: [u16; 2],
color: [u8; 4],
}
unsafe impl Zeroable for Vertex {}
let... | code_fim | medium | {
"lang": "rust",
"repo": "Lokathor/bytemuck",
"path": "/tests/offset_of_tests.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a_offset = offset_of!(Default::default(), Foo, a);
let b_offset = offset_of!(Default::default(), Foo, b);
let c_offset = offset_of!(Default::default(), Foo, c);
assert_ne!(a_offset, b_offset);
assert_ne!(b_offset, c_offset);
// We can't check against hardcoded values for a repr(Rust) type... | code_fim | medium | {
"lang": "rust",
"repo": "Lokathor/bytemuck",
"path": "/tests/offset_of_tests.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn load_state_fixed(key: &[u8], value: &mut [u8]) -> Result<usize, SystemError>{
push_costack(key);
_system_call(GLOBAL_STORAGE_FEATURE, GlobalStorageFunctions::StoreState as u32)?;
Ok(pop_costack_fixed(value)? as usize)
}
/*
pub fn load_state(key: &[u8]) -> Result<Vec<u8>, SystemError>{
... | code_fim | hard | {
"lang": "rust",
"repo": "earlgreytech/neutron-star",
"path": "/src/storage.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: earlgreytech/neutron-star path: /src/storage.rs
use crate::syscalls::*;
/*
## Global Storage
ID: 1
Functions:
* store_state(key, value) -> ()
* load_state(key) -> (value)
* key_exists(key) -> (bool)
*/
const GLOBAL_STORAGE_FEATURE: u32 = 1;
<|fim_suffix|>pub fn load_state_fixed(key: &[u8], ... | code_fim | hard | {
"lang": "rust",
"repo": "earlgreytech/neutron-star",
"path": "/src/storage.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // method body would be defined here
}
}
// let m = Message::Write(String::from("hello"));
// m.call();
fn main() {
let v = vec!["Hello".to_string(), "World".to_string()];
let v1: Vec<Message> = v.into_iter().map(Message::Write).collect();
}<|fim_prefix|>// repo: szkkentaro/rust-hands... | code_fim | hard | {
"lang": "rust",
"repo": "szkkentaro/rust-hands-on",
"path": "/enums/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// embeds the address data type insisde the variants
struct IpV4Addr{
// detail
}
struct IpV6Addr{
// detail elided
}
enum IpAddr {
V4(IpV4Addr),
V6(IpV6Addr),
}
// constructor as a function
enum Message {
Quit,
Move { x: i32, y: i32},
Write(String),
ChangeColor(i32, i32, ... | code_fim | hard | {
"lang": "rust",
"repo": "szkkentaro/rust-hands-on",
"path": "/enums/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: szkkentaro/rust-hands-on path: /enums/src/main.rs
// enum with struct
// enum IpAddrKind {
// V4,
// V6,
// }
// struct IpAddr {
// kind: IpAddrKind,
// address: String,
// }
<|fim_suffix|> let v = vec!["Hello".to_string(), "World".to_string()];
let v1: Vec<Message> = v... | code_fim | hard | {
"lang": "rust",
"repo": "szkkentaro/rust-hands-on",
"path": "/enums/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let y: f64 = 0.01f64 * 1i16.into();
//~^ ERROR type annotations needed
//~| HELP try using a fully qualified path
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/inference/issue-70082.rs
fn main() {
// this closure is fine, and should not get any error annotations
let em = |v: ... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/inference/issue-70082.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/inference/issue-70082.rs
fn main() {
// this closure is fine, and should not get any error annotations
let em = |v: f64| -> f64 { v };
<|fim_suffix|> let y: f64 = 0.01f64 * 1i16.into();
//~^ ERROR type annotations needed
//~| HELP try using a fu... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/inference/issue-70082.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ekicyou/emo-rs path: /src/parse_req.rs
use shiori3::*;
pub struct Req<'a> {
inner: ShioriRequest<'a>,
}
<|fim_suffix|> 0.to_lua(lua)
}
}<|fim_middle|>impl<'lua, 'a> ToLua<'lua> for &Req<'a> {
fn to_lua(self, lua: &'lua Lua) {
| code_fim | medium | {
"lang": "rust",
"repo": "ekicyou/emo-rs",
"path": "/src/parse_req.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0.to_lua(lua)
}
}<|fim_prefix|>// repo: ekicyou/emo-rs path: /src/parse_req.rs
use shiori3::*;
pub struct Req<'a> {
inner: ShioriRequest<'a>,
}
<|fim_middle|>impl<'lua, 'a> ToLua<'lua> for &Req<'a> {
fn to_lua(self, lua: &'lua Lua) {
| code_fim | medium | {
"lang": "rust",
"repo": "ekicyou/emo-rs",
"path": "/src/parse_req.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: japaric/linux-rtfm path: /rtfm/examples/mc-xspawn.rs
#![deny(rust_2018_compatibility)]
#![deny(rust_2018_idioms)]
#![deny(warnings)]
#![no_main]
#![no_std]
use linux_io::{process, Stderr, Stdout};
use panic_exit as _;
#[rtfm::app(cores = 2)]
const APP: () = {
#[init(core = 0, spawn = [ping... | code_fim | medium | {
"lang": "rust",
"repo": "japaric/linux-rtfm",
"path": "/rtfm/examples/mc-xspawn.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Stderr.write(b"[1] ping\n").ok();
c.spawn.pong().ok();
}
};<|fim_prefix|>// repo: japaric/linux-rtfm path: /rtfm/examples/mc-xspawn.rs
#![deny(rust_2018_compatibility)]
#![deny(rust_2018_idioms)]
#![deny(warnings)]
#![no_main]
#![no_std]
use linux_io::{process, Stderr, Stdout};
use ... | code_fim | medium | {
"lang": "rust",
"repo": "japaric/linux-rtfm",
"path": "/rtfm/examples/mc-xspawn.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuillaumeGomez/paste path: /tests/test_attr.rs
use paste::paste;
#[test]
fn test_paste_cfg() {
<|fim_suffix|> }
};
}
struct Paste;
#[cfg(target_pointer_width = "64")]
m!(Paste, 64);
#[cfg(target_pointer_width = "32")]
m!(Paste, 32);
let _ = new;... | code_fim | hard | {
"lang": "rust",
"repo": "GuillaumeGomez/paste",
"path": "/tests/test_attr.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct Paste;
#[cfg(target_pointer_width = "64")]
m!(Paste, 64);
#[cfg(target_pointer_width = "32")]
m!(Paste, 32);
let _ = new;
}<|fim_prefix|>// repo: GuillaumeGomez/paste path: /tests/test_attr.rs
use paste::paste;
#[test]
fn test_paste_cfg() {
macro_rules! m {
(... | code_fim | easy | {
"lang": "rust",
"repo": "GuillaumeGomez/paste",
"path": "/tests/test_attr.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zenkriztao/rust path: /src/test/ui/consts/std/net/ip.rs
// run-pass
use std::net::{IpAddr, Ipv4Addr};
<|fim_suffix|> const IP_ADDRESS : IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
const IS_IP_V4 : bool = IP_ADDRESS.is_ipv4();
assert!(IS_IP_V4);
const IS_IP_V6 : bool = IP_ADDRESS... | code_fim | easy | {
"lang": "rust",
"repo": "zenkriztao/rust",
"path": "/src/test/ui/consts/std/net/ip.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const IS_IP_V4 : bool = IP_ADDRESS.is_ipv4();
assert!(IS_IP_V4);
const IS_IP_V6 : bool = IP_ADDRESS.is_ipv6();
assert!(!IS_IP_V6);
}<|fim_prefix|>// repo: zenkriztao/rust path: /src/test/ui/consts/std/net/ip.rs
// run-pass
use std::net::{IpAddr, Ipv4Addr};
fn main() {
<|fim_middle|> ... | code_fim | medium | {
"lang": "rust",
"repo": "zenkriztao/rust",
"path": "/src/test/ui/consts/std/net/ip.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const IS_IP_V6 : bool = IP_ADDRESS.is_ipv6();
assert!(!IS_IP_V6);
}<|fim_prefix|>// repo: zenkriztao/rust path: /src/test/ui/consts/std/net/ip.rs
// run-pass
use std::net::{IpAddr, Ipv4Addr};
fn main() {
<|fim_middle|> const IP_ADDRESS : IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
const I... | code_fim | medium | {
"lang": "rust",
"repo": "zenkriztao/rust",
"path": "/src/test/ui/consts/std/net/ip.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leopangan/linkerd2-proxy path: /linkerd/app/inbound/src/policy/store.rs
use super::{discover, AllowPolicy, CheckPolicy, DefaultPolicy, DeniedUnknownPort};
use linkerd_app_core::{proxy::http, transport::OrigDstAddr, Error, Result};
pub use linkerd_server_policy::{Authentication, Authorization, Pr... | code_fim | hard | {
"lang": "rust",
"repo": "leopangan/linkerd2-proxy",
"path": "/linkerd/app/inbound/src/policy/store.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let store = Self {
default,
ports: Arc::new(rxs),
};
(store, default_tx)
}
/// Spawns a watch for each of the given ports.
///
/// The returned future completes when a watch has been successfully created for all of the
/// provided ports... | code_fim | hard | {
"lang": "rust",
"repo": "leopangan/linkerd2-proxy",
"path": "/linkerd/app/inbound/src/policy/store.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// === impl Store ===
impl Store {
fn mk_default(default: DefaultPolicy) -> Option<(Tx, Rx)> {
match default {
DefaultPolicy::Deny => None,
DefaultPolicy::Allow(sp) => Some(watch::channel(sp)),
}
}
pub(crate) fn fixed(
default: impl Into<Defaul... | code_fim | hard | {
"lang": "rust",
"repo": "leopangan/linkerd2-proxy",
"path": "/linkerd/app/inbound/src/policy/store.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Torkilso/open-ended-coevolution path: /src/neatns/novelty_archive.rs
use crate::config;
use crate::simulator::Point;
pub struct NoveltyArchive {
pub(crate) novelty_items: Vec<Point>,
}
impl NoveltyArchive {
pub fn new() -> NoveltyArchive {
NoveltyArchive {
novelty_i... | code_fim | hard | {
"lang": "rust",
"repo": "Torkilso/open-ended-coevolution",
"path": "/src/neatns/novelty_archive.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if distances.len() < 15 {
return 0.0;
}
let closest_points = distances[0..config::NEATNS.amount_of_neighbors].to_vec();
closest_points.iter().sum::<f64>() / closest_points.len() as f64
}
pub fn find_distances_to_point(&self, current_point: &Point) -> V... | code_fim | hard | {
"lang": "rust",
"repo": "Torkilso/open-ended-coevolution",
"path": "/src/neatns/novelty_archive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for point in self.novelty_items.iter() {
distances.push(euclidean_distance(point, current_point));
}
distances
}
}
pub fn euclidean_distance(point_a: &Point, point_b: &Point) -> f64 {
((point_b.x - point_a.x).powi(2) + (point_b.y - point_a.y).powi(2)).sqrt()
}<... | code_fim | medium | {
"lang": "rust",
"repo": "Torkilso/open-ended-coevolution",
"path": "/src/neatns/novelty_archive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/editor/icon_auto_graph.rs
pub struct IconAutoGraph {
props: crate::Props,
}
impl yew::Component for IconAutoGraph {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelude:... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/editor/icon_auto_graph.rs",
"mode": "psm",
"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.