text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: glugg23/rox path: /tests/misc.rs
use std::process::Command;
use std::str;
#[test]
fn empty_file() {
let result = Command::new("cargo")
.args(&[
"run",
"-q",
"--release",
"--",
"tests/resources/empty_file.lox",
])
... | code_fim | hard | {
"lang": "rust",
"repo": "glugg23/rox",
"path": "/tests/misc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //TODO: Fix this test once LeftParen has a precedence of Call
assert_eq!(
str::from_utf8(&result.stderr).unwrap(),
"[line 3] Error at '(': Expect ';' after expression.\n[line 3] Error at '|': Unexpected character.\n"
);
assert_eq!(result.status.code().unwrap(), 65);
}<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "glugg23/rox",
"path": "/tests/misc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> desc.node.as_ref().map(|nodes| {
nodes.iter().for_each(|n| {
node_id_gen_file.write_all(n.gen_id().as_bytes()).unwrap();
node_desc_gen_file
.write_all(n.gen_desc().as_bytes())
.unwrap();
})
});
node_desc_gen_file
... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/home-network-old",
"path": "/param-desc/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = match value_type {
ParameterValueTypeId::None => String::from("ParameterValue::None"),
ParameterValueTypeId::Notification => String::from("ParameterValue::Notification"),
ParameterValueTypeId::Bool => String::from(format!(
"ParameterV... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/home-network-old",
"path": "/param-desc/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonlamb-gh/home-network-old path: /param-desc/build.rs
use params::ParameterValueTypeId;
use serde_derive::Deserialize;
use std::collections::HashSet;
use std::fs::File;
use std::hash::Hash;
use std::io::prelude::*;
use std::path::Path;
use std::str::FromStr;
// TODO
// - sanity check unique ID... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/home-network-old",
"path": "/param-desc/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let opt = Opt::from_args();
let rom = fs::read(opt.file)?;
let mut i = 0;
while i < rom.len() {
let (cnt, inst) = i8085::Instruction::decode_one(&rom[i..]);
if !opt.raw {
println!("${:04x} {:x?} {}", i, &rom[i..i+cnt], inst.raw_asm());
} else {... | code_fim | medium | {
"lang": "rust",
"repo": "barzamin/ripntear",
"path": "/src/bin/disasm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: barzamin/ripntear path: /src/bin/disasm.rs
use std::fs;
use anyhow::Result;
use ripntear::i8085;
use structopt::StructOpt;
use std::path::PathBuf;
<|fim_suffix|>fn main() -> Result<()> {
let opt = Opt::from_args();
let rom = fs::read(opt.file)?;
let mut i = 0;
while i < rom.len() {... | code_fim | medium | {
"lang": "rust",
"repo": "barzamin/ripntear",
"path": "/src/bin/disasm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: carbotaniuman/vision_manager path: /src/pipeline/toposort.rs
use std::{
collections::{HashMap, HashSet, VecDeque},
fmt,
};
use uuid::Uuid;
pub struct CircularDependancyError;
impl fmt::Debug for CircularDependancyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
... | code_fim | medium | {
"lang": "rust",
"repo": "carbotaniuman/vision_manager",
"path": "/src/pipeline/toposort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ret: Vec<Uuid> = Vec::new();
while let Some(node) = deque.pop_front() {
ret.push(node);
for adj_node in input[&node].iter() {
*in_degree.entry(*adj_node).or_insert(0) -= 1;
if in_degree[adj_node] == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "carbotaniuman/vision_manager",
"path": "/src/pipeline/toposort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: veeg/disir-c-frontend-rs path: /c/src/lib.rs
extern crate libc;
use std::mem;
use std::ptr;
// We are not exporting the C interface to the crate.
mod c;
use c::{DisirInstance, disir_instance_create, disir_instance_destroy};
// Define the public disir instace object
pub struct Instance {
op... | code_fim | hard | {
"lang": "rust",
"repo": "veeg/disir-c-frontend-rs",
"path": "/c/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_creates_and_destroys () {
let mut inst : Instance = Default::default();
inst.create();
inst.destroy();
}
}<|fim_prefix|>// repo: veeg/disir-c-frontend-rs path: /c/src/lib.rs
extern crate libc;
use std::mem;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "veeg/disir-c-frontend-rs",
"path": "/c/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: orzogc/acfunliveapi path: /api/src/rest.rs
use crate::{client::ApiClient, response::*, Error, Result};
use async_trait::async_trait;
#[async_trait]
pub trait Rest: Sized {
async fn request<C>(client: &ApiClient<C>) -> Result<Self>
where
C: pretend::client::Client + Send + Sync;
... | code_fim | hard | {
"lang": "rust",
"repo": "orzogc/acfunliveapi",
"path": "/api/src/rest.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl Rest for UserLiveInfo {
#[inline]
async fn request<C>(client: &ApiClient<C>) -> Result<Self>
where
C: pretend::client::Client + Send + Sync,
{
match client.liver_uid() {
Some(liver_uid) => client.get_user_live_info(liver_uid).await,
... | code_fim | hard | {
"lang": "rust",
"repo": "orzogc/acfunliveapi",
"path": "/api/src/rest.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn offset(mut self, dx: f32, dy: f32) -> Self {
self.x1 += dx;
self.y1 += dy;
self.x2 += dx;
self.y2 += dy;
self
}
}
/// `<path d="..." />`
#[derive(Clone, PartialEq)]
pub struct Path {
pub ops: Vec<PathOp>,
pub style: Style,
}
/// `M {} {} L {... | code_fim | hard | {
"lang": "rust",
"repo": "nical/rust_debug",
"path": "/svg_fmt/src/svg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nical/rust_debug path: /svg_fmt/src/svg.rs
use std::fmt;
/// `rgb({r},{g},{b})`
#[derive(Copy, Clone, PartialEq)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
}
impl fmt::Display for Color {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "rgb({}... | code_fim | hard | {
"lang": "rust",
"repo": "nical/rust_debug",
"path": "/svg_fmt/src/svg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Polygon {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, r#"<path d=""#)?;
if self.points.len() > 0 {
write!(f, "M {} {} ", self.points[0][0], self.points[0][1])?;
for &p in &self.points[1..] {
write!(f, "L... | code_fim | hard | {
"lang": "rust",
"repo": "nical/rust_debug",
"path": "/svg_fmt/src/svg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// 現在の選挙における投票状況.
pub ballot: Ballot,
}
impl Node {
// 初期状態の`Node`インスタンスを生成する.
//
// # Examples
//
// ```
// use raftlog::election::Role;
// use raftlog::node::Node;
//
// let n = Node::new("foo".into());
// assert_eq!(n.id.as_str(), "foo");
// assert_e... | code_fim | medium | {
"lang": "rust",
"repo": "frugalos/raftlog",
"path": "/src/node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frugalos/raftlog path: /src/node.rs
//! ノード関連の構成要素.
use crate::election::{Ballot, Role};
/// ノードのID.
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NodeId(String);
impl NodeId {
/// 新しい`NodeId`インスタンスを生成する.
pub fn new<T: Into<String>>(id: T) -> Self {
No... | code_fim | medium | {
"lang": "rust",
"repo": "frugalos/raftlog",
"path": "/src/node.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ales-tsurko/koto path: /core/runtime/src/meta_map.rs
use {
crate::{
external_function::{ArgRegisters, ExternalFunction},
prelude::*,
},
indexmap::{Equivalent, IndexMap},
koto_parser::MetaKeyId,
std::{
fmt,
hash::{BuildHasherDefault, Hash},
... | code_fim | hard | {
"lang": "rust",
"repo": "ales-tsurko/koto",
"path": "/core/runtime/src/meta_map.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The binary operations that can be implemented in a [MetaMap](crate::MetaMap)
///
/// See [MetaKey::BinaryOp]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum BinaryOp {
/// `@+`
Add,
/// `@-`
Subtract,
/// `@*`
Multiply,
/// `@/`
Divide,
/// `@%`
Rema... | code_fim | hard | {
"lang": "rust",
"repo": "ales-tsurko/koto",
"path": "/core/runtime/src/meta_map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<&str> for MetaKey {
fn from(name: &str) -> Self {
Self::Named(name.into())
}
}
impl From<ValueString> for MetaKey {
fn from(name: ValueString) -> Self {
Self::Named(name)
}
}
impl From<UnaryOp> for MetaKey {
fn from(op: UnaryOp) -> Self {
Self::Unary... | code_fim | hard | {
"lang": "rust",
"repo": "ales-tsurko/koto",
"path": "/core/runtime/src/meta_map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>gister_filter("base64_encode", filters::base64_encode);
tera.register_filter("base64_decode", filters::base64_decode);
tera
};
}
/// Renders the `internal/alias.html` template that will redirect
/// via refresh to the url given
pub fn render_redirect_template(url: &str, tera: &Tera) -... | code_fim | hard | {
"lang": "rust",
"repo": "GoldsteinE/pepel",
"path": "/components/templates/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GoldsteinE/pepel path: /components/templates/src/lib.rs
pub mod filters;
pub mod global_fns;
use lazy_static::lazy_static;
use tera::{Context, Tera};
use errors::{Error, Result};
lazy_static! {
pub static ref PEPEL_TERA: Tera = {
let mut tera = Tera::default();
tera.add_ra... | code_fim | hard | {
"lang": "rust",
"repo": "GoldsteinE/pepel",
"path": "/components/templates/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dojiong/node-rs path: /napi/src/types/buffer.rs
use std::{ffi::c_void, marker::PhantomData, mem::MaybeUninit};
use napi_sys::{napi_create_buffer_copy, napi_get_buffer_info, napi_is_buffer, napi_value};
use crate::{
env::Env,
value::{CastToJs, CastToRust, JsValue},
JsResult,
};
pub... | code_fim | hard | {
"lang": "rust",
"repo": "dojiong/node-rs",
"path": "/napi/src/types/buffer.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn as_bytes(&self, env: Env<'a>) -> JsResult<&[u8]> {
unsafe {
let mut data = MaybeUninit::uninit();
let mut size = MaybeUninit::uninit();
node_try!(
napi_get_buffer_info,
env,
self.value,
d... | code_fim | hard | {
"lang": "rust",
"repo": "dojiong/node-rs",
"path": "/napi/src/types/buffer.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielschemmel/drsat path: /src/driver/sudoku.rs
use std::fs::File;
use super::errors::*;
use crate::io::open_file;
#[derive(clap::Parser, Debug)]
#[clap(about = "Parse and solve a sudoku puzzle", long_about = None)]
pub struct Cli {
/// The path to the file containing the puzzle
#[arg(value... | code_fim | hard | {
"lang": "rust",
"repo": "danielschemmel/drsat",
"path": "/src/driver/sudoku.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sw.start();
let mut board = crate::parser::sudoku::parse(&mut reader, args.rows, args.cols)
.chain_err(|| ErrorKind::Parse(args.path.display().to_string()))?;
sw.stop();
if args.time {
println!("[T] Parsing board: {}", sw);
}
if args.deduce {
sw.start();
board.deduce();
sw.stop();
if ar... | code_fim | hard | {
"lang": "rust",
"repo": "danielschemmel/drsat",
"path": "/src/driver/sudoku.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sw.start();
let result = board.solve();
sw.stop();
if args.time {
println!("[T] Solving query: {}", sw);
// FIXME: decide what to do here // problem.print_conflict_histo();
}
// FIXME: print result
match result {
None => {
println!("Puzzle is impossible");
}
Some(solution) => {
let... | code_fim | hard | {
"lang": "rust",
"repo": "danielschemmel/drsat",
"path": "/src/driver/sudoku.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JulianKnodt/risc-v-sim path: /src/sim/mod.rs
mod normal;
mod in_order;
mod out_of_order;<|fim_suffix|>pub use self::in_order::in_order;
pub use self::out_of_order::execute as out_of_order;<|fim_middle|>
pub use self::normal::execute as normal;
| code_fim | easy | {
"lang": "rust",
"repo": "JulianKnodt/risc-v-sim",
"path": "/src/sim/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::in_order::in_order;
pub use self::out_of_order::execute as out_of_order;<|fim_prefix|>// repo: JulianKnodt/risc-v-sim path: /src/sim/mod.rs
mod normal;
mod in_order;
mod out_of_order;<|fim_middle|>
pub use self::normal::execute as normal;
| code_fim | easy | {
"lang": "rust",
"repo": "JulianKnodt/risc-v-sim",
"path": "/src/sim/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JulianKnodt/risc-v-sim path: /src/sim/mod.rs
mod normal;
mod in_order;
mod out_of_order;
pub use self::normal::execute as normal;
<|fim_suffix|>elf::out_of_order::execute as out_of_order;<|fim_middle|>pub use self::in_order::in_order;
pub use s | code_fim | easy | {
"lang": "rust",
"repo": "JulianKnodt/risc-v-sim",
"path": "/src/sim/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut model = AnimationModel{
objects: Vec::new(),
};
let mut file = remain_file;
let _remain_file = file.split_off(objects_total_length);
for _ in 0..objects_size {
let (object_size, remain_file): (usize, _) = {
let mut in... | code_fim | hard | {
"lang": "rust",
"repo": "megumish/animo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file = BufReader::new(file).bytes().collect::<io::Result<Vec<_>>>().unwrap();
let remain_file = file.split_off(LENGTH_OF_OBJECTS_SIZE);
let objects_size: usize = file.iter().fold(0 as usize, |size, x| (size << 8) + *x as usize);
let mut file = remain_file;
... | code_fim | hard | {
"lang": "rust",
"repo": "megumish/animo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: megumish/animo path: /src/lib.rs
//! animo
#![deny(missing_docs)]
use std::io::prelude::*;
use std::io::{self, BufReader};
use std::fs::File;
const LENGTH_OF_OBJECT_SIZE: usize = 4;
const LENGTH_OF_OBJECTS_SIZE: usize = 4;
const LENGTH_OF_OBJECTS_TOTAL_LENGTH: usize = 4;
const LENGTH_OF_ANIMATI... | code_fim | hard | {
"lang": "rust",
"repo": "megumish/animo",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input: &str,
expected: TemplateExpr,
) -> Result<(), Box<dyn std::error::Error>> {
assert_eq!(
expected,
HclParser::template_expr(
<HclParser as pest_consume::Parser>::parse(Rule::template_expr, input)
... | code_fim | hard | {
"lang": "rust",
"repo": "mortenmj/rust-hcl",
"path": "/src/ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[track_caller]
fn assert_input(
input: &str,
expected: TemplateExpr,
) -> Result<(), Box<dyn std::error::Error>> {
assert_eq!(
expected,
HclParser::template_expr(
<HclParser as pest_consume::Pa... | code_fim | hard | {
"lang": "rust",
"repo": "mortenmj/rust-hcl",
"path": "/src/ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mortenmj/rust-hcl path: /src/ast.rs
[ident(name), expr_newline(es)..]=>FunctionCall{name, arguments:es.collect(), ellipsis:false},
))
}
fn function_call_newline(input: Node) -> ParseResult<FunctionCall> {
Ok(match_nodes!(input.into_children();
[ident(name), expr... | code_fim | hard | {
"lang": "rust",
"repo": "mortenmj/rust-hcl",
"path": "/src/ast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.len() < 1 {
return Err( Error::TooManyArgs );
}
let rv = args[0];
*args = &args[1..];
Ok( rv )
}
}
#[cfg(target_pointer_width="64")]
impl SyscallArg for u64 {
fn get_arg(args: &mut &[usize]) -> Result<Self,Error> {
if args.len() < 1 {
return Err( Error::TooManyArgs );
}
let... | code_fim | hard | {
"lang": "rust",
"repo": "Cloudxtreme/rust_os",
"path": "/Kernel/Modules/syscalls/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cloudxtreme/rust_os path: /Kernel/Modules/syscalls/lib.rs
// "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/syscalls/mod.rs
//! Userland system-call interface
#![no_std]
#![feature(associated_consts)]
#![feature(reflect_marker)]
#[allow(unused_imports)]
use kernel::prelude::*;
u... | code_fim | hard | {
"lang": "rust",
"repo": "Cloudxtreme/rust_os",
"path": "/Kernel/Modules/syscalls/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.len() < 1 {
return Err( Error::TooManyArgs );
}
let rv = args[0] as u32;
*args = &args[1..];
Ok( rv )
}
}
impl SyscallArg for u16 {
fn get_arg(args: &mut &[usize]) -> Result<Self,Error> {
if args.len() < 1 {
return Err( Error::TooManyArgs );
}
let rv = args[0] as u16;
*ar... | code_fim | hard | {
"lang": "rust",
"repo": "Cloudxtreme/rust_os",
"path": "/Kernel/Modules/syscalls/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yaoliao/rust-web path: /src/models.rs
use diesel;
use diesel::{MysqlConnection, RunQueryDsl};
use diesel::debug_query;
use diesel::mysql::Mysql;
use diesel::prelude::*;
use crate::schema::user as user;
#[derive(Serialize, Deserialize, Queryable)]
pub struct User {
pub id: i32,
pub user... | code_fim | medium | {
"lang": "rust",
"repo": "yaoliao/rust-web",
"path": "/src/models.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update(id: i32, new_user: User, conn: &MysqlConnection) -> usize {
use crate::schema::user::dsl::user as dsl_user;
let filter = dsl_user.filter(user::id.eq(id));
diesel::update(filter).set(
(user::username.eq(new_user.username),
user::password.eq... | code_fim | hard | {
"lang": "rust",
"repo": "yaoliao/rust-web",
"path": "/src/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
fn get_xy(&self, _coords: [f64; 2]) -> Point2 {
let _x = map_values(self._perlin_x.get(_coords) as f32, -1.0, 1.0, -self._noise_diameter, self._noise_diameter);
let _y = map_values(self._perlin_y.get(_coords) as f32, -1.0, 1.0, -self._noise_diameter, self._noise_diameter);
... | code_fim | medium | {
"lang": "rust",
"repo": "jairoandre/my-nannou",
"path": "/src/particle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jairoandre/my-nannou path: /src/particle.rs
use nannou::prelude::*;
use noise::{NoiseFn, Perlin, Seedable};
use nannou::app::{Draw};
use rand::Rng;
struct Particle {
_perlin_x: Perlin,
_perlin_y: Perlin,
_noise_diameter: f32,
_radius: f32,
}
impl Particle {
fn new(_noise_di... | code_fim | medium | {
"lang": "rust",
"repo": "jairoandre/my-nannou",
"path": "/src/particle.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn map_values(n: f32, start_1: f32, stop_1: f32, start_2: f32, stop_2: f32) -> f32 {
((n - start_1) / (stop_1 - start_1)) * (stop_2 - start_2) + start_2
}<|fim_prefix|>// repo: jairoandre/my-nannou path: /src/particle.rs
use nannou::prelude::*;
use noise::{NoiseFn, Perlin, Seedable};
use nannou::app:... | code_fim | hard | {
"lang": "rust",
"repo": "jairoandre/my-nannou",
"path": "/src/particle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thibautRe/rustrogueliketutorial path: /chapter-56-caverns/src/raws/mob_structs.rs
use serde::{Deserialize};
use super::{Renderable};
use std::collections::HashMap;
#[derive(Deserialize, Debug)]
pub struct Mob {
pub name : String,
pub renderable : Option<Renderable>,
pub blocks_tile ... | code_fim | medium | {
"lang": "rust",
"repo": "thibautRe/rustrogueliketutorial",
"path": "/chapter-56-caverns/src/raws/mob_structs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize, Debug)]
pub struct NaturalAttack {
pub name : String,
pub hit_bonus : i32,
pub damage : String
}
#[derive(Deserialize, Debug)]
pub struct MobLight {
pub range : i32,
pub color : String
}<|fim_prefix|>// repo: thibautRe/rustrogueliketutorial path: /chapter-56-ca... | code_fim | medium | {
"lang": "rust",
"repo": "thibautRe/rustrogueliketutorial",
"path": "/chapter-56-caverns/src/raws/mob_structs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_sec":74.574,"effect":1,"effect_value":2.0,"position":7},{"timing_sec":74.75,"effect":1,"effect_value":2.0,"position":8},{"timing_sec":74.927,"effect":1,"effect_value":2.0,"position":9},{"timing_sec":75.28,"effect":1,"effect_value":2.0,"position":4},{"timing_sec":75.456,"effect":1,"effect_value":2.0,"posi... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_005_expert.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kbz/beatmap-repo path: /datafiles/m_005_expert.rs
ct_value":2.0,"position":2},{"timing_sec":32.397,"effect":1,"effect_value":2.0,"position":1},{"timing_sec":32.75,"effect":4,"effect_value":0.527,"position":5},{"timing_sec":33.633,"effect":1,"effect_value":2.0,"position":8},{"timing_sec":33.809,"... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_005_expert.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kbz/beatmap-repo path: /datafiles/m_005_expert.rs
":16.868,"effect":17,"effect_value":2.0,"position":9},{"timing_sec":16.868,"effect":17,"effect_value":2.0,"position":1},{"timing_sec":17.574,"effect":1,"effect_value":2.0,"position":6},{"timing_sec":18.28,"effect":1,"effect_value":2.0,"position":... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_005_expert.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ianlet/encrust path: /lib/src/pattern/mod.rs
mod turnip_pattern;
use std::collections::HashMap;
use regex::{Captures, CaptureNames, Regex};
pub trait Pattern {
fn to_regex(&self) -> Regex;
fn to_string(&self) -> String;
}
#[derive(PartialEq, Eq, Debug)]
pub enum StepArgument {
Str... | code_fim | hard | {
"lang": "rust",
"repo": "ianlet/encrust",
"path": "/lib/src/pattern/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(!step_pattern.is_match(&A_DESCRIPTION.to_string()));
}
#[test]
fn it_captures_step_arguments_from_a_description_given_a_pattern_with_arguments() {
let pattern = TurnipPattern::from(A_PATTERN_WITH_ARGUMENTS);
let description = A_DESCRIPTION_WITH_ARGUMENTS.to_str... | code_fim | hard | {
"lang": "rust",
"repo": "ianlet/encrust",
"path": "/lib/src/pattern/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pattern = PatternMock {};
let description = pattern.to_string();
let step_pattern = StepPattern::new(pattern);
assert!(step_pattern.is_match(&description));
}
#[test]
fn it_is_not_matching_a_description_that_does_not_match_its_pattern() {
let patte... | code_fim | hard | {
"lang": "rust",
"repo": "ianlet/encrust",
"path": "/lib/src/pattern/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// A callback fired immediately before the plugin is unloaded. Use this if
/// you need to do any cleanup.
fn on_plugin_unload(&self) {}
}<|fim_prefix|>// repo: dannysauer/gary path: /common/src/plugins/scheduler.rs
///A Trait for all scheduler plugins.
pub trait SchedulerPlugin: Any +... | code_fim | medium | {
"lang": "rust",
"repo": "dannysauer/gary",
"path": "/common/src/plugins/scheduler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dannysauer/gary path: /common/src/plugins/scheduler.rs
///A Trait for all scheduler plugins.
pub trait SchedulerPlugin: Any + Send + Sync {
/// The name of the plugin used to identify it.
fn name(&self) -> String;
<|fim_suffix|> /// A callback fired immediately before the plugin is u... | code_fim | medium | {
"lang": "rust",
"repo": "dannysauer/gary",
"path": "/common/src/plugins/scheduler.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kitsuneninetails/chrono-utils path: /src/year_calc.rs
extern crate chrono;
use chrono::{DateTime, Datelike, TimeZone, Utc};
use std::cmp;
/// This trait defines functions which allow for year calculations between two dates. As
/// the standard DateTime, Date, and Duration types in chrono are ... | code_fim | hard | {
"lang": "rust",
"repo": "kitsuneninetails/chrono-utils",
"path": "/src/year_calc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test_date1 = DateTime::parse_from_rfc3339("2018-03-15T12:00:00Z").unwrap();
let test_date2 = DateTime::parse_from_rfc3339("2018-06-21T12:00:00Z").unwrap();
assert_eq!(test_date1.years_since(&test_date2), 0);
}
#[test]
fn test_years_ymd_sas() {
let test_date... | code_fim | hard | {
"lang": "rust",
"repo": "kitsuneninetails/chrono-utils",
"path": "/src/year_calc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EmbarkStudios/cargo-about path: /src/cargo-about/main.rs
#![doc = include_str!("../../README.md")]
use anyhow::Context as _;
mod clarify;
mod generate;
mod init;
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[derive(clap::Subcommand, Debug)]
enum Command {
//... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/cargo-about",
"path": "/src/cargo-about/main.rs",
"mode": "psm",
"license": "Unicode-DFS-2016",
"source": "the-stack-v2"
} |
<|fim_suffix|> use clap::Parser;
let args = Opts::parse_from({
std::env::args().enumerate().filter_map(|(i, a)| {
if i == 1 && a == "about" {
None
} else {
Some(a)
}
})
});
setup_logger(args.log_level)?;
match args... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/cargo-about",
"path": "/src/cargo-about/main.rs",
"mode": "spm",
"license": "Unicode-DFS-2016",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atNightly/puroro path: /puroro-plugin/src/main.rs
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/lic... | code_fim | hard | {
"lang": "rust",
"repo": "atNightly/puroro",
"path": "/puroro-plugin/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let package_to_subpackage_map = make_package_to_subpackages_map(&cgreq.proto_file);
let package_to_file_descriptor_map = wrapped_cgreq
.input_files()
.iter()
.map(|file| {
Ok((
file.package().iter().join("."),
generators::Messages... | code_fim | hard | {
"lang": "rust",
"repo": "atNightly/puroro",
"path": "/puroro-plugin/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neivv/aise path: /bw_dat/src/dialog.rs
{
match crate::is_scr() {
false => (*self.0.as_ptr()).misc_u16 = value,
true => (*(self.0.as_ptr() as *mut bw::scr::Control)).misc_u16 = value,
}
}
}
pub fn is_disabled(self) -> bool ... | code_fim | hard | {
"lang": "rust",
"repo": "neivv/aise",
"path": "/bw_dat/src/dialog.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn child_by_id(self, id: i16) -> Option<Control> {
self.children().find(|x| x.id() == id)
}
pub fn children(self) -> impl Iterator<Item = Control> {
unsafe {
let child = match crate::is_scr() {
false => (*self.0.as_ptr()).first_child,
... | code_fim | hard | {
"lang": "rust",
"repo": "neivv/aise",
"path": "/bw_dat/src/dialog.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neivv/aise path: /bw_dat/src/dialog.rs
bled(self) -> bool {
unsafe {
match crate::is_scr() {
false => (*self.0.as_ptr()).flags & 0x2 != 0,
true => (*(self.0.as_ptr() as *mut bw::scr::Control)).flags2 & 0x1 != 0,
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "neivv/aise",
"path": "/bw_dat/src/dialog.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>t set")]
NoTimeoutSet,
#[error("not relates to message set")]
NoRelatesToMessageSet,
#[error("could not get current directory {0}")]
Io(#[from] io::Error),
}<|fim_prefix|>// repo: Justin-Schmitz/git-mit path: /git-mit-relates-to/src/errors.rs
use std::{io, num, string};
use thiserror... | code_fim | medium | {
"lang": "rust",
"repo": "Justin-Schmitz/git-mit",
"path": "/git-mit-relates-to/src/errors.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Justin-Schmitz/git-mit path: /git-mit-relates-to/src/errors.rs
use std::{io, num, string};
use thiserror::Error;
use mit_commit_message_lints::{external, relates};
#[derive(Error, Debug)]
pub enum GitRelatesTo {
#[error("relates to should be a number in minutes {0}")]
RelatesToNotNumb... | code_fim | medium | {
"lang": "rust",
"repo": "Justin-Schmitz/git-mit",
"path": "/git-mit-relates-to/src/errors.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error("failed to interact with the vcs: {0}")]
RelatesVcs(#[from] relates::VcsError),
#[error("{0}")]
External(#[from] external::Error),
#[error("not timeout set")]
NoTimeoutSet,
#[error("not relates to message set")]
NoRelatesToMessageSet,
#[error("could not get curre... | code_fim | medium | {
"lang": "rust",
"repo": "Justin-Schmitz/git-mit",
"path": "/git-mit-relates-to/src/errors.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let profile = profile?.ok_or(GatewayDomainInvalid)?;
// If there was a policy resolution, return it with the profile so
// the stack can determine how to switch on them.
match policy {
Ok(policy) => return Ok((Some(profil... | code_fim | hard | {
"lang": "rust",
"repo": "linkerd/linkerd2-proxy",
"path": "/linkerd/app/gateway/src/discover.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let discovery = future::join(profile, policy).map(move |(profile, policy)| {
tracing::debug!("Discovered");
let profile = profile?.ok_or(GatewayDomainInvalid)?;
// If there was a policy resolution, return it with the profile so
... | code_fim | hard | {
"lang": "rust",
"repo": "linkerd/linkerd2-proxy",
"path": "/linkerd/app/gateway/src/discover.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linkerd/linkerd2-proxy path: /linkerd/app/gateway/src/discover.rs
use crate::Gateway;
use futures::FutureExt;
use linkerd_app_core::{errors, profiles, svc, Error};
use linkerd_app_inbound::{GatewayAddr, GatewayDomainInvalid};
use linkerd_app_outbound::{self as outbound};
use linkerd_proxy_client... | code_fim | hard | {
"lang": "rust",
"repo": "linkerd/linkerd2-proxy",
"path": "/linkerd/app/gateway/src/discover.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Reserved data area
pub reserved: [u8; 26],
}
impl Header {
pub const fn default() -> Self {
Self {
start_code: 0xEA00002E,
logo: LOGO,
title: [0u8; 12],
game_code: 0,
maker_code: 0,
fixed: 0x96,
un... | code_fim | hard | {
"lang": "rust",
"repo": "ryankurte/rust-gba",
"path": "/src/header.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryankurte/rust-gba path: /src/header.rs
//! GBA ROM header object
/// ROM header
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub struct Header {
/// Trampoline 1, b 80000c0, jumps to end of header
pub start_code: u32,
/// Nintendo logo, must match for boot to succeed (see [`LOGO`])
... | code_fim | hard | {
"lang": "rust",
"repo": "ryankurte/rust-gba",
"path": "/src/header.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Nintendo logo (must be included in the header)
pub const LOGO: [u8; 0x9C] = [
0x24, 0xFF, 0xAE, 0x51, 0x69, 0x9A, 0xA2, 0x21, 0x3D, 0x84, 0x82, 0x0A, 0x84, 0xE4, 0x09, 0xAD,
0x11, 0x24, 0x8B, 0x98, 0xC0, 0x81, 0x7F, 0x21, 0xA3, 0x52, 0xBE, 0x19, 0x93, 0x09, 0xCE, 0x20,
0x10, 0x46, 0x4A, 0x... | code_fim | hard | {
"lang": "rust",
"repo": "ryankurte/rust-gba",
"path": "/src/header.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// http://graphql.org/learn/queries/#variables
#[test]
fn test_parse_with_variables() {
parse(r#"query HeroNameAndFriends($episode: Episode) {
hero(episode: $episode) {
name
friends {
name
}
}
}"#);
}
}<|fim_prefix|>// repo: jacobbudin/graphql-parser path: /... | code_fim | hard | {
"lang": "rust",
"repo": "jacobbudin/graphql-parser",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> parse(r#"{
human(id: "1000") {
name
height(unit: FOOT)
}
}"#);
}
/// http://graphql.org/learn/queries/#aliases
#[test]
fn test_parse_with_aliases() {
parse(r#"{
empireHero: hero(episode: EMPIRE) {
name
}
jediHero: hero(episode: JEDI) {
name
... | code_fim | hard | {
"lang": "rust",
"repo": "jacobbudin/graphql-parser",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobbudin/graphql-parser path: /src/lib.rs
#[macro_use]
extern crate pest;
use pest::prelude::*;
impl_rdp! {
grammar! {
query = { ["query"]? ~ query_name? ~ brace ~ fragment* }
query_name = { word ~ def? }
brace = { ["{"] ~ fields ~ ["}"] }
fragme... | code_fim | hard | {
"lang": "rust",
"repo": "jacobbudin/graphql-parser",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ThreatsMap/libpvm-rs path: /modules/pvm-data/src/lib.rs
mod id;
mod meta_store;
pub mod node_types;
pub mod rel_types;
mod built_info {
#![allow(dead_code)]
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
pub const fn version() -> &'static str {
built_info::PKG_VERSION
}
pub us... | code_fim | medium | {
"lang": "rust",
"repo": "ThreatsMap/libpvm-rs",
"path": "/modules/pvm-data/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Enumerable {
type Target;
fn enumerate(self) -> Self::Target;
}
pub trait Denumerate: Enumerable {
fn denumerate(val: &<Self as Enumerable>::Target) -> &Self;
fn denumerate_mut(val: &mut <Self as Enumerable>::Target) -> &mut Self;
}
pub trait HasID {
fn get_db_id(&self) -> ... | code_fim | medium | {
"lang": "rust",
"repo": "ThreatsMap/libpvm-rs",
"path": "/modules/pvm-data/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn write(&mut self, bytes: &[u8]) {
self.state.write(bytes);
self.bytes_hashed += bytes.len() as u64;
}
}<|fim_prefix|>// repo: swgillespie/rust path: /src/librustc_incremental/calculate_svh/hasher.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
/... | code_fim | hard | {
"lang": "rust",
"repo": "swgillespie/rust",
"path": "/src/librustc_incremental/calculate_svh/hasher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swgillespie/rust path: /src/librustc_incremental/calculate_svh/hasher.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENS... | code_fim | medium | {
"lang": "rust",
"repo": "swgillespie/rust",
"path": "/src/librustc_incremental/calculate_svh/hasher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doodeehee70/solana path: /programs/stake_api/src/stake_state.rs
cmp::min(stake.stake, self.account.lamports);
self.set_state(&StakeState::Stake(stake))
}
StakeState::Uninitialized => {
if lamports > self.account.lamports {
... | code_fim | hard | {
"lang": "rust",
"repo": "doodeehee70/solana",
"path": "/programs/stake_api/src/stake_state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // test cooldown
for i in STAKE_WARMUP_EPOCHS..STAKE_WARMUP_EPOCHS * 2 {
assert_eq!(
stake.stake(i),
staked - (staked / STAKE_WARMUP_EPOCHS) * (i - STAKE_WARMUP_EPOCHS)
);
}
assert_eq!(stake.stake(STAKE_WARMUP_EPOCHS *... | code_fim | hard | {
"lang": "rust",
"repo": "doodeehee70/solana",
"path": "/programs/stake_api/src/stake_state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doodeehee70/solana path: /programs/stake_api/src/stake_state.rs
+ 2 * STAKE_WARMUP_EPOCHS - 1,
);
}
}
pub trait StakeAccount {
fn delegate_stake(
&mut self,
vote_account: &KeyedAccount,
stake: u64,
clock: &sysvar::clock::Clock,
) -> Result<()... | code_fim | hard | {
"lang": "rust",
"repo": "doodeehee70/solana",
"path": "/programs/stake_api/src/stake_state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match (v, c) {
(ALIVE, 2) | (ALIVE, 3)
=> { new_data[y as usize][x as usize] = ALIVE; },
(DEAD, 3)
=> { new_data[y as usize][x as usize] = ALIVE; },
_ => { new_data[y as usize][x as usize] = DEAD; },
}
}
}
self.cells = new_data;
}
}
fn main() {
// Start an in... | code_fim | hard | {
"lang": "rust",
"repo": "shazow/lpfx-rs",
"path": "/src/bin/conway.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shazow/lpfx-rs path: /src/bin/conway.rs
// conway.rs
// game of life simulation with launchpad
extern crate lpfx;
use lpfx::launchpad::*;
use lpfx::utils::*;
const ALIVE : u8 = 1;
const DEAD : u8 = 0;
const ROWMOD : u8 = 8;
const GAP : u8 = 7;
pub struct Game {
pub cells: [[u8; 8]; 8]... | code_fim | hard | {
"lang": "rust",
"repo": "shazow/lpfx-rs",
"path": "/src/bin/conway.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_queries(filename: String) -> std::io::Result<QueryState> {
let mut file = File::open(filename)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let precompute: QueryState = toml::from_str(&contents).unwrap();
Ok(precompute)
}<|fim_prefix|>// repo: kev... | code_fim | hard | {
"lang": "rust",
"repo": "kev-liao/6.824-final-project",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kev-liao/6.824-final-project path: /src/config.rs
use crate::flpcp::QueryState;
use rug::Integer;
use serde::{Serialize, Deserialize};
use std::{str,
fs::File,
io::Read};
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Config {
pub root_cert: String,
pub q... | code_fim | hard | {
"lang": "rust",
"repo": "kev-liao/6.824-final-project",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_config(filename: String) -> std::io::Result<Config> {
let mut file = File::open(filename)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let config: Config = toml::from_str(&contents).unwrap();
Ok(config)
}
pub fn get_queries(filename: String) -> s... | code_fim | hard | {
"lang": "rust",
"repo": "kev-liao/6.824-final-project",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Helper functions
fn only_live<'a>(loans: &LoanPowerSet<'a>, lfs: &LifetimeTFSpace<'a>) -> LoanPowerSet<'a>
{
let mut result = LoanPowerSet::bottom();
for loan in loans.all() {
if live(lfs, loan.lifetime){
result += LoanPowerSet::singleton(loan);
}
}
result
}<|fim_prefix|>// repo: Emoun/mi... | code_fim | hard | {
"lang": "rust",
"repo": "Emoun/micro_c_analyzer",
"path": "/src/micro_c/analysis/loan/analysis.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a,G,L> Analysis<G,L> for LoanAnalysis<'a>
where
G: Graph<Directedness=Directed, EdgeWeight = Action<'a>>,
G::Vertex: Hash,
L: Bottom + SubLattice<LoanPowerSet<'a>> + SubLattice<LifetimeTFSpace<'a>>,
{
type Lattice = LoanPowerSet<'a>;
const FORWARD: bool = true;
fn transfer(dependency: ... | code_fim | hard | {
"lang": "rust",
"repo": "Emoun/micro_c_analyzer",
"path": "/src/micro_c/analysis/loan/analysis.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emoun/micro_c_analyzer path: /src/micro_c/analysis/loan/analysis.rs
use crate::micro_c::{
Action, Lvalue, Expression, UnaryOperator,
analysis::{
lifetime::{
LifetimeTFSpace, LifetimePowerSet
},
loan::lattice::{
LoanPowerSet, Loan,
},
}
};
use progysis::{
core::{
TFSpace, Pow... | code_fim | hard | {
"lang": "rust",
"repo": "Emoun/micro_c_analyzer",
"path": "/src/micro_c/analysis/loan/analysis.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Polkadex-Substrate/interbtc path: /crates/oracle/src/ext.rs
#[cfg(test)]
use mocktopus::macros::mockable;
#[cfg_attr(test, mockable)]
pub(crate) mod security {
use frame_support::dispatch::DispatchResult;
use security::{ErrorCode, StatusCode};
use sp_std::collections::btree_set::BTr... | code_fim | hard | {
"lang": "rust",
"repo": "Polkadex-Substrate/interbtc",
"path": "/crates/oracle/src/ext.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn get_errors<T: crate::Config>() -> BTreeSet<ErrorCode> {
<security::Pallet<T>>::get_errors()
}
}<|fim_prefix|>// repo: Polkadex-Substrate/interbtc path: /crates/oracle/src/ext.rs
#[cfg(test)]
use mocktopus::macros::mockable;
#[cfg_attr(test, mockable)]
pub(crate) mod securit... | code_fim | hard | {
"lang": "rust",
"repo": "Polkadex-Substrate/interbtc",
"path": "/crates/oracle/src/ext.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MajorBreakfast/embrio-rs path: /embrio-core/src/io/sink.rs
use core::mem::Pin;
use futures::{task, Async, Poll};
use io::Write;
pub struct Sink {
_marker: (),
}
pub fn sink() -> Sink {
Sink { _marker: () }
}
impl Write for Sink {
type Error = !;
fn poll_write(
self:... | code_fim | medium | {
"lang": "rust",
"repo": "MajorBreakfast/embrio-rs",
"path": "/embrio-core/src/io/sink.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Write for Sink {
type Error = !;
fn poll_write(
self: Pin<Self>,
_cx: &mut task::Context,
buf: &[u8],
) -> Poll<usize, Self::Error> {
Ok(Async::Ready(buf.len()))
}
fn poll_flush(
self: Pin<Self>,
_cx: &mut task::Context,
) -> P... | code_fim | medium | {
"lang": "rust",
"repo": "MajorBreakfast/embrio-rs",
"path": "/embrio-core/src/io/sink.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> env::var_os("PATH").and_then(|paths| {
env::split_paths(&paths).filter_map(|dir| {
let full_path = dir.join(&exe_name);
if full_path.is_file() {
Some(full_path)
} else {
None
}
}).next()
})
}
macro_rul... | code_fim | hard | {
"lang": "rust",
"repo": "larago/rust-runas",
"path": "/src/impl_darwin.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: larago/rust-runas path: /src/impl_darwin.rs
use std::io;
use std::env;
use std::ptr;
use std::mem;
use std::ffi::{CString, OsString};
use std::path::{Path, PathBuf};
use std::process::ExitStatus;
use std::os::unix::ffi::OsStrExt;
use Command;
use impl_unix::runas_impl as runas_sudo_impl;
exter... | code_fim | hard | {
"lang": "rust",
"repo": "larago/rust-runas",
"path": "/src/impl_darwin.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
Ok(mem::transmute(rust_darwin_gui_runas(prog.as_ptr(), argv.as_ptr())))
}
}
pub fn runas_impl(cmd: &Command) -> io::Result<ExitStatus> {
if cmd.gui {
runas_gui_impl(&cmd)
} else {
runas_sudo_impl(&cmd)
}
}<|fim_prefix|>// repo: larago/rust-runas path:... | code_fim | hard | {
"lang": "rust",
"repo": "larago/rust-runas",
"path": "/src/impl_darwin.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BarePotato/gooey path: /frontends/browser/src/lib.rs
get_element_by_id(root_id).expect("id not found");
let class_list = parent.class_list();
drop(class_list.add_1(active_theme));
drop(class_list.remove_1(inactive_theme));
}
#[derive(Debug)]
pub struct RegisteredTransmogrifier(pub B... | code_fim | hard | {
"lang": "rust",
"repo": "BarePotato/gooey",
"path": "/frontends/browser/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BarePotato/gooey path: /frontends/browser/src/lib.rs
ctive_theme));
}
#[derive(Debug)]
pub struct RegisteredTransmogrifier(pub Box<dyn AnyWebSysTransmogrifier>);
impl AnyWebSysTransmogrifier for RegisteredTransmogrifier {
fn transmogrify(
&self,
context: &mut AnyTransmogrif... | code_fim | hard | {
"lang": "rust",
"repo": "BarePotato/gooey",
"path": "/frontends/browser/src/lib.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.