text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> pub fn endList(&mut self) {
glEndList();
self.enumIdx += 1;
self.registered = true;
}
pub fn call(&self, i : i32/*= 0*/) {
glCallList(self.idx + i);
}
pub fn close(&self) {
if self.registered {
glDeleteLists(self.idx, self.num);
}
}
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "MORTAL2000/titanion",
"path": "/src/util/sdl/displaylist.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MORTAL2000/titanion path: /src/util/sdl/displaylist.rs
/*
* Copyright 2005 Kenta Cho. Some rights reserved.
*/
/**
* Display list of OpenGL.
*/
use ttn::dummy::*;
pub struct DisplayList {
registered : bool,
num : i32,
idx : i32,
enumIdx : i32,
}
impl DisplayLis... | code_fim | medium | {
"lang": "rust",
"repo": "MORTAL2000/titanion",
"path": "/src/util/sdl/displaylist.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..16 {
cursor.write_u8(rand::random()).map_err(|e| {
EkkoError::RequestWriteIcmpv6Payload(e.to_string())
})?;
}
cursor.set_position(2);
cursor.write_u16::<BigEndian>(checksum_v6(cursor.get_ref(), src, dst)).map_err(|e| {
... | code_fim | hard | {
"lang": "rust",
"repo": "zaphar/Ekko",
"path": "/src/packets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zaphar/Ekko path: /src/packets.rs
use std::{
fmt::{
Result as FmtResult,
Formatter,
Debug,
},
io::{Cursor},
};
use super::error::{EkkoError};
use byteorder::{
WriteBytesExt,
ReadBytesExt,
BigEndian,
};
pub(crate) struct EchoResp... | code_fim | hard | {
"lang": "rust",
"repo": "zaphar/Ekko",
"path": "/src/packets.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spenserblack/plus-plus-rs path: /src/lib.rs
//! `++` and `--` for Rust.
//!
//! # `++`
//!
//! ```
//! # use plus_plus::ppmm;
//! let mut x = 0;
//!
//! assert_eq!(ppmm!(x++), 0);
//! assert_eq!(x, 1);
//! assert_eq!(ppmm!(++x), 2);
//! assert_eq!(x, 2);
//<|fim_suffix|>=> {
{
... | code_fim | hard | {
"lang": "rust",
"repo": "spenserblack/plus-plus-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>=> {
{
let temp = $n;
$n += 1;
temp
}
};
($n:ident --) => {
{
let temp = $n;
$n -= 1;
temp
}
};
}<|fim_prefix|>// repo: spenserblack/plus-plus-rs path: /src/lib.rs
//! `++` and `--` for Rus... | code_fim | hard | {
"lang": "rust",
"repo": "spenserblack/plus-plus-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sifton/pgors-protobuf path: /src/POGOProtos_Map_Pokemon.rs
for value in &self.spawn_point_id {
my_size += ::protobuf::rt::string_size(5, &value);
};
for value in &self.pokemon_data {
let len = value.compute_size();
my_size += 1 + ::prot... | code_fim | hard | {
"lang": "rust",
"repo": "sifton/pgors-protobuf",
"path": "/src/POGOProtos_Map_Pokemon.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn descriptor_static(_: ::std::option::Option<WildPokemon>) -> &'static ::protobuf::reflect::MessageDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as... | code_fim | hard | {
"lang": "rust",
"repo": "sifton/pgors-protobuf",
"path": "/src/POGOProtos_Map_Pokemon.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut reg = AddressRegister::new();
reg.update(0x02);
reg.update(0xFF);
assert_eq!(reg.value.0, 0x02);
assert_eq!(reg.value.1, 0xFF);
}
#[test]
fn test_ppu_addr_register_increment() {
let mut reg = AddressRegister::new();
reg.set(0x02F... | code_fim | hard | {
"lang": "rust",
"repo": "rvillegasm/phantom",
"path": "/src/nes/ppu/registers/address.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rvillegasm/phantom path: /src/nes/ppu/registers/address.rs
/// PPU read/write address (two writes: most significant byte, least significant byte).
/// RAM address: 0x2006 - Bits: aaaa aaaa.
pub struct AddressRegister {
value: (u8, u8), // (higher byte, lower byte)
hi_ptr: bool,
}
impl A... | code_fim | hard | {
"lang": "rust",
"repo": "rvillegasm/phantom",
"path": "/src/nes/ppu/registers/address.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ormat!("{}{}", "effective interest rate: ", calculators::effective_interest(12,284.00+1.60,284.00,1.00/12.00)));
}<|fim_prefix|>// repo: ldhasty/financial-calculator path: /src/main.rs
// use calculators::*;
fn main() {
println!("{}", format!("{}{}", "compound interest: ", calculators::compound... | code_fim | medium | {
"lang": "rust",
"repo": "ldhasty/financial-calculator",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ldhasty/financial-calculator path: /src/main.rs
// use calculators::*;
fn main() {
println!("{}", format!("{}{}", "compound interest: ", calculators::compound_interest(5000.50f32,7.82f32,12,1)));
println!("{}", format!("{}{}", "compound interest with contributions end of th<|fim_suffix... | code_fim | medium | {
"lang": "rust",
"repo": "ldhasty/financial-calculator",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theperiscope/uuid path: /src/main.rs
use std::env;
use std::process;
use uuid::Uuid;
fn main() {
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err| {
println!("{}", err);
process::exit(1);
});
for _ in 0..config.count {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "theperiscope/uuid",
"path": "/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Ok(Config {
count: count,
outputformat: "-a".to_string(),
});
// second argument is output format type: binary, hyphenated, simple, bytes
} else if args.len() == 3 {
return Ok(Config {
count: args[1].parse::<u32>().unwrap(),
outputformat: a... | code_fim | hard | {
"lang": "rust",
"repo": "theperiscope/uuid",
"path": "/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sjames/initception path: /src/common.rs
/*
Copyright 2020 Sojan James
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LI... | code_fim | medium | {
"lang": "rust",
"repo": "sjames/initception",
"path": "/src/common.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> TaskReply::Ok
}
}
pub enum TaskMessage {
RequestLaunch(ServiceIndex, Option<Sender<TaskReply>>),
RequestStop(ServiceIndex, Option<Sender<TaskReply>>),
RequestPause(ServiceIndex, Option<Sender<TaskReply>>),
RequestResume(ServiceIndex, Option<Sender<TaskReply>>),
ProcessLaunc... | code_fim | medium | {
"lang": "rust",
"repo": "sjames/initception",
"path": "/src/common.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let k = it.next().unwrap().parse::<i64>().unwrap();
println!("{}", if k%2 == 0 { a-b } else { b-a });
}<|fim_prefix|>// repo: pes-magic/procon path: /AtCoder/AGC024/A.rs
use std::io::Read;
fn main() {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).ok();
let mut... | code_fim | medium | {
"lang": "rust",
"repo": "pes-magic/procon",
"path": "/AtCoder/AGC024/A.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pes-magic/procon path: /AtCoder/AGC024/A.rs
use std::io::Read;
fn main() {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf<|fim_suffix|> let k = it.next().unwrap().parse::<i64>().unwrap();
println!("{}", if k%2 == 0 { a-b } else { b-a });
}<|fim_middle|>).ok(... | code_fim | hard | {
"lang": "rust",
"repo": "pes-magic/procon",
"path": "/AtCoder/AGC024/A.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: input-output-hk/jormungandr path: /jormungandr/src/context/mod.rs
use crate::{
blockchain::{Blockchain, Tip},
diagnostic::Diagnostic,
intercom::{NetworkMsg, TopologyMsg, TransactionMsg},
leadership::Logs as LeadershipLogs,
metrics::backends::SimpleCounter,
network::Global... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/jormungandr/src/context/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_bootstrap_stopper(&mut self, bootstrap_stopper: CancellationToken) {
self.bootstrap_stopper = Some(bootstrap_stopper);
}
pub fn remove_bootstrap_stopper(&mut self) {
self.bootstrap_stopper = None;
}
pub fn stop_bootstrap(&mut self) {
if let Some(can... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/jormungandr/src/context/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_diagnostic_data(&mut self, diagnostic: Diagnostic) {
self.diagnostic = Some(diagnostic);
}
pub fn get_diagnostic_data(&self) -> Result<&Diagnostic, Error> {
self.diagnostic.as_ref().ok_or(Error::Diagnostic)
}
pub fn set_blockchain(&mut self, blockchain: Blo... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/jormungandr/src/context/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eldruin/ds323x-rs path: /src/ds323x/status.rs
//! Device status
use crate::{
interface::{ReadData, WriteData},
BitFlags, Ds323x, Error, Register,
};
impl<DI, IC, CommE, PinE> Ds323x<DI, IC>
where
DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/ds323x-rs",
"path": "/src/ds323x/status.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Clear flag signalling whether the Alarm1 has matched at some point.
///
/// See also: [`has_alarm1_matched()`](#method.has_alarm1_matched)
pub fn clear_alarm1_matched_flag(&mut self) -> Result<(), Error<CommE, PinE>> {
let status = self.status | BitFlags::ALARM2F;
self.... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/ds323x-rs",
"path": "/src/ds323x/status.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Read whether the Alarm1 has matched at some point.
///
/// Once this is true, it will stay as such until cleared with
/// [`clear_alarm1_matched_flag()`](#method.clear_alarm1_matched_flag)
pub fn has_alarm1_matched(&mut self) -> Result<bool, Error<CommE, PinE>> {
let status... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/ds323x-rs",
"path": "/src/ds323x/status.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sudachen/pos-server path: /crates/pos-compute/src/lib.rs
use std::ptr;
use std::str;
pub const SPACEMESH_API_ERROR_NONE: i32 = 0;
pub const SPACEMESH_API_ERROR: i32 = -1;
pub const SPACEMESH_API_ERROR_TIMEOUT: i32 = -2;
pub const SPACEMESH_API_ERROR_ALREADY: i32 = -3;
pub const SPACEMESH_API_ER... | code_fim | hard | {
"lang": "rust",
"repo": "sudachen/pos-server",
"path": "/crates/pos-compute/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ) -> i32;
// return non-zero if stop in progress
fn spacemesh_api_stop_inprogress() -> i32;
// return POST compute providers info
fn spacemesh_api_get_providers(
providers: *mut u8, // out providers info buffer, if NULL - return count of available providers
max_provid... | code_fim | hard | {
"lang": "rust",
"repo": "sudachen/pos-server",
"path": "/crates/pos-compute/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (index, item) in self.items.iter().enumerate() {
let selected = index == self.selected_item;
item.draw(settings, debug_renderer, [left_margin, top_margin + item_space * index as i32], selected);
}
}
/// Respond to keyboard events
pub fn event<E: Gen... | code_fim | hard | {
"lang": "rust",
"repo": "PistonDevelopers/dev_menu",
"path": "/src/menu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Keyboard(Key::Down) => {
self.selected_item = self.selected_item.wrapping_add(1) % self.items.len();
}
_ => {}
}
});
let selected_item = &mut self.items[self.selected_item];
selected_item.event(e, set... | code_fim | medium | {
"lang": "rust",
"repo": "PistonDevelopers/dev_menu",
"path": "/src/menu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PistonDevelopers/dev_menu path: /src/menu.rs
use gfx;
use gfx_debug_draw::DebugRenderer;
use input::{GenericEvent, Key};
use input::Button::Keyboard;
use menu_item::MenuItem;
type ItemIndex = usize;
/// An in-game developer menu that responds to keyboard events,
/// and can be drawn using a D... | code_fim | hard | {
"lang": "rust",
"repo": "PistonDevelopers/dev_menu",
"path": "/src/menu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod providers;
mod ui;
fn main() {
log::set_boxed_logger(Logger::new()).unwrap();
log::set_max_level(log::LevelFilter::Trace);
info!("parc started");
let current_path = Path::new(".").canonicalize().unwrap();
let main_provider = Box::new(Directory::open(¤t_path));
let backgr... | code_fim | medium | {
"lang": "rust",
"repo": "coffeecup-winner/parc",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::set_boxed_logger(Logger::new()).unwrap();
log::set_max_level(log::LevelFilter::Trace);
info!("parc started");
let current_path = Path::new(".").canonicalize().unwrap();
let main_provider = Box::new(Directory::open(¤t_path));
let background_provider = Box::new(Directory::... | code_fim | medium | {
"lang": "rust",
"repo": "coffeecup-winner/parc",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coffeecup-winner/parc path: /src/main.rs
use std::path::Path;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
use crate::providers::{Directory, Log, Logger};
use crate::ui::{Input, UI};
<|fim_suffix|>fn main() {
log::set_boxed_logger(Logger::new()).unwrap();
log:... | code_fim | medium | {
"lang": "rust",
"repo": "coffeecup-winner/parc",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ellipticoin/ellipticoind path: /ellipticoind/src/system_contracts/macros.rs
#[macro_export]
macro_rules! impl_ellipticoin_externals {
($contract:ident) => {
pub struct $contract<'a> {
pub state: &'a mut State,
pub transaction: Transaction,
pub call... | code_fim | hard | {
"lang": "rust",
"repo": "ellipticoin/ellipticoind",
"path": "/ellipticoind/src/system_contracts/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.transaction.contract_address.clone()
}
fn sender(&self) -> Vec<u8> {
self.transaction.sender.clone()
}
fn caller(&self) -> Vec<u8> {
self.caller.clone()
}
fn call<
D... | code_fim | hard | {
"lang": "rust",
"repo": "ellipticoin/ellipticoind",
"path": "/ellipticoind/src/system_contracts/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TyOverby/ares-2 path: /ares/src/compiler/binding/error.rs
use ares_syntax::Symbol;
use compiler::parse::Span;
#[derive(Debug, Eq, PartialEq)]
pub enum Binding<|fim_suffix|>yDefined(Symbol),
Multiple(Vec<BindingError>)
}<|fim_middle|>Error {
CouldNotBind(Symbol, Span),
Alread | code_fim | easy | {
"lang": "rust",
"repo": "TyOverby/ares-2",
"path": "/ares/src/compiler/binding/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Error {
CouldNotBind(Symbol, Span),
AlreadyDefined(Symbol),
Multiple(Vec<BindingError>)
}<|fim_prefix|>// repo: TyOverby/ares-2 path: /ares/src/compiler/binding/error.rs
use ares_syntax::Symbol;
use compiler::parse::Span<|fim_middle|>;
#[derive(Debug, Eq, PartialEq)]
pub enum Binding | code_fim | easy | {
"lang": "rust",
"repo": "TyOverby/ares-2",
"path": "/ares/src/compiler/binding/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (w, _) = layout_glyphs(scale, font, text, |g, bb| {
g.draw(|gx, gy, gv| {
let gx = gx as i32 + bb.min.x;
let gy = gy as i32 + bb.min.y;
let image_x = gx + x;
let image_y = gy + y;
if (0..image_width).contains(&image_x) && (0..im... | code_fim | hard | {
"lang": "rust",
"repo": "uditkarode/BatbinPreviewer",
"path": "/src/ipri.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uditkarode/BatbinPreviewer path: /src/ipri.rs
use rusttype::{point, Font, PositionedGlyph, Rect, Scale};
use std::cmp::max;
use conv::ValueInto;
use image::Pixel;
use imageproc::definitions::Clamp;
use imageproc::drawing::Canvas;
use imageproc::pixelops::weighted_sum;
// These functions were ta... | code_fim | hard | {
"lang": "rust",
"repo": "uditkarode/BatbinPreviewer",
"path": "/src/ipri.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let image_x = gx + x;
let image_y = gy + y;
if (0..image_width).contains(&image_x) && (0..image_height).contains(&image_y) {
let pixel = canvas.get_pixel(image_x as u32, image_y as u32);
let weighted_color = weighted_sum(pixel, color, 1.... | code_fim | hard | {
"lang": "rust",
"repo": "uditkarode/BatbinPreviewer",
"path": "/src/ipri.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rusterlium/rustler path: /rustler/src/wrapper/check.rs
use crate::wrapper::{NIF_ENV, NIF_TERM};
macro_rules! impl_check_fun {
($name:ident, $inner:path) => {
pub unsafe fn $name(env: NIF_ENV, term: NIF_TERM) -> bool {
$inner(env, term) == 1
}
};
}
impl_check... | code_fim | hard | {
"lang": "rust",
"repo": "rusterlium/rustler",
"path": "/rustler/src/wrapper/check.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>eck_fun!(is_fun, rustler_sys::enif_is_fun);
impl_check_fun!(is_list, rustler_sys::enif_is_list);
impl_check_fun!(is_map, rustler_sys::enif_is_map);
impl_check_fun!(is_number, rustler_sys::enif_is_number);
impl_check_fun!(is_pid, rustler_sys::enif_is_pid);
impl_check_fun!(is_port, rustler_sys::enif_is_port... | code_fim | hard | {
"lang": "rust",
"repo": "rusterlium/rustler",
"path": "/rustler/src/wrapper/check.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pl_check_fun!(is_pid, rustler_sys::enif_is_pid);
impl_check_fun!(is_port, rustler_sys::enif_is_port);
impl_check_fun!(is_ref, rustler_sys::enif_is_ref);
impl_check_fun!(is_tuple, rustler_sys::enif_is_tuple);<|fim_prefix|>// repo: rusterlium/rustler path: /rustler/src/wrapper/check.rs
use crate::wrapper::... | code_fim | hard | {
"lang": "rust",
"repo": "rusterlium/rustler",
"path": "/rustler/src/wrapper/check.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r {
ExpectedToken(TokenKind, Span),
Expected(&'static str, Span),
IntegerOutOfRange(Span),
}<|fim_prefix|>// repo: czipperz/rust-comp path: /rust-comp-front/src/parse/error.rs
use crate::pos::Span;
use crate::token::TokenKind;
<|fim_middle|>#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Err... | code_fim | easy | {
"lang": "rust",
"repo": "czipperz/rust-comp",
"path": "/rust-comp-front/src/parse/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: czipperz/rust-comp path: /rust-comp-front/src/parse/error.rs
use crate::pos::Span;
use crate::token::TokenKind;
<|fim_suffix|>r {
ExpectedToken(TokenKind, Span),
Expected(&'static str, Span),
IntegerOutOfRange(Span),
}<|fim_middle|>#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Err... | code_fim | easy | {
"lang": "rust",
"repo": "czipperz/rust-comp",
"path": "/rust-comp-front/src/parse/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Creates the basic FIDL Event object containing the event type, target_moniker
/// and basic handler for resumption. It returns a tuple of the future to run the
/// handler, and the FIDL event.
async fn create_event_fidl_object(
event: Event,
) -> Result<(Option<BoxFuture<'static, ()>>, fsys::Event... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/sys/component_manager/src/model/events/serve.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/sys/component_manager/src/model/events/serve.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::{
capability::Capabilit... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/sys/component_manager/src/model/events/serve.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Saran51/akri path: /agent/src/util/device_plugin_builder.rs
use super::{
constants::{
DEVICE_PLUGIN_PATH, DEVICE_PLUGIN_SERVER_ENDER_CHANNEL_CAPACITY, K8S_DEVICE_PLUGIN_VERSION,
KUBELET_SOCKET, LIST_AND_WATCH_MESSAGE_CHANNEL_CAPACITY,
},
device_plugin_service::{Device... | code_fim | hard | {
"lang": "rust",
"repo": "Saran51/akri",
"path": "/agent/src/util/device_plugin_builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[tokio::test]
async fn test_register() {
let device_plugins_dirs = Builder::new().prefix("device-plugins").tempdir().unwrap();
let kubelet_socket = device_plugins_dirs.path().join("kubelet.sock");
let kubelet_socket_clone = kubelet_socket.clone();
let kubelet_socke... | code_fim | hard | {
"lang": "rust",
"repo": "Saran51/akri",
"path": "/agent/src/util/device_plugin_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async_stream::stream! {
while let item = uds.accept().map_ok(|(st, _)| unix_stream::UnixStream(st)).await {
yield item;
}
}
};
Server::builder()
.add_service(service)
.serve_with_incoming(i... | code_fim | hard | {
"lang": "rust",
"repo": "Saran51/akri",
"path": "/agent/src/util/device_plugin_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn shuffle<T>(&mut self, values: &mut [T]) {
let mut i = values.len();
while i >= 2 {
i -= 1;
values.swap(i, self.gen_range(0, (i + 1) as u32) as usize);
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use rand::Rng;
use std::sync::atomic::... | code_fim | hard | {
"lang": "rust",
"repo": "maidsafe-archive/safe_crypto",
"path": "/src/seeded_rng.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maidsafe-archive/safe_crypto path: /src/seeded_rng.rs
// Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// https://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses... | code_fim | hard | {
"lang": "rust",
"repo": "maidsafe-archive/safe_crypto",
"path": "/src/seeded_rng.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for SeededRng {
fn default() -> Self {
SeededRng::new()
}
}
impl Display for SeededRng {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
write!(
formatter,
"RNG seed: {:?}",
*SEED.lock().unwrap_or_else(PoisonError::int... | code_fim | hard | {
"lang": "rust",
"repo": "maidsafe-archive/safe_crypto",
"path": "/src/seeded_rng.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> match matches.subcommand() {
("search", Some(arg)) => {
let name = arg.value_of("name").expect("miss fund name");
if let Ok(v) = fund::App::new().search(name).await {
Blueprint::new(v).draw();
} else {
println!("Not found {} !"... | code_fim | hard | {
"lang": "rust",
"repo": "xiangxiaoxiao/fds",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xiangxiaoxiao/fds path: /src/main.rs
mod config;
mod fund;
mod ui;
use crate::ui::Blueprint;
use clap::{App, AppSettings, Arg, SubCommand};
use config::Config;
use std::io::Result;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<()> {
let matches = App::new(env!("CARGO_PKG... | code_fim | hard | {
"lang": "rust",
"repo": "xiangxiaoxiao/fds",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ame: expr) => {
#[cfg(feature = "profile")]
cao_profile::profile!($name)
};
}<|fim_prefix|>// repo: kissmikijr/caolo-backend path: /sim/simulation/src/utils.rs
/// If `profile` feature is enabled, records high-level profiling information to `profile.csv`.
/// Recording is done via a t... | code_fim | medium | {
"lang": "rust",
"repo": "kissmikijr/caolo-backend",
"path": "/sim/simulation/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kissmikijr/caolo-backend path: /sim/simulation/src/utils.rs
/// If `profile` feature is enabled, records high-level profiling information to `profile.csv`.
/// Recording is done via a thread-local buffer and dedicated file writing thread, in an attempt <|fim_suffix|>ame: expr) => {
#[cfg... | code_fim | medium | {
"lang": "rust",
"repo": "kissmikijr/caolo-backend",
"path": "/sim/simulation/src/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_bear_db() -> Box<dyn BearDb> {
#[cfg(target_os = "macos")]
let beardb = sqlite_db::SqliteBearDb {};
Box::new(beardb)
}<|fim_prefix|>// repo: ylgrgyq/playground path: /bear_reader/src/db/mod.rs
use crate::article::{Article};
use std::error::Error;
mod sqlite_db;
<|fim_middle|>... | code_fim | hard | {
"lang": "rust",
"repo": "ylgrgyq/playground",
"path": "/bear_reader/src/db/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ylgrgyq/playground path: /bear_reader/src/db/mod.rs
use crate::article::{Article};
use std::error::Error;
mod sqlite_db;
/// This is the arguments used to filter articles from DB
#[derive(Debug)]
pub struct SearchArguments<'a> {
title: Option<&'a str>,
limit: u32,
offset: u32,
}
<... | code_fim | hard | {
"lang": "rust",
"repo": "ylgrgyq/playground",
"path": "/bear_reader/src/db/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jason-S-Ross/stylish-stringlike path: /src/lib.rs
//! This is a libary for creating styled spans of text. The style can be
//! something like an ANSI terminal color/format, or it could be some
//! markup like enclosing text in html tags.
//!
//!
//! ## Structure
//! This crate is subdivided into... | code_fim | hard | {
"lang": "rust",
"repo": "Jason-S-Ross/stylish-stringlike",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let actual = spans
.split("::")
.map(|Split { segment, delim }| vec![segment, delim])
.flatten()
.flatten()
.map(|s| {
let foo: Box<dyn Fitable<_>> =
Box::new(TextWidget::<Spans<_>, TruncationStyle<_>>:... | code_fim | hard | {
"lang": "rust",
"repo": "Jason-S-Ross/stylish-stringlike",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chyyuu/zCore path: /zircon-loader/src/lib.rs
#![no_std]
#![feature(asm)]
#![deny(warnings, unused_must_use)]
#[macro_use]
extern crate alloc;
#[macro_use]
extern crate log;
use {
alloc::{boxed::Box, sync::Arc, vec::Vec},
core::{future::Future, pin::Pin},
xmas_elf::ElfFile,
zirc... | code_fim | hard | {
"lang": "rust",
"repo": "chyyuu/zCore",
"path": "/zircon-loader/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn handle_syscall(thread: &CurrentThread) {
let (num, args) = thread.with_context(|cx| {
let regs = cx.general;
#[cfg(target_arch = "x86_64")]
let num = regs.rax as u32;
#[cfg(target_arch = "aarch64")]
let num = regs.x16 as u32;
// LibOS: Function ... | code_fim | hard | {
"lang": "rust",
"repo": "chyyuu/zCore",
"path": "/zircon-loader/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(unused)]
fn get_datasource_fields_for_relation_field(
&self,
field: &dml::Field,
rel_info: &dml::RelationInfo,
datamodel: &dml::Datamodel,
) -> Vec<DataSourceField> {
let final_db_names = self.final_db_names_for_relation_field(&field, &rel_info, ... | code_fim | hard | {
"lang": "rust",
"repo": "cjjenkinson/prisma-engines",
"path": "/libs/datamodel/core/src/validator/standardise.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cjjenkinson/prisma-engines path: /libs/datamodel/core/src/validator/standardise.rs
// self.add_missing_relation_tables(ast_schema, schema)?;
self.set_relation_to_field_to_id_if_missing(schema);
self.name_unnamed_relations(schema);
self.populate_datasource_fields(schem... | code_fim | hard | {
"lang": "rust",
"repo": "cjjenkinson/prisma-engines",
"path": "/libs/datamodel/core/src/validator/standardise.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> datasource_fields_to_push.into_iter().for_each(|add_ds_field| {
let AddDatasourceField {
model,
field,
datasource_field,
} = add_ds_field;
let field = datamodel
.find_model_mut(&model)
... | code_fim | hard | {
"lang": "rust",
"repo": "cjjenkinson/prisma-engines",
"path": "/libs/datamodel/core/src/validator/standardise.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fee1-dead/enrgy path: /src/http/version.rs
use {
crate::http::HttpError,
std::{
fmt::{self, Display, Formatter},
str::FromStr,
},
};
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub enum Version {
Http09,
Http10,
Http11,
}
impl Dis... | code_fim | medium | {
"lang": "rust",
"repo": "fee1-dead/enrgy",
"path": "/src/http/version.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"HTTP/0.9" => Ok(Self::Http09),
"HTTP/1.0" => Ok(Self::Http10),
"HTTP/1.1" => Ok(Self::Http11),
_ => Err(HttpError::ParseUnknownVersion),
}
}
}<|fim_prefix|>// repo: fee1-dea... | code_fim | hard | {
"lang": "rust",
"repo": "fee1-dead/enrgy",
"path": "/src/http/version.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let program = vec![0x06, 0xFF, 0x00];
let mut cpu = CPU::with(program.to_vec());
cpu.mem_write(0x00FF, 0x10);
cpu.run();
assert_eq!(cpu.mem_read(0x00FF), 0x20);
}
#[test]
fn test_asl_acc() {
let program = vec![0x69, 0x10, 0x0A, 0x00];
... | code_fim | hard | {
"lang": "rust",
"repo": "EugenFeuer/feuernes",
"path": "/src/cpu/instructions/bitwise.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EugenFeuer/feuernes path: /src/cpu/instructions/bitwise.rs
use super::super::AddressMode;
use super::super::CPU;
use super::common::*;
use crate::mem::Memory;
pub fn adc(cpu: &mut CPU, mode: &AddressMode) {
let addr = cpu.get_operand_address(mode);
let data = cpu.mem_read(addr);
ad... | code_fim | hard | {
"lang": "rust",
"repo": "EugenFeuer/feuernes",
"path": "/src/cpu/instructions/bitwise.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aep/safewrt path: /packages/hatch/src/services/sentry/src/sentry/portal.rs
use sentry::proxy;
use hyper::{Headers, Method, Uri};
use tokio_core::reactor::Handle;
const HEADER_CONNECTED_IP: &'static str = "X-SC-Sentry-Connected-Ip";
const HEADER_CONNECTED_MAC: &'static str = "X-SC-Sentry-Conne... | code_fim | hard | {
"lang": "rust",
"repo": "aep/safewrt",
"path": "/packages/hatch/src/services/sentry/src/sentry/portal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let addr = "127.0.0.1:0".parse().unwrap();
let listener = TcpListener::bind(&addr, handle).unwrap();
let addr = listener.local_addr().unwrap();
let handle2 = handle.clone();
let http = hyper::server::Http::new();
handle.spawn(
listener
... | code_fim | hard | {
"lang": "rust",
"repo": "aep/safewrt",
"path": "/packages/hatch/src/services/sentry/src/sentry/portal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ///Finish writing the archive.
fn finish(&mut self) -> Result<()>;
}<|fim_prefix|>// repo: sagebind/naru path: /src/archive/write.rs
use super::Metadata;
use std::{
io::{Read, Result},
path::Path,
};
/// An incremental writer for some archive format.
pub trait ArchiveWriter {
/// Add... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/naru",
"path": "/src/archive/write.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagebind/naru path: /src/archive/write.rs
use super::Metadata;
use std::{
io::{Read, Result},
path::Path,
};
<|fim_suffix|> ///Finish writing the archive.
fn finish(&mut self) -> Result<()>;
}<|fim_middle|>/// An incremental writer for some archive format.
pub trait ArchiveWriter... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/naru",
"path": "/src/archive/write.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Add a file to the archive from a byte stream.
///
/// The path for the directory specified is relative to the root of the
/// archive.
fn add_file(&mut self, path: &Path, metadata: Metadata, file: &mut dyn Read) -> Result<()>;
///Finish writing the archive.
fn finish(&mut... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/naru",
"path": "/src/archive/write.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Perform [Lloyd's algorithm](https://en.wikipedia.org/wiki/Lloyd%27s_algorithm) on the supplied points.
///
/// This will attempt to spread the supplied points more evenly by calculating the voronoi diagram
/// of the plane and generate a new series of points which are the centers of the resultant regi... | code_fim | hard | {
"lang": "rust",
"repo": "DanMaycock/fortunes_algorithm_rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DanMaycock/fortunes_algorithm_rs path: /src/lib.rs
#![warn(clippy::all)]
#![forbid(unsafe_code)]
//!# Docs
//!
//! This is a rust implementation of
//! [fortune's algorithm](https://en.wikipedia.org/wiki/Fortune%27s_algorithm) to generate a
//! bounded [voronoi diagram](https://en.wikipedia.org/... | code_fim | hard | {
"lang": "rust",
"repo": "DanMaycock/fortunes_algorithm_rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/codebuild/src/operation_deser.rs
-> std::result::Result<
crate::output::ListSharedProjectsOutput,
crate::error::ListSharedProjectsError,
> {
Ok({
#[allow(unused_mut)]
let mut output = crate::output::list_shared_projects_output::Builder::... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/codebuild/src/operation_deser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/codebuild/src/operation_deser.rs
nse.body().as_ref(), output).map_err(crate::error::StartBuildError::unhandled)?;
output.build()
};
if (&tmp.message).is_none() {
tmp.message = _error_message;
... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/codebuild/src/operation_deser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jn0102-Rust-Experiments/Rc-LinkedList path: /src/data_structures/linked_list.rs
use std::{cell::RefCell, ptr, rc::Rc};
#[derive(Debug)]
pub enum ListOperationErr {
IndexOutOfBounds,
OperationOnEmptyList,
UnexpectedError,
ElementNotFound,
}
pub const UNEXPECTED_ERR: Li... | code_fim | hard | {
"lang": "rust",
"repo": "jn0102-Rust-Experiments/Rc-LinkedList",
"path": "/src/data_structures/linked_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn contains(&self, item: Rc<RefCell<T>>) -> bool {
let clone = self.clone();
let mut result = false;
for i in clone {
if ptr::eq(item.as_ref(), i.as_ref()) {
result = true;
}
}
result
}
fn remove(&m... | code_fim | hard | {
"lang": "rust",
"repo": "jn0102-Rust-Experiments/Rc-LinkedList",
"path": "/src/data_structures/linked_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get(&self, index: usize) -> Result<Rc<RefCell<T>>, ListOperationErr> {
self.index_check(index)?;
let mut iter = self.clone().into_iter();
for _ in 0..index {
iter.next();
}
iter.next().clone().ok_or(UNEXPECTED_ERR)
}
fn con... | code_fim | hard | {
"lang": "rust",
"repo": "jn0102-Rust-Experiments/Rc-LinkedList",
"path": "/src/data_structures/linked_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fitzgen/associative-cache path: /src/replacement.rs
//! Implementations of various replacement algorithms used when inserting into a
//! full cache.
pub use super::{Capacity, Replacement};
pub mod lru;
pub use lru::*;
/// Choose cache entries to replace in a round-robin order.
///
/// When co... | code_fim | hard | {
"lang": "rust",
"repo": "fitzgen/associative-cache",
"path": "/src/replacement.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "rand")]
impl<V, C, R> Replacement<V, C> for RandomReplacement<R>
where
C: Capacity,
R: rand::Rng,
{
#[inline]
fn choose_for_replacement<'a>(
&mut self,
candidates: impl Iterator<Item = (usize, &'a V)>,
) -> usize
where
V: 'a,
{
u... | code_fim | hard | {
"lang": "rust",
"repo": "fitzgen/associative-cache",
"path": "/src/replacement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (
bitcoin_rpc_user,
bitcoin_rpc_pass,
bitcoin_rpc_host,
bitcoin_rpc_port,
bitcoin_zmq_host,
bitcoin_zmq_block_port,
bitcoin_zmq_tx_port,
) = match config.bitcoind {
BitcoinCoreConfig::Intern... | code_fim | hard | {
"lang": "rust",
"repo": "BrianMillsJr/lnd-wrapper",
"path": "/configurator/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BrianMillsJr/lnd-wrapper path: /configurator/src/main.rs
use std::fs::File;
use std::io::{Read, Write};
use std::net::{IpAddr, SocketAddr};
use std::path::Path;
use http::Uri;
use serde::{
de::{Deserializer, Error as DeserializeError, Unexpected},
Deserialize,
};
fn deserialize_parse<'... | code_fim | hard | {
"lang": "rust",
"repo": "BrianMillsJr/lnd-wrapper",
"path": "/configurator/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> function_types: &[FunctionType],
functions: &[u32],
exports: &ExternalInterfaces,
codes: Vec<Result<(Vec<u8>, Vec<ValueTypes>)>>,
) -> Result<Vec<FunctionInstance>> {
codes
.into_iter()
.enumerate()
.map(|(idx, code)| {
let export_name = exports
.f... | code_fim | hard | {
"lang": "rust",
"repo": "kogai/wasvm",
"path": "/src/decode/section.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut internal_function_instances =
Module::function_instances(&function_types, &functions, &exports, codes)?;
let mut function_instances = Module::external_function_instances(
&function_types,
&imports_function,
&external_modules,
)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "kogai/wasvm",
"path": "/src/decode/section.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kogai/wasvm path: /src/decode/section.rs
use super::sec_element::Element;
use super::sec_table::TableType;
use super::Data;
#[cfg(not(test))]
use alloc::prelude::*;
use alloc::string::String;
use alloc::vec::Vec;
use core::convert::TryFrom;
use core::default::Default;
use error::{Result, Trap, W... | code_fim | hard | {
"lang": "rust",
"repo": "kogai/wasvm",
"path": "/src/decode/section.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lolgeny/challengerbot path: /src/submissions.rs
use crate::{
consts::MODERATOR,
database::{Database, Submission},
};
use anyhow::{anyhow, bail, Context as _, Result};
use futures::{join, lock::MutexGuard};
use serenity::{client::Context, model::{channel::{Channel, Message, Reaction}, id:... | code_fim | hard | {
"lang": "rust",
"repo": "lolgeny/challengerbot",
"path": "/src/submissions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn message_delete(ctx: &Context, message_id: &MessageId) -> Result<()> {
let mut db = get_database().lock().await;
for challenge in &mut db.challenges {
let mut index = None;
for (i, s) in challenge.submissions.iter().enumerate() {
if &s.message == message_id ... | code_fim | hard | {
"lang": "rust",
"repo": "lolgeny/challengerbot",
"path": "/src/submissions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gimli-rs/gimli path: /src/read/loclists.rs
(self.debug_loc.section.clone(), LocListsFormat::Bare)
} else {
(self.debug_loclists.section.clone(), LocListsFormat::Lle)
};
input.skip(offset.0)?;
Ok(RawLocListIter::new(input, unit_encoding, format)... | code_fim | hard | {
"lang": "rust",
"repo": "gimli-rs/gimli",
"path": "/src/read/loclists.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let start = Label::new();
let first = Label::new();
let size = Label::new();
#[rustfmt::skip]
let section = Section::with_endian(Endian::Little)
// Header
.mark(&start)
.L32(&size)
.L16(encoding.version)
.L... | code_fim | hard | {
"lang": "rust",
"repo": "gimli-rs/gimli",
"path": "/src/read/loclists.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> eprintln!("Usage: bundle [-o output] path/to/project excluded_dep1 excluded_dep2");
std::process::exit(1);
}<|fim_prefix|>// repo: Ten0/rust-bundler path: /src/main.rs
extern crate bundler;
use std::collections::HashSet;
fn main() {
let mut args = std::env::args().skip(1).peekable();
let write_code... | code_fim | medium | {
"lang": "rust",
"repo": "Ten0/rust-bundler",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ten0/rust-bundler path: /src/main.rs
extern crate bundler;
use std::collections::HashSet;
fn main() {
let mut args = std::env::args().skip(1).peekable();
let write_code_to = if args.peek().unwrap_or_else(|| usage()) == "-o" {
Some(args.nth(1).unwrap_or_else(|| usage()))
} else {
None
}... | code_fim | medium | {
"lang": "rust",
"repo": "Ten0/rust-bundler",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rocket::ignite()
.attach(prime::PrimeInterface::fairing())
.mount(
"/",
routes![root, first_greater_than, greater_than, at_position],
)
.launch();
}<|fim_prefix|>// repo: Leereen/fbp path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]... | code_fim | hard | {
"lang": "rust",
"repo": "Leereen/fbp",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> prime_i.at_position(position).to_json()
}
fn main() {
rocket::ignite()
.attach(prime::PrimeInterface::fairing())
.mount(
"/",
routes![root, first_greater_than, greater_than, at_position],
)
.launch();
}<|fim_prefix|>// repo: Leereen/fbp pat... | code_fim | hard | {
"lang": "rust",
"repo": "Leereen/fbp",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Leereen/fbp path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
#[macro_use]
extern crate diesel;
use rocket::response::content::Json;
mod prime;
use prime::PrimeInterface;
#[get("/")]
fn root(prime_i: Pri... | code_fim | hard | {
"lang": "rust",
"repo": "Leereen/fbp",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jaxelr/RustTutorial path: /The Rust Book/16_02_channels/src/main.rs
use std::thread;
use std::sync::mpsc;
use std::time::Duration;
fn main() {
//Initial basic example of message sending.
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let val = String::from("Hi");
... | code_fim | hard | {
"lang": "rust",
"repo": "Jaxelr/RustTutorial",
"path": "/The Rust Book/16_02_channels/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for val in vals {
tx3.send(val).unwrap();
thread::sleep(Duration::from_secs(1));
}
});
for received in rx3 {
println!("Third got: {}", received);
}
}<|fim_prefix|>// repo: Jaxelr/RustTutorial path: /The Rust Book/16_02_channels/src/main.rs
use ... | code_fim | hard | {
"lang": "rust",
"repo": "Jaxelr/RustTutorial",
"path": "/The Rust Book/16_02_channels/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(buffer)
}
pub fn to_bytes(&self) -> Result<Vec<u8>> {
self.to_vec::<_, i8>(sys::napi_get_value_string_utf8)
}
pub fn to_latin1(&self) -> Result<Vec<u8>> {
self.to_vec::<_, i8>(sys::napi_get_value_string_latin1)
}
pub fn to_utf16(&self) -> Result<Vec<u1... | code_fim | hard | {
"lang": "rust",
"repo": "aqrln/jsfest2019-napi-rust",
"path": "/examples-rust/napi/src/value/string.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.