text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: wrule/rust-test path: /src/main.rs
use std::io;
use rand::Rng;
use std::cmp::Ordering;
<|fim_suffix|> println!("猜数字");
let secret_number = rand::thread_rng().gen_range(1, 101);
println!("生成的随机数字是:{}", secret_number);
println!("请输入一个数字:");
let mut guess = String::new();
io::stdin... | code_fim | easy | {
"lang": "rust",
"repo": "wrule/rust-test",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut guess = String::new();
io::stdin().read_line(&mut guess)
.expect("失败,未能读输入");
let guess: u32 = guess.trim().parse()
.expect("请输入一个正确的数字");
println!("你输入的是: {}", guess);
}<|fim_prefix|>// repo: wrule/rust-test path: /src/main.rs
use std::io;
use rand::Rng;
use std::cmp::Orde... | code_fim | medium | {
"lang": "rust",
"repo": "wrule/rust-test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wrule/rust-test path: /src/main.rs
use std::io;
use rand::Rng;
use std::cmp::Ordering;
fn main() {
println!("猜数字");
let secret_number = rand::thread_rng().gen_range(1, 101);
<|fim_suffix|> println!("请输入一个数字:");
let mut guess = String::new();
io::stdin().read_line(&mut guess)
... | code_fim | easy | {
"lang": "rust",
"repo": "wrule/rust-test",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bahelms/machines path: /cpu/examples/cpu.rs
use cpu::circuits::{RegisterFile, CPU, RAM};
fn main() {
/*
Instructions
"ADD Reg1 Reg2 Reg1" - 0000 0001 0010 0001
false, false, false, true,
false, false, false, true,
false, false, true, false,
false, false, false, true... | code_fim | hard | {
"lang": "rust",
"repo": "bahelms/machines",
"path": "/cpu/examples/cpu.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 8-bit registers
let mut rf = RegisterFile::new();
rf.set(
1,
vec![false, false, false, false, false, false, true, true],
);
rf.set(
2,
vec![false, false, false, false, false, true, false, false],
);
let mut cpu = CPU::new(memory, rf);
let... | code_fim | hard | {
"lang": "rust",
"repo": "bahelms/machines",
"path": "/cpu/examples/cpu.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ahosha/rsyncservice path: /src/error_handler.rs
/*
* Licensed Materials - Property of IBM
* 5725I71-CC011829
* (C) Copyright IBM Corp. 2018 . All Rights Reserved.
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp... | code_fim | easy | {
"lang": "rust",
"repo": "ahosha/rsyncservice",
"path": "/src/error_handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn fail_log_handler(message: &str) {
logger::log_error(&message.to_string());
process::exit(0x0100);
}<|fim_prefix|>// repo: ahosha/rsyncservice path: /src/error_handler.rs
/*
* Licensed Materials - Property of IBM
* 5725I71-CC011829
* (C) Copyright IBM Corp. 2018 . All Rights Reserved.
*... | code_fim | medium | {
"lang": "rust",
"repo": "ahosha/rsyncservice",
"path": "/src/error_handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>BlendContext, BlendContextError};
pub use filter_context::{FilterContext, FilterContextError};
pub use union_context::{UnionContext, UnionContextError};<|fim_prefix|>// repo: TaKO8Ki/gluesql path: /src/executor/context/mod.rs
mod aggregate_context;
mod blend_context;
mod filter_context;
mod union_con<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "TaKO8Ki/gluesql",
"path": "/src/executor/context/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TaKO8Ki/gluesql path: /src/executor/context/mod.rs
mod aggregate_context;
mod blend_context;
mod filter_context;
mod union_context;
pub use aggregate_context::AggregateContext;
pub use blend_context::{<|fim_suffix|>lterContextError};
pub use union_context::{UnionContext, UnionContextError};<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "TaKO8Ki/gluesql",
"path": "/src/executor/context/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eraden/roguelike-rust path: /src/game/map/tile_type.rs
use std::str::FromStr;
#[derive(Debug)]
pub enum TileTypeErr {
InvalidTileValue(String),
}
// 16x16
#[derive(Debug, Clone)]
pub enum TileType {
Empty,
//= ground
// 7x1
GrassSmallPlant1,
// 7x2
GrassSmallPlant2,... | code_fim | hard | {
"lang": "rust",
"repo": "Eraden/roguelike-rust",
"path": "/src/game/map/tile_type.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match contents {
// ground
"0" => Ok(TileType::Grass),
"1" => Ok(TileType::GrassSmallPlant1),
"2" => Ok(TileType::GrassSmallPlant2),
"3" => Ok(TileType::GrassSmallPlant3),
"4" => Ok(TileType::GrassSmallPlant4),
"5"... | code_fim | hard | {
"lang": "rust",
"repo": "Eraden/roguelike-rust",
"path": "/src/game/map/tile_type.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> "7" => Ok(TileType::PondLeftTop),
"8" => Ok(TileType::PondLeft),
"9" => Ok(TileType::PondLeftBottom),
"10" => Ok(TileType::PondBottom),
"11" => Ok(TileType::PondRightBottom),
"12" => Ok(TileType::PondRight),
"13" => Ok(Til... | code_fim | hard | {
"lang": "rust",
"repo": "Eraden/roguelike-rust",
"path": "/src/game/map/tile_type.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lain1936/ideo path: /src/gen/column.rs
#[allow(non_upper_case_globals)]
pub const bio: &'static str = "bio";
<|fim_suffix|>#[allow(non_upper_case_globals)]
pub const text: &'static str = "text";
#[allow(non_upper_case_globals)]
pub const title: &'static str = "title";
#[allow(non_upper_case_... | code_fim | hard | {
"lang": "rust",
"repo": "lain1936/ideo",
"path": "/src/gen/column.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(non_upper_case_globals)]
pub const user_id: &'static str = "user_id";<|fim_prefix|>// repo: lain1936/ideo path: /src/gen/column.rs
#[allow(non_upper_case_globals)]
pub const bio: &'static str = "bio";
#[allow(non_upper_case_globals)]
pub const body: &'static str = "body";
<|fim_middle|>#[allow... | code_fim | hard | {
"lang": "rust",
"repo": "lain1936/ideo",
"path": "/src/gen/column.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DiemoHeuer/rust-meetup-rostock path: /2021-11-02/demos/rayon-demo/src/serial.rs
use super::processing_data::ProcessingData;
use super::utils::*;
use std::ops::Range;
use std::time::Duration;
use std::time::Instant;
pub fn run(data: ProcessingData) {
println!("Started serial processin... | code_fim | hard | {
"lang": "rust",
"repo": "DiemoHeuer/rust-meetup-rostock",
"path": "/2021-11-02/demos/rayon-demo/src/serial.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn iter_any(source: Vec<i32>) -> Duration {
let instant = Instant::now();
let _result = source.into_iter().any(|number| is_odd(number));
instant.elapsed()
}
fn iter_all(source: Vec<i32>) -> Duration {
let instant = Instant::now();
let _result = source.into_iter().all(|number| ... | code_fim | hard | {
"lang": "rust",
"repo": "DiemoHeuer/rust-meetup-rostock",
"path": "/2021-11-02/demos/rayon-demo/src/serial.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SOF3/webcord path: /src/index/guilds.rs
use diesel::prelude::{ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl};
use webcord_schema::models;
use webcord_schema::schema::guilds::dsl as guilds;
use super::{Index, QueryError};
use crate::GuildId;
impl Index {
pub fn list_guilds(&se... | code_fim | hard | {
"lang": "rust",
"repo": "SOF3/webcord",
"path": "/src/index/guilds.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn guilds_new_join(&self, id: GuildId, name: &str) -> Result<(), QueryError> {
let row = guilds::guilds
.select(guilds::online)
.filter(guilds::id.eq(id.to_db()))
.first::<bool>(&self.0.get()?)
.optional()?;
match row {
So... | code_fim | hard | {
"lang": "rust",
"repo": "SOF3/webcord",
"path": "/src/index/guilds.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn unescape_char(input: Option<char>) -> Result<char, MalError> {
match input {
Some('n') => Ok('\n'),
Some(c) => Ok(c),
None => Err(MalError::unexpected_eof()),
}
}
fn read_keyword(reader: &mut Reader) -> MalResult {
let token = reader.next().unwrap();
Ok(MalType::Keyword(token[1..].... | code_fim | hard | {
"lang": "rust",
"repo": "tyler-goodwin/mal-rust",
"path": "/src/reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let list = read_inner_list(reader, '}')?;
Ok(MalType::HashMap(list))
}
fn read_string(reader: &mut Reader) -> MalResult {
let token = reader.next().unwrap();
let mut chars = token.chars();
if chars.next().unwrap() != '"' {
return Err(MalError::unknown());
}
let mut out = String::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "tyler-goodwin/mal-rust",
"path": "/src/reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyler-goodwin/mal-rust path: /src/reader.rs
extern crate regex;
use regex::Regex;
use crate::types::*;
const TOKEN_PATTERN: &str =
r#"[\s,]*(~@|[\[\]{}()'`~^@]|"(?:\\.|[^\\"])*"|;.*|[^\s\[\]{}('"`,;)]*)"#;
const NUMBER_PATTERN: &str = r#"^\-?[\d\.]+$"#;
pub fn read_str(input: String) -> Ma... | code_fim | hard | {
"lang": "rust",
"repo": "tyler-goodwin/mal-rust",
"path": "/src/reader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn as_string(&self) -> String {
match &self {
Value::ObjValue(obj) => {
match **obj {
LoxObject::String(ref s) => s.to_string(),
// _ => panic!("Object is not a String"),
}
},
_ => p... | code_fim | hard | {
"lang": "rust",
"repo": "adamreeve/rlox",
"path": "/src/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adamreeve/rlox path: /src/value.rs
use std::fmt;
use std::rc::Rc;
use ::object::{LoxObject};
#[derive(Debug,Clone)]
pub enum Value {
NilValue,
BoolValue(bool),
NumberValue(f64),
ObjValue(Rc<LoxObject>)
}
impl Value {
pub fn nil() -> Value {
Value::NilValue
}
... | code_fim | hard | {
"lang": "rust",
"repo": "adamreeve/rlox",
"path": "/src/value.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self {
&Value::NilValue => write!(f, "Nil"),
&Value::BoolValue(val) => write!(f, "Bool({})", val),
&Value::NumberValue(val) => write!(f, "Number({})", val),
... | code_fim | hard | {
"lang": "rust",
"repo": "adamreeve/rlox",
"path": "/src/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl traits::ReadChannel for SpramFrom {}
impl traits::Address for SpramTo {
const CONTROL: *mut usize = 0x1000_d400 as *mut usize;
const ADDRESS: *mut usize = 0x1000_d410 as *mut usize;
const COUNT: *mut usize = 0x1000_d420 as *mut usize;
}
impl traits::WriteChannel for SpramTo {}<|fim_pref... | code_fim | hard | {
"lang": "rust",
"repo": "Ravenslofty/prussia",
"path": "/prussia_dma/src/devices/spram.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ravenslofty/prussia path: /prussia_dma/src/devices/spram.rs
use crate::devices::traits;
/// Scratchpad RAM, for fast data reads.
pub struct SpramFrom;
/// Scratchpad RAM, for fast data writes.
pub struct SpramTo;
<|fim_suffix|>impl traits::ReadChannel for SpramFrom {}
impl traits::Address for... | code_fim | hard | {
"lang": "rust",
"repo": "Ravenslofty/prussia",
"path": "/prussia_dma/src/devices/spram.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn render(&self, renderer: &mut Renderer) -> () {
renderer.set_draw_color(self.color);
match renderer.fill_rect(self.rect) {
Ok(..) => (),
Err(e) => println!("Error rendering game_rect: {}", e),
}
}
}<|fim_prefix|>// repo: jamiltron/boxes_catchin... | code_fim | hard | {
"lang": "rust",
"repo": "jamiltron/boxes_catching_boxes",
"path": "/src/entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamiltron/boxes_catching_boxes path: /src/entity.rs
use sdl2::pixels::Color;
use sdl2::rect::Rect;
use sdl2::render::Renderer;
<|fim_suffix|> pub fn render(&self, renderer: &mut Renderer) -> () {
renderer.set_draw_color(self.color);
match renderer.fill_rect(self.rect) {
... | code_fim | hard | {
"lang": "rust",
"repo": "jamiltron/boxes_catching_boxes",
"path": "/src/entity.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Entity {
pub fn new(x: i32, y: i32, width: u32, height: u32, color: Color) -> Self {
Entity {
rect: Rect::new(x, y, width, height),
color: color,
}
}
pub fn render(&self, renderer: &mut Renderer) -> () {
renderer.set_draw_color(self.color);... | code_fim | medium | {
"lang": "rust",
"repo": "jamiltron/boxes_catching_boxes",
"path": "/src/entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tckz/cw-metrics path: /src/main.rs
#[macro_use]
extern crate clap;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate rusoto_cloudwatch;
extern crate rusoto_core;
use clap::{App, Arg, SubCommand};
use rusoto_cloudwatch::{
CloudWatch, CloudWatch... | code_fim | hard | {
"lang": "rust",
"repo": "tckz/cw-metrics",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("next={:?}", out.next_token);
if let Some(next) = out.next_token {
let mut next_req: ListMetricsInput = Default::default();
next_req.next_token = Some(next);
return list_metrics(client, next_req);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "tckz/cw-metrics",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nolanderc/snow-fight path: /logic/src/systems/attack.rs
use legion::prelude::*;
use protocol::EntityId;
use crate::components::{CollisionListener, Projectile, Health};
use crate::resources::DeadEntities;
use crate::System;
/// Apply damage when a projectile hits another entity.
pub fn system(... | code_fim | hard | {
"lang": "rust",
"repo": "nolanderc/snow-fight",
"path": "/logic/src/systems/attack.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (entity, (listener, projectile)) in query.iter_entities_immutable(world) {
for collision in listener.collisions.iter() {
damage.push((collision.entity, projectile.damage));
cmd.delete(entity);
deleted.push(entity);... | code_fim | hard | {
"lang": "rust",
"repo": "nolanderc/snow-fight",
"path": "/logic/src/systems/attack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for entity in deleted {
if let Some(id) = world.get_component::<EntityId>(entity) {
dead.entities.push(*id);
}
}
})
}<|fim_prefix|>// repo: nolanderc/snow-fight path: /logic/src/systems/attack.rs
use legion::prelude::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "nolanderc/snow-fight",
"path": "/logic/src/systems/attack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dicksontung/redis-ws-rs path: /src/main.rs
use std::sync::Arc;
use dashmap::mapref::one::Ref;
use dashmap::DashMap;
use futures::executor::block_on;
use futures::stream::SplitSink;
use futures::{SinkExt, StreamExt};
use log::{debug, info};
use std::collections::HashSet;
use std::vec::Vec;
use t... | code_fim | hard | {
"lang": "rust",
"repo": "dicksontung/redis-ws-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::main]
async fn main() {
let mut settings = Config::default();
settings
.merge(config::File::with_name("config/config.yaml"))
.unwrap()
.merge(config::Environment::with_prefix("SOCKET"))
.unwrap();
let refm = Arc::new(ReferenceMaps::new());
let redis... | code_fim | hard | {
"lang": "rust",
"repo": "dicksontung/redis-ws-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: softiger/datafuse path: /common/datablocks/src/lib.rs
// Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
<|fim_suffix|>mod data_block;
pub use crate::data_block::DataBlock;<|fim_middle|>#[cfg(test)]
mod data_block_test;
| code_fim | easy | {
"lang": "rust",
"repo": "softiger/datafuse",
"path": "/common/datablocks/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use crate::data_block::DataBlock;<|fim_prefix|>// repo: softiger/datafuse path: /common/datablocks/src/lib.rs
// Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
<|fim_middle|>#[cfg(test)]
mod data_block_test;
mod data_block;
| code_fim | easy | {
"lang": "rust",
"repo": "softiger/datafuse",
"path": "/common/datablocks/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redox-os/orbtk path: /orbtk_orbclient/src/web/mod.rs
//! This module contains a platform specific implementation of the window shell.
use std::sync::mpsc;
use stdweb::web::window;
use crate::prelude::*;
use self::states::*;
pub use self::window::*;
pub use self::window_builder::*;
mod states;... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/orbtk",
"path": "/orbtk_orbclient/src/web/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if remove {
self.window_shells.remove(i);
break;
}
}
self.receive_requests();
self.run();
});
}
}
lazy_static! {
pub static ref CONSOLE: Console = Console;
}
pub struct Console;
... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/orbtk",
"path": "/orbtk_orbclient/src/web/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Configuration type for transition sequence name.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, new)]
#[serde(deny_unknown_fields)]
pub struct InputReactionSingle<SeqName, IRR>
where
SeqName: SequenceName,
{
/// Sequence name to transition to.
pub next: SequenceNameString<SeqNam... | code_fim | medium | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/input_reaction_model/src/config/input_reaction_single.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/input_reaction_model/src/config/input_reaction_single.rs
use derive_new::new;
use sequence_model::config::{SequenceName, SequenceNameString};
use serde::{Deserialize, Serialize};
<|fim_suffix|>/// Configuration type for transition sequence name.
#[derive(Clone... | code_fim | medium | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/input_reaction_model/src/config/input_reaction_single.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return common::types::Ohlc {
time: self.time as _,
open: self.open,
high: self.high,
low: self.low,
close: self.close,
vol: self.vol,
};
}
}
impl Ohlc {
pub fn new(pair_id: i32, ohlc: common::types::Ohlc) -> S... | code_fim | hard | {
"lang": "rust",
"repo": "daCapricorn/cryptrader",
"path": "/code/deps/db/src/schema/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daCapricorn/cryptrader path: /code/deps/db/src/schema/mod.rs
use super::*;
use ::std::result::Result as Result;
use uuid::Uuid;
use common::types::Exchange;
table! {
assignments (pair_id, user_id) {
pair_id -> Int4,
user_id -> Int4,
period -> Text,
strategy_i... | code_fim | hard | {
"lang": "rust",
"repo": "daCapricorn/cryptrader",
"path": "/code/deps/db/src/schema/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, PartialOrd, PartialEq, Serialize, Deserialize)]
#[derive(Identifiable, Queryable, Insertable, AsChangeset, Associations, QueryableByName)]
#[table_name = "evaluations"]
#[primary_key(id)]
#[belongs_to(User, foreign_key = "user_id")]
#[belongs_to(Strategy, foreign_key = "strategy_id"... | code_fim | hard | {
"lang": "rust",
"repo": "daCapricorn/cryptrader",
"path": "/code/deps/db/src/schema/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adowsky/rocket-microservice-template path: /src/my_domain/config.rs
use serde::Deserialize;
<|fim_suffix|>}
#[derive(Deserialize)]
pub(crate) struct MyDomainConfig {
pub(crate) my_domain: MyDomainProperties
}<|fim_middle|>#[derive(Deserialize)]
pub(crate) struct MyDomainProperties {
pu... | code_fim | medium | {
"lang": "rust",
"repo": "adowsky/rocket-microservice-template",
"path": "/src/my_domain/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize)]
pub(crate) struct MyDomainConfig {
pub(crate) my_domain: MyDomainProperties
}<|fim_prefix|>// repo: adowsky/rocket-microservice-template path: /src/my_domain/config.rs
use serde::Deserialize;
<|fim_middle|>#[derive(Deserialize)]
pub(crate) struct MyDomainProperties {
pub g... | code_fim | medium | {
"lang": "rust",
"repo": "adowsky/rocket-microservice-template",
"path": "/src/my_domain/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hdhoang/anne-key path: /src/usb/descriptors.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
pub const DEV_DESC: [u8; 18] = [
0x12, // bLength
0x01, // bDescriptorType (Device)
0x00, 0x02, // bcdUSB 2.00
0x00, // bDeviceClass (Use class information in the Interface D... | code_fim | hard | {
"lang": "rust",
"repo": "hdhoang/anne-key",
"path": "/src/usb/descriptors.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const LANG_STR: [u8; 4] = [
0x04, 0x03, //
0x09, 0x04, // English - US
];
pub const MANUFACTURER_STR: [u8; 38] = [
0x26, 0x03, //
0x52, 0x00, // R
0x75, 0x00, // u
0x73, 0x00, // s
0x74, 0x00, // t
0x79, 0x00, // y
0x20, 0x00, //
0x4d, 0x00, // M
0x61, 0x... | code_fim | hard | {
"lang": "rust",
"repo": "hdhoang/anne-key",
"path": "/src/usb/descriptors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liamdawson/hubauth path: /ssh_authorized_keys/src/algs.rs
// haven't used these yet, but want to record them
#![allow(dead_code)]
// https://tools.ietf.org/html/rfc4253#section-6.6
// these don't all seem to be in standards, I may have missed some
<|fim_suffix|>const VALID_ALGS: &[&str] = &[
... | code_fim | hard | {
"lang": "rust",
"repo": "liamdawson/hubauth",
"path": "/ssh_authorized_keys/src/algs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>const VALID_ALGS: &[&str] = &[
SSH_DSA,
SSH_RSA,
SSH_ED25519,
SSH_ECDSA_SHA2_NISTP256,
SSH_ECDSA_SHA2_NISTP384,
SSH_ECDSA_SHA2_NISTP521,
PGP_SIGN_DSA,
PGP_SIGN_RSA,
];<|fim_prefix|>// repo: liamdawson/hubauth path: /ssh_authorized_keys/src/algs.rs
// haven't used these yet... | code_fim | hard | {
"lang": "rust",
"repo": "liamdawson/hubauth",
"path": "/ssh_authorized_keys/src/algs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vatyx/idk path: /cli/src/main.rs
use clap::{App, Arg};
use clipboard::ClipboardProvider;
use clipboard::ClipboardContext;
use std::fs;
use std::io::Write;
use std::process::Command;
use std::path::PathBuf;
mod idkrequest;
mod authserver;
const CONFIG_FILE: &str = "idk.config";
const LOGIN_PAG... | code_fim | hard | {
"lang": "rust",
"repo": "Vatyx/idk",
"path": "/cli/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> save_config(&token);
println!("Successfully logged in! Try asking for a command.");
return token;
}
fn main() {
let matches = App::new("idk cli")
.version("1.0")
.about("Generate commands you don't know.")
.arg(Arg:... | code_fim | hard | {
"lang": "rust",
"repo": "Vatyx/idk",
"path": "/cli/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((conn, version, krate))
}
fn extract_crate_name(req: &dyn RequestExt) -> &str {
&req.params()["crate_id"]
}
fn extract_semver(req: &dyn RequestExt) -> AppResult<&str> {
let semver = &req.params()["version"];
if semver::Version::parse(semver).is_err() {
return Err(cargo_err(&fo... | code_fim | medium | {
"lang": "rust",
"repo": "andrew-johnson-4/crates.io",
"path": "/src/controllers/version.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrew-johnson-4/crates.io path: /src/controllers/version.rs
pub mod deprecated;
pub mod downloads;
pub mod metadata;
pub mod yank;
use super::prelude::*;
use crate::db::DieselPooledConn;
use crate::models::{Crate, Version};
fn version_and_crate(req: &dyn RequestExt) -> AppResult<(DieselPoole... | code_fim | medium | {
"lang": "rust",
"repo": "andrew-johnson-4/crates.io",
"path": "/src/controllers/version.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/dotao path: /tsml/src/serializer.rs
use crate::{FileTree, Groups, Tags, TsmlError, TsmlResult};
// TODO: preserve comments, somehow
// TODO: fix order
// TODO: preserve order of values (iter.rs)
// Where T is whatever it wants to be
pub fn groups_to_tsml(groups: &Groups) -> TsmlResult<... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/dotao",
"path": "/tsml/src/serializer.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file: &FileTree = file;
text.push_str(
format!("\"{}\"", file.path().file_name().expect("unexpected").to_str().expect(""))
.as_str(),
);
// Draw regular file
match file {
FileTree::Regular ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/dotao",
"path": "/tsml/src/serializer.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if key != "main" {
text.push_str(format!("- [{}]\n", key.trim_end_matches('/')).as_str());
}
let mut last_depth = 0;
for file_tree in files.iter() {
// For each file inside of this bad boi
let mut file_iter = file_tree.files();
while let Some(file) = file_i... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/dotao",
"path": "/tsml/src/serializer.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-sql-processor/src/ast_translator/column_name.rs
use apllodb_shared_components::ApllodbResult;
use apllodb_sql_parser::apllodb_ast;
use apllodb_storage_engine_interface::ColumnName;
<|fim_suffix|>impl AstTranslator {
pub fn column_name(ast_column_name: apllodb_... | code_fim | easy | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-sql-processor/src/ast_translator/column_name.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AstTranslator {
pub fn column_name(ast_column_name: apllodb_ast::ColumnName) -> ApllodbResult<ColumnName> {
ColumnName::new(ast_column_name.0 .0)
}
}<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-sql-processor/src/ast_translator/column_name.rs
use apllodb_shared_components::Ap... | code_fim | easy | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-sql-processor/src/ast_translator/column_name.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ast_file.read_to_string(&mut code).expect("Unable to read file");
let blk = ast::Block::from_json(code).unwrap();
gen_and_run(blk);
}<|fim_prefix|>// repo: losfair/luax-bin path: /src/main.rs
#![feature(nll)]
extern crate luax;
use std::io::Read;
use std::fs::File;
use std::panic::{catch_un... | code_fim | medium | {
"lang": "rust",
"repo": "losfair/luax-bin",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: losfair/luax-bin path: /src/main.rs
#![feature(nll)]
extern crate luax;
use std::io::Read;
use std::fs::File;
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
use luax::{ast, codegen, vm, runtime};
use vm::executor::ExecutorImpl;
use vm::errors::VMError;
fn gen_and_run(ast: ast... | code_fim | hard | {
"lang": "rust",
"repo": "losfair/luax-bin",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cr1901/msp430f5529 path: /src/port_7_8/p7sel.rs
#[doc = "Register `P7SEL` reader"]
pub struct R(crate::R<P7SEL_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<P7SEL_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<P7S... | code_fim | hard | {
"lang": "rust",
"repo": "cr1901/msp430f5529",
"path": "/src/port_7_8/p7sel.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `P7SEL7` writer - P7SEL7"]
pub struct P7SEL7_W<'a> {
w: &'a mut W,
}
impl<'a> P7SEL7_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[i... | code_fim | hard | {
"lang": "rust",
"repo": "cr1901/msp430f5529",
"path": "/src/port_7_8/p7sel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fomys/rustracer path: /src/raytracer/lights/spot.rs
use crate::raytracer::color::{Color, BLACK};
use crate::raytracer::lights::light::Light;
use crate::raytracer::utils::Vec3;
<|fim_suffix|> if ((self.direction | direction) / direction.length())
.acos()
.abs()
... | code_fim | hard | {
"lang": "rust",
"repo": "Fomys/rustracer",
"path": "/src/raytracer/lights/spot.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![self.position]
}
fn get_color(&self, direction: Vec3) -> Color {
if ((self.direction | direction) / direction.length())
.acos()
.abs()
> self.angle
{
BLACK
} else {
self.color_power / (0.7 * direction.... | code_fim | medium | {
"lang": "rust",
"repo": "Fomys/rustracer",
"path": "/src/raytracer/lights/spot.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pub fn read_byte(&self) -> u8 {
// while self.rx.len() == 0 {
// wfi()
// }
// self.rx.dequeue().unwrap()
// }
// pub fn action(&self) -> Option<SpiAction> {
// self.action.get()
// }
// pub fn reg_read(&self, pin: u8, reg: u8) -> u8 {... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-kinetis/kinetis-common/src/ext/spi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu/bobbin-kinetis/kinetis-common/src/ext/spi.rs
pub use bobbin_common::configure::*;
pub use bobbin_common::enabled::*;
pub use bobbin_hal::spi::*;
// use bobbin_sys::ring::Ring;
// use bobbin_common::{Irq, Poll};
// use bobbin_hal::digital::DigitalOutput;
// use bo... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-kinetis/kinetis-common/src/ext/spi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let wrapped_config = KeybindingsConfig::new("keybindings_config.yaml");
assert!(wrapped_config.is_ok());
let config = wrapped_config.unwrap();
assert_eq!(config.get("key1"), Some(String::from("value1")));
assert_eq!(config.get("key2"), Some(String::from("value2")));... | code_fim | hard | {
"lang": "rust",
"repo": "torch-rs/config",
"path": "/src/keybindings_config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.data = new_data;
}
fn save(&self) -> Result<(), Error> {
let serialized = serde_yaml::to_string(&self.data)
.map_err(|_e| Error::new(ErrorKind::Other, "Trouble serializing"))?;
let mut file = File::create(self.filename.clone())?;
file.lock_excl... | code_fim | hard | {
"lang": "rust",
"repo": "torch-rs/config",
"path": "/src/keybindings_config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: torch-rs/config path: /src/keybindings_config.rs
extern crate fs2;
extern crate serde;
extern crate serde_yaml;
use self::fs2::FileExt;
use Config;
use std::collections::HashMap;
use std::fs::File;
use std::io::{Error, ErrorKind, Read, Write};
pub struct KeybindingsConfig<'c> {
filename: &... | code_fim | hard | {
"lang": "rust",
"repo": "torch-rs/config",
"path": "/src/keybindings_config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let impl_user_service = ImplUserService::default();
print!("--> Started on ");
println!("http://{}", addr);
Server::builder()
.add_service(health_service)
.add_service(UserServiceServer::new(impl_user_service))
.serve(addr)
.await?;
Ok(())
}<|fim_pref... | code_fim | medium | {
"lang": "rust",
"repo": "slackmagic/helix-user-app",
"path": "/bin/helix-user-grpc/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print!("--> Started on ");
println!("http://{}", addr);
Server::builder()
.add_service(health_service)
.add_service(UserServiceServer::new(impl_user_service))
.serve(addr)
.await?;
Ok(())
}<|fim_prefix|>// repo: slackmagic/helix-user-app path: /bin/helix-... | code_fim | medium | {
"lang": "rust",
"repo": "slackmagic/helix-user-app",
"path": "/bin/helix-user-grpc/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slackmagic/helix-user-app path: /bin/helix-user-grpc/src/main.rs
use crate::controller::business_controller::ImplUserService;
use crate::controller::user_service_server::UserServiceServer;
use tonic::transport::Server;
pub mod controller;
const APP_NAME: &str = "USER_APP";
<|fim_suffix|> l... | code_fim | hard | {
"lang": "rust",
"repo": "slackmagic/helix-user-app",
"path": "/bin/helix-user-grpc/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> RSAError::RandomGenError(e)
}
}
impl From<ASN1DecodeErr> for RSAError {
fn from(e: ASN1DecodeErr) -> RSAError {
RSAError::ASN1DecodeErr(e)
}
}<|fim_prefix|>// repo: iCodeIN/simple_crypto path: /src/rsa/errors.rs
use simple_asn1::ASN1DecodeErr;
use rand;
/// A bunch of errors... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/simple_crypto",
"path": "/src/rsa/errors.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/simple_crypto path: /src/rsa/errors.rs
use simple_asn1::ASN1DecodeErr;
use rand;
/// A bunch of errors that you can get generating, reading, or
/// writing RSA keys.
#[derive(Debug)]
pub enum RSAError {
BadMessageSize,
KeyTooSmallForHash,
DecryptionError,
DecryptHashMism... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/simple_crypto",
"path": "/src/rsa/errors.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config_string = toml::to_string(&config).expect("Convert config to TOML.");
let mut file = File::create(output_path).expect("Should create config file.");
file.write_all(&config_string.as_bytes())
.expect("Should write config to file.");
}
fn prompt(text: &str, default_value: Opt... | code_fim | hard | {
"lang": "rust",
"repo": "ondrowan/dgraph-cli",
"path": "/src/commands/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if default_value.is_some() {
print!(
"{} ({}): ",
text,
default_value.expect("default_value to be present.")
);
} else {
print!("{}: ", text);
}
stdout().flush().expect("Should flush stdout.");
let mut value = String::new();... | code_fim | hard | {
"lang": "rust",
"repo": "ondrowan/dgraph-cli",
"path": "/src/commands/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ondrowan/dgraph-cli path: /src/commands/config.rs
use std::fs::File;
use std::io::{stdin, stdout, Write};
use std::path::Path;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct Config {
url: String,
root_ca_path: Option<String>,
cert_path: Option<String>... | code_fim | hard | {
"lang": "rust",
"repo": "ondrowan/dgraph-cli",
"path": "/src/commands/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atimos/deploy path: /cli/src/print.rs
use pipeline::{data::Template, Command, ExecutionMode, InstanceId, Location, Node};
pub fn verbose(pipeline: &pipeline::Node) {
dbg!(pipeline);
}
pub fn pretty(pipeline: &Node, indentation: String) {
match pipeline {
pipeline::Node::Nodes { ... | code_fim | hard | {
"lang": "rust",
"repo": "atimos/deploy",
"path": "/cli/src/print.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_commands(
description: &Option<Template>,
location: &Location,
cmds: &[Command],
id: &InstanceId,
indentation: String,
) {
print!("{}", indentation);
match location {
pipeline::Location::Oci { repository, image } => {
print!("Oci(");
if ... | code_fim | hard | {
"lang": "rust",
"repo": "atimos/deploy",
"path": "/cli/src/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> description: &Option<Template>,
nodes: &[Node],
mode: &ExecutionMode,
indentation: String,
) {
print!("{}{:?}(", indentation, mode);
if let Some(description) = description {
print!("\"{}\" ", description);
}
println!("[");
for node in nodes {
pretty(node... | code_fim | medium | {
"lang": "rust",
"repo": "atimos/deploy",
"path": "/cli/src/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vix993/algorithms_in_rust path: /tests/sort_tests.rs
#[cfg(test)]
mod sort_tests {
use algorithms_in_rust::sort::bubble_sort_recursive;
#[test]
fn test_bubble_sort_recursive() {
let mut test_small_sample_middle: Vec<i32> = vec![1, 3, 2, 4, 5];
let sample_middle_size: usize ... | code_fim | hard | {
"lang": "rust",
"repo": "vix993/algorithms_in_rust",
"path": "/tests/sort_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(bubble_sort_recursive(&mut test_small_sample_front, sample_front_size), &small_sample_front_expected);
let mut test_mid_random_sample: Vec<i32> = vec![100, 22, 5, 65, 87, 45, 39, 101, 27, 27, 65, 89];
let sample_mid_random_size: usize = test_mid_random_sample.len();
let mut test_mid... | code_fim | hard | {
"lang": "rust",
"repo": "vix993/algorithms_in_rust",
"path": "/tests/sort_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use token::simple_name;
use scanner::name;
#[test]
fn resolves_top_level_names() {
assert_eq!(resolve(&simple_name("ape"), 3), syn::Ident::new("_s0.ape"));
}
#[test]
fn resolves_nested_names() {
assert_eq!(resolve(&na... | code_fim | hard | {
"lang": "rust",
"repo": "nkoehring/bart",
"path": "/libs/bart_derive/src/generator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nkoehring/bart path: /libs/bart_derive/src/generator.rs
use ast;
use itertools;
use syn;
use token;
use quote;
pub trait PartialsResolver {
fn generate_partial(&mut self, partial_name: &str) -> quote::Tokens;
}
fn resolve(name: &token::Name, scope_depth: u32) -> syn::Ident {
use iterto... | code_fim | hard | {
"lang": "rust",
"repo": "nkoehring/bart",
"path": "/libs/bart_derive/src/generator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn scope(name: token::Name, scope_level: u32, ast: ast::Ast, partials_resolver: &mut PartialsResolver)
-> (syn::Ident, syn::Ident, quote::Tokens)
{
let name = resolve(&name, scope_level);
let scope_variable = syn::Ident::new(format!("_s{}", scope_level));
let nested_generated = generate(as... | code_fim | hard | {
"lang": "rust",
"repo": "nkoehring/bart",
"path": "/libs/bart_derive/src/generator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Registers breakpoints against a set of EventTypes.
pub async fn register(&self, event_types: Vec<EventType>) -> BreakpointInvocationReceiver {
let (tx, rx) = mpsc::channel(0);
let sender = BreakpointInvocationSender::new(tx);
let receiver = BreakpointInvocationReceiver:... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/sys/component_manager/src/model/testing/breakpoints.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: winksaville/fuchsia path: /src/sys/component_manager/src/model/testing/breakpoints.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::model::*,
futures::{chan... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/sys/component_manager/src/model/testing/breakpoints.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // If this EventType has senders installed against it, then
// send this event via those senders.
if let Some(senders) = sender_map.get(&event.type_()) {
let mut responder_channels = vec![];
for sender in senders {
let responder_channel = sen... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/sys/component_manager/src/model/testing/breakpoints.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hyrasso/rust-advent-2019 path: /src/solutions/advent2.rs
use std::fs;
use crate::solutions::Solution;
pub struct Day2 {}
fn run(text: String, noun: i32, verb: i32) -> i32 {
let mut program: Vec<_> = text.split(",").map(|s| s.parse::<i32>().unwrap()).collect();
program[1] = noun;
pr... | code_fim | medium | {
"lang": "rust",
"repo": "Hyrasso/rust-advent-2019",
"path": "/src/solutions/advent2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let text = fs::read_to_string("inputs/2-1.txt").expect("Error while opening input");
// let res = run(text, 12, 2);
// println!("{}", res);
let target = 19690720;
for noun in 0..100 {
for verb in 0..100 {
let res = run(text.clone(), noun,... | code_fim | medium | {
"lang": "rust",
"repo": "Hyrasso/rust-advent-2019",
"path": "/src/solutions/advent2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unimplemented!()
}
fn resume_mutators(_tls: OpaquePointer) {
unimplemented!()
}
fn block_for_gc(_tls: OpaquePointer) {
unimplemented!();
}
fn spawn_worker_thread(_tls: OpaquePointer, _ctx: Option<&Worker<MMTK<DummyVM>>>) {
unimplemented!();
}
... | code_fim | medium | {
"lang": "rust",
"repo": "wangbrenda/mmtk-core",
"path": "/vmbindings/dummyvm/src/collection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wangbrenda/mmtk-core path: /vmbindings/dummyvm/src/collection.rs
use mmtk::vm::Collection;
use mmtk::MutatorContext;
use mmtk::util::OpaquePointer;
use mmtk::MMTK;
use mmtk::scheduler::*;
use mmtk::scheduler::gc_work::*;
use DummyVM;
pub struct VMCollection {}
<|fim_suffix|> unimplement... | code_fim | hard | {
"lang": "rust",
"repo": "wangbrenda/mmtk-core",
"path": "/vmbindings/dummyvm/src/collection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Ensure we can find nodes at all inserted paths
if node_specs.iter().any(|&(ref path, ty)| tree.find(&path.0, ty).is_err()) {
return false;
}
// Ensure we can walk all inserted paths using a PathIter
let paths = node_specs.iter... | code_fim | hard | {
"lang": "rust",
"repo": "justinsheehy/vertree",
"path": "/src/iterators.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justinsheehy/vertree path: /src/iterators.rs
use std::sync::Arc;
use tree::Tree;
use node::{Node, Content};
use errors::{Result, ErrorKind};
use containers::Container;
/// Deep clone a node and bump it's version
pub fn cow_node(node: &Arc<Node>) -> Arc<Node> {
// Create a shallow copy of th... | code_fim | hard | {
"lang": "rust",
"repo": "justinsheehy/vertree",
"path": "/src/iterators.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut emissions = Histogram::<u64>::new(3).unwrap();
for m in self.moers() {
if intervals.iter().any(|range| range.contains(&m.start)) {
let rate = (m.rate * 1000.) as u64;
emissions.record(rate).unwrap();
}
}
emis... | code_fim | medium | {
"lang": "rust",
"repo": "hdevalence/sgip-ev-charging",
"path": "/src/forecast_ext.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hdevalence/sgip-ev-charging path: /src/forecast_ext.rs
use std::ops::Range;
use chrono::{DateTime, Utc};
use hdrhistogram::Histogram;
use sgip_signal::Forecast;
<|fim_suffix|>}
impl ForecastExt for Forecast {
fn histogram_over(&self, intervals: Vec<Range<DateTime<Utc>>>) -> Histogram<u64>... | code_fim | medium | {
"lang": "rust",
"repo": "hdevalence/sgip-ev-charging",
"path": "/src/forecast_ext.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> isolate.exec(move |context| {
let scope = ContextScope::New(context);
let source = V8String::New(r#"
"Hello, " + "World!"
"#);
let mut script = V8Script::New(context, source)?;
let result: String = script.run(context)?.into();
println... | code_fim | medium | {
"lang": "rust",
"repo": "uuhan/rvb",
"path": "/examples/hello-world.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uuhan/rvb path: /examples/hello-world.rs
#![allow(unused)]
extern crate rvb;
use rvb::v8::prelude::*;
use rvb::v8::{
self,
Platform,
Isolate,
HandleScope,
Context,
ContextScope,
Script,
};
<|fim_suffix|> isolate.exec(move |context| {
let scope = ContextSco... | code_fim | medium | {
"lang": "rust",
"repo": "uuhan/rvb",
"path": "/examples/hello-world.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.