text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: jdiazcano/ocean path: /rust/src/lib.rs
use build_system::BuildSystem;
use build_system::beans::UserConfiguration;
use std::process::Command;
use colored::*;
pub struct Rust;
impl BuildSystem for Rust {
fn build(&self, folder: &str, config: &UserConfiguration) -> i32 {
execute(&["bu... | code_fim | hard | {
"lang": "rust",
"repo": "jdiazcano/ocean",
"path": "/rust/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nhhtrung/ibc-rs path: /relayer/src/rest/error.rs
use flex_error::define_error;
use serde::Serialize;
use ibc::{ics24_host::error::ValidationError, ics24_host::identifier::ChainId};
<|fim_suffix|> ChannelRecv
{ cause: String }
|e| { format!("failed to receive a re... | code_fim | hard | {
"lang": "rust",
"repo": "nhhtrung/ibc-rs",
"path": "/relayer/src/rest/error.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> ChainConfigNotFound
{ chain_id: ChainId }
|e| { format!("could not find configuration for chain id {0}", e.chain_id) },
InvalidChainId
{ chain_id_raw: String }
[ ValidationError ]
|e| { format!("failed to parse the string {0} int... | code_fim | hard | {
"lang": "rust",
"repo": "nhhtrung/ibc-rs",
"path": "/relayer/src/rest/error.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> InvalidChainConfig
{ cause: String }
|e| { format!("failed while parsing the request body into a chain configuration {}", e.cause) },
Unimplemented
| _ | { "not implemented".to_string() },
}
}<|fim_prefix|>// repo: nhhtrung/ibc-rs path: /relayer/sr... | code_fim | hard | {
"lang": "rust",
"repo": "nhhtrung/ibc-rs",
"path": "/relayer/src/rest/error.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> match (button_pressed, modal_window_id) {
(Some(UI_MP_ROOM_PLAYER1_KICK), _) => {
system_data.ui_network_command.command =
Some(UiNetworkCommand::Kick { player_number: 0 });
StateUpdate::None
}
(Some(UI_MP_ROOM... | code_fim | hard | {
"lang": "rust",
"repo": "amethyst/grumpy_visitors",
"path": "/bins/client/src/ecs/systems/menu/multiplayer_room.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MultiplayerRoomMenuScreen {
pub fn new() -> Self {
Self {
initiated_disconnecting: false,
players: Vec::new(),
}
}
}
impl MenuScreen for MultiplayerRoomMenuScreen {
fn elements_to_show(&self, system_data: &MenuSystemData) -> Vec<MenuElement> {
... | code_fim | hard | {
"lang": "rust",
"repo": "amethyst/grumpy_visitors",
"path": "/bins/client/src/ecs/systems/menu/multiplayer_room.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amethyst/grumpy_visitors path: /bins/client/src/ecs/systems/menu/multiplayer_room.rs
use gv_client_shared::ecs::resources::ConnectionStatus;
use super::*;
use crate::{ecs::resources::UiNetworkCommand, utils::ui::disconnect_reason_title};
use gv_core::ecs::resources::net::MultiplayerRoomPlayer;
... | code_fim | hard | {
"lang": "rust",
"repo": "amethyst/grumpy_visitors",
"path": "/bins/client/src/ecs/systems/menu/multiplayer_room.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn find_mutations(indices: Vec<usize>, bodies: &[FuncBody]) -> Vec<Mutation> {
let mut mutations = Vec::<Mutation>::new();
for index in indices.iter() {
let body = &bodies[*index];
for mutator in all_mutators::ALL_MUTATORS.iter() {
mutations.append(&mut mutat... | code_fim | medium | {
"lang": "rust",
"repo": "hovinen/mutation-testing-rust",
"path": "/src/mutation/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hovinen/mutation-testing-rust path: /src/mutation/mod.rs
mod all_mutators;
mod if_condition_to_false_mutator;
mod if_condition_to_true_mutator;
mod instruction_swapping_mutator;
pub mod mutation;
mod mutator;
mod set_cancelling_mutator;
<|fim_suffix|>pub(crate) fn find_mutations(indices: Vec<us... | code_fim | medium | {
"lang": "rust",
"repo": "hovinen/mutation-testing-rust",
"path": "/src/mutation/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcls/svd2rust-example path: /lpc408x/src/qei/cmpos1.rs
#[doc = "Register `CMPOS1` reader"]
pub struct R(crate::R<CMPOS1_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<CMPOS1_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<cr... | code_fim | hard | {
"lang": "rust",
"repo": "rcls/svd2rust-example",
"path": "/lpc408x/src/qei/cmpos1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self.0
}
}
impl From<crate::W<CMPOS1_SPEC>> for W {
#[inline(always)]
fn from(writer: crate::W<CMPOS1_SPEC>) -> Self {
W(writer)
}
}
#[doc = "Field `PCMP1` reader - Position compare value 1."]
pub struct PCMP1_R(crate::FieldReader<u32, u32>);
impl PCMP1_R {
pub(cra... | code_fim | hard | {
"lang": "rust",
"repo": "rcls/svd2rust-example",
"path": "/lpc408x/src/qei/cmpos1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ct prefers .expect("reason") instead of .unwrap() so we fail
// on any .unwrap() statements in the code.
#![warn(clippy::unwrap_used)]
// Lint groups: https://doc.rust-lang.org/rustc/lints/groups.html
#![warn(future_incompatible, nonstandard_style, unused)]
#![warn(
improper_ctypes,
non_shorthand_... | code_fim | hard | {
"lang": "rust",
"repo": "aurae-runtime/aurae",
"path": "/auraescript/macros/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aurae-runtime/aurae path: /auraescript/macros/src/lib.rs
/* -------------------------------------------------------------------------- *\
* Apache 2.0 License Copyright © 2022-2023 The Aurae Authors *
* ... | code_fim | hard | {
"lang": "rust",
"repo": "aurae-runtime/aurae",
"path": "/auraescript/macros/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under... | code_fim | hard | {
"lang": "rust",
"repo": "aurae-runtime/aurae",
"path": "/auraescript/macros/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yskszk63/ssssh path: /src/connection/run/on_channel_close.rs
use tokio::io::{AsyncRead, AsyncWrite};
use crate::msg::channel_close::ChannelClose;
use crate::HandlerError;
<|fim_suffix|>impl<IO, E, Pty> Runner<IO, E, Pty>
where
IO: AsyncRead + AsyncWrite + Unpin + Send,
E: Into<HandlerE... | code_fim | medium | {
"lang": "rust",
"repo": "yskszk63/ssssh",
"path": "/src/connection/run/on_channel_close.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> hook_res.map_err(|err| {
D::Error::invalid_value(
Unexpected::Other("gitlab hook"),
&format!("{:?}", err).as_str(),
)
})
}
}<|fim_prefix|>// repo: Jezza/deploy path: /gitlab/src/hooks.rs
// Licensed under the Apache License, Vers... | code_fim | hard | {
"lang": "rust",
"repo": "Jezza/deploy",
"path": "/gitlab/src/hooks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Look for `object_kind` first because some web hooks also have `event_name` which would
// cause a false match here.
let hook_res = if val.pointer("/object_kind").is_some() {
serde_json::from_value(val).map(|hook| GitlabHook::Web(Box::new(hook)))
} else if val... | code_fim | hard | {
"lang": "rust",
"repo": "Jezza/deploy",
"path": "/gitlab/src/hooks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jezza/deploy path: /gitlab/src/hooks.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or dist... | code_fim | hard | {
"lang": "rust",
"repo": "Jezza/deploy",
"path": "/gitlab/src/hooks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// This function is used to read a knapsack instance from file. It returns either a
/// knapsack instance if everything went on well or an error describing the problem.
pub fn read_instance<P: AsRef<Path>>(fname: P) -> Result<Knapsack, Error> {
let f = File::open(fname)?;
let f = BufReader::new(f... | code_fim | hard | {
"lang": "rust",
"repo": "xgillard/ddo",
"path": "/ddo/examples/visualisation/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xgillard/ddo path: /ddo/examples/visualisation/main.rs
// Copyright 2020 Xavier Gillard
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, incl... | code_fim | hard | {
"lang": "rust",
"repo": "xgillard/ddo",
"path": "/ddo/examples/visualisation/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hgzimmerman/SWEN344-web-project path: /backend/auth/src/lib.rs
//! This is a crate for wrapping common JWT functionality needed for securing information in a webapp.
//! It is flexible in that it can support arbitrary payload subjects.
#![deny(
missing_docs,
missing_debug_implementation... | code_fim | hard | {
"lang": "rust",
"repo": "hgzimmerman/SWEN344-web-project",
"path": "/backend/auth/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::*;
/// Tests if a jwt payload can be encoded and then decoded.
#[test]
fn encode_decode() {
let payload = JwtPayload::new("hello_there".to_string(), Duration::weeks(2));
let secret = Secret::new("secret");
let encoded = payload.e... | code_fim | hard | {
"lang": "rust",
"repo": "hgzimmerman/SWEN344-web-project",
"path": "/backend/auth/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: merwaaan/psx path: /psxtest/src/main.rs
extern crate psx;
use psx::psx::PSX; // TODO rename to System or something
use imgui::*;
use std::env;
use std::path::PathBuf;
mod support;
fn main()
{
// Check the arguments
let args: Vec<String> = env::args().collect();
if args.len() < 2... | code_fim | hard | {
"lang": "rust",
"repo": "merwaaan/psx",
"path": "/psxtest/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Window::new(im_str!("Memory"))
.position([500.0, 0.0], Condition::FirstUseEver)
.size([0.0, 0.0], Condition::FirstUseEver)
.collapsed(true, Condition::FirstUseEver)
.build(ui, ||
{
// Header row
ui.text(" ... | code_fim | hard | {
"lang": "rust",
"repo": "merwaaan/psx",
"path": "/psxtest/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct ShardedCollection {
shards: Vec<Shard>,
}
impl ShardedCollection {
fn new(num_shards: usize) -> ShardedCollection {
let mut shards = vec![];
for _ in 0..num_shards {
let (request_sender, request_receiver) = channel::<RequestData>();
... | code_fim | hard | {
"lang": "rust",
"repo": "rukodb/ruko-server",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ShardedCollection { shards }
}
}
#[derive(Debug)]
pub struct Ruko {
num_shards: usize,
collections: HashMap<String, ShardedCollection>,
}
impl Default for Ruko {
fn default() -> Self {
Ruko::new()
}
}
impl Ruko {
pub fn new() -> Ruko {
Ruko {
... | code_fim | hard | {
"lang": "rust",
"repo": "rukodb/ruko-server",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rukodb/ruko-server path: /src/lib.rs
//! Ruko in-memory sharded kv database.
#![warn(
unreachable_pub,
trivial_casts,
trivial_numeric_casts,
unused_extern_crates,
rust_2018_idioms,
missing_debug_implementations
)]
use log::{error, info};
use std::collections::HashMap;
u... | code_fim | hard | {
"lang": "rust",
"repo": "rukodb/ruko-server",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let image_len = ((bi.user_image_frames.end - bi.user_image_frames.start) as usize) * kernel::PAGE_4K_SIZE;
print_bootinfo(mantle::debug(), bi).unwrap();
crust::capalloc::init_cslots(CapRange::range(bi.empty.start as usize, bi.empty.end as usize));
crust::vspace::init_vspace(executable_star... | code_fim | hard | {
"lang": "rust",
"repo": "celskeggs/searust",
"path": "/corerust/src/crust/start.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: celskeggs/searust path: /corerust/src/crust/start.rs
use ::mantle;
use ::memory;
use mantle::kernel;
use mantle::kernel::BootInfo;
use ::crust;
use ::core;
use ::kobject::*;
use core::fmt::Write;
#[no_mangle]
pub extern fn mantle_main(bootinfo: &BootInfo, executable_start: usize) {
set_boot... | code_fim | hard | {
"lang": "rust",
"repo": "celskeggs/searust",
"path": "/corerust/src/crust/start.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn prg_ram_mut(&mut self) -> &mut [u8] {
&mut self.prg_ram.as_mut()[..]
}
pub fn prg_ram(&self) -> &[u8] {
&self.prg_ram[..]
}
pub fn mapper_type(&self) -> MapperType {
self.mapper
}
}
impl<R: Rom> Display for Cartridge<R> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) ... | code_fim | hard | {
"lang": "rust",
"repo": "henrikpersson/potatis",
"path": "/nes/src/cartridge.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.len()
}
fn get(&self) -> &[u8] {
self.0
}
}
#[derive(PartialEq, Eq)]
pub struct Cartridge<R: Rom> {
rom: R,
mirroring: Mirroring,
prg: Range<usize>,
chr: Range<usize>,
chr_ram: Option<Box<[u8; CHR_ROM_BLOCK_SIZE]>>,
// PRG RAM is optional for some mappers, but 8kb is was... | code_fim | hard | {
"lang": "rust",
"repo": "henrikpersson/potatis",
"path": "/nes/src/cartridge.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: henrikpersson/potatis path: /nes/src/cartridge.rs
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::fmt::Display;
use core::ops::Range;
use common::kilobytes;
use self::error::CartridgeError;
pub const MAGIC: [u8; 4] = [0x4e, 0x45, 0x53, 0x1a];
pub const HEADER_SIZE: usize = 16;
const PRG... | code_fim | hard | {
"lang": "rust",
"repo": "henrikpersson/potatis",
"path": "/nes/src/cartridge.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/noise-rs path: /src/noise_fns/generators/fractals/mod.rs
// Copyright (c) 2017 The Noise-rs Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT
// or http://opensource.org/licens... | code_fim | medium | {
"lang": "rust",
"repo": "mystor/noise-rs",
"path": "/src/noise_fns/generators/fractals/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sources = Vec::with_capacity(octaves);
for x in 0..octaves {
sources.push(Perlin::new().set_seed(seed + x as u32));
}
sources
}<|fim_prefix|>// repo: mystor/noise-rs path: /src/noise_fns/generators/fractals/mod.rs
// Copyright (c) 2017 The Noise-rs Developers.
//
// Licens... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/noise-rs",
"path": "/src/noise_fns/generators/fractals/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: copterust/alt-stm32f30x-hal path: /src/rcc.rs
//! Reset and Clock Control
use core::cmp;
use crate::pac::{rcc, RCC};
use cast::u32;
use crate::flash::ACR;
use crate::time::Hertz;
/// Extension trait that constrains the `RCC` peripheral
pub trait RccExt {
/// Constrains the `RCC` peripher... | code_fim | hard | {
"lang": "rust",
"repo": "copterust/alt-stm32f30x-hal",
"path": "/src/rcc.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // adjust flash wait states
unsafe {
acr.acr().write(|w| {
w.latency().bits(if sysclk <= 24_000_000 {
0b000
} else if sysclk <= 48_000_000 {
... | code_fim | hard | {
"lang": "rust",
"repo": "copterust/alt-stm32f30x-hal",
"path": "/src/rcc.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: synecdoche/pelikan path: /src/rust/storage/seg/src/tests.rs
// Copyright 2021 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use super::*;
use crate::hashtable::HashBucket;
use crate::item::ITEM_HDR_SIZE;
use core::num::NonZeroU32;
... | code_fim | hard | {
"lang": "rust",
"repo": "synecdoche/pelikan",
"path": "/src/rust/storage/seg/src/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("==== third insert ====");
assert!(cache.insert(b"drink", b"whisky", None, ttl).is_ok());
assert_eq!(cache.segments.free(), 63);
assert_eq!(cache.items(), 1);
let item = cache.get(b"drink");
assert!(item.is_some());
let item = item.unwrap();
let value = item.value(... | code_fim | hard | {
"lang": "rust",
"repo": "synecdoche/pelikan",
"path": "/src/rust/storage/seg/src/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thoov/volta path: /crates/volta-core/src/run/binary.rs
use std::env;
use std::ffi::{OsStr, OsString};
use std::path::PathBuf;
use super::executor::{Executor, ToolCommand, ToolKind};
use super::{debug_active_image, debug_no_platform};
use crate::error::{Context, ErrorKind, Fallible};
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "thoov/volta",
"path": "/crates/volta-core/src/run/binary.rs",
"mode": "psm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Load information about a default binary by name, if available
///
/// A `None` response here means that the tool information couldn't be found. Either the tool
/// name is not a valid UTF-8 string, or the tool config doesn't exist.
pub fn from_name(tool_name: &OsStr, session: &mut ... | code_fim | hard | {
"lang": "rust",
"repo": "thoov/volta",
"path": "/crates/volta-core/src/run/binary.rs",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dkhayes117/5eroRISC path: /examples/user_stack.rs
#![no_std]
#![no_main]
#![feature(asm)]
extern crate panic_halt;
use hifive1::hal::prelude::*;
use hifive1::hal::DeviceResources;
use hifive1::{pin, sprintln};
use riscv_rt::entry;
//use core::mem;
use riscv::register::{mcause, mepc, mstatus, m... | code_fim | hard | {
"lang": "rust",
"repo": "dkhayes117/5eroRISC",
"path": "/examples/user_stack.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> //sprintln!("aligned array address:{:p}", raw_ptr);
//sprintln!("user_stack alignment: {}", mem::align_of_val(&user_stack));
//sprintln!("user_stack size: {}", mem::size_of_val(&user_stack));
sprintln!("stack address::{:0X}", stack_ptr as usize);
sprintln!("Trap Address::{:0X}",... | code_fim | hard | {
"lang": "rust",
"repo": "dkhayes117/5eroRISC",
"path": "/examples/user_stack.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> // start all our sender threads and blast away
for _ in 0..max_thrs {
let mut thr_snd = snd.clone();
joins.push(thread::spawn(move || for i in 0..cap {
thr_snd.send(i);
}));
}
// wait until... | code_fim | hard | {
"lang": "rust",
"repo": "elsin-r/hopper",
"path": "/tests/afl_crashes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // start our receiver thread
let mut nxt = 0;
let expected = max_thrs * cap;
let recv_jh = thread::spawn(move || {
let mut count = 0;
let dur = time::Duration::from_millis(1);
for _ in 0..100 {
... | code_fim | hard | {
"lang": "rust",
"repo": "elsin-r/hopper",
"path": "/tests/afl_crashes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elsin-r/hopper path: /tests/afl_crashes.rs
mod integration {
extern crate hopper;
extern crate tempdir;
use self::hopper::channel_with_max_bytes;
use std::thread;
use std::time;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use std::str::FromS... | code_fim | hard | {
"lang": "rust",
"repo": "elsin-r/hopper",
"path": "/tests/afl_crashes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Return a option if the current Entity is tagged
pub fn get_tag(&self) -> Option<Tag> {
ENTITIES_MANAGER.get_tag_by_entity(self)
}
pub fn group_by_id(&self, grpid: GrpTag) {
}
}<|fim_prefix|>// repo: alexandre-roulin/Kecs path: /src/entities/entity.rs
use super::*;
#[der... | code_fim | hard | {
"lang": "rust",
"repo": "alexandre-roulin/Kecs",
"path": "/src/entities/entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ///Kill all entity in the same group of `self`
pub fn kill_group(&self) {
ENTITIES_MANAGER.kill_group_by_entity(self);
}
///Tag the entity with `Tag`
pub fn tag_by_id(&self, tag: Tag) {
ENTITIES_MANAGER.tag_entity(self, tag)
}
/// Return a option if the curren... | code_fim | hard | {
"lang": "rust",
"repo": "alexandre-roulin/Kecs",
"path": "/src/entities/entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexandre-roulin/Kecs path: /src/entities/entity.rs
use super::*;
#[derive(Clone, Copy)]
#[allow(dead_code)]
pub struct Entity {
id: Id,
}
#[allow(dead_code)]
impl Entity {
pub(super) fn new(id: Id) -> Self {
Entity { id }
}
<|fim_suffix|> ///Tag the entity with `Tag`
... | code_fim | hard | {
"lang": "rust",
"repo": "alexandre-roulin/Kecs",
"path": "/src/entities/entity.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fkohlgrueber/elf-code path: /src/main.rs
pub mod part_1;
pub mod part_2;
use part_1::{
Program
};
use part_2::{
PatchProgram,
RegStatus,
};
<|fim_suffix|> let input = std::fs::read_to_string("input19.txt").unwrap();
let program = Program::from_str(&input);
println!("{}"... | code_fim | medium | {
"lang": "rust",
"repo": "fkohlgrueber/elf-code",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = std::fs::read_to_string("input19.txt").unwrap();
let program = Program::from_str(&input);
println!("{}", program);
let program_ip_inlined = program.inline_ip_lhs();
println!("{}", program_ip_inlined);
let mut patch_program = PatchProgram::from_program(program_ip_inlined... | code_fim | medium | {
"lang": "rust",
"repo": "fkohlgrueber/elf-code",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Rate limiter.
#[derive(Debug, Clone)]
pub struct Limiter {
client: Client,
limit: usize,
period: Duration,
get_key_fn: GetArcBoxKeyFn,
}
impl Limiter {
/// Construct rate limiter builder with defaults.
///
/// See [`redis-rs` docs](https://docs.rs/redis/0.21/redis/#connect... | code_fim | hard | {
"lang": "rust",
"repo": "actix/actix-extras",
"path": "/actix-limitation/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: actix/actix-extras path: /actix-limitation/src/lib.rs
//! Rate limiter using a fixed window counter for arbitrary keys, backed by Redis for Actix Web.
//!
//! ```toml
//! [dependencies]
//! actix-web = "4"
#![doc = concat!("actix-limitation = \"", env!("CARGO_PKG_VERSION_MAJOR"), ".", env!("CARG... | code_fim | hard | {
"lang": "rust",
"repo": "actix/actix-extras",
"path": "/actix-limitation/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlexPikalov/cdrs-async path: /src/query/query_values.rs
use std::{collections::HashMap, hash::Hash};
use cassandra_proto::{frame::IntoBytes, types::value::Value, types::CString};
/// Enum that represents named and simple query values.
#[derive(Debug, Clone)]
pub enum QueryValues {
/// Simple... | code_fim | hard | {
"lang": "rust",
"repo": "AlexPikalov/cdrs-async",
"path": "/src/query/query_values.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl IntoBytes for QueryValues {
fn into_cbytes(&self) -> Vec<u8> {
let bytes: Vec<u8> = vec![];
match *self {
QueryValues::SimpleValues(ref v) => v.iter().fold(bytes, QueryValues::value_into_bytes_fold),
QueryValues::NamedValues(ref v) => v
.iter()
.fold(bytes, Query... | code_fim | hard | {
"lang": "rust",
"repo": "AlexPikalov/cdrs-async",
"path": "/src/query/query_values.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !retain {
listeners_to_remove.insert(0, i);
}
}
for index in listeners_to_remove {
self.listeners.borrow_mut().swap_remove(index);
}
}
fn process_pending_modifications(&self) {
while let Some(modification) = s... | code_fim | hard | {
"lang": "rust",
"repo": "kellpossible/reactive-state",
"path": "/src/store.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kellpossible/reactive-state path: /src/store.rs
ction` to the store using
/// [dispatch()](Store::dispatch()).
pub fn state(&self) -> Rc<State> {
self.state.borrow().clone()
}
/// Dispatch an `Action` to the reducer on this `Store` without
/// invoking middleware.
... | code_fim | hard | {
"lang": "rust",
"repo": "kellpossible/reactive-state",
"path": "/src/store.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(effect) = self.middleware.borrow()[current_middleware as usize]
.clone()
.process_effect(self, effect)
{
self.middleware_process_effects_next(effect);
}
}
/// Notify store listeners of events produced during a reduce as a
... | code_fim | hard | {
"lang": "rust",
"repo": "kellpossible/reactive-state",
"path": "/src/store.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whentze/klinke path: /src/base_modules.rs
const TAU: f32 = std::f32::consts::PI * 2.0;
use crate::{Module, cables::{Input, Output}, config::SAMPLE_RATE};
#[derive(Debug, Default)]
pub struct Sine {
a: f32,
b: f32,
cos_b: f32,
sin_a: f32,
sin_a_old: f32,
}
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "whentze/klinke",
"path": "/src/base_modules.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut count = 0;
let mut sum = 0.0;
for i in is {
if i.is_connected() {
count += 1;
sum += i.get();
}
}
&o[0] << if count > 0 { sum / count as f32 } else { 0.0 };
}
}
#[derive(Debug, Default)]
pub struct... | code_fim | hard | {
"lang": "rust",
"repo": "whentze/klinke",
"path": "/src/base_modules.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, i: &[Input], o: &[Output]) {
let freq = 440.0 * 2.0f32.powf(i[0].get());
&o[0] << 2.0*(self.phase % 1.0) - 1.0;
self.phase += freq/SAMPLE_RATE;
}
}<|fim_prefix|>// repo: whentze/klinke path: /src/base_modules.rs
const TAU: f32 = std::f32::consts::PI * 2... | code_fim | hard | {
"lang": "rust",
"repo": "whentze/klinke",
"path": "/src/base_modules.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: T0mstone/clif path: /clif_proc_macro/src/template.rs
}
f.pad("*")?;
for j in 0..Zdz {
if idx & (1 << j) != 0 {
f.pad("e")?;
(j + 1).fmt(f)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "T0mstone/clif",
"path": "/clif_proc_macro/src/template.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: T0mstone/clif path: /clif_proc_macro/src/template.rs
}
if not_first {
f.pad(" + ")?;
} else {
not_first = true;
}
t.fmt(f)?;
any = true;... | code_fim | hard | {
"lang": "rust",
"repo": "T0mstone/clif",
"path": "/clif_proc_macro/src/template.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The right inner product, defined as
/// ```A.left_inner_prod(B) = sum over r,s with 0 <= r,s <= Zdz of (A.grade(r) * B.grade(s)).grade(r - s)```
#[inline]
pub fn right_inner_prod(self, rhs: Self) -> Self {
self.product_helper(rhs, |r, s| r as isize - s as is... | code_fim | hard | {
"lang": "rust",
"repo": "T0mstone/clif",
"path": "/clif_proc_macro/src/template.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rotation_radians = Rad(k.moment.rotation);
let dist = (score * 5) as f64;
let end_point = (
start_point.0 as f32 + (dist * Rad::cos(rotation_radians)).round() as f32,
start_point.1 as f32 + (dist * Rad::sin(rotation_radians)).round() as f32
);
... | code_fim | hard | {
"lang": "rust",
"repo": "patrickisroman/orbrs",
"path": "/src/fast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: patrickisroman/orbrs path: /src/fast.rs
use image::{ImageError, Rgba, GrayImage};
use imageproc::drawing::draw_line_segment_mut;
use cgmath::{prelude::{*}, Rad};
use crate::common;
use common::*;
// Consts
const DEFAULT_FAST_THRESHOLD:i32 = 50;
#[derive(Debug, Clone, Copy)]
pub struct FastKey... | code_fim | hard | {
"lang": "rust",
"repo": "patrickisroman/orbrs",
"path": "/src/fast.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oisincoveney/tda-rust path: /src/link_handler.rs
use crate::key;
use std::collections::HashMap;
use std::borrow::Borrow;
pub(crate) fn set_link_api(link: String) -> String {
str::replace(&link, "{apikey}", key::API_KEY)
}
<|fim_suffix|>pub(crate) fn check_options(keys: &[&str], options: &H... | code_fim | hard | {
"lang": "rust",
"repo": "oisincoveney/tda-rust",
"path": "/src/link_handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn set_link_params(link: String, options: HashMap<String, String>) -> String {
let mut lnk = link;
for (key, value) in &options {
lnk = set_param(&lnk, key, value);
}
lnk
}
pub(crate) fn check_options(keys: &[&str], options: &HashMap<String, String>) -> bool {
for k... | code_fim | medium | {
"lang": "rust",
"repo": "oisincoveney/tda-rust",
"path": "/src/link_handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn next(&mut self) -> Option<u64> {
match self.iter.next() {
None => None,
Some(x) => Some(x % self.div),
}
}
}<|fim_prefix|>// repo: bryanburgers/advent-of-code-2017.rs path: /day-15/src/remainder_iterator.rs
pub trait IteratorRemainderExtension {
type... | code_fim | hard | {
"lang": "rust",
"repo": "bryanburgers/advent-of-code-2017.rs",
"path": "/day-15/src/remainder_iterator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bryanburgers/advent-of-code-2017.rs path: /day-15/src/remainder_iterator.rs
pub trait IteratorRemainderExtension {
type Item;
fn to_remainder(self, div: u64) -> RemainderIterator<Self> where Self: Sized, Self: Iterator<Item=u64>;
}
impl<I> IteratorRemainderExtension for I where I: Iter... | code_fim | hard | {
"lang": "rust",
"repo": "bryanburgers/advent-of-code-2017.rs",
"path": "/day-15/src/remainder_iterator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class!(
/// **dcterms:MediaTypeOrExtent**
/// A media type or extent.
:"http://purl.org/dc/terms/MediaTypeOrExtent", MediaTypeOrExtent,
6);
class!(
/// **dcterms:RightsStatement**
/// A statement about the intellectual property rights (IPR) held in or over a Resource, a legal document giving official per... | code_fim | hard | {
"lang": "rust",
"repo": "potocpav/lv2",
"path": "/src/ontology/classes/dcterms.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: potocpav/lv2 path: /src/ontology/classes/dcterms.rs
use std;
use rome::graph;
use rome::resource;
use rome::ontology_adapter;
use ontology;
class!(
/// **dcterms:Agent**
/// A resource that acts or has the power to act.
:"http://purl.org/dc/terms/Agent", Agent,
1);
<|fim_suffix|>class!(
/// **... | code_fim | hard | {
"lang": "rust",
"repo": "potocpav/lv2",
"path": "/src/ontology/classes/dcterms.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>class!(
/// **dcterms:LinguisticSystem**
/// A system of signs, symbols, sounds, gestures, or rules used in communication.
:"http://purl.org/dc/terms/LinguisticSystem", LinguisticSystem,
4);
class!(
/// **dcterms:MediaType**
/// A file format or physical medium.
:"http://purl.org/dc/terms/MediaType", Med... | code_fim | medium | {
"lang": "rust",
"repo": "potocpav/lv2",
"path": "/src/ontology/classes/dcterms.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> let message = A2AMessage::Version2(
A2AMessageV2::GetMessages(
GetMessages::build(A2AMessageKinds::GetMessagesByConnections,
self.exclude_payload.clone(),
self.uids.clone(),
... | code_fim | hard | {
"lang": "rust",
"repo": "michalisioak/aries-vcx",
"path": "/agency_client/src/get_message.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michalisioak/aries-vcx path: /agency_client/src/get_message.rs
use crate::{get_messages, MessageStatusCode, prepare_message_for_agent, A2AMessageKinds, A2AMessageV2, A2AMessage, GeneralMessage, parse_response_from_agency, prepare_message_for_agency, agency_settings, mocking};
use crate::error::{... | code_fim | hard | {
"lang": "rust",
"repo": "michalisioak/aries-vcx",
"path": "/agency_client/src/get_message.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // todo: This should be removed after public method vcx_messages_download is removed
fn parse_download_messages_response_noauth(&self, response: Vec<u8>) -> AgencyClientResult<Vec<MessageByConnection>> {
trace!("parse_download_messages_response >>>");
let mut response = parse_respo... | code_fim | hard | {
"lang": "rust",
"repo": "michalisioak/aries-vcx",
"path": "/agency_client/src/get_message.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // without an Element containing an Entry, validation will fail
assert_eq!(
validate_update_entry_project_meta(validate_data.clone()),
Error::ProjectMetaEditableFields.into(),
);
// SUCCESS CASE, can edit name and image (only)
let valid_ori... | code_fim | hard | {
"lang": "rust",
"repo": "harlantwood/acorn",
"path": "/dna/tests/src/project/project_meta.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let valid_original_project_meta = ProjectMeta {
//make it valid, by matching the rest, but name and image
name: "test".to_string(),
image: Some("hi".to_string()),
..project_meta
};
let mut valid_original_project_meta_element = fixt!(E... | code_fim | hard | {
"lang": "rust",
"repo": "harlantwood/acorn",
"path": "/dna/tests/src/project/project_meta.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harlantwood/acorn path: /dna/tests/src/project/project_meta.rs
#[cfg(test)]
pub mod tests {
use crate::fixtures::fixtures::ProjectMetaFixturator;
use ::fixt::prelude::*;
use hdk::prelude::*;
use holo_hash::AgentPubKeyB64;
use holochain_types::prelude::option_entry_hashed;
... | code_fim | hard | {
"lang": "rust",
"repo": "harlantwood/acorn",
"path": "/dna/tests/src/project/project_meta.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn flush(&mut self) -> result::Result<(), Error> {
Ok(())
}
}<|fim_prefix|>// repo: universeroc/udp-dtls path: /src/udp_channel.rs
use std::io::{Error, Read, Result, Write};
use std::net::{SocketAddr, UdpSocket};
use std::result;
/// Wrapper to read from and sent data to an remote UDP en... | code_fim | medium | {
"lang": "rust",
"repo": "universeroc/udp-dtls",
"path": "/src/udp_channel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: universeroc/udp-dtls path: /src/udp_channel.rs
use std::io::{Error, Read, Result, Write};
use std::net::{SocketAddr, UdpSocket};
use std::result;
/// Wrapper to read from and sent data to an remote UDP endpoint.
#[derive(Debug)]
pub struct UdpChannel {
pub socket: UdpSocket,
pub remote_... | code_fim | medium | {
"lang": "rust",
"repo": "universeroc/udp-dtls",
"path": "/src/udp_channel.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonkgrimes/lox path: /src/parser.rs
use std::error::Error;
use std::fmt;
use std::fmt::Display;
use std::str::FromStr;
use crate::expr::{Assign, Binary, BoxedExpr, Call, Grouping, Literal, Logical, Unary, Variable};
use crate::lox_value::LoxValue;
use crate::stmt::{Block, Expression, Function, ... | code_fim | hard | {
"lang": "rust",
"repo": "jonkgrimes/lox",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.matches(&[TokenType::Bang, TokenType::Minus]) {
let operator = self.previous();
let right = self.unary();
return Unary::new(operator, right);
}
self.call()
}
fn call(&mut self) -> BoxedExpr {
let mut expr = self.primary(... | code_fim | hard | {
"lang": "rust",
"repo": "jonkgrimes/lox",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn call(&mut self) -> BoxedExpr {
let mut expr = self.primary();
loop {
if self.matches(&[TokenType::LeftParen]) {
expr = self.finish_call(expr);
} else {
break;
}
}
expr
}
fn finish_call(&mu... | code_fim | hard | {
"lang": "rust",
"repo": "jonkgrimes/lox",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DzenanJupic/proc_macros path: /bitfield/impl/src/_lib.rs
// TODO: just for now
#![allow(unused_imports, unused, unused_mut, dead_code)]
extern crate proc_macro;
use proc_macro::TokenStream;
use proc_macro2::{self, TokenStream as TokenStream2};
use syn::{self, parse_macro_input, Item, Ident};
us... | code_fim | hard | {
"lang": "rust",
"repo": "DzenanJupic/proc_macros",
"path": "/bitfield/impl/src/_lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (quote! {
#[repr(C)]
#src_visibility struct #src_ident {
data: [u8; #total_byte_size]
}
impl #src_ident {
pub fn new() -> Self {
Self {
data: [0u8; #total_byte_size]
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "DzenanJupic/proc_macros",
"path": "/bitfield/impl/src/_lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // create the getter and setter methods for the current field
getter_methods.push(quote! {
pub fn #getter_ident(&self) -> #field_data_type {
// let start =
self.get_bytes_as_int(&self, start: usize, bytes: usize)
let bytes: u8 = (... | code_fim | hard | {
"lang": "rust",
"repo": "DzenanJupic/proc_macros",
"path": "/bitfield/impl/src/_lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>derive(FromPrimitive)]
pub enum Instruction {
NOP = 0x1,
HLT = 0x2,
JMP = 0x3
}<|fim_prefix|>// repo: Technohacker/tiny-machine path: /system/src/isa.rs
use num_derive::FromPrimitive;
#[allow(unused<|fim_middle|>_imports)]
use num_traits::FromPrimitive;
#[ | code_fim | easy | {
"lang": "rust",
"repo": "Technohacker/tiny-machine",
"path": "/system/src/isa.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Technohacker/tiny-machine path: /system/src/isa.rs
use num_derive::FromPrimitive;
#[allow(unused_imports)]
use num_traits::FromPrimitive;
#[<|fim_suffix|>
NOP = 0x1,
HLT = 0x2,
JMP = 0x3
}<|fim_middle|>derive(FromPrimitive)]
pub enum Instruction { | code_fim | easy | {
"lang": "rust",
"repo": "Technohacker/tiny-machine",
"path": "/system/src/isa.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn toggle_online(&mut self) {
self._lamp.is_online = !self._lamp.is_online;
if self._lamp.is_online {
self.sync_lamp();
}
}
pub fn sync_lamp(&mut self) {
// Update lamp status according to Fane.
}
}<|fim_prefix|>// repo: haruka28/lovol pat... | code_fim | medium | {
"lang": "rust",
"repo": "haruka28/lovol",
"path": "/src/lohse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Turns off the lamp. Triggered by Fane's signal.
pub fn turn_off(&mut self) -> Result<(), Error> {
self._lamp.is_on = false;
if self._lamp.is_online {
// Turn off physical lamp.
}
Ok(())
}
// Toggles the light's on/off status and send it to Fa... | code_fim | hard | {
"lang": "rust",
"repo": "haruka28/lovol",
"path": "/src/lohse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haruka28/lovol path: /src/lohse.rs
use crate::lamp::Lamp;
use std::io::{Error, ErrorKind};
pub struct Lohse {
pub _lamp: Lamp,
}
impl Lohse {
pub fn receive(&mut self, _signal: &str) -> Result<(), Error> {
if !self._lamp.is_online {
return Ok(());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "haruka28/lovol",
"path": "/src/lohse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dfischer/unbase path: /tests/udp.rs
extern crate unbase;
use std::{thread, time};
#[test]
fn test_udp() {
let t1 = thread::spawn(|| {
let net1 = unbase::Network::create_new_system();
let udp1 = unbase::network::transport::TransportUDP::new("127.0.0.1:12345".to_string());
... | code_fim | hard | {
"lang": "rust",
"repo": "dfischer/unbase",
"path": "/tests/udp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::spawn(|| {
let net1 = Network::create_new_system();
let udp1 = TransportUDP::new("127.0.0.1:12021".to_string());
net1.add_transport( Box::new(udp1) );
let context_a = Slab::new(&net1).create_context();
let beast_a = SubjectHandle::new_kv(&context_a,... | code_fim | hard | {
"lang": "rust",
"repo": "dfischer/unbase",
"path": "/tests/udp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> t1.join().expect("thread1.join");
t2.join().expect("thread2.join");
}
#[test]
fn test_udp2() {
use std::{thread,time};
use unbase::{Network,Slab,SubjectHandle};
use unbase::network::transport::TransportUDP;
thread::spawn(|| {
let net1 = Network::create_new_system();
... | code_fim | hard | {
"lang": "rust",
"repo": "dfischer/unbase",
"path": "/tests/udp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Calls a function with a stack as parameters and return's its return
/// results
/// # Examples
/// ```
/// # use libvm::module::*;
/// # use libvm::function::Function;
/// let mut module: Module = Default::default();
/// let func: Function = Default::default();
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "zacklukem/vimib",
"path": "/src/libvm/src/module.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zacklukem/vimib path: /src/libvm/src/module.rs
use crate::consts;
use crate::function::Function;
use crate::vm_type::Type;
use std::collections::HashMap;
#[derive(Default, PartialEq, Debug)]
pub struct Module {
constants: Vec<u8>,
functions: HashMap<usize, Function>,
}
impl Module {
... | code_fim | hard | {
"lang": "rust",
"repo": "zacklukem/vimib",
"path": "/src/libvm/src/module.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TauGames/mlua path: /src/serde/mod.rs
//! (De)Serialization support using serde.
use std::os::raw::c_void;
use std::ptr;
use serde::{Deserialize, Serialize};
use crate::error::Result;
use crate::ffi;
use crate::lua::Lua;
use crate::table::Table;
use crate::types::LightUserData;
use crate::uti... | code_fim | hard | {
"lang": "rust",
"repo": "TauGames/mlua",
"path": "/src/serde/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
let _sg = StackGuard::new(self.state);
assert_stack(self.state, 1);
push_array_metatable(self.state);
Table(self.pop_ref())
}
}
fn to_value<T>(&'lua self, t: &T) -> Result<Value<'lua>>
where
T: Serialize + ?Siz... | code_fim | hard | {
"lang": "rust",
"repo": "TauGames/mlua",
"path": "/src/serde/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aidiakapi/advent-of-code-2016 path: /src/day24.rs
use crate::astar::AStar;
use crate::prelude::*;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Map {
columns: Vec<u64>,
height: usize,
points_of_interest: Vec<Vec2us>,
}
impl Map {
fn is_wall(&self, pos: Vec2us) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "Aidiakapi/advent-of-code-2016",
"path": "/src/day24.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Then permute the points of interest, and calculate the sum of the path sections
// for each permutation. This is O(N!).
let mut min_path_len = (std::usize::MAX, std::usize::MAX);
for permutation in
(1..map.points_of_interest.len()).permutations(map.points_of_interest.len() - 1)
... | code_fim | hard | {
"lang": "rust",
"repo": "Aidiakapi/advent-of-code-2016",
"path": "/src/day24.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.