text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/rocket_codegen/src/derive/responder.rs
use quote::ToTokens;
use proc_macro::TokenStream;
use devise::{*, ext::TypeExt};
use devise::proc_macro2::TokenStream as TokenStream2;
use crate::http_codegen::{ContentType, Status};
#[derive(Default, FromMeta)]
stru... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/rocket_codegen/src/derive/responder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let content_type = attr.content_type.map(set_header_tokens);
let status = attr.status.map(|status| {
quote_spanned!(status.span().into() => __res.set_status(#status);)
});
Ok(quote! {
#responder
#(#headers)*
... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-io",
"path": "/vendor/rocket_codegen/src/derive/responder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (*self) as isize == (*other) as isize
}
fn ne(&self, other: &x) -> bool { !(*self).eq(other) }
}
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/coherence/coherence-impl-in-fn.rs
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/coherence/coherence-impl-in-fn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/coherence/coherence-impl-in-fn.rs
// run-pass
// revisions: old re
#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
<|fim_suffix|> (*self) as isize == (*other) as isize
... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass/coherence/coherence-impl-in-fn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(part2(4), 5);
assert_eq!(part2(11), 23);
assert_eq!(part2(25), 26);
assert_eq!(part2(26), 54);
assert_eq!(part2(747), 806);
}
pub fn day3(args: &mut env::Args) -> Result<(), io::Error> {
// Expect input to be passed as first arg
let input = args
.next()
... | code_fim | hard | {
"lang": "rust",
"repo": "trevorsm7/advent_of_code_2017",
"path": "/src/day3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trevorsm7/advent_of_code_2017 path: /src/day3.rs
use std::env;
use std::mem;
use std::io;
use std::process::exit;
fn part1(input: u32) -> u32 {
// Handle trivial case
if input <= 1 {return 0}
// Compute the radial distance (Chebyshev distance)
let radius = ((((input - 1) as f64... | code_fim | hard | {
"lang": "rust",
"repo": "trevorsm7/advent_of_code_2017",
"path": "/src/day3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Swap outer to inner for next ring (swaps refs, does not move elements)
mem::swap(&mut inner, &mut outer);
outer.clear();
ring += 1;
};
}
#[test]
fn test_part2() {
assert_eq!(part2(4), 5);
assert_eq!(part2(11), 23);
assert_eq!(part2(25), 26);
assert_e... | code_fim | hard | {
"lang": "rust",
"repo": "trevorsm7/advent_of_code_2017",
"path": "/src/day3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn qexpr_pattern(&mut self, ctx: &mut LocalCtx, code: &mut Vec<Ir>, e: QExpr) -> Result<Pattern, ElabError> {
match e.k {
QExprKind::IdentApp(sp, es) => {
let head = match self.ast.clone().span(sp) {
b"_" => Pattern::Skip,
s if es.is_empty() => Pattern::QExprAtom(se... | code_fim | hard | {
"lang": "rust",
"repo": "asmexcaliburwoods/mm0",
"path": "/mm0-rs/src/elab/lisp/parser.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asmexcaliburwoods/mm0 path: /mm0-rs/src/elab/lisp/parser.rs
Simple(p.remap(r)),
}
}
}
impl Ir {
fn unconst(cs: Vec<Ir>) -> Result<Vec<LispVal>, Vec<Ir>> {
if cs.iter().all(|c| matches!(c, Ir::Const(_))) {
Ok(cs.into_iter().map(|c| let_unchecked!(Ir::Const(v) = c, v)).collect()... | code_fim | hard | {
"lang": "rust",
"repo": "asmexcaliburwoods/mm0",
"path": "/mm0-rs/src/elab/lisp/parser.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asmexcaliburwoods/mm0 path: /mm0-rs/src/elab/lisp/parser.rs
ult<(Span, AtomId, Vec<Ir>), ElabError> {
let (sp, x, stack) = self.def_var(e)?;
let ir = self.def_ir(sp, es, stack)?;
if self.ctx.len() == 0 {
self.spans.insert(sp, ObjectKind::Global(x));
}
Ok((sp, x, ir))
... | code_fim | hard | {
"lang": "rust",
"repo": "asmexcaliburwoods/mm0",
"path": "/mm0-rs/src/elab/lisp/parser.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CryZe/raytracer path: /lib/src/entity/mod.rs
use prelude::*;
use ray::Ray;
use collision::Collision;
pub trait Entity {
type BrdfType: Brdf;
fn collides_with(&self, ray: &Ray) -> Option<Collision<Self::BrdfType>>;
<|fim_suffix|> fn set_position(&mut self, p: Vec3);
}
pub mod sphere;... | code_fim | easy | {
"lang": "rust",
"repo": "CryZe/raytracer",
"path": "/lib/src/entity/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::sphere::Sphere;
pub use self::camera::Camera;
pub use self::mesh::{Triangle, Mesh};<|fim_prefix|>// repo: CryZe/raytracer path: /lib/src/entity/mod.rs
use prelude::*;
use ray::Ray;
use collision::Collision;
pub trait Entity {
type BrdfType: Brdf;
fn collides_with(&self, ray: &Ray) ... | code_fim | easy | {
"lang": "rust",
"repo": "CryZe/raytracer",
"path": "/lib/src/entity/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andete/esb_db path: /src/view.rs.in
table! {
rich_faction (id) {
id -> Int4,
name -> Varchar,
allegiance_id -> Nullable<Int4>,
allegiance -> Nullable<Varchar>,
government_id -> Nullable<Int4>,
government -> Nulla<|fim_suffix|>r_faction -> Bool,... | code_fim | medium | {
"lang": "rust",
"repo": "andete/esb_db",
"path": "/src/view.rs.in",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>r_faction -> Bool,
updated_at -> Timestamptz,
}
}
joinable!(controlling -> rich_faction (faction_id));<|fim_prefix|>// repo: andete/esb_db path: /src/view.rs.in
table! {
rich_faction (id) {
id -> Int4,
name -> Varchar,
allegiance_id -> Nullable<Int4>,
alle... | code_fim | medium | {
"lang": "rust",
"repo": "andete/esb_db",
"path": "/src/view.rs.in",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aschaeffer/rust-ecs-poc path: /src/tests/builder/relation_edge_builder_test.rs
use crate::builder::RelationEdgeBuilder;
use crate::tests::{r_string, r_json_string};
use uuid::Uuid;
use indradb::{EdgeKey, Type};
<|fim_suffix|> let type_name = r_string();
let outbound_id = Uuid::new_v4();
... | code_fim | medium | {
"lang": "rust",
"repo": "aschaeffer/rust-ecs-poc",
"path": "/src/tests/builder/relation_edge_builder_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let type_name = r_string();
let outbound_id = Uuid::new_v4();
let inbound_id = Uuid::new_v4();
let property_name = r_string();
let property_value = r_json_string();
RelationEdgeBuilder::new(outbound_id, type_name.clone(), inbound_id)
.property(property_name.clone(), propert... | code_fim | medium | {
"lang": "rust",
"repo": "aschaeffer/rust-ecs-poc",
"path": "/src/tests/builder/relation_edge_builder_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: camdencheek/jotr path: /src/edit.rs
use crate::args::BaseOpts;
use crate::index::Index;
use clap::*;
use std::process::Command;
#[derive(Clap)]
pub struct EditOpts {
name: String,
}
pub struct EditCommand {
base_opts: BaseOpts,
opts: EditOpts,
}
<|fim_suffix|> let entry = m... | code_fim | hard | {
"lang": "rust",
"repo": "camdencheek/jotr",
"path": "/src/edit.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl EditCommand {
pub fn new(base_opts: BaseOpts, opts: EditOpts) -> Self {
EditCommand { base_opts, opts }
}
pub fn run(&self) {
let index_path = self.base_opts.index_path();
let mut index = Index::from_file(&index_path).expect("failed to read from index");
... | code_fim | medium | {
"lang": "rust",
"repo": "camdencheek/jotr",
"path": "/src/edit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ByteHeathen/libsip path: /src/headers/parse.rs
parse_content_language_header |
parse_content_length_header |
parse_content_type_header |
parse_cseq_header |
parse_date_header |
parse_error_info_header |
parse_expires_header |
parse_event_header |
parse_from_hea... | code_fim | hard | {
"lang": "rust",
"repo": "ByteHeathen/libsip",
"path": "/src/headers/parse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn parse_authorization_header<'a, E: ParseError<&'a [u8]>>(
input: &'a [u8],
) -> IResult<&'a [u8], Header, E> {
let (input, _) = opt(tag("\r\n"))(input)?;
let (input, _) = tag_no_case("Authorization")(input)?;
let (input, _) = opt(take_while(is_space))(input)?;
let (input, _) = ch... | code_fim | hard | {
"lang": "rust",
"repo": "ByteHeathen/libsip",
"path": "/src/headers/parse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>//! These can also be used directly in cases where more granular parsing is desired.
//!
//! For better performance, a parallelized implementation is recommended. See the [`Async`](#Async) header below for more.
//!
//! ## Format Support
//! [`ogre`](crate) supports the Quake [`WAD2`](https://www.gamers.o... | code_fim | hard | {
"lang": "rust",
"repo": "CyberSys/WADparser-ogre",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CyberSys/WADparser-ogre path: /src/lib.rs
#![forbid(unsafe_code)]
//! # A rusty, dual-wielding Quake and Half-Life texture WAD parser
//! [`ogre`](crate) is a Rust representation and [`nom`] parser for Quake and Half-Life [`WAD`](https://www.gamers.org/dEngine/quake/spec/quake-spec34/qkspec_7.h... | code_fim | hard | {
"lang": "rust",
"repo": "CyberSys/WADparser-ogre",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>1")]
pub non_seasonal_order: ::core::option::Option<super::super::super::ArimaOrder>,
/// Arima coefficients.
#[prost(message, optional, tag = "2")]
pub arima_coefficients: ::core::option::Option<ArimaCoefficients>,
... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.bigquery.v2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/googapis path: /googapis/genproto/google.cloud.bigquery.v2.rs
pub f1_score: ::core::option::Option<f64>,
/// Logarithmic Loss. For multiclass this is a macro-averaged metric.
#[prost(message, optional, tag = "6")]
pub log_loss: ::core::option::Option<f64>,
... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.bigquery.v2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/googapis path: /googapis/genproto/google.cloud.bigquery.v2.rs
ning and evaluation
/// data tables that were used to train the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataSplitResult {
/// Table reference of the training data after split.
... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.bigquery.v2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl Output for Xmobar {
fn refresh(status_data: &StatusData) {
println!("<fc={}>|</fc> <fc={}>CPU:{:3}%</fc> <fc={}>|</fc> \
<fc={}>MEM:{:3}%</fc> <fc={}>SWP:{:3}%</fc> <fc={}>|</fc> \
<fc={}>RX:{:3}%</fc> <fc={}>TX:{:3}%</fc> {}<fc={}>|</fc> \
... | code_fim | hard | {
"lang": "rust",
"repo": "nakal/sysinfobar",
"path": "/src/output/xmobar/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nakal/sysinfobar path: /src/output/xmobar/mod.rs
use super::{Output, StatusData, PowerInfo};
use std::io::{self, Write};
const COLOR_INACTIVE: &'static str = "#606060";
const COLOR_ACTIVE: &'static str = "#a8ff60";
const COLOR_CRITICAL: &'static str = "red";
const COLOR_WARNING: &'static str = ... | code_fim | hard | {
"lang": "rust",
"repo": "nakal/sysinfobar",
"path": "/src/output/xmobar/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yuulive/mo path: /src/generator/mod.rs
las choices
// println!("{:?}", rules);
dynamic_blacklist.append(&mut rules);
} else {
// sino solo adicionar la regla
... | code_fim | hard | {
"lang": "rust",
"repo": "yuulive/mo",
"path": "/src/generator/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Solo se remueve la ultima ocurrencia encontrada para evitar problemas de remover un item de la blacklist en
// profundidad por ejemplo |BLACKLIST|I|ThingWithA| |BLACKLIST|I|A| / |BLACKLIST|R|A| |BLACKLIST|R|ThingWithA|
... | code_fim | hard | {
"lang": "rust",
"repo": "yuulive/mo",
"path": "/src/generator/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yuulive/mo path: /src/generator/mod.rs
None => return Ok(start_rule.to_string()),
}
// Lista negra dinámica, usada para evitar la expansión de ciertos elementos de forma dinámica
// Por ejemplo para evitar <a><p><a>TEXT</a></p></a>
let mut dynamic_blacklist: Vec<String> = Vec:... | code_fim | hard | {
"lang": "rust",
"repo": "yuulive/mo",
"path": "/src/generator/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fut = async {
let res = await!(fut).unwrap();
println!("{}", res.status());
};
let mut rt = Runtime::new().unwrap();
let fut = fut.compat(rt.executor().compat());
rt.block_on(fut);
}<|fim_prefix|>// repo: tinaun/futures-playground path: /examples/h... | code_fim | medium | {
"lang": "rust",
"repo": "tinaun/futures-playground",
"path": "/examples/hyper.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tinaun/futures-playground path: /examples/hyper.rs
#![feature(async_await, await_macro)]
use hyper::Client;
use hyper::rt::Future;
use futures_playground::{Compat01, Compat03, ExecCompat};
use tokio::runtime::Runtime;
fn main() {
<|fim_suffix|> let mut rt = Runtime::new().unwrap... | code_fim | hard | {
"lang": "rust",
"repo": "tinaun/futures-playground",
"path": "/examples/hyper.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lizhuohua/mesabox path: /tests/gnu/base32.rs
//
// Copyright (c) 2018, The MesaLock Linux Project Contributors
// All rights reserved.
//
// This work is licensed under the terms of the BSD 3-Clause License.
// For a copy, see the LICENSE file.
//
// This file incorporates work covered by the fo... | code_fim | hard | {
"lang": "rust",
"repo": "lizhuohua/mesabox",
"path": "/tests/gnu/base32.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_cmd!()
.current_dir(fixtures_dir!())
.arg("plain.txt")
.assert()
.success()
.stdout("JBSWY3DPFQQFO33SNRSCCCQ=\n")
.stderr("");
}
#[test]
fn test_decode_file() {
new_cmd!()
.current_dir(fixtures_dir!())
.args(&["-d", "encoded.txt"... | code_fim | hard | {
"lang": "rust",
"repo": "lizhuohua/mesabox",
"path": "/tests/gnu/base32.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for wrap_param in vec!["-w", "--wrap"] {
new_cmd!()
.arg(wrap_param)
.assert()
.failure()
.stdout("")
.stderr(pred_str_contains!("requires a value but none was supplied\n"));
}
}
#[test]
fn test_wrap_bad_arg() {
for wrap_para... | code_fim | hard | {
"lang": "rust",
"repo": "lizhuohua/mesabox",
"path": "/tests/gnu/base32.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stereobooster/emcache path: /src/metrics/statistics/aggregated_metric.rs
#[derive(Debug, Clone, PartialEq)]
pub struct AggregatedMe<|fim_suffix|>ption<f64>,
pub p0: Option<f64>,
pub p90: Option<f64>,
pub p99: Option<f64>,
pub p999: Option<f64>,
}<|fim_middle|>tric {
pub name:... | code_fim | easy | {
"lang": "rust",
"repo": "stereobooster/emcache",
"path": "/src/metrics/statistics/aggregated_metric.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ption<f64>,
pub p0: Option<f64>,
pub p90: Option<f64>,
pub p99: Option<f64>,
pub p999: Option<f64>,
}<|fim_prefix|>// repo: stereobooster/emcache path: /src/metrics/statistics/aggregated_metric.rs
#[derive(Debug, Clone, PartialEq)]
pub struct AggregatedMe<|fim_middle|>tric {
pub name:... | code_fim | easy | {
"lang": "rust",
"repo": "stereobooster/emcache",
"path": "/src/metrics/statistics/aggregated_metric.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn shift_right(&mut self, delta: i32);
fn split_columns(&self, at: i32) -> (Self, Self);
fn split_rows(&self, at: i32) -> (Self, Self);
}
impl RectUtil for winapi::RECT {
fn inset(&mut self, delta: i32) {
self.left += delta;
self.top += delta;
self.right -= 2 * del... | code_fim | hard | {
"lang": "rust",
"repo": "toChaim/rust-reader",
"path": "/src/window.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
msg: winapi::UINT,
w_param: winapi::WPARAM,
l_param: winapi::LPARAM,
) -> Option<winapi::LRESULT>;
}
pub unsafe extern "system" fn window_proc_generic<T: Windowed>(
h_wnd: winapi::HWND,
msg: winapi::UINT,
w_param: winapi::WPARAM,
l_param: win... | code_fim | hard | {
"lang": "rust",
"repo": "toChaim/rust-reader",
"path": "/src/window.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: toChaim/rust-reader path: /src/window.rs
use winapi;
use user32;
use kernel32;
use std::ops::Range;
use std::mem;
pub use wide_string::*;
// waiting for winapi
pub mod winapi_stub {
#![allow(dead_code, non_snake_case)]
use winapi::{DWORD, HMENU};
// Static Control Constants
/... | code_fim | hard | {
"lang": "rust",
"repo": "toChaim/rust-reader",
"path": "/src/window.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flipstone/dolittle path: /src/http_parser.rs
/* automatically generated by rust-bindgen */
use core::libc::*;
pub type __u_char = c_uchar;
pub type __u_short = c_ushort;
pub type __u_int = c_uint;
pub type __u_long = c_ulong;
pub type __int8_t = c_schar;
pub type __uint8_t = c_uchar;
pub type _... | code_fim | hard | {
"lang": "rust",
"repo": "flipstone/dolittle",
"path": "/src/http_parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { cast::reinterpret_cast(&ptr::to_unsafe_ptr(self)) }
}
pub fn __align(&self) -> *c_long {
unsafe { cast::reinterpret_cast(&ptr::to_unsafe_ptr(self)) }
}
}
pub type pthread_spinlock_t = c_int;
pub struct pthread_barrier_t {
pub data: [c_uchar, ..32u],
}
pub impl pthread... | code_fim | hard | {
"lang": "rust",
"repo": "flipstone/dolittle",
"path": "/src/http_parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zTgx/httplib-rs path: /src/ffi.rs
use libc::c_void;
use libc::c_int;
use crate::traits::{
ContentProviderResourceReleaser,
};
///Headers
#[repr(C)]
pub struct Headers {
}
#[repr(C)]
pub struct Params {
}
#[repr(C)]
pub struct MultipartFiles {
}
#[repr(C)]
pub struct Ranges {
}
#[re... | code_fim | hard | {
"lang": "rust",
"repo": "zTgx/httplib-rs",
"path": "/src/ffi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>//Test
extern "C" {
pub fn make_test() -> *mut Test;
pub fn test_get(t: *mut Test, path: *const libc::c_int, cb: Box<extern fn(i32, RT)>);
}
extern "C" {
// Declare the prototype for the external function
//pub fn do_thing(cb: extern fn (*const libc::c_int));
// Declare the prototype... | code_fim | hard | {
"lang": "rust",
"repo": "zTgx/httplib-rs",
"path": "/src/ffi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: auxoncorp/rust-lcm-codec path: /tests/sliceable_list.rs
extern crate generated;
extern crate rust_lcm_codec;
use core::mem::{transmute, MaybeUninit};
type TestError = rust_lcm_codec::CodecError<
rust_lcm_codec::BufferReaderError,
rust_lcm_codec::BufferWriterError,
>;
#[test]
fn byte_sl... | code_fim | hard | {
"lang": "rust",
"repo": "auxoncorp/rust-lcm-codec",
"path": "/tests/sliceable_list.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn byte_slice_read_round_trip() -> Result<(), TestError> {
let mut buf = [0u8; 256];
let item_values_to_write = [2u8, 4, 8, 16, 32, 64];
let n_bytes_written = {
let mut w = rust_lcm_codec::BufferWriter::new(&mut buf);
let pw = generated::sliceable_list::begin_blob_t_wr... | code_fim | hard | {
"lang": "rust",
"repo": "auxoncorp/rust-lcm-codec",
"path": "/tests/sliceable_list.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knokko/Memory-Structures path: /src/array.rs
/// Some kind of array structure that uses interior mutability. It uses a Vec to claim
/// a piece of memory that will then be used to store the contents of the array.
/// The Vec will be kept as private field of the Array to make sure it won't be dro... | code_fim | hard | {
"lang": "rust",
"repo": "knokko/Memory-Structures",
"path": "/src/array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Unfortunately, this requires a mutable reference to the Array, but so be it...
impl<T> IndexMut<usize> for Array<T> {
fn index_mut(&mut self, index: usize) -> &mut T {
self.get_mut_ref(index)
}
}
impl<T: Copy> Array<T> {
pub fn create_filled(size: usize, value: T) -> Array<T> {
... | code_fim | hard | {
"lang": "rust",
"repo": "knokko/Memory-Structures",
"path": "/src/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> commands
.spawn((
attributes::Player {
stats: attributes::PlayerStats {
boost_speed: 1500.0,
boost_duration: 0.1,
boost_cooldown: 0.2,
speed: 400.0,
acceleration: 0.8... | code_fim | hard | {
"lang": "rust",
"repo": "nhaney/fish-game",
"path": "/src/player/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nhaney/fish-game path: /src/player/mod.rs
use crate::shared::{
animation::AnimationState,
collision::Collider,
game::GameRestarted,
movement::{SideScrollDirection, Velocity},
render::RenderLayer,
stages,
};
use bevy::prelude::*;
use std::collections::HashSet;
mod animati... | code_fim | hard | {
"lang": "rust",
"repo": "nhaney/fish-game",
"path": "/src/player/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // spawn a new player with new ui components
let new_player = spawn_player_entity(commands, &player_state_animations);
render::spawn_player_boost_trackers(
&mut commands,
materials,
meshes,
PLAYER_WIDTH,
PLAYER_HEIGHT,
... | code_fim | hard | {
"lang": "rust",
"repo": "nhaney/fish-game",
"path": "/src/player/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IamfromSpace/rust-cycle path: /src/telemetry_db.rs
use btleplug::api::UUID;
use nmea0183::ParseResult;
use serde::{Deserialize, Serialize};
use std::convert::TryInto;
use std::time::Duration;
#[derive(Clone)]
pub struct TelemetryDb {
db: sled::Db,
serial_config: bincode::Config,
}
// T... | code_fim | hard | {
"lang": "rust",
"repo": "IamfromSpace/rust-cycle",
"path": "/src/telemetry_db.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn check_session(&self, key: u64) -> sled::Result<bool> {
self.db
.get_gt(self.serial_config.serialize(&key).unwrap())
.map(|x| x.map_or(false, |(k, _)| self.decode_key(k).0 == key))
}
pub fn sessions_between_inclusive(&self, a: u64, b: u64) -> sled::Result... | code_fim | hard | {
"lang": "rust",
"repo": "IamfromSpace/rust-cycle",
"path": "/src/telemetry_db.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>&self) -> RUNLOCK_R {
RUNLOCK_R::new((self.bits & 0xffff_ffff) as u32)
}
}<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsamd51j19a/src/nvmctrl/runlock.rs
#[doc = "Reader of register RUNLOCK"]
pub type R = crate::R<u32, super::RUNLOCK>;
#[doc = "Reader of field `RUNLOCK`"]
pub type RUNLOC... | code_fim | medium | {
"lang": "rust",
"repo": "wgwoods/atsamd",
"path": "/pac/atsamd51j19a/src/nvmctrl/runlock.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsamd51j19a/src/nvmctrl/runlock.rs
#[doc = "Reader of register RUNLOCK"]
pub type R = crate::R<u32, super::RUNLOCK>;
#[d<|fim_suffix|> #[doc = "Bits 0:31 - Region Un-Lock Bits"]
#[inline(always)]
pub fn runlock(&self) -> RUNLOCK_R {
RUNLOCK_R::new((sel... | code_fim | medium | {
"lang": "rust",
"repo": "wgwoods/atsamd",
"path": "/pac/atsamd51j19a/src/nvmctrl/runlock.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gege00/db-backuper path: /src/main.rs
use tiberius::{Client, Config, AuthMethod, error::Error};
use tokio_util::compat::TokioAsyncWriteCompatExt;
use tokio::net::TcpStream;
use std::{fs, str::FromStr};
use serde::{Serialize, Deserialize};
use serde_json::Result as SerdeResult;
#[derive(Seria... | code_fim | hard | {
"lang": "rust",
"repo": "Gege00/db-backuper",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let back_up_config = load_config("D:/dev/db-backuper/config.json".to_string());
print!("DB Address: {}", back_up_config.dbAddress);
let mut config = Config::new();
config.host(back_up_config.dbAddress);
... | code_fim | medium | {
"lang": "rust",
"repo": "Gege00/db-backuper",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tailhook/ns-router path: /src/coroutine.rs
use std::fmt;
use std::sync::{Arc};
use std::mem;
use abstract_ns::{Address, IpList, Name, Error};
use async_slot as slot;
use futures::future::Shared;
use futures::stream::{FuturesUnordered, Fuse};
use futures::sync::mpsc::{UnboundedReceiver};
use fut... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/ns-router",
"path": "/src/coroutine.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name: Name, tx: oneshot::Sender<Result<IpList, Error>>)
{
// need to retry resolving static host because the config might just
// arrived right now
if let Some(value) = cfg.hosts.get(&name) {
reply(&name, tx, value.clone());
return;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/ns-router",
"path": "/src/coroutine.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimtion/AdventOfCode2020 path: /src/day08.rs
use std::{convert::TryInto, error::Error, fs::File, io::BufRead, io::BufReader};
#[derive(Debug, Copy, Clone)]
enum Instr {
Acc(i64),
Jmp(i64),
Nop(i64),
}
type Program = Vec<Instr>;
impl From<String> for Instr {
fn from(line: Strin... | code_fim | hard | {
"lang": "rust",
"repo": "dimtion/AdventOfCode2020",
"path": "/src/day08.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..program.len() {
let mut program = program.clone();
match program[i] {
Instr::Jmp(c) => program[i] = Instr::Nop(c),
Instr::Nop(c) => program[i] = Instr::Jmp(c),
_ => continue,
};
match execute(program) {
(true, ... | code_fim | hard | {
"lang": "rust",
"repo": "dimtion/AdventOfCode2020",
"path": "/src/day08.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn average_interval(&self, perf_type: PerfType, time: f64) -> f64 {
match self.interval_log.get(&perf_type) {
Some(intervals) => {
let mut n_intervals = 0;
let mut total_interval = 0f64;
let deadline_time = current_time() - time;
... | code_fim | hard | {
"lang": "rust",
"repo": "CrazedProgrammer/darkbin",
"path": "/src/util/perf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CrazedProgrammer/darkbin path: /src/util/perf.rs
extern crate time;
use std::collections::HashMap;
use util::Hasher;
const GC_INTERVAL: f64 = 10f64;
#[derive(PartialEq, Eq, Hash, Copy, Clone)]
pub enum PerfType {
Update,
Draw,
VSync,
Total,
}
pub struct Perf {
interval_lo... | code_fim | hard | {
"lang": "rust",
"repo": "CrazedProgrammer/darkbin",
"path": "/src/util/perf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_example() {
let test_input = r"+1
-2
+3
+1";
assert_eq!(calculate_freq(test_input), 3);
assert_eq!(find_first_duplicate(test_input), 2);
}<|fim_prefix|>// repo: Tirka/advent-of-code-2018 path: /src/day01.rs
use std::collections::HashSet;
macro_rules! input_iterator {
($... | code_fim | hard | {
"lang": "rust",
"repo": "Tirka/advent-of-code-2018",
"path": "/src/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tirka/advent-of-code-2018 path: /src/day01.rs
use std::collections::HashSet;
macro_rules! input_iterator {
($input: expr) => {
$input
.lines()
.map(|num| num.parse::<i32>().unwrap())
};
}
<|fim_suffix|>#[test]
fn test_example() {
let test_input = r"+1
-2
+3... | code_fim | hard | {
"lang": "rust",
"repo": "Tirka/advent-of-code-2018",
"path": "/src/day01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.try_into().expect("process identifier is invalid")
}
pub(crate) unsafe fn is_running(&self) -> io::Result<bool> {
check_syscall(unsafe { libc::kill(self.as_pid(), 0) })
.map(|()| true)
.or_else(|error| {
if error.raw_os_error() == Som... | code_fim | medium | {
"lang": "rust",
"repo": "dylni/process_control",
"path": "/tests/common/unix.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dylni/process_control path: /tests/common/unix.rs
use std::convert::TryInto;
use std::io;
use std::os::raw::c_int;
use std::process::Child;
use libc::pid_t;
use libc::ESRCH;
fn check_syscall(result: c_int) -> io::Result<()> {
if result >= 0 {
Ok(())
} else {
Err(io::Err... | code_fim | hard | {
"lang": "rust",
"repo": "dylni/process_control",
"path": "/tests/common/unix.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The `tick` method increments time for the JobScheduler and executes
/// any pending jobs. It is recommended to sleep for at least 500
/// milliseconds between invocations of this method.
/// This is kept public if you're running this yourself. It is better to
/// call the `start` m... | code_fim | hard | {
"lang": "rust",
"repo": "ssduter92/tokio-cron-scheduler",
"path": "/src/job_scheduler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ssduter92/tokio-cron-scheduler path: /src/job_scheduler.rs
use crate::job::{JobLocked, JobType};
use chrono::Utc;
use std::sync::{Arc, RwLock};
use tokio::task::JoinHandle;
use uuid::Uuid;
/// The JobScheduler contains and executes the scheduled jobs.
pub struct JobsSchedulerLocked(Arc<RwLock<J... | code_fim | hard | {
"lang": "rust",
"repo": "ssduter92/tokio-cron-scheduler",
"path": "/src/job_scheduler.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>elect::Select;
pub use where_::Where;
pub use wrap::Wrap;<|fim_prefix|>// repo: xiuxiu62/engine-q path: /crates/nu-command/src/filters/mod.rs
mod each;
mod get;
mod length;
mod lines;
mod select;
mo<|fim_middle|>d where_;
mod wrap;
pub use each::Each;
pub use get::Get;
pub use length::Length;
pub use li... | code_fim | medium | {
"lang": "rust",
"repo": "xiuxiu62/engine-q",
"path": "/crates/nu-command/src/filters/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xiuxiu62/engine-q path: /crates/nu-command/src/filters/mod.rs
mod each;
mod get;
mod length;
mod lines;
mod select;
mo<|fim_suffix|>;
pub use length::Length;
pub use lines::Lines;
pub use select::Select;
pub use where_::Where;
pub use wrap::Wrap;<|fim_middle|>d where_;
mod wrap;
pub use each::E... | code_fim | easy | {
"lang": "rust",
"repo": "xiuxiu62/engine-q",
"path": "/crates/nu-command/src/filters/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: v33ps/mischief path: /src/filesystem.rs
use std::fs::File;
#[allow(unused_imports)]
use std::io::prelude::*;
use std::path::Path;
#[allow(unused_imports)]
use std::fs::OpenOptions;
#[allow(unused_imports)]
use std::fs::remove_file;
#[allow(unused_imports)]
use crossbeam_channel::{Receiver, Sende... | code_fim | hard | {
"lang": "rust",
"repo": "v33ps/mischief",
"path": "/src/filesystem.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> File::create(&path)?;
Ok(())
}
fn write_file(path: &Path, content: String) -> std::io::Result<()> {
let mut file = OpenOptions::new().write(true).open(&path)?;
file.write_all(content.as_bytes())?;
Ok(())
}<|fim_prefix|>// repo: v33ps/mischief path: /src/filesystem.rs
use std::fs::Fil... | code_fim | medium | {
"lang": "rust",
"repo": "v33ps/mischief",
"path": "/src/filesystem.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michaelwoerister/rust-pgo-test-programs path: /branch_weights/branch_weights.rs
#![crate_type="bin"]
extern crate opt_lib;
// A thousand evenly distributed random numbers
const RANDOM_NUMBERS: &[u8] = &[
28,18,67,57,23,12,45,41,8,94,91,46,51,34,60,66,97,16,58,58,44,65,96,52,94,
11,74,... | code_fim | hard | {
"lang": "rust",
"repo": "michaelwoerister/rust-pgo-test-programs",
"path": "/branch_weights/branch_weights.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>3,21,75,25,95,72,5,73,53,69,70,23,16,65,38,50,5,52,84,
62,2,74,94,85,61,56,0,79,88,50,13,6,36,32,6,70,36,64,66,1,35,76,1,5,0,78,
12,47,58,82,68,11,86,75,46,13,65,54,57,32,20,55,0,62,94,58,91,68,10,16,18,
71,9,60,29,82,53,85,45,8,74,16,77,32,30,86,55,3,59,50,49,37,80,13,80,71,
20,62,50,85,5... | code_fim | hard | {
"lang": "rust",
"repo": "michaelwoerister/rust-pgo-test-programs",
"path": "/branch_weights/branch_weights.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>0,21,63,35,15,32,44,
58,86,47,23,87,77,89,9,17,35,0,8,80,89,48,17,17,66,54,76,65,6,45,35,82,85,
91,87,86,18,59,19,18,16,22,87,25,74,38,67,1,7,45,0,29,18,30,34,41,57,52,44,
68,87,93,30,100,21,75,56,98,50,15,66,5,35,13,30,85,97,82,51,5,79,2,96,23,
37,5,29,96,16,25,4,80,64,22,88,11,64,27,0,45... | code_fim | hard | {
"lang": "rust",
"repo": "michaelwoerister/rust-pgo-test-programs",
"path": "/branch_weights/branch_weights.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boomshroom/pikelet path: /src/syntax/translation/desugar/tests.rs
use codespan::{CodeMap, FileName};
use goldenfile::Mint;
use std::io::Write;
use syntax::parse;
use super::*;
fn golden(filename: &str, literal: &str) {
let path = "src/syntax/translation/desugar/goldenfiles";
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "boomshroom/pikelet",
"path": "/src/syntax/translation/desugar/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> golden("ann_ann_left", r"Type : Type : Type");
}
#[test]
fn ann_ann_right() {
golden("ann_ann_right", r"Type : (Type : Type)");
}
#[test]
fn ann_ann_ann() {
golden("ann_ann_ann", r"(Type : Type) : (Type : Type)");
}
#[test]
fn lam_ann() {
... | code_fim | hard | {
"lang": "rust",
"repo": "boomshroom/pikelet",
"path": "/src/syntax/translation/desugar/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn id() {
let x = FreeVar::fresh_named("x");
let a = FreeVar::fresh_named("a");
assert_term_eq!(
parse(r"\(a : Type) (x : a) => x"),
RcTerm::from(Term::Lam(
ByteSpan::default(),
Scope::new(
... | code_fim | hard | {
"lang": "rust",
"repo": "boomshroom/pikelet",
"path": "/src/syntax/translation/desugar/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stewart/rff path: /src/ansi/clear.rs
use std::fmt::{Display, Formatter, Result};
// Clears from the cursor to the end of the line
generate_csi_struct!(AfterCursor, "K");
// Clears from the cursor to the beginning of the line
generate_csi_struct!(BeforeCursor, "1K");
// Clears the current line... | code_fim | hard | {
"lang": "rust",
"repo": "stewart/rff",
"path": "/src/ansi/clear.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(format!("{}", AfterCursor), "\x1b[K");
}
#[test]
fn before_cursor() {
assert_eq!(format!("{}", BeforeCursor), "\x1b[1K");
}
#[test]
fn line() {
assert_eq!(format!("{}", Line), "\x1b[2K");
}
#[test]
fn screen() {
assert_eq!(f... | code_fim | medium | {
"lang": "rust",
"repo": "stewart/rff",
"path": "/src/ansi/clear.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn line() {
assert_eq!(format!("{}", Line), "\x1b[2K");
}
#[test]
fn screen() {
assert_eq!(format!("{}", Screen), "\x1b[J");
}
}<|fim_prefix|>// repo: stewart/rff path: /src/ansi/clear.rs
use std::fmt::{Display, Formatter, Result};
// Clears from the curs... | code_fim | medium | {
"lang": "rust",
"repo": "stewart/rff",
"path": "/src/ansi/clear.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hannobraun/embedded path: /blink/src/hardware/base/rtt.rs
// Real-time Timer code for Atmel SAM3X.
// See data sheet, chapter 13.
use volatile::Volatile;
<|fim_suffix|>// Mode register flags. See data sheet, section 13.5.1.
pub const ALMIEN : u32 = 0x1 << 16; // Alarm Interrupt Enable
pub c... | code_fim | hard | {
"lang": "rust",
"repo": "hannobraun/embedded",
"path": "/blink/src/hardware/base/rtt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Mode register flags. See data sheet, section 13.5.1.
pub const ALMIEN : u32 = 0x1 << 16; // Alarm Interrupt Enable
pub const RTTINCIEN: u32 = 0x1 << 17; // RTT Increment Interrupt Enable
pub const RTTRST : u32 = 0x1 << 18; // RTT Restart
// Status register flags. See data sheet, section 13.5.4.
pu... | code_fim | hard | {
"lang": "rust",
"repo": "hannobraun/embedded",
"path": "/blink/src/hardware/base/rtt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(JsValue::new_bool(value))
}
// 15.6.4.2 Boolean.prototype.toString ( )
pub fn Boolean_toString(env: &mut JsEnv, _mode: JsFnMode, args: JsArgs) -> JsResult<JsValue> {
let this_arg = args.this(env);
let value = try!(get_bool_value(env, this_arg));
let result = if value { "true" } el... | code_fim | hard | {
"lang": "rust",
"repo": "CM-Tech/rjs",
"path": "/src/rt/env/boolean.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CM-Tech/rjs path: /src/rt/env/boolean.rs
use ::{JsResult, JsError};
use rt::{JsEnv, JsArgs, JsValue, JsFnMode, JsItem, JsType, JsString};
use syntax::token::name;
// 15.6.1 The Boolean Constructor Called as a Function
// 15.6.2 The Boolean Constructor
pub fn Boolean_constructor(env: &mut JsEnv,... | code_fim | hard | {
"lang": "rust",
"repo": "CM-Tech/rjs",
"path": "/src/rt/env/boolean.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// 15.6.4.2 Boolean.prototype.toString ( )
pub fn Boolean_toString(env: &mut JsEnv, _mode: JsFnMode, args: JsArgs) -> JsResult<JsValue> {
let this_arg = args.this(env);
let value = try!(get_bool_value(env, this_arg));
let result = if value { "true" } else { "false" };
Ok(JsString... | code_fim | hard | {
"lang": "rust",
"repo": "CM-Tech/rjs",
"path": "/src/rt/env/boolean.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use std::collections::HashSet;
use super::*;
use crate::polar::Polar;
#[test]
fn test_rule_index() {
let polar = Polar::new();
polar
.load_str(
r#"
f(1, 1, "x");
f(1, 1, "y");
f(1... | code_fim | hard | {
"lang": "rust",
"repo": "osohq/oso",
"path": "/polar-core/src/rules.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osohq/oso path: /polar-core/src/rules.rs
use std::collections::{BTreeSet, HashMap};
use std::sync::Arc;
use serde::{Deserialize, Serialize};
use super::sources::{Context, Source, SourceInfo};
use super::terms::*;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Parame... | code_fim | hard | {
"lang": "rust",
"repo": "osohq/oso",
"path": "/polar-core/src/rules.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fanhaipeng0403/rust_api path: /src/auth/handler.rs
use actix_web::{web, HttpResponse};
use actix_session::Session;
use serde::Deserialize;
use serde_json::json;
use crate::errors::ApiError;
use crate::user::model::{User, NewUser};
#[derive(Debug, Deserialize)]
pub struct AuthData {
pub emai... | code_fim | hard | {
"lang": "rust",
"repo": "fanhaipeng0403/rust_api",
"path": "/src/auth/handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn get_me(session: Session) -> Result<HttpResponse, ApiError> {
let id: Option<String> = session.get("user_id")?;
if let Some(id) = id {
let user = User::find(id)?;
Ok(HttpResponse::Ok().json(user))
}
else{
Err(ApiError::new(401, "Unauthorized".to_string(... | code_fim | hard | {
"lang": "rust",
"repo": "fanhaipeng0403/rust_api",
"path": "/src/auth/handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get a mutable reference to the contents of this packet, excluding the
/// header.
pub fn payload_mut(&mut self) -> &mut [u8] {
&mut self.0[5..]
}
/// Get the raw ID of this packet.
pub fn id(&self) -> u8 {
self.0[4]
}
/// Attempt to parse this raw pack... | code_fim | hard | {
"lang": "rust",
"repo": "dmarcuse/rotmg-rs",
"path": "/rotmg_packets/src/raw.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Attempt to parse this raw packet into a structured packet using the
/// given mappings.
///
/// On success, the packet will be returned, along with any remaining bytes
/// that weren't captured (leftover bytes usually indicates out-of-date or
/// incorrect packet definitions). ... | code_fim | hard | {
"lang": "rust",
"repo": "dmarcuse/rotmg-rs",
"path": "/rotmg_packets/src/raw.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmarcuse/rotmg-rs path: /rotmg_packets/src/raw.rs
//! Raw, unparsed ROTMG packets.
//!
//! Raw packets represent packets that have been framed and decrypted so that
//! the binary payload and ID can be accessed, but aren't necessarily parsed.
//! These are primarily intended as an intermediary f... | code_fim | hard | {
"lang": "rust",
"repo": "dmarcuse/rotmg-rs",
"path": "/rotmg_packets/src/raw.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (module, info)
};
let base = info.lpBaseOfDll as usize;
let size = info.SizeOfImage as usize;
let module = Module {
module,
name: String::from(name),
base,
size,
end: base + size,
};
... | code_fim | hard | {
"lang": "rust",
"repo": "rkr35/blps",
"path": "/src/module.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rkr35/blps path: /src/module.rs
use std::mem::{self, MaybeUninit};
use thiserror::Error;
use winapi::shared::minwindef::HMODULE;
use winapi::um::{
libloaderapi::GetModuleHandleW,
processthreadsapi::GetCurrentProcess,
psapi::{GetModuleInformation, MODULEINFO},
};
#[macro_export]
mac... | code_fim | hard | {
"lang": "rust",
"repo": "rkr35/blps",
"path": "/src/module.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn apply_arg(&self, arg: lval::LVal) -> lval::LVal {
match self.get_top_arg_type(){
Some(required_type) =>
if required_type == arg.get_type(){
let mut new_func = self.clone();
new_func.sig.remove(0);
ne... | code_fim | hard | {
"lang": "rust",
"repo": "or1426/rust-logic",
"path": "/src/lval/lfunc/lfn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: or1426/rust-logic path: /src/lval/lfunc/lfn.rs
use ast;
use lval;
use lval::lfunc;
use lval::ltype;
use env;
use std::vec;
use std::option;
use std::string;
pub struct LFn{
tree: ast::Ast,
environment: env::Env,
sig: vec::Vec<ltype::LType>,
ret_type: ltype::LType,
applied_a... | code_fim | hard | {
"lang": "rust",
"repo": "or1426/rust-logic",
"path": "/src/lval/lfunc/lfn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: google/tock-on-titan path: /kernel/h1_syscalls/src/dcrypto_test.rs
// Copyright 2018 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
//
// https://w... | code_fim | medium | {
"lang": "rust",
"repo": "google/tock-on-titan",
"path": "/kernel/h1_syscalls/src/dcrypto_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub disputed: bool,
}
/// A single transaction meant to be readable by a human
#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone)]
pub struct HumanReadableTransaction {
/// Types including deposits, withdrawals, disputes, resolutions of disputes, and chargebacks
#[serde(rename = ... | code_fim | hard | {
"lang": "rust",
"repo": "scrblue/transaction-processor",
"path": "/src/model.rs",
"mode": "spm",
"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.