text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: 2428621928/cashbox path: /bc/murmel/src/getdata.rs
//! after send loadfilter message in bloomfilter mod we can get merkleblock in this mod and get
//! loadfilter message do not get any response.
//! we get response here
use crate::error::Error;
use crate::hooks::{HooksMessage, ShowCondition};
us... | code_fim | hard | {
"lang": "rust",
"repo": "2428621928/cashbox",
"path": "/bc/murmel/src/getdata.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let vec = RB_DETAIL.list_btc_output_tx();
let mut output_map = HashMap::new();
for output in vec {
output_map.insert(output.btc_tx_hash, output.idx);
}
let inputs = tx.clone().input;
for (index, txin) in inputs.iter().enumerate() {
l... | code_fim | hard | {
"lang": "rust",
"repo": "2428621928/cashbox",
"path": "/bc/murmel/src/getdata.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akmaljalilov/rust_tutorial path: /src/general_tree.rs
use std::collections::VecDeque;
#[test]
fn test() {
struct Node {
key: u32,
child: VecDeque<Node>,
}
fn new_node(key: u32) -> Node {
Node {
key,
child: VecDeque::new(),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "akmaljalilov/rust_tutorial",
"path": "/src/general_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while !vec_deq.is_empty() {
let mut n = vec_deq.len();
while n > 0 {
let p = vec_deq.pop_front().unwrap();
print!("{} ", p.key);
for child in p.child {
vec_deq.push_back(child)
}
... | code_fim | medium | {
"lang": "rust",
"repo": "akmaljalilov/rust_tutorial",
"path": "/src/general_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bytes = input.from_hex().unwrap();
bytes.to_base64(STANDARD)
}<|fim_prefix|>// repo: anoopelias/matasano path: /rust-matasano/src/challenge1.rs
extern crate rustc_serialize;
use rustc_serialize::hex::FromHex;
use rustc_serialize::base64::ToBase64;
use rustc_serialize::base64::STANDARD;
pub ... | code_fim | easy | {
"lang": "rust",
"repo": "anoopelias/matasano",
"path": "/rust-matasano/src/challenge1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Challenge 1 : {}", output);
}
fn hex_to_base64(input: &str) -> String {
let bytes = input.from_hex().unwrap();
bytes.to_base64(STANDARD)
}<|fim_prefix|>// repo: anoopelias/matasano path: /rust-matasano/src/challenge1.rs
extern crate rustc_serialize;
use rustc_serialize::hex::FromH... | code_fim | medium | {
"lang": "rust",
"repo": "anoopelias/matasano",
"path": "/rust-matasano/src/challenge1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anoopelias/matasano path: /rust-matasano/src/challenge1.rs
extern crate rustc_serialize;
use rustc_serialize::hex::FromHex;
use rustc_serialize::base64::ToBase64;
use rustc_serialize::base64::STANDARD;
<|fim_suffix|> println!("Challenge 1 : {}", output);
}
fn hex_to_base64(input: &str) -> ... | code_fim | medium | {
"lang": "rust",
"repo": "anoopelias/matasano",
"path": "/rust-matasano/src/challenge1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn local_normal_at(&self, point: Point3<f32>, _intersection: &Intersection) -> Vector3<f32> {
Vector3::zeros()
}
}<|fim_prefix|>// repo: ckampfe/racy path: /src/example_shape.rs
use crate::group::Group;
use crate::intersection::Intersection;
use crate::material::Material;
use crate::ray::... | code_fim | medium | {
"lang": "rust",
"repo": "ckampfe/racy",
"path": "/src/example_shape.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ckampfe/racy path: /src/example_shape.rs
use crate::group::Group;
use crate::intersection::Intersection;
use crate::material::Material;
use crate::ray::Ray;
use crate::shape::Shape;
use nalgebra::{Matrix4, Point3, Vector3};
pub struct ExampleShape<'a> {
pub material: Material,
pub trans... | code_fim | hard | {
"lang": "rust",
"repo": "ckampfe/racy",
"path": "/src/example_shape.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/savingsplans/src/model.rs
td::string::String>,
/// <p>The payment option.</p>
pub payment_option: std::option::Option<crate::model::SavingsPlanPaymentOption>,
/// <p>The duration, in seconds.</p>
pub duration_seconds: i64,
/// <p>The currency.</... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/savingsplans/src/model.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Ok(SavingsPlanRateUnit::from(s))
}
}
impl SavingsPlanRateUnit {
pub fn as_str(&self) -> &str {
match self {
SavingsPlanRateUnit::Hours => "Hrs",
SavingsPlanRateUnit::LambdaGbSecond => "Lambda... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/savingsplans/src/model.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/savingsplans/src/model.rs
n::Option<crate::model::SavingsPlanOfferingFilterAttribute>,
pub(crate) values: std::option::Option<std::vec::Vec<std::string::String>>,
}
impl Builder {
/// <p>The filter name.</p>
pub fn name(mut self, inp... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/savingsplans/src/model.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn deref(&self) -> &T {
&self.name
}
}
pub fn deref_simple_demo() {
println!(
"{}",
"------------deref_simple_demo start-------------------"
);
let x = 5;
let y = MyBox::new(x);
assert_eq!(5, x);
assert_eq!(5, *y);
let z = String::from("deref_... | code_fim | hard | {
"lang": "rust",
"repo": "bradyjoestar/rust-learning",
"path": "/src/smart_pointer_demo/deref_demo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bradyjoestar/rust-learning path: /src/smart_pointer_demo/deref_demo.rs
use std::ops::Deref;
struct MyBox<T>(T);
impl<T> MyBox<T> {
fn new(x: T) -> MyBox<T> {
MyBox(x)
}
}
impl<T> Deref for MyBox<T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
st... | code_fim | hard | {
"lang": "rust",
"repo": "bradyjoestar/rust-learning",
"path": "/src/smart_pointer_demo/deref_demo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Z65kcA29kvJHUMTc/tree path: /src/lib.rs
use std::slice::Iter;
pub enum Tree<T> {
Leaf(T),
Children(Vec<Tree<T>>),
}
// https://www.reddit.com/r/rust/comments/fsbqwp/how_to_iterate_trees_nicely
impl<T> Tree<T> {
pub fn iter(&self) -> impl Iterator<Item = &T> {
fn t... | code_fim | hard | {
"lang": "rust",
"repo": "Z65kcA29kvJHUMTc/tree",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_tree() {
let tree = Tree::Children(vec![
Tree::Leaf(1),
Tree::Leaf(2),
Tree::Children(vec![
Tree::Leaf(3),
Tree::Leaf(4),
Tree::Childr... | code_fim | hard | {
"lang": "rust",
"repo": "Z65kcA29kvJHUMTc/tree",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: letheka/euphonium path: /src/parse.rs
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Serialize, Deserialize)]
pub struct JSONArrangement {
pub metadata: JSONMetadata,
pub sample_banks: Vec<JSONSampleBank>,
pub waveforms: Vec<JSONWaveform>,
pub envel... | code_fim | hard | {
"lang": "rust",
"repo": "letheka/euphonium",
"path": "/src/parse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize)]
pub struct JSONModulator {
pub modulator: String,
pub depth: f32
}
#[derive(Serialize, Deserialize)]
pub struct JSONOutput {
pub output_file: String,
pub channels: Vec<u8>
}<|fim_prefix|>// repo: letheka/euphonium path: /src/parse.rs
use serde::{Deserial... | code_fim | hard | {
"lang": "rust",
"repo": "letheka/euphonium",
"path": "/src/parse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seed-rs/seed path: /src/virtual_dom/node/el.rs
use super::super::{
At, AtValue, Attrs, CSSValue, EventHandler, EventHandlerManager, Node, SharedNodeWs, St, Style,
Tag, Text,
};
use crate::{
app::MessageMapper,
browser::{
dom::{virtual_dom_bridge, Namespace},
util,... | code_fim | hard | {
"lang": "rust",
"repo": "seed-rs/seed",
"path": "/src/virtual_dom/node/el.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Add an attribute (eg class, or href)
pub fn add_attr(
&mut self,
key: impl Into<Cow<'static, str>>,
val: impl Into<AtValue>,
) -> &mut Self {
self.attrs.vals.insert(At::from(key), val.into());
self
}
/// Add a class. May be cleaner than `add... | code_fim | hard | {
"lang": "rust",
"repo": "seed-rs/seed",
"path": "/src/virtual_dom/node/el.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sacrrie/DependencyInqury path: /dependencies_client/main.rs
extern crate udp_messenging;
use std::io;
use std::net;
use std::str;
fn main() {
let ip = net::Ipv4Addr::new(127, 0, 0, 1);
let send_addr = net::SocketAddrV4::new(ip, 8888);
let listen_addr = net::SocketAddrV4::new(ip, 8889... | code_fim | hard | {
"lang": "rust",
"repo": "sacrrie/DependencyInqury",
"path": "/dependencies_client/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Addr::V4(listen_addr),net::SocketAddr::V4(send_addr),msg);
//look for reply
//thread.sleep(200);
let capture = udp_messenging::listen(net::SocketAddr::V4(listen_addr));
let received = capture.join().unwrap();
let answer=str::from_utf8(&received[..]).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "sacrrie/DependencyInqury",
"path": "/dependencies_client/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> to inqury:\n");
let mut packageName=String::new();
io::stdin().read_line(&mut packageName)
.expect("failed to read package name");
let mut packageName= packageName.trim().to_string();
let mut codedName = packageName.into_bytes();
msg.append(&mut codedNa... | code_fim | hard | {
"lang": "rust",
"repo": "sacrrie/DependencyInqury",
"path": "/dependencies_client/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>stration.add_primary_service(srv::GENERIC_ATTRIBUTE);
// ServiceChanged
registration.add_characteristic(
ch::SERVICE_CHANGED,
vec![0x00],
CharacteristicProperties::INDICATE,
);
}<|fim_prefix|>// repo: yskszk63/btknmle path: /src/hogp/gatt.rs
use gatt::characteristics a... | code_fim | medium | {
"lang": "rust",
"repo": "yskszk63/btknmle",
"path": "/src/hogp/gatt.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yskszk63/btknmle path: /src/hogp/gatt.rs
use gatt::characteristics as ch;
use gatt::services as srv;
use gatt::{CharacteristicProperties, Registrat<|fim_suffix|>stration.add_primary_service(srv::GENERIC_ATTRIBUTE);
// ServiceChanged
registration.add_characteristic(
ch::SERVICE_CH... | code_fim | medium | {
"lang": "rust",
"repo": "yskszk63/btknmle",
"path": "/src/hogp/gatt.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_rgb_tohsv() {
let rgb_vec = vec!["rgb( 81% , 89% , 10%)", "rgba(81%,89%,10%,0.5)", "rgba(81,89,12,0.3)"];
let rgb_result = vec![
vec!["hsv(66.08,88.76%,89%)", "HSV(66.08,88.76%,89%)", "hsv(66.08,88.76%,89%)", "hsv(66.08,88.76%,89%)", "HSV(66.08,88.76%,89%)", "HSV(66.08,88.76%,89%)... | code_fim | hard | {
"lang": "rust",
"repo": "RUGMJ/color-convert",
"path": "/tests/rgb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_rgb_tohsl() {
let rgb_vec = vec!["rgb( 81% , 89% , 10%)", "rgba(81%,89%,10%,0.5)", "rgba(81,89,12,0.3)"];
let rgb_result = vec![
vec!["hsl(66.08,79.79%,49.5%)", "HSL(66.08,79.79%,49.5%)", "hsl(66.08,79.79%,49.5%)", "hsla(66.08,79.79%,49.5%,1)", "HSL(66.08,79.79%,49.5%)", "HSLA(66.... | code_fim | hard | {
"lang": "rust",
"repo": "RUGMJ/color-convert",
"path": "/tests/rgb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RUGMJ/color-convert path: /tests/rgb.rs
extern crate color_convert;
pub mod common;
#[cfg(test)]
mod tests {
use color_convert::color::{Color};
use color_convert::handles::rgb;
use common::init_color;
#[test]
fn test_handle_rgb() {
let rgb_vec = vec!["rgb( 81 , 89% , 10%)", "rgba(81%,89... | code_fim | hard | {
"lang": "rust",
"repo": "RUGMJ/color-convert",
"path": "/tests/rgb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: XuJiandong/smt-cli path: /src/main.rs
mod blake2b;
use blake2b::Blake2bHasher;
use clap::{App, AppSettings, Arg};
use lazy_static::lazy_static;
use smt::default_store::DefaultStore;
use smt::{SparseMerkleTree, H256};
lazy_static! {
pub static ref NON_INCLUSION: H256 = [0; 32].into();
... | code_fim | hard | {
"lang": "rust",
"repo": "XuJiandong/smt-cli",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let proof = smt.merkle_proof(inclusion_keys).expect("gen proof");
let compiled_proof = proof.clone().compile(inclusion_pairs.clone()).unwrap();
// verify it locally
assert!(compiled_proof
.verify::<Blake2bHasher>(smt.root(), inclusion_pairs)
.expect("verify compiled proof")... | code_fim | hard | {
"lang": "rust",
"repo": "XuJiandong/smt-cli",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn by_accumulated_difficulty(self) -> Self {
self.add_comparer_as_then(Box::<AccumulatedDifficultySquaredComparer>::default())
}
pub fn by_randomx_difficulty(self) -> Self {
self.add_comparer_as_then(Box::<RandomxDifficultyComparer>::default())
}
pub fn by_sha3x_d... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/base_layer/core/src/consensus/chain_strength_comparer.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tari-project/tari path: /base_layer/core/src/consensus/chain_strength_comparer.rs
// Copyright 2022 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause
use std::{cmp::Ordering, fmt::Debug};
use crate::blocks::ChainHeader;
pub trait ChainStrengthComparer: Debug {
fn compare(&self, a:... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/base_layer/core/src/consensus/chain_strength_comparer.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drmorr0/rustybot path: /src/state_machine/initialization_state.rs
use crate::{
avr_async::Waiter,
state_machine::State,
uno::{
timers,
MotorController,
Uno,
},
};
use arduino_uno::prelude::*;
<|fim_suffix|>pub async fn initialization_future(uno: &mut Uno)... | code_fim | medium | {
"lang": "rust",
"repo": "drmorr0/rustybot",
"path": "/src/state_machine/initialization_state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn initialization_future(uno: &mut Uno) -> State {
uno.pushbutton.wait_for_press().await;
let additional_button_presses = uno.pushbutton.count_presses_before(timers::millis() + 1000).await;
if additional_button_presses >= CONFIG_EXTRA_PRESSES {
State::Calibration
} else {... | code_fim | medium | {
"lang": "rust",
"repo": "drmorr0/rustybot",
"path": "/src/state_machine/initialization_state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/smallvec/tests/macro.rs
/
/
/
This
file
tests
smallvec
!
without
actually
having
the
macro
in
scope
.
/
/
/
This
forces
any
recursion
to
use
a
crate
prefix
to
<|fim_suffix|>
tt
)
=
>
{
vec
=
smallvec
:
:
smallvec
!
init
;
assert_eq
!
(
*
vec
*
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/smallvec/tests/macro.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
;
check
!
(
[
2
;
2
]
)
;
check
!
(
[
3
;
3
]
)
;
check
!
(
[
]
)
;
check
!
(
[
1
]
)
;
check
!
(
[
1
2
]
)
;
check
!
(
[
1
2
3
]
)
;
}<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/smallvec/tests/macro.rs
/
/
/
This
file
tests
smallvec
!
without
actually
having
the
macro
in
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/smallvec/tests/macro.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PowerSnail/AdventOfCode2019 path: /src/day15.rs
mod intcode_machine;
mod util;
use intcode_machine::{run_all, Machine, State};
use std::collections::{HashMap, HashSet};
use std::io::{stdin, BufRead};
use util::error_exit;
const C_NORTH: i64 = 1;
const C_SOUTH: i64 = 2;
const C_WEST: i64 = 3;
c... | code_fim | hard | {
"lang": "rust",
"repo": "PowerSnail/AdventOfCode2019",
"path": "/src/day15.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> WorldMap {
machine: Machine::new(&program),
prev: HashMap::new(),
wall: HashSet::new(),
target: None,
}
}
fn step(&mut self, dir: i64) -> i64 {
run_all(&mut self.machine, yield_iter![dir,]);
self.machine.pop_output()
... | code_fim | hard | {
"lang": "rust",
"repo": "PowerSnail/AdventOfCode2019",
"path": "/src/day15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let program = stdin()
.lock()
.split(',' as u8)
.map(|chunk| String::from_utf8(chunk.ok()?).ok()?.parse().ok())
.map(|result| result.expect("Failed to get next input"))
.collect();
WorldMap {
machine: Machine::new(&pr... | code_fim | hard | {
"lang": "rust",
"repo": "PowerSnail/AdventOfCode2019",
"path": "/src/day15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OceanBelongsToMe/vscode-sys path: /src/commands.rs
use crate::disposable::Disposable;
use js_sys::{Function, JsString};
use wasm_bindgen::prelude::*;
<|fim_suffix|> pub static commands: Commands;
#[wasm_bindgen(method, js_name = "registerCommand")]
#[must_use]
pub fn register_co... | code_fim | medium | {
"lang": "rust",
"repo": "OceanBelongsToMe/vscode-sys",
"path": "/src/commands.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen(method, js_name = "registerCommand")]
#[must_use]
pub fn register_command(this: &Commands, cmd: JsString, cb: &Function) -> Disposable;
}<|fim_prefix|>// repo: OceanBelongsToMe/vscode-sys path: /src/commands.rs
use crate::disposable::Disposable;
use js_sys::{Function, JsString}... | code_fim | medium | {
"lang": "rust",
"repo": "OceanBelongsToMe/vscode-sys",
"path": "/src/commands.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> CryptoError::Bech32Error(error)
}
}
use std::sync::atomic::{AtomicUsize, Ordering};
static STATE: AtomicUsize = AtomicUsize::new(UNINITIALIZED);
const UNINITIALIZED: usize = 0;
const INITIALIZING: usize = 1;
const INITIALIZED: usize = 2;
/// Initialize crypto to work with specific network p... | code_fim | hard | {
"lang": "rust",
"repo": "stegos/stegos",
"path": "/crypto/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stegos/stegos path: /crypto/src/lib.rs
//
// Copyright (c) 2018 Stegos AG
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without ... | code_fim | hard | {
"lang": "rust",
"repo": "stegos/stegos",
"path": "/crypto/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>static STATE: AtomicUsize = AtomicUsize::new(UNINITIALIZED);
const UNINITIALIZED: usize = 0;
const INITIALIZING: usize = 1;
const INITIALIZED: usize = 2;
/// Initialize crypto to work with specific network prefix.
/// Reserved network prefixes:
/// stg - stegos mainnet;
/// stt - stegos testnet;
/// str ... | code_fim | hard | {
"lang": "rust",
"repo": "stegos/stegos",
"path": "/crypto/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> device_connector
.connect_to_application(
&mut uuid,
Some(ClientEnd::new(zx_provider_client_end)),
ServerEnd::new(channel),
)
.context("Could not connect to fuchsia.tee.Application over DeviceConnectorProxy")?;
provider.serve(provider_se... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/bin/tee_manager/src/device_server.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Serves a `fuchsia.tee.DeviceInfo` protocol request by passing it through the
/// `TeeDeviceConnection`.
pub async fn serve_device_info_passthrough(
device_connector: DeviceConnectorProxy,
channel: zx::Channel,
) -> Result<(), Error> {
device_connector
.connect_to_device_info(Server... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/bin/tee_manager/src/device_server.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/security/bin/tee_manager/src/device_server.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::provider_server::ProviderServer,
any... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/bin/tee_manager/src/device_server.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tdolist/tdo-notify path: /src/settings.rs
//! Settings needed for mail notification.
use base64::{encode, decode};
use super::tdo_core::error::*;
use std::fs::File;
use std::io::{Read, Write};
/// Base stuct for Mail settings
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Settings ... | code_fim | hard | {
"lang": "rust",
"repo": "tdolist/tdo-notify",
"path": "/src/settings.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Stores a Settings object to JSON
pub fn store(&self, path: &String) -> TdoResult<()> {
match File::create(path.to_owned() + ".notify") {
Ok(mut file) => {
let raw = super::serde_json::to_string(self).unwrap().into_bytes();
match file.write(&e... | code_fim | hard | {
"lang": "rust",
"repo": "tdolist/tdo-notify",
"path": "/src/settings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write_sockaddr(&endpoint, Some(sockaddr), Some(socklen))?;
Ok(0)
}
}<|fim_prefix|>// repo: 5l1v3r1/kerla path: /kernel/syscalls/getpeername.rs
use crate::{arch::UserVAddr, fs::opened_file::Fd, result::Result};
use crate::{net::socket::write_sockaddr, process::current_process, syscalls... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/kerla",
"path": "/kernel/syscalls/getpeername.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 5l1v3r1/kerla path: /kernel/syscalls/getpeername.rs
use crate::{arch::UserVAddr, fs::opened_file::Fd, result::Result};
use crate::{net::socket::write_sockaddr, process::current_process, syscalls::SyscallHandler};
<|fim_suffix|> write_sockaddr(&endpoint, Some(sockaddr), Some(socklen))?;
... | code_fim | hard | {
"lang": "rust",
"repo": "5l1v3r1/kerla",
"path": "/kernel/syscalls/getpeername.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>2){
*input = vec![];
dict.display_vars();
}
pub fn display_all(input:&mut Vec<Code>, dict:&mut Dict, _:usize, _:&mut Option<Data>, _:&mut Vec<Vec<Code>>, _:&mut i32){
*input = vec![];
dict.display_heap();
dict.display_stack();
dict.display_vars();
}
pub fn display_line(input:&mut V... | code_fim | hard | {
"lang": "rust",
"repo": "thea0032/old-language-attempt",
"path": "/src/operations/display.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thea0032/old-language-attempt path: /src/operations/display.rs
use crate::operations::*;
pub fn display_heap(input:&mut Vec<Code>, dict:&mut Dict, _:usize, _:&mut Option<Data>, _:&mut Vec<Vec<Code>>, _:&mut i32){
*input = vec![];
dict.display_heap();
}
pub fn display_stack(input:&mut Vec... | code_fim | hard | {
"lang": "rust",
"repo": "thea0032/old-language-attempt",
"path": "/src/operations/display.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lgphp/webrtc-rs path: /src/native/ice_candidate.rs
use libc::{c_char, c_void};
use std::ffi::{CStr, CString};
use crate::*;
impl<'a> internal::FromWithCleanup<&'a dyn IceCandidateCommon> for internal::RTCIceCandidateInit {
fn from_with_cleanup<'b>(common: &'b dyn IceCandidateCommon, c_string... | code_fim | hard | {
"lang": "rust",
"repo": "lgphp/webrtc-rs",
"path": "/src/native/ice_candidate.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
internal::free(candidate.candidate as *mut c_void);
internal::free(candidate.sdp_mid as *mut c_void);
}
new_candidate
}
}<|fim_prefix|>// repo: lgphp/webrtc-rs path: /src/native/ice_candidate.rs
use libc::{c_char, c_void};
use std::ffi::{CStr, CString};
use crate::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "lgphp/webrtc-rs",
"path": "/src/native/ice_candidate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let new_candidate = unsafe {
RTCIceCandidate::new(RTCIceCandidateInit {
candidate: CStr::from_ptr(candidate.candidate).to_str().unwrap().to_string(),
sdp_mid: Some(CStr::from_ptr(candidate.sdp_mid).to_str().unwrap().to_string()),
sdp_mline_index: Some(candidate.sdp_mline_... | code_fim | hard | {
"lang": "rust",
"repo": "lgphp/webrtc-rs",
"path": "/src/native/ice_candidate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match node.left {
Some(node_left) => {
let node_index = level_index + parent_index;
acc[node_index] = node_left.value;
bfs(node_left, height + 1, parent_index, acc);
}
None => (),
}
match node.rig... | code_fim | hard | {
"lang": "rust",
"repo": "kansi/g4g",
"path": "/src/binary_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kansi/g4g path: /src/binary_tree.rs
mod binary_tree {
#[derive(Debug, Default)]
pub struct Node<'a> {
pub value: u32,
pub left: Option<&'a Node<'a>>,
pub right: Option<&'a Node<'a>>,
}
pub fn new_node<'a>(value: &'a u32) -> Node {
Node {
... | code_fim | hard | {
"lang": "rust",
"repo": "kansi/g4g",
"path": "/src/binary_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Network { engine }
}
/// Creates a network instance with an associated [`EventQueue`] where the input network
/// events can be read.
/// If you want to create a [`EventQueue`] that manages more events than `NetEvent`,
/// You can create use instead [Network::split_and_map()].... | code_fim | hard | {
"lang": "rust",
"repo": "ChaosStudyGroup/message-io",
"path": "/src/network.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Network is in charge of managing all the connections transparently.
/// It transforms raw data from the network into message events and vice versa,
/// and manages the different adapters for you.
pub struct Network {
engine: NetworkEngine,
}
impl Network {
/// Creates a new `Network` instance... | code_fim | hard | {
"lang": "rust",
"repo": "ChaosStudyGroup/message-io",
"path": "/src/network.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChaosStudyGroup/message-io path: /src/network.rs
// The ext public uses allows the user to use all this elements as network elements
pub use crate::resource_id::{ResourceId, ResourceType};
pub use crate::endpoint::{Endpoint};
pub use crate::adapter::{SendStatus};
pub use crate::remote_addr::{Rem... | code_fim | hard | {
"lang": "rust",
"repo": "ChaosStudyGroup/message-io",
"path": "/src/network.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattkim/sdk-core path: /tests/integ_tests/simple_wf_tests.rs
lete_workflow_task(schedule_activity_and_timer_cmds(
task_q,
&activity_id,
&timer_id,
ActivityCancellationType::Abandon,
task,
Duration::from_secs(60),
Duration::from_millis(50),
... | code_fim | hard | {
"lang": "rust",
"repo": "mattkim/sdk-core",
"path": "/tests/integ_tests/simple_wf_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::test]
async fn activity_cancellation_try_cancel() {
let mut rng = rand::thread_rng();
let task_q_salt: u32 = rng.gen();
let task_q = &format!("activity_cancelled_workflow_{}", task_q_salt.to_string());
let core = get_integ_core(task_q).await;
let workflow_id: u32 = rng.gen();
... | code_fim | hard | {
"lang": "rust",
"repo": "mattkim/sdk-core",
"path": "/tests/integ_tests/simple_wf_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattkim/sdk-core path: /tests/integ_tests/simple_wf_tests.rs
ion { result: None }.into()],
task.task_token,
))
.await
.unwrap();
}
#[tokio::test]
async fn activity_cancellation_abandon() {
let mut rng = rand::thread_rng();
let task_q_salt: u32 = rng.gen();
let ta... | code_fim | hard | {
"lang": "rust",
"repo": "mattkim/sdk-core",
"path": "/tests/integ_tests/simple_wf_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> to_comp_m.send((s.clone(), d.clone())).is_err() {
logger.error("calling comp_m".to_string());
return;
}
if to_comp_p.send((s, d)).is_err() {
logger.error("calling comp_p".to_string());
return;
... | code_fim | hard | {
"lang": "rust",
"repo": "cyrille-blanchet-1974/rust_synch",
"path": "/src/join.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyrille-blanchet-1974/rust_synch path: /src/join.rs
use super::constant::*;
use super::explorer::*;
use super::fold::*;
use super::logger::*;
use super::progression::*;
use std::collections::VecDeque;
use std::sync::mpsc::{Receiver, Sender};
use std::sync::Arc;
use std::thread::{spawn, JoinHand... | code_fim | hard | {
"lang": "rust",
"repo": "cyrille-blanchet-1974/rust_synch",
"path": "/src/join.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uncle-T0ny/app path: /contract/dao/src/release.rs
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::serde::{Deserialize, Serialize};
<|fim_suffix|>impl ReleaseModel {
pub fn get_release_amount(
&mut self,
current_time: u64,
total_supply: u3... | code_fim | hard | {
"lang": "rust",
"repo": "uncle-T0ny/app",
"path": "/contract/dao/src/release.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ReleaseModel {
pub fn get_release_amount(
&mut self,
current_time: u64,
total_supply: u32,
init_distribution: u32,
already_released: u32,
) -> u32 {
match self {
Self::Voting => 0,
_ => unimplemented!()
}
}
}<... | code_fim | hard | {
"lang": "rust",
"repo": "uncle-T0ny/app",
"path": "/contract/dao/src/release.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/Rudra-PoC path: /poc/0085-cdr.rs
/*!
```rudra-poc
[target]
crate = "cdr"
version = "0.2.3"
<|fim_suffix|>fn main() {
panic!("This issue was reported without PoC");
}<|fim_middle|>[report]
issue_url = "https://github.com/hrektts/cdr-rs/issues/10"
issue_date = 2021-01-02
rustsec_url =... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/Rudra-PoC",
"path": "/poc/0085-cdr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn queue_text<R, F>(
&self,
_styling: &Styling,
brush: &mut GlyphBrush<R, F>)
where
R: Resources,
F: Factory<R>,
{
let section = Section {
text: &self.message_buf,
screen_position: (5.0, 5.0),
scale: Scale:... | code_fim | hard | {
"lang": "rust",
"repo": "burtonageo/gfx_tutorial",
"path": "/src/graphics/fps_counter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: burtonageo/gfx_tutorial path: /src/graphics/fps_counter.rs
use ::Styling;
use gfx::{Factory, Resources};
use gfx_glyph::{Scale, Section, GlyphBrush};
#[derive(Debug)]
pub struct FpsCounter {
show_fps: bool,
message_buf: String,
}
<|fim_suffix|> #[inline]
pub fn toggle_show_fps(&... | code_fim | hard | {
"lang": "rust",
"repo": "burtonageo/gfx_tutorial",
"path": "/src/graphics/fps_counter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod ball;
mod broad_phase_multi_sap;
mod collider;
mod collider_set;
mod contact;
mod contact_generator;
pub(crate) mod cuboid;
#[cfg(feature = "dim2")]
mod cuboid_feature2d;
#[cfg(feature = "dim3")]
mod cuboid_feature3d;
mod interaction_graph;
mod narrow_phase;
mod polygon;
#[cfg(feature = "dim3")]
mod p... | code_fim | hard | {
"lang": "rust",
"repo": "willcrichton/rapier",
"path": "/src/geometry/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: willcrichton/rapier path: /src/geometry/mod.rs
//! Structures related to geometry: colliders, shapes, etc.
pub use self::broad_phase_multi_sap::BroadPhase;
pub use self::capsule::Capsule;
pub use self::collider::{Collider, ColliderBuilder, ColliderShape};
pub use self::collider_set::{ColliderHa... | code_fim | hard | {
"lang": "rust",
"repo": "willcrichton/rapier",
"path": "/src/geometry/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likr/atcoder path: /abc149/src/bin/e.rs
use num::Complex;
use proconio::input;
use std::f64::consts::PI;
fn fft(a: &mut Vec<Complex<f64>>, n: usize, sign: f64) {
if n == 1 {
return;
}
let mut a0 = vec![Complex::new(0., 0.); n / 2];
let mut a1 = vec![Complex::new(0., 0.);... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc149/src/bin/e.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = 0;
for i in 0..l {
let b = l - 1 - i;
let k = x[b].re.round() as usize;
if k != 0 {
let k = if k > m { m } else { k };
// println!("{} {}", b, k);
s += k * b;
m -= k;
if m == 0 {
break;
... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc149/src/bin/e.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sakateka/atb path: /src/course2/week1/Programming-Assignment-1/stack_with_max/stack_with_max.rs
use std::io;
#[derive(Debug)]
struct Max {
data: i32,
count: u32,
}
#[derive(Debug)]
struct StackWithMax {
stack: Vec<i32>,
max: Vec<Max>,
}
impl StackWithMax {
fn new() -> Self... | code_fim | hard | {
"lang": "rust",
"repo": "sakateka/atb",
"path": "/src/course2/week1/Programming-Assignment-1/stack_with_max/stack_with_max.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn push(&mut self, val: i32) {
let max = match self.max.last_mut() {
Some(ref mut m) => {
let mut new_max = None;
if m.data == val {
m.count += 1;
} else if m.data < val {
new_max = Some(Max{dat... | code_fim | medium | {
"lang": "rust",
"repo": "sakateka/atb",
"path": "/src/course2/week1/Programming-Assignment-1/stack_with_max/stack_with_max.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SaeedAnas/mal-cli path: /src/api/model/mod.rs
/// Anime related structs
pub mod anime;
pub use anime::*;
/// Manga related structs
pub mod manga;
pub use manga::*;
/// User related structs
pub mod user;
pub use user::*;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt... | code_fim | hard | {
"lang": "rust",
"repo": "SaeedAnas/mal-cli",
"path": "/src/api/model/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn deserialize_in_place<D>(
deserializer: D,
place: &mut Self,
) -> Result<(), <D as Deserializer<'de>>::Error>
where
D: Deserializer<'de>,
{
use serde::de::Error;
let s = String::deserialize(deserializer)?;
match Date::parse(&s, "%Y-%m-%d") ... | code_fim | hard | {
"lang": "rust",
"repo": "SaeedAnas/mal-cli",
"path": "/src/api/model/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'de> Deserialize<'de> for DateWrapper {
fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
where
D: Deserializer<'de>,
{
use serde::de::Error;
let s = String::deserialize(deserializer)?;
match Date::parse(&s, "%Y-%m-%d") {
... | code_fim | hard | {
"lang": "rust",
"repo": "SaeedAnas/mal-cli",
"path": "/src/api/model/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustyforks/ssh_jumper path: /crate/ssh_jumper_model/src/host_socket_params.rs
use std::fmt;
use crate::HostAddress;
/// Parameters to identify a host and port.
#[derive(Clone, Debug, PartialEq)]
pub struct HostSocketParams<'host> {
/// Name or IP address of the host.
pub address: HostA... | code_fim | medium | {
"lang": "rust",
"repo": "rustyforks/ssh_jumper",
"path": "/crate/ssh_jumper_model/src/host_socket_params.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{}:{}", self.address, self.port)
}
}
impl<'host> HostSocketParams<'host> {
/// Returns an owned version of self.
pub fn into_static(&self) -> HostSocketParams<'static> {
HostSocketParams {
address: self.address.into_static(),
port: self.port,... | code_fim | medium | {
"lang": "rust",
"repo": "rustyforks/ssh_jumper",
"path": "/crate/ssh_jumper_model/src/host_socket_params.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>or {
#[error("PacketType {0} is not supported")]
Unknown(u8),
#[error("Cannot parse Message from packet of type {0}, expected type {1}")]
Unexpected(u8, u8),
}<|fim_prefix|>// repo: Mirko-von-Leipzig/interledger-rs path: /crates/interledger-btp/src/errors.rs
use interledger_packet::OerErr... | code_fim | medium | {
"lang": "rust",
"repo": "Mirko-von-Leipzig/interledger-rs",
"path": "/crates/interledger-btp/src/errors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mirko-von-Leipzig/interledger-rs path: /crates/interledger-btp/src/errors.rs
use interledger_packet::OerError;
use std::str::Utf8Error;
#[derive(Debug, thiserror::Error)]
pub enum BtpPacketError {
#[error("extra trailing bytes")]
TrailingByte<|fim_suffix|>t: {0}")]
PacketType(#[from... | code_fim | medium | {
"lang": "rust",
"repo": "Mirko-von-Leipzig/interledger-rs",
"path": "/crates/interledger-btp/src/errors.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>t: {0}")]
PacketType(#[from] PacketTypeError),
#[error("Invalid Packet: {0}")]
Oer(#[from] OerError),
}
#[derive(Debug, thiserror::Error)]
pub enum PacketTypeError {
#[error("PacketType {0} is not supported")]
Unknown(u8),
#[error("Cannot parse Message from packet of type {0}, exp... | code_fim | medium | {
"lang": "rust",
"repo": "Mirko-von-Leipzig/interledger-rs",
"path": "/crates/interledger-btp/src/errors.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nuta/archives path: /resea-old-rust-kernel/kernel/arch/x64/thread.rs
use super::KERNEL_STACK_SIZE;
use super::asm;
use super::gdt::{USER_CS64, USER_DS, USER_RPL};
use super::PAGE_SIZE;
use crate::allocator::Ref;
use crate::process::Process;
use crate::ipc::Payload;
use crate::thread::Thread;
use... | code_fim | hard | {
"lang": "rust",
"repo": "nuta/archives",
"path": "/resea-old-rust-kernel/kernel/arch/x64/thread.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern "C" {
fn enter_userspace();
fn x64_switch(prev: &ArchThread, next: &ArchThread, save_current: i32);
fn x64_overwrite_context(thread: &ArchThread) -> i32;
fn x64_send(
header: u64,
m0: u64,
m1: u64,
m2: u64,
m3: u64,
m4: u64,
cu... | code_fim | hard | {
"lang": "rust",
"repo": "nuta/archives",
"path": "/resea-old-rust-kernel/kernel/arch/x64/thread.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TrionProg/server_admin path: /src/config.rs
use std::str::Chars;
use std::collections::BTreeMap;
use std::collections::btree_map::Entry::{Occupied, Vacant};
use std::str::FromStr;
use std::slice::Iter;
pub enum ParameterValue {
String{line:usize, value:String},
List(List),
Map(Map... | code_fim | hard | {
"lang": "rust",
"repo": "TrionProg/server_admin",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match cur.ch {
'\n'=>Ok( Lexeme::NewLine ),
'\0'=>Ok( Lexeme::EOF ),
':' | '=' =>Ok( Lexeme::Set ),
','=>Ok( Lexeme::Comma ),
'{' | '}' | '[' | ']' =>Ok( Lexeme::Bracket(cur.ch) ),
'"' | '\'' => {
let beginChar... | code_fim | hard | {
"lang": "rust",
"repo": "TrionProg/server_admin",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ch
}
};
self.ch
}
}
fn getLine( text:&String, lineBegin:usize ) -> String{
let mut line=String::with_capacity(80);
for ch in text.chars().skip(lineBegin).take_while(|c| *c!='\n' && *c!='\0') {
line.push( ch );
}
line
}
#[derive(Pa... | code_fim | hard | {
"lang": "rust",
"repo": "TrionProg/server_admin",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isabella232/BellmanBindings-iOS path: /cargo/src/helpers/types_helpers.rs
use std::slice;
use std::error::Error;
use std::os::raw::{c_char};
use std::ffi::{CString, CStr};
<|fim_suffix|>pub fn utf8_bytes_to_rust(bytes: *const u8, len: usize) -> &'static [u8] {
let bytes_slice = unsafe { sli... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/BellmanBindings-iOS",
"path": "/cargo/src/helpers/types_helpers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn utf8_bytes_to_rust(bytes: *const u8, len: usize) -> &'static [u8] {
let bytes_slice = unsafe { slice::from_raw_parts(bytes, len) };
bytes_slice
}<|fim_prefix|>// repo: isabella232/BellmanBindings-iOS path: /cargo/src/helpers/types_helpers.rs
use std::slice;
use std::error::Error;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/BellmanBindings-iOS",
"path": "/cargo/src/helpers/types_helpers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 4geru/rust-introduction path: /section4/function/src/main.rs
fn main() {
let mut x: i32 = 21;
print_number(x);
x = add_one(x);
println!("x is {}", x);
// without type inference
let g: fn(i32) -> i32 = plus_one;
// with type inference
// let f = plus_one;
le... | code_fim | medium | {
"lang": "rust",
"repo": "4geru/rust-introduction",
"path": "/section4/function/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_number(x: i32){
println!("x is: {}", x);
}
// NG
// fn print_sum(x , y){
// println!("sum is: {}", x + y);
// }
fn add_one(x: i32) -> i32 {
// return value don't have ;
x + 1
}
fn plus_one(x: i32) -> i32 {
x + 1
}<|fim_prefix|>// repo: 4geru/rust-introduction path: /section4/functio... | code_fim | hard | {
"lang": "rust",
"repo": "4geru/rust-introduction",
"path": "/section4/function/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Quang7hong81/miningpool-observer path: /shared/src/db_pool.rs
use diesel::pg::PgConnection;
use diesel::r2d2::{ConnectionManager, Pool, PoolError};
<|fim_suffix|>pub fn new(database_url: &str) -> Result<PgPool, PoolError> {
let manager = ConnectionManager::<PgConnection>::new(database_url);... | code_fim | easy | {
"lang": "rust",
"repo": "Quang7hong81/miningpool-observer",
"path": "/shared/src/db_pool.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn new(database_url: &str) -> Result<PgPool, PoolError> {
let manager = ConnectionManager::<PgConnection>::new(database_url);
Pool::builder().build(manager)
}<|fim_prefix|>// repo: Quang7hong81/miningpool-observer path: /shared/src/db_pool.rs
use diesel::pg::PgConnection;
use diesel::r2d2::{C... | code_fim | easy | {
"lang": "rust",
"repo": "Quang7hong81/miningpool-observer",
"path": "/shared/src/db_pool.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filmor/eir path: /interpreter/src/lib.rs
//! LIR interpreter with zero consideration of performance.
//! Made as an experiment to narrow down relevant implementation
//! details.
extern crate eir;
extern crate core_erlang_compiler;
use eir::Atom;
use eir::{ Module, FunctionIdent, SSAVariable, ... | code_fim | hard | {
"lang": "rust",
"repo": "filmor/eir",
"path": "/interpreter/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use eir::Atom;
use eir::{ Module, FunctionIdent, SSAVariable, Source };
use eir::cfg::{ BasicBlock, LabelN };
use eir::op::{ OpKind };
use eir::LambdaEnvIdx;
use eir::AtomicTerm;
extern crate lazy_static;
extern crate num_bigint;
extern crate num_traits;
extern crate serde;
extern crate serde_json;
ex... | code_fim | medium | {
"lang": "rust",
"repo": "filmor/eir",
"path": "/interpreter/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kiwiyou/workers-rs path: /worker-sys/src/response.rs
use crate::FormData;
use crate::ResponseInit;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends=::js_sys::Object, js_name=Response)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub type Response;
#[... | code_fim | hard | {
"lang": "rust",
"repo": "kiwiyou/workers-rs",
"path": "/worker-sys/src/response.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen(catch, method, structural, js_class=Response, js_name=arrayBuffer)]
#[doc = "The `arrayBuffer()` method."]
pub fn array_buffer(this: &Response) -> Result<::js_sys::Promise, JsValue>;
#[wasm_bindgen(catch, method, structural, js_class=Response, js_name=blob)]
#[doc = "Th... | code_fim | hard | {
"lang": "rust",
"repo": "kiwiyou/workers-rs",
"path": "/worker-sys/src/response.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.