text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>pub fn gc_debug_malloc(llvm: &Llvm, b: BuilderRef, size: ValueRef, file: &str, line: u32) -> ValueRef {
let file = llvm.add_global_cstring_const(file);
let line = llvm.int_type(32).const_int(line as u128);
b.call(llvm.intrinsic(Intrinsic::GcDebugMalloc), &mut [size, file, line])
}
pub fn memc... | code_fim | hard | {
"lang": "rust",
"repo": "pingw33n/czar-old",
"path": "/src/codegen/llvm/intrinsic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pingw33n/czar-old path: /src/codegen/llvm/intrinsic.rs
use super::*;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Intrinsic {
GcDebugMalloc,
Memcpy32,
Memcpy64,
}
impl Intrinsic {
pub fn cname(self) -> &'static CStr {
use Intrinsic::*;
unsafe { CStr::fr... | code_fim | hard | {
"lang": "rust",
"repo": "pingw33n/czar-old",
"path": "/src/codegen/llvm/intrinsic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivanceras/mushroom path: /src/std/rpc/ws_client/client.rs
use std::sync::mpsc::channel;
use std::sync::mpsc::Sender as ThreadOut;
use std::thread;
use log::info;
use serde_json::Value;
use sp_core::H256 as Hash;
use ws::{connect, Result as WsResult};
use crate::std::rpc::json_req;
use crate::s... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/mushroom",
"path": "/src/std/rpc/ws_client/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
jsonreq: String,
result_in: ThreadOut<String>,
on_message_fn: OnMessageFn,
) -> WsResult<()> {
let url = self.url.clone();
let _client =
thread::Builder::new()
.name("client".to_owned())
.spawn(move || -... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/mushroom",
"path": "/src/std/rpc/ws_client/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = Mutex::new(1);
let t = unsafe { thread::spawn(|| *a.lock().unwrap() *= 2) };
println!("{:?}", a.lock().unwrap());
t.join().unwrap();
println!("{:?}", a.lock().unwrap());
}<|fim_prefix|>// repo: chinoto/rust_prime path: /mutex_test.rs
use std::sync::{mpsc, Arc, Mutex, RwLock};
... | code_fim | easy | {
"lang": "rust",
"repo": "chinoto/rust_prime",
"path": "/mutex_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chinoto/rust_prime path: /mutex_test.rs
use std::sync::{mpsc, Arc, Mutex, RwLock};
use std::thread;
<|fim_suffix|> let a = Mutex::new(1);
let t = unsafe { thread::spawn(|| *a.lock().unwrap() *= 2) };
println!("{:?}", a.lock().unwrap());
t.join().unwrap();
println!("{:?}", a.l... | code_fim | easy | {
"lang": "rust",
"repo": "chinoto/rust_prime",
"path": "/mutex_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tikv/grpc-rs path: /src/security/auth_context.rs
//! API for authenticating peer
//! Based on https://grpc.github.io/grpc/core/md_doc_server_side_auth.html
use std::ffi::CStr;
use std::marker::PhantomData;
use std::ptr::NonNull;
use crate::grpc_sys::{
self, grpc_auth_context, grpc_auth_pro... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/grpc-rs",
"path": "/src/security/auth_context.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Auth properties are elements of the AuthContext. They have a name
/// (a key of type string) and a value which can be a string or binary data.
pub struct AuthProperty<'a> {
prop: *const grpc_auth_property,
_lifetime: PhantomData<&'a grpc_auth_property>,
}
impl<'a> AuthProperty<'a> {
pub f... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/grpc-rs",
"path": "/src/security/auth_context.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Defines a token bucket with a maximum capacity (size), an initial burst size
/// (one_time_burst) and an interval for refilling purposes (refill_time).
/// The refill-rate is derived from size and refill_time, and it is the constant
/// rate at which the tokens replenish. The refill pr... | code_fim | hard | {
"lang": "rust",
"repo": "bnavetta/sparkler",
"path": "/sparkler/src/firecracker/api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Instance state, as part of the [`InstanceInfo`] response.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize)]
pub enum InstanceState {
#[serde(rename = "Not started")]
NotStarted,
Running,
Paused,
}
/// Variant wrapper containing the real acti... | code_fim | hard | {
"lang": "rust",
"repo": "bnavetta/sparkler",
"path": "/sparkler/src/firecracker/api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bnavetta/sparkler path: /sparkler/src/firecracker/api.rs
//! Client for the Firecracker HTTP API
// TODO: client-side logging/tracing
// TODO: Firecracker metrics, logger, mmds, maybe snapshots, maybe vsock
use std::path::PathBuf;
use http::StatusCode;
use hyper::body::{Body, Buf};
use hyperl... | code_fim | hard | {
"lang": "rust",
"repo": "bnavetta/sparkler",
"path": "/sparkler/src/firecracker/api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
mut
[
MaybeUninit
<
u8
>
]
)
-
>
Result
<
(
)
Error
>
{
static
GETRANDOM
:
Weak
=
unsafe
{
Weak
:
:
new
(
"
getrandom
\
0
"
)
}
;
type
GetRandomFn
=
unsafe
extern
"
C
"
fn
(
*
mut
u8
libc
:
:
size_t
libc
:
:
c_uint
)
-
>
libc
:
:
ssize_t
;
/
/
getrandom
(
2
)
was
introduced
in
DragonflyBSD
5
.
7
if
let
S... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/getrandom/src/dragonfly.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/getrandom/src/dragonfly.rs
/
/
Copyright
2021
Developers
of
the
Rand
project
.
/
/
/
/
Licensed
under
the
Apache
License
Version
2
.
0
<
LICENSE
-
APACHE
or
/
/
https
:
/
/
www
.
apache
.
org
/
licenses
/
LICENSE
-
2
.
0
>
or
the
MIT
license
/
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/getrandom/src/dragonfly.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewpedia/cashbox path: /bc/chain/eth/src/transaction/transaction.rs
<u64>,
signature: &SignatureComponents,
) {
self.encode_rlp(rlp, chain_id, Some(signature));
}
fn encode_rlp(
&self,
rlp: &mut RlpStream,
chain_id: Option<u64>,
sig... | code_fim | hard | {
"lang": "rust",
"repo": "andrewpedia/cashbox",
"path": "/bc/chain/eth/src/transaction/transaction.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn encode(&self, chain_id: Option<u64>, signature: &SignatureComponents) -> Vec<u8> {
let signature = Some(signature);
match self {
Self::Legacy(tx) => tx.encode(chain_id, signature),
Self::AccessList(opt) => opt.encode(chain_id, signature),
Self::EI... | code_fim | hard | {
"lang": "rust",
"repo": "andrewpedia/cashbox",
"path": "/bc/chain/eth/src/transaction/transaction.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewpedia/cashbox path: /bc/chain/eth/src/transaction/transaction.rs
ansaction and recover sender.
pub fn new(transaction: UnverifiedTransaction) -> Result<Self, publickey::Error> {
if transaction.is_unsigned() {
return Err(publickey::Error::InvalidSignature);
}... | code_fim | hard | {
"lang": "rust",
"repo": "andrewpedia/cashbox",
"path": "/bc/chain/eth/src/transaction/transaction.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> collections::array::array_test();
collections::string::string_test();
collections::map::map_test();
}<|fim_prefix|>// repo: smtakeda/rust-playground path: /collections/src/main.rs
extern crate collections;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "smtakeda/rust-playground",
"path": "/collections/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smtakeda/rust-playground path: /collections/src/main.rs
extern crate collections;
<|fim_suffix|> collections::array::array_test();
collections::string::string_test();
collections::map::map_test();
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "smtakeda/rust-playground",
"path": "/collections/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johannesvollmer/psychopath path: /sub_crates/math3d/src/matrix.rs
#![allow(dead_code)]
use std::ops::{Add, Mul};
use approx::RelativeEq;
use glam::{Mat4, Vec4};
use super::Point;
/// A 4x4 matrix, used for transforms
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Matrix4x4(pub Mat4);
i... | code_fim | hard | {
"lang": "rust",
"repo": "johannesvollmer/psychopath",
"path": "/sub_crates/math3d/src/matrix.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(a, b);
assert!(a != c);
}
#[test]
fn approximate_equality_test() {
let a = Matrix4x4::new();
let b = Matrix4x4::new_from_values(
1.000001, 0.0, 0.0, 0.0, 0.0, 1.000001, 0.0, 0.0, 0.0, 0.0, 1.000001, 0.0, 0.0, 0.0,
0.0, 1.00000... | code_fim | hard | {
"lang": "rust",
"repo": "johannesvollmer/psychopath",
"path": "/sub_crates/math3d/src/matrix.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[tokio::test]
async fn get_by_coordinates() -> Result<(), Box<dyn std::error::Error>> {
dotenv().expect("No env file found");
let token = env::var("OPENWEATHER_API_KEY").unwrap();
let weather: OpenWeather = OpenWeather::new(&token, Units::Metric);
let _temp = weath... | code_fim | hard | {
"lang": "rust",
"repo": "cooks0/openweather-async",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cooks0/openweather-async path: /src/lib.rs
pub mod openweather;
pub mod models;
pub mod units;
pub use openweather::OpenWeather;
pub use models::*;
pub use units::Units;
#[cfg(test)]
mod test {
use super::openweather::{OpenWeather, Units};
use std::env;
use dotenv::dotenv;
#[t... | code_fim | hard | {
"lang": "rust",
"repo": "cooks0/openweather-async",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[tokio::test]
async fn get_by_zipcode() -> Result<(), Box<dyn std::error::Error>> {
dotenv().expect("No env file found");
let token = env::var("OPENWEATHER_API_KEY").unwrap();
let weather: OpenWeather = OpenWeather::new(&token, Units::Metric);
let _temp = weather.g... | code_fim | hard | {
"lang": "rust",
"repo": "cooks0/openweather-async",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn hello_response_with_medium_should_serialize_and_deserialize() {
let hello_response = SuccessMessage::Hello {
id: 42.into(),
clients: vec![ClientResponse {
id: ClientId::from(8080),
name: "IMSAI".to_string(),
}],
current_medium: VersionedMediumResponse {
medium: Mediu... | code_fim | hard | {
"lang": "rust",
"repo": "communityvi/communityvi",
"path": "/communityvi-server/src/message/outgoing/success_message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: communityvi/communityvi path: /communityvi-server/src/message/outgoing/success_message.rs
use js_int::{Int, UInt};
use serde::{Deserialize, Serialize};
use crate::room::client::Client;
use crate::room::client_id::ClientId;
use crate::room::medium::playback_state::PlaybackState;
use crate::room:... | code_fim | hard | {
"lang": "rust",
"repo": "communityvi/communityvi",
"path": "/communityvi-server/src/message/outgoing/success_message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match playback_state {
PlaybackState::Playing { start_time } => Self::Playing {
start_time_in_milliseconds: Int::try_from(start_time.num_milliseconds()).unwrap(),
},
PlaybackState::Paused { at_position } => Self::Paused {
position_in_milliseconds: UInt::try_from(at_position.num_millisec... | code_fim | hard | {
"lang": "rust",
"repo": "communityvi/communityvi",
"path": "/communityvi-server/src/message/outgoing/success_message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let row_len = 4;
let col_len = 4;
let mut arr = vec![ 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15];
let expected = vec![ 0, 1, 14, 3,
4, ... | code_fim | hard | {
"lang": "rust",
"repo": "grim7reaper/AdventOfCode",
"path": "/2016/Day 08 - Two-Factor Authentication/src/main.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grim7reaper/AdventOfCode path: /2016/Day 08 - Two-Factor Authentication/src/main.rs
// {{{ Lints
#![deny(missing_debug_implementations,
missing_copy_implementations,
trivial_casts,
trivial_numeric_casts,
unstable_features,
unused_import_braces,
un... | code_fim | hard | {
"lang": "rust",
"repo": "grim7reaper/AdventOfCode",
"path": "/2016/Day 08 - Two-Factor Authentication/src/main.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> start: usize, len: usize, shift: usize, stride: usize)
{
let pivot = start + shift*stride;
assert!(len > shift);
reverse(&mut self.pixels, start, len, stride);
reverse(&mut self.pixels, start, shift, stride);
... | code_fim | hard | {
"lang": "rust",
"repo": "grim7reaper/AdventOfCode",
"path": "/2016/Day 08 - Two-Factor Authentication/src/main.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mostafanamazy/design-patterns-rust path: /strategy/src/main.rs
use strategy::duck_box::{Duck, MallardDuck, ModelDuck};
use strategy::duck_generic::{MalarDuck, ModDuck};
use strategy::fly::FlyRocketPowered;
fn main() {
let mallard = MallardDuck::new();
mallard.perform_fly();
mallard.p... | code_fim | hard | {
"lang": "rust",
"repo": "mostafanamazy/design-patterns-rust",
"path": "/strategy/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let model_duck = ModDuck::new();
model_duck.perform_fly();
let model_duck = model_duck.set_fly_behavior(FlyRocketPowered {});
model_duck.perform_fly();
model_duck.perform_quack();
model_duck.display();
model_duck.swim();
}<|fim_prefix|>// repo: mostafanamazy/design-patterns-rus... | code_fim | medium | {
"lang": "rust",
"repo": "mostafanamazy/design-patterns-rust",
"path": "/strategy/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut runtime = Runtime::new().expect("Runtime");
let connection = open_paired_connection(&mut runtime, &addr);
let data_size = 100;
b.iter(|| {
for x in 0..data_size {
let test_key = format!("test_{}", x);
connection.send_and_forget(resp_array!["SET", ... | code_fim | hard | {
"lang": "rust",
"repo": "Atul9/redis-async-rs",
"path": "/benches/benchmarks.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Atul9/redis-async-rs path: /benches/benchmarks.rs
/*
* Copyright 2017-2018 Ben Ashford
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
* opt... | code_fim | hard | {
"lang": "rust",
"repo": "Atul9/redis-async-rs",
"path": "/benches/benchmarks.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn bench_complex_pipeline(b: &mut Bencher) {
let addr = "127.0.0.1:6379".parse().unwrap();
let mut runtime = Runtime::new().expect("Runtime");
let connection_outer = Arc::new(open_paired_connection(&mut runtime, &addr));
let data_size = 100;
b.iter(|| {
let all_set... | code_fim | hard | {
"lang": "rust",
"repo": "Atul9/redis-async-rs",
"path": "/benches/benchmarks.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sYnfo/brainfuckvm path: /src/optimize.rs
use parse::Instruction;
use parse::Instruction::*;
use parse::link_jumps;
pub fn optimize(program: &[Instruction]) -> Vec<Instruction> {
let program = colapse_moves(&program);
let program = colapse_adds(&program);
link_jumps(&program)
}
fn... | code_fim | hard | {
"lang": "rust",
"repo": "sYnfo/brainfuckvm",
"path": "/src/optimize.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_colapses_moves() {
let program = vec![Add(1), Move(2), Move(-1), Move(3), Add(1)];
assert_eq!(colapse_moves(&program), vec![Add(1), Move(4), Add(1)]);
}
#[test]
fn it_colapses_adds() {
let program = vec!... | code_fim | hard | {
"lang": "rust",
"repo": "sYnfo/brainfuckvm",
"path": "/src/optimize.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
T: ?Sized + Serialize + Debug,
{
let mut out = Vec::new();
let ser = &mut serde_json::Serializer::new(&mut out);
let result = serde_path_to_error::serialize(value, ser);
let path = result.unwrap_err().path().to_string();
assert_eq!(path, expected);
}
#[test]
fn test_refcell_... | code_fim | medium | {
"lang": "rust",
"repo": "dtolnay/path-to-error",
"path": "/tests/serialize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtolnay/path-to-error path: /tests/serialize.rs
use serde::Serialize;
use serde_derive::Serialize;
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::fmt::Debug;
fn test<T>(value: &T, expected: &str)
where
T: ?Sized + Serialize + Debug,
{
let mut out = Vec::new();
let ... | code_fim | hard | {
"lang": "rust",
"repo": "dtolnay/path-to-error",
"path": "/tests/serialize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Serialize, Debug)]
struct Inner<'a> {
refcell: &'a RefCell<String>,
}
let refcell = RefCell::new(String::new());
let outer = Outer {
k: Inner { refcell: &refcell },
};
let _borrowed = refcell.borrow_mut();
test(&outer, "k.refcell");
}
#[test]
fn ... | code_fim | medium | {
"lang": "rust",
"repo": "dtolnay/path-to-error",
"path": "/tests/serialize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fiji-flo/bikeshed-rs path: /src/markdown/mod.rs
atic ref FENCED_LINE_REG: Regex = Regex::new(
r"(?x)
^(\s*)
(?P<tag>`{3,}|~{3,})
([^`]*)$"
)
.unwrap();
// regex for equals line
static ref EQUALS_LINE_REG: Regex = Regex::new(r"^={3,}\s*$").unwrap();... | code_fim | hard | {
"lang": "rust",
"repo": "fiji-flo/bikeshed-rs",
"path": "/src/markdown/mod.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fiji-flo/bikeshed-rs path: /src/markdown/mod.rs
unwrap();
// regex for fenced line
static ref FENCED_LINE_REG: Regex = Regex::new(
r"(?x)
^(\s*)
(?P<tag>`{3,}|~{3,})
([^`]*)$"
)
.unwrap();
// regex for equals line
static ref EQUALS_LINE_REG... | code_fim | hard | {
"lang": "rust",
"repo": "fiji-flo/bikeshed-rs",
"path": "/src/markdown/mod.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut lines = vec![format!("<{} {}>", outer_tag, outer_el_attr)];
loop {
let (token_kind, item_lines) = parse_item(stream);
let tag = match token_kind {
TokenKind::Numbered | TokenKind::Bulleted => "li",
TokenKind::Dt => "dt",
_ => "dd",
... | code_fim | hard | {
"lang": "rust",
"repo": "fiji-flo/bikeshed-rs",
"path": "/src/markdown/mod.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvnallsn/motd-rs path: /src/commands/common.rs
//! All commands that will work on every operating system
use crate::error::MotdResult;
use std::{collections::HashMap, net::IpAddr};
// Returns the IPs associated with this device
pub fn interfaces(
hide_loopback: bool,
hide_public: bool,... | code_fim | hard | {
"lang": "rust",
"repo": "kvnallsn/motd-rs",
"path": "/src/commands/common.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if hide_public && !ip.is_private() {
continue;
}
addrs.push(format!("{}, ", ip));
}
IpAddr::V6(ip6) => {}
}
}
map.insert(interface.name, addrs);
}
map
... | code_fim | hard | {
"lang": "rust",
"repo": "kvnallsn/motd-rs",
"path": "/src/commands/common.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> map
}
/// Returns the hostname of this computer
pub fn hostname(args: Option<String>) -> MotdResult<String> {
cmd!("hostname", args)
}
/// Returns the currently logged in user
pub fn user(args: Option<String>) -> MotdResult<String> {
cmd!("whoami", args)
}<|fim_prefix|>// repo: kvnallsn/motd... | code_fim | hard | {
"lang": "rust",
"repo": "kvnallsn/motd-rs",
"path": "/src/commands/common.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rachel-s-c/rust_HeuristicGameTree path: /src/tictactoe.rs
use super::*;
use crate::general_game::print_piece;
use crate::general_game::Piece;
use crate::minimax;
use std::io::{stdin, stdout, Write};
const TICWINS: [[usize; 3]; 8] = [
[0, 1, 2],
[0, 3, 6],
[0, 4, 8],
[1, 4, 7],
... | code_fim | hard | {
"lang": "rust",
"repo": "rachel-s-c/rust_HeuristicGameTree",
"path": "/src/tictactoe.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn print_piece_x_tic_test() {
let mut tic_1 = TicGame::new();
tic_1.store_move(5, Piece::X);
assert_eq!(print_piece(tic_1.board[5]), "X");
}
#[test]
fn print_piece_o_tic_test() {
let mut tic_1 = TicGame::new();
tic_1.store_move(5, Piece:... | code_fim | hard | {
"lang": "rust",
"repo": "rachel-s-c/rust_HeuristicGameTree",
"path": "/src/tictactoe.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct KafkaConfig {
#[serde(rename="batch.size")]
pub batch_size: usize,
pub topic: String,
pub brokers: String,
#[serde(rename="compression.codec")]
pub compression_codec: String,
#[s... | code_fim | hard | {
"lang": "rust",
"repo": "yorkart/collector-rs",
"path": "/src/core/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yorkart/collector-rs path: /src/core/config.rs
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
#[serde(rename="env.index")]
pub env_index: usize,
#[serde(rename="channel.buffer.size")]
pub channel_buffer_size: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "yorkart/collector-rs",
"path": "/src/core/config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[serde(rename="tcp.addr")]
pub tcp_addr: String,
#[serde(rename="tcp.frame.max.size")]
pub tcp_frame_max_size: usize,
#[serde(rename="tcp.threads")]
pub tcp_threads: usize,
#[serde(rename="output.workers")]
pub out_workers: usize,
pub kafka: KafkaConfig,
}
#[derive(... | code_fim | medium | {
"lang": "rust",
"repo": "yorkart/collector-rs",
"path": "/src/core/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub fn save_or_load(&mut self, ser: &mut Serializer) -> Result<()> {
ser.save_or_load_entries(self, Ver(1))?;
self.video.save_or_load(ser)?;
if ser.mode() == Mode::Load {
// mute
self.player.stop();
self.mix... | code_fim | hard | {
"lang": "rust",
"repo": "HaronK/awbi",
"path": "/core/src/vm_context.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HaronK/awbi path: /core/src/vm_context.rs
use std::fmt;
use crate::{
file::File, memlist::MemEntryState, mixer::*, parts::*, reference::Ref, resource::ResourceRef,
serializer::*, sfxplayer::SfxPlayer, staticres::*, system::*, video::Video,
};
use anyhow::Result;
trace::init_dep... | code_fim | hard | {
"lang": "rust",
"repo": "HaronK/awbi",
"path": "/core/src/vm_context.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: piaojin/RustFFIOmnbusIniOS path: /RustFFIOmnbusIniOS/Rust_FFI_Omnbus/src/rust_to_swift.rs
extern crate libc;
use libc::{c_char, uint32_t};
use std::str;
use std::collections::HashMap;
use std::ffi::CStr;
use std::ffi::CString;
#[warn(non_snake_case)]
#[warn(dead_code)]
pub struct Test {
zi... | code_fim | hard | {
"lang": "rust",
"repo": "piaojin/RustFFIOmnbusIniOS",
"path": "/RustFFIOmnbusIniOS/Rust_FFI_Omnbus/src/rust_to_swift.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> database.set_zip_name(string);
}
#[no_mangle]
pub unsafe extern fn test_get_zip_name(ptr: *const ZipCodeDatabase) -> *mut c_char {
assert!(!ptr.is_null());
let database = &*ptr;//unsafe
let name = database.test.get_zip_name();
let c_name = CString::new(name).unwrap();//unsafe
c_n... | code_fim | hard | {
"lang": "rust",
"repo": "piaojin/RustFFIOmnbusIniOS",
"path": "/RustFFIOmnbusIniOS/Rust_FFI_Omnbus/src/rust_to_swift.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match piece_iter.next() {
None => Ok(()),
_ => Err(fmt::Error),
}
}<|fim_prefix|>// repo: maxwells-daemons/reason path: /rust/reason-othello/src/utils.rs
//! Miscellaneous project utilities.
use crate::EDGE_LENGTH;
use std::fmt::{self, Formatter};
use std::iter::Iterator;
/// Fo... | code_fim | medium | {
"lang": "rust",
"repo": "maxwells-daemons/reason",
"path": "/rust/reason-othello/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxwells-daemons/reason path: /rust/reason-othello/src/utils.rs
//! Miscellaneous project utilities.
use crate::EDGE_LENGTH;
use std::fmt::{self, Formatter};
use std::iter::Iterator;
<|fim_suffix|> match piece_iter.next() {
None => Ok(()),
_ => Err(fmt::Error),
}
}<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "maxwells-daemons/reason",
"path": "/rust/reason-othello/src/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Queryable, Insertable)]
pub struct Namespace {
pub name: String,
pub owner_id: i32
}<|fim_prefix|>// repo: jkile/namespaces-server path: /src/models/namespace.rs
// use crate::models::{user::User, thread::Thread};
use serde::{Deserialize, Serialize};
use diesel::{... | code_fim | easy | {
"lang": "rust",
"repo": "jkile/namespaces-server",
"path": "/src/models/namespace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jkile/namespaces-server path: /src/models/namespace.rs
// use crate::models::{user::User, thread::Thread};
use serde::{Deserialize, Serialize};
use diesel::{Queryable, Insertable};
<|fim_suffix|>#[derive(Serialize, Deserialize, Queryable, Insertable)]
pub struct Namespace {
pub name: String... | code_fim | easy | {
"lang": "rust",
"repo": "jkile/namespaces-server",
"path": "/src/models/namespace.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlexGoico/RustyChip-JIT path: /src/render/keymaps.rs
use sdl2::keyboard::Keycode;
use std::collections::HashMap;
pub type KeyMap = HashMap<Keycode, u8>;
lazy_static! {
pub static ref QWERTY_KEYMAP: KeyMap = {
let mut m = HashMap::new();
m.insert(Keycode::Num1, 0x1);
... | code_fim | hard | {
"lang": "rust",
"repo": "AlexGoico/RustyChip-JIT",
"path": "/src/render/keymaps.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> m
};
pub static ref COLEMAK_KEYMAP: KeyMap = {
let mut m = HashMap::new();
m.insert(Keycode::Num1, 0x1);
m.insert(Keycode::Num2, 0x2);
m.insert(Keycode::Num3, 0x3);
m.insert(Keycode::Num4, 0xc);
m.insert(Keycode::Q, 0x4);
m.insert(Key... | code_fim | hard | {
"lang": "rust",
"repo": "AlexGoico/RustyChip-JIT",
"path": "/src/render/keymaps.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ruddle/oxidator path: /src/mobile.rs
use super::frame::Player;
use crate::botdef;
use crate::unit;
use crate::utils;
use na::{Matrix4, Point3, Vector2, Vector3};
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use typename::TypeName;
use utils::Id;
#[derive(Clone, TypeName,... | code_fim | hard | {
"lang": "rust",
"repo": "Ruddle/oxidator",
"path": "/src/mobile.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::new(rad)
}
}
#[derive(Clone, TypeName, Debug, Serialize, Deserialize, PartialEq)]
pub enum Command {
None,
Build(Id<KBot>),
Repair(Id<KBot>),
}
#[derive(Clone, TypeName, Debug, Serialize, Deserialize, PartialEq)]
pub struct KBot {
pub id: Id<KBot>,
pub position: Poi... | code_fim | hard | {
"lang": "rust",
"repo": "Ruddle/oxidator",
"path": "/src/mobile.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parse(include_str!("statement_funcdef/expected.json"), || {
montyc_parser::comb::statement(0)
.parse(lex(include_str!("statement_funcdef/input.py")))
.expect("failed to parse statement")
})
}
#[test]
fn test_parse_statement_classdef() {
parse(include_str!("stat... | code_fim | hard | {
"lang": "rust",
"repo": "mental32/monty",
"path": "/montyc_parser/tests/regression_testing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mental32/monty path: /montyc_parser/tests/regression_testing.rs
use chumsky::Parser;
fn lex(input: &str) -> Vec<(montyc_lexer::PyToken, montyc_lexer::Span)> {
let lexer = montyc_lexer::lex(input);
let sr = montyc_parser::span_interner::SpanInterner::new();
montyc_parser::token_stre... | code_fim | hard | {
"lang": "rust",
"repo": "mental32/monty",
"path": "/montyc_parser/tests/regression_testing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parse(include_str!("expr_await/expected.json"), || {
montyc_parser::comb::expr()
.parse(lex(include_str!("expr_await/input.py")))
.expect("failed to parse expr")
})
}
#[test]
fn test_parse_statement_funcdef() {
parse(include_str!("statement_funcdef/expected.jso... | code_fim | hard | {
"lang": "rust",
"repo": "mental32/monty",
"path": "/montyc_parser/tests/regression_testing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: debris/matrix-rocketchat path: /src/matrix-rocketchat/handlers/rocketchat/forwarder.rs
use std::time::{SystemTime, UNIX_EPOCH};
use diesel::Connection;
use diesel::sqlite::SqliteConnection;
use slog::Logger;
use ruma_identifiers::RoomId;
use i18n::*;
use api::{MatrixApi, RocketchatApi};
use ap... | code_fim | hard | {
"lang": "rust",
"repo": "debris/matrix-rocketchat",
"path": "/src/matrix-rocketchat/handlers/rocketchat/forwarder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // this is a pretty hacky way to find a Matrix user that could be the recipient for this
// message. The message itself doesn't contain any information about the recipient so the
// channel ID has to be checked against all users that use the application service and are
// logged in on the ... | code_fim | hard | {
"lang": "rust",
"repo": "debris/matrix-rocketchat",
"path": "/src/matrix-rocketchat/handlers/rocketchat/forwarder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: synasius/nannou-arts path: /linetrace/src/main.rs
use nannou::prelude::*;
use ndarray::{Array, Axis, stack, arr2};
fn main() {
nannou::app(model)
.update(update)
.simple_window(view)
.run();
}
struct Model {}
fn model(_app: &App) -> Model {
let a = Array::lins... | code_fim | medium | {
"lang": "rust",
"repo": "synasius/nannou-arts",
"path": "/linetrace/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..20 {
draw.line()
.start(Vector2::new(0.0, 1.0))
.end(Vector2::new(10.0, 10.0))
.color(BLACK);
}
draw.to_frame(app, &frame).expect("Errors");
frame
}<|fim_prefix|>// repo: synasius/nannou-arts path: /linetrace/src/main.rs
use nannou... | code_fim | medium | {
"lang": "rust",
"repo": "synasius/nannou-arts",
"path": "/linetrace/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let draw = app.draw();
draw.background().color(WHITE);
for _ in 0..20 {
draw.line()
.start(Vector2::new(0.0, 1.0))
.end(Vector2::new(10.0, 10.0))
.color(BLACK);
}
draw.to_frame(app, &frame).expect("Errors");
frame
}<|fim_prefix|>// re... | code_fim | medium | {
"lang": "rust",
"repo": "synasius/nannou-arts",
"path": "/linetrace/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nezdolik/reproto path: /lib/backend-go/src/compiler.rs
//! Backend for Go
use backend::PackageProcessor;
use core::errors::*;
use core::{Handle, Loc, RelativePathBuf};
use flavored::{
GoFlavor, GoName, RpEnumBody, RpField, RpInterfaceBody, RpPackage, RpTupleBody, RpTypeBody,
};
use genco::g... | code_fim | hard | {
"lang": "rust",
"repo": "nezdolik/reproto",
"path": "/lib/backend-go/src/compiler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> t.nested_into(|t| {
push!(t, "Value interface {");
nested!(t, "Is", &body.name, "()");
push!(t, "}");
});
push!(t, "}");
Ok(())
})?;
t.push({
... | code_fim | hard | {
"lang": "rust",
"repo": "nezdolik/reproto",
"path": "/lib/backend-go/src/compiler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn process_enum(&self, out: &mut Self::Out, body: &'el RpEnumBody) -> Result<()> {
out.0.push({
let mut t = Tokens::new();
t.push_into(|t| {
t.push(Comments(&body.comment));
t.push(toks!["type ", &body.name, " int"])
});
... | code_fim | hard | {
"lang": "rust",
"repo": "nezdolik/reproto",
"path": "/lib/backend-go/src/compiler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_item(index: isize, wnd: &Wnd) -> Result<(Setting, String), Error> {
let width: Result<isize, Error> = match wnd.send_message(LVM_GETCOLUMNWIDTH, index as WPARAM, 0)
{
v if v < 1 => Err(io::Error::last_os_error())
.with_context(|e| format!("LVM_GETCOLUMNWIDTH failed - ind... | code_fim | hard | {
"lang": "rust",
"repo": "omerbenamram/cloppy",
"path": "/src/actions/save_columns_position.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let width: Result<isize, Error> = match wnd.send_message(LVM_GETCOLUMNWIDTH, index as WPARAM, 0)
{
v if v < 1 => Err(io::Error::last_os_error())
.with_context(|e| format!("LVM_GETCOLUMNWIDTH failed - index {}: {}", index, e))?,
v => Ok(v),
};
match index {
... | code_fim | medium | {
"lang": "rust",
"repo": "omerbenamram/cloppy",
"path": "/src/actions/save_columns_position.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: omerbenamram/cloppy path: /src/actions/save_columns_position.rs
use crate::dispatcher::UiAsyncMessage;
use crate::errors::MyErrorKind::WindowsError;
use crate::gui::event::Event;
use crate::gui::Gui;
use crate::gui::Wnd;
use crate::settings::Setting;
use failure::Error;
use failure::ResultExt;
u... | code_fim | hard | {
"lang": "rust",
"repo": "omerbenamram/cloppy",
"path": "/src/actions/save_columns_position.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> data
.get(index)
.copied()
.map(MerkleSignatureTag::new)
.ok_or(Error::InvalidMerkleSignatureKeyTag(None))
}
}
#[cfg(test)]
mod tests {
use crate::crypto::merkle_key::Blake2b256;
use crate::crypto::merkle_key::MerkleDigest;
use crate::crypto::merkle_key::MerkleDigestTa... | code_fim | hard | {
"lang": "rust",
"repo": "maxverbeek/Blockchain-based-E-voting",
"path": "/myDigitalWalletWebApp/src/app/identity-core/src/crypto/merkle_key/base.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rename_success: bool = r_conn.rename_nx(REDIS_KEY_ROLL_STATS, &buffer_key)?;
if !rename_success {
error!("Redis error: Key not available");
return Ok(());
}
let entries: Vec<String> = r_conn.hgetall(&buffer_key).expect("Error loading keys");
for chunk in entries.... | code_fim | hard | {
"lang": "rust",
"repo": "benbrandt/d20",
"path": "/src/bin/d20_save_roll_stats.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benbrandt/d20 path: /src/bin/d20_save_roll_stats.rs
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
#![allow(clippy::used_underscore_binding)]
use d20::{db_pool, models::RollStat, redis_pool, schema, sentry_init, REDIS_KEY_ROLL_STATS};
use diesel::{self, prelude::*};
use dotenv::dotenv;... | code_fim | medium | {
"lang": "rust",
"repo": "benbrandt/d20",
"path": "/src/bin/d20_save_roll_stats.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: santosh241/Windary path: /Rust/src/0371_sum_of_two_integers.rs
//! Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.
//!
//! ```
//! Example 1:
//!
//! Input: a = 1, b = 2
//! Output: 3
//! ```
//!
//! ```
//! Example 2:
//!
//! Input: a = -2, b = 3
... | code_fim | medium | {
"lang": "rust",
"repo": "santosh241/Windary",
"path": "/Rust/src/0371_sum_of_two_integers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> b
}
}
#[cfg(test)]
mod tests {
use super::Solution;
#[test]
fn test_0() {
assert_eq!(Solution::get_sum(1, 2), 3);
}
#[test]
fn test_1() {
assert_eq!(Solution::get_sum(-2, 3), 1);
}
}<|fim_prefix|>// repo: santosh241/Windary path: /Rust/src/0371_... | code_fim | medium | {
"lang": "rust",
"repo": "santosh241/Windary",
"path": "/Rust/src/0371_sum_of_two_integers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aaely/substrate-product-management path: /pallets/peptides/src/types.rs
use sp_std::prelude::*;
use codec::{Encode, Decode};
#[derive(Encode, Decode, Clone, PartialEq, Eq, Default)]
pub struct Peptide<AccountId, Moment> {
pub id: u128,
pub name: Vec<u8>,
pub price: u32,
pub inventory: u32,
... | code_fim | medium | {
"lang": "rust",
"repo": "aaely/substrate-product-management",
"path": "/pallets/peptides/src/types.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Encode, Decode, Clone, PartialEq, Eq, Default)]
pub struct AminoAcid {
pub id: u128,
pub name: Vec<u8>,
pub cost: u32,
}<|fim_prefix|>// repo: aaely/substrate-product-management path: /pallets/peptides/src/types.rs
use sp_std::prelude::*;
use codec::{Encode, Decode};
#[derive(Encode, Decode,... | code_fim | medium | {
"lang": "rust",
"repo": "aaely/substrate-product-management",
"path": "/pallets/peptides/src/types.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let str = result.to_rust_string_lossy(scope);
println!("{}", str);
context.exit();
}
drop(locker);
}<|fim_prefix|>// repo: manyuanrong/rusty_v8_hello_world path: /src/main.rs
use rusty_v8 as v8;
fn main() {
let platform = v8::platform::new_default_platform();
v... | code_fim | hard | {
"lang": "rust",
"repo": "manyuanrong/rusty_v8_hello_world",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: manyuanrong/rusty_v8_hello_world path: /src/main.rs
use rusty_v8 as v8;
fn main() {
let platform = v8::platform::new_default_platform();
v8::V8::initialize_platform(platform);
v8::V8::initialize();
<|fim_suffix|> let mut context = v8::Context::new(scope);
context.ent... | code_fim | hard | {
"lang": "rust",
"repo": "manyuanrong/rusty_v8_hello_world",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn ppid(&self) -> Option<Pid> {
self.inner.ppid()
}
fn is_main_thread(&self) -> bool {
self.inner.is_main_thread()
}
fn is_root_process(&self) -> bool {
self.inner.is_root_process()
}
fn is_root_thread(&self) -> bool {
self.inner.is_root_threa... | code_fim | hard | {
"lang": "rust",
"repo": "jasonwhite/reverie",
"path": "/reverie/src/guest.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Like [`Guest::inject`], but will retry the syscall if `EINTR` or
/// `ERESTARTSYS` are returned.
///
/// This is useful if we need to inject a syscall other than the one
/// currently being handled in `handle_syscall_event`. If we don't retry
/// interrupted syscalls, we could ... | code_fim | hard | {
"lang": "rust",
"repo": "jasonwhite/reverie",
"path": "/reverie/src/guest.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jasonwhite/reverie path: /reverie/src/guest.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
//! Guest (i.e. thread) stru... | code_fim | hard | {
"lang": "rust",
"repo": "jasonwhite/reverie",
"path": "/reverie/src/guest.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fbaiesec/rust-libp2p path: /protocols/noise/src/io/handshake/payload.rs
// This file is generated by rust-protobuf 2.3.0. Do not edit
// @generated
// https://github.com/Manishearth/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy)]
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(... | code_fim | hard | {
"lang": "rust",
"repo": "fbaiesec/rust-libp2p",
"path": "/protocols/noise/src/io/handshake/payload.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_signature(&self) -> &[u8] {
&self.signature
}
}
impl ::protobuf::Message for Identity {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
... | code_fim | hard | {
"lang": "rust",
"repo": "fbaiesec/rust-libp2p",
"path": "/protocols/noise/src/io/handshake/payload.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GunterMueller/ST_STX_Fork path: /build/stx/libtool/resources/ro.rs
#encoding utf-8
; $Header: /cvs/stx/stx/libtool/resources/ro.rs,v 1.3 2008/11/28 16:41:56 cg Exp $
;
; Launcher
;
; Afrikaans 'Afrikaans'
Arabic 'Arabă'
Chinese 'Chineză'
'Chinese ... | code_fim | hard | {
"lang": "rust",
"repo": "GunterMueller/ST_STX_Fork",
"path": "/build/stx/libtool/resources/ro.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'Poloneză'
Portuguese 'Portugheză'
Russian 'Rusă'
Spanish 'Spaniolă'
Swedish 'Suedeză'
Romanian
Thai 'Tailandeză'
Turkish 'Turcă'
Ukrainian 'Ucraineană'<|fim_prefix|>// repo: GunterMueller/ST_... | code_fim | hard | {
"lang": "rust",
"repo": "GunterMueller/ST_STX_Fork",
"path": "/build/stx/libtool/resources/ro.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'Engleză (UK)'
; Esperanto 'Esperanto'
German 'Germană'
Greek 'Greacă'
; Italian
Finnish 'Finlandeză'
Japanese 'Japoneză'
'Korean' 'Coreeană'
Polish 'Poloneză'
Portuguese '... | code_fim | hard | {
"lang": "rust",
"repo": "GunterMueller/ST_STX_Fork",
"path": "/build/stx/libtool/resources/ro.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SPuntte/yarhos path: /tests/basic_boot.rs
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(yarhos::test_runner)]
#![reexport_test_harness_main = "test_main"]
<|fim_suffix|>#[test_case]
fn test_println() {
yarhos::println!("test_println output");
}<|fim_middle|>use c... | code_fim | hard | {
"lang": "rust",
"repo": "SPuntte/yarhos",
"path": "/tests/basic_boot.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
yarhos::test_panic_handler(info)
}
#[test_case]
fn test_println() {
yarhos::println!("test_println output");
}<|fim_prefix|>// repo: SPuntte/yarhos path: /tests/basic_boot.rs
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_run... | code_fim | hard | {
"lang": "rust",
"repo": "SPuntte/yarhos",
"path": "/tests/basic_boot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lcoenen/fluence path: /tools/wasm-utils/src/main.rs
/*
* Copyright 2019 Fluence Labs Limited
*
* 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.... | code_fim | hard | {
"lang": "rust",
"repo": "lcoenen/fluence",
"path": "/tools/wasm-utils/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn prepare_wasm_file<'a, 'b>() -> App<'a, 'b> {
let arg = &[
Arg::with_name(MODULE_PATH)
.required(true)
.takes_value(true)
.help("path to the wasm file"),
];
SubCommand::with_name("prepare")
.about("Prepare wasm file to run on the Fluence n... | code_fim | hard | {
"lang": "rust",
"repo": "lcoenen/fluence",
"path": "/tools/wasm-utils/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reb/advent_of_code_2017 path: /day-6/src/main.rs
use std::collections::HashSet;
fn get_input() -> Vec<u32> {
const INPUT: &str = include_str!("input.txt");
convert(INPUT)
}
fn convert(input: &str) -> Vec<u32> {
input.lines().next().unwrap()
.split_whitespace()
.map... | code_fim | hard | {
"lang": "rust",
"repo": "reb/advent_of_code_2017",
"path": "/day-6/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let new_memory = redistribute(&memory);
// check if the memory state was reached before
if previous_states.contains(&new_memory) {
// if it was check if it was already reach before in the loop
if loop_states.contains(&new_memory) {
... | code_fim | hard | {
"lang": "rust",
"repo": "reb/advent_of_code_2017",
"path": "/day-6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ericsink/rust-raytracer path: /src/material/materials/cooktorrancematerial.rs
use crate::prelude::*;
use core::f64::consts::PI;
use crate::material::{Material, Texture};
use crate::raytracer::compositor::ColorRGBA;
use crate::vec3::Vec3;
#[allow(dead_code)]
#[derive(Clone)]
pub struct CookTorra... | code_fim | hard | {
"lang": "rust",
"repo": "ericsink/rust-raytracer",
"path": "/src/material/materials/cooktorrancematerial.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.