text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: robroyx3m/f4 path: /examples/timer-interrupt.rs
//! Timer interrupt test. LED should flicker unevenly.
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate stm32_f429_bgt6;
extern crate stm32f429x;
extern crate cortex_m_rtfm as rtfm;
extern crate nb;
<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "robroyx3m/f4",
"path": "/examples/timer-interrupt.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 2. Trace the main entry point(s) + every enum separately.
tracer.trace_type::<messages::Address>(&samples)?;
tracer.trace_type::<error::FastPayError>(&samples)?;
tracer.trace_type::<serialize::SerializedMessage>(&samples)?;
tracer.registry()
}
arg_enum! {
#[derive(Debug, StructOpt,... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/fastpay",
"path": "/fastpay_core/src/generate_format.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gdanezis/fastpay path: /fastpay_core/src/generate_format.rs
// Copyright (c) Facebook, Inc. and its affiliates.
// SPDX-License-Identifier: Apache-2.0
use fastpay_core::{error, messages, serialize};
use serde_reflection::{Registry, Result, Samples, Tracer, TracerConfig};
use std::{fs::File, io:... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/fastpay",
"path": "/fastpay_core/src/generate_format.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>arg_enum! {
#[derive(Debug, StructOpt, Clone, Copy)]
enum Action {
Print,
Test,
Record,
}
}
#[derive(Debug, StructOpt)]
#[structopt(
name = "FastPay format generator",
about = "Trace serde (de)serialization to generate format descriptions for FastPay types"
)]
struct Options {
#[s... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/fastpay",
"path": "/fastpay_core/src/generate_format.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h503/i3c1/i3c_getcapr.rs
#[doc = "Register `I3C_GETCAPR` reader"]
pub type R = crate::R<I3C_GETCAPR_SPEC>;
#[doc = "Register `I3C_GETCAPR` writer"]
pub type W = crate::W<I3C_GETCAPR_SPEC>;
#[doc = "Field `CAPPEND` reader - IBI MDB support for p... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h503/i3c1/i3c_getcapr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>g::write_with_zero) this register using [`i3c_getcapr::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct I3C_GETCAPR_SPEC;
impl crate::RegisterSpec for I3C_GETCAPR_SPEC {
type Ux = u32;
}
#[doc = "`rea... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h503/i3c1/i3c_getcapr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>static USED_CPUS: AtomicU16 = AtomicU16::new(!0b110);
pub fn spawn<F: 'static + FnMut()>(mut f: F) {
// Wait until there is a free CPU in the bit map
let mut used_cpus = USED_CPUS.load(Ordering::Relaxed);
let mut next_cpu;
loop {
loop {
if used_cpus != !0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "alevy/allora",
"path": "/src/thread.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn spawn<F: 'static + FnMut()>(mut f: F) {
// Wait until there is a free CPU in the bit map
let mut used_cpus = USED_CPUS.load(Ordering::Relaxed);
let mut next_cpu;
loop {
loop {
if used_cpus != !0 {
break;
}
used_cpus = USED_... | code_fim | hard | {
"lang": "rust",
"repo": "alevy/allora",
"path": "/src/thread.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alevy/allora path: /src/thread.rs
use alloc::boxed::Box;
use core::sync::atomic::{AtomicU16, Ordering};
use crate::gic;
#[repr(C)]
struct Thread<T: Sized> {
main: extern "C" fn(Box<Self>),
stack: Box<[usize; 1024]>,
userdata: T,
}
<|fim_suffix|>extern "C" fn thread_start(mut conf:... | code_fim | hard | {
"lang": "rust",
"repo": "alevy/allora",
"path": "/src/thread.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atsushi130/EnigmaMachine path: /src/enigma_machine/enigma.rs
/// enigma module
use super::{ Router, Reflector, RouterManager, Plugboard };
/// base64 module
use base64::{ encode, decode };
pub struct Enigma {
router_manager: RouterManager,
plugboard: Plugboard,
reflector: Reflecto... | code_fim | hard | {
"lang": "rust",
"repo": "atsushi130/EnigmaMachine",
"path": "/src/enigma_machine/enigma.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bytes = string.as_bytes();
encode(&bytes)
}
pub fn decrypt(&mut self, string: &str) -> String {
let decrypted: Vec<String> = string.chars().map( |character| {
let intput = self.plugboard.input(&character);
let in_encrypted = self.router_manag... | code_fim | hard | {
"lang": "rust",
"repo": "atsushi130/EnigmaMachine",
"path": "/src/enigma_machine/enigma.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pvva/leetcode-rust path: /problems_0001_0100/examples/12_integer_to_roman.rs
/*
https://leetcode.com/problems/integer-to-roman/
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol Value
I 1
V 5
X 10
L 5... | code_fim | hard | {
"lang": "rust",
"repo": "pvva/leetcode-rust",
"path": "/problems_0001_0100/examples/12_integer_to_roman.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn int_to_roman(num: i32) -> String {
let mut n = num;
// Option 1) - slower, a bit more memory
// NUMERALS.iter().map(|(d, v)| {
// let count = n / d;
// n -= count * d;
// (*v).repeat(count as usize)
// }).fold(S... | code_fim | hard | {
"lang": "rust",
"repo": "pvva/leetcode-rust",
"path": "/problems_0001_0100/examples/12_integer_to_roman.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hashmismatch/periphery.rs path: /periphery_core/src/float_core.rs
use core::intrinsics;
type c_float = f32;
extern {
fn acosf(n: c_float) -> c_float;
fn asinf(n: c_float) -> c_float;
fn atan2f(a: c_float, b: c_float) -> c_float;
fn atanf(n: c_float) -> c_float;
fn coshf(n: c_flo... | code_fim | hard | {
"lang": "rust",
"repo": "hashmismatch/periphery.rs",
"path": "/periphery_core/src/float_core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { asinf(self) }
}
#[inline]
fn acos(self) -> f32 {
unsafe { acosf(self) }
}
}<|fim_prefix|>// repo: hashmismatch/periphery.rs path: /periphery_core/src/float_core.rs
use core::intrinsics;
type c_float = f32;
extern {
fn acosf(n: c_float) -> c_float;
fn asinf(n... | code_fim | hard | {
"lang": "rust",
"repo": "hashmismatch/periphery.rs",
"path": "/periphery_core/src/float_core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tristoney/xv7 path: /xv7-user/src/io.rs
use crate::syscall;
use core::fmt;
use core::fmt::Write;
struct Stdout;
impl fmt::Write for Stdout {
fn write_str(&mut self, s: &str) -> fmt::Result {
<|fim_suffix|>#[doc(hidden)]
pub fn _print(args: fmt::Arguments) {
Stdout.write_fmt(args).unwra... | code_fim | medium | {
"lang": "rust",
"repo": "tristoney/xv7",
"path": "/xv7-user/src/io.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[doc(hidden)]
pub fn _print(args: fmt::Arguments) {
Stdout.write_fmt(args).unwrap();
}<|fim_prefix|>// repo: tristoney/xv7 path: /xv7-user/src/io.rs
use crate::syscall;
use core::fmt;
use core::fmt::Write;
struct Stdout;
<|fim_middle|>impl fmt::Write for Stdout {
fn write_str(&mut self, s: &st... | code_fim | medium | {
"lang": "rust",
"repo": "tristoney/xv7",
"path": "/xv7-user/src/io.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn diff() {
unimplemented!()
}
pub async fn run(api_key: String, args: Star) -> anyhow::Result<()> {
let github = Github::new(USER_AGENT, Credentials::Token(api_key.clone()))?;
let Star { dryrun } = args;
graphql(api_key.clone()).await?;
// Does not consume rate limit
let stat... | code_fim | hard | {
"lang": "rust",
"repo": "davidmaceachern/ohcool",
"path": "/src/star.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidmaceachern/ohcool path: /src/star.rs
use anyhow::{anyhow, bail};
use hubcaps::{Credentials, Github};
use reqwest::{header, Client};
use serde_json::json;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
pub struct Star {
/// Run without actually updating account
#[structopt(sho... | code_fim | hard | {
"lang": "rust",
"repo": "davidmaceachern/ohcool",
"path": "/src/star.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn execute<N>(
&'static self,
executor_name: N,
working_directory: &'static str,
) -> ResultFuture<Vec<Arc<Execution>>>
where
N: Into<ExecutorName>,
{
self.executor_repository()
.executor_of_name(executor_name.into(), working_directory)
... | code_fim | hard | {
"lang": "rust",
"repo": "megumish/iza",
"path": "/src/package/executor_app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: megumish/iza path: /src/package/executor_app.rs
use crate::package::*;
use futures::prelude::*;
use std::sync::Arc;
pub trait ExecutorApp: HasExecutorRepository + Sync {
fn new_executor<N>(
&'static self,
executor_name: N,
working_directory: &'static str,
) -> Re... | code_fim | medium | {
"lang": "rust",
"repo": "megumish/iza",
"path": "/src/package/executor_app.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Copy, Clone)]
pub struct Accessory {
pub _address: u8,
}<|fim_prefix|>// repo: heruhday/arx-interpolation path: /src/arx/acgi/drawable.rs
use crate::arx::acrx;
#[repr(C)]
#[derive(Copy, Clone, Debu<|fim_middle|>g)]
pub struct Drawable {
pub _base: acrx::Object,
pub m_pAccessory: *mut Access... | code_fim | medium | {
"lang": "rust",
"repo": "heruhday/arx-interpolation",
"path": "/src/arx/acgi/drawable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>b m_pAccessory: *mut Accessory,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Accessory {
pub _address: u8,
}<|fim_prefix|>// repo: heruhday/arx-interpolation path: /src/arx/acgi/drawable.rs
use crate::arx::acrx;
#[repr(C)]
#[derive(Copy, Clone, Debu<|fim_middle|>g)]
pub struct Drawable {
... | code_fim | medium | {
"lang": "rust",
"repo": "heruhday/arx-interpolation",
"path": "/src/arx/acgi/drawable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heruhday/arx-interpolation path: /src/arx/acgi/drawable.rs
use crate::arx::acrx;
#[repr(C)]
#[derive(Copy, Clone, Debu<|fim_suffix|> Copy, Clone)]
pub struct Accessory {
pub _address: u8,
}<|fim_middle|>g)]
pub struct Drawable {
pub _base: acrx::Object,
pub m_pAccessory: *mut Access... | code_fim | medium | {
"lang": "rust",
"repo": "heruhday/arx-interpolation",
"path": "/src/arx/acgi/drawable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(true, PlayerName::new(&"aaaa".to_string()).is_ok());
assert_eq!(true, PlayerName::new(&"dave".to_string()).is_ok());
assert_eq!(true, PlayerName::new(&"dave_dave_".to_string()).is_ok());
assert_eq!(true, PlayerName::new(&"dave_d4ve".to_string()).is_ok());
assert_eq!(true, Pl... | code_fim | hard | {
"lang": "rust",
"repo": "VoigtSebastian/gladiators-player-service",
"path": "/src/player.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VoigtSebastian/gladiators-player-service path: /src/player.rs
use crate::error::CustomError;
use lazy_static::lazy_static;
use regex::Regex;
use tide::convert::{Deserialize, Serialize};
use tide::http::mime;
use tide::{Body, Response, StatusCode};
lazy_static! {
static ref PLAYER_NAME_REGEX... | code_fim | hard | {
"lang": "rust",
"repo": "VoigtSebastian/gladiators-player-service",
"path": "/src/player.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juryokun/passwordManager path: /src/manage_file.rs
use serde::Deserialize;
use serde::Serialize;
use std::fs::File;
const FILE_NAME: &str = "serviceList.csv";
const DIST_FILE_NAME: &str = "serviceList.enc";
#[derive(Debug, Deserialize, Serialize)]
pub struct Record {
pub service: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "juryokun/passwordManager",
"path": "/src/manage_file.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> File::open(&self.file_path)
}
}
pub fn load_data() -> Vec<Record> {
let file = DataFile::new();
let mut rdr = csv::Reader::from_reader(file.file_open().unwrap());
let mut rel: Vec<Record> = vec![];
for result in rdr.deserialize() {
let record: Record = result.unwrap();... | code_fim | medium | {
"lang": "rust",
"repo": "juryokun/passwordManager",
"path": "/src/manage_file.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ericsink/rust-raytracer path: /src/scene/scene.rs
use crate::prelude::*;
use crate::light::Light;
use crate::geometry<|fim_suffix|>octree: Octree<Box<dyn Prim+Send+Sync>>,
pub background: Vec3,
}<|fim_middle|>::Prim;
use crate::raytracer::Octree;
use crate::vec3::Vec3;
pub struct Scene {
... | code_fim | medium | {
"lang": "rust",
"repo": "ericsink/rust-raytracer",
"path": "/src/scene/scene.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ruct Scene {
pub lights: Vec<Box<dyn Light+Send+Sync>>,
pub octree: Octree<Box<dyn Prim+Send+Sync>>,
pub background: Vec3,
}<|fim_prefix|>// repo: ericsink/rust-raytracer path: /src/scene/scene.rs
use crate::prelude::*;
use crate::light::Light;
use crate::geometry<|fim_middle|>::Prim;
use cra... | code_fim | medium | {
"lang": "rust",
"repo": "ericsink/rust-raytracer",
"path": "/src/scene/scene.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>octree: Octree<Box<dyn Prim+Send+Sync>>,
pub background: Vec3,
}<|fim_prefix|>// repo: ericsink/rust-raytracer path: /src/scene/scene.rs
use crate::prelude::*;
use crate::light::Light;
use crate::geometry<|fim_middle|>::Prim;
use crate::raytracer::Octree;
use crate::vec3::Vec3;
pub struct Scene {
... | code_fim | medium | {
"lang": "rust",
"repo": "ericsink/rust-raytracer",
"path": "/src/scene/scene.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RedlineTriad/unitystation_serverlist path: /api_converter/src/old_data.rs
#[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Root {
pub servers: Vec<Server>,
}
#[derive(Default, Debug, Clone, PartialE... | code_fim | hard | {
"lang": "rust",
"repo": "RedlineTriad/unitystation_serverlist",
"path": "/api_converter/src/old_data.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Map")]
pub current_map: String,
#[serde(rename = "GameMode")]
pub game_mode: String,
#[serde(rename = "IngameTime")]
pub ingame_time: String,
#[serde(rename = "PlayerCount")]
pub player_count: i64,
#[serde(rename = "ServerIP")]
pub server_ip: String,
#[serde(rename ... | code_fim | hard | {
"lang": "rust",
"repo": "RedlineTriad/unitystation_serverlist",
"path": "/api_converter/src/old_data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>: String,
#[serde(rename = "ServerPort")]
pub server_port: i64,
#[serde(rename = "WinDownload")]
pub win_download: String,
#[serde(rename = "OSXDownload")]
pub osxdownload: String,
#[serde(rename = "LinuxDownload")]
pub linux_download: String,
}<|fim_prefix|>// repo: Redlin... | code_fim | hard | {
"lang": "rust",
"repo": "RedlineTriad/unitystation_serverlist",
"path": "/api_converter/src/old_data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: patm1987/rust_d20_test path: /src/player.rs
use ability::{Ability, AbilityFactory};
#[derive(Clone)]
pub struct Player {
name: String,
strength: Ability,
dexterity: Ability,
constitution: Ability,
intelligence: Ability,
wisdom: Ability,
charisma: Ability
}
pub struct PlayerBuilder {
na... | code_fim | hard | {
"lang": "rust",
"repo": "patm1987/rust_d20_test",
"path": "/src/player.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_intelligence(&self) -> &Ability {
&self.intelligence
}
pub fn get_wisdom(&self) -> &Ability {
&self.wisdom
}
pub fn get_charisma(&self) -> &Ability {
&self.charisma
}
}
impl PlayerBuilder {
pub fn new() -> PlayerBuilder {
PlayerBuilder {
name: "None".to_string(),
strengt... | code_fim | hard | {
"lang": "rust",
"repo": "patm1987/rust_d20_test",
"path": "/src/player.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vajicek/rustray path: /src/main.rs
mod geometry;
mod image;
mod math;
mod raytracing;
mod scene;
use geometry::Plane;
use geometry::Sphere;
use image::Image;
use image::Scaling;
use math::Vec3;
use math::Vec3u8;
use raytracing::Raytracer;
use scene::Camera;
use scene::Light;
use scene::Material... | code_fim | hard | {
"lang": "rust",
"repo": "vajicek/rustray",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Scene::new(
vec![
Box::new(Sphere::new(
Vec3::new(-1.0, 0.0, 6.0), 1.0,
Material::new(
Vec3::new(0.01, 0.0, 0.01),
Vec3::new(1.0, 0.0, 1.0),
Vec3::new(0.0, 0.0, 0.0),
100... | code_fim | medium | {
"lang": "rust",
"repo": "vajicek/rustray",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ol(Symbol::Add), parse_path_node),
)),
)),
)),
)),
|(ident, trait_list)| {
let (trait_list, default_trait_list) = trait_list.unwrap_or_else(Default::default);
let default_trait_list = default_trait_list.unwrap_or_else(... | code_fim | hard | {
"lang": "rust",
"repo": "illlust/danube",
"path": "/danube-parse/src/parse/parse_generic_node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: illlust/danube path: /danube-parse/src/parse/parse_generic_node.rs
use super::*;
pub(super) fn parse_generic_node(t: Tokens) -> ParseResult<GenericNode> {
map(
tuple((
parse_ident_node,
opt(preceded(
parse_symbol(Symbol::Colon),
... | code_fim | hard | {
"lang": "rust",
"repo": "illlust/danube",
"path": "/danube-parse/src/parse/parse_generic_node.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yobicash/yobicrypto path: /src/memory.rs
// Copyright 2018 Yobicash Ltd.
//
// Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>
// and the Apache 2.0 license <LICENSE-APACHE or https://opensource.org/licenses/Apache-2.0>.
// This file may not be copied, modified... | code_fim | hard | {
"lang": "rust",
"repo": "yobicash/yobicrypto",
"path": "/src/memory.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Memory(Integer::from_f64(n).unwrap())
}
}
impl Add for Memory {
type Output = Memory;
fn add(self, rhs: Memory) -> Memory {
let mut output = self.0.clone();
output += rhs.0.clone();
Memory(output)
}
}
impl<'a> Add<&'a Memory> for Memory {
type Output... | code_fim | hard | {
"lang": "rust",
"repo": "yobicash/yobicrypto",
"path": "/src/memory.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Memory(output)
}
}
impl<'a> Sub<&'a Memory> for Memory {
type Output = Memory;
fn sub(self, rhs: &Memory) -> Memory {
let mut output = self.0.clone();
output -= rhs.0.clone();
Memory(output)
}
}
impl<'a, 'b> Sub<&'b Memory> for &'a Memory {
type Outp... | code_fim | hard | {
"lang": "rust",
"repo": "yobicash/yobicrypto",
"path": "/src/memory.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: K0R0VA/portal-chat path: /src/graphql/loaders/participants_loader.rs
use deadpool_postgres::{Pool, Client};
use async_graphql::dataloader::Loader;
use std::collections::HashMap;
use itertools::join;
use crate::graphql::models::user::User;
use crate::graphql::models::room::RoomId;
use crate::gra... | code_fim | hard | {
"lang": "rust",
"repo": "K0R0VA/portal-chat",
"path": "/src/graphql/loaders/participants_loader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file = OpenOptions::new()
.write(true)
.create(true)
.open("src/views/App.css")
.unwrap();
file.set_len(0).unwrap();
file.write(
compile_file("src/views/App.scss", Options::default())
.unwrap()
.as_bytes(),
)
.unwr... | code_fim | easy | {
"lang": "rust",
"repo": "pjtsearch/mconnect-gtk",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pjtsearch/mconnect-gtk path: /build.rs
use sass_rs::*;
use std::fs::OpenOptions;
use std::io::Write;
<|fim_suffix|> let mut file = OpenOptions::new()
.write(true)
.create(true)
.open("src/views/App.css")
.unwrap();
file.set_len(0).unwrap();
file.write(... | code_fim | easy | {
"lang": "rust",
"repo": "pjtsearch/mconnect-gtk",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruchira/RustExercisesSolutions path: /average/src/main.rs
use std::collections::HashMap;
#[derive(Debug)]
struct Averages {
mean: f64,
median: f64,
mode: Option<Vec<i32>>,
}
fn get_mode(numvec: &Vec<i32>) -> Option<Vec<i32>> {
let mut histogram: HashMap<i32, u32> = HashMap::new... | code_fim | hard | {
"lang": "rust",
"repo": "ruchira/RustExercisesSolutions",
"path": "/average/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_averages(nums: &[i32]) -> Averages {
let mut numvec: Vec<i32> = Vec::from(nums);
let mut sum: f64 = 0.0;
for &num in numvec.iter() {
sum += num as f64;
}
numvec.sort();
let num_nums = nums.len();
let mid = num_nums / 2;
let median =
if num_nums % 2 ==... | code_fim | hard | {
"lang": "rust",
"repo": "ruchira/RustExercisesSolutions",
"path": "/average/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sushma-biswas/grep path: /minigrep/src/main.rs
// to accept command line arguments
use std::env;
// for aborting execution
use std::process;
// bringing our api into scope
use minigrep::Config;
fn main() {
// args() is an iterator that returns the command line args as a series of values
... | code_fim | hard | {
"lang": "rust",
"repo": "sushma-biswas/grep",
"path": "/minigrep/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config = Config::new(env::args()).unwrap_or_else(|err| {
// printing error messages to std error instead of std output
eprintln!("Problem parsing arguments: {}", err);
// non-zero exit - indicates error
process::exit(1);
});
if let Err(e) = minigre... | code_fim | hard | {
"lang": "rust",
"repo": "sushma-biswas/grep",
"path": "/minigrep/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LawnGnome/waybar-custom-modules path: /swaync-client/build.rs
use std::{env, fs, path::PathBuf, time::Duration};
use anyhow::Result;
use dbus::blocking::{stdintf::org_freedesktop_dbus::Introspectable, Connection};
use dbus_codegen::GenOpts;
use serde::{Deserialize, Serialize};
#[derive(Debug, ... | code_fim | hard | {
"lang": "rust",
"repo": "LawnGnome/waybar-custom-modules",
"path": "/swaync-client/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let conn = Connection::new_session()?;
let proxy = conn.with_proxy(
"org.erikreider.swaync.cc",
"/org/erikreider/swaync/cc",
Duration::from_millis(1000),
);
let dest = PathBuf::from(env::var("OUT_DIR")?).join("swaync.rs");
match proxy.introspect() {
Ok(... | code_fim | hard | {
"lang": "rust",
"repo": "LawnGnome/waybar-custom-modules",
"path": "/swaync-client/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut clients = vec![];
let listener = TcpListener::bind("127.0.0.1:6666")?;
for connection in listener.incoming() {
handle_client(connection?.try_clone()?, &mut clients);
}
Ok(())
}<|fim_prefix|>// repo: rasongame/chatorust path: /src/main.rs
use std::net::{TcpListener, Tcp... | code_fim | medium | {
"lang": "rust",
"repo": "rasongame/chatorust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rasongame/chatorust path: /src/main.rs
use std::net::{TcpListener, TcpStream};
use std::io::{
Write,
//Read
};
fn handle_client(stream: TcpStream, clients: &mut Vec<TcpStream>) {
<|fim_suffix|>fn main() -> std::io::Result<()> {
let mut clients = vec![];
let listener = TcpListene... | code_fim | medium | {
"lang": "rust",
"repo": "rasongame/chatorust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: age-rs/riddle path: /riddle/src/error.rs
use crate::*;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum RiddleError {
#[cfg(feature = "riddle-audio")]
#[error(transparent)]
AudioError(#[from] audio::AudioError),
#[cfg(feature = "riddle-font")]
#[error(transparent)]
... | code_fim | medium | {
"lang": "rust",
"repo": "age-rs/riddle",
"path": "/riddle/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error(transparent)]
WindowError(#[from] platform::PlatformError),
}<|fim_prefix|>// repo: age-rs/riddle path: /riddle/src/error.rs
use crate::*;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum RiddleError {
#[cfg(feature = "riddle-audio")]
#[error(transparent)]
AudioError(#... | code_fim | medium | {
"lang": "rust",
"repo": "age-rs/riddle",
"path": "/riddle/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> \n itpl: A BAC .b A BAC .b, A BAC .b A BAC .c, A BAC .b A BAC .d-foo, A BAC .c A BAC .b, A BAC .c A BAC .c, A BAC .c A BAC .d-foo, A BAC .d A BAC .b, A BAC .d A BAC .c, A BAC .d A BAC .d-foobar;\
\n}\
\nA BAC .b A .b, A BAC .b A .c, A BAC .b A .d-foo, A BAC .c A .b, A BAC .c A .c, A BA... | code_fim | hard | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/libsass_closed_issues/issue_2291.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/libsass_closed_issues/issue_2291.rs
//! Tests auto-converted from "sass-spec/spec/libsass-closed-issues/issue_2291.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner().with_cwd("issue_2291")
}
#[test]
#[ignore] // unexepected error
fn t... | code_fim | hard | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/libsass_closed_issues/issue_2291.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn andpd_4() {
run_test(&Instruction { mnemonic: Mnemonic::ANDPD, operand1: Some(Direct(XMM4)), operand2: Some(IndirectDisplaced(RBX, 950857234, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broad... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/instr_andpd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_andpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[te... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/instr_andpd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // crear un grafo vacío
pub fn new() -> Self {
Grafo { Lista::new() }
}
// agregar un vértice
pub fn add_vertex(&mut grafo: Grafo, vertice: T) {
// simplemente se agrega a la lista.
Lista::push(&mut grafo.grafo, vertice);
}
// eliminar un vértice
p... | code_fim | medium | {
"lang": "rust",
"repo": "LuisChDev/grafo_rust",
"path": "/src/grafo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LuisChDev/grafo_rust path: /src/grafo.rs
use lista::Lista;
// definición de los grafos.
// se implementan como una lista de adyacencia.lista::Lista;
// Es decir, una lista de nodos, con sus respectivos arcos.
// Cada elemento de la lista es un struct que contiene el elemento y una lista
// de t... | code_fim | hard | {
"lang": "rust",
"repo": "LuisChDev/grafo_rust",
"path": "/src/grafo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // búsqueda por anchura
// árbol recubridor mínimo
}
// -- -- -- --
#[cfg(test)]
mod test {
use super::Grafo;
// agregar y eliminar vértices.
#[test]
}<|fim_prefix|>// repo: LuisChDev/grafo_rust path: /src/grafo.rs
use lista::Lista;
// definición de los grafos.
// se implementan co... | code_fim | hard | {
"lang": "rust",
"repo": "LuisChDev/grafo_rust",
"path": "/src/grafo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("HashMap contains:\n{:#?}", table.mapper);
}
fn lookup_user(uid: u32) -> String {
let user = match uid {
0 => "root",
502 => "Matt",
503 => "Jenny",
_ => "UNKNOWN!"
};
user.to_string()
}
// --<|fim_prefix|>// repo: pwrdwnsys/rust-examples p... | code_fim | hard | {
"lang": "rust",
"repo": "pwrdwnsys/rust-examples",
"path": "/rust-example-hashmap-cache/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pwrdwnsys/rust-examples path: /rust-example-hashmap-cache/src/main.rs
use std::collections::hash_map::{HashMap, Entry};
type UidGidHashMap = HashMap<u32, String>;
struct UidGidHash { mapper: UidGidHashMap }
impl UidGidHash {
fn search(&mut self, key: u32) -> String {
<|fim_suffix|> pr... | code_fim | hard | {
"lang": "rust",
"repo": "pwrdwnsys/rust-examples",
"path": "/rust-example-hashmap-cache/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn lookup_user(uid: u32) -> String {
let user = match uid {
0 => "root",
502 => "Matt",
503 => "Jenny",
_ => "UNKNOWN!"
};
user.to_string()
}
// --<|fim_prefix|>// repo: pwrdwnsys/rust-examples path: /rust-example-hashmap-cache/src/main.rs
use std::collect... | code_fim | medium | {
"lang": "rust",
"repo": "pwrdwnsys/rust-examples",
"path": "/rust-example-hashmap-cache/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: edenzik/pushloader path: /src/argparser.rs
#[macro_use]
extern crate clap;
use std::env;
use std::path::PathBuf;
use clap::{Arg, App, SubCommand};
use std::net::Ipv4Addr;
fn parse_args() -> Args {
<|fim_suffix|> let root = match matches.value_of("root") {
Some(v) => PathBuf::from(v... | code_fim | hard | {
"lang": "rust",
"repo": "edenzik/pushloader",
"path": "/src/argparser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(root.is_dir(), true);
return Args {port: port, address: address, root: root}
}
struct Args {
port: u16,
address: Ipv4Addr,
root: PathBuf,
}<|fim_prefix|>// repo: edenzik/pushloader path: /src/argparser.rs
#[macro_use]
extern crate clap;
use std::env;
use std::path::Pa... | code_fim | medium | {
"lang": "rust",
"repo": "edenzik/pushloader",
"path": "/src/argparser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Opportunitylivetv/weekendraytracer path: /src/sphere.rs
use material::Material;
use vector::Vector4;
use ray::Ray;
use renderable::{ IntersectionRecord, Renderable };
use std::rc::Rc;
pub struct Sphere {
center: Vector4,
radius: f32,
material: Rc<Box<Material>>,
}
impl Sphere {
... | code_fim | hard | {
"lang": "rust",
"repo": "Opportunitylivetv/weekendraytracer",
"path": "/src/sphere.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> -> Option<IntersectionRecord> {
let o_minus_c = ray.origin() - self.center;
let a = ray.direction().dot3(ray.direction());
let b = o_minus_c.dot3(ray.direction());
let c = (o_minus_c).dot3(o_minus_c) - self.radius * self.radius;
let discriminant = b * b -... | code_fim | hard | {
"lang": "rust",
"repo": "Opportunitylivetv/weekendraytracer",
"path": "/src/sphere.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if distance < distance_max && distance > distance_min {
let intersection_point = ray.point_at_distance(distance);
return Some(IntersectionRecord::new(
distance,
intersection_point,
(intersec... | code_fim | hard | {
"lang": "rust",
"repo": "Opportunitylivetv/weekendraytracer",
"path": "/src/sphere.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agourlay/zbb path: /src/main.rs
use colored::*;
use futures_util::stream::{self, StreamExt};
use reqwest::Client;
use select::document::Document;
use select::node::Node;
use select::predicate::*;
use std::num::ParseIntError;
use std::ops::RangeInclusive;
use std::process;
mod args;
mod models;
... | code_fim | hard | {
"lang": "rust",
"repo": "agourlay/zbb",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn get_station_overview(
client: &Client,
station: &StationSearch,
) -> Result<StationOverview, ZbbError> {
let html = request_html(client, &station.link_to_station_overview).await?;
let query = Class("ivu_table")
.descendant(Name("tbody"))
.descendant(Name("tr"));
... | code_fim | hard | {
"lang": "rust",
"repo": "agourlay/zbb",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut char_dict: HashMap<String, CharInitialConfig> = HashMap::new();
for entity_k in entity_keys.into_iter() {
js_get_mult!(
init_config,
Ok(js_pos), str ["chars", &entity_k, "pos"].join("."),
{
char_dict.insert(
en... | code_fim | hard | {
"lang": "rust",
"repo": "ArcQ/kf-1",
"path": "/rust/src/utils/char_dicts.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArcQ/kf-1 path: /rust/src/utils/char_dicts.rs
use utils::encoder::CoderKeyMapping;
use types::{Pt};
use std::collections::HashMap;
pub struct CharInitialConfig {
pub encodedK: i32,
pub speed: f32,
pub pos: Pt,
}
pub fn create_char_dict(
encoder_keys_dict: &CoderKeyMapping,
... | code_fim | hard | {
"lang": "rust",
"repo": "ArcQ/kf-1",
"path": "/rust/src/utils/char_dicts.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(clippy::type_complexity, non_snake_case)]
pub fn deser_list_com_amazonaws_pricing_attribute_value_list<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<std::vec::Vec<crate::model::AttributeValue>>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smi... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/pricing/src/json_deser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/pricing/src/json_deser.rs
) -> Result<crate::error::expired_next_token_exception::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable(... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/pricing/src/json_deser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn deser_structure_crate_model_service<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::Service>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tok... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/pricing/src/json_deser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
//
include!( "../../only_test/use_non_layer_only_test.rs" );<|fim_prefix|>// repo: dmvict/wTools path: /rust/test/meta/mod_interface/front/use_non_layer/mod.rs
use super::*;
mod tools
{
#[ allow( unused_imports ) ]
pub use super::super::*;
}
/// Private namespace of the module.
mod private
{
}
... | code_fim | medium | {
"lang": "rust",
"repo": "dmvict/wTools",
"path": "/rust/test/meta/mod_interface/front/use_non_layer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmvict/wTools path: /rust/test/meta/mod_interface/front/use_non_layer/mod.rs
use super::*;
mod tools
{
#[ allow( unused_imports ) ]
pub use super::super::*;
}
/// Private namespace of the module.
mod private
{
}
<|fim_suffix|> /// layer_a
layer layer_a;
}
//
include!( "../../only_te... | code_fim | medium | {
"lang": "rust",
"repo": "dmvict/wTools",
"path": "/rust/test/meta/mod_interface/front/use_non_layer/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>//
include!( "../../only_test/use_non_layer_only_test.rs" );<|fim_prefix|>// repo: dmvict/wTools path: /rust/test/meta/mod_interface/front/use_non_layer/mod.rs
use super::*;
mod tools
{
#[ allow( unused_imports ) ]
pub use super::super::*;
}
<|fim_middle|>/// Private namespace of the module.
mod p... | code_fim | medium | {
"lang": "rust",
"repo": "dmvict/wTools",
"path": "/rust/test/meta/mod_interface/front/use_non_layer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>se self::ray_triangle::ray_intersection_with_triangle;
#[doc(hidden)]
pub mod ray;
mod ray_aabb;
mod ray_ball;
mod ray_bounding_sphere;
mod ray_compound;
mod ray_cuboid;
mod ray_heightfield;
mod ray_plane;
mod ray_polyline;
mod ray_shape;
mod ray_support_map;
#[cfg(feature = "dim3")]
mod ray_triangle;
#[... | code_fim | medium | {
"lang": "rust",
"repo": "dimforge/ncollide",
"path": "/src/query/ray/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimforge/ncollide path: /src/query/ray/mod.rs
//! Ray-casting related definitions and implementations.
#[doc(inline)]
pub use self::ray::{Ray, RayCast, RayIntersection};
pub use self::ray_ball::ray_toi_with_ball;
pub <|fim_suffix|>od ray_heightfield;
mod ray_plane;
mod ray_polyline;
mod ray_sha... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/ncollide",
"path": "/src/query/ray/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>od ray_heightfield;
mod ray_plane;
mod ray_polyline;
mod ray_shape;
mod ray_support_map;
#[cfg(feature = "dim3")]
mod ray_triangle;
#[cfg(feature = "dim3")]
mod ray_trimesh;<|fim_prefix|>// repo: dimforge/ncollide path: /src/query/ray/mod.rs
//! Ray-casting related definitions and implementations.
#[doc... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/ncollide",
"path": "/src/query/ray/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/em-refactor path: /em-refactor-lib/src/refactorings/visitors/hir/function_definition_collector.rs
use rustc_span::{BytePos, Span};
use rustc_hir::{ImplItem, Item, ItemKind, Mod, def_id::DefId};
use rustc_hir::intravisit::{NestedVisitorMap, Visitor, walk_crate, walk_impl_item, walk_item};... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/em-refactor",
"path": "/em-refactor-lib/src/refactorings/visitors/hir/function_definition_collector.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(actual, expected);
}
#[test]
fn fn_decl_3() {
let input = r#"
struct S;
impl S {
fn main () {
/*START*/fn foo() {}/*END*/;
}
}"#;
let expected = Ok(FnDefinitionTest{
span: "fn foo() ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/em-refactor",
"path": "/em-refactor-lib/src/refactorings/visitors/hir/function_definition_collector.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knisht/ray-tracing path: /src/world/camera.rs
use std::f32::consts::PI;
use rand::prelude::ThreadRng;
use rand::Rng;
use super::math::{Ray, Vec3};
pub struct Camera {
origin: Vec3,
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
u: Vec3,
v: Vec3,
lens_ra... | code_fim | medium | {
"lang": "rust",
"repo": "knisht/ray-tracing",
"path": "/src/world/camera.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn random_vec(rng: &mut ThreadRng) -> Vec3 {
Vec3(rng.gen_range(0., 1.), rng.gen_range(0., 1.), 0.)
}
fn random_in_normalized_disc_impl(rng: &mut ThreadRng) -> Vec3 {
let p = &Self::random_vec(rng) * 2. - Vec3(1., 1., 0.);
if p.squared_norm() >= 1. {
Self::... | code_fim | hard | {
"lang": "rust",
"repo": "knisht/ray-tracing",
"path": "/src/world/camera.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'ducc> ToValues<'ducc> for () {
fn to_values(self, _ducc: &'ducc Ducc) -> Result<Values<'ducc>> {
Ok(Values::new())
}
}
impl<'ducc> FromValues<'ducc> for () {
fn from_values(_values: Values, _ducc: &'ducc Ducc) -> Result<Self> {
Ok(())
}
}
macro_rules! impl_tuple {
... | code_fim | hard | {
"lang": "rust",
"repo": "Ekranos/ducc-reborn",
"path": "/ducc-reborn/src/conversion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ekranos/ducc-reborn path: /ducc-reborn/src/conversion.rs
use array::Array;
use bytes::Bytes;
use ducc::Ducc;
use error::{Error, Result};
use function::Function;
use object::Object;
use std::collections::{BTreeMap, HashMap, BTreeSet, HashSet};
use std::cmp::{Eq, Ord};
use std::hash::{BuildHasher,... | code_fim | hard | {
"lang": "rust",
"repo": "Ekranos/ducc-reborn",
"path": "/ducc-reborn/src/conversion.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match value {
Value::Array(a) => Ok(a),
value => Err(Error::from_js_conversion(value.type_name(), "Array")),
}
}
}
impl<'ducc> ToValue<'ducc> for Object<'ducc> {
fn to_value(self, _ducc: &'ducc Ducc) -> Result<Value<'ducc>> {
Ok(Value::Object(self))... | code_fim | hard | {
"lang": "rust",
"repo": "Ekranos/ducc-reborn",
"path": "/ducc-reborn/src/conversion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Default names for [ir::LibCall]s. A function by this name is imported into the object as
/// part of the translation of a [ir::ExternalName::LibCall] variant.
pub fn default_libcall_names() -> Box<dyn Fn(ir::LibCall) -> String + Send + Sync> {
Box::new(move |libcall| match libcall {
ir::Li... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/module/src/lib.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/module/src/lib.rs
//! Top-level lib.rs for `cranelift_module`.
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr(feature = "clippy", plu... | code_fim | medium | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/module/src/lib.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>use cranelift_codegen::ir;
mod data_context;
mod module;
mod traps;
pub use crate::data_context::{DataDescription, Init};
pub use crate::module::{
DataDeclaration, DataId, FuncId, FuncOrDataId, FunctionDeclaration, Linkage, Module,
ModuleDeclarations, ModuleError, ModuleExtName, ModuleReloc, Mod... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/module/src/lib.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>rt
]
macro_rules
!
arr
{
(
T
:
ty
;
(
)
*
)
=
>
(
{
unsafe
{
crate
:
:
transmute
:
:
<
[
T
;
0
]
crate
:
:
GenericArray
<
T
crate
:
:
typenum
:
:
U0
>
>
(
[
]
)
}
}
)
;
(
T
:
ty
;
(
x
:
expr
)
*
(
)
*
)
=
>
(
crate
:
:
arr_impl
!
(
T
;
crate
:
:
typenum
:
:
U0
[
]
[
(
x
)
*
]
)
)
;
(
(
x
:
expr
)
+
)
=
>
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/generic-array/src/arr.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/generic-array/src/arr.rs
/
/
!
Implementation
for
arr
!
macro
.
use
super
:
:
ArrayLength
;
use
core
:
:
ops
:
:
Add
;
use
typenum
:
:
U1
;
/
/
/
Helper
trait
for
arr
!
macro
pub
trait
AddLength
<
T
N
:
ArrayLength
<
T
>
>
:
ArrayLength
<
T
>
{... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/generic-array/src/arr.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mk0x9/gsd-backlight-helper path: /src/main.rs
#![feature(convert)]
use std::env;
use std::process;
mod helper;
const OPT_SET: &'static str = "--set-brightness";
const OPT_GET: &'static str = "--get-brightness";
const OPT_GET_MAX: &'static str = "--get-max-brightness";
static BACKLIGH... | code_fim | medium | {
"lang": "rust",
"repo": "mk0x9/gsd-backlight-helper",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args: Vec<_> = env::args().collect();
if args.len() <= 1 {
show_help();
process::exit(0);
}
let backlight = helper::Backlight::new(BACKLIGHT_PATH);
match args[1].as_str() {
OPT_SET => {
if args.len() < 3 {
println!("wrong option")... | code_fim | medium | {
"lang": "rust",
"repo": "mk0x9/gsd-backlight-helper",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let args: Vec<_> = env::args().collect();
if args.len() <= 1 {
show_help();
process::exit(0);
}
let backlight = helper::Backlight::new(BACKLIGHT_PATH);
match args[1].as_str() {
OPT_SET => {
if args.len() < 3 {
println!("wr... | code_fim | medium | {
"lang": "rust",
"repo": "mk0x9/gsd-backlight-helper",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steamroller-airmash/airmash-server path: /server/src/defaults.rs
//! This module has the default component sets for all entity types. This is
//! meant to make it easier add new ones for use within the main server.
//! (External code can add them in EntitySpawn events if it needs to.)
use std::... | code_fim | medium | {
"lang": "rust",
"repo": "steamroller-airmash/airmash-server",
"path": "/server/src/defaults.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.