text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: deontologician/rapier path: /src_testbed/objects/node.rs
use bevy::prelude::*;
use bevy::render::mesh::{Indices, VertexAttributeValues};
//use crate::objects::plane::Plane;
use na::{point, Point3, Vector3};
use std::collections::HashMap;
use bevy::render::pipeline::PrimitiveTopology;
use bevy:... | code_fim | hard | {
"lang": "rust",
"repo": "deontologician/rapier",
"path": "/src_testbed/objects/node.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = vertices.len();
let idx = (1..n as u32 - 1).map(|i| [0, i, i + 1]).collect();
let vtx = vertices
.into_iter()
.map(|v| Point3::new(v.x, v.y, 0.0))
.collect();
bevy_mesh((vtx, idx))
}
#[cfg(feature = "dim2")]
fn bevy_polyline(buffers: (Vec<Point2<f32>>, Opti... | code_fim | hard | {
"lang": "rust",
"repo": "deontologician/rapier",
"path": "/src_testbed/objects/node.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn limit_does_not_apply_when_cond_var_is_not_set() {
let limit = Limit::new("test_namespace", 10, 60, vec!["x == 5"], vec!["y"]);
// Notice that "x" is not set
let mut values: HashMap<String, String> = HashMap::new();
values.insert("a".into(), "1".into());
... | code_fim | hard | {
"lang": "rust",
"repo": "pwright/kuadrant",
"path": "/subrepos/limitador/limitador/src/limit.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut values: HashMap<String, String> = HashMap::new();
values.insert("x".into(), "5".into());
values.insert("y".into(), "1".into());
assert!(limit.applies(&values))
}
#[test]
fn limit_does_not_apply_when_cond_is_false() {
let limit = Limit::new("tes... | code_fim | hard | {
"lang": "rust",
"repo": "pwright/kuadrant",
"path": "/subrepos/limitador/limitador/src/limit.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pwright/kuadrant path: /subrepos/limitador/limitador/src/limit.rs
use serde::{Deserialize, Serialize, Serializer};
use std::collections::{BTreeSet, HashMap, HashSet};
use std::fmt::Error;
use std::hash::{Hash, Hasher};
use std::str::FromStr;
#[derive(Debug, Hash, Eq, PartialEq, Clone, Serialize... | code_fim | hard | {
"lang": "rust",
"repo": "pwright/kuadrant",
"path": "/subrepos/limitador/limitador/src/limit.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: txstate-etc/redirector path: /health/src/main.rs
#[macro_use] extern crate lazy_static;
use std::fmt;
use std::env;
use hyper::{Client, StatusCode, Uri};
use std::error::Error;
// LOCATION is what should be found in the location header returned back from redirector;
// example: LOCATION=https:/... | code_fim | hard | {
"lang": "rust",
"repo": "txstate-etc/redirector",
"path": "/health/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Error for HealthCheckError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
HealthCheckError::NonRedirect(_status_code) => None,
HealthCheckError::InvalidLocation(_location) => None,
HealthCheckError::UnreadableLocation(error) => Some... | code_fim | hard | {
"lang": "rust",
"repo": "txstate-etc/redirector",
"path": "/health/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ozkriff/ggez_assets_test path: /src/main.rs
extern crate ggez;
use ggez::{
conf, event,
event::EventHandler,
graphics, {Context, ContextBuilder, GameResult},
};
struct Assets {
player_image: graphics::Image,
}
<|fim_suffix|> graphics::clear(ctx);
let dst = graph... | code_fim | hard | {
"lang": "rust",
"repo": "ozkriff/ggez_assets_test",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cb = ContextBuilder::new("Game", "ggez")
.add_resource_path("resources")
.window_setup(conf::WindowSetup::default().title("Game Title"))
.window_mode(conf::WindowMode::default().dimensions(700, 700));
let ctx = cb.build().unwrap();
let state = MainState::new(&mut ct... | code_fim | hard | {
"lang": "rust",
"repo": "ozkriff/ggez_assets_test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> graphics::clear(ctx);
let dst = graphics::Point2::new(20.0, 20.0);
graphics::draw(ctx, &self.assets.player_image, dst, 0.0)?;
graphics::present(ctx);
Ok(())
}
}
fn main() {
let cb = ContextBuilder::new("Game", "ggez")
.add_resource_path("resources")... | code_fim | hard | {
"lang": "rust",
"repo": "ozkriff/ggez_assets_test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)]
pub struct SettingsKrb5Domain {
/// Specifies the name of the realm.
#[serde(rename = "realm")]
pub realm: Option<String>,
}<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/settings_krb5_domain.rs
/// SettingsKrb5Domain : Specifies the Kerb... | code_fim | easy | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/settings_krb5_domain.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/settings_krb5_domain.rs
/// SettingsKrb5Domain : Specifies the Kerberos settings for domain-realm mappings.
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)]
pub struct SettingsKrb5Domain {
/// Specifies the name of the realm.
#[serde(rename = ... | code_fim | easy | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/settings_krb5_domain.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlterionX/benxu-dev path: /crypto/src/token/paseto/v2/public/error.rs
use crate::token::paseto::token::{DeserializeError, UnpackingError};
#[derive(Debug)]
pub enum Error {
// Encrypt
Serialization,
Signing,
// Decrypt
Unpack,
BadSignature,
Decryption,
Deserializ... | code_fim | medium | {
"lang": "rust",
"repo": "AlterionX/benxu-dev",
"path": "/crypto/src/token/paseto/v2/public/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Error::Serialization
}
}
impl From<UnpackingError> for Error {
fn from(_: UnpackingError) -> Self {
Error::Unpack
}
}
impl From<DeserializeError> for Error {
fn from(_: DeserializeError) -> Self {
Error::Deserialize
}
}<|fim_prefix|>// repo: AlterionX/benxu-dev ... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/benxu-dev",
"path": "/crypto/src/token/paseto/v2/public/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytebuddha/wasm-block-editor path: /examples/editor/src/app.rs
use yew::prelude::*;
use wasm_block_editor::*;
use wasm_block_editor::components::{Editor, SimpleRenderer};
pub struct App {
_link: ComponentLink<Self>,
document: Document
}
pub enum Msg {
}
impl Component for App {
t... | code_fim | hard | {
"lang": "rust",
"repo": "bytebuddha/wasm-block-editor",
"path": "/examples/editor/src/app.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![
Block {
container_id: None,
container_tag: None,
container_class: None,
container_style: None,
class: None,
style: None,
id: None,
content: BlockContent::Heading { level: HeadingLevel::H1, tex... | code_fim | hard | {
"lang": "rust",
"repo": "bytebuddha/wasm-block-editor",
"path": "/examples/editor/src/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> html! {
<Editor<SimpleRenderer> document=self.document.clone() renderer=SimpleRenderer />
}
}
}
fn get_document() -> Document {
Document {
container_class: None,
container_id: None,
container_style: None,
container_tag: None,
blo... | code_fim | hard | {
"lang": "rust",
"repo": "bytebuddha/wasm-block-editor",
"path": "/examples/editor/src/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> W(writer)
}
}
#[doc = "Field `CLKPSC` reader - PWM Counter Clock Prescale \nThe clock of PWM counter is decided by clock prescaler. Each PWM pair share one PWM counter clock prescaler. The clock of PWM counter is divided by (CLKPSC+ 1)."]
pub struct CLKPSC_R(crate::FieldReader<u16, u16>);
impl... | code_fim | hard | {
"lang": "rust",
"repo": "gsuyemoto/M031AE-rs",
"path": "/src/pwm1/pwm_clkpsc2_3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gsuyemoto/M031AE-rs path: /src/pwm1/pwm_clkpsc2_3.rs
#[doc = "Register `PWM_CLKPSC2_3` reader"]
pub struct R(crate::R<PWM_CLKPSC2_3_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<PWM_CLKPSC2_3_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
... | code_fim | hard | {
"lang": "rust",
"repo": "gsuyemoto/M031AE-rs",
"path": "/src/pwm1/pwm_clkpsc2_3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::*;
use arrayvec::ArrayString;
use core::fmt::Write;
#[test]
fn test_debug_no_value() {
let mut buf = ArrayString::<20>::new();
write!(&mut buf, "{:?}", Response::Ok).expect("Can't write");
assert_eq!(&buf, "Ok");
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "drogue-iot/drogue-device-ng",
"path": "/device/src/drivers/wifi/esp8266/protocol.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match code {
1 => WifiConnectionFailure::Timeout,
2 => WifiConnectionFailure::WrongPassword,
3 => WifiConnectionFailure::CannotFindTargetAp,
_ => WifiConnectionFailure::ConnectionFailed,
}
}
}
/// Dump some data, which is stored in a buf... | code_fim | hard | {
"lang": "rust",
"repo": "drogue-iot/drogue-device-ng",
"path": "/device/src/drivers/wifi/esp8266/protocol.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drogue-iot/drogue-device-ng path: /device/src/drivers/wifi/esp8266/protocol.rs
use super::BUFFER_LEN;
use crate::traits::ip::{IpAddress, IpAddressV4, SocketAddress};
use core::fmt;
use core::fmt::{Debug, Write};
use heapless::String;
#[derive(Debug)]
pub struct ResolverAddresses {
pub resol... | code_fim | hard | {
"lang": "rust",
"repo": "drogue-iot/drogue-device-ng",
"path": "/device/src/drivers/wifi/esp8266/protocol.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeremyletang/rustenstein3D path: /src/rustenstein3D.rs
#![license = "MIT"]
#![crate_type = "bin"]
#![feature(globs)]
#![feature(managed_boxes)]
#![allow(non_camel_case_types)]
#![allow(visible_private_types)]
#![allow(dead_code)]
#![allow(non_snake_case)]
extern crate native;
extern crate rsfm... | code_fim | hard | {
"lang": "rust",
"repo": "jeremyletang/rustenstein3D",
"path": "/src/rustenstein3D.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create the render_window.
let settings = ContextSettings::default();
let video_mode = VideoMode::new_init(width, height, 32);
// let video_mode = VideoMode::new_init(512, 384, 32);
let mut render_window = RenderWindow::new(video_mode,
"R... | code_fim | hard | {
"lang": "rust",
"repo": "jeremyletang/rustenstein3D",
"path": "/src/rustenstein3D.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jasperav/cdrs-tokio path: /tests/user_defined_types.rs
mod common;
#[cfg(feature = "e2e-tests")]
use common::*;
#[cfg(feature = "e2e-tests")]
use cdrs_tokio::error::Result;
#[cfg(feature = "e2e-tests")]
use cdrs_tokio::frame::AsBytes;
#[cfg(feature = "e2e-tests")]
use cdrs_tokio::query::QueryE... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs-tokio",
"path": "/tests/user_defined_types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Debug, Clone, PartialEq)]
struct MyInnerUdt {
pub my_text: String,
}
impl MyInnerUdt {
pub fn try_from(udt: Udt) -> Result<MyInnerUdt> {
let my_text: String = udt.get_r_by_name("my_text")?;
Ok(MyInnerUdt { my_text })
}
}
im... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs-tokio",
"path": "/tests/user_defined_types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn unmap_memory_pre(_range: &MemoryRange) -> core::result::Result<(), Error> {
Ok(())
}
pub fn unmap_memory_post(range: MemoryRange) -> core::result::Result<(), Error> {
let layout = Layout::from_size_align(range.len(), 4096).unwrap();
let ptr = range.as_mut_ptr();
unsafe { dealloc(pt... | code_fim | hard | {
"lang": "rust",
"repo": "betrusted-io/xous-core",
"path": "/xous-rs/src/arch/test/mem.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: betrusted-io/xous-core path: /xous-rs/src/arch/test/mem.rs
use crate::{Error, MemoryAddress, MemoryFlags, MemoryRange};
extern crate alloc;
use alloc::alloc::{alloc, dealloc, Layout};
pub fn map_memory_pre(
_phys: &Option<MemoryAddress>,
_virt: &Option<MemoryAddress>,
_size: usize,... | code_fim | medium | {
"lang": "rust",
"repo": "betrusted-io/xous-core",
"path": "/xous-rs/src/arch/test/mem.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use clap::{App, Arg, SubCommand};
use env_logger::Builder;
use log::LevelFilter;
use std::io::Write;
fn main() {
let mut builder = Builder::from_default_env();
if std::env::var("RUST_LOG").is_err() {
builder
.format(|buf, record| writeln!(buf, "{}", record.args()))
... | code_fim | medium | {
"lang": "rust",
"repo": "rlay-project/rlay-client",
"path": "/rlay-client/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rlay-project/rlay-client path: /rlay-client/src/main.rs
#![warn(clippy::perf)]
#![recursion_limit = "128"]
#[macro_use]
extern crate failure;
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
extern crate static_assertions as sa;
<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "rlay-project/rlay-client",
"path": "/rlay-client/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(matches) = matches.subcommand_matches("client") {
let config_path = matches.value_of("config_path");
let config = config::Config::from_path_opt(config_path).expect("Couldn't read config file");
config.init_data_dir().unwrap();
sync::run_sync(&config);
} ... | code_fim | hard | {
"lang": "rust",
"repo": "rlay-project/rlay-client",
"path": "/rlay-client/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ExPixel/miniaudio-rs path: /miniaudio-sys/build.rs
#[allow(unused_macros)]
macro_rules! warn {
($fmt:literal $(,$arg:expr)*) => {
println!(concat!("cargo-warning=", $fmt) $(,$arg)*)
};
}
pub fn main() {
let mut cc_builder = cc::Build::new();
cc_builder.cpp(false).define(... | code_fim | hard | {
"lang": "rust",
"repo": "ExPixel/miniaudio-rs",
"path": "/miniaudio-sys/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ma_android {
support_aaudio = true;
support_opensl = true;
}
// FIXME change this to ma_bsd whenever miniaudio decides to do it as well.
if ma_openbsd {
// SNDIO is only supported on OpenBSD for now. May be... | code_fim | hard | {
"lang": "rust",
"repo": "ExPixel/miniaudio-rs",
"path": "/miniaudio-sys/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zaksky7/Rust-project path: /src/year2020/day17.rs
use ahash::{AHashMap, AHashSet};
use itertools::Itertools;
fn solve(s: &str, dim: usize) -> usize {
let mut on_cubes: AHashSet<Vec<i64>> = s
.lines()
.enumerate()
.flat_map(|(y, row)| {
row.chars()
... | code_fim | hard | {
"lang": "rust",
"repo": "zaksky7/Rust-project",
"path": "/src/year2020/day17.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>collect();
let p2 = m
.iter()
.filter(|&(pos, v)| !on_cubes.contains(pos) && v == &3)
.map(|(pos, _)| pos.clone())
.collect();
on_cubes = p1.union(&p2).cloned().collect();
}
on_cubes.len()
}
pub fn part1(input: &str) -> usize {
s... | code_fim | hard | {
"lang": "rust",
"repo": "zaksky7/Rust-project",
"path": "/src/year2020/day17.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TypingData {
pub fn as_vec(&self) -> Vec<char> {
self.data.clone()
}
}
impl Display for TypingData {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.data.iter().collect::<String>())
}
}
impl<S> From<S> for TypingData
where
S: Into<... | code_fim | hard | {
"lang": "rust",
"repo": "TilBlechschmidt/thirtyfour",
"path": "/src/common/keys.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TilBlechschmidt/thirtyfour path: /src/common/keys.rs
use std::{
fmt::{self, Display},
ops::Add,
};
pub enum Keys {
Null,
Cancel,
Help,
Backspace,
Tab,
Clear,
Return,
Enter,
Shift,
Control,
Alt,
Pause,
Escape,
Space,
PageUp,
... | code_fim | hard | {
"lang": "rust",
"repo": "TilBlechschmidt/thirtyfour",
"path": "/src/common/keys.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix/src/repository/init.rs
use std::cell::RefCell;
impl crate::Repository {
#[allow(clippy::too_many_arguments)]
pub(crate) fn from_refs_and_objects(
refs: crate::RefStore,
mut objects: crate::OdbHandle,
work_tree: Option<std::path::PathBuf>... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix/src/repository/init.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg_attr(not(feature = "max-performance-safe"), allow(unused_variables, unused_mut))]
pub(crate) fn setup_objects(objects: &mut crate::OdbHandle, config: &crate::config::Cache) {
#[cfg(feature = "max-performance-safe")]
{
match config.pack_cache_bytes {
None => match config.s... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix/src/repository/init.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(modifier) = modifier_applied.as_opt() {
world.modify_with_desc(ent, ModifierTrackingData::modifiers_by_key.set_key_to(modifier_key, modifier.clone()), None);
world.add_event(GameEvent::ReactionEffectApp... | code_fim | hard | {
"lang": "rust",
"repo": "nonvirtualthunk/rust-survival-hex",
"path": "/samvival/game/src/logic/reaction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nonvirtualthunk/rust-survival-hex path: /samvival/game/src/logic/reaction.rs
use common::prelude::*;
use prelude::*;
use entities::reactions::*;
use entities::actions::*;
use entities::common_entities::*;
use entities::AllegianceData;
use entities::combat::CombatData;
use game::ModifierReference... | code_fim | hard | {
"lang": "rust",
"repo": "nonvirtualthunk/rust-survival-hex",
"path": "/samvival/game/src/logic/reaction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if event.is_ended() {
let modifier_applied = match reaction {
ReactionTypeRef::Dodge => {
let increase_dodge_by = (world.view().data::<CombatData>(ent).dodge_bonus * 2).max(2);
... | code_fim | hard | {
"lang": "rust",
"repo": "nonvirtualthunk/rust-survival-hex",
"path": "/samvival/game/src/logic/reaction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: okard/rust-playground path: /storage/src/core/error.rs
use std::io;
pub enum StorageError
{
KeyNotFound, //Key is not available
CorruptStorage, //database file broken or something like that
Custom(Strin<|fim_suffix|>key handle
ValueIoError(io::Error), //io error when accessing value handl... | code_fim | medium | {
"lang": "rust",
"repo": "okard/rust-playground",
"path": "/storage/src/core/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>key handle
ValueIoError(io::Error), //io error when accessing value handle
}<|fim_prefix|>// repo: okard/rust-playground path: /storage/src/core/error.rs
use std::io;
pub enum StorageError
{
KeyNotFound, //Key is not available
CorruptStorage, //database file broken or something like that
Custom(St... | code_fim | medium | {
"lang": "rust",
"repo": "okard/rust-playground",
"path": "/storage/src/core/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match connection.back_stream.read(&mut buf) {
Ok(0) => {}
Ok(bytes_read) => {
println!(
"[{}] Received {} bytes from back!",
connection.id, bytes_read
);
... | code_fim | hard | {
"lang": "rust",
"repo": "Evgenius2020/Computer-Networks-Labs",
"path": "/06. Port_forwarder/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Evgenius2020/Computer-Networks-Labs path: /06. Port_forwarder/src/main.rs
use std::env;
use std::io;
use std::io::Read;
use std::io::Write;
use std::net::{IpAddr, SocketAddr, TcpListener, TcpStream, ToSocketAddrs};
fn parse_back_addr(back_addr: &str) -> io::Result<SocketAddr> {
let mut back... | code_fim | hard | {
"lang": "rust",
"repo": "Evgenius2020/Computer-Networks-Labs",
"path": "/06. Port_forwarder/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let listener: TcpListener =
TcpListener::bind(&front_addr).expect("Failed to bind at front_addr");
println!("Started listening at {}", &front_addr);
let mut connections: Vec<Connection> = Vec::new();
let mut next_id: usize = 0;
let mut buf = [0; 8192];
listener
.s... | code_fim | hard | {
"lang": "rust",
"repo": "Evgenius2020/Computer-Networks-Labs",
"path": "/06. Port_forwarder/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: BufferData> crate::Bind for Uniform<T>
{
fn binding_type(&self) -> wgpu::BindingType
{
wgpu::BindingType::UniformBuffer { dynamic: false }
}
fn resource(&self) -> wgpu::BindingResource
{
wgpu::BindingResource::Buffer
{
buffer: &self.buffer,
... | code_fim | medium | {
"lang": "rust",
"repo": "yohandev/voxels",
"path": "/ezgfx/src/bind/uniform.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self { buffer, size, ty }
}
/// update the data inside the uniform buffer
pub(crate) fn update(&self, ctx: &crate::Renderer, data: T)
{
let mut encoder = ctx.device.create_command_encoder
(
&wgpu::CommandEncoderDescriptor
{
l... | code_fim | hard | {
"lang": "rust",
"repo": "yohandev/voxels",
"path": "/ezgfx/src/bind/uniform.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yohandev/voxels path: /ezgfx/src/bind/uniform.rs
use crate::marker::BufferData;
/// the uniform buffer is a bind-able shader resource,
/// which in GLSL looks like this:
/// ```glsl
/// layout(set=0, binding=0) uniform MyBuffer
/// {
/// mat4 u_buffer_data;
/// };
/// ```
/// it can store d... | code_fim | medium | {
"lang": "rust",
"repo": "yohandev/voxels",
"path": "/ezgfx/src/bind/uniform.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
active_cubes: HashSet::from_iter(value.lines().enumerate().flat_map(|(y, line)| {
line.chars()
.enumerate()
.filter(|(_, c)| *c == '#')
.map(move |(x, _)| Coordinate::new(x as i32, y as i32, 0))
... | code_fim | hard | {
"lang": "rust",
"repo": "ojii/aoc2020",
"path": "/src/day17.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
struct Universe {
active_cubes: HashSet<Coordinate>,
}
impl Universe {
fn cube_state(&self, coord: &Coordinate) -> CubeState {
let active_neighbors = coord
.neighbors()
.iter()
.filter(|coord| self.active_cubes.contains(coord))
... | code_fim | hard | {
"lang": "rust",
"repo": "ojii/aoc2020",
"path": "/src/day17.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ojii/aoc2020 path: /src/day17.rs
use crate::maybe_from::MaybeFrom;
use itertools::Itertools;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::iter::FromIterator;
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
struct Coordinate {
x: i32,
y: i32,
z: i32,
}
impl Co... | code_fim | hard | {
"lang": "rust",
"repo": "ojii/aoc2020",
"path": "/src/day17.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn haddps_3() {
run_test(&Instruction { mnemonic: Mnemonic::HADDPS, operand1: Some(Direct(XMM3)), operand2: Some(Direct(XMM2)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[242, 15, 124, 218], OperandSize::Qword)
}
fn... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/haddps.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::HADDPS, operand1: Some(Direct(XMM3)), operand2: Some(Direct(XMM2)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[242, 15, 124, 218], OperandSize::Qword)
}
fn haddps_4() {
... | code_fim | medium | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/haddps.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/haddps.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn haddps_1() {
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/haddps.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hirni-Meshram2/pants path: /src/rust/engine/logging/src/logger.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::PythonLogLevel;
use std::cell::RefCell;
use std::collections::HashMap;
use std::conve... | code_fim | hard | {
"lang": "rust",
"repo": "Hirni-Meshram2/pants",
"path": "/src/rust/engine/logging/src/logger.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> PANTS_LOGGER.use_color.store(use_color, Ordering::SeqCst);
PANTS_LOGGER
.show_rust_3rdparty_logs
.store(show_rust_3rdparty_logs, Ordering::SeqCst);
*PANTS_LOGGER.log_level_filters.lock() = log_levels_by_target;
*PANTS_LOGGER.literal_filters.lock() = literal_filters;
*PANTS_... | code_fim | hard | {
"lang": "rust",
"repo": "Hirni-Meshram2/pants",
"path": "/src/rust/engine/logging/src/logger.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azkarell/genli path: /src/game/map/mapgen.rs
extern crate rand_distr;
extern crate voronoi;
use super::map::{Map, TileData};
use rand::distributions::{Distribution, Uniform};
use voronoi::{Point, voronoi, DCEL, make_line_segments};
use rand::{Rng};
use rand::rngs::{StdRng};
pub enum GenState{
... | code_fim | hard | {
"lang": "rust",
"repo": "Azkarell/genli",
"path": "/src/game/map/mapgen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = rand::thread_rng();
let val = rng.gen_range(0,4);
match val {
0 => GREEN,
1 => BLACK,
2 => BLUE,
3 => GREY,
_ => WHITE
}
}
fn gen_points(width: u64, height: u64, rng: &mut impl Rng) -> Vec<Point> {
let uniform_w = Uniform::new(0... | code_fim | hard | {
"lang": "rust",
"repo": "Azkarell/genli",
"path": "/src/game/map/mapgen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn restart(&mut self) {
self.state = GenState::Start;
self.rng = super::super::get_rng(self.seed)
}
}
fn get_random_color() -> [f32;4]{
let mut rng = rand::thread_rng();
let val = rng.gen_range(0,4);
match val {
0 => GREEN,
1 => BLACK,
2 =>... | code_fim | hard | {
"lang": "rust",
"repo": "Azkarell/genli",
"path": "/src/game/map/mapgen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>d keep_hydrated;
pub mod playing_banjo;
pub mod abbrev_name;
pub mod round_to_next_5;
pub mod high_low;<|fim_prefix|>// repo: LionelBeato/rustyfun path: /src/codewars/mod.rs
pub mod desc;
pub mod square_sum;
pub mod odd_even;<|fim_middle|>
pub mod remove_chars;
pub mod calculate_bmi;
pub mo | code_fim | easy | {
"lang": "rust",
"repo": "LionelBeato/rustyfun",
"path": "/src/codewars/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LionelBeato/rustyfun path: /src/codewars/mod.rs
pub mod desc;
pub mod square_sum;
pub mod odd_even;<|fim_suffix|>rev_name;
pub mod round_to_next_5;
pub mod high_low;<|fim_middle|>
pub mod remove_chars;
pub mod calculate_bmi;
pub mod keep_hydrated;
pub mod playing_banjo;
pub mod abb | code_fim | medium | {
"lang": "rust",
"repo": "LionelBeato/rustyfun",
"path": "/src/codewars/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<R: Read> Iterator for ChunkIterator<R> {
type Item = io::Result<Vec<u8>>;
fn next(&mut self) -> Option<Self::Item> {
let mut buffer = vec![0u8; self.chunk_size];
match self.reader.read_many(&mut buffer) {
Ok(bytes_read) if bytes_read == self.chunk_size => Some(Ok(... | code_fim | hard | {
"lang": "rust",
"repo": "filecoin-project/rust-fil-proofs",
"path": "/filecoin-proofs/src/chunk_iter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filecoin-project/rust-fil-proofs path: /filecoin-proofs/src/chunk_iter.rs
use std::io::{self, Read};
use iowrap::ReadMany;
/// The number of bytes that are read from the reader at once.
const READER_CHUNK_SIZE: usize = 4096;
// Based on
// https://stackoverflow.com/questions/73145503/iterator... | code_fim | hard | {
"lang": "rust",
"repo": "filecoin-project/rust-fil-proofs",
"path": "/filecoin-proofs/src/chunk_iter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = vec![0u8; self.chunk_size];
match self.reader.read_many(&mut buffer) {
Ok(bytes_read) if bytes_read == self.chunk_size => Some(Ok(buffer)),
// A position of 0 indicates end of file.
Ok(bytes_read) if bytes_read == 0 => None,
... | code_fim | medium | {
"lang": "rust",
"repo": "filecoin-project/rust-fil-proofs",
"path": "/filecoin-proofs/src/chunk_iter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gigoteur/UnicornConsole path: /unicorn-console/src/gui/controller.rs
use egui::{ComboBox, Slider, Ui};
use gilrs::Gilrs;
use crate::input::{InputMode, LocalInputManager, LocalKeyboardId};
pub struct ControllerGui {
pub local_player_count: usize,
}
impl Default for ControllerGui {
fn d... | code_fim | hard | {
"lang": "rust",
"repo": "Gigoteur/UnicornConsole",
"path": "/unicorn-console/src/gui/controller.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input
.player_bindings
.iter_mut()
.enumerate()
.for_each(|(player_id, input_mode)| {
let combo_text = match &input_mode {
InputMode::Emulated(keyboard_index) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "Gigoteur/UnicornConsole",
"path": "/unicorn-console/src/gui/controller.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> gilrs.gamepads().for_each(|(id, gamepad)| {
ui.selectable_value(
input_mode,
InputMode::Gamepad(id),
format!("{} [{}]", gamepad.name(), id... | code_fim | hard | {
"lang": "rust",
"repo": "Gigoteur/UnicornConsole",
"path": "/unicorn-console/src/gui/controller.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whatisinternet/fresh_cargo path: /src/lib.rs
#![deny(warnings)]
#![feature(custom_derive, custom_attribute, plugin)]
#![plugin(diesel_codegen, dotenv_macros)]
#[macro_use]
extern crate diesel;
extern crate dotenv;
extern crate rustc_serialize;
pub mod schema;
pub mod models;
pub mod fetch_crat... | code_fim | medium | {
"lang": "rust",
"repo": "whatisinternet/fresh_cargo",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn part2(input: &str) {
println!(
"Part 2 = {:?}",
parser::Graph::new(input).find_in_order_with_durations()
);
}<|fim_prefix|>// repo: C-Saunders/advent-of-code-2018 path: /problem07/src/main.rs
use std::fs;
extern crate lazy_static;
mod parser;
fn main() -> Result<(), String> {... | code_fim | medium | {
"lang": "rust",
"repo": "C-Saunders/advent-of-code-2018",
"path": "/problem07/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: C-Saunders/advent-of-code-2018 path: /problem07/src/main.rs
use std::fs;
extern crate lazy_static;
mod parser;
fn main() -> Result<(), String> {
<|fim_suffix|> println!("Part 1 = {}", parser::Graph::new(input).find_in_order());
}
fn part2(input: &str) {
println!(
"Part 2 = {:?}... | code_fim | medium | {
"lang": "rust",
"repo": "C-Saunders/advent-of-code-2018",
"path": "/problem07/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"Part 2 = {:?}",
parser::Graph::new(input).find_in_order_with_durations()
);
}<|fim_prefix|>// repo: C-Saunders/advent-of-code-2018 path: /problem07/src/main.rs
use std::fs;
extern crate lazy_static;
mod parser;
fn main() -> Result<(), String> {
<|fim_middle|> let i... | code_fim | hard | {
"lang": "rust",
"repo": "C-Saunders/advent-of-code-2018",
"path": "/problem07/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>n_error_packet;
pub mod msg_channel_announcement;
pub mod msg_node_announcement;
pub mod msg_query_short_channel_ids;
pub mod msg_reply_channel_range;
pub mod msg_error_message;
pub mod msg_warning_message;
pub mod msg_channel_update;<|fim_prefix|>// repo: TheBlueMatt/rust-lightning path: /fuzz/src/msg_t... | code_fim | hard | {
"lang": "rust",
"repo": "TheBlueMatt/rust-lightning",
"path": "/fuzz/src/msg_targets/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ogata-k/dotecnf path: /src/lib.rs
#[macro_use]
extern crate failure;
<|fim_suffix|>pub use error::ECnfLoaderError;
pub use loader::ECnfLoader;
pub use loader::PREFIX_KEY_SEPARATOR;
pub use loader::PREFIX_SEPARATOR;<|fim_middle|>mod error;
mod helper;
mod loader;
| code_fim | easy | {
"lang": "rust",
"repo": "ogata-k/dotecnf",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use error::ECnfLoaderError;
pub use loader::ECnfLoader;
pub use loader::PREFIX_KEY_SEPARATOR;
pub use loader::PREFIX_SEPARATOR;<|fim_prefix|>// repo: ogata-k/dotecnf path: /src/lib.rs
#[macro_use]
extern crate failure;
<|fim_middle|>mod error;
mod helper;
mod loader;
| code_fim | easy | {
"lang": "rust",
"repo": "ogata-k/dotecnf",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix-filter/src/pipeline/util.rs
use std::path::Path;
use bstr::BStr;
use gix_attributes::StateRef;
use smallvec::SmallVec;
use crate::{
driver, eol,
eol::AttributesDigest,
pipeline::{convert::configuration, Context, CrlfRoundTripCheck},
Driver,
};
/// A u... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-filter/src/pipeline/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match attr.assignment.state {
StateRef::Unspecified | StateRef::Unset | StateRef::Set => None,
StateRef::Value(v) => {
if v.as_bstr() == "lf" {
Some(eol::Mode::Lf)
} else if v.as_bstr() == "crlf" {
... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-filter/src/pipeline/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hawkw/mycelium path: /maitake/src/time/timer/sleep.rs
use super::{Ticks, Timer};
use crate::{
loom::{
cell::UnsafeCell,
sync::atomic::{AtomicBool, Ordering::*},
},
sync::wait_cell::WaitCell,
};
use cordyceps::{list, Linked};
use core::{
future::Future,
marker:... | code_fim | hard | {
"lang": "rust",
"repo": "hawkw/mycelium",
"path": "/maitake/src/time/timer/sleep.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe fn links(target: NonNull<Self>) -> NonNull<list::Links<Entry>> {
// Safety: using `ptr::addr_of!` avoids creating a temporary
// reference, which stacked borrows dislikes.
let links = ptr::addr_of!((*target.as_ptr()).links);
(*links).with_mut(|links| {
... | code_fim | hard | {
"lang": "rust",
"repo": "hawkw/mycelium",
"path": "/maitake/src/time/timer/sleep.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::fmt::Debug for SvgElement {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
match *self {
SvgElement::Circle(ref c) => writeln!(fmt, "{}", c.to_string()),
SvgElement::Line(ref l) => writeln!(fmt, "{}", l.to_string()),
... | code_fim | medium | {
"lang": "rust",
"repo": "K4zuki/svgbob",
"path": "/svgbob/src/svg_element.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: K4zuki/svgbob path: /svgbob/src/svg_element.rs
use std;
use svg::node::element::Circle as SvgCircle;
use svg::node::element::Line as SvgLine;
use svg::node::element::Path as SvgPath;
use svg::node::element::Text as SvgText;
pub enum SvgElement {
Circle(SvgCircle),
Line(SvgLine),
Pat... | code_fim | medium | {
"lang": "rust",
"repo": "K4zuki/svgbob",
"path": "/svgbob/src/svg_element.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benediktwerner/z3.rs path: /z3/src/tactic.rs
use std::ffi::CString;
use z3_sys::*;
use ApplyResult;
use Context;
use Goal;
use Tactic;
use Z3_MUTEX;
impl<'ctx> Tactic<'ctx> {
pub(crate) fn new(ctx: &'ctx Context, z3_tactic: Z3_tactic) -> Tactic<'ctx> {
unsafe {
let guard... | code_fim | hard | {
"lang": "rust",
"repo": "benediktwerner/z3.rs",
"path": "/z3/src/tactic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn apply(&self, goal: &Goal<'ctx>) -> ApplyResult<'ctx> {
let result = unsafe {
let guard = Z3_MUTEX.lock().unwrap();
Z3_tactic_apply(self.ctx.z3_ctx, self.z3_tactic, goal.z3_goal)
};
ApplyResult::new(self.ctx, result)
}
}
impl<'ctx> Drop for Ta... | code_fim | hard | {
"lang": "rust",
"repo": "benediktwerner/z3.rs",
"path": "/z3/src/tactic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>t == 2020 {
return (x_int * y_int * z_int).to_string();
}
}
}
}
return "No Solution".to_string();
}
}<|fim_prefix|>// repo: rileycohn/AdventOfCode2020 path: /AdventOfCode2020-Rust/src/day1.rs
use crate::utils::Uti... | code_fim | hard | {
"lang": "rust",
"repo": "rileycohn/AdventOfCode2020",
"path": "/AdventOfCode2020-Rust/src/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rileycohn/AdventOfCode2020 path: /AdventOfCode2020-Rust/src/day1.rs
use crate::utils::Utils;
pub struct Day1 {
}
const INPUT_FILE: &str = "src/inputs/day1.txt";
impl Day1 {
pub(crate) fn solve(&self) -> String {
let lines = Utils::lines_from_fil<|fim_suffix|>rap();
... | code_fim | hard | {
"lang": "rust",
"repo": "rileycohn/AdventOfCode2020",
"path": "/AdventOfCode2020-Rust/src/day1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for operation in self.ops.iter().cloned() {
w_handle.apply_operation(operation);
}
// Swap the pointers.
let writers_inner = self.writers_inner.as_ref().unwrap().swap(
self.readers_inner.load(Ordering::Relaxed),
Ordering::Release,
... | code_fim | hard | {
"lang": "rust",
"repo": "Skarlett/evc",
"path": "/src/write.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Skarlett/evc path: /src/write.rs
use std::mem;
use std::ptr;
use std::sync::atomic;
use std::sync::atomic::{AtomicPtr, Ordering};
use std::sync::Arc;
use std::thread;
use crate::{Epochs, Inner, OperationCache, WeakEpoch, USIZE_MSB};
/// A handle which allows accessing the inner data mutably th... | code_fim | hard | {
"lang": "rust",
"repo": "Skarlett/evc",
"path": "/src/write.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> atomic::fence(Ordering::SeqCst);
for (i, epoch) in epochs.iter().enumerate() {
if let Some(e) = epoch.upgrade() {
self.last_epochs[i] = e.load(Ordering::Acquire);
}
}
let w_handle = &mut unsafe {
self.writers_inner
... | code_fim | hard | {
"lang": "rust",
"repo": "Skarlett/evc",
"path": "/src/write.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Strip entries which are out of bounds from the buffer.
while self
.buffer
.front()
.map(|&(ref key, _)| match self.min_key {
MyBound::Included(ref min_key) => key < min_key,
MyBound::Excluded(ref min_key) => key <= min_... | code_fim | hard | {
"lang": "rust",
"repo": "Nilix007/betree_storage_stack",
"path": "/src/tree/imp/range.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // First, we gather all messages for the given key and its value in the leaf.
let mut node = self.get_root_node()?;
loop {
let next_node = match node.get_range(
key,
&mut left_pivot_key,
&mut r... | code_fim | hard | {
"lang": "rust",
"repo": "Nilix007/betree_storage_stack",
"path": "/src/tree/imp/range.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nilix007/betree_storage_stack path: /src/tree/imp/range.rs
use super::node::{GetRangeResult, Node};
use super::{Inner, Tree};
use crate::cow_bytes::{CowBytes, SlicedCowBytes};
use crate::data_management::{Dml, ObjectRef};
use crate::tree::errors::*;
use crate::tree::MessageAction;
use std::borro... | code_fim | hard | {
"lang": "rust",
"repo": "Nilix007/betree_storage_stack",
"path": "/src/tree/imp/range.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quadrupleslap/tether path: /src/lib.rs
#![deny(missing_docs)]
//! Windows that are web views.
use log::error;
use std::cell::{Cell, RefCell};
use std::ffi::{c_void, CStr, CString};
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::{panic, process};
thread_local! {
s... | code_fim | hard | {
"lang": "rust",
"repo": "quadrupleslap/tether",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe extern fn init() {
abort_on_panic(|| {
MAIN_THREAD.with(|initialized| {
initialized.set(true);
});
INITIALIZED.store(true, Ordering::Relaxed);
INIT.unwrap()();
});
}
raw::tether_start(Some(init));
}
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "quadrupleslap/tether",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chenenjie/mqtt path: /src/bin/test1.rs
extern crate futures;
extern crate futures_cpupool;
extern crate tokio_timer;
use std::time::Duration;
use futures::Future;
use futures_cpupool::CpuPool;
use tokio_timer::Timer;
<|fim_suffix|>fn test2() -> Result<(), ()>{
let result: Result<(),()> ... | code_fim | hard | {
"lang": "rust",
"repo": "chenenjie/mqtt",
"path": "/src/bin/test1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn test2() -> Result<(), ()>{
let result: Result<(),()> = Err(());
try!(result);
Ok(())
}
fn test3() {
let a_result: Result<(), ()> = Ok(());
let b = a_result.map(Some);
println!("{:?}", a_result);
println!("{:?}", b);
}<|fim_prefix|>// repo: chenenjie/mqtt path: /src/bin/t... | code_fim | hard | {
"lang": "rust",
"repo": "chenenjie/mqtt",
"path": "/src/bin/test1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn get_all(db: &Db) -> sqlx::Result<Vec<Self>> {
let res: Vec<Record> = sqlx::query_as::<Postgres, Record>(
"SELECT * FROM Records")
.fetch_all(&db.pool).await?;
Ok(res)
}
pub async fn get_all_by_user(db: &Db, uid: Uuid) -> sqlx::Result<Vec<Se... | code_fim | hard | {
"lang": "rust",
"repo": "clpi/di-srv",
"path": "/di-db/src/models/record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clpi/di-srv path: /di-db/src/models/record.rs
use serde::{Serialize, Deserialize};
use sqlx::{
types::{chrono::{Utc, DateTime, NaiveDate, NaiveDateTime}, Json, uuid::Uuid},
FromRow, Type, postgres::{Postgres, PgRow}, Decode, prelude::*,
};
use crate::{Db,
types::{Visibility, Status},... | code_fim | hard | {
"lang": "rust",
"repo": "clpi/di-srv",
"path": "/di-db/src/models/record.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn delete_by_id<I: Into<Uuid>>(db: &Db, id: I) -> sqlx::Result<Uuid> {
let res = sqlx::query(
"DELETE FROM Records WHERE id=$1 RETURNING id")
.bind(id.into())
.fetch_one(&db.pool).await?;
Ok( res.get("id") )
}
pub async fn update_... | code_fim | hard | {
"lang": "rust",
"repo": "clpi/di-srv",
"path": "/di-db/src/models/record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(result.is_err(),true);
let error = result.unwrap_err();
assert_eq!(error,INVALID_COACH_ID);
Ok(())
});
}
fn build_program_request() -> NewProgramRequest {
NewProgramRequest{
coach_id:"coach-1".to_string(),
name: "name-... | code_fim | medium | {
"lang": "rust",
"repo": "krsmanian1972/ferries",
"path": "/src/service_tests/program_creation_feature.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.