text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>impl From<u8> for ReportType {
fn from(val: u8) -> Self {
match val {
1 => ReportType::Input,
2 => ReportType::Output,
3 => ReportType::Feature,
_ => ReportType::Reserved(val),
}
}
}
#[derive(Debug, TryFromPrimitive)]
#[repr(u8)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "thalesfragoso/keykey",
"path": "/host/src/packets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
Self: Sized,
{
// Generally the needed vector capacity should be equal to
// the number of bytes
let v = Vec::<u8>::with_capacity(size_of::<Self>());
self.serialize_append(v)
}
}<|fim_prefix|>// repo: MihirLuthra/gnutella path: /src/transmittable/... | code_fim | medium | {
"lang": "rust",
"repo": "MihirLuthra/gnutella",
"path": "/src/transmittable/serializable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MihirLuthra/gnutella path: /src/transmittable/serializable.rs
use std::mem::size_of;
pub trait Serializable {
/// This is to be defined by the implementer such that
/// the serialized version of self extends the argument vector `v`.
/// In general, the the vector `v` received in the... | code_fim | medium | {
"lang": "rust",
"repo": "MihirLuthra/gnutella",
"path": "/src/transmittable/serializable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marshallpierce/base64-serde path: /tests/tests.rs
#![allow(clippy::box_collection)]
use base64::{engine::general_purpose::STANDARD, Engine};
use base64_serde::base64_serde_type;
use std::cell::RefCell;
base64_serde_type!(Base64Standard, STANDARD);
mod some_other_mod {
use base64::engine::... | code_fim | hard | {
"lang": "rust",
"repo": "marshallpierce/base64-serde",
"path": "/tests/tests.rs",
"mode": "psm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected = format!(
"{{\"bytes\":\"{}\"}}",
STANDARD.encode(b.bytes.borrow().as_slice())
);
let b2 = serde_json::from_str(&expected).unwrap();
assert_eq!(b, b2);
}
#[test]
fn serialize_with_u8_slice() {
let bytes = vec![0x00, 0x77, 0xFF];
let b = SliceHolder {... | code_fim | hard | {
"lang": "rust",
"repo": "marshallpierce/base64-serde",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b2 = serde_json::from_str(&s).unwrap();
assert_eq!(b, b2);
}
#[test]
fn fails_nicely_on_inappropriate_input() {
assert_eq!(
"invalid type: integer `1234`, expected base64 ASCII text at line 1 column 13",
format!(
"{}",
serde_json::from_str::<ByteHol... | code_fim | hard | {
"lang": "rust",
"repo": "marshallpierce/base64-serde",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MrKWatkins/rust-rendering path: /src/scene/mod.rs
mod attenuation;
pub use self::attenuation::Attenuation;
mod camera;
pub use self::camera::Camera;
<|fim_suffix|>mod scene;
pub use self::scene::*;
mod texture;
pub use self::texture::Texture;
pub mod io;<|fim_middle|>mod light;
pub use self:... | code_fim | medium | {
"lang": "rust",
"repo": "MrKWatkins/rust-rendering",
"path": "/src/scene/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod scene;
pub use self::scene::*;
mod texture;
pub use self::texture::Texture;
pub mod io;<|fim_prefix|>// repo: MrKWatkins/rust-rendering path: /src/scene/mod.rs
mod attenuation;
pub use self::attenuation::Attenuation;
mod camera;
pub use self::camera::Camera;
mod light;
pub use self::light::Light;... | code_fim | medium | {
"lang": "rust",
"repo": "MrKWatkins/rust-rendering",
"path": "/src/scene/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod material;
pub use self::material::Material;
mod object;
pub use self::object::Object;
mod scene;
pub use self::scene::*;
mod texture;
pub use self::texture::Texture;
pub mod io;<|fim_prefix|>// repo: MrKWatkins/rust-rendering path: /src/scene/mod.rs
mod attenuation;
pub use self::attenuation::Att... | code_fim | easy | {
"lang": "rust",
"repo": "MrKWatkins/rust-rendering",
"path": "/src/scene/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub unsafe fn xcb_xf86vidmode_get_monitor_alignment_pad_length (R : *get_monitor_reply) -> c_int;
pub unsafe fn xcb_xf86vidmode_get_monitor_alignment_pad_end (R : *get_monitor_reply) -> generic_iterator;
pub unsafe fn xcb_xf86vidmode_get_monitor_model (R : *get_monitor_reply) -> *c_char;
pub unsafe ... | code_fim | hard | {
"lang": "rust",
"repo": "mibitzi/rust-xcb",
"path": "/src/ffi/xf86vidmode.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mibitzi/rust-xcb path: /src/ffi/xf86vidmode.rs
> *get_mode_line_reply;
pub unsafe fn xcb_xf86vidmode_mod_mode_line_sizeof (_buffer : *c_void) -> c_int;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
* This form can be used only if the requ... | code_fim | hard | {
"lang": "rust",
"repo": "mibitzi/rust-xcb",
"path": "/src/ffi/xf86vidmode.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub unsafe fn xcb_xf86vidmode_validate_mode_line_sizeof (_buffer : *c_void) -> c_int;
/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
pub unsafe fn xcb_xf86vidmode_validate_mode_line (c : *connection,
s... | code_fim | hard | {
"lang": "rust",
"repo": "mibitzi/rust-xcb",
"path": "/src/ffi/xf86vidmode.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> A list of available devices.
// pub available_devices: Vec<CudaDevice>,
}<|fim_prefix|>// repo: jason-timios/parenchyma path: /src/frameworks/cuda/interface.rs
/// Provides the CUDA framework.
#[deri<|fim_middle|>ve(Debug)]
pub struct Cuda {
// /// | code_fim | easy | {
"lang": "rust",
"repo": "jason-timios/parenchyma",
"path": "/src/frameworks/cuda/interface.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jason-timios/parenchyma path: /src/frameworks/cuda/interface.rs
/// Provides the CUDA framework.
#[deri<|fim_suffix|>b available_devices: Vec<CudaDevice>,
}<|fim_middle|>ve(Debug)]
pub struct Cuda {
// /// A list of available devices.
// pu | code_fim | medium | {
"lang": "rust",
"repo": "jason-timios/parenchyma",
"path": "/src/frameworks/cuda/interface.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
n: usize,
a: [i64; n],
}
let mut acc = vec![0; n + 1];
for i in 0..n {
acc[i + 1] = acc[i] + a[i];
}
let mut max_x = 0;
let mut max_d = 0;
let mut x = 0;
for i in 1..=n {
max_d = max(max_d, acc[i]);
max_x = max(max_x, x ... | code_fim | medium | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc182/src/bin/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut max_x = 0;
let mut max_d = 0;
let mut x = 0;
for i in 1..=n {
max_d = max(max_d, acc[i]);
max_x = max(max_x, x + max_d);
x += acc[i];
}
println!("{}", max_x);
}<|fim_prefix|>// repo: likr/atcoder path: /abc182/src/bin/d.rs
use proconio::input;
#[all... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc182/src/bin/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likr/atcoder path: /abc182/src/bin/d.rs
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::u... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc182/src/bin/d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn from_str(src: &str) -> ::core::result::Result<Self, Self::Err> {
Ok(match src.to_lowercase().as_str() {
#(#cases)*
_ => return Err(::derive_more::FromStrError::new(#input_type_name)),
})
... | code_fim | hard | {
"lang": "rust",
"repo": "JelteF/derive_more",
"path": "/impl/src/from_str.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JelteF/derive_more path: /impl/src/from_str.rs
use crate::utils::{DeriveType, HashMap};
use crate::utils::{SingleFieldData, State};
use proc_macro2::TokenStream;
use quote::quote;
use syn::{parse::Result, DeriveInput};
/// Provides the hook to expand `#[derive(FromStr)]` into an implementation ... | code_fim | hard | {
"lang": "rust",
"repo": "JelteF/derive_more",
"path": "/impl/src/from_str.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NaomiLea/ji-cloud path: /frontend/apps/crates/entry/user/src/router.rs
use utils::routes::*;
use std::rc::Rc;
use wasm_bindgen::UnwrapThrowExt;
use web_sys::Url;
use futures_signals::{
map_ref,
signal::{Mutable, SignalExt, Signal}
};
use dominator::{Dom, html};
use crate::{
login::do... | code_fim | hard | {
"lang": "rust",
"repo": "NaomiLea/ji-cloud",
"path": "/frontend/apps/crates/entry/user/src/router.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eldruin/iaq-core-rs path: /src/device_impl.rs
use crate::{Error, IaqCore, Measurement};
use embedded_hal::blocking::i2c::Read;
const DEV_ADDR: u8 = 0x5A;
impl<E, I2C> IaqCore<I2C>
where
I2C: Read<Error = E>,
{
/// Create new instance of the iAQ-Core device.
pub fn new(i2c: I2C) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/iaq-core-rs",
"path": "/src/device_impl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the CO2 (ppm) equivalent prediction value
///
/// Returns `nb::Error::WouldBlock` in case the device reports a busy or warm up status.
pub fn co2(&mut self) -> nb::Result<u16, Error<E>> {
let mut data = [0; 3];
self.read(&mut data)?;
Ok((u16::from(data[0]) <... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/iaq-core-rs",
"path": "/src/device_impl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the TVOC (ppb) equivalent prediction value
///
/// Returns `nb::Error::WouldBlock` in case the device reports a busy or warm up status.
pub fn tvoc(&mut self) -> nb::Result<u16, Error<E>> {
let mut data = [0; 9];
self.read(&mut data)?;
Ok((u16::from(data[7])... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/iaq-core-rs",
"path": "/src/device_impl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = model.get_variable_by_name("a").unwrap();
let mut a = a.borrow_mut();
let b = model.get_variable_by_name("b").unwrap();
let mut b = b.borrow_mut();
assert_eq!(b.next(), 0);
assert_eq!(a.next(), 0);
assert_eq!(b.next(), 1);
assert_eq!(a.next(), 1);
assert_eq!(b.... | code_fim | hard | {
"lang": "rust",
"repo": "rfdonnelly/rvs",
"path": "/tests/variables_in_expressions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rfdonnelly/rvs path: /tests/variables_in_expressions.rs
#[test]
fn next() {
let model = rvs::parse(&Default::default(), "a = 1; b = a;").unwrap();
let b = model.get_variable_by_name("b").unwrap();
let mut b = b.borrow_mut();
assert_eq!(b.next(), 1);
}
/// Verifies that the und... | code_fim | hard | {
"lang": "rust",
"repo": "rfdonnelly/rvs",
"path": "/tests/variables_in_expressions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pczarn/panini path: /panini_codegen/src/rs.rs
#![allow(dead_code)]
use std::cell::RefCell;
// Public imports
pub use quote::ToTokens;
// pub use proc_macro2::Term;
pub use proc_macro2::Ident as Term;
pub use proc_macro2::{Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
// pub ... | code_fim | hard | {
"lang": "rust",
"repo": "pczarn/panini",
"path": "/panini_codegen/src/rs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn gensym(name: &str) -> Ident {
let counter = COUNTER.with(|c| {
*c.borrow_mut() += 1;
*c.borrow() - 1
});
let gen_name = format!("{}__{}", name, counter);
Ident::new(name, Span::call_site())
}
pub fn dummy_spanned<T>(elem: T) -> Spanned<T> {
respan(Span::call_sit... | code_fim | hard | {
"lang": "rust",
"repo": "pczarn/panini",
"path": "/panini_codegen/src/rs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BitSine/sinewave path: /src/test_commands/send_mod_log.rs
use serenity::{
client::Context,
framework::standard::{macros::command, CommandResult},
model::channel::Message,
};
#[command]
#[<|fim_suffix|>nd_mod_log(ctx: &Context, msg: &Message) -> CommandResult {
Ok(())
}<|fim_midd... | code_fim | medium | {
"lang": "rust",
"repo": "BitSine/sinewave",
"path": "/src/test_commands/send_mod_log.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>nd_mod_log(ctx: &Context, msg: &Message) -> CommandResult {
Ok(())
}<|fim_prefix|>// repo: BitSine/sinewave path: /src/test_commands/send_mod_log.rs
use serenity::{
client::Context,
framework::standard::{macros::<|fim_middle|>command, CommandResult},
model::channel::Message,
};
#[command... | code_fim | medium | {
"lang": "rust",
"repo": "BitSine/sinewave",
"path": "/src/test_commands/send_mod_log.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>only_in(guilds)]
#[required_permissions(ADMINISTRATOR)]
pub async fn send_mod_log(ctx: &Context, msg: &Message) -> CommandResult {
Ok(())
}<|fim_prefix|>// repo: BitSine/sinewave path: /src/test_commands/send_mod_log.rs
use serenity::{
client::Context,
framework::standard::{macros::<|fim_midd... | code_fim | medium | {
"lang": "rust",
"repo": "BitSine/sinewave",
"path": "/src/test_commands/send_mod_log.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
// enum Option<T> {
// Some(T),
// None
// }
let origin = Point {x: 0, y: 0};
let mut circ = Shape::Circle(origin, 10);
// circ = Shape::Ractangle(origin, origin);
}<|fim_prefix|>// repo: anildigital/rust_workshop path: /enums.rs
struct Point {
x: i32,... | code_fim | medium | {
"lang": "rust",
"repo": "anildigital/rust_workshop",
"path": "/enums.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anildigital/rust_workshop path: /enums.rs
struct Point {
x: i32,
y: i32
}
enum Shape {
Circle(Point, u32),
Rectangle(Point, Point)
}
<|fim_suffix|> // }
let origin = Point {x: 0, y: 0};
let mut circ = Shape::Circle(origin, 10);
// circ = Shape::Ractangle(origin... | code_fim | medium | {
"lang": "rust",
"repo": "anildigital/rust_workshop",
"path": "/enums.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // }
let origin = Point {x: 0, y: 0};
let mut circ = Shape::Circle(origin, 10);
// circ = Shape::Ractangle(origin, origin);
}<|fim_prefix|>// repo: anildigital/rust_workshop path: /enums.rs
struct Point {
x: i32,
y: i32
}
<|fim_middle|>enum Shape {
Circle(Point, u32),
Re... | code_fim | medium | {
"lang": "rust",
"repo": "anildigital/rust_workshop",
"path": "/enums.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::fs::read_to_string(file)
.unwrap()
.lines()
.map(|x| x.parse().unwrap())
.collect()
}<|fim_prefix|>// repo: Afterglow/aoc-2020 path: /day1-1/src/main.rs
use std::str::FromStr;
const TARGET: usize = 2020;
fn main() {
let mut numbers = read_lines::<usize>("input.txt")... | code_fim | hard | {
"lang": "rust",
"repo": "Afterglow/aoc-2020",
"path": "/day1-1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_lines<T: FromStr>(file: &str) -> Vec<usize> {
std::fs::read_to_string(file)
.unwrap()
.lines()
.map(|x| x.parse().unwrap())
.collect()
}<|fim_prefix|>// repo: Afterglow/aoc-2020 path: /day1-1/src/main.rs
use std::str::FromStr;
const TARGET: usize = 2020;
fn main() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Afterglow/aoc-2020",
"path": "/day1-1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Afterglow/aoc-2020 path: /day1-1/src/main.rs
use std::str::FromStr;
const TARGET: usize = 2020;
fn main() {
let mut numbers = read_lines::<usize>("input.txt");
// Put them into ascending order
numbers.sort_unstable();
// Flip it into descending order
numbers.reverse();
<|f... | code_fim | medium | {
"lang": "rust",
"repo": "Afterglow/aoc-2020",
"path": "/day1-1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use alloc::{MessageBuffer};
pub use error::{Error, Result};
pub use protocol::{
Pub, Sub,
Bus,
Req, Rep,
Push, Pull,
Surveyor, Respondent,
Pair,
SPSocket, SPRecv, SPSend, Loopback
};<|fim_prefix|>// repo: tmccombs/nmsg-rust path: /src/lib.rs
#![warn(missing_docs)]
//! Thi... | code_fim | medium | {
"lang": "rust",
"repo": "tmccombs/nmsg-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tmccombs/nmsg-rust path: /src/lib.rs
#![warn(missing_docs)]
//! This is a rust library for [Nanomsg](http://nanomsg.org/index.html).
//!
//! It is a wrapper around the C API that provides a more rusty interface.
//!
//! In particular this library provides:
//! * A [`MessageBuffer`](alloc/struct.... | code_fim | medium | {
"lang": "rust",
"repo": "tmccombs/nmsg-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fcard/MGL path: /src/resources/script.rs
use crate::ast::*;
#[derive(Debug, Clone, PartialEq)]
pub struct Script {
pub source: FunctionDeclaration,
pub kind: ScriptKind,
}
<|fim_suffix|>impl Script {
pub fn global(source: FunctionDeclaration) -> Script {
Script {
source,
... | code_fim | medium | {
"lang": "rust",
"repo": "fcard/MGL",
"path": "/src/resources/script.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn method(source: FunctionDeclaration, name: ResourceName) -> Script {
Script {
source,
kind: ScriptKind::Method(name)
}
}
}<|fim_prefix|>// repo: fcard/MGL path: /src/resources/script.rs
use crate::ast::*;
#[derive(Debug, Clone, PartialEq)]
pub struct Script {
pub source: ... | code_fim | hard | {
"lang": "rust",
"repo": "fcard/MGL",
"path": "/src/resources/script.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Script {
pub fn global(source: FunctionDeclaration) -> Script {
Script {
source,
kind: ScriptKind::Global
}
}
pub fn method(source: FunctionDeclaration, name: ResourceName) -> Script {
Script {
source,
kind: ScriptKind::Method(name)
}
}
}<|fim_prefix|>... | code_fim | medium | {
"lang": "rust",
"repo": "fcard/MGL",
"path": "/src/resources/script.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Set the entry point so we skip over any previously defined
// code. We have to keep that code around since it defines
// our function bodies, but we don't want to re-make the
// closures etc.
self.code.set_enter(self.code.len());
let mut tmp = BuildCode... | code_fim | hard | {
"lang": "rust",
"repo": "rcdomigan/atl-rs",
"path": "/src/rep.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcdomigan/atl-rs path: /src/rep.rs
// Read Eval (PYO Print)
use std::error::Error;
use std::fs::File;
use std::io::Read;
use std::mem::swap;
use std::path::Path;
use compile;
use compile::compile;
use lexical_scope::{scope, Environment};
use op_codes::BuildCode;
use parser;
use parser::{Parsed,... | code_fim | hard | {
"lang": "rust",
"repo": "rcdomigan/atl-rs",
"path": "/src/rep.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn evaluate(idx: usize, factions: &ReadStorage<Faction>, my_faction: &FactionName,
reactions: &mut Vec<(Entity, Reaction)>) {
crate::spatial::for_each_tile_content(idx, |other_entity| {
if let Some(faction) = factions.get(other_entity) {
reactions.push((
other_... | code_fim | hard | {
"lang": "rust",
"repo": "tnyjhnsn/rust-roguelike",
"path": "/server/src/ai/adjacent_ai_system.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tnyjhnsn/rust-roguelike path: /server/src/ai/adjacent_ai_system.rs
use specs::prelude::*;
use crate::{
MyTurn,
Faction,
FactionName,
Position,
Map,
WantsToMelee,
Reaction,
PlayerEntity,
raws::*,
};
pub struct AdjacentAI {}
impl<'a> System<'a> for AdjacentAI ... | code_fim | hard | {
"lang": "rust",
"repo": "tnyjhnsn/rust-roguelike",
"path": "/server/src/ai/adjacent_ai_system.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xanathar/quiche path: /src/recovery/nocc.rs
// Copyright (C) 2019, Cloudflare, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of so... | code_fim | hard | {
"lang": "rust",
"repo": "xanathar/quiche",
"path": "/src/recovery/nocc.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn on_packet_acked(
r: &mut Recovery, packet: &Acked, _epoch: packet::Epoch, _now: Instant,
) {
r.congestion_window = usize::max_value();
r.bytes_in_flight = r.bytes_in_flight.saturating_sub(packet.size);
}
fn congestion_event(
_r: &mut Recovery, _time_sent: Instant, _epoch: packet::Epoch... | code_fim | hard | {
"lang": "rust",
"repo": "xanathar/quiche",
"path": "/src/recovery/nocc.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn on_packet_sent(r: &mut Recovery, sent_bytes: usize, _now: Instant) {
r.congestion_window = usize::max_value();
r.bytes_in_flight += sent_bytes;
}
fn on_packet_acked(
r: &mut Recovery, packet: &Acked, _epoch: packet::Epoch, _now: Instant,
) {
r.congestion_window = usize::max_value();... | code_fim | hard | {
"lang": "rust",
"repo": "xanathar/quiche",
"path": "/src/recovery/nocc.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[rustc_abi(debug)]
fn test_generic<T>(_x: *const T) { } //~ ERROR: fn_abi
struct S(u16);
impl S {
#[rustc_abi(debug)]
fn assoc_test(&self) { } //~ ERROR: fn_abi
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/abi/debug.rs
// normalize-stderr-test "(abi|pref|unadjusted_abi_align): Align... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/abi/debug.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/abi/debug.rs
// normalize-stderr-test "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
// normalize-stderr-test "(size): Size\([48] bytes\)" -> "$1: $$SOME_SIZE"
// normalize-stderr-test "(can_unwind): (true|false)" -> "$1: $$SOME_BOOL"... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/abi/debug.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NJUPT-NYR/SOPT path: /backend/src/controller/tracker.rs
use super::*;
use crate::data::{
torrent_info as torrent_info_model, torrent_status as torrent_status_model, user as user_model,
user_info as user_info_model,
};
#[repr(C)]
#[derive(Deserialize, Debug, Copy, Clone)]
enum Action {
... | code_fim | hard | {
"lang": "rust",
"repo": "NJUPT-NYR/SOPT",
"path": "/backend/src/controller/tracker.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let status = data.action.clone().unwrap_or(Action::Start) as i32;
torrent_status_model::update_or_add_status(
&client,
data.tid,
data.uid,
status,
data.upload,
data.download,
)
.await?;
if data.action.is_some() {
match data.action... | code_fim | hard | {
"lang": "rust",
"repo": "NJUPT-NYR/SOPT",
"path": "/backend/src/controller/tracker.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut data = deserialize_from_req!(req, AnnouncePacket);
let torrent = torrent_info_model::find_torrent_by_id_mini(&client, data.tid).await?;
if torrent.free {
data.download = 0;
}
let current_status =
torrent_status_model::find_status_by_tid_uid(&client, data.tid, da... | code_fim | hard | {
"lang": "rust",
"repo": "NJUPT-NYR/SOPT",
"path": "/backend/src/controller/tracker.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/hackc/ir/assemble/assemble.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use std::io::Read;
use std::path::Path;
use std... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/hackc/ir/assemble/assemble.rs",
"mode": "psm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|> let src_loc = parse_src_loc(tokenizer, None)?;
self.src_loc = Some(src_loc);
Ok(())
}
fn parse_module(&mut self, tokenizer: &mut Tokenizer<'_>) -> Result<()> {
parse!(tokenizer, <name:parse_class_id> "[" <attributes:parse_attribute,*> "]");
let doc_comment... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/hackc/ir/assemble/assemble.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn parse_src_loc(&mut self, tokenizer: &mut Tokenizer<'_>) -> Result<()> {
let src_loc = parse_src_loc(tokenizer, None)?;
self.src_loc = Some(src_loc);
Ok(())
}
fn parse_module(&mut self, tokenizer: &mut Tokenizer<'_>) -> Result<()> {
pars... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/hackc/ir/assemble/assemble.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/byte-literals.rs
// run-pass
//
static FOO: u8 = b'\xF0';
static BAR: &'static [u8] = b"a\xF0\t";
static BAR_FIXED: &'static [u8; 3] = b"a\xF0\t";
static BAZ: &'static [u8] = br"a\n";
pub fn main() {
let bar: &'static [u8] = b"a\xF0\t";
... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/byte-literals.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let val = &[97u8, 10u8];
match val {
b"a\n" => {},
_ => panic!(),
}
let buf = vec![97u8, 98, 99, 100];
assert_eq!(match &buf[0..3] {
b"def" => 1,
b"abc" => 2,
_ => 3
}, 2);
let expected: &[_] = &[97u8, 92u8, 110u8];
assert_eq!(BA... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/byte-literals.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
io::stdin().read_line(&mut your_name).expect("Failure to input!");
println("It is a pleasure in meeting you! {}", your_name);
}<|fim_prefix|>// repo: LordAncientJewal/MyProjects path: /LambdaCode.rs
use std::io;
fn main() {
println!("Hello, I am Darryl Brown!!!")<|fim_middle|>;
println!(... | code_fim | medium | {
"lang": "rust",
"repo": "LordAncientJewal/MyProjects",
"path": "/LambdaCode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LordAncientJewal/MyProjects path: /LambdaCode.rs
use std::io;
fn main() {
println!("Hello, I am Darryl Brown!!!")<|fim_suffix|>);
println("It is a pleasure in meeting you! {}", your_name);
}<|fim_middle|>;
println!("Who are you?");
let mut your_name = String::new();
io::stdin(... | code_fim | medium | {
"lang": "rust",
"repo": "LordAncientJewal/MyProjects",
"path": "/LambdaCode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: terrehbyte/terry-learns-rust path: /2-structs/src/main.rs
// `fmt::Debug` is a trait that implements rudimentary printing capabilities
// This structure cannot be printed either with `fmt::Display` or with
// `fmt::Debug`
struct UnPrintable(i32);
// The `derive` attribute automatically create... | code_fim | hard | {
"lang": "rust",
"repo": "terrehbyte/terry-learns-rust",
"path": "/2-structs/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main()
{
// We can pass in an instance of `Structure` for printing!
//
// Printing with `{:?}` is similar to printing with `{}`.
println!("1. Now {:?} will print!", Structure(3));
// Results in...
/*
1. Now Structure(3) will print!
*/
// The problem with `derive... | code_fim | hard | {
"lang": "rust",
"repo": "terrehbyte/terry-learns-rust",
"path": "/2-structs/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dandels/dmodman path: /src/api/query/mod.rs
pub mod download_link;
pub mod file_details;
pub mod file_list;
pub mod games;
pub mod md5_sea<|fim_suffix|>md5_search::*;
pub use self::mod_info::*;
pub use self::queriable::*;
pub use self::search::*;<|fim_middle|>rch;
pub mod mod_info;
pub mod queri... | code_fim | medium | {
"lang": "rust",
"repo": "dandels/dmodman",
"path": "/src/api/query/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>md5_search::*;
pub use self::mod_info::*;
pub use self::queriable::*;
pub use self::search::*;<|fim_prefix|>// repo: dandels/dmodman path: /src/api/query/mod.rs
pub mod download_link;
pub mod file_details;
pub mod file_list;
pub mod games;
pub mod md5_search;
pub mod mod_info;
pub mod queriable;
pub mod ... | code_fim | medium | {
"lang": "rust",
"repo": "dandels/dmodman",
"path": "/src/api/query/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: floric/secret-clan path: /backend/src/model/proto/message.rs
.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for Server_SelfUpdated {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "floric/secret-clan",
"path": "/backend/src/model/proto/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(Server_oneof_message::playerUpdated(ref v)) = self.message {
if !v.is_initialized() {
return false;
}
}
if let Some(Server_oneof_message::gameUpdated(ref v)) = self.message {
if !v.is_initialized() {
re... | code_fim | hard | {
"lang": "rust",
"repo": "floric/secret-clan",
"path": "/backend/src/model/proto/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ::std::fmt::Debug for Server_PlayerLeft {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for Server_PlayerLeft {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
... | code_fim | hard | {
"lang": "rust",
"repo": "floric/secret-clan",
"path": "/backend/src/model/proto/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let low: String;
let fields: Vec<&str> = match &c.fields {
None => Vec::new(),
Some(v) => {
low = v.trim_start_matches(|c: char| c == ' ' || c == '=').to_lowercase();
low.split(|c: char| c == ',' || c == ':').collect()
}
};
if !fields.is_emp... | code_fim | hard | {
"lang": "rust",
"repo": "VladimirMarkelov/todo_lib",
"path": "/src/tsort.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VladimirMarkelov/todo_lib path: /src/tsort.rs
use std::cmp::Ordering;
use crate::timer;
use crate::todo;
use crate::todotxt;
/// Sorting rules. First, the list of todos is sorted by the fields defined
/// in `fields` in order of appearance. Then, if `rev` is `true` the list is
/// reversed
#[d... | code_fim | hard | {
"lang": "rust",
"repo": "VladimirMarkelov/todo_lib",
"path": "/src/tsort.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !fields.is_empty() {
ids.sort_by(|a, b| {
if *a >= todos.len() && *b >= todos.len() {
return Ordering::Equal;
} else if *a >= todos.len() {
return Ordering::Greater;
} else if *b >= todos.len() {
return Orde... | code_fim | hard | {
"lang": "rust",
"repo": "VladimirMarkelov/todo_lib",
"path": "/src/tsort.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buf = String::new();
File::open(path)
.context(format!("opening configuration file {:?}", &path))?
.read_to_string(&mut buf)
.context("reading configuration file")?;
Ok(serde_yaml::from_str(&buf).context("parsing the YAML configuration")... | code_fim | hard | {
"lang": "rust",
"repo": "LucioFranco/sendgrid-amqp-bridge",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Config {
/// Load configuration from filesystem. The file is expected to be
/// YAML compatible.
pub(crate) fn load(path: &Path, logger: &slog::Logger) -> Result<Self, failure::Error> {
debug!(logger, "Loading configuration file {:?}", &path);
let mut buf = String::new();... | code_fim | medium | {
"lang": "rust",
"repo": "LucioFranco/sendgrid-amqp-bridge",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LucioFranco/sendgrid-amqp-bridge path: /src/config.rs
// Copyright (C) 2018 O.S. Systems Sofware LTDA
//
// SPDX-License-Identifier: MIT
use crate::{amqp::AMQP, sendgrid::SendGrid};
use failure::ResultExt;
use serde::Deserialize;
use slog::debug;
use std::{fs::File, io::Read, path::Path};
#[de... | code_fim | hard | {
"lang": "rust",
"repo": "LucioFranco/sendgrid-amqp-bridge",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gina-stoffel/riscv-pk path: /sm_rs/mprv.rs
use core::mem::{size_of, transmute};
use core::marker::PhantomData;
use core::slice;
use util::ctypes::*;
#[repr(transparent)]
#[derive(Copy, Clone)]
#[allow(non_camel_case_types)]
pub struct sptr<T> {
ptr: usize,
_type: PhantomData<T>,
}
imp... | code_fim | hard | {
"lang": "rust",
"repo": "gina-stoffel/riscv-pk",
"path": "/sm_rs/mprv.rs",
"mode": "psm",
"license": "LicenseRef-scancode-bsd-3-clause-jtag",
"source": "the-stack-v2"
} |
<|fim_suffix|> while src.len() >= 8 {
unsafe {
let res = copy8_from_sm(dst.cast(), src.as_ptr() as *const u64);
if res != 0 { return Err(()) }
dst.seek(8);
}
src = &src[8..];
}
}
while src.len() > 0 {
un... | code_fim | hard | {
"lang": "rust",
"repo": "gina-stoffel/riscv-pk",
"path": "/sm_rs/mprv.rs",
"mode": "spm",
"license": "LicenseRef-scancode-bsd-3-clause-jtag",
"source": "the-stack-v2"
} |
<|fim_suffix|> let caps = match regex.captures(content) {
Some(caps) => caps,
None => return append_text_message(msg),
};
let url = caps.get(1).unwrap().as_str().to_owned();
let msg = msg.clone();
thread::spawn(move || {
let mut headers = Headers::new();
headers.set... | code_fim | hard | {
"lang": "rust",
"repo": "stamhe/pidgin-wechat",
"path": "/src/server.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stamhe/pidgin-wechat path: /src/server.rs
efresh_chat_members(chat: &str) {
let wechat = WECHAT.read().unwrap();
let chat = wechat.find_chat_by_id(chat).unwrap();
let conv = conversion(PURPLE_CONV_TYPE_CHAT, &chat.id());
let conv_chat = purple_conversation_get_chat_data(conv);
... | code_fim | hard | {
"lang": "rust",
"repo": "stamhe/pidgin-wechat",
"path": "/src/server.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stamhe/pidgin-wechat path: /src/server.rs
ert("BaseRequest".to_owned(), Value::Object(base_obj));
Value::Object(obj)
}
fn status_notify_data(&self) -> Value {
let mut value = self.base_data();
value["Code"] = json!(3);
value["FromUserName"] = json!(sel... | code_fim | hard | {
"lang": "rust",
"repo": "stamhe/pidgin-wechat",
"path": "/src/server.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> Pack(StructName, Vec<BaseType>, Vec<(Field, BaseType, Exp)>),
ExpList(Vec<ExpListItem>),
Borrow(bool, Box<Exp>, Field),
BorrowLocal(bool, Var),
UnresolvedError,
}
pub type UnannotatedExp = Spanned<UnannotatedExp_>;
#[derive(Debug, PartialEq)]
pub struct Exp {
pub ty: Type,
pu... | code_fim | hard | {
"lang": "rust",
"repo": "osde8info/libra",
"path": "/language/move-lang/src/hlir/ast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osde8info/libra path: /language/move-lang/src/hlir/ast.rs
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::shared::unique_map::UniqueMap;
use crate::{
naming::ast::{BuiltinTypeName_, TParam, TypeName, TypeName_},
parser::ast::{
BinOp... | code_fim | hard | {
"lang": "rust",
"repo": "osde8info/libra",
"path": "/language/move-lang/src/hlir/ast.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/arc149/src/bin/a/main.rs
use proconio::input;
fn main() {
input! {
n: usize,
m: usize,
};
let mut rep = vec![[0; 10]; n];
for d in 1..=9 {
rep[0][d] = d % m;
}
for i in 1..n {
for d in 1..=9 {
... | code_fim | medium | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/arc149/src/bin/a/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>.to_string().repeat(i + 1);
println!("{}", x);
return;
}
}
}
println!("-1");
}<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/arc149/src/bin/a/main.rs
use proconio::input;
fn main() {
input! {
n: usize,
m... | code_fim | medium | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/arc149/src/bin/a/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unsafe_code)]
#![allow(unused_imports)]
#![allow(unused_results)]
mod inner {
include!(concat!(env!("OUT_D... | code_fim | medium | {
"lang": "rust",
"repo": "arifai/mainframe.rf",
"path": "/src/protos/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arifai/mainframe.rf path: /src/protos/mod.rs
//! Wrapper untuk meng-import struct dari protobuf autogenerated output files.
//!
<|fim_suffix|>mod inner {
include!(concat!(env!("OUT_DIR"), "/$name_snake_case$.rs"));
}
pub use self::inner::{$param.service_name_camel_case$};<|fim_middle|>#![... | code_fim | hard | {
"lang": "rust",
"repo": "arifai/mainframe.rf",
"path": "/src/protos/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Read CONFIG File
print!(" Reading {}...", file_name);
let config_txt = root.open_file(file_name).unwrap();
//loop {}
//println!("{}", config_txt.len());
let mut buf = vec![0u8; config_txt.len()];
config_txt.read(&mut buf).unwrap();
let config = Config::new(core::str::fr... | code_fim | hard | {
"lang": "rust",
"repo": "o8vm/krabs",
"path": "/src/bios/stage_4th/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: o8vm/krabs path: /src/bios/stage_4th/src/main.rs
#![feature(llvm_asm)]
#![no_std]
#![no_main]
extern crate alloc;
extern crate rlibc;
#[macro_use]
use alloc::vec;
use stage_4th::fs::{fat32::FileSystem, gpt::GPT};
use stage_4th::{
clear_bss,
loader::{config::Config, load_elf, load_items,... | code_fim | hard | {
"lang": "rust",
"repo": "o8vm/krabs",
"path": "/src/bios/stage_4th/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Arbiter::spawn_fn(move || {
addr.send(Get { key: "test".into() }).then(|res| {
match res {
Ok(Err(Error::NotConnected)) => (),
_ => panic!("Should not happen {:?}", res),
}
System::current().stop();
Ok(())
... | code_fim | hard | {
"lang": "rust",
"repo": "KeenS/actix-redis-cluster",
"path": "/tests/test_redis.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KeenS/actix-redis-cluster path: /tests/test_redis.rs
extern crate redis_async;
use actix::prelude::*;
use actix_redis::{command::*, Error, RedisActor};
use futures::Future;
#[test]
fn test_error_connect() -> std::io::Result<()> {
let sys = System::new("test");
<|fim_suffix|> Arbiter::s... | code_fim | hard | {
"lang": "rust",
"repo": "KeenS/actix-redis-cluster",
"path": "/tests/test_redis.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmgolembiowski/pty-rs path: /tests/it_fork_with_new_pty.rs
use pty;
use self::pty::prelude::*;
use std::io::prelude::*;
use std::process::{Command, Stdio};
use std::string::String;
#[test]
fn it_fork_with_new_pty() {
let fork = Fork::from_ptmx().unwrap();
if let Some(mut master) = fo... | code_fim | medium | {
"lang": "rust",
"repo": "dmgolembiowski/pty-rs",
"path": "/tests/it_fork_with_new_pty.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output = Command::new("tty")
.stdin(Stdio::inherit())
.output()
.unwrap()
.stdout;
let output_str = String::from_utf8_lossy(&output);
let parent_tty = output_str.trim();
let child_tty = string.trim();
assert!(chi... | code_fim | hard | {
"lang": "rust",
"repo": "dmgolembiowski/pty-rs",
"path": "/tests/it_fork_with_new_pty.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(child_tty != "");
assert!(child_tty != parent_tty);
// only compare if parent is tty
// travis runs the tests without tty
if parent_tty != "not a tty" {
let mut parent_tty_dir: Vec<&str> = parent_tty.split("/").collect();
let mut chi... | code_fim | hard | {
"lang": "rust",
"repo": "dmgolembiowski/pty-rs",
"path": "/tests/it_fork_with_new_pty.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: staticgc/warlock path: /keyvalue/src/sqlite.rs
use std::sync::Arc;
use std::path::{PathBuf, Path};
use rusqlite::{params, Connection, NO_PARAMS};
use parking_lot::Mutex;
use crate::{Error, KeyValue};
#[derive(Clone)]
pub struct SqliteDB {
dbpath: PathBuf,
db: Arc<Mutex<Connection>>,
}... | code_fim | hard | {
"lang": "rust",
"repo": "staticgc/warlock",
"path": "/keyvalue/src/sqlite.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rows = stmt.query(params![ver, key]).map_err(|e| Error::impl_err(e.to_string()))?;
match rows.next().map_err(|e| Error::impl_err(e.to_string()))? {
None => {
Ok(None)
}
Some(row) => {
let buf: Vec<u8> = row.get(2).... | code_fim | hard | {
"lang": "rust",
"repo": "staticgc/warlock",
"path": "/keyvalue/src/sqlite.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MnO2/kvs path: /src/record.rs
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
// TODO: add CRC32
pub(crate) struct Record {
pub(crate) timestamp: u64,
pub(crate) tombstone: u8,
pub(crate) key: String,
pub(cr<|fim_suffix|>,
tombstone: 0,
... | code_fim | medium | {
"lang": "rust",
"repo": "MnO2/kvs",
"path": "/src/record.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ate) value: String,
}
impl Record {
pub(crate) fn new() -> Self {
Record {
timestamp: 0,
tombstone: 0,
key: "".to_string(),
value: "".to_string(),
}
}
}<|fim_prefix|>// repo: MnO2/kvs path: /src/record.rs
use serde::{Deserialize, Se... | code_fim | medium | {
"lang": "rust",
"repo": "MnO2/kvs",
"path": "/src/record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akitsu-sanae/mumrik path: /src/command/build.rs
use ast;
use codegen;
use command::Command;
use config;
use parser;
use std::collections::VecDeque;
use std::path::PathBuf;
use typecheck;
use util;
pub struct BuildCommand {
pub src: Option<PathBuf>,
pub output: Option<PathBuf>,
}
fn pri... | code_fim | hard | {
"lang": "rust",
"repo": "akitsu-sanae/mumrik",
"path": "/src/command/build.rs",
"mode": "psm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut path = import.dirs.into_iter().fold(path, |mut acc, dir| {
acc.push(format!("{}", dir));
acc
});
path.push(format!("{}.mm", import.module_name));
path
}
fn imported_filepath(entry_modules: &Vec<PathBuf>, import: ast::Import) -> Option<PathBuf> {
for entry_modul... | code_fim | hard | {
"lang": "rust",
"repo": "akitsu-sanae/mumrik",
"path": "/src/command/build.rs",
"mode": "spm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Happy-Ferret/reproto path: /lib/backend-java/src/jackson.rs
//! Module that adds fasterxml annotations to generated classes.
use backend::errors::*;
use genco::{Cons, Element, IntoTokens, Java, Quoted, Tokens};
use genco::java::{Argument, Class, DOUBLE, FLOAT, Field, INTEGER, LONG, Modifier, SH... | code_fim | hard | {
"lang": "rust",
"repo": "Happy-Ferret/reproto",
"path": "/lib/backend-java/src/jackson.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> spec.body.push(serializer);
let deserializer = self.tuple_deserializer(spec.name(), &mut spec.fields)?;
let deserializer_type = Rc::new(format!(
"{}.{}",
spec.name().as_ref(),
deserializer.name().as_ref()
));
let deserialize =
... | code_fim | hard | {
"lang": "rust",
"repo": "Happy-Ferret/reproto",
"path": "/lib/backend-java/src/jackson.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/unsized2.rs
// run-pass
#![allow(unconditional_recursion)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![feature(box_syntax)]
// Test sized-ness checking in substitution.
use std::marker;
// Unbounded.
fn f1<X... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/unsized2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.