text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: aristotle9/qt_generator-output path: /qt_3d_input/src/mouse_handler.rs
presents a built-in Qt signal `Qt3DInput::QMouseHandler::pressed`.
///
/// An object of this type can be created from `MouseHandler` with `object.signals().pressed()` and used for creating Qt connections using `qt_core::c... | code_fim | hard | {
"lang": "rust",
"repo": "aristotle9/qt_generator-output",
"path": "/qt_3d_input/src/mouse_handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: noda-sin/leetcode-1 path: /rust/src/solution/minimum_number_of_refueling_stops.rs
use std::collections::BinaryHeap;
pub struct Solution {}
impl Solution {
pub fn min_refuel_stops(target: i32, start_fuel: i32, stations: Vec<Vec<i32>>) -> i32 {
let mut location = 0;
let mut c... | code_fim | hard | {
"lang": "rust",
"repo": "noda-sin/leetcode-1",
"path": "/rust/src/solution/minimum_number_of_refueling_stops.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(3, Solution::min_refuel_stops(1000, 10, vec![vec![3,133],vec![5,418],vec![11,202],vec![12,381],vec![29,14],vec![43,423],vec![56,299],vec![60,353],vec![64,267],vec![66,224],vec![68,248],vec![76,106],vec![78,121],vec![81,410],vec![92,486],vec![105,311],vec![107,354],vec![111,461],vec![119... | code_fim | medium | {
"lang": "rust",
"repo": "noda-sin/leetcode-1",
"path": "/rust/src/solution/minimum_number_of_refueling_stops.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while location + car_fuel < target {
location += car_fuel;
while curr_station_index < stations.len() && stations[curr_station_index][0] <= location {
station_fuels.push(stations[curr_station_index][1]);
curr_station_index += 1;
}... | code_fim | medium | {
"lang": "rust",
"repo": "noda-sin/leetcode-1",
"path": "/rust/src/solution/minimum_number_of_refueling_stops.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/tokio/src/runtime/task/mod.rs
mod core;
use self::core::Cell;
pub(crate) use self::core::Header;
mod error;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::error::JoinError;
mod harness;
use self::... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/third_party/rust_crates/vendor/tokio/src/runtime/task/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(fmt, "Task({:p})", self.header())
}
}
impl<S> fmt::Debug for Notified<S> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "task::Notified({:p})", self.0.header())
}
}
/// # Safety
///
/// Tasks are pinned
unsafe impl<S> linked_list::Link for T... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/third_party/rust_crates/vendor/tokio/src/runtime/task/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn header(&self) -> &Header {
self.raw.header()
}
}
cfg_rt_threaded! {
impl<S: 'static> Notified<S> {
pub(crate) unsafe fn from_raw(ptr: NonNull<Header>) -> Notified<S> {
Notified(Task::from_raw(ptr))
}
pub(crate) fn header(&self) -> &He... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/third_party/rust_crates/vendor/tokio/src/runtime/task/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn bubble_sort<T:Ord>(arr: &mut [T]){
for i in 0..arr.len() {
//println!("iii{}",i);
for j in 0..arr.len() -1 -i {
//println!("jjj{}",j);
//panic!("p{:#?}",arr[j]);
if(arr[j] > arr[j + 1]){
arr.swap(j,j + 1);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "slionx/Rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slionx/Rust path: /src/main.rs
use std::fmt::Debug;
//冒泡排序(Bubble Sort)
fn main() {
println!("Sort numbers ascending");
let mut numbers = vec![4, 65, 2, -31, 0, 99, 2, 83, 782, 1];
println!("Before: {:?}", numbers);
bubble_sort(&mut numbers);
println!("After: {:?}\n", numbe... | code_fim | hard | {
"lang": "rust",
"repo": "slionx/Rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn bubble_sort<T:Ord>(arr: &mut [T]){
for i in 0..arr.len() {
//println!("iii{}",i);
for j in 0..arr.len() -1 -i {
//println!("jjj{}",j);
//panic!("p{:#?}",arr[j]);
if(arr[j] > arr[j + 1]){
arr.swap(j,j + 1);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "slionx/Rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tinou98/json path: /src/de/stream/mod.rs
use crate::de::{Deserializer, Read, Result};
use serde::Deserialize;
mod parse_type;
use parse_type::{Array, Map, ParseType, Root};
/// Iterator that deserializes a stream into multiple JSON values.
///
/// A stream deserializer can be created from any ... | code_fim | hard | {
"lang": "rust",
"repo": "tinou98/json",
"path": "/src/de/stream/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Leave the current array
pub fn end_map(mut self) -> Result<Stream<'de, R, P>> {
tri!(self.deserializer.end_map());
Ok(self.unwrap())
}
/// Create a single typed iterator
pub fn iter<'a, T: Deserialize<'de>>(&'a mut self) -> StreamIterator<'de, 'a, R, Map<P>, T> {
... | code_fim | hard | {
"lang": "rust",
"repo": "tinou98/json",
"path": "/src/de/stream/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create a single typed iterator
pub fn iter<'a, T: Deserialize<'de>>(&'a mut self) -> StreamIterator<'de, 'a, R, Array<P>, T> {
StreamIterator {
stream: self,
element_type: std::marker::PhantomData::default(),
}
}
}
impl<'de, R: Read<'de>, P> Stream<... | code_fim | hard | {
"lang": "rust",
"repo": "tinou98/json",
"path": "/src/de/stream/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let one_minus_src_a = C::MAX - src.alpha().value();
let a = src.alpha().value() + dst.alpha().value() * one_minus_src_a;
Self::new(a)
}
}<|fim_prefix|>// repo: DougLau/pixops path: /src/mask.rs
// mask.rs Pixel operations for alpha mask pixel format.
//
// Copyright (c) ... | code_fim | medium | {
"lang": "rust",
"repo": "DougLau/pixops",
"path": "/src/mask.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DougLau/pixops path: /src/mask.rs
// mask.rs Pixel operations for alpha mask pixel format.
//
// Copyright (c) 2019 Douglas P Lau
// Copyright (c) 2020 Jeron Aldaron Lau
//
use crate::Blend;
use pix::{Alpha, Channel, Format, Mask};
<|fim_suffix|> let one_minus_src_a = C::MAX - src... | code_fim | hard | {
"lang": "rust",
"repo": "DougLau/pixops",
"path": "/src/mask.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: QCALabs/qca-edge path: /qca-common/src/tag_data/unit_data.rs
use crate::tag_data::device_data::DeviceConfig;
use crate::{IJsonSerializable, IYamlSerializable};
use serde::{Deserialize, Serialize};
<|fim_suffix|>impl IJsonSerializable for UnitConfig {}
impl IYamlSerializable for UnitConfig {}<|f... | code_fim | medium | {
"lang": "rust",
"repo": "QCALabs/qca-edge",
"path": "/qca-common/src/tag_data/unit_data.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl IJsonSerializable for UnitConfig {}
impl IYamlSerializable for UnitConfig {}<|fim_prefix|>// repo: QCALabs/qca-edge path: /qca-common/src/tag_data/unit_data.rs
use crate::tag_data::device_data::DeviceConfig;
use crate::{IJsonSerializable, IYamlSerializable};
use serde::{Deserialize, Serialize};
<|f... | code_fim | medium | {
"lang": "rust",
"repo": "QCALabs/qca-edge",
"path": "/qca-common/src/tag_data/unit_data.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ebarnard/carproject path: /rust_controller/ui/src/plot.rs
use std::cell::Cell;
use std::collections::VecDeque;
use std::f64::{INFINITY, NEG_INFINITY};
use std::fmt::Write;
use colors::BLACK;
use {max, min, Canvas, Color, TextXAlign, TextYAlign};
#[derive(Clone, Copy)]
pub enum AxesRange {
... | code_fim | hard | {
"lang": "rust",
"repo": "ebarnard/carproject",
"path": "/rust_controller/ui/src/plot.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let range_per_tick = if diff_1_x_tick < diff_2_x_tick && diff_1_x_tick < diff_5_x_tick {
range_per_power_10
} else if diff_2_x_tick < diff_5_x_tick {
2.0 * range_per_power_10
} else {
5.0 * range_per_power_10
};
let first_tick = ... | code_fim | hard | {
"lang": "rust",
"repo": "ebarnard/carproject",
"path": "/rust_controller/ui/src/plot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: noirotm/advent-of-code-2019 path: /src/solutions/day11.rs
use crate::intcode::AsyncIO;
use crate::{
intcode::{parse_program, IntCodeComputer},
solver::Solver,
};
use std::{
collections::HashMap,
error::Error,
io::Read,
iter::repeat,
sync::mpsc::{Receiver, Sender},
... | code_fim | hard | {
"lang": "rust",
"repo": "noirotm/advent-of-code-2019",
"path": "/src/solutions/day11.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = self.handle.join();
}
fn paint(&mut self, panel: &mut Panel) -> Result<(), Box<dyn Error>> {
// color at current position in panel
let current_color = panel.color(&self.position);
// send error means program has exited, abort then
self.tx.send(curr... | code_fim | hard | {
"lang": "rust",
"repo": "noirotm/advent-of-code-2019",
"path": "/src/solutions/day11.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LucasPickering/osrs-cli path: /src/commands/mod.rs
mod calc;
mod config;
mod hiscore;
mod ping;
mod price;
mod wiki;
pub use self::config::*;
pub use calc::*;
pub use hiscore::*;
pub use ping::*;
pub use price::*;
pub use wiki::*;
use crate::utils::context::CommandContext;
use async_trait::asy... | code_fim | medium | {
"lang": "rust",
"repo": "LucasPickering/osrs-cli",
"path": "/src/commands/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// One subcommand for the CLI. Each command should also implement `StructOpt`,
/// so that it can collect its own CLI args.
// wasm bindgen futures don't impl Send/Sync, so we have to disable that bound.
// That's fine since our program is single threaded anyway.
#[async_trait(?Send)]
pub trait Command<O... | code_fim | medium | {
"lang": "rust",
"repo": "LucasPickering/osrs-cli",
"path": "/src/commands/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomaspeitz/linkerd2-proxy path: /lib/stack/src/either.rs
use futures::future::Either as EitherFuture;
use futures::Poll;
use svc;
/// Describes two alternate `Layer`s, `Stacks`s or `Service`s.
#[derive(Clone, Debug)]
pub enum Either<A, B> {
A(A),
B(B),
}
impl<T, U, A, B, N> super::La... | code_fim | hard | {
"lang": "rust",
"repo": "thomaspeitz/linkerd2-proxy",
"path": "/lib/stack/src/either.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn make(&self, target: &T) -> Result<Self::Value, Self::Error> {
match self {
Either::A(ref a) => a.make(target).map(Either::A),
Either::B(ref b) => b.make(target).map(Either::B),
}
}
}
impl<A, B> svc::Service for Either<A, B>
where
A: svc::Service,
... | code_fim | hard | {
"lang": "rust",
"repo": "thomaspeitz/linkerd2-proxy",
"path": "/lib/stack/src/either.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn call(&mut self, req: Self::Request) -> Self::Future {
match self {
Either::A(ref mut a) => EitherFuture::A(a.call(req)),
Either::B(ref mut b) => EitherFuture::B(b.call(req)),
}
}
}<|fim_prefix|>// repo: thomaspeitz/linkerd2-proxy path: /lib/stack/src/eit... | code_fim | medium | {
"lang": "rust",
"repo": "thomaspeitz/linkerd2-proxy",
"path": "/lib/stack/src/either.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::convert::TryInto;
let a: PortAddress = 0x1234.try_into().unwrap();
assert!(a.to_be_bytes() == [0x12, 0x34]);
assert!(a.to_le_bytes() == [0x34, 0x12]);
}
#[test]
fn port_address_bound_check() {
use std::convert::TryInto;
assert!(
... | code_fim | hard | {
"lang": "rust",
"repo": "Firionus/artnet_packer",
"path": "/src/types/port_address.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Firionus/artnet_packer path: /src/types/port_address.rs
use std::convert::TryFrom;
/// A `PortAddress` is an unsigned integer from 0 to 32_767 (15-bit).
///
/// The trait `From` is implemented for `u8`and `TryFrom` for `u16` and `i32`:
///
/// ```
/// use artnet_packer::PortAddress;
/// use std... | code_fim | hard | {
"lang": "rust",
"repo": "Firionus/artnet_packer",
"path": "/src/types/port_address.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::convert::TryInto;
assert!(
PortAddress::try_from(32_768u16).is_err(),
"u16 values over 32_767 should not convert to PortAddress succesfully"
);
assert!(
PortAddress::try_from(32_768).is_err(),
"i32 values over 32_767 ... | code_fim | hard | {
"lang": "rust",
"repo": "Firionus/artnet_packer",
"path": "/src/types/port_address.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tianyaochou/search-engine-rs path: /src/bin/index.rs
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::vec::Vec;
use walkdir::WalkDir;
use crossbeam;
use rayon::iter::ParallelBridge;
use rayon::prelude::*;
use mailparse::*;
// use rus... | code_fim | hard | {
"lang": "rust",
"repo": "tianyaochou/search-engine-rs",
"path": "/src/bin/index.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> db.insert(
bincode_config.serialize("tokens").unwrap().as_slice(),
bincode_config.serialize(&all_token_ids).unwrap().as_slice(),
).unwrap();
for (token_id, set) in &index {
tf_df_tree1
.insert(
bincode_config.... | code_fim | hard | {
"lang": "rust",
"repo": "tianyaochou/search-engine-rs",
"path": "/src/bin/index.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // count token frequencies
let (count_tx, count_rx) = crossbeam::channel::bounded(1024);
let tf_df_tree = db.open_tree("tf_df").unwrap();
let tf_df_tree1 = tf_df_tree.clone();
std::thread::spawn(move || {
for (file_id, mut token_ids) in token_rx {
let mut token_freq... | code_fim | hard | {
"lang": "rust",
"repo": "tianyaochou/search-engine-rs",
"path": "/src/bin/index.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 调用处理闭包的函数(原文:Call the function which applies the closure)。
apply(diary);
// `double` 满足 `apply_to_3` 的 trait 限定。
let double = |x| 2 * x;
println!("3 doubled: {}", apply_to_3(double));
}<|fim_prefix|>// repo: suyanlongfamily/rust_study path: /Study/closure_fnMut_fnOnce_fn.rs
// 将闭... | code_fim | hard | {
"lang": "rust",
"repo": "suyanlongfamily/rust_study",
"path": "/Study/closure_fnMut_fnOnce_fn.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suyanlongfamily/rust_study path: /Study/closure_fnMut_fnOnce_fn.rs
// 将闭包作为参数并调用它的函数。作为输入参量
//Fn、 FnOnce、FnMut 是一个trait,区别关键字与fn,妈的!!!!
//关于变量绑定的权限,T > &mut T > &T 三个权限依次递减。
fn apply<F>(f: F)
where F: FnOnce()
{
// ^ 试一试:将 `FnOnce` 换成 `Fn` 或 `FnMut`。
f();
}
// 使用闭包并返回一个 `i32` 整型的函数... | code_fim | hard | {
"lang": "rust",
"repo": "suyanlongfamily/rust_study",
"path": "/Study/closure_fnMut_fnOnce_fn.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.pin_get_inner()
.poll_flush(cx)
.map_err(StreamDeckSocketError::WebSocketError)
}
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
self.pin_get_inner()
.poll_close(cx)
.map_err(StreamDeckS... | code_fim | hard | {
"lang": "rust",
"repo": "mdonoughe/streamdeck-rs",
"path": "/src/socket.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Address { url: value }
}
}
impl From<u16> for Address {
fn from(value: u16) -> Self {
let mut url = Url::parse("ws://localhost").unwrap();
url.set_port(Some(value)).unwrap();
Address { url }
}
}
/// Represents an error that occurred while connecting to and reg... | code_fim | hard | {
"lang": "rust",
"repo": "mdonoughe/streamdeck-rs",
"path": "/src/socket.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mdonoughe/streamdeck-rs path: /src/socket.rs
use super::{Message, MessageOut};
use failure::Fail;
use futures::prelude::*;
use serde::{de, ser};
use serde_derive::Serialize;
use std::marker::PhantomData;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::net::TcpStream;
use tokio_tung... | code_fim | hard | {
"lang": "rust",
"repo": "mdonoughe/streamdeck-rs",
"path": "/src/socket.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn on_open<'a>(&mut self, event: &OpenEvent<'a>);
fn on_match<'a>(&mut self, event: &MatchEvent<'a>);
fn on_change<'a>(&mut self, event: &ChangeEvent<'a>);
fn on_done<'a>(&mut self, event: &DoneEvent<'a>);
}
pub struct Book {
bid: OrdersByPrice,
ask: OrdersByPrice,
orders: Has... | code_fim | hard | {
"lang": "rust",
"repo": "tmandry/cryptoview",
"path": "/src/book.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tmandry/cryptoview path: /src/book.rs
#![allow(dead_code)] // TODO: remove
/// Implementation of a level 3 book.
use std::collections::{BTreeMap, HashMap, VecDeque};
use std::cell::RefCell;
use std::rc::Rc;
use price::Price;
#[derive(Copy, Clone, Debug)]
pub enum Side {
Bid,
Ask,
}
p... | code_fim | hard | {
"lang": "rust",
"repo": "tmandry/cryptoview",
"path": "/src/book.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn market_match() {
let mut book = Book::new();
book.on_add(&new_event(&"order1", Side::Bid, Limit(px(10.00)), px(100.)));
book.on_open(&open_event(&"order1", px(100.)));
book.on_add(&new_event(&"order2", Side::Ask, Market, px(40.)));
book.on_match(&... | code_fim | hard | {
"lang": "rust",
"repo": "tmandry/cryptoview",
"path": "/src/book.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn compound_types() {
// Rust has 2 primitive compound types: tuples and arrays
// tuples
let tup: (i32, f64, u8) = (500, 6.4, 1);
print!("The value of tup is {:?}\n", tup);
let (x, y, z) = tup;
print!("The value of z is {}\n", z);
let five_hundred = tup.0;
let s... | code_fim | hard | {
"lang": "rust",
"repo": "joaoh82/the_rust_programming_language_book",
"path": "/chapter_3/variables/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joaoh82/the_rust_programming_language_book path: /chapter_3/variables/src/main.rs
// Rust is staticaly typed language, which means that it must know the type of all variables at
// compile time, even if it is inferred.
const MAX_POINTS: u32 = 100_000;
fn main() {
// variables();
compo... | code_fim | hard | {
"lang": "rust",
"repo": "joaoh82/the_rust_programming_language_book",
"path": "/chapter_3/variables/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tmp_dir = config.tmp_dir.as_ref().unwrap();
let management_kp = Keypair::generate_ed25519();
let m_public_key = management_kp.public();
let m_id = PeerId::from(m_public_key);
let root_weights: &[_] = trust.as_ref().map_or(&[], |t| &t.root_weights);
let mut trust_graph = {
... | code_fim | hard | {
"lang": "rust",
"repo": "cyberbono3/fluence",
"path": "/crates/created-swarm/src/swarm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if config.tmp_dir.is_none() {
config.tmp_dir = Some(make_tmp_dir_peer_id(peer_id.to_string()));
}
let tmp_dir = config.tmp_dir.as_ref().unwrap();
let management_kp = Keypair::generate_ed25519();
let m_public_key = management_kp.public();
let m_id = PeerId::from(m_public_ke... | code_fim | hard | {
"lang": "rust",
"repo": "cyberbono3/fluence",
"path": "/crates/created-swarm/src/swarm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyberbono3/fluence path: /crates/created-swarm/src/swarm.rs
/*
* Copyright 2021 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
*
* htt... | code_fim | hard | {
"lang": "rust",
"repo": "cyberbono3/fluence",
"path": "/crates/created-swarm/src/swarm.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Synom for InterfaceDecl {
named!(parse -> Self, do_parse!(
name: syn!(Ident) >>
block: syn!(Block) >>
(InterfaceDecl { name, block })
));
}<|fim_prefix|>// repo: akiselev/vtable-rs path: /derive/src/interface.rs
#![feature(proc_macro)]
// macros
use syn::{named, syn, ... | code_fim | medium | {
"lang": "rust",
"repo": "akiselev/vtable-rs",
"path": "/derive/src/interface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akiselev/vtable-rs path: /derive/src/interface.rs
#![feature(proc_macro)]
// macros
use syn::{named, syn, keyword, punct, do_parse, Token, call};
// Parser combinators
use syn::{Visibility, Ident, Generics, GenericParam, Type, Field, Block};
use syn::punctuated::Punctuated;
use syn::token::{Semi... | code_fim | medium | {
"lang": "rust",
"repo": "akiselev/vtable-rs",
"path": "/derive/src/interface.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: greathugegithub/Team1 path: /projects/lesson2/src/class2.rs
//链上存储加密猫数据
//遍历猫
//DNA 128bit
//每个用户可以拥有零到多只猫
//猫只有一个主人
//遍历用户拥有的所有猫
数据结构
struct Kitty {
unit32 ID
string name
uint128 DNA;
uint64 birthTime; // 出生时间
uint32 moytherId; // 母亲的ID
ui... | code_fim | hard | {
"lang": "rust",
"repo": "greathugegithub/Team1",
"path": "/projects/lesson2/src/class2.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
链上函数
Search Catbyowner(Owner ID) return List
Sold cat (price, target)
Search catinfo(cat ID)
gotDNA(cat iD)
CreateKitty(
uint32 _motherID,
uint32 _fatherId,
address _owner
uint32 _generation,
uint128 _DNA,
uni... | code_fim | hard | {
"lang": "rust",
"repo": "greathugegithub/Team1",
"path": "/projects/lesson2/src/class2.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>DNA 128bit
32个特征
每个特征四个字符,第一位为显性基因,决定样式。前端按照样式表去画出该猫特征
ABCD
4*3*2*1=24种排列
初代猫的DNA
系统按照时间生成的随机数除以24得到的余数决定ABCD
运行32次,生成所有特征
繁殖猫的DNA
概率
ABCD 50 25 15 10
BACD 50 25 15 10
繁殖后代的DNA 按照概率排序,
A概率 75
B概率 75
C概率 30
D概率 20
AB概率相同时,系统生成两次随机数... | code_fim | hard | {
"lang": "rust",
"repo": "greathugegithub/Team1",
"path": "/projects/lesson2/src/class2.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Parse the contents of a PEM file and return a DER-serialized byte slice.
/// This won't work if `pem_file_contents` contains more than a single key / certificate.
pub fn pem_to_der(pem_file_contents: &str) -> Result<Vec<u8>, DecodeError> {
let re = Regex::new(REGEX).unwrap();
let contents_without_... | code_fim | medium | {
"lang": "rust",
"repo": "melynx/rust-sgx-remote-attestation",
"path": "/sgx-crypto/src/pem_parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: melynx/rust-sgx-remote-attestation path: /sgx-crypto/src/pem_parser.rs
// modified from https://docs.rs/pem-parser/0.1.1/src/pem_parser/lib.rs.html#1-18
use regex::Regex;
use base64::{decode, DecodeError};
<|fim_suffix|>/// Parse the contents of a PEM file and return a DER-serialized byte slice... | code_fim | medium | {
"lang": "rust",
"repo": "melynx/rust-sgx-remote-attestation",
"path": "/sgx-crypto/src/pem_parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reetis/Advent_of_Code_2018 path: /src/day3/second_part/mod.rs
use super::*;
pub fn find_non_overlapped_claim(claims: &Vec<Claim>) -> &Claim {
claims.iter()
.find(|claim| {
claims
.iter()
.filter(|it| { it.rectangle().intersection(claim.rec... | code_fim | medium | {
"lang": "rust",
"repo": "reetis/Advent_of_Code_2018",
"path": "/src/day3/second_part/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = vec![
Claim::new(1, 3, 1, 4, 4),
Claim::new(2, 1, 3, 4, 4),
Claim::new(3, 5, 5, 2, 2),
];
let result = find_non_overlapped_claim(&input);
assert_eq!(result.id(), &3);
}
}<|fim_prefix|>// repo: reetis/Advent_of_Code_2018 p... | code_fim | medium | {
"lang": "rust",
"repo": "reetis/Advent_of_Code_2018",
"path": "/src/day3/second_part/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use credential::{AwsCredentials, ChainProvider, ContainerProvider, CredentialsError,
EnvironmentProvider, InstanceMetadataProvider, ProfileProvider,
ProvideAwsCredentials, DefaultCredentialsProvider,
DefaultCredentialsProviderSync, claims,... | code_fim | hard | {
"lang": "rust",
"repo": "asyade/rusoto-seedup",
"path": "/rusoto/core/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asyade/rusoto-seedup path: /rusoto/core/src/lib.rs
#![cfg_attr(feature = "unstable", feature(proc_macro))]
#![cfg_attr(feature = "nightly-testing", feature(plugin))]
#![cfg_attr(feature = "nightly-testing", plugin(clippy))]
#![cfg_attr(feature = "nightly-testing", allow(cyclomatic_complexity, us... | code_fim | hard | {
"lang": "rust",
"repo": "asyade/rusoto-seedup",
"path": "/rusoto/core/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frozolotl/noak path: /bench/benches/mutf8.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use noak::mutf8::MStr;
pub fn validation(c: &mut Criterion) {
let mut group = c.benchmark_group("validation");
group.bench_function("ascii", |b| {
let data = blac... | code_fim | medium | {
"lang": "rust",
"repo": "frozolotl/noak",
"path": "/bench/benches/mutf8.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>| assert!(MStr::from_bytes(data).is_ok()));
});
group.bench_function("utf8", |b| {
let data = black_box(include_bytes!("../data/mutf8/validation_utf8"));
b.iter(|| assert!(MStr::from_bytes(data).is_ok()));
});
group.finish();
}
criterion_group!(benches, validation);
criter... | code_fim | medium | {
"lang": "rust",
"repo": "frozolotl/noak",
"path": "/bench/benches/mutf8.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let intersections = wire1.keys().filter(|p| wire2.contains_key(p));
let dist_to_closest = intersections
.map(|&(x, y)| x.abs() + y.abs())
.min()
.expect("No intersections.");
dist_to_closest
}
fn part2(wire1: &Wire, wire2: &Wire) -> u32 {
let intersections = wire... | code_fim | hard | {
"lang": "rust",
"repo": "khollbach/advent",
"path": "/2019/rust/3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Start at the origin.
let mut x = 0;
let mut y = 0;
let mut total_dist = 0;
let line = read_line().expect("Failed to read from stdin");
for section in line.split(',') {
let dir = section.chars().next().expect("Empty wire section");
let dist: u32 = section[1..].pa... | code_fim | hard | {
"lang": "rust",
"repo": "khollbach/advent",
"path": "/2019/rust/3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: khollbach/advent path: /2019/rust/3/src/main.rs
// 20 minutes thinking of a solution that uses a representation of intervals and gets the space
// complexity down to O(N) where N is the sum of the wire-section lengths, instead of O(n) where n
// is the number of wire sections. The time complexit... | code_fim | hard | {
"lang": "rust",
"repo": "khollbach/advent",
"path": "/2019/rust/3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sezna/Inflector path: /src/suffix/foreignkey/mod.rs
use cases::snakecase::to_snake_case;
/// Converts a `&str` to a `foreign_key`
///
/// ```
/// use inflector::suffix::foreignkey::to_foreign_key;
/// let mock_string: &str = "foo_bar";
/// let expected_string: String = "foo_bar_id".... | code_fim | hard | {
"lang": "rust",
"repo": "sezna/Inflector",
"path": "/src/suffix/foreignkey/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Determines if a `&str` is a `foreign_key`
///
/// ```
/// use inflector::suffix::foreignkey::is_foreign_key;
/// let mock_string: &str = "Foo bar string that is really really long";
/// let asserted_bool: bool = is_foreign_key(mock_string);
/// assert!(asserted_bool == false);
///
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "sezna/Inflector",
"path": "/src/suffix/foreignkey/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // it's possible we fell behind
if next > now {
// if we didn't, sample at the next planned time
self.next = next;
} else {
// if we did, sample after the interval has elapsed
self.next = now + self.interval;
}
// mar... | code_fim | hard | {
"lang": "rust",
"repo": "brayniac/rezolus",
"path": "/src/samplers/cpu/perf/proc_cpuinfo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brayniac/rezolus path: /src/samplers/cpu/perf/proc_cpuinfo.rs
use super::*;
use std::fs::File;
use std::io::{Read, Seek};
pub struct ProcCpuinfo {
prev: Instant,
next: Instant,
interval: Duration,
file: File,
}
impl ProcCpuinfo {
pub fn new(_config: &Config) -> Result<Self,... | code_fim | hard | {
"lang": "rust",
"repo": "brayniac/rezolus",
"path": "/src/samplers/cpu/perf/proc_cpuinfo.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let (Some(&"cpu"), Some(&"MHz")) = (parts.first(), parts.get(1)) {
if let Some(Ok(freq)) = parts
.get(3)
.map(|v| v.parse::<f64>().map(|v| v.floor() as u64))
{
let _ = CPU_FREQUENCY_HEATMAP.increment... | code_fim | hard | {
"lang": "rust",
"repo": "brayniac/rezolus",
"path": "/src/samplers/cpu/perf/proc_cpuinfo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_wrapper(wrapper: &Wrapper) -> crate::Result<Self> {
Self::from(wrapper.tag, &wrapper.blob)
}
pub fn as_wrapper(&self) -> crate::Result<Wrapper> {
Ok(match self {
Message::StartBundle(b) => Wrapper::new(TAG_START_BUNDLE, serde_cbor::to_vec(b)?),
... | code_fim | hard | {
"lang": "rust",
"repo": "Pear0/rustos",
"path": "/lib/pigrate-core/src/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pear0/rustos path: /lib/pigrate-core/src/message.rs
use alloc::vec::Vec;
use crate::bundle::ProcessBundle;
use crate::Error;
use serde::Deserialize;
#[derive(Default, Clone, Serialize, Deserialize)]
pub struct Wrapper {
pub tag: i32,
pub blob: Vec<u8>,
}
impl Wrapper {
pub fn new(... | code_fim | medium | {
"lang": "rust",
"repo": "Pear0/rustos",
"path": "/lib/pigrate-core/src/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sql.execute(r#"
INSERT INTO example (key, val) VALUES
('0', 'Zero'),
('1', 'One'),
('2', 'Two'),
('3', 'Three'),
('4', 'Four'),
('5', 'Five'),
('6', 'Six'),
('7', 'Seven'),
('8', 'Eight'),
('9', 'Nine'),
('... | code_fim | medium | {
"lang": "rust",
"repo": "Dygear/rust-sqlite-examples",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pkvalue: i64 = 1337;
let row: Result<String, rusqlite::Error> = sql.query_row("SELECT val FROM example WHERE pk = :pkvalue;", &[(":pkvalue", &pkvalue)], |row| row.get(0),);
println!("Value of row: {:?}", row);
}<|fim_prefix|>// repo: Dygear/rust-sqlite-examples path: /src/main.rs
use rus... | code_fim | hard | {
"lang": "rust",
"repo": "Dygear/rust-sqlite-examples",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dygear/rust-sqlite-examples path: /src/main.rs
use rusqlite::{Result, Connection};
fn main()
{
let sql = match Connection::open("SQLite.db")
{
Ok(sql) =>
{
println!("SQLite.db Opened");
sql
},
Err(e) =>
{
printl... | code_fim | hard | {
"lang": "rust",
"repo": "Dygear/rust-sqlite-examples",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeaye/ncurses-rs path: /examples/ex_7.rs
/*
Copyright © 2013 Free Software Foundation, Inc
See licensing in LICENSE file
File: examples/ex_7.rs
Author: Jesse 'Jeaye' Wilkerson
Description:
Basic input and attribute example, using the Unicode-aware get_wch functions.
*/... | code_fim | hard | {
"lang": "rust",
"repo": "jeaye/ncurses-rs",
"path": "/examples/ex_7.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* Refresh, showing the previous message. */
refresh();
/* Wait for one more character before exiting. Disable the input timeout. */
nocbreak();
getch();
endwin();
}
#[cfg(not(feature = "wide"))]
fn main() {
initscr();
addstr("This example requires wide character support.");
getch();
... | code_fim | hard | {
"lang": "rust",
"repo": "jeaye/ncurses-rs",
"path": "/examples/ex_7.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check what subcommand was used
if let Some(command) = matches.subcommand_name() {
// Load the project.json file from the cwd
let project = Project::new();
let program = Program::new(project.entry);
match command {
"build" => {
let buil... | code_fim | hard | {
"lang": "rust",
"repo": "magnetardev/plume",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magnetardev/plume path: /src/main.rs
mod ast;
mod compiler;
mod lexer;
mod parser;
mod project;
use clap::{App, Arg, SubCommand};
use parser::{Program, SourceFile};
use project::Project;
const NAME: &'static str = env!("CARGO_BIN_NAME");
const AUTHOR: &'static str = env!("CARGO_PKG_AUTHORS");
c... | code_fim | hard | {
"lang": "rust",
"repo": "magnetardev/plume",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quininer/colorhash256 path: /src/colorhash256.rs
//! Like Chroma-Hash, but with ANSI terminal colors.
extern crate sodiumoxide;
use sodiumoxide::crypto::hash::sha256;
/// Hashes given bytes and encodes the result as ANSI terminal colors.
pub fn hash_as_ansi(bytes: &[u8]) -> [u16; 8] {
let s... | code_fim | hard | {
"lang": "rust",
"repo": "quininer/colorhash256",
"path": "/src/colorhash256.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_rgb() {
assert_eq!(hash_as_rgb(b"Correct Horse Battery Staple"), [(204, 255, 51), (0, 153, 51), (204, 102, 153), (204, 153, 0), (153, 204, 0), (51, 153, 0), (51, 255, 0), (0, 153, 153)]);
}
}<|fim_prefix|>// repo: quininer/colorhash256 path: /src/colorhash256.rs
//! Li... | code_fim | medium | {
"lang": "rust",
"repo": "quininer/colorhash256",
"path": "/src/colorhash256.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scrtlabs/rs-poker path: /src/core/card.rs
use serde::{Deserialize, Serialize};
use std::cmp;
use std::fmt;
use std::mem;
/// Card rank or value.
/// This is basically the face value - 2
#[derive(PartialEq, PartialOrd, Eq, Ord, Debug, Clone, Copy, Hash, Serialize, Deserialize)]
#[repr(u8)]
pub e... | code_fim | hard | {
"lang": "rust",
"repo": "scrtlabs/rs-poker",
"path": "/src/core/card.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c1 = Card {
value: Value::Three,
suit: Suit::Spade,
};
let c2 = Card {
value: Value::Four,
suit: Suit::Spade,
};
let c3 = Card {
value: Value::Four,
suit: Suit::Club,
};
// ... | code_fim | hard | {
"lang": "rust",
"repo": "scrtlabs/rs-poker",
"path": "/src/core/card.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Converts `Time` to a `SystemTime`.
impl From<Time> for SystemTime {
fn from(time: Time) -> SystemTime {
if time.seconds >= 0 {
UNIX_EPOCH + Duration::new(time.seconds as u64, time.nanos as u32)
} else {
UNIX_EPOCH - Duration::new(time.seconds as u64, time.na... | code_fim | medium | {
"lang": "rust",
"repo": "mrpound/kms",
"path": "/src/types/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrpound/kms path: /src/types/mod.rs
extern crate prost;
mod heartbeat;
mod proposal;
mod vote;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
<|fim_suffix|>/// Converts `Time` to a `SystemTime`.
impl From<Time> for SystemTime {
fn from(time: Time) -> SystemTime {
if time.secon... | code_fim | hard | {
"lang": "rust",
"repo": "mrpound/kms",
"path": "/src/types/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, PartialEq, Message)]
pub struct Time {
#[prost(sfixed64, tag = "1")]
pub seconds: i64,
#[prost(sfixed32, tag = "2")]
pub nanos: i32,
}
/// Converts `Time` to a `SystemTime`.
impl From<Time> for SystemTime {
fn from(time: Time) -> SystemTime {
if time.seconds >=... | code_fim | hard | {
"lang": "rust",
"repo": "mrpound/kms",
"path": "/src/types/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let css = jss_ns!("frame",{
".": {
"display": "block",
},
".layer": {
"background-color": "red",
"border": "1px solid green",
},
"@media screen and (max-width: 800px)": {
".l... | code_fim | hard | {
"lang": "rust",
"repo": "ArunGust/sauron",
"path": "/crates/sauron-core/src/jss.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArunGust/sauron path: /crates/sauron-core/src/jss.rs
//! json css
//!
//!
use crate::html::attributes;
fn make_indent(n: usize) -> String {
" ".repeat(n)
}
fn process_css_map(
indent: usize,
namespace: Option<&str>,
css_map: &serde_json::Map<String, serde_json::Value>,
) -> S... | code_fim | hard | {
"lang": "rust",
"repo": "ArunGust/sauron",
"path": "/crates/sauron-core/src/jss.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ".layer": {
"background-color": "red",
"border": "1px solid green",
},
"@media screen and (max-width: 800px)": {
".layer": {
"width": "100%",
}
},
".hide .layer": {
... | code_fim | hard | {
"lang": "rust",
"repo": "ArunGust/sauron",
"path": "/crates/sauron-core/src/jss.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn parent_id(&self) -> &Self::ParentId { &() }
async fn load_page(self, spotify: AsyncCell<Client>, offset: u32) -> ClientResult<Self::Page> {
spotify.read().await.get_categories(offset, 20).await
}
fn epoch(&self) -> usize { self.0 }
}<|fim_prefix|>// repo: kstep/spodjfy path:... | code_fim | hard | {
"lang": "rust",
"repo": "kstep/spodjfy",
"path": "/src/loaders/category.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kstep/spodjfy path: /src/loaders/category.rs
use crate::{
loaders::ContainerLoader,
services::api::{PlaylistsStorageApi, ThreadSafe},
utils::AsyncCell,
};
use async_trait::async_trait;
use rspotify::{
client::ClientResult,
model::{Category, Page},
};
#[derive(Clone, Copy)]
p... | code_fim | medium | {
"lang": "rust",
"repo": "kstep/spodjfy",
"path": "/src/loaders/category.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Polkadex-Substrate/interbtc path: /crates/replace/src/default_weights.rs
//! Autogenerated weights for replace
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-09-08, STEPS: `100`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION:... | code_fim | hard | {
"lang": "rust",
"repo": "Polkadex-Substrate/interbtc",
"path": "/crates/replace/src/default_weights.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (301_210_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(22 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
}
// Storage: Security ParachainStatus (r:1 w:0)
// Storage: Replace ReplaceRequests (r:1 w:1)
// Storage: VaultRegistry Vaults (r:2 w:2)
// Storage: BT... | code_fim | hard | {
"lang": "rust",
"repo": "Polkadex-Substrate/interbtc",
"path": "/crates/replace/src/default_weights.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (3_247_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
// Storage: Security ParachainStatus (r:1 w:0)
// Storage: VaultRegistry Vaults (r:1 w:1)
// Storage: Nomination Vaults (r:1 w:0)
// Storage: Repla... | code_fim | hard | {
"lang": "rust",
"repo": "Polkadex-Substrate/interbtc",
"path": "/crates/replace/src/default_weights.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Samuele0/contract_analyzer path: /src/net/test_macro.rs
use super::netbuilder::NetBuilder;
use super::transaction::RunningFunction;
use super::transaction::{MethodType, TransactionDataProvider};
use crate::contract_data::{ContractData, ContractMethod};
use crate::contract_utils::DataType;
use cr... | code_fim | hard | {
"lang": "rust",
"repo": "Samuele0/contract_analyzer",
"path": "/src/net/test_macro.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut builder = NetBuilder::new();
let rf = || {};
builder.register_contract(
u56!(10),
contract_data! {
0 => {
read: 0 ,1;
write: 0,1;
calls: ;
};
0x43 =>{
read: 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "Samuele0/contract_analyzer",
"path": "/src/net/test_macro.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (sender, receiver) = mpsc::channel();
// state for server
let client_event_handler = ClientEventHandler {
sender : sender,
};
let handler_copy = client_event_handler.clone();
let join_handle = thread::spawn(move || {
println!("Client {} :: connecting to {:?... | code_fim | hard | {
"lang": "rust",
"repo": "MichaelShaw/psyk",
"path": "/examples/math.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MichaelShaw/psyk path: /examples/math.rs
#![allow(dead_code)]
extern crate psyk;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate aphid;
extern crate bytes;
extern crate futures;
// #[macro_use]
extern crate tokio_core;
extern crate tokio_io;
u... | code_fim | hard | {
"lang": "rust",
"repo": "MichaelShaw/psyk",
"path": "/examples/math.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let client_poison_result = client_poison_pill.shutdown();
println!("Client {} :: Poisoned done", n);
45
});
(handler_copy, join_handle)
}
fn spawn_math_server() -> (ServerEventHandler<MathToServerEvent, MathToClientEvent>, JoinHandle<u32>) {
use std::collec... | code_fim | hard | {
"lang": "rust",
"repo": "MichaelShaw/psyk",
"path": "/examples/math.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(unused_variables)]
fn main() {
let sdl = sdl2::init().unwrap();
let video = sdl.video().unwrap();
let mut window = video.window("Rust", 640, 480).build().unwrap();
window.show();
let mut event_pump = sdl.event_pump().unwrap();
{
let mut surface = window.surface_mut(... | code_fim | medium | {
"lang": "rust",
"repo": "fluffels/studious-guide",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sdl = sdl2::init().unwrap();
let video = sdl.video().unwrap();
let mut window = video.window("Rust", 640, 480).build().unwrap();
window.show();
let mut event_pump = sdl.event_pump().unwrap();
{
let mut surface = window.surface_mut(&event_pump).unwrap();
let must... | code_fim | hard | {
"lang": "rust",
"repo": "fluffels/studious-guide",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fluffels/studious-guide path: /src/main.rs
extern crate sdl2;
use sdl2::event::Event;
use sdl2::rect::Rect;
use sdl2::pixels::Color;
use std::fmt;
#[allow(dead_code)]
struct Vector {
w: i32,
x: i32,
y: i32,
z: i32,
}
#[allow(dead_code)]
impl Vector {
fn new() -> Vector {
... | code_fim | hard | {
"lang": "rust",
"repo": "fluffels/studious-guide",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 791837060/plancks path: /src/collections/ring_buffer.rs
use std::fmt;
use std::fmt::Debug;
use crate::collections::{Buffer, StreamingIterator};
use crate::elements::Element;
const BUFFER_SIZE: usize = 1_000_000;
const DEBUG_SLICE_SIZE: usize = 10;
// operate in series or parallel?
// maintain... | code_fim | hard | {
"lang": "rust",
"repo": "791837060/plancks",
"path": "/src/collections/ring_buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<E: Element + Debug> fmt::Debug for RingBuffer<E> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let buffer_slice = &self.buf[0..DEBUG_SLICE_SIZE];
let mut out = String::new();
for (i, event) in buffer_slice.iter().enumerate() {
out += &format!("\n... | code_fim | hard | {
"lang": "rust",
"repo": "791837060/plancks",
"path": "/src/collections/ring_buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.