text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: clynamen/roadsim2d path: /src/bin/road_main.rs
#![feature(duration_as_u128)]
#![feature(fn_traits)]
#![feature(unboxed_closures)]
extern crate piston_window;
extern crate piston;
extern crate rand;
extern crate euclid;
extern crate conrod;
extern crate rosrust;
#[macro_use]
extern crate rosrust... | code_fim | hard | {
"lang": "rust",
"repo": "clynamen/roadsim2d",
"path": "/src/bin/road_main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let colors = ColoredLevelConfig::new()
.info(Color::Green)
.warn(Color::Magenta)
.error(Color::Red)
.debug(Color::Blue);
if logging_level == Level::Trace || logging_level == Level::Debug {
return dispatch.format(move |out, message, record| {
out... | code_fim | hard | {
"lang": "rust",
"repo": "ethankhall/release-manager",
"path": "/src/manager_lib/logging.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ethankhall/release-manager path: /src/manager_lib/logging.rs
use chrono::Local;
use std::io::{stderr, stdout};
use fern::Dispatch;
use fern::colors::{Color, ColoredLevelConfig};
use log::Level;
pub fn configure_logging(verbose: i32, quite: bool) {
let level: Level = if quite {
log_... | code_fim | hard | {
"lang": "rust",
"repo": "ethankhall/release-manager",
"path": "/src/manager_lib/logging.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
$engine(&mut set);
)+
set
});
}
/// Renders the template named `name` with the given template info `info` and
/// context `ctxt` using one of the templates in the template set passed in. It
/// does this by checking if the template's extension matches the engine's
/// ex... | code_fim | hard | {
"lang": "rust",
"repo": "spytheman/Rocket",
"path": "/contrib/src/templates/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spytheman/Rocket path: /contrib/src/templates/macros.rs
/// Returns a hashset with the extensions of all of the enabled template
/// engines from the set of template engined passed in.
macro_rules! engine_set {
($($feature:expr => $engine:ident),+,) => ({
type RegisterFn = for<'a, 'b... | code_fim | hard | {
"lang": "rust",
"repo": "spytheman/Rocket",
"path": "/contrib/src/templates/macros.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> common::benchmark_test_case("sorted_list_add", count, |_| {
for (score, value) in &items {
db.sorted_list_add(key, score.as_slice(), value.as_bytes())
.unwrap();
}
});
common::benchmark_test_case("sorted_list_count", count, |count| {
for _ in... | code_fim | hard | {
"lang": "rust",
"repo": "leizongmin/simpledb",
"path": "/benchmark/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leizongmin/simpledb path: /benchmark/src/main.rs
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use simpledb::codec::get_score_bytes;
#[macro_use]
pub mod common;
fn main() {
test_multi_threading();
test_multi_threading2();
test_map();
test_set();
t... | code_fim | hard | {
"lang": "rust",
"repo": "leizongmin/simpledb",
"path": "/benchmark/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return response;
}
pub fn respond(&self, data: &String) -> String {
let data = data.trim().to_string();
for (re, responses) in &self.pairs {
if re.is_match(&data) {
let response = CompiledChatbot::get_random_response(&responses);
... | code_fim | hard | {
"lang": "rust",
"repo": "HectorPulido/human-language-toolkit-chatbot",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HectorPulido/human-language-toolkit-chatbot path: /src/lib.rs
pub mod bots;
extern crate custom_error;
use custom_error::custom_error;
use rand::prelude::*;
use regex::Regex;
use serde::{Deserialize, Serialize};
use serde_json;
use std::collections::HashMap;
use std::io::prelude::*;
use std::{f... | code_fim | hard | {
"lang": "rust",
"repo": "HectorPulido/human-language-toolkit-chatbot",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return responses[num].clone();
}
fn reflect(&self, bit: &String) -> String {
let mut new_bit = bit.clone().to_lowercase();
for reflection in &self.reflections {
if !new_bit.contains(&reflection.0) {
continue;
}
new_bit =... | code_fim | hard | {
"lang": "rust",
"repo": "HectorPulido/human-language-toolkit-chatbot",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phantom217/aoc path: /aoc2020/src/days/day03.rs
use crate::solution::Solution;
pub(crate) struct Solver(());
const SLOPE_PART_1: [(usize, usize); 1] = [(3, 1)];
const SLOPE_PART_2: [(usize, usize); 5] = [(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)];
impl Solver {
pub fn new() -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "Phantom217/aoc",
"path": "/aoc2020/src/days/day03.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> const INPUT: &str = "\
..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#";
#[test]
fn example_part1() {
let expected = 7;
let actual = count_trees(INPUT, &SLOPE_PART_1);
assert_eq!(actual... | code_fim | hard | {
"lang": "rust",
"repo": "Phantom217/aoc",
"path": "/aoc2020/src/days/day03.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GrandmasterTash/nails path: /src/routes/admin/mod.rs
///
/// These are endpoints that are used<|fim_suffix|>acer;
pub mod settings;
pub mod set_time;<|fim_middle|> internally by the platform or tests.
///
pub mod ping;
pub mod health;
pub mod tr | code_fim | medium | {
"lang": "rust",
"repo": "GrandmasterTash/nails",
"path": "/src/routes/admin/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>acer;
pub mod settings;
pub mod set_time;<|fim_prefix|>// repo: GrandmasterTash/nails path: /src/routes/admin/mod.rs
///
/// These are endpoints that are used internally by the platform or tests.
///<|fim_middle|>
pub mod ping;
pub mod health;
pub mod tr | code_fim | easy | {
"lang": "rust",
"repo": "GrandmasterTash/nails",
"path": "/src/routes/admin/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: google/rust_icu path: /rust_icu_ustring/src/lib.rs
// Copyright 2019 Google LLC
//
// 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/li... | code_fim | hard | {
"lang": "rust",
"repo": "google/rust_icu",
"path": "/rust_icu_ustring/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ($method_name:ident, $buffer_capacity:expr,
[$($before_arg:ident: $before_arg_type:ty,)*],
[$($after_arg:ident: $after_arg_type:ty,)*]) => {
fn $method_name(
method_to_call: unsafe extern "C" fn(
$($before_arg_type,)*
*mut sys::UChar,
... | code_fim | hard | {
"lang": "rust",
"repo": "google/rust_icu",
"path": "/rust_icu_ustring/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pryvkin10x/rust-htslib path: /src/htslib/vcf.rs
pub static mut stdout: *mut Struct__IO_FILE;
pub static mut stderr: *mut Struct__IO_FILE;
pub static mut sys_nerr: ::libc::c_int;
pub static mut sys_errlist: *const *const ::libc::c_char;
pub static mut bcf_type_shift: *mut uin... | code_fim | hard | {
"lang": "rust",
"repo": "pryvkin10x/rust-htslib",
"path": "/src/htslib/vcf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub type __locale_t = *mut Struct___locale_struct;
pub type locale_t = __locale_t;
pub type __gnuc_va_list = __builtin_va_list;
pub type va_list = __gnuc_va_list;
pub type FILE = Struct__IO_FILE;
pub type __FILE = Struct__IO_FILE;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_Unnamed26 {
pub _... | code_fim | hard | {
"lang": "rust",
"repo": "pryvkin10x/rust-htslib",
"path": "/src/htslib/vcf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pryvkin10x/rust-htslib path: /src/htslib/vcf.rs
nst BCF_HT_REAL: ::libc::c_int = 2;
pub const BCF_HT_STR: ::libc::c_int = 3;
pub const BCF_UN_STR: ::libc::c_int = 1;
pub const BCF_UN_FLT: ::libc::c_int = 2;
pub const BCF_DT_ID: ::libc::c_int = 0;
pub const BCF_DT_CTG: ::libc::c_int = 1;
pub co... | code_fim | hard | {
"lang": "rust",
"repo": "pryvkin10x/rust-htslib",
"path": "/src/htslib/vcf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NLnetLabs/routinator path: /src/process.rs
ite!(stderr, "[{}] ",
format_local_iso_date(chrono::Local::now()),
);
}
let _ = writeln!(
stderr, "[{}] {}", record.level(), record.args()
);... | code_fim | hard | {
"lang": "rust",
"repo": "NLnetLabs/routinator",
"path": "/src/process.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl LogOutput {
fn new() -> (Arc<Mutex<String>>, Self) {
let queue = Arc::new(Mutex::new(String::new()));
let res = LogOutput {
queue: queue.clone(),
current: RwLock::new(
"Initial validation ongoing. Please wait.".into(),
)
... | code_fim | hard | {
"lang": "rust",
"repo": "NLnetLabs/routinator",
"path": "/src/process.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NLnetLabs/routinator path: /src/process.rs
ting important information, and directs all logging to
/// stderr.
fn init_logging() -> Result<(), Failed> {
log::set_max_level(LevelFilter::Warn);
if let Err(err) = log::set_logger(&GLOBAL_LOGGER) {
eprintln!("Failed... | code_fim | hard | {
"lang": "rust",
"repo": "NLnetLabs/routinator",
"path": "/src/process.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mineshaft-server/chorus_api path: /src/protocol/packets/s2c/open_window.rs
define_packet!(OpenWindow, {
window_id: <|fim_suffix|>nds(window_type == "EntityHorse") i32,
});<|fim_middle|>u8,
window_type: string,
window_title: chat,
slot_count: u8,
entity_id: depe | code_fim | medium | {
"lang": "rust",
"repo": "mineshaft-server/chorus_api",
"path": "/src/protocol/packets/s2c/open_window.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nds(window_type == "EntityHorse") i32,
});<|fim_prefix|>// repo: mineshaft-server/chorus_api path: /src/protocol/packets/s2c/open_window.rs
define_packet!(OpenWindow, {
window_id: u8,
window_type: string,
window_title:<|fim_middle|> chat,
slot_count: u8,
entity_id: depe | code_fim | easy | {
"lang": "rust",
"repo": "mineshaft-server/chorus_api",
"path": "/src/protocol/packets/s2c/open_window.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[no_mangle]
#vis static #export_name: ::abi_stable::library::LibHeader = {
pub extern "C" fn _sabi_erased_module()-> ::abi_stable::library::RootModuleResult {
::abi_stable::library::__call_root_module_loader(#original_fn_ident)
}
type ... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable_derive/src/export_root_module_impl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rodrimati1992/abi_stable_crates path: /abi_stable_derive/src/export_root_module_impl.rs
//! The implementation of the `#[export_root_module]` attribute.
use super::*;
use as_derive_utils::return_spanned_err;
use syn::Ident;
use proc_macro2::Span;
use abi_stable_shared::mangled_root_module_l... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable_derive/src/export_root_module_impl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_output() {
let list = vec![
(
r##"
pub fn hello()->RString{}
"##,
"CheckTypeLayout::Yes",
),
(
r##"
... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable_derive/src/export_root_module_impl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = String::new();
channel.read_to_string(&mut s).unwrap();
println!("{}", s);
channel.wait_close().unwrap();
println!("{}", channel.exit_status().unwrap());
}
}<|fim_prefix|>// repo: jorotenev/nxx_dash path: /src/ssh.rs
pub mod ssh {
use ssh2::Session;
... | code_fim | hard | {
"lang": "rust",
"repo": "jorotenev/nxx_dash",
"path": "/src/ssh.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jorotenev/nxx_dash path: /src/ssh.rs
pub mod ssh {
use ssh2::Session;
use std::io::prelude::*;
use std::net::TcpStream;
use std::path::Path;
pub fn invoke_command(command: &str, ip: String) {
let tcp = TcpStream::c<|fim_suffix|> let mut s = String::new();
cha... | code_fim | hard | {
"lang": "rust",
"repo": "jorotenev/nxx_dash",
"path": "/src/ssh.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>C:\\Users\\Joro\\Downloads\\jorotenev-fr-2019.pem"),
None,
)
.unwrap();
let mut channel = sess.channel_session().unwrap();
channel.exec(command).unwrap();
let mut s = String::new();
channel.read_to_string(&mut s).unwrap();
println!("{}", ... | code_fim | hard | {
"lang": "rust",
"repo": "jorotenev/nxx_dash",
"path": "/src/ssh.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_rpool_r1_ok() {
let dh_secret: Secp256r1Scalar = ECScalar::from(
&BigInt::from_hex("ffa8b1420c958881923ba9f7fcaf1c5bd994499d31da5d677ca9fa79c5762a28")
.unwrap(),
)
.unwrap();
let dh_public = Secp256r1Point::from_bigint(
... | code_fim | hard | {
"lang": "rust",
"repo": "Vorticity-Flux/nash-rust",
"path": "/mpc-wallet/nash-mpc/src/server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vorticity-Flux/nash-rust path: /mpc-wallet/nash-mpc/src/server.rs
214c3e3d26b337d4937fd9a4d1c78d843c511e6de4f4f44fe7784a7edc33fdabd222be0c6600d38c55f48967847f17f6f049fe4b0ac485010226c16eece202a34b357d5acee6109d5bccfa3a61a79c80ddebb8c2cef192afa0440452739bbe55fc94b6a0af2d98328196b6041e584215a399ce... | code_fim | hard | {
"lang": "rust",
"repo": "Vorticity-Flux/nash-rust",
"path": "/mpc-wallet/nash-mpc/src/server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vorticity-Flux/nash-rust path: /mpc-wallet/nash-mpc/src/server.rs
;
use crate::curves::secp256_r1::{Secp256r1Point, Secp256r1Scalar};
use crate::curves::traits::ECScalar;
use crate::server::{
complete_sig, compute_rpool_secp256k1, compute_rpool_secp256r1, correct_key_proof_si... | code_fim | medium | {
"lang": "rust",
"repo": "Vorticity-Flux/nash-rust",
"path": "/mpc-wallet/nash-mpc/src/server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danhper/diem path: /testsuite/forge-cli/src/main.rs
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use diem_sdk::{
client::{BlockingClient, MethodRequest},
move_types::account_address::AccountAddress,
transaction_builder::Currency,
};
use forge::{... | code_fim | hard | {
"lang": "rust",
"repo": "danhper/diem",
"path": "/testsuite/forge-cli/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
#[derive(Debug)]
struct FundAccount;
impl Test for FundAccount {
fn name(&self) -> &'static str {
"fund_account"
}
}
impl PublicUsageTest for FundAccount {
fn run<'t>(&self, ctx: &mut PublicUsageContext<'t>) -> Result<()> {
let client = ctx.client();
le... | code_fim | hard | {
"lang": "rust",
"repo": "danhper/diem",
"path": "/testsuite/forge-cli/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy,Clone)]
pub struct ExtendedProcessorSignature {
ecx: u32,
edx: u32,
}
impl ExtendedProcessorSignature {
fn new() -> ExtendedProcessorSignature {
let (_, _, c, d) = cpuid(RequestType::ExtendedProcessorSignature);
ExtendedProcessorSignature { ecx: c, edx: d }
}... | code_fim | hard | {
"lang": "rust",
"repo": "shepmaster/cupid",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shepmaster/cupid path: /src/lib.rs
x:expr => $name:ident),+}) => {
$(pub fn $name(self) -> bool {
((self.$reg >> $idx) & 1) != 0
})+
}
}
macro_rules! dump {
($me:expr, $f: expr, $sname:expr, {$($name:ident),+}) => {
$f.debug_struct($sname)
... | code_fim | hard | {
"lang": "rust",
"repo": "shepmaster/cupid",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// 3 calls of 4 registers of 4 bytes
const BRAND_STRING_LENGTH: usize = 3 * 4 * 4;
pub struct BrandString {
bytes: [u8; BRAND_STRING_LENGTH],
}
impl BrandString {
fn new() -> BrandString {
fn append_bytes(a: RequestType, bytes: &mut [u8]) {
let (a, b, c, d) = cpuid(a);
... | code_fim | hard | {
"lang": "rust",
"repo": "shepmaster/cupid",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raa0121/taplo path: /taplo-lsp/src/external/wasm32/mod.rs
use crate::{create_server, create_world, utils, World};
use anyhow::anyhow;
use futures::{Future, Sink};
use js_sys::Uint8Array;
use lsp_async_stub::{rpc::Message, Server};
use lsp_types::Url;
use once_cell::sync::Lazy;
use std::{io, task... | code_fim | hard | {
"lang": "rust",
"repo": "raa0121/taplo",
"path": "/taplo-lsp/src/external/wasm32/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
struct MessageWriter;
impl Sink<Message> for MessageWriter {
type Error = io::Error;
fn poll_ready(
self: std::pin::Pin<&mut Self>,
_cx: &mut std::task::Context<'_>,
) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn start_send(sel... | code_fim | hard | {
"lang": "rust",
"repo": "raa0121/taplo",
"path": "/taplo-lsp/src/external/wasm32/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: burrbull/sleef-rs path: /src/common.rs
pub use core::f32;
pub use core::f64;
pub use core::i32;
pub use core::i64;
// ---- Advanced Traits -----------------
use doubled::*;
pub trait SqrtAsDoubled
where
Self: Sized,
{
fn sqrt_as_doubled(self) -> Doubled<Self>;
}
impl SqrtAsDoubled fo... | code_fim | hard | {
"lang": "rust",
"repo": "burrbull/sleef-rs",
"path": "/src/common.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub trait IsInt: MaskType {
fn is_integer(self) -> Self::Mask;
}
pub trait IsOdd: MaskType {
fn is_odd(self) -> Self::Mask;
}
pub trait IsNegZero: MaskType {
fn is_neg_zero(self) -> Self::Mask;
}
pub trait MaskType {
type Mask;
}
pub trait BitsType {
type Bits;
}
pub trait Sele... | code_fim | hard | {
"lang": "rust",
"repo": "burrbull/sleef-rs",
"path": "/src/common.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /crates/test-programs/wasi-tests/src/bin/file_truncation.rs
use std::{env, process};
use wasi_tests::open_scratch_directory;
unsafe fn test_file_truncation(dir_fd: wasi::Fd) {
const FILENAME: &str = "test.txt";
// Open a file for writing
let file_fd ... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/crates/test-programs/wasi-tests/src/bin/file_truncation.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ::protobuf::Clear for Verb {
fn clear(&mut self) {
self.clear_identifier();
self.clear_url();
self.clear_page_id();
self.clear_description();
self.clear_etymology();
self.clear_pronunciations();
self.clear_related();
self.clear_synon... | code_fim | hard | {
"lang": "rust",
"repo": "ian-hamlin/proto-verb-data",
"path": "/protocol/src/verb.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ian-hamlin/proto-verb-data path: /protocol/src/verb.rs
:protobuf::rt::string_size(4, &self.description);
}
if !self.etymology.is_empty() {
my_size += ::protobuf::rt::string_size(5, &self.etymology);
}
for value in &self.pronunciations {
my_... | code_fim | hard | {
"lang": "rust",
"repo": "ian-hamlin/proto-verb-data",
"path": "/protocol/src/verb.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ian-hamlin/proto-verb-data path: /protocol/src/verb.rs
] {
&self.pronunciations
}
// repeated string related = 7;
pub fn clear_related(&mut self) {
self.related.clear();
}
// Param is passed by value, moved
pub fn set_related(&mut self, v: ::protobuf::R... | code_fim | hard | {
"lang": "rust",
"repo": "ian-hamlin/proto-verb-data",
"path": "/protocol/src/verb.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bpa/advent-of-code path: /2018/src/day3/claim.rs
use nom::bytes::complete::tag;
use nom::character::complete::{digit1, multispace0};
use nom::combinator::map;
use nom::IResult;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Claim {
pub id: usize,
pub bounds: Rect,
}
#[derive(Clone... | code_fim | medium | {
"lang": "rust",
"repo": "bpa/advent-of-code",
"path": "/2018/src/day3/claim.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Claim {
pub fn overlaps(&self, other: &Claim) -> bool {
self.bounds.overlaps(&other.bounds)
}
}
impl Rect {
pub fn overlaps(&self, other: &Rect) -> bool {
self.x1 < other.x2 && self.x2 > other.x1 && self.y1 < other.y2 && self.y2 > other.y1
}
}
fn parse_claim(input: &... | code_fim | medium | {
"lang": "rust",
"repo": "bpa/advent-of-code",
"path": "/2018/src/day3/claim.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
// test of Bandwidth
#[test]
fn bandwidth_test() {
assert_eq!(Bandwidth::bw_infinite().value, 18446744073709551615);
// assert_eq!(Bandwidth::bw_zero().value, 0);
let mut bw = Bandwidth { value: 0 };
assert!(bw.bw_is_... | code_fim | hard | {
"lang": "rust",
"repo": "STAR-Tsinghua/DTP",
"path": "/src/cc/bbr.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: STAR-Tsinghua/DTP path: /src/cc/bbr.rs
}
fn get_min_rtt(&self) -> Duration {
if self.bbr_min_rtt > Duration::from_micros(0) {
return self.bbr_min_rtt;
} else {
let mut min_rtt = self.bbr_rtt_stats.rtt_stats_get_min_rtt();
if min_rtt == D... | code_fim | hard | {
"lang": "rust",
"repo": "STAR-Tsinghua/DTP",
"path": "/src/cc/bbr.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// sampler of BBR
#[derive(Debug, Clone, Copy)]
pub struct Bandwidth {
value: u64,
}
impl Bandwidth {
pub fn bw_infinite() -> Bandwidth {
Bandwidth {
value: u64::max_value(),
}
}
// usecs' type:lsquic_time_t
pub fn bw_from_bytes_and_delta(bytes: u64, usecs... | code_fim | hard | {
"lang": "rust",
"repo": "STAR-Tsinghua/DTP",
"path": "/src/cc/bbr.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: channgo2203/rosrust path: /ros_message/src/srv.rs
use crate::{Error, MessagePath, Msg, Result};
use lazy_static::lazy_static;
use regex::RegexBuilder;
use serde_derive::{Deserialize, Serialize};
use std::convert::TryFrom;
use std::fmt;
use std::fmt::Formatter;
/// A ROS service parsed from a `s... | code_fim | hard | {
"lang": "rust",
"repo": "channgo2203/rosrust",
"path": "/ros_message/src/srv.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize)]
struct SrvSerde {
path: MessagePath,
source: String,
}
impl TryFrom<SrvSerde> for Srv {
type Error = Error;
fn try_from(src: SrvSerde) -> Result<Self> {
Self::new(src.path, &src.source)
}
}
impl From<Srv> for SrvSerde {
fn from(src: Srv)... | code_fim | hard | {
"lang": "rust",
"repo": "channgo2203/rosrust",
"path": "/ros_message/src/srv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // When you "undo" a choice, remove the constraint here.
pub fn remove_conflict(&mut self, val: SudokuValue) {
self.value_conflicts[val.as_usize_idx()] -= 1;
// If this was the last choice forbidding the given value, then we
// increase the options of values we can place here.
if self... | code_fim | hard | {
"lang": "rust",
"repo": "ruggeri/sudoku_solver",
"path": "/src/checker/group_checker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruggeri/sudoku_solver path: /src/checker/group_checker.rs
use core::{SudokuValue, SUDOKU_DIM_U8, SUDOKU_DIM_USIZE};
// A SudokGroupConflictChecker keeps track of what values are available
// for a given cell in the Sudoku grid. This allows the user to quickly
// determine whether a choice is va... | code_fim | hard | {
"lang": "rust",
"repo": "ruggeri/sudoku_solver",
"path": "/src/checker/group_checker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a: A = Default::default();
println!( "struct A ({} bytes)\n f0: {:p}\n f1: {:p}\n f2: {:p}\n",
std::mem::size_of::<A>(), &a.f0, &a.f1, &a.f2);
}<|fim_prefix|>// repo: yujiimt/rust_practice path: /ch_05/src/examples/ch05_13.rs
#[derive(Default)]
struct A{f0: u8, f1: u32, f2: u8}
<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "yujiimt/rust_practice",
"path": "/ch_05/src/examples/ch05_13.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yujiimt/rust_practice path: /ch_05/src/examples/ch05_13.rs
#[derive(Default)]
struct A{f0: u8, f1: u32, f2: u8}
<|fim_suffix|> let a: A = Default::default();
println!( "struct A ({} bytes)\n f0: {:p}\n f1: {:p}\n f2: {:p}\n",
std::mem::size_of::<A>(), &a.f0, &a.f1, &a.f2);
}<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "yujiimt/rust_practice",
"path": "/ch_05/src/examples/ch05_13.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{:X}", self.0)
}
}
/// allows print Address as lower-case hex value
impl fmt::LowerHex for Address {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:x}", self.0)
}
}
/// allows Display format the Address (as upper-case hex value with 0x prefix)
... | code_fim | hard | {
"lang": "rust",
"repo": "qinsoon/zebu",
"path": "/src/utils/src/address.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qinsoon/zebu path: /src/utils/src/address.rs
// Copyright 2017 The Australian National University
//
// 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://... | code_fim | hard | {
"lang": "rust",
"repo": "qinsoon/zebu",
"path": "/src/utils/src/address.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// returns the ObjectReference
pub fn value(&self) -> usize {
self.0
}
}
/// allows equal test between Address
impl PartialEq for ObjectReference {
#[inline(always)]
fn eq(&self, other: &ObjectReference) -> bool {
self.0 == other.0
}
#[inline(always)]
fn n... | code_fim | hard | {
"lang": "rust",
"repo": "qinsoon/zebu",
"path": "/src/utils/src/address.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kornelski/lodepng-rust path: /examples/write.rs
use std::path::Path;
fn main() {
let path = &Path::new("write_test.png");
<|fim_suffix|> // encode_file takes the path to the image, a u8 array,
// the width, the height, the color mode, and the bit depth
if let Err(e) = lodepng::e... | code_fim | medium | {
"lang": "rust",
"repo": "kornelski/lodepng-rust",
"path": "/examples/write.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> // encode_file takes the path to the image, a u8 array,
// the width, the height, the color mode, and the bit depth
if let Err(e) = lodepng::encode_file(path, &image, 2, 2, lodepng::ColorType::RGB, 8) {
panic!("failed to write png: {:?}", e);
}
println!("Written to {}", path.d... | code_fim | medium | {
"lang": "rust",
"repo": "kornelski/lodepng-rust",
"path": "/examples/write.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Send a request to the Telegram server and wait for a response, timing out after `duration`.
/// Future will resolve to `None` if timeout fired.
///
/// # Examples
///
/// ```rust
/// # extern crate futures;
/// # extern crate telegram_bot_fork;
/// # extern crate to... | code_fim | hard | {
"lang": "rust",
"repo": "Emulator000/telegram-bot",
"path": "/lib/src/api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emulator000/telegram-bot path: /lib/src/api.rs
use std::{rc::Rc, time::Duration};
use futures::{future::result, Future};
use tokio;
use tokio_timer;
use telegram_bot_fork_raw::{Request, ResponseType};
use connector::Connector;
use future::{NewTelegramFuture, TelegramFuture};
use stream::{NewU... | code_fim | hard | {
"lang": "rust",
"repo": "Emulator000/telegram-bot",
"path": "/lib/src/api.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Duck {
pub fn new(id: u32, name: String, age: u32, lat: f64, long: f64) -> Duck {
Duck {
id,
name,
age,
location: Location::new(lat, long),
}
}
}<|fim_prefix|>// repo: fterdal/playing-with-rust path: /src/duck_reducer.rs
#[derive(Debug)]
pub struct Store {
state... | code_fim | medium | {
"lang": "rust",
"repo": "fterdal/playing-with-rust",
"path": "/src/duck_reducer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct Duck {
id: u32,
name: String,
age: u32,
location: Location,
}
impl Duck {
pub fn new(id: u32, name: String, age: u32, lat: f64, long: f64) -> Duck {
Duck {
id,
name,
age,
location: Location::new(lat, long),
}
}
}<|fim_prefix|>... | code_fim | hard | {
"lang": "rust",
"repo": "fterdal/playing-with-rust",
"path": "/src/duck_reducer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fterdal/playing-with-rust path: /src/duck_reducer.rs
#[derive(Debug)]
pub struct Store {
state: DuckPond,
}
impl Store {
pub fn new() -> Store {
Store { state: DuckPond::new() }
}
pub fn get_state(&self) -> &DuckPond {
&self.state
}
pub fn dispatch(&mut self, duck: Duck) {
... | code_fim | medium | {
"lang": "rust",
"repo": "fterdal/playing-with-rust",
"path": "/src/duck_reducer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaulingMonkey/vfs-zip path: /src/read/read_at_cursor.rs
use super::AbsSeekPos;
use read_write_at::ReadAt;
use std::io::{self, Read, Seek, SeekFrom};
/// Adapt [ReadAt] back into [Read] + [Seek]
#[derive(Clone)]
pub(crate) struct ReadAtCursor<RA: ReadAt> {
offset: u64,
length: u64,
... | code_fim | hard | {
"lang": "rust",
"repo": "MaulingMonkey/vfs-zip",
"path": "/src/read/read_at_cursor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<RA: ReadAt> Seek for ReadAtCursor<RA> {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
self.offset = AbsSeekPos(self.offset).offset_bounded(pos, self.length)?.0;
Ok(self.offset)
}
}<|fim_prefix|>// repo: MaulingMonkey/vfs-zip path: /src/read/read_at_cursor.rs
use supe... | code_fim | hard | {
"lang": "rust",
"repo": "MaulingMonkey/vfs-zip",
"path": "/src/read/read_at_cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
let dst = self.offset.checked_add(buf.len() as u64).ok_or_else(|| io::ErrorKind::UnexpectedEof)?;
self.ra.read_exact_at(buf, self.offset)?;
self.offset = dst;
Ok(())
}
}
impl<RA: ReadAt> Seek for ReadAtCu... | code_fim | hard | {
"lang": "rust",
"repo": "MaulingMonkey/vfs-zip",
"path": "/src/read/read_at_cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Peek for Pat {
fn peek(p: &mut Peeker<'_>) -> bool {
match p.nth(0) {
K!['('] => true,
K!['['] => true,
K![#] => matches!(p.nth(1), K!['{']),
K![_] => true,
K![..] => true,
K![byte] | K![char] | K![number] | K![str] =... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/ast/pat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/ast/pat.rs
use crate::ast::prelude::*;
#[test]
fn ast_parse() {
use crate::testing::rt;
rt::<ast::Pat>("()");
rt::<ast::Pat>("42");
rt::<ast::Pat>("-42");
rt::<ast::Pat>("3.1415");
rt::<ast::Pat>("-3.1415");
rt::<ast::Pat>("b'a'")... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/ast/pat.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A literal pattern.
#[derive(Debug, Clone, PartialEq, Eq, ToTokens, Spanned)]
#[non_exhaustive]
pub struct PatLit {
/// Attributes associated with the pattern.
#[rune(iter)]
pub attributes: Vec<ast::Attribute>,
/// The literal expression.
pub expr: Box<ast::Expr>,
}
/// The rest pa... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/ast/pat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn distance(&self, other: &CharFreq) -> usize {
let d = order_distance(&mut self.order(), &mut other.order());
// println!("JB - distance ({}) between [{}] and [{}]", d, self.order().iter().collect::<String>(), other.order().iter().collect::<String>());
d
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jbert/cpals-rust",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbert/cpals-rust path: /src/util.rs
use convert::*;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Read;
use std::time::{SystemTime, UNIX_EPOCH};
pub fn ascii_filter(in_buf: &[u8]) -> Vec<u8> {
in_buf.iter().filter(|c| c.is_ascii()).map(|c| *c).collect()
}
p... | code_fim | hard | {
"lang": "rust",
"repo": "jbert/cpals-rust",
"path": "/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvdnes/spin-rs path: /src/lib.rs
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(missing_docs)]
//! This crate provides [spin-based](https://en.wikipedia.org/wiki/Spinlock) versions of the
//! primitives in `std::sync` and `std::lazy`. B... | code_fim | hard | {
"lang": "rust",
"repo": "mvdnes/spin-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A lock that provides data access to either one writer or many readers. See [`rwlock::RwLock`] for documentation.
///
/// A note for advanced users: this alias exists to avoid subtle type inference errors due to the default relax
/// strategy type parameter. If you need a non-default relax strategy, us... | code_fim | hard | {
"lang": "rust",
"repo": "mvdnes/spin-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //use nix::sys::signal::kill;
//use nix::sys::signal::SIGINT;
//use nix::unistd::Pid;
//#[test]
// ```
// thread '<unnamed>' panicked at 'assertion failed: c.borrow().is_none()', src/libstd/sys_common/thread_info.rs:37:26
// test tests::signal ... ok
// stack backtrace:
... | code_fim | hard | {
"lang": "rust",
"repo": "replicante-io/common",
"path": "/util/upkeep/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: replicante-io/common path: /util/upkeep/src/lib.rs
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use crossbeam_channel::unbounded;
use crossbeam_channel::Receiver;
use crossbeam_channel::Select;
use crossbeam_channel::Sender;
use humthreads::ErrorKind a... | code_fim | hard | {
"lang": "rust",
"repo": "replicante-io/common",
"path": "/util/upkeep/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtolnay-contrib/tract path: /pulse/src/ops/array/pad.rs
use crate::internal::*;
use tract_core::ndarray::*;
use tract_core::ops::array::{Pad, PadMode};
use tract_pulse_opl::ops::{Delay, PulsePad};
register_all!(Pad: pulsify);
fn pulsify(
op: &Pad,
_source: &TypedModel,
node: &Typed... | code_fim | hard | {
"lang": "rust",
"repo": "dtolnay-contrib/tract",
"path": "/pulse/src/ops/array/pad.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn pad(
&mut self,
session: &mut SessionState,
op: &PulsePad,
mut input: Tensor,
) -> TractResult<Tensor> {
let pulse_begin = self.current_pos;
let pulse_end = self.current_pos + op.pulse;
self.current_pos += op.pulse;
let end_input =... | code_fim | hard | {
"lang": "rust",
"repo": "dtolnay-contrib/tract",
"path": "/pulse/src/ops/array/pad.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let PadMode::Edge = op.mode {
if after != 0 && pulse_begin < end_input {
let latest_valid_frame = (end_input - pulse_begin).min(op.pulse) - 1;
unsafe {
dispatch_copy_by_size!(Self::save_frame(input.datum_type())(
... | code_fim | hard | {
"lang": "rust",
"repo": "dtolnay-contrib/tract",
"path": "/pulse/src/ops/array/pad.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/sct0/count.rs
#[doc = "Reader of register COUNT"]
pub type R = crate::R<u32, super::COUNT>;
#[doc = "Writer for register COUNT"]
pub type W = crate::W<u32, super::COUNT>;
#[doc = "Register COUNT `reset()`'s with value 0"]
impl crate::ResetValue for super::COUNT {
... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/sct0/count.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bits >> 16) & 0xffff) as u16)
}
}
impl W {
#[doc = "Bits 0:15 - When UNIFY = 0, read or write the 16-bit L counter value. When UNIFY = 1, read or write the lower 16 bits of the 32-bit unified counter."]
#[inline(always)]
pub fn ctr_l(&mut self) -> CTR_L_W {
CTR_L_W { w: self }
... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/sct0/count.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|><< 16);
self.w
}
}
impl R {
#[doc = "Bits 0:15 - When UNIFY = 0, read or write the 16-bit L counter value. When UNIFY = 1, read or write the lower 16 bits of the 32-bit unified counter."]
#[inline(always)]
pub fn ctr_l(&self) -> CTR_L_R {
CTR_L_R::new((self.bits & 0xffff) a... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/sct0/count.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn flush_lines(&mut self) {
self.info_lines.clear();
}
pub fn solve(&mut self, res: u32) -> RawCString {
self.main_result = Some(res);
self.export()
}
pub fn export(&self) -> RawCString {
let s = self.to_string();
export_string(s)
}
}<|... | code_fim | hard | {
"lang": "rust",
"repo": "Torrencem/addcomb-local",
"path": "/src/wasm_result.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Torrencem/addcomb-local path: /src/wasm_result.rs
use std::fmt;
use std::ffi::CString;
use std::os::raw::c_char;
pub type RawCString = *mut c_char;
fn export_string(s: String) -> RawCString {
<|fim_suffix|> // Write the main results on the first line
write!(f, "{}\n", match sel... | code_fim | hard | {
"lang": "rust",
"repo": "Torrencem/addcomb-local",
"path": "/src/wasm_result.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgeisler/hal path: /src/bin/hal/cmd/psbt/edit.rs
use std::fs::File;
use std::io::Write;
use base64;
use clap;
use hex;
use bitcoin::consensus::deserialize;
use bitcoin::consensus::serialize;
use bitcoin::util::bip32;
use bitcoin::util::psbt;
use bitcoin::PublicKey;
use cmd;
pub fn subcommand... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/hal",
"path": "/src/bin/hal/cmd/psbt/edit.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn edit_output<'a>(
idx: usize,
matches: &clap::ArgMatches<'a>,
psbt: &mut psbt::PartiallySignedTransaction,
) {
let output = psbt.outputs.get_mut(idx).expect("output index out of range");
if let Some(hex) = matches.value_of("redeem-script") {
let raw = hex::decode(&hex).expect("invalid redeem-scr... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/hal",
"path": "/src/bin/hal/cmd/psbt/edit.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Gets the destination.
pub fn destination(&self) -> &XorName {
&self.destination
}
/// Gets the authorised getter.
pub fn authorised_getter(&self) -> &PublicKey {
&self.authorised_getter
}
/// Returns the data.
pub fn data(&self) -> &[u8] {
&sel... | code_fim | hard | {
"lang": "rust",
"repo": "bochaco/sn_data_types",
"path": "/src/request/login_packet.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bochaco/sn_data_types path: /src/request/login_packet.rs
// Copyright 2019 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/licen... | code_fim | hard | {
"lang": "rust",
"repo": "bochaco/sn_data_types",
"path": "/src/request/login_packet.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test("04_op_r_imm.gb")
}
#[test]
#[timeout(2000)]
fn blargg_05_op_rp() -> Result<(), String> {
run_test("05_op_rp.gb")
}
#[test]
#[timeout(2000)]
fn blargg_06_ld_r_r() -> Result<(), String> {
run_test("06_ld_r_r.gb")
}
#[test]
#[timeout(2000)]
fn blargg_07_jr_jp_call_ret_rst() -> Result... | code_fim | medium | {
"lang": "rust",
"repo": "dpchamps/WASMBoi",
"path": "/tests/cpu_integration.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test("07_jr_jp_call_ret_rst.gb")
}
#[test]
#[timeout(2000)]
fn blargg_08_misc_instrs() -> Result<(), String> {
run_test("08_misc_instrs.gb")
}
#[test]
#[timeout(5000)]
fn blargg_09_op_r_r() -> Result<(), String> {
run_test("09_op_r_r.gb")
}
#[ignore]
#[timeout(2000)]
fn blargg_10_bit_op... | code_fim | hard | {
"lang": "rust",
"repo": "dpchamps/WASMBoi",
"path": "/tests/cpu_integration.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dpchamps/WASMBoi path: /tests/cpu_integration.rs
use ntest::timeout;
mod util;
use util::run_integration_test as run_test;
#[test]
#[timeout(2000)]
fn blargg_01_special() -> Result<(), String> {
run_test("01_special.gb")
}
#[test]
#[timeout(2000)]
fn blargg_02_interrupts() -> Result<(), S... | code_fim | hard | {
"lang": "rust",
"repo": "dpchamps/WASMBoi",
"path": "/tests/cpu_integration.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: euclidr/something-about-rust path: /yield_curve/src/request.rs
use futures::{future, Future, Stream};
use hyper::client::HttpConnector;
use hyper::{Body, Client};
use hyper_tls::HttpsConnector;
use std::collections::HashMap;
use select::document::Document;
use select::node::Node;
use select::pr... | code_fim | hard | {
"lang": "rust",
"repo": "euclidr/something-about-rust",
"path": "/yield_curve/src/request.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut keys = vec![];
for (_, th) in row.find(Name("th")).enumerate() {
keys.push(th.text().trim().to_string())
}
keys
}
fn extract_row(row: &Node, keys: &Vec<String>) -> Option<HashMap<String, String>> {
if keys.len() == 0 {
return None;
}
let cnt = row.find... | code_fim | hard | {
"lang": "rust",
"repo": "euclidr/something-about-rust",
"path": "/yield_curve/src/request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: the-locksmith/fuchsia path: /garnet/bin/ui/text/test_suite/src/tests.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::test_helpers::TextFieldWrapper;
use failure::{ba... | code_fim | hard | {
"lang": "rust",
"repo": "the-locksmith/fuchsia",
"path": "/garnet/bin/ui/text/test_suite/src/tests.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>// TextField::PointOffset()/TextField::Distance()/TextField::Contents() tests
// #######################################################
pub async fn test_simple_content_request(text_field: &mut TextFieldWrapper) -> Result<(), Error> {
await!(text_field.simple_insert("meow1 meow2 meow3"))?;
// c... | code_fim | hard | {
"lang": "rust",
"repo": "the-locksmith/fuchsia",
"path": "/garnet/bin/ui/text/test_suite/src/tests.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gregl83/comandare path: /src/command.rs
use std::io;
use std::process::{Command, Output};
pub fn parse(comma<|fim_suffix|>esult = Command::new(args[0]).args(&args[1..]).output();
result
}<|fim_middle|>nd: &str) -> io::Result<Output> {
// parse command for program and args
let args: ... | code_fim | medium | {
"lang": "rust",
"repo": "gregl83/comandare",
"path": "/src/command.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>d args
let args: Vec<_> = command.split(" ").collect();
let result = Command::new(args[0]).args(&args[1..]).output();
result
}<|fim_prefix|>// repo: gregl83/comandare path: /src/command.rs
use std::io;
use std::process::{Command, Output};
pub fn parse(comma<|fim_middle|>nd: &str) -> io::Resu... | code_fim | medium | {
"lang": "rust",
"repo": "gregl83/comandare",
"path": "/src/command.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.