text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: rust-lang/miri path: /src/shims/dlsym.rs
use rustc_middle::mir;
use rustc_target::spec::abi::Abi;
use crate::helpers::target_os_is_unix;
use crate::*;
use shims::unix::dlsym as unix;
use shims::windows::dlsym as windows;
<|fim_suffix|>impl Dlsym {
// Returns an error for unsupported symbol... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/miri",
"path": "/src/shims/dlsym.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
fn call_dlsym(
&mut self,
dlsym: Dlsym,
abi: Abi,
args: &[OpTy<'tcx, Provenance>],
dest: &Pl... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/miri",
"path": "/src/shims/dlsym.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// swapping f0 with f1 and f1 with f2.
f0 = replace(&mut f1, f2);
//println!("{}%", percent);
}
f0
}
fn main() {
println!("fib(1000000) = {}", fib(1000000));
}<|fim_prefix|>// repo: TPXS/rosetta-code-contributions path: /rust_nth_fibonacci_number/src/main.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "TPXS/rosetta-code-contributions",
"path": "/rust_nth_fibonacci_number/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TPXS/rosetta-code-contributions path: /rust_nth_fibonacci_number/src/main.rs
extern crate num_bigint;
extern crate num_traits;
use num_bigint::BigUint;
use num_traits::{One, Zero};
use std::mem::replace;
<|fim_suffix|> // swapping f0 with f1 and f1 with f2.
f0 = replace(&mut f1,... | code_fim | hard | {
"lang": "rust",
"repo": "TPXS/rosetta-code-contributions",
"path": "/rust_nth_fibonacci_number/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SpannerProtocol/spanner path: /pallets/rewards/src/mock.rs
use super::*;
use crate as pallet_rewards;
use frame_support::{dispatch::DispatchError, weights::Weight, construct_runtime, parameter_types, sp_std};
use primitives::{TokenSymbol, Amount};
use sp_core::H256;
use sp_runtime::{testing::Hea... | code_fim | hard | {
"lang": "rust",
"repo": "SpannerProtocol/spanner",
"path": "/pallets/rewards/src/mock.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_swap_supply_amount(_: &[CurrencyId], _: Balance, _: Option<Ratio>) -> Option<Balance> {
unimplemented!()
}
fn swap_with_exact_supply(
_: &AccountId,
_: &[CurrencyId],
_: Balance,
_: Balance,
_: Option<Ratio>,
) -> sp_std::result::Resu... | code_fim | hard | {
"lang": "rust",
"repo": "SpannerProtocol/spanner",
"path": "/pallets/rewards/src/mock.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xlnx/myrpg path: /src/lalr_util/src/parse_util.rs
use std::collections::{BTreeSet, HashMap, HashSet, VecDeque};
use std::hash::{Hash, Hasher};
use pretty::{Doc, *};
use crate::ast::{Ast, Token};
use crate::log::{LogItem, Severity, SourceFileLocation, SourceLocationProvider};
use crate::rule::{... | code_fim | hard | {
"lang": "rust",
"repo": "xlnx/myrpg",
"path": "/src/lalr_util/src/parse_util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let la = if let Some(old_item) = self.0.get(&item) {
// println!("{:?}", item);
// println!("{:?}", );
// la has no item.
if !item.gt_some_what(&old_item) {
return false;
}
self.0
.take(&item)
... | code_fim | hard | {
"lang": "rust",
"repo": "xlnx/myrpg",
"path": "/src/lalr_util/src/parse_util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T> std::fmt::Debug for Item<'a, T> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.as_string())
}
}
pub struct Closure<'a, T>(BTreeSet<Item<'a, T>>, &'a Grammar<T>);
impl<'a, T> Closure<'a, T> {
pub fn iter(&self) -> std::collections::... | code_fim | hard | {
"lang": "rust",
"repo": "xlnx/myrpg",
"path": "/src/lalr_util/src/parse_util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
pub fn close_pane_with_multiple_panes_to_the_right() {
// ┌─────┬─────┐ ┌──────────┐
// │█████│xxxxx│ │xxxxxxxxxx│
// │█████│xxxxx│ │xxxxxxxxxx│
// │█████├─────┤ ==close==> ├──────────┤
// │█████│xxxxx│ │xxxxxxxxxx│
// │█████│xxxx... | code_fim | hard | {
"lang": "rust",
"repo": "TheLostLambda/zellij",
"path": "/src/tests/integration/close_pane.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheLostLambda/zellij path: /src/tests/integration/close_pane.rs
nd snapshot");
assert_snapshot!(snapshot_before_quit);
}
#[test]
pub fn close_pane_with_another_pane_to_the_left() {
// ┌─────┬─────┐ ┌──────────┐
// │xxxxx│█████│ │xxxxxxxxxx│
// │xxxxx│█████│... | code_fim | hard | {
"lang": "rust",
"repo": "TheLostLambda/zellij",
"path": "/src/tests/integration/close_pane.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
pub fn close_pane_with_multiple_panes_below_it_away_from_screen_edges() {
// ┌───┬───────┬───┐ ┌───┬───┬───┬───┐
// │xxx│███████│xxx│ │xxx│xxx│xxx│xxx│
// │xxx│███████│xxx│ │xxx│xxx│xxx│xxx│
// │xxx├───┬───┤xxx│ ==close==> │xxx│xxx│xxx│xxx│
// ├... | code_fim | hard | {
"lang": "rust",
"repo": "TheLostLambda/zellij",
"path": "/src/tests/integration/close_pane.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match n_args {
1 => repl(),
2 => run_file(&args[1]),
_ => {
println!("Usage: ./rlox [script.lox]");
}
}
}<|fim_prefix|>// repo: KHN190/rlox path: /src/main.rs
#![allow(dead_code)]
#[macro_use]
mod macros;
<|fim_middle|>mod chunk;
mod compiler;
mod deb... | code_fim | hard | {
"lang": "rust",
"repo": "KHN190/rlox",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KHN190/rlox path: /src/main.rs
#![allow(dead_code)]
#[macro_use]
mod macros;
<|fim_suffix|> let args: Vec<String> = env::args().collect();
let n_args = args.len();
match n_args {
1 => repl(),
2 => run_file(&args[1]),
_ => {
println!("Usage: ./rlo... | code_fim | medium | {
"lang": "rust",
"repo": "KHN190/rlox",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// True if stream is initiated locally,
/// e. g. `is_init_locally(3)` returns `true` for client and `false` for server.
fn is_init_locally(stream_id: StreamId) -> bool {
(stream_id % 2) == (Self::first_id() % 2)
}
}<|fim_prefix|>// repo: tempbottle/rust-http2 path: /src/common/... | code_fim | medium | {
"lang": "rust",
"repo": "tempbottle/rust-http2",
"path": "/src/common/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tempbottle/rust-http2 path: /src/common/types.rs
use solicit::StreamId;
use super::*;
/// Client or server type names for connection and stream
pub trait Types : 'static {
type HttpStream : HttpStream;
type HttpStreamSpecific : HttpStreamDataSpecific;
type ConnDataSpecific : ConnDa... | code_fim | medium | {
"lang": "rust",
"repo": "tempbottle/rust-http2",
"path": "/src/common/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nikic/rust path: /src/libstd/alloc.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.or... | code_fim | hard | {
"lang": "rust",
"repo": "nikic/rust",
"path": "/src/libstd/alloc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[no_mangle]
#[rustc_std_internal_symbol]
pub unsafe extern fn __rdl_grow_in_place(_ptr: *mut u8,
_old_size: usize,
_old_align: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "nikic/rust",
"path": "/src/libstd/alloc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prz23/zinc path: /zargo/src/project/target/bytecode.rs
//!
//! The bytecode binary file.
//!
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use anyhow::Context;
///
/// The bytecode binary file representation.
///
pub struct Bytecode {
/// The file contents.
pub inner: ... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zargo/src/project/target/bytecode.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Self { inner: buffer })
}
///
/// Creates a string with the default file name.
///
fn file_name() -> String {
zinc_const::file_name::BINARY.to_owned()
}
}<|fim_prefix|>// repo: prz23/zinc path: /zargo/src/project/target/bytecode.rs
//!
//! The bytecode binary f... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zargo/src/project/target/bytecode.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Post to the API with an authorized client.
pub async fn post<T: Serialize + ?Sized>(
client: &Client,
path: &str,
data: &T,
) -> anyhow::Result<()> {
log::debug!("JWT: {}", client.jwt);
let res = client
.http
.post(&client.url(path))
.bearer_auth(&client.jwt... | code_fim | hard | {
"lang": "rust",
"repo": "baytechc/waasabi-matrix",
"path": "/src/strapi.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: baytechc/waasabi-matrix path: /src/strapi.rs
//! Simple Strapi client implementation.
//!
//! Strapi is the currently used backend, storing data about the event
//! and acting as the hub between the Matrix chat and the event frontend.
use anyhow::bail;
use reqwest::StatusCode;
use serde::{Deser... | code_fim | hard | {
"lang": "rust",
"repo": "baytechc/waasabi-matrix",
"path": "/src/strapi.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match source {
EmployeeCommand::CreateEmployee(Employee) =>
EmployeeEvent::EmployeeCreated(Employee),
EmployeeCommand::UpdateEmployee { emp_id, emp_salary } =>
EmployeeEvent::EmployeeUpdated { salary },
EmployeeCommand::DeleteEmpl... | code_fim | hard | {
"lang": "rust",
"repo": "amitayadav/eventsourcing-modularization",
"path": "/src/eventsourcing_module/employee_event/model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amitayadav/eventsourcing-modularization path: /src/eventsourcing_module/employee_event/model.rs
use env_set_up::model::Employee;
use eventsourcing_module::employee_command::model::EmployeeCommand;
<|fim_suffix|>impl From<EmployeeCommand> for EmployeeEvent {
fn from(source: EmployeeCommand) ... | code_fim | hard | {
"lang": "rust",
"repo": "amitayadav/eventsourcing-modularization",
"path": "/src/eventsourcing_module/employee_event/model.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Camjian/txpool-service path: /src/data_provider.rs
use async_trait::async_trait;
use auto_impl::auto_impl;
use ethereum_txpool::AccountInfo;
use ethereum_types::{Address, H256};
mod control;
mod tarpc;
<|fim_suffix|>#[async_trait]
#[auto_impl(&, Box, Arc)]
pub trait AccountInfoProvider: Send +... | code_fim | easy | {
"lang": "rust",
"repo": "Camjian/txpool-service",
"path": "/src/data_provider.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
#[auto_impl(&, Box, Arc)]
pub trait AccountInfoProvider: Send + Sync + 'static {
async fn get_account_info(
&self,
block: H256,
address: Address,
) -> anyhow::Result<Option<AccountInfo>>;
}<|fim_prefix|>// repo: Camjian/txpool-service path: /src/data_provide... | code_fim | medium | {
"lang": "rust",
"repo": "Camjian/txpool-service",
"path": "/src/data_provider.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kapilpatwa93/rust-exercism path: /grade-school/src/lib.rs
use std::collections::HashMap;
#[derive(Default)]
pub struct School<'a> {
students: HashMap<u32, Vec<&'a str>>,
}
impl School<'static> {
pub fn new() -> School<'static> {
School::default()
}
pub fn add(&mut self... | code_fim | medium | {
"lang": "rust",
"repo": "kapilpatwa93/rust-exercism",
"path": "/grade-school/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hulloitskai/api path: /src/routes/healthz.rs
use crate::status::{Health, Status};
<|fim_suffix|>pub fn healthz(
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone {
let method = head().or(get()).unify();
method.map(|| {
let health = Health::new(Status::Pass);
... | code_fim | medium | {
"lang": "rust",
"repo": "hulloitskai/api",
"path": "/src/routes/healthz.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn healthz(
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone {
let method = head().or(get()).unify();
method.map(|| {
let health = Health::new(Status::Pass);
json(&health)
})
}<|fim_prefix|>// repo: hulloitskai/api path: /src/routes/healthz.rs
use crate... | code_fim | medium | {
"lang": "rust",
"repo": "hulloitskai/api",
"path": "/src/routes/healthz.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let matrix = handlers.matrix;
let injector = handlers.reader.injector();
let keypair = Keypair::generate();
// Generate events.
let msg = serde_json::to_string(&Message {
event: EventType::NewJudgementRequest,
data: serde_json::to_value(&Ju... | code_fim | hard | {
"lang": "rust",
"repo": "openweb3-foundation/polkadot-registrar-challenger",
"path": "/src/tests/matrix_adapter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(events.contains(&Event::Matrix(MatrixEvent::SendMessage {
room_id: room_id.clone(),
message: VerifierMessageBlank::InitMessageWithContext
})));
assert!(events.contains(&Event::Matrix(MatrixEvent::SendMessage {
room_id: room_id.clone(),
... | code_fim | hard | {
"lang": "rust",
"repo": "openweb3-foundation/polkadot-registrar-challenger",
"path": "/src/tests/matrix_adapter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: openweb3-foundation/polkadot-registrar-challenger path: /src/tests/matrix_adapter.rs
use super::mocks::*;
use super::{db_path, pause};
use crate::connector::{AckResponse, EventType, JudgementRequest, JudgementResponse, Message};
use crate::primitives::{Account, AccountType, Challenge, Judgement,... | code_fim | hard | {
"lang": "rust",
"repo": "openweb3-foundation/polkadot-registrar-challenger",
"path": "/src/tests/matrix_adapter.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let n: i32 = parse(&getword());
let mut ret: f64 = 1.0;
for i in 2 .. (n + 1) {
ret += calc(i);
}
println!("{}", ret);
}<|fim_prefix|>// repo: sogapalag/contest path: /yukicoder/352.rs
use std::cmp::*;
use std::io::*;
fn getline() -> String {
let mut ret = Stri... | code_fim | hard | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/yukicoder/352.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sogapalag/contest path: /yukicoder/352.rs
use std::cmp::*;
use std::io::*;
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok();
return ret;
}
fn getword() -> String {
<|fim_suffix|> match s.parse::<T>() {
Ok(t) => t,
_ ... | code_fim | hard | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/yukicoder/352.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Value::Map(meta) = from_avro_datum(&meta_schema, reader, None)? {
// TODO: surface original parse schema errors instead of coalescing them here
let json = meta
.get("avro.schema")
.and_then(|bytes| {
if let Value::Bytes(ref bytes) = *bytes... | code_fim | hard | {
"lang": "rust",
"repo": "blakesmith/arrow2",
"path": "/src/io/avro/read/util.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blakesmith/arrow2 path: /src/io/avro/read/util.rs
use std::io::Read;
use std::str::FromStr;
use crate::error::Result;
use avro_rs::{from_avro_datum, types::Value, AvroResult, Codec, Error, Schema};
use serde_json::from_slice;
pub fn zigzag_i64<R: Read>(reader: &mut R) -> Result<i64> {
let... | code_fim | hard | {
"lang": "rust",
"repo": "blakesmith/arrow2",
"path": "/src/io/avro/read/util.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lostinblue/rocket path: /src/arch/x86/i386/interrupt/handler/page_fault.rs
//!
//! This module gives a handler for the page fault exception.
//!
use super::InterruptStackFrame;
<|fim_suffix|> panic_args!("Page fault (Error code: 0b{:b}) \
\n\t\tWhile accessing 0x{:x}\
... | code_fim | hard | {
"lang": "rust",
"repo": "lostinblue/rocket",
"path": "/src/arch/x86/i386/interrupt/handler/page_fault.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(unused_variables)]
pub extern "C" fn page_fault_handler(esf: *const InterruptStackFrame, e: usize)
-> !
{
unsafe {
use ::arch::common::control_registers::cr2;
panic_args!("Page fault (Error code: 0b{:b}) \
\n\t\tWhile accessing 0x{:x}\
\n\t\tOperati... | code_fim | hard | {
"lang": "rust",
"repo": "lostinblue/rocket",
"path": "/src/arch/x86/i386/interrupt/handler/page_fault.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let protocol_id = crc32::checksum_ieee(PROTOCOL_VERSION.as_bytes());
assert!(ProtocolVersion::valid_version(protocol_id));
}
#[test]
fn not_valid_version() {
let protocol_id = crc32::checksum_ieee("not-laminar".as_bytes());
assert!(!ProtocolVersion::valid_versi... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/laminar",
"path": "/src/protocol_version.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/laminar path: /src/protocol_version.rs
use crc::crc32;
use lazy_static::lazy_static;
pub use crate::net::constants::PROTOCOL_VERSION;
lazy_static! {
// The CRC32 of the current protocol version.
static ref VERSION_CRC32: u32 = crc32::checksum_ieee(PROTOCOL_VERSION.as_bytes());
... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/laminar",
"path": "/src/protocol_version.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(ProtocolVersion::get_crc32(), *VERSION_CRC32);
}
#[test]
fn get_version() {
assert_eq!(ProtocolVersion::get_version(), PROTOCOL_VERSION);
}
}<|fim_prefix|>// repo: isgasho/laminar path: /src/protocol_version.rs
use crc::crc32;
use lazy_static::lazy_static;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/laminar",
"path": "/src/protocol_version.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Used to store direct reference to external function.
#[derive(Copy)]
pub struct FnExternalRef(pub fn(&mut Runtime) -> Result<(), String>);
impl Clone for FnExternalRef {
fn clone(&self) -> FnExternalRef {
*self
}
}
impl fmt::Debug for FnExternalRef {
fn fmt(&self, f: &mut fmt::Fo... | code_fim | hard | {
"lang": "rust",
"repo": "pvmsikrsna/dyon",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn error_source(&self, range: Range, msg: &str, source: &Arc<String>) -> String {
use piston_meta::ParseErrorHandler;
let mut w: Vec<u8> = vec![];
ParseErrorHandler::new(source)
.write_msg(&mut w, range, &format!("{}", msg))
.unwrap();
Strin... | code_fim | hard | {
"lang": "rust",
"repo": "pvmsikrsna/dyon",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pvmsikrsna/dyon path: /src/lib.rs
able.
pub fn invalidate_handle(
rt: &mut Runtime,
var: Variable
) -> Result<JoinHandle<Result<Variable, String>>, String> {
use std::error::Error;
let thread = match var {
Variable::Ref(ind) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "pvmsikrsna/dyon",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Parse arguments
let config = instcollect::Config::new(&args).unwrap_or_else(|err| {
eprintln!("Problem parsing arguments: {}\n", err);
eprintln!("Use option '--help' to display usage info.");
process::exit(1);
});
// Run collector with parsed arguments
if le... | code_fim | medium | {
"lang": "rust",
"repo": "Sequoja/tRust",
"path": "/instcollect/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sequoja/tRust path: /instcollect/src/main.rs
use instcollect;
use std::env;
use std::process;
fn main() {
// Collect arguments
let args: Vec<String> = env::args().collect();
// Display usage info
if args.len() >= 2 && args[1] == "--help" {
println!(
"Usage:\... | code_fim | medium | {
"lang": "rust",
"repo": "Sequoja/tRust",
"path": "/instcollect/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> process::exit(1);
});
// Run collector with parsed arguments
if let Err(e) = instcollect::run(config) {
eprintln!("Application error: {}", e);
process::exit(1);
}
}<|fim_prefix|>// repo: Sequoja/tRust path: /instcollect/src/main.rs
use instcollect;
use std::env;
u... | code_fim | hard | {
"lang": "rust",
"repo": "Sequoja/tRust",
"path": "/instcollect/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: happydpc/raymarching_voxels path: /src/gbuffer.rs
use vulkano::instance::QueueFamily;
use vulkano::device::Device;
use vulkano::image::{StorageImage, Dimensions};
use vulkano::format::Format;
use std::sync::Arc;
pub const PRE_DEPTH_ESTIMATE_PATCH : u32 = 8;
// container for all of the buffe... | code_fim | hard | {
"lang": "rust",
"repo": "happydpc/raymarching_voxels",
"path": "/src/gbuffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let atomic_buffer = StorageImage::new(device.clone(), Dimensions::Dim2d{width, height}, Format::R32Uint, [queue_family].iter().cloned()).unwrap();
let reprojection_count_a_buffer = StorageImage::new(device.clone(), Dimensions::Dim2d{width, height}, Format::R32Uint, [queue_fam... | code_fim | hard | {
"lang": "rust",
"repo": "happydpc/raymarching_voxels",
"path": "/src/gbuffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let luminance_buffer = StorageImage::new(device.clone(), Dimensions::Dim2d{width : 32, height : 32}, Format::R32G32B32A32Sfloat, [queue_family].iter().cloned()).unwrap();
let luminance_buffer_t = StorageImage::new(device.clone(), Dimensions::Dim2d{width : 32, height : 3... | code_fim | hard | {
"lang": "rust",
"repo": "happydpc/raymarching_voxels",
"path": "/src/gbuffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn width(&self) -> usize {
WIDTH
}
pub fn height(&self) -> usize {
WIDTH
}
pub fn as_rgb(&self) -> Vec<u8> {
self.pixels.iter().flat_map(Color::as_rgb).collect()
}
}<|fim_prefix|>// repo: cjab/uoc path: /src/art/land_tile.rs
use std::io;
use byteor... | code_fim | hard | {
"lang": "rust",
"repo": "cjab/uoc",
"path": "/src/art/land_tile.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cjab/uoc path: /src/art/land_tile.rs
use std::io;
use byteorder::{ReadBytesExt, LittleEndian};
use art::Error;
use color::Color;
const WIDTH: usize = 44;
const HALF_WIDTH: usize = WIDTH / 2;
<|fim_suffix|> pub fn height(&self) -> usize {
WIDTH
}
pub fn as_rgb(&self) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "cjab/uoc",
"path": "/src/art/land_tile.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut line_width = 2;
let mut x = HALF_WIDTH;
for y in 0..HALF_WIDTH {
x -= 1;
for i in 0..line_width {
let pos = y * WIDTH + i;
let pixel = try!(cursor.read_u16::<LittleEndian>().map(Color::parse));
... | code_fim | hard | {
"lang": "rust",
"repo": "cjab/uoc",
"path": "/src/art/land_tile.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.control_register & TIMER_CONTROL_ENABLE != 0 {
let clock_select = self.control_register & TIMER_CONTROL_CLOCK_SELECT_MASK;
if TIMER_CLOCK_BITS[clock_select as usize] != 0 {
// if counter overflows...
if self.count... | code_fim | hard | {
"lang": "rust",
"repo": "rykrr/Emerald",
"path": "/src/timer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rykrr/Emerald path: /src/timer.rs
use crate::cpu::{interrupt, InterruptType};
use std::cell::RefCell;
use std::rc::{Rc, Weak};
use std::time::{Duration, Instant};
use crate::clock::ClockListener;
use crate::bus::*;
const TIMER_CONTROL_ENABLE: u8 = 1 << 2;
const TIMER_CONTROL_CLOCK_SELECT_MASK... | code_fim | hard | {
"lang": "rust",
"repo": "rykrr/Emerald",
"path": "/src/timer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ClockListener for Timer {
fn callback(&mut self, bus: &mut Bus, cycles: u8) {
for _ in 0..cycles {
if self.cycles == 0xFFFF {
self.cycles = 0;
}
else {
self.cycles += 1;
}
if self.control_register... | code_fim | hard | {
"lang": "rust",
"repo": "rykrr/Emerald",
"path": "/src/timer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> t_user_info (f_open_id) {
f_open_id -> Varchar,
f_mobile -> Varchar,
f_state -> Integer,
f_remark -> Nullable<Varchar>,
}
}
allow_tables_to_appear_in_same_query!(t_user_details_info, t_user_info,);<|fim_prefix|>// repo: zayfen/wxoa.rs path: /src/schema.rs
table! {
use diesel::sql_t... | code_fim | medium | {
"lang": "rust",
"repo": "zayfen/wxoa.rs",
"path": "/src/schema.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zayfen/wxoa.rs path: /src/schema.rs
table! {
use diesel::sql_types::*;
t_user_details_info (f_mobile, f_datetime) {
f_mobile -> Varchar,
f_name -> Nullable<Varchar>,
f_annual_leave_days -> Float,
f_rest_days -> Float,
f_datetime -> Varchar,
f_remark -> Nullable<Varch... | code_fim | medium | {
"lang": "rust",
"repo": "zayfen/wxoa.rs",
"path": "/src/schema.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pepyakin/chetyre path: /servant/nrf51822/src/qdec/reportper.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::REPORTPER {
#[doc = r" Modifies the contents of the register"]
... | code_fim | hard | {
"lang": "rust",
"repo": "pepyakin/chetyre",
"path": "/servant/nrf51822/src/qdec/reportper.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>elf) -> &'a mut W {
self.variant(REPORTPERW::_120SMPL)
}
#[doc = "160 samples per report."]
#[inline]
pub fn _160smpl(self) -> &'a mut W {
self.variant(REPORTPERW::_160SMPL)
}
#[doc = "200 samples per report."]
#[inline]
pub fn _200smpl(self) -> &'a mut W {
... | code_fim | hard | {
"lang": "rust",
"repo": "pepyakin/chetyre",
"path": "/servant/nrf51822/src/qdec/reportper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eliasyaoyc/mapreduce path: /mapreduce/src/mrsequential.rs
use std::thread;
use crate::{KeyValue, MrPhase, merge_name, merge};
use crate::common_map::common_map;
use crate::common_reduce::common_reduce;
use log::info;
#[allow(non_snake_case)]
pub fn sequential(
job_name: String,
files: V... | code_fim | hard | {
"lang": "rust",
"repo": "eliasyaoyc/mapreduce",
"path": "/mapreduce/src/mrsequential.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> job_name: String,
files: &Vec<String>,
n_reduce: usize,
schedule: F,
finish: fn(), )
where F: Fn(MrPhase)
{
info!("Start run: ");
schedule(MrPhase::MapPhase);
schedule(MrPhase::ReducePhase);
finish();
merge(&job_name, n_reduce);
info!("run finish");
}
fn s... | code_fim | hard | {
"lang": "rust",
"repo": "eliasyaoyc/mapreduce",
"path": "/mapreduce/src/mrsequential.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lsr-lang/lsr path: /lib/parser/src/lib.rs
#[macro_use]
extern crate lalrpop_util;
lalrpop_mod!(pub parser);
<|fim_suffix|>#[cfg(test)]
mod tests;<|fim_middle|>pub mod ast;
// Testing modules
#[cfg(test)]
#[macro_use]
extern crate lazy_static;
| code_fim | medium | {
"lang": "rust",
"repo": "lsr-lang/lsr",
"path": "/lib/parser/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests;<|fim_prefix|>// repo: lsr-lang/lsr path: /lib/parser/src/lib.rs
#[macro_use]
extern crate lalrpop_util;
lalrpop_mod!(pub parser);
pub mod ast;
<|fim_middle|>// Testing modules
#[cfg(test)]
#[macro_use]
extern crate lazy_static;
| code_fim | medium | {
"lang": "rust",
"repo": "lsr-lang/lsr",
"path": "/lib/parser/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix-refspec/tests/spec/mod.rs
mod prefix {
use gix_refspec::{parse::Operation, RefSpec};
#[test]
fn head_is_specifically_known() {
assert_eq!(parse("HEAD").to_ref().prefix().unwrap(), "HEAD");
}
#[test]
fn partial_refs_have_no_prefix() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-refspec/tests/spec/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn short_absolute_refs_expand_to_themselves() {
assert_eq!(parse("refs/short"), ["refs/short"]);
}
#[test]
fn full_names_expand_to_their_prefix() {
assert_eq!(parse("refs/heads/main"), ["refs/heads/"]);
assert_eq!(parse("refs/foo/bar"), ["refs/foo/"]);
... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-refspec/tests/spec/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: povilasb/rust-playground path: /fileio/src/fio.rs
use std::fs::File;
use std::io::{self, Write};
use std::fmt::Display;
<|fim_suffix|>pub fn writeln_to<T: Display>(fname: &str, data: T) -> io::Result<()> {
let mut f = File::create(fname)?;
write!(&mut f, "{}\n", data);
Ok(())
}<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "povilasb/rust-playground",
"path": "/fileio/src/fio.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn writeln_to<T: Display>(fname: &str, data: T) -> io::Result<()> {
let mut f = File::create(fname)?;
write!(&mut f, "{}\n", data);
Ok(())
}<|fim_prefix|>// repo: povilasb/rust-playground path: /fileio/src/fio.rs
use std::fs::File;
use std::io::{self, Write};
use std::fmt::Display;
<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "povilasb/rust-playground",
"path": "/fileio/src/fio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if std::iter::order::equals(num_str.as_slice().chars(),
num_str.as_slice().chars().rev()){
return true;
}else{
return false;
}
}
fn main() {
let mut max_product =0;
for i in range(0,999){
for j in range(0,999){
if is_palindromic(i*j) && i*j > max_product {
max_product = i*j;
... | code_fim | medium | {
"lang": "rust",
"repo": "Syntaf/Euler",
"path": "/4/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Syntaf/Euler path: /4/main.rs
/*
Find the largest palindrome made from the product of two 3digit numbers
*/
<|fim_suffix|>fn main() {
let mut max_product =0;
for i in range(0,999){
for j in range(0,999){
if is_palindromic(i*j) && i*j > max_product {
max_product = i*j;
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Syntaf/Euler",
"path": "/4/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paulaplan/misc path: /examples/oldlogging.rs
#[macro_use]
extern crate slog;
extern crate slog_term;
extern crate slog_scope;
extern crate slog_stdlog;
#[macro_use]
extern crate log;
<|fim_suffix|> let decorator = slog_term::PlainSyncDecorator::new(io::stderr());
let drain = slog_term::F... | code_fim | medium | {
"lang": "rust",
"repo": "paulaplan/misc",
"path": "/examples/oldlogging.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // slog_stdlog uses the logger from slog_scope, so set a logger there
let _guard = slog_scope::set_global_logger(logger);
// register slog_stdlog as the log handler with the log crate
slog_stdlog::init().unwrap();
info!("standard logging redirected to slog");
}<|fim_prefix|>// repo: ... | code_fim | hard | {
"lang": "rust",
"repo": "paulaplan/misc",
"path": "/examples/oldlogging.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let decorator = slog_term::PlainSyncDecorator::new(io::stderr());
let drain = slog_term::FullFormat::new(decorator).build().fuse();
let logger = slog::Logger::root(drain, o!("version" => "0.5"));
// slog_stdlog uses the logger from slog_scope, so set a logger there
let _guard = slog_s... | code_fim | medium | {
"lang": "rust",
"repo": "paulaplan/misc",
"path": "/examples/oldlogging.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl_stable_hash_for!(struct crate::middle::cstore::ExternCrate {
src,
span,
path_len,
direct
});
impl_stable_hash_for!(enum crate::middle::cstore::ExternCrateSource {
Extern(def_id),
Use,
Path,
});
impl_stable_hash_for!(struct crate::middle::cstore::CrateSource {
dylib,
... | code_fim | hard | {
"lang": "rust",
"repo": "su225/rust",
"path": "/src/librustc/ich/impls_cstore.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: su225/rust path: /src/librustc/ich/impls_cstore.rs
//! This module contains `HashStable` implementations for various data types
//! from rustc::middle::cstore in no particular order.
<|fim_suffix|>impl_stable_hash_for!(enum crate::middle::cstore::NativeLibraryKind {
NativeStatic,
Native... | code_fim | medium | {
"lang": "rust",
"repo": "su225/rust",
"path": "/src/librustc/ich/impls_cstore.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: obscuren/jev_os path: /src/cpuio/lib.rs
use core::marker::PhantomData;
pub struct Port<T> {
port: u16,
phantom: PhantomData<T>,
}
<|fim_suffix|> pub fn read(&self) -> u8 {
unsafe { inb(self.port) }
}
pub fn write(&self, value: u8) {
unsafe { outb(value, self... | code_fim | medium | {
"lang": "rust",
"repo": "obscuren/jev_os",
"path": "/src/cpuio/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write(&self, value: u8) {
unsafe { outb(value, self.port) }
}
}<|fim_prefix|>// repo: obscuren/jev_os path: /src/cpuio/lib.rs
use core::marker::PhantomData;
pub struct Port<T> {
port: u16,
phantom: PhantomData<T>,
}
impl<T> Port<T> {
pub unsafe fn new(port: u16) -> Po... | code_fim | medium | {
"lang": "rust",
"repo": "obscuren/jev_os",
"path": "/src/cpuio/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eminence/sc2rs path: /src/types/raw.rs
use sc2_protobuf::protos;
use failure;
use super::{ToProtobuf, FromProtobuf};
use super::common::*;
#[derive(Debug, FromProtobuf)]
pub struct StartRaw {
pub map_size: Size2DI,
pub pathing_grid: ImageData,
pub terrain_height: ImageData,
... | code_fim | hard | {
"lang": "rust",
"repo": "eminence/sc2rs",
"path": "/src/types/raw.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[derive(Debug, FromProtobuf)]
pub struct Effect {
#[Get]
pub effect_id: u32,
/// Effect may impact multiple locations.
///
/// For example: Lurker attack
pub pos: Vec<Point2D>,
}
#[derive(Debug, ToProtobuf, FromProtobuf)]
pub enum ActionRaw {
UnitCommand(ActionRawUnitComm... | code_fim | hard | {
"lang": "rust",
"repo": "eminence/sc2rs",
"path": "/src/types/raw.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[derive(Clone, PartialEq, Eq, Debug, Hash, FromProtobuf)]
pub enum Alliance {
#[allow(non_camel_case_types)]
value_Self = 1,
Ally = 2,
Neutral = 3,
Enemy = 4,
}
#[derive(Clone, PartialEq, Eq, Debug, Hash, FromProtobuf)]
pub enum CloakState {
Cloaked = 1,
CloakedDetected = 2,... | code_fim | hard | {
"lang": "rust",
"repo": "eminence/sc2rs",
"path": "/src/types/raw.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s/redirect.mp3/cdn.newrustacean.com/interview/rbr_2017/thomas_gideon.mp3">
//! <source src="http://www.podtrac.com/pts/redirect.ogg/cdn.newrustacean.com/interview/rbr_2017/thomas_gideon.ogg">
//! </audio>
/// Transcript: coming soon!
pub struct Transcript;<|fim_prefix|>// repo: bjornwsv/newrustacean.co... | code_fim | hard | {
"lang": "rust",
"repo": "bjornwsv/newrustacean.com",
"path": "/src/interview/rbr_2017/thomas_gideon.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bjornwsv/newrustacean.com path: /src/interview/rbr_2017/thomas_gideon.rs
//! Thomas Gideon
//!
//! - **Date:** December 6, 2017 (recorded October 27, 2017)
//! - **Audio:**
//! + [M4A]
//! + [MP3]
//! + [Ogg]
//!
//! [M4A]: http://www.podtrac.com/pts/redirect.m4a/cdn.newrus... | code_fim | hard | {
"lang": "rust",
"repo": "bjornwsv/newrustacean.com",
"path": "/src/interview/rbr_2017/thomas_gideon.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> ///
/// Create a log entry for a given level
///
/// # Arguments:
/// * level: An logging level of INFO, DEBUG, ERROR, CRITICAL or WARN
/// * msg: Message to log
///
fn log_at(&self, level: Level, msg: &str);
}<|fim_prefix|>// repo: EngineersBox/Rust-MQTT path: /src/connec... | code_fim | hard | {
"lang": "rust",
"repo": "EngineersBox/Rust-MQTT",
"path": "/src/connector/connector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EngineersBox/Rust-MQTT path: /src/connector/connector.rs
use slog::Level;
pub trait Connector {
///
/// Creates a connection based on the options given in a configuration. This will configure
/// aspects such as:
/// * username
/// * password
/// * host
/// * port
... | code_fim | hard | {
"lang": "rust",
"repo": "EngineersBox/Rust-MQTT",
"path": "/src/connector/connector.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dprint/dprint path: /crates/dprint/src/plugins/implementations/wasm/functions.rs
use anyhow::bail;
use anyhow::Result;
use wasmer::Engine;
use wasmer::Instance;
use wasmer::Memory;
use wasmer::MemoryView;
use wasmer::RuntimeError;
use wasmer::Store;
use wasmer::TypedFunction;
use wasmer::WasmPtr... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/plugins/implementations/wasm/functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub fn get_memory_view(&self) -> MemoryView {
self.memory.view(&self.store)
}
#[inline]
pub fn clear_shared_bytes(&mut self, capacity: usize) -> Result<()> {
let clear_shared_bytes_func = self.get_export::<u32, ()>("clear_shared_bytes")?;
wasm_runtime_error_to_err_box(clea... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/plugins/implementations/wasm/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(WasmFunctions {
instance: instance.inner,
memory,
store,
_engine: instance.engine,
})
}
#[inline]
pub fn set_global_config(&mut self) -> Result<()> {
let set_global_config_func = self.get_export::<(), ()>("set_global_config")?;
wasm_runtime_error_to_err_bo... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/plugins/implementations/wasm/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Erk-/worker path: /src/commands/help.rs
use super::prelude::*;
pub struct HelpCommand;
impl HelpCommand {
async fn _run() -> CommandResult {
Response::text("A list of our commands is available here: <https://dabbot.org/commands>")
}
}
impl<'a> Command<'a> for HelpCommand {
... | code_fim | medium | {
"lang": "rust",
"repo": "Erk-/worker",
"path": "/src/commands/help.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &["help", "h"]
}
fn run(&self, _: Context) -> RunFuture<'a> {
RunFuture::new(Self::_run().boxed())
}
}<|fim_prefix|>// repo: Erk-/worker path: /src/commands/help.rs
use super::prelude::*;
pub struct HelpCommand;
impl HelpCommand {
async fn _run() -> CommandResult {
... | code_fim | medium | {
"lang": "rust",
"repo": "Erk-/worker",
"path": "/src/commands/help.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = group.map(|x| x.1.to_string()).reduce(|acc, c| c + "|" + &acc).unwrap();
println!("{}", s);
}
}
/*
低|举|疑|床
头|头|是|前
思|望|地|明
故|明|上|月
乡|月|霜|光
*/<|fim_prefix|>// repo: zwvista/SampleMisc path: /Rust/sample_rust/src/jys.rs
use itertools::Itertools;
use reduce::Reduce;
pub fn jys() {
... | code_fim | medium | {
"lang": "rust",
"repo": "zwvista/SampleMisc",
"path": "/Rust/sample_rust/src/jys.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zwvista/SampleMisc path: /Rust/sample_rust/src/jys.rs
use itertools::Itertools;
use reduce::Reduce;
pub fn jys() {
let text = "床前明月光疑是地上霜举头望明月低头思故乡";
let offset = 5;
let f = |x: &(usize, char)| x.0 % offset;
for (_, group) in text.chars().enumerate().sorted_by_key(&f).group_by(&... | code_fim | medium | {
"lang": "rust",
"repo": "zwvista/SampleMisc",
"path": "/Rust/sample_rust/src/jys.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Setup paging
reg_names[0] = WHV_REGISTER_NAME::WHvX64RegisterCr3;
reg_values[0].Reg64 = pml4_addr;
reg_names[1] = WHV_REGISTER_NAME::WHvX64RegisterCr4;
reg_values[1].Reg64 = CR4_PAE;
reg_names[2] = WHV_REGISTER_NAME::WHvX64RegisterCr0;
reg_values[2].Reg64 = CR0_PE | CR0_MP |... | code_fim | hard | {
"lang": "rust",
"repo": "alexpilotti/libwhp-sample",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexpilotti/libwhp-sample path: /src/main.rs
extern crate libwhp;
use libwhp::instruction_emulator::*;
use libwhp::memory::*;
use libwhp::*;
use std::cell::RefCell;
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, Write};
const CPUID_EXT_HYPERVISOR: UINT32 = 1 << 31;
const PDE... | code_fim | hard | {
"lang": "rust",
"repo": "alexpilotti/libwhp-sample",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn setup_partition(p: &mut Partition) {
let mut property: WHV_PARTITION_PROPERTY = unsafe { std::mem::zeroed() };
property.ProcessorCount = 1;
p.set_property(
WHV_PARTITION_PROPERTY_CODE::WHvPartitionPropertyCodeProcessorCount,
&property,
).unwrap();
property = unsafe ... | code_fim | hard | {
"lang": "rust",
"repo": "alexpilotti/libwhp-sample",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> transformations: WordTransformations::RandomLowerUpper,
},
seperator: SeperatorConfiguration {
seperator_type: SeperatorTypes::RandomCharacter,
seperators: vec!['-', ':', '.', ','],
},
padding_digits: PaddingDigitConfiguration {
... | code_fim | hard | {
"lang": "rust",
"repo": "darayus/XKCDPass",
"path": "/src/configuration/defaults/appleid.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: darayus/XKCDPass path: /src/configuration/defaults/appleid.rs
//! The Apple ID configuration for the password generator.
use super::super::*;
pub fn configuration_appleid() -> Configuration {
<|fim_suffix|> transformations: WordTransformations::RandomLowerUpper,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "darayus/XKCDPass",
"path": "/src/configuration/defaults/appleid.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reminder-bot/timezone-web path: /src/templates.rs
use askama::Template;
use crate::models::{ClockChannel, DiscordGuild};
<|fim_suffix|>#[derive(Template)]
#[template(path = "login.html")]
pub struct Login {
pub login_redir: String,
}
#[derive(Template)]
#[template(path = "get_guilds_error... | code_fim | hard | {
"lang": "rust",
"repo": "reminder-bot/timezone-web",
"path": "/src/templates.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Template)]
#[template(path = "get_guilds_error.html")]
pub struct GetGuildsError {
pub home_redir: String,
}<|fim_prefix|>// repo: reminder-bot/timezone-web path: /src/templates.rs
use askama::Template;
use crate::models::{ClockChannel, DiscordGuild};
<|fim_middle|>#[derive(Template)]
#[te... | code_fim | hard | {
"lang": "rust",
"repo": "reminder-bot/timezone-web",
"path": "/src/templates.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> the target of any edges).
// revisions:rpass1 rpass2
// aux-build:generic.rs
extern crate generic;
fn main() { }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/incremental/issue-39828/issue-39828.rs
// Regression test for #39828. If you make use of a module that
// consists only... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/incremental/issue-39828/issue-39828.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/incremental/issue-39828/issue-39828.rs
// Regression test for #39828. If you make use of a module that
// consists only of generics, no code is generated<|fim_suffix|> only serialize edges, when we
// reload, we would consider that node dirty since... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/incremental/issue-39828/issue-39828.rs",
"mode": "psm",
"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.