text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: fengshunli/curiefense path: /curiefense/curieproxy/rust/curiefense/src/tagging.rs
use crate::config::globalfilter::{PairEntry, GlobalFilterEntry, GlobalFilterEntryE, GlobalFilterSSection, SingleEntry};
use crate::config::raw::Relation;
use crate::config::Config;
use crate::interface::{SimpleActi... | code_fim | hard | {
"lang": "rust",
"repo": "fengshunli/curiefense",
"path": "/curiefense/curieproxy/rust/curiefense/src/tagging.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = t_check_entry(false, GlobalFilterEntryE::Path(single_re("adminl%20e")));
assert!(r);
}
#[test]
fn check_path_out() {
let r = t_check_entry(false, GlobalFilterEntryE::Path(single_re(".*adminl e.*")));
assert!(!r);
}
#[test]
fn check_headers_... | code_fim | hard | {
"lang": "rust",
"repo": "fengshunli/curiefense",
"path": "/curiefense/curieproxy/rust/curiefense/src/tagging.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = t_check_entry(false, GlobalFilterEntryE::Ip("52.78.12.57".parse().unwrap()));
assert!(!r);
}
#[test]
fn check_path_in() {
let r = t_check_entry(false, GlobalFilterEntryE::Path(single_re(".*adminl%20e.*")));
assert!(r);
}
#[test]
fn check_pa... | code_fim | hard | {
"lang": "rust",
"repo": "fengshunli/curiefense",
"path": "/curiefense/curieproxy/rust/curiefense/src/tagging.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "playground_api")]
let playground_api_service = PlaygroundApiServiceFactory::new(compiler_msg_handler, handle.clone());
let factory = DefaultServiceFactory::new(
render_service_factory,
resource_service_factory,
static_resource_service_factory,
... | code_fim | hard | {
"lang": "rust",
"repo": "tmzt/isymtope",
"path": "/isymtope-server/src/server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tmzt/isymtope path: /isymtope-server/src/server.rs
use std::env;
use std::fmt::Debug;
use std::path::{Path, PathBuf};
use std::thread;
use futures::{self, Stream};
use futures::future;
use tokio_core::reactor::Core;
use tokio_core::net::TcpListener;
use hyper::server::{Http, NewService, Servic... | code_fim | hard | {
"lang": "rust",
"repo": "tmzt/isymtope",
"path": "/isymtope-server/src/server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn new<A, F, R, T, U>(addr: A, func: F) -> Result<TestServer, anyhow::Error>
where
A: ToSocketAddrs + 'static + Send + Copy,
F: Factory<T, R, U> + 'static + Send + Copy,
T: FromRequest + 'static,
R: Future<Output = U> + 'static,
U: Responder + 'static,
{
let (tx, rx) = crossbea... | code_fim | medium | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/third-party/test-server/src/server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.stop()
}
}
pub fn new<A, F, R, T, U>(addr: A, func: F) -> Result<TestServer, anyhow::Error>
where
A: ToSocketAddrs + 'static + Send + Copy,
F: Factory<T, R, U> + 'static + Send + Copy,
T: FromRequest + 'static,
R: Future<Output = U> + 'static,
U: Responder + 'static,
... | code_fim | hard | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/third-party/test-server/src/server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 10allday-kai/api-daemon path: /third-party/test-server/src/server.rs
use crate::channel::{Receiver, Sender};
use actix_web::{dev::Factory, web, App, FromRequest, HttpServer, Responder, Result};
use futures::{executor::block_on, Future};
use std::{
net::{SocketAddr, ToSocketAddrs},
rc::Rc... | code_fim | hard | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/third-party/test-server/src/server.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut runtime = task::Builder::new();
let mut join = runtime.spawn(async move {
let (tx, rx) = channel::<i32>(1);
let mut ch = OnceChannel::new(tx);
ch.send(100).await;
rx.recv().await;
println!("Hello Word");
}).unwrap(... | code_fim | hard | {
"lang": "rust",
"repo": "laohanlinux/beanstalkr",
"path": "/src/operation/once_channel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laohanlinux/beanstalkr path: /src/operation/once_channel.rs
use futures::future::err;
use failure::{self, Fail, Error, err_msg};
use async_std::sync::{channel, Arc, Sender, Receiver};
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
#[derive(Debug, Clone)]
pub struct OnceCha... | code_fim | medium | {
"lang": "rust",
"repo": "laohanlinux/beanstalkr",
"path": "/src/operation/once_channel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cr1901/hl2html path: /src/ast.rs
use chrono::{DateTime, Utc};
use lalrpop_util::ParseError;
use url::Url;
use uuid::Uuid;
use version_compare::version::Version;
use std::error;
use std::fmt;
use crate::lexer::{LexerError, Tok};
#[derive(Debug, PartialEq)]
pub struct Hotlist<'a> {
pub vers... | code_fim | hard | {
"lang": "rust",
"repo": "cr1901/hl2html",
"path": "/src/ast.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq)]
pub(crate) enum NoteField<'a> {
Id(u32),
Uuid(Uuid),
Contents(&'a str),
Url(Url),
Timestamp(DateTime<Utc>),
Active(bool),
}
// We squirrel this away in LexerError's UserError variant, because LexerError is already
// associated with the ParseError::User... | code_fim | hard | {
"lang": "rust",
"repo": "cr1901/hl2html",
"path": "/src/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, PartialEq)]
pub struct Note<'a> {
pub id: u32,
pub uuid: Uuid,
pub contents: Option<&'a str>,
pub url: Option<Url>,
pub timestamp: DateTime<Utc>,
pub active: bool,
}
#[derive(Debug, PartialEq)]
pub(crate) enum NoteField<'a> {
Id(u32),
Uuid(Uuid),
Conten... | code_fim | hard | {
"lang": "rust",
"repo": "cr1901/hl2html",
"path": "/src/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HANDZCZ/kalkulacka_hw path: /src/main.rs
#![cfg_attr(feature = "gui", windows_subsystem = "windows")]
#[cfg(all(feature = "gui", feature = "cli"))]
compile_error!("features `gui` and `cli` are can't be used together");
mod types;
mod calculations;
mod utils;
<|fim_suffix|> #[cfg(feature = ... | code_fim | medium | {
"lang": "rust",
"repo": "HANDZCZ/kalkulacka_hw",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "gui")]
gui::run();
}<|fim_prefix|>// repo: HANDZCZ/kalkulacka_hw path: /src/main.rs
#![cfg_attr(feature = "gui", windows_subsystem = "windows")]
#[cfg(all(feature = "gui", feature = "cli"))]
compile_error!("features `gui` and `cli` are can't be used together");
mod types;
mo... | code_fim | medium | {
"lang": "rust",
"repo": "HANDZCZ/kalkulacka_hw",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// loads the default file paths from stoke_preview.toml or returns empty strings if that file does not exist
fn load_default_files() -> anyhow::Result<Files> {
match File::open("stroke_preview.toml") {
Ok(mut file) => {
let mut string =
String::with_capacity(file.m... | code_fim | medium | {
"lang": "rust",
"repo": "robeady/cricket-2004-stroke-preview",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: robeady/cricket-2004-stroke-preview path: /src/main.rs
use anyhow::Result;
use serde_derive::Deserialize;
use std::fs::File;
use std::io::Read;
use window::render_app;
<|fim_suffix|> match File::open("stroke_preview.toml") {
Ok(mut file) => {
let mut string =
... | code_fim | hard | {
"lang": "rust",
"repo": "robeady/cricket-2004-stroke-preview",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> Result<()> {
let files = load_default_files()?;
Ok(render_app(files)?)
}
#[derive(Deserialize)]
pub struct Files {
cfg_file: String,
list_file: String,
}
/// loads the default file paths from stoke_preview.toml or returns empty strings if that file does not exist
fn load_def... | code_fim | medium | {
"lang": "rust",
"repo": "robeady/cricket-2004-stroke-preview",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paucarre/algebraic_robots path: /src/screw_chains.rs
use crate::algebraic_robots::{Screw, GeneralizedCoordinates, ScrewChain};
use nalgebra::{ Vector3, Matrix4};
use std::collections::HashMap;
pub trait ScrewChainLike {
fn from_default() -> Option<ScrewChain>;
fn from_parameters(topolog... | code_fim | hard | {
"lang": "rust",
"repo": "paucarre/algebraic_robots",
"path": "/src/screw_chains.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return vec![String::from("h1"), String::from("h2"),
String::from("l1"), String::from("l2"),
String::from("w1"), String::from("w2")];
}
fn from_parameters(parameters_map: &HashMap<&str, f64>) -> Option<ScrewChain> {
let params_opt = Self::par... | code_fim | hard | {
"lang": "rust",
"repo": "paucarre/algebraic_robots",
"path": "/src/screw_chains.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return vec![String::from("l1"), String::from("l2")];
}
fn from_parameters(parameters_map: &HashMap<&str, f64>) -> Option<ScrewChain> {
let params_opt = Self::param_map_to_param_vect(parameters_map);
params_opt.map(|params|
ScrewChain {
screws: v... | code_fim | hard | {
"lang": "rust",
"repo": "paucarre/algebraic_robots",
"path": "/src/screw_chains.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>er::*;
pub use self::parser::*;
pub use self::checker::*;
pub use self::transpiler::*;<|fim_prefix|>// repo: nilq/golf path: /src/golf/mod.rs
pub mod lexer;
pub mod parser;
pub mod chec<|fim_middle|>ker;
pub mod transpiler;
pub use self::lex | code_fim | easy | {
"lang": "rust",
"repo": "nilq/golf",
"path": "/src/golf/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilq/golf path: /src/golf/mod.rs
pub mod lexer;
pub mod parser;
pub mod chec<|fim_suffix|>f::checker::*;
pub use self::transpiler::*;<|fim_middle|>ker;
pub mod transpiler;
pub use self::lexer::*;
pub use self::parser::*;
pub use sel | code_fim | medium | {
"lang": "rust",
"repo": "nilq/golf",
"path": "/src/golf/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>f::checker::*;
pub use self::transpiler::*;<|fim_prefix|>// repo: nilq/golf path: /src/golf/mod.rs
pub mod lexer;
pub mod parser;
pub mod chec<|fim_middle|>ker;
pub mod transpiler;
pub use self::lexer::*;
pub use self::parser::*;
pub use sel | code_fim | medium | {
"lang": "rust",
"repo": "nilq/golf",
"path": "/src/golf/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
let uVar1: u16; code * * ppcVar2;
let unaff_DS: u16;
FUN_3444_02c6(0x39d9);
uVar1 = 0xc7a8; ppcVar2 = (code * *)0xcf74; ( * * ppcVar2)(0x3444, 0x5ddc, param_1, 0x5de0,
0x5de4 + param_1 + - 1, 0x7fda); FUN_168b_04c4(0x3444, 0x5ddc, param_1, param_2); FUN_2692_0ecc(0x168b, 0x138a + 0x5ddc, param_1, param... | code_fim | hard | {
"lang": "rust",
"repo": "cyrex562/sim-earth-rs",
"path": "/src/simearth_exe_dump_1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyrex562/sim-earth-rs path: /src/simearth_exe_dump_1.rs
local_1c[0] = in_stack_00000008; local_1c[1] = in_stack_0000000a; local_1c[2] = in_stack_0000000c; local_1c[3] = in_stack_0000000e; local_c._0_2_ = 0x9c7a; local_c = CONCAT22(0x9c7c,local_c); uVar4 = local_c; loop {
if ((local_c + 2) == - ... | code_fim | hard | {
"lang": "rust",
"repo": "cyrex562/sim-earth-rs",
"path": "/src/simearth_exe_dump_1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyrex562/sim-earth-rs path: /src/simearth_exe_dump_1.rs
(param_1 >> 0x10));
return;
}
fn fun_2692_00cc(param_1_00: u16, param_1: u16, param_2: u16, byte param_3)
{
code * *ppcVar1;
let u_var2: u32;
let unaff_ds: u16;
u_var2 =
0x7fce;
ppcVar1 = (c... | code_fim | hard | {
"lang": "rust",
"repo": "cyrex562/sim-earth-rs",
"path": "/src/simearth_exe_dump_1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skeleton0/aoc2017 path: /day12_part1/src/main.rs
mod graph;
use std::fs::File;
use std::io::Read;
fn main() {
let mut f = File::open("input.txt").expect("Failed to open file.");
let mut input = String::new();
f.read_to_string(&mut input).expect("Failed to read from file.");
... | code_fim | hard | {
"lang": "rust",
"repo": "skeleton0/aoc2017",
"path": "/day12_part1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Populate the village with the nodes
for line in input.lines() {
let mut iter = line.split_whitespace();
let node = iter.next().expect("Unable to extract node id from input line.");
let node: u32 = node.trim().parse().expect("Failed to parse node id to u32.");
if... | code_fim | medium | {
"lang": "rust",
"repo": "skeleton0/aoc2017",
"path": "/day12_part1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !village.add_connection(root_node, connection) {
panic!("Failed to make node connection as either root node or connection node does not exist.");
}
}
}
let root_node = 0;
let members = village.count_group_members(root_node);
println!("Cou... | code_fim | hard | {
"lang": "rust",
"repo": "skeleton0/aoc2017",
"path": "/day12_part1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_quote() {
test("\"foo\\\"bar\"", RawOsStr::from_str("foo\"bar"));
}<|fim_prefix|>// repo: dylni/os_str_bytes path: /tests/raw_debug.rs
#![cfg(feature = "raw_os_str")]
use os_str_bytes::RawOsStr;
mod raw_common;
use raw_common::RAW_WTF8_STRING;
fn test(result: &str, string: &RawOsSt... | code_fim | hard | {
"lang": "rust",
"repo": "dylni/os_str_bytes",
"path": "/tests/raw_debug.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dylni/os_str_bytes path: /tests/raw_debug.rs
#![cfg(feature = "raw_os_str")]
use os_str_bytes::RawOsStr;
mod raw_common;
use raw_common::RAW_WTF8_STRING;
<|fim_suffix|> let wchar = if cfg!(unix) {
"\\xED\\xA0\\xBD"
} else {
"\\u{D83D}"
};
test(&format!("\"foo{}\... | code_fim | hard | {
"lang": "rust",
"repo": "dylni/os_str_bytes",
"path": "/tests/raw_debug.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bevyengine/bevy path: /examples/window/transparent_window.rs
//! Shows how to display a window in transparent mode.
//!
//! This feature works as expected depending on the platform. Please check the
//! [documentation](https://docs.rs/bevy/latest/bevy/prelude/struct.WindowDescriptor.html#structf... | code_fim | medium | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/examples/window/transparent_window.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnkoehn/trading_sim path: /src/bot/traits.rs
use crate::config;
use config::Config;
use rand::Rng;
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum Direction {
Up,
Down,
Both
}
// TODO: Remove unused traits from the bot in the simulation - i.e. bots become more scoped ... | code_fim | hard | {
"lang": "rust",
"repo": "johnkoehn/trading_sim",
"path": "/src/bot/traits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn mutate<R: Rng>(&mut self, rng: &mut R, config: &Config) {
// for each trait, see if we need to regenerate based on mutation chance
self.number_of_averaging_periods = match rng.gen_bool(config.mutation_chance) {
true => rng.gen_range(config.traits.number_of_averaging_... | code_fim | hard | {
"lang": "rust",
"repo": "johnkoehn/trading_sim",
"path": "/src/bot/traits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HewlettPackard/woodchipper path: /src/parser/klog.rs
// (C) Copyright 2019 Hewlett Packard Enterprise Development LP
use std::collections::HashMap;
use std::error::Error;
use std::sync::Arc;
use chrono::prelude::*;
use regex::Regex;
use serde_json::Value;
use crate::config::Config;
use super:... | code_fim | hard | {
"lang": "rust",
"repo": "HewlettPackard/woodchipper",
"path": "/src/parser/klog.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(context) = caps.get(4).map(|c| c.as_str()) {
metadata.insert(
"caller".to_string(),
Value::String(context.to_string())
);
}
return Ok(Some(Message {
kind: MessageKind::Klog,
reader_metadata: meta,
raw: line.to_string(),
text: Som... | code_fim | hard | {
"lang": "rust",
"repo": "HewlettPackard/woodchipper",
"path": "/src/parser/klog.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (true, 0b00) => 0,
(true, 0b01) => 8,
(true, 0b10) => 2,
(true, 0b11) => 0,
_ => unreachable!(),
}
}
fn dest_addr_size(&self) -> Result<u8, ()> {
Ok(match (self.get_m(), self.get_dac(), self.get_dam()) {
(fal... | code_fim | hard | {
"lang": "rust",
"repo": "japaric/jnet",
"path": "/src/sixlowpan/iphc.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ElidedAddr {
/// Complete this elided address using Link-layer information
pub fn complete<A>(self, ll_addr: A) -> ipv6::Addr
where
A: Into<ll::Addr>,
{
self.complete_(ll_addr.into())
}
fn complete_(self, ll_addr: ll::Addr) -> ipv6::Addr {
let mut byte... | code_fim | hard | {
"lang": "rust",
"repo": "japaric/jnet",
"path": "/src/sixlowpan/iphc.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: japaric/jnet path: /src/sixlowpan/iphc.rs
ffXX::00XX:XXXX:XXXX
bytes[0] = 0xff;
bytes[1] = unsafe { *self.as_slice().gu(start) };
bytes[11..].copy_from_slice(unsafe { self.as_slice().r(start + 1..start + 6) });
Addr::Complete(ipv6... | code_fim | hard | {
"lang": "rust",
"repo": "japaric/jnet",
"path": "/src/sixlowpan/iphc.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Texlo-Dev/spectacles-rs path: /gateway/src/shard.rs
use serde_json::Value;
pub struct Shard {
id: i32,
token: String,
has_acked: bool,
}
<|fim_suffix|> /// Identifies a shard with Discord.
pub fn identify(&self) {
}
}<|fim_middle|>impl Shard {
/// Creates a new Disc... | code_fim | medium | {
"lang": "rust",
"repo": "Texlo-Dev/spectacles-rs",
"path": "/gateway/src/shard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Identifies a shard with Discord.
pub fn identify(&self) {
}
}<|fim_prefix|>// repo: Texlo-Dev/spectacles-rs path: /gateway/src/shard.rs
use serde_json::Value;
pub struct Shard {
id: i32,
token: String,
has_acked: bool,
}
<|fim_middle|>impl Shard {
/// Creates a new Disc... | code_fim | medium | {
"lang": "rust",
"repo": "Texlo-Dev/spectacles-rs",
"path": "/gateway/src/shard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kirawi/feather path: /feather/server/src/systems/health.rs
use crate::{ClientId, Game, Server};
use ecs::{SysResult, SystemExecutor};
use quill_common::{
components::{Health, Hunger},
events::{
entity_damage_event_kind, entity_regen_event_kind, entity_special_event_kind,
... | code_fim | hard | {
"lang": "rust",
"repo": "kirawi/feather",
"path": "/feather/server/src/systems/health.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut events = Vec::new();
for (entity, _) in game
.ecs
.query::<&entity_damage_event_kind::Starvation>()
.iter()
{
events.push((entity, EntityHealthEvent::Damage(1)));
}
for (entity, event) in events {
game.ecs.insert_entity_event(entity, ev... | code_fim | hard | {
"lang": "rust",
"repo": "kirawi/feather",
"path": "/feather/server/src/systems/health.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn player_hunger(game: &mut Game, _server: &mut Server) -> SysResult {
let mut events = Vec::new();
for (entity, _) in game
.ecs
.query::<&entity_damage_event_kind::Starvation>()
.iter()
{
events.push((entity, EntityHealthEvent::Damage(1)));
}
for (ent... | code_fim | hard | {
"lang": "rust",
"repo": "kirawi/feather",
"path": "/feather/server/src/systems/health.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sneakycrow/static-blog-generator path: /src/main.rs
extern crate comrak;
use comrak::{markdown_to_html, ComrakOptions};
use std::fs::{self, File};
use std::io::{self, Read};
use std::path::{Path, PathBuf};
fn get_md_paths(dir: &Path) -> io::Result<Vec<PathBuf>> {
let mut entries: Vec<PathBuf... | code_fim | medium | {
"lang": "rust",
"repo": "sneakycrow/static-blog-generator",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> file.read_to_string(&mut contents).unwrap();
let html = markdown_to_html(&contents, &ComrakOptions::default());
println!("{:?}", html);
}
Ok(())
}<|fim_prefix|>// repo: sneakycrow/static-blog-generator path: /src/main.rs
extern crate comrak;
use comrak::{markdown_to_html, ComrakOptions}... | code_fim | hard | {
"lang": "rust",
"repo": "sneakycrow/static-blog-generator",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leontoeides/google_maps path: /src/places/place_search/nearby_search/request/with_keyword.rs
use crate::places::place_search::nearby_search::request::Request;
// -----------------------------------------------------------------------------
<|fim_suffix|> pub fn with_keyword(&'a mut self, ke... | code_fim | hard | {
"lang": "rust",
"repo": "leontoeides/google_maps",
"path": "/src/places/place_search/nearby_search/request/with_keyword.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn with_keyword(&'a mut self, keyword: String) -> &'a mut Request {
// Set maximum price in Request struct.
self.keyword = Some(keyword);
// Return modified Request struct to caller.
self
} // fn
} // impl<|fim_prefix|>// repo: leontoeides/google_maps path: /s... | code_fim | hard | {
"lang": "rust",
"repo": "leontoeides/google_maps",
"path": "/src/places/place_search/nearby_search/request/with_keyword.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ine in file_reader.lines() {
println!("You typed:{}", single_line.unwrap());
}
}<|fim_prefix|>// repo: burakbayramli/books path: /Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter10/miscellaneous/snippet7.rs
use std::io::{BufRead, BufReader};
fn main() {
// Create handle t... | code_fim | medium | {
"lang": "rust",
"repo": "burakbayramli/books",
"path": "/Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter10/miscellaneous/snippet7.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e_reader = BufReader::new(s);
// Read from standard input line-by-line
for single_line in file_reader.lines() {
println!("You typed:{}", single_line.unwrap());
}
}<|fim_prefix|>// repo: burakbayramli/books path: /Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter10/misc... | code_fim | medium | {
"lang": "rust",
"repo": "burakbayramli/books",
"path": "/Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter10/miscellaneous/snippet7.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ::std::fmt::Debug for SendParameter {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
write!(f, "SendParameter {{name: {:?}, type_of: {:?}, value: {:?} }}", &self.name, &self.type_of, &self.value)
}
}
implement!(UnsafeParameter,UnsafeAny,,);
implement_m... | code_fim | hard | {
"lang": "rust",
"repo": "bgbahoue/shaku",
"path": "/src/parameter/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bgbahoue/shaku path: /src/parameter/mod.rs
//! `AnyMap` variants to pass parameters to a `ContainerBuilder` or `Container`.
//!
//! - [ParameterMap](struct.ParameterMap.html): simplest Map; doesn't support multithread since not `+Send +Sync`,
//! - [SendParameterMap](struct.SendParameterMap.html... | code_fim | hard | {
"lang": "rust",
"repo": "bgbahoue/shaku",
"path": "/src/parameter/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn search_by_e_number(&self, query: &str) -> Result<Vec<Item>, Box<dyn Error>> {
let query_prefixed_with_e = format!("E{query}");
Ok(self
.client
.search::<Item>()
.index(INDEX)
.body(json!({
"query": {
... | code_fim | hard | {
"lang": "rust",
"repo": "isitvegan/isitvegan-web",
"path": "/src/search_engine.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isitvegan/isitvegan-web path: /src/search_engine.rs
//! Client for the communication with the underlying search engine
use crate::model::Item;
use elastic::client::responses::search::Hit;
use elastic::prelude::*;
use serde_json::json;
use std::error::Error;
use std::fmt::{self, Debug};
/// A s... | code_fim | hard | {
"lang": "rust",
"repo": "isitvegan/isitvegan-web",
"path": "/src/search_engine.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //
// 構文木作成
//
let nodes = parse::parse(tokens);
//println!("nodes:{:#?}", nodes);
//
// アセンブリに変換
//
let result = codegen::codegen(nodes);
//println!("compiled:\n{}", result);
//
// 出力
//
output(&result, &config)?;
Ok(())
}
fn output(s: &str, config: &Config) -> Result<()> {
let path = ... | code_fim | hard | {
"lang": "rust",
"repo": "Ryomasao/rust-9cc",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryomasao/rust-9cc path: /src/lib.rs
use std::error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
// modとuseの違いがわからなくなったでござる
// 利用するときはuse。子は親をしってるけど、親は子を知らないってことかな。
// 親から利用する場合はmodで読み込んでuseかしら。
// codegenの中でmod fooとした場合、rustはcodegen/foo.rsを期待してるっぽい
// main.rsとlib.rsの場合は同じ階層... | code_fim | hard | {
"lang": "rust",
"repo": "Ryomasao/rust-9cc",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_profile_constraints(|| {
let cs = cs_enforce_value(&[false, true, true, false, false], 3, false);
print_unsatisfied_constraints(cs.clone());
assert!(cs.is_satisfied().unwrap());
});
}
#[test]
fn four_zeros... | code_fim | hard | {
"lang": "rust",
"repo": "gustavorobertux/celo-bls-snark-rs",
"path": "/crates/bls-gadgets/src/bitmap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gustavorobertux/celo-bls-snark-rs path: /crates/bls-gadgets/src/bitmap.rs
use ark_ff::PrimeField;
use ark_r1cs_std::{fields::fp::FpVar, prelude::*};
use ark_relations::{
lc,
r1cs::{LinearCombination, SynthesisError, Variable},
};
pub trait Bitmap<F: PrimeField> {
/// Enforces that t... | code_fim | hard | {
"lang": "rust",
"repo": "gustavorobertux/celo-bls-snark-rs",
"path": "/crates/bls-gadgets/src/bitmap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rng = &mut rand::thread_rng();
#[derive(Clone)]
struct BitmapGadget {
bitmap: Vec<Option<bool>>,
max_occurrences: u64,
value: bool,
}
impl ConstraintSynthesizer<Fr> for BitmapGadget {
fn generate_constraints(
... | code_fim | hard | {
"lang": "rust",
"repo": "gustavorobertux/celo-bls-snark-rs",
"path": "/crates/bls-gadgets/src/bitmap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vvbv/abstreet path: /map_model/src/pathfind/driving.rs
use crate::{DirectedRoadID, LaneID, LaneType, Map, Path, PathRequest, PathStep, Turn, TurnID};
use abstutil::{deserialize_btreemap, serialize_btreemap};
use geom::Distance;
use petgraph::graph::NodeIndex;
use petgraph::stable_graph::StableGr... | code_fim | hard | {
"lang": "rust",
"repo": "vvbv/abstreet",
"path": "/map_model/src/pathfind/driving.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let start_node = self.get_node(req.start.lane(), map);
let end_node = self.get_node(req.end.lane(), map);
let end_pt = map.get_l(req.end.lane()).first_pt();
let raw_nodes = match petgraph::algo::astar(
&self.graph,
start_node,
|n| n == e... | code_fim | hard | {
"lang": "rust",
"repo": "vvbv/abstreet",
"path": "/map_model/src/pathfind/driving.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::std::env::set_var("RUST_LOG", "info,cargo=WARN,fina=DEBUG");
::std::env::set_var("RUST_BACKTRACE", "1");
::std::env::set_var(
"DATABASE_URL",
"postgres://billac:billac@localhost/billacdb",
);
env_logger::init();
fina_app_lib::rocket().0.launch();
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "mmrath/fina-server",
"path": "/app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmrath/fina-server path: /app/src/main.rs
#![feature(plugin, decl_macro)]
#![plugin(rocket_codegen)]
#![feature(rust_2018_preview)]
<|fim_suffix|>fn main() {
::std::env::set_var("RUST_LOG", "info,cargo=WARN,fina=DEBUG");
::std::env::set_var("RUST_BACKTRACE", "1");
::std::env::set_va... | code_fim | hard | {
"lang": "rust",
"repo": "mmrath/fina-server",
"path": "/app/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>muReshapeWidget (_4: Widget, _3: c_int, _2: c_int, _1: c_int) -> c_char,
pub fn XmuScanlineAnd (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline,
pub fn XmuScanlineAndSegment (_2: *mut XmuScanline, _1: *mut XmuSegment) -> *mut XmuScanline,
pub fn XmuScanlineCopy (_2: *mut XmuScanline,... | code_fim | hard | {
"lang": "rust",
"repo": "mendess/x11-rs",
"path": "/src/xmu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mendess/x11-rs path: /src/xmu.rs
// x11-rs: Rust bindings for X11 libraries
// The X11 libraries are available under the MIT license.
// These bindings are public domain.
use std::os::raw::{
c_char,
c_int,
c_uchar,
c_uint,
c_ulong,
c_void,
};
use libc::FILE;
use ::xlib::{
Display... | code_fim | hard | {
"lang": "rust",
"repo": "mendess/x11-rs",
"path": "/src/xmu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tock/tock path: /boards/components/src/flash.rs
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.
//! Component for Flash
//!
//! Provides `FlashMux` and `FlashUser` (virtual flash).
//!
//! U... | code_fim | hard | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/components/src/flash.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Setup static space for the objects.
#[macro_export]
macro_rules! flash_user_component_static {
($F:ty) => {{
kernel::static_buf!(capsules_core::virtualizers::virtual_flash::FlashUser<'static, $F>)
};};
}
#[macro_export]
macro_rules! flash_mux_component_static {
($F:ty) => {{
... | code_fim | hard | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/components/src/flash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<F: 'static + Flash + HasClient<'static, MuxFlash<'static, F>>> Component
for FlashMuxComponent<F>
{
type StaticInput = &'static mut MaybeUninit<MuxFlash<'static, F>>;
type Output = &'static MuxFlash<'static, F>;
fn finalize(self, s: Self::StaticInput) -> Self::Output {
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/components/src/flash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: riotrah/wsld path: /server/src/util.rs
use std::future::Future;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
<|fim_suffix|>pub async fn connect_stream<R: AsyncRead + Unpin, W: AsyncWrite + Unpin>(
mut r: R,
mut w: W,
) -> std::io::Result<()> {
let mut buf = v... | code_fim | medium | {
"lang": "rust",
"repo": "riotrah/wsld",
"path": "/server/src/util.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn connect_stream<R: AsyncRead + Unpin, W: AsyncWrite + Unpin>(
mut r: R,
mut w: W,
) -> std::io::Result<()> {
let mut buf = vec![0u8; 4096];
loop {
let size = r.read(&mut buf).await?;
if size == 0 {
break;
}
w.write_all(&buf[0..size]).... | code_fim | medium | {
"lang": "rust",
"repo": "riotrah/wsld",
"path": "/server/src/util.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GoXLR-on-Linux/goxlr-utility path: /profile/src/components/submix/monitor_tree.rs
use crate::components::mixer::{InputChannels, OutputChannels};
use crate::components::submix::mix_routing_tree::Mix;
use crate::profile::Attribute;
use anyhow::Result;
use enum_map::EnumMap;
use quick_xml::events::... | code_fim | hard | {
"lang": "rust",
"repo": "GoXLR-on-Linux/goxlr-utility",
"path": "/profile/src/components/submix/monitor_tree.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if attr.name == "headphoneMix" {
if let Some(mix) = Mix::iter().nth(attr.value.parse::<usize>()? - 1) {
self.headphone_mix = mix;
}
continue;
}
// The monitor Mix only has <Channel>ToHP..
i... | code_fim | hard | {
"lang": "rust",
"repo": "GoXLR-on-Linux/goxlr-utility",
"path": "/profile/src/components/submix/monitor_tree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let reindeer = get_reindeer(&input);
assert_eq!(1120, reindeer_distance_after_seconds(&reindeer[0], 1000));
assert_eq!(1056, reindeer_distance_after_seconds(&reindeer[1], 1000));
}
#[test]
fn test_part2() {
let input = r#"Comet can fly 14 km/s for 10 seconds, ... | code_fim | hard | {
"lang": "rust",
"repo": "PsypherPunk/advent-of-code",
"path": "/2015/14/src/main.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PsypherPunk/advent-of-code path: /2015/14/src/main.rs
use std::fs;
#[derive(Debug)]
enum State {
Flying(i32),
Resting(i32),
}
#[derive(Debug)]
struct Reindeer {
name: String,
speed_km_s: i32,
distance: i32,
duration: i32,
rest: i32,
points: u32,
state: State... | code_fim | hard | {
"lang": "rust",
"repo": "PsypherPunk/advent-of-code",
"path": "/2015/14/src/main.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k0kubun/xremap path: /src/client/mod.rs
pub trait Client {
fn supported(&mut self) -> bool;
fn current_application(&mut self) -> Option<String>;
}
pub struct WMClient {
name: String,
client: Box<dyn Client>,
supported: Option<bool>,
last_application: String,
}
impl WMCl... | code_fim | hard | {
"lang": "rust",
"repo": "k0kubun/xremap",
"path": "/src/client/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "sway")]
mod sway_client;
#[cfg(feature = "sway")]
pub fn build_client() -> WMClient {
WMClient::new("Sway", Box::new(sway_client::SwayClient::new()))
}
#[cfg(feature = "hypr")]
mod hypr_client;
#[cfg(feature = "hypr")]
pub fn build_client() -> WMClient {
WMClient::new("Hypr", Box... | code_fim | hard | {
"lang": "rust",
"repo": "k0kubun/xremap",
"path": "/src/client/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: himlpplm/rust-tdlib path: /src/types/profile_photo.rs
use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Describes a user profile photo
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfilePhoto {
#[doc(hidden)]
#[serde(rename(serialize = "@extra", dese... | code_fim | hard | {
"lang": "rust",
"repo": "himlpplm/rust-tdlib",
"path": "/src/types/profile_photo.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn big(&self) -> &File {
&self.big
}
pub fn has_animation(&self) -> &Option<bool> {
&self.has_animation
}
}
#[doc(hidden)]
pub struct RTDProfilePhotoBuilder {
inner: ProfilePhoto,
}
impl RTDProfilePhotoBuilder {
pub fn build(&self) -> ProfilePhoto {
s... | code_fim | hard | {
"lang": "rust",
"repo": "himlpplm/rust-tdlib",
"path": "/src/types/profile_photo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GoXLR-on-Linux/goxlr-utility path: /launcher/src/main.rs
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use anyhow::{bail, Result};
use std::path::PathBuf;
use goxlr_ipc::client::Client;
use goxlr_ipc::clients::ipc::ipc_client::IPCClient;
use goxlr_ipc::clients::ipc::ipc_so... | code_fim | hard | {
"lang": "rust",
"repo": "GoXLR-on-Linux/goxlr-utility",
"path": "/launcher/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(path) = locate_daemon_binary() {
// Use execve to replace this process with the daemon..
let c_path = CString::new(path.to_string_lossy().as_bytes())?;
let c_daemon = CString::new(get_daemon_binary_name())?;
let c_start_ui = CString::new("--start-ui")?;
... | code_fim | hard | {
"lang": "rust",
"repo": "GoXLR-on-Linux/goxlr-utility",
"path": "/launcher/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn locate_daemon_binary() -> Option<PathBuf> {
let mut binary_path = None;
let bin_name = get_daemon_binary_name();
// There are three possible places to check for this, the CWD, the binary WD, and $PATH
let cwd = std::env::current_dir().unwrap().join(bin_name.clone());
if cwd.exists(... | code_fim | hard | {
"lang": "rust",
"repo": "GoXLR-on-Linux/goxlr-utility",
"path": "/launcher/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>spawn();
if let Err(error) = res {
println!("{}", error)
}
}<|fim_prefix|>// repo: TonnerreExtensions/launch_service path: /src/execute.rs
use std::process::Command;
pub fn execute(id: &str, is_alter: bool) {
<|fim_middle|>let mut command = Command::new("open");
let res = if is_a... | code_fim | medium | {
"lang": "rust",
"repo": "TonnerreExtensions/launch_service",
"path": "/src/execute.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> command.arg("-R").arg(id)
} else {
command.arg(id)
}
.spawn();
if let Err(error) = res {
println!("{}", error)
}
}<|fim_prefix|>// repo: TonnerreExtensions/launch_service path: /src/execute.rs
use std::process::Command;
pub fn execute(id: &str, is_alter: bool) {
... | code_fim | medium | {
"lang": "rust",
"repo": "TonnerreExtensions/launch_service",
"path": "/src/execute.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TonnerreExtensions/launch_service path: /src/execute.rs
use std::process::Command;
pub fn execute(id: &str, is_alter: bool) {
<|fim_suffix|> command.arg("-R").arg(id)
} else {
command.arg(id)
}
.spawn();
if let Err(error) = res {
println!("{}", error)
}
}... | code_fim | medium | {
"lang": "rust",
"repo": "TonnerreExtensions/launch_service",
"path": "/src/execute.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<K: fmt::Debug + TableIndex, V: Clone + Default> Table<K, V> {
/// Inserts a new key and its value.
///
/// # Complexity
///
/// Amortized O(1)
///
/// # Panics
///
/// Panics if the key already exists.
pub fn insert(&mut self, key: &K, value: V) {
let i... | code_fim | hard | {
"lang": "rust",
"repo": "matthieu-m/stysh",
"path": "/stysh-compile/src/basic/sea/table.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, K: TableIndex, V> iter::Iterator for TableIterMut<'a, K, V> {
type Item = &'a mut V;
fn next(&mut self) -> Option<Self::Item> {
if self.index < self.table.len() {
let index = K::from_index(self.index);
assert!(index.index() == self.index);
// ... | code_fim | hard | {
"lang": "rust",
"repo": "matthieu-m/stysh",
"path": "/stysh-compile/src/basic/sea/table.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matthieu-m/stysh path: /stysh-compile/src/basic/sea/table.rs
//! Table.
//!
//! The `Table` is a collection geared toward tracking one-to-one relationships
//! with O(1) memory allocations.
//!
//! In exchange for the efficiency, it only offers a limited interface.
use std::{fmt, iter, marker};... | code_fim | hard | {
"lang": "rust",
"repo": "matthieu-m/stysh",
"path": "/stysh-compile/src/basic/sea/table.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg_attr(test, mockable)]
pub fn note_patch_if_exists(account_id: String, note_id: String, note: PatchingNote, connection: &PgConnection) -> Result<usize, String> {
let target = notes::dsl::notes.filter(
notes::account_id.eq(&account_id))
.filter(notes::note_id.eq(¬e_id));
ret... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/potatosync-rust",
"path": "/src/note/repository.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/potatosync-rust path: /src/note/repository.rs
use diesel::expression::exists::exists;
use diesel::prelude::*;
use diesel::select;
#[cfg(test)]
use mocktopus::macros::*;
use crate::note::model::{Note, PatchingNote};
use crate::schema::notes;
#[cfg_attr(test, mockable)]
pub fn note_exis... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/potatosync-rust",
"path": "/src/note/repository.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(1, xor(1, 0));
assert_eq!(0, xor(0, 0));
assert_eq!(0, xor(1, 1));
assert_eq!(1, xor(0, 1));
}
}<|fim_prefix|>// repo: vagicc/logic_gates path: /src/lib.rs
#![doc(html_logo_url = "https://d30y9cdsu7xlg0.cloudfront.net/png/411962-200.png")]
//!这是一个逻辑门模拟器程序,用于... | code_fim | hard | {
"lang": "rust",
"repo": "vagicc/logic_gates",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vagicc/logic_gates path: /src/lib.rs
#![doc(html_logo_url = "https://d30y9cdsu7xlg0.cloudfront.net/png/411962-200.png")]
//!这是一个逻辑门模拟器程序,用于演示编写单元测试和集成测试 unit tests and integration tests
// logic_gates/src/lib.rs
/// 实现一个逻辑门and,将两个位作为输入,并返回一个位作为输出 bit as output
pub fn and(a: u8, b: u8) -> u8 {
... | code_fim | medium | {
"lang": "rust",
"repo": "vagicc/logic_gates",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>axAge
(
_
)
name
:
ACCESS_CONTROL_MAX_AGE
}
impl
From
<
Duration
>
for
AccessControlMaxAge
{
fn
from
(
dur
:
Duration
)
-
>
AccessControlMaxAge
{
AccessControlMaxAge
(
dur
.
into
(
)
)
}
}
impl
From
<
AccessControlMaxAge
>
for
Duration
{
fn
from
(
acma
:
AccessControlMaxAge
)
-
>
Duration
{
acma
.
0
.
int... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/headers/src/common/access_control_max_age.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/
use
std
:
:
time
:
:
Duration
;
/
/
/
use
headers
:
:
AccessControlMaxAge
;
/
/
/
/
/
/
let
max_age
=
AccessControlMaxAge
:
:
from
(
Duration
:
:
from_secs
(
531
)
)
;
/
/
/
#
[
derive
(
Clone
Debug
PartialEq
Eq
PartialOrd
Ord
Hash
)
]
pub
struct
AccessControlMaxAge
(
Seconds
)
;
derive_header
!
{
Acces... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/headers/src/common/access_control_max_age.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/headers/src/common/access_control_max_age.rs
use
std
:
:
time
:
:
Duration
;
use
util
:
:
Seconds
;
/
/
/
Access
-
Control
-
Max
-
Age
header
part
of
/
/
/
[
CORS
]
(
http
:
/
/
www
.
w3
.
org
/
TR
/
cors
/
#
access
-
control
-
max
-
age
-
resp... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/headers/src/common/access_control_max_age.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>to https://rust-unofficial.github.io/too-many-lists/index.html
fn main() {}<|fim_prefix|>// repo: gongbaodd/rust_webAssembly_study path: /src/main.rs
mod linked_list;
mod linked_node;
mod<|fim_middle|> queue;
mod stack;
/// you can refer | code_fim | easy | {
"lang": "rust",
"repo": "gongbaodd/rust_webAssembly_study",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gongbaodd/rust_webAssembly_study path: /src/main.rs
mod linked_list;
mod linked_node;
mod<|fim_suffix|>to https://rust-unofficial.github.io/too-many-lists/index.html
fn main() {}<|fim_middle|> queue;
mod stack;
/// you can refer | code_fim | easy | {
"lang": "rust",
"repo": "gongbaodd/rust_webAssembly_study",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.mongo_client.update(model)
}
fn remove(&self, mut model: Client) -> Result<(), ed::Error> {
model.is_deleted = true;
self.mongo_client.update(&model)
}
}<|fim_prefix|>// repo: prokosna/jongleur_back path: /src/infra/persistence/client.rs
use domain::model::Client;... | code_fim | hard | {
"lang": "rust",
"repo": "prokosna/jongleur_back",
"path": "/src/infra/persistence/client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prokosna/jongleur_back path: /src/infra/persistence/client.rs
use domain::model::Client;
use domain::repository::ClientRepository;
use domain::error::domain as ed;
use infra::persistence::{MongoClient, MongoModel};
#[derive(Clone)]
pub struct ClientRepositoryMongo {
pub mongo_client: MongoC... | code_fim | medium | {
"lang": "rust",
"repo": "prokosna/jongleur_back",
"path": "/src/infra/persistence/client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let plain = DMatrix::from_vec(
NUM_ROWS,
NUM_COLS,
vec![
Complex64::new(1.0, 0.0),
Complex64::new(2.0, -1.0),
Complex64::new(3.0, -5.0),
Complex64::new(4.0, 0.0),
],
);
l... | code_fim | hard | {
"lang": "rust",
"repo": "s0l0ist/rust-ckks",
"path": "/src/ckks/encoder.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.