text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: happysalada/poem path: /poem/src/web/websocket/utils.rs
use std::io::{Error as IoError, ErrorKind};
use sha1::Sha1;
use tokio_tungstenite::tungstenite::protocol::CloseFrame;
use super::{CloseCode, Message};
use crate::http::header::HeaderValue;
pub(crate) fn sign(key: &[u8]) -> HeaderValue {
... | code_fim | hard | {
"lang": "rust",
"repo": "happysalada/poem",
"path": "/poem/src/web/websocket/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>a pattern x times. E60 sets the (optional) loop start point and E6x with x values 1–F sets the end point and the number of iterations. If loop start point is not set, beginning of the pattern is used by default.
//@
//@ Notes
//@ The loop points need to be set on the same channel for them to work correctl... | code_fim | hard | {
"lang": "rust",
"repo": "adamnemecek/tgtracker",
"path": "/specs/src/core/pattern/effects.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@ ··· ·· ·· E70
//@ ··· ·· ·· 700
//@ Explanation
//@ This command sets the waveform used for 7xy tremolo command. As with E4x vibrato control, the default waveform is sine and the possible parameter x values are:
//@
//@ 0 = Sine
//@ 1 = Ramp down
//@ 2 = Square
//@ 4 = Continuous sine
//@ 5 = Continuous... | code_fim | hard | {
"lang": "rust",
"repo": "adamnemecek/tgtracker",
"path": "/specs/src/core/pattern/effects.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adamnemecek/tgtracker path: /specs/src/core/pattern/effects.rs
)
//@ - **Mx** Portamento to note
//@ - **Px** Set note panning position
//@ - **Rx** Panning slide right (displayed as ▶x)
//@ - **Sx** Set vibrato speed
//@ - **Ux** Fine volume slide up (displayed as ▲x)
//@ - **Vx** Vibrato
//@
/... | code_fim | hard | {
"lang": "rust",
"repo": "adamnemecek/tgtracker",
"path": "/specs/src/core/pattern/effects.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // "Volatile state on all servers:"
// [1]
/// "index of highest log entry known to be committed (initialized
/// to 0, increases monotonically)" [1]
pub commit_index: u64,
/// "index of highest log entry applied to state machine
/// (initialized to 0, increases monotonically)"... | code_fim | hard | {
"lang": "rust",
"repo": "mgrabmueller/rafters",
"path": "/src/state.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgrabmueller/rafters path: /src/state.rs
// Copyright 2016 Martin Grabmueller. See the LICENSE file at the
// top-level directory of this distribution for license information.
//
//! This module defines a data type for a Raft server state and
//! matching utilities.
use uuid::Uuid;
use std::co... | code_fim | hard | {
"lang": "rust",
"repo": "mgrabmueller/rafters",
"path": "/src/state.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_next_index(&mut self, follower_id: &Uuid) -> Result<u64, Error> {
match self {
&mut State { role: Role::Leader(ref mut leader_state), .. } => {
let log_len = self.log.len() as u64;
Ok(*leader_state.next_index.entry(*follower_id).or_insert_... | code_fim | hard | {
"lang": "rust",
"repo": "mgrabmueller/rafters",
"path": "/src/state.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jiayihu/fedra-thesis path: /packages/fedra-iot/src/time.rs
use core::cell::{Cell, RefCell};
use cortex_m::interrupt::Mutex;
use hal::{
stm32::TIM2,
time::U32Ext,
timer::{Event as TimerEvent, Timer},
};
use stm32f4xx_hal as hal;
static TIME: Mutex<Cell<u64>> = Mutex::new(Cell::new(0)... | code_fim | hard | {
"lang": "rust",
"repo": "jiayihu/fedra-thesis",
"path": "/packages/fedra-iot/src/time.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn handle_tim2_interrupt() {
cortex_m::interrupt::free(|cs| {
if let Some(ref mut tim2) = *TIMER2.borrow(cs).borrow_mut() {
tim2.clear_interrupt(TimerEvent::TimeOut);
}
let time = TIME.borrow(cs);
time.replace(time.get() + 1);
})
}
/// Obtain curre... | code_fim | hard | {
"lang": "rust",
"repo": "jiayihu/fedra-thesis",
"path": "/packages/fedra-iot/src/time.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let time = TIME.borrow(cs);
time.replace(time.get() + 1);
})
}
/// Obtain current time in milliseconds
pub fn now() -> u64 {
cortex_m::interrupt::free(|cs| TIME.borrow(cs).get())
}<|fim_prefix|>// repo: jiayihu/fedra-thesis path: /packages/fedra-iot/src/time.rs
use core::cell::{C... | code_fim | hard | {
"lang": "rust",
"repo": "jiayihu/fedra-thesis",
"path": "/packages/fedra-iot/src/time.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<&SoundHandle> for SoundId {
fn from(handle: &SoundHandle) -> Self {
handle.id()
}
}<|fim_prefix|>// repo: Moxinilian/kira path: /kira/src/sound/id.rs
use std::hash::Hash;
use uuid::Uuid;
use super::handle::SoundHandle;
/// A unique identifier for a [`Sound`](crate::sound::Sound).
#[deriv... | code_fim | medium | {
"lang": "rust",
"repo": "Moxinilian/kira",
"path": "/kira/src/sound/id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Moxinilian/kira path: /kira/src/sound/id.rs
use std::hash::Hash;
use uuid::Uuid;
use super::handle::SoundHandle;
<|fim_suffix|>impl From<&SoundHandle> for SoundId {
fn from(handle: &SoundHandle) -> Self {
handle.id()
}
}<|fim_middle|>/// A unique identifier for a [`Sound`](crate::sound::S... | code_fim | hard | {
"lang": "rust",
"repo": "Moxinilian/kira",
"path": "/kira/src/sound/id.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Compress an iterator of i32 using delta encoding + gzip
fn compress(mut values: impl Iterator<Item = i32>) -> Vec<u8> {
let mut encoder = GzEncoder::new(Vec::new(), Compression::default());
let mut prev = values.next().unwrap();
encoder.write_i32::<LittleEndian>(prev).unwrap();
for val... | code_fim | hard | {
"lang": "rust",
"repo": "sitegui/ptolemy",
"path": "/src/generator/parser/serialize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sitegui/ptolemy path: /src/generator/parser/serialize.rs
use crate::generator::data_types::*;
use byteorder::{LittleEndian, WriteBytesExt};
use crossbeam;
use flate2::write::GzEncoder;
use flate2::Compression;
use petgraph::visit::{EdgeRef, IntoNodeReferences};
use std::fs::File;
use std::io;
us... | code_fim | hard | {
"lang": "rust",
"repo": "sitegui/ptolemy",
"path": "/src/generator/parser/serialize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut i = p;
while i != self.id[i] {
self.id[i] = self.id[self.id[i]];
i = self.id[i];
}
return i;
}
}
impl FlatUnion {
pub fn new(n: usize) -> FlatUnion {
let mut s: Vec<usize> = Vec::new();
for x in 0..n {
s.push(x);
}
FlatUnion {
id: s
}
}
}<|fim_prefix|>// repo: ele... | code_fim | medium | {
"lang": "rust",
"repo": "elennaro/rust-algorithms",
"path": "/src/union_find/lazyflatunion.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elennaro/rust-algorithms path: /src/union_find/lazyflatunion.rs
use union_find::unionfind::*;
#[derive(Debug)]
pub struct FlatUnion {
id: Vec<usize>
}
///
/// Quick Union implementation of union find task.
///
impl UnionFind for FlatUnion {
fn union(&mut self, p: usize, q: usize) {
self.id... | code_fim | medium | {
"lang": "rust",
"repo": "elennaro/rust-algorithms",
"path": "/src/union_find/lazyflatunion.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rowhit/rust-orgmode path: /src/lib.rs
#[macro_use]
extern crate lazy_static;
extern crate chrono;
extern crate regex;
#[macro_use]
extern crate nom;
extern crate failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]
pub mod macros;
#[macro_use]
mod enum_from_str;
mod parse;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "rowhit/rust-orgmode",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type OrgProperties = HashMap<String, String>;
/// Represents the content (section) for one headline.
///
/// TODO make this more detailed than just a string
#[derive(Debug, PartialEq, Eq, Default)]
pub struct OrgContent {
value: String,
}
enum_from_str!(
Priority => A, B, C, D, E, F, G, H, I... | code_fim | hard | {
"lang": "rust",
"repo": "rowhit/rust-orgmode",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shrimanwar92/Learning-Rust path: /shopping-cart/src/main.rs
#[derive(Debug)]
#[derive(Copy, Clone)]
struct Product {
name: &'static str,
unit_price: f64,
}
#[derive(Debug, Copy, Clone)]
struct Item {
item: Product,
quantity: i32,
total_price: f64,
}
#[derive(Debug)]
struct Cart {
items: ... | code_fim | hard | {
"lang": "rust",
"repo": "shrimanwar92/Learning-Rust",
"path": "/shopping-cart/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut i1 = Item::new(products[0], 3);
let mut i2 = Item::new(products[1], 6);
// individual item update
let i1 = i1.update_item(4);
println!("{:?}", i1);
let i2 = i2.update_item(10);
println!("{:?}", i2);
let mut cart = Cart::new();
cart.add(i1);
cart.add(i... | code_fim | hard | {
"lang": "rust",
"repo": "shrimanwar92/Learning-Rust",
"path": "/shopping-cart/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oconnor663/hash_test path: /src/main.rs
use std::time::Instant;
use ring::digest::{SHA1_FOR_LEGACY_USE_ONLY, SHA256, SHA384, SHA512, SHA512_256};
use ring::digest::Context;
use blake3::Hasher;
use data_encoding::HEXUPPER;
use std::ffi::OsStr;
use pretty_bytes::converter::convert;
use std::fs::... | code_fim | hard | {
"lang": "rust",
"repo": "oconnor663/hash_test",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let metadata = file.metadata()?;
let file_size = metadata.len();
Ok(if !metadata.is_file() {
// Not a real file.
None
} else if file_size > isize::max_value() as u64 {
// Too long to safely map.
// https://github.com/danburkert/memmap-rs/issues/69
No... | code_fim | hard | {
"lang": "rust",
"repo": "oconnor663/hash_test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abargiela/xaynet path: /rust/xaynet-server/src/bin/main.rs
use std::{path::PathBuf, process};
use structopt::StructOpt;
use tokio::signal;
use tracing_subscriber::*;
use xaynet_server::{
rest,
services,
settings::Settings,
state_machine::StateMachine,
storage::redis,
};
#[c... | code_fim | hard | {
"lang": "rust",
"repo": "abargiela/xaynet",
"path": "/rust/xaynet-server/src/bin/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let settings = Settings::new(opt.config_path).unwrap_or_else(|err| {
eprintln!("{}", err);
process::exit(1);
});
let Settings {
pet: pet_settings,
mask: mask_settings,
api: api_settings,
log: log_settings,
model: model_settings,
r... | code_fim | hard | {
"lang": "rust",
"repo": "abargiela/xaynet",
"path": "/rust/xaynet-server/src/bin/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let redis = redis::Client::new(redis_settings.url, 100)
.await
.expect("failed to establish a connection to Redis");
redis
.connection()
.await
.flush_db()
.await
.expect("failed to flush the Redis database");
let (state_machine, request... | code_fim | hard | {
"lang": "rust",
"repo": "abargiela/xaynet",
"path": "/rust/xaynet-server/src/bin/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0338_counting_bits/mod.rs
pub mod dynamic_programming;
pub mod dynamic_programming_2;
pub trait Solution {
fn count_bits(num: i32) -> Vec<i32>;
}
<|fim_suffix|> pub fn run<S: Solution>() {
let test_cases = [(2, &[0, 1, 1] as &[_]), (5, &[0, 1, ... | code_fim | easy | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0338_counting_bits/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (num, expected) in test_cases {
assert_eq!(S::count_bits(num), expected);
}
}
}<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0338_counting_bits/mod.rs
pub mod dynamic_programming;
pub mod dynamic_programming_2;
pub trait Solution {
fn count_bits(num: i... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0338_counting_bits/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 10 + i
}
fn main() {
let i: int = 2;
let j: int = func(i);
if j == i || j > 7 {
i = 9;
}
}<|fim_prefix|>// repo: msiemens/RusTiny path: /tests/asm/test.rs
//! SKIP
// RusTiny IR:
//
// fn func() {
// entry-block:
// %ret_slot = alloca
// store 10 %ret_slot
// jm... | code_fim | medium | {
"lang": "rust",
"repo": "msiemens/RusTiny",
"path": "/tests/asm/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msiemens/RusTiny path: /tests/asm/test.rs
//! SKIP
// RusTiny IR:
//
// fn func() {
// entry-block:
// %ret_slot = alloca
// store 10 %ret_slot
// jmp return
// return:
// %0 = load %ret_slot
// ret %0
// }
//
// fn main() {
// entry-block:
// %1 = cmp eq 1 2
// br %... | code_fim | medium | {
"lang": "rust",
"repo": "msiemens/RusTiny",
"path": "/tests/asm/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // manual tests
check(1, 1, 1, 0);
check(16, 4, 13, 3);
check(23, 20, 29, 24);
check(23, 391, 55, 12);
check(31, 397, 55, 26);
check(Num::MAX, 2, 100, 25);
check(Num::MAX, Num::MAX, u32::MAX as Num, 0);
check(Num::MAX, Num::MAX, Num::MAX, 0);
}<|fim_prefix|>// repo: jk9... | code_fim | hard | {
"lang": "rust",
"repo": "jk977/pubcrypt-rs",
"path": "/math/src/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jk977/pubcrypt-rs path: /math/src/tests.rs
use super::*;
// List of test values for modular exponentiation that does not contain the
// potentially problematic values 0 or 1.
const SAFE_VALS: [Num; 33] = [
2,
3,
4,
8,
9,
10,
50,
99,
100,
127,
128,
... | code_fim | hard | {
"lang": "rust",
"repo": "jk977/pubcrypt-rs",
"path": "/math/src/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Connicpu/sealy-lang path: /ast/src/scope.rs
use super::Node;
use super::Statement;
<|fim_suffix|>#[derive(Debug)]
pub struct Scope {
pub statements: Vec<Statement>,
}<|fim_middle|>pub type ScopeNode = Node<Scope>;
| code_fim | easy | {
"lang": "rust",
"repo": "Connicpu/sealy-lang",
"path": "/ast/src/scope.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct Scope {
pub statements: Vec<Statement>,
}<|fim_prefix|>// repo: Connicpu/sealy-lang path: /ast/src/scope.rs
use super::Node;
use super::Statement;
<|fim_middle|>pub type ScopeNode = Node<Scope>;
| code_fim | easy | {
"lang": "rust",
"repo": "Connicpu/sealy-lang",
"path": "/ast/src/scope.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ef<[u8]>;
fn try_get_project_team(id: &Self::ProjectId) -> Option<AccountId>;
}<|fim_prefix|>// repo: AlexShkor/deip-polkadot path: /pallets/deip_assets/src/traits.rs
pub trait DeipProjectsInfo<AccountId> {
type ProjectId: sp_std::fmt::Debug + Cl<|fim_middle|>one + frame_support::codec::FullCode... | code_fim | medium | {
"lang": "rust",
"repo": "AlexShkor/deip-polkadot",
"path": "/pallets/deip_assets/src/traits.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlexShkor/deip-polkadot path: /pallets/deip_assets/src/traits.rs
pub trait DeipProjectsInfo<AccountId> {
type ProjectId: sp_std::fmt::Debug + Cl<|fim_suffix|>ef<[u8]>;
fn try_get_project_team(id: &Self::ProjectId) -> Option<AccountId>;
}<|fim_middle|>one + frame_support::codec::FullCode... | code_fim | medium | {
"lang": "rust",
"repo": "AlexShkor/deip-polkadot",
"path": "/pallets/deip_assets/src/traits.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oleksandr-kuzmenko/verwalter path: /src/daemon/elect/encode.rs
use std::io::{Cursor, Write};
use std::sync::Arc;
use cbor::{Encoder, Decoder, Config, DecodeResult};
use cbor::{DecodeError, EncodeResult, opt};
use cbor::types::Type;
use shared::{Id};
use super::{Capsule, Message, ScheduleStamp}... | code_fim | hard | {
"lang": "rust",
"repo": "oleksandr-kuzmenko/verwalter",
"path": "/src/daemon/elect/encode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn read_packet(buf: &[u8]) -> DecodeResult<Capsule> {
let mut dec = Decoder::new(Config::default(), Cursor::new(buf));
let source = try!(Id::decode(&mut dec));
let epoch = try!(dec.u64());
let (src, epoch, msg) = match try!(dec.u8()) {
x if x == PING => (source, epoch, Message... | code_fim | hard | {
"lang": "rust",
"repo": "oleksandr-kuzmenko/verwalter",
"path": "/src/daemon/elect/encode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evan-brass/webtrace path: /src/ffi.rs
extern "C" {
fn console_log(ptr: *const u8, length: u32);
<|fim_suffix|>}
pub fn get_seed() -> [u8; 16] {
let seed = [0; 16];
unsafe {
get_random(seed.as_ptr(), seed.len() as u32);
}
seed
}
pub fn log<T: AsRef<str>>(s: T) {
unsafe {
console_log(s.a... | code_fim | easy | {
"lang": "rust",
"repo": "evan-brass/webtrace",
"path": "/src/ffi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub fn get_seed() -> [u8; 16] {
let seed = [0; 16];
unsafe {
get_random(seed.as_ptr(), seed.len() as u32);
}
seed
}
pub fn log<T: AsRef<str>>(s: T) {
unsafe {
console_log(s.as_ref().as_ptr(), s.as_ref().len() as u32);
}
}<|fim_prefix|>// repo: evan-brass/webtrace path: /src/ffi.rs
extern "C" ... | code_fim | easy | {
"lang": "rust",
"repo": "evan-brass/webtrace",
"path": "/src/ffi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qqwa/rustos path: /kernel/src/scheduler.rs
#[derive(Debug, Clone)]
pub struct Scheduler {
current: u64,
next: u64,
stack_pointer_base: usize,
stack_pointer_size: usize,
processes: [Option<crate::process::Process>; 3],
}
<|fim_suffix|> pub fn add(&mut self, _func: fn()) {}... | code_fim | hard | {
"lang": "rust",
"repo": "qqwa/rustos",
"path": "/kernel/src/scheduler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn add(&mut self, _func: fn()) {}
pub fn start(&mut self) -> ! {
loop {}
}
}<|fim_prefix|>// repo: qqwa/rustos path: /kernel/src/scheduler.rs
#[derive(Debug, Clone)]
pub struct Scheduler {
current: u64,
next: u64,
stack_pointer_base: usize,
stack_pointer_size: usi... | code_fim | hard | {
"lang": "rust",
"repo": "qqwa/rustos",
"path": "/kernel/src/scheduler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "qemu")]
{
use mercuros_mercurius::drivers::uart::ns16550a::UART;
let uart_base = 0x1000_0000 as *const core::ffi::c_void;
let uart = unsafe { UART::new(uart_base) };
uart.set_word_length(8);
uart.fifo_enable();
uart.write("Hello W... | code_fim | medium | {
"lang": "rust",
"repo": "mfkiwl/mercurius",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> uart.write("Hello World!\r\n");
}
loop {}
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}<|fim_prefix|>// repo: mfkiwl/mercurius path: /src/main.rs
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[no_mangle]
pub extern "C" fn _start() -> ! {
#[cfg(feature =... | code_fim | hard | {
"lang": "rust",
"repo": "mfkiwl/mercurius",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfkiwl/mercurius path: /src/main.rs
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[no_mangle]
pub extern "C" fn _start() -> ! {
#[cfg(feature = "fu740")]
{
use mercuros_mercurius::drivers::uart::fu740_c000::{UART, StopBits};
<|fim_suffix|> uart.set_word_length(8);... | code_fim | hard | {
"lang": "rust",
"repo": "mfkiwl/mercurius",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> since_the_epoch.as_millis() as u64
}
#[cfg(feature = "metrics")]
#[inline]
pub fn get_system_time_nano() -> u64 {
let start = SystemTime::now();
let since_the_epoch = start
.duration_since(UNIX_EPOCH)
.expect("Time went backwards");
since_the_epoch.as_nanos() as u64
}
pu... | code_fim | medium | {
"lang": "rust",
"repo": "cda-group/arcon",
"path": "/arcon/src/util/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cda-group/arcon path: /arcon/src/util/mod.rs
#[cfg(feature = "socket")]
#[allow(dead_code)]
pub mod io;
pub mod prost_helpers;
pub mod system_killer;
<|fim_suffix|> since_the_epoch.as_nanos() as u64
}
pub trait ArconFnBounds: Send + Sync + Clone + 'static {}
impl<T> ArconFnBounds for T whe... | code_fim | hard | {
"lang": "rust",
"repo": "cda-group/arcon",
"path": "/arcon/src/util/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bevyengine/bevy path: /crates/bevy_asset/src/io/wasm_asset_io.rs
use crate::{AssetIo, AssetIoError, ChangeWatcher, Metadata};
use anyhow::Result;
use bevy_utils::BoxedFuture;
use js_sys::Uint8Array;
use std::{
convert::TryFrom,
path::{Path, PathBuf},
};
use wasm_bindgen::JsCast;
use wasm... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_asset/src/io/wasm_asset_io.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
_path: &Path,
) -> Result<Box<dyn Iterator<Item = PathBuf>>, AssetIoError> {
bevy_log::warn!("Loading folders is not supported in WASM");
Ok(Box::new(std::iter::empty::<PathBuf>()))
}
fn watch_path_for_changes(
&self,
_to_watch: &Path,
... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_asset/src/io/wasm_asset_io.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn naive_a() {
assert_eq!(6, naive::a(7));
assert_eq!(5, naive::a(41));
}
#[test]
fn cmp_with_naive() {
for n in (1..100).step_by(2) {
if n.is_multiple_of(&5) {
continue;
}
assert_eq!(naive::a(n), supe... | code_fim | hard | {
"lang": "rust",
"repo": "gifnksm/ProjectEulerRust",
"path": "/src/bin/p130.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(6, naive::a(7));
assert_eq!(5, naive::a(41));
}
#[test]
fn cmp_with_naive() {
for n in (1..100).step_by(2) {
if n.is_multiple_of(&5) {
continue;
}
assert_eq!(naive::a(n), super::a(n));
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "gifnksm/ProjectEulerRust",
"path": "/src/bin/p130.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gifnksm/ProjectEulerRust path: /src/bin/p130.rs
//! [Problem 130](https://projecteuler.net/problem=130) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use num_integer::Integer;
use prime::PrimeSet... | code_fim | hard | {
"lang": "rust",
"repo": "gifnksm/ProjectEulerRust",
"path": "/src/bin/p130.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// label_text: "EMPTY".to_string(),
// label_icon: "".to_string(),
// }
// }
// }<|fim_prefix|>// repo: santokalayil/DRUID-LEARN path: /src/data/sidebar.rs
use druid::{Data, Color}; // Lens
#[derive(Clone, Data, Debug)] // , Lens
pub struct SidebarButtonData... | code_fim | hard | {
"lang": "rust",
"repo": "santokalayil/DRUID-LEARN",
"path": "/src/data/sidebar.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: santokalayil/DRUID-LEARN path: /src/data/sidebar.rs
use druid::{Data, Color}; // Lens
#[derive(Clone, Data, Debug)] // , Lens
pub struct SidebarButtonData {
pub background: Color,
pub foreground: Color,
pub stroke: Color,
<|fim_suffix|>// label_text: "EMPTY".... | code_fim | hard | {
"lang": "rust",
"repo": "santokalayil/DRUID-LEARN",
"path": "/src/data/sidebar.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> ToChatRef<'a> for ChatMember {
fn to_chat_ref(&self) -> ChatRef<'a> {
self.user.to_chat_ref()
}
}
impl<'a> ToChatRef<'a> for ForwardFrom {
fn to_chat_ref(&self) -> ChatRef<'a> {
match *self {
ForwardFrom::User {ref user, ..} => user.to_chat_ref(),
... | code_fim | hard | {
"lang": "rust",
"repo": "matprec/telegram-bot",
"path": "/raw/src/types/refs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl<S> ToUserId for S where S: Deref, S::Target: ToUserId {
fn to_user_id(&self) -> UserId {
self.deref().to_user_id()
}
}
impl ToUserId for UserId {
fn to_user_id(&self) -> UserId {
*self
}
}
impl ToUserId for ChatMember {
fn to_user_id(&self) -> UserId {
... | code_fim | hard | {
"lang": "rust",
"repo": "matprec/telegram-bot",
"path": "/raw/src/types/refs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matprec/telegram-bot path: /raw/src/types/refs.rs
use std::borrow::Cow;
use std::ops::Deref;
use serde::ser::{Serialize, Serializer};
use types::*;
macro_rules! integer_id_impls {
($name: ident) => {
impl $name {
pub fn new(inner: Integer) -> Self {
$na... | code_fim | hard | {
"lang": "rust",
"repo": "matprec/telegram-bot",
"path": "/raw/src/types/refs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CloverHackyColor/CloverBootloader path: /CloverApp/Clover/ThemeManager/libimagequant/rust-sys/build.rs
//! This is a build script for Cargo https://crates.io/
//! It produces a static library that can be used by C or Rust.
extern crate cc;
use std::env;
use std::path::PathBuf;
use std::fs::can... | code_fim | hard | {
"lang": "rust",
"repo": "CloverHackyColor/CloverBootloader",
"path": "/CloverApp/Clover/ThemeManager/libimagequant/rust-sys/build.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if outdated_c_compiler && has_msvc_files {
println!("cargo:include={}", canonicalize("msvc-dist").unwrap().display());
cc.file("msvc-dist/libimagequant.c")
.file("msvc-dist/nearest.c")
.file("msvc-dist/kmeans.c")
.file("msvc-dist/mediancut.c")
... | code_fim | medium | {
"lang": "rust",
"repo": "CloverHackyColor/CloverBootloader",
"path": "/CloverApp/Clover/ThemeManager/libimagequant/rust-sys/build.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let outdated_c_compiler = env::var("TARGET").unwrap().contains("windows-msvc");
let has_msvc_files = PathBuf::from("msvc-dist/libimagequant.c").exists();
if outdated_c_compiler && has_msvc_files {
println!("cargo:include={}", canonicalize("msvc-dist").unwrap().display());
cc.f... | code_fim | hard | {
"lang": "rust",
"repo": "CloverHackyColor/CloverBootloader",
"path": "/CloverApp/Clover/ThemeManager/libimagequant/rust-sys/build.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct IdQueryParam<T: Model + Serialize> {
id: i32,
model: T,
}
/*
#[derive(FromRequest)]
pub struct ReqData<T> {
path: web::Path<(String, String)>,
query: web::Query<HashMap<String, String>>,
json: web::Json<T>,
}
*/<|fim_prefix|>// repo: clpi/di-srv path: /src/models/request.r... | code_fim | medium | {
"lang": "rust",
"repo": "clpi/di-srv",
"path": "/src/models/request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
#[derive(FromRequest)]
pub struct ReqData<T> {
path: web::Path<(String, String)>,
query: web::Query<HashMap<String, String>>,
json: web::Json<T>,
}
*/<|fim_prefix|>// repo: clpi/di-srv path: /src/models/request.rs
use serde::{Serialize, Deserialize};
use crate::state::State;
use actix_web:... | code_fim | medium | {
"lang": "rust",
"repo": "clpi/di-srv",
"path": "/src/models/request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clpi/di-srv path: /src/models/request.rs
use serde::{Serialize, Deserialize};
use crate::state::State;
use actix_web::{
HttpRequest, HttpResponse, web
};
use div_db::models::{Model, user::*};
pub struct AuthRequest<T: Serialize> {
id: actix_session::Session,
req: HttpRequest,
da... | code_fim | medium | {
"lang": "rust",
"repo": "clpi/di-srv",
"path": "/src/models/request.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
codes: Vec<Code>,
cond: &TestCondition,
backend: B,
ctx: &mut TestContext,
) {
let emitter = Emitter::new(backend);
let entry_points = vec![Path::current()].into_iter().collect();
let (modules, errors) = build_modules(codes, entry_... | code_fim | hard | {
"lang": "rust",
"repo": "chin0/llrl",
"path": "/llrl0/src/tests/test_case.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chin0/llrl path: /llrl0/src/tests/test_case.rs
use super::{test_std, ErrorExpectation, ModuleValidation, TestContext};
use crate::formatting::ContextualDisplay as _;
use crate::prelude::*;
use crate::sexp::matcher as m;
use itertools::Itertools;
use std::borrow::Cow;
use std::collections::HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "chin0/llrl",
"path": "/llrl0/src/tests/test_case.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TestTarget {
fn prepare_loader(&self, sources: HashMap<String, Ss>) -> CodeLoader {
let mut loader = CodeLoader::new();
loader.add_source(Path::builtin(), ast::builtin::module());
for (path, source) in sources {
assert!(loader.add_source(
path.... | code_fim | hard | {
"lang": "rust",
"repo": "chin0/llrl",
"path": "/llrl0/src/tests/test_case.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kuririn246/sabun_data_model path: /sabun_maker/src/imp/rust_to_json/rust_array_to_json.rs
use crate::imp::rust_to_json::get_param::get_param;
use crate::imp::structs::array_type::ArrayType;
use crate::imp::structs::qv::Qv;
use crate::imp::structs::my_json::Value;
use crate::imp::structs::rust_ar... | code_fim | medium | {
"lang": "rust",
"repo": "kuririn246/sabun_data_model",
"path": "/sabun_maker/src/imp/rust_to_json/rust_array_to_json.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
match at{
//ArrayType::String =>{ result.push(Value::String("StrArray".to_string())) },
ArrayType::Int =>{
let array_len = if let Qv::Val(v) = array.qv(){
v.len()
} else{ 0 };
//noisyすぎるので基本省略
if array_len == 0 {
... | code_fim | medium | {
"lang": "rust",
"repo": "kuririn246/sabun_data_model",
"path": "/sabun_maker/src/imp/rust_to_json/rust_array_to_json.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: najamelan/async_executors path: /examples/trait_set.rs
//! An example showing how to take an executor in an API that can use SpawnHandle
//! with multiple output types. This one uses the trait-set crate to avoid writing the blanket impl.
//!
//! You can also make your object generic over the exe... | code_fim | hard | {
"lang": "rust",
"repo": "najamelan/async_executors",
"path": "/examples/trait_set.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
struct Connection
{
// Since it's hard to get a clone on a trait object, we just wrap it
// in an Arc, that way we can pass it to child tasks. Spawning does
// not require mutable access.
//
exec: Arc< dyn CustomSpawnHandle > ,
}
impl Connection
{
pub fn new( exec: Arc< dyn CustomSpawnHandle > ) ... | code_fim | hard | {
"lang": "rust",
"repo": "najamelan/async_executors",
"path": "/examples/trait_set.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main()
{
let exec = Arc::new( AsyncStd );
let ex2 = exec.clone();
// We can't just spawn conn.run(), because it takes &self, but a spawned
// task needs to be 'static. Since conn now lives inside the async task,
// we don't borrow a local variable from our main function. The compiler
// can ass... | code_fim | hard | {
"lang": "rust",
"repo": "najamelan/async_executors",
"path": "/examples/trait_set.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: inbararan/reversi-backend path: /src/handler.rs
use super::game;
use super::game::Game;
use super::position::Position;
#[derive(Debug, PartialEq, Eq)]
pub enum Request {
Start, /* Start of the game */
DoTurn(Position), ... | code_fim | hard | {
"lang": "rust",
"repo": "inbararan/reversi-backend",
"path": "/src/handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.game.as_mut().map_or(Err(String::from("No game is running")), task)
}
fn handle_parsed(&mut self, request: Request) -> Response {
let result = match request {
Request::Start => {
self.game = Some(Game::new());
Ok(self.game.as_ref().... | code_fim | hard | {
"lang": "rust",
"repo": "inbararan/reversi-backend",
"path": "/src/handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn result_of(&mut self, task: impl Fn(&mut Game)->game::Result) -> Result<game::ChangeSet, String> {
self.game.as_mut().map_or(Err(String::from("No game is running")), task)
}
fn handle_parsed(&mut self, request: Request) -> Response {
let result = match request {
... | code_fim | hard | {
"lang": "rust",
"repo": "inbararan/reversi-backend",
"path": "/src/handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>3708, 53737, 53767, 53796, 53825, 53855, 53884, 53913,
53943, 53973, 54003, 54032, 54062, 54092, 54121, 54151, 54180, 54209, 54239, 54268, 54297,
54327, 54357, 54387, 54416, 54446, 54476, 54505, 54535, 54564, 54593, 54623, 54652, 54681,
54711, 54741, 54770, 54800, 54830, 54859, 54889, 54919, 5... | code_fim | hard | {
"lang": "rust",
"repo": "sigmaSd/HijriDate-rs",
"path": "/src/umalqura_array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigmaSd/HijriDate-rs path: /src/umalqura_array.rs
pub fn umalqura_index(mcjdn: f64) -> Result<usize, String> {
for (i, umalqura) in UMALQURA_DAT.iter().enumerate() {
if *umalqura as f64 > mcjdn {
return Ok(i);
}
}
bail!("Something went wrong in the algorit... | code_fim | hard | {
"lang": "rust",
"repo": "sigmaSd/HijriDate-rs",
"path": "/src/umalqura_array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
#[derive(Debug, PartialEq, Clone)]
struct MyStruct1(i32);
impl MyTrait for MyStruct1 {
fn get(&self) -> i32 {
self.0
}
fn set(&mut self, v: i32) {
self.0 = v
}
}
#[derive(Debug, PartialEq)]
struct MyStruct2(i32);
imp... | code_fim | hard | {
"lang": "rust",
"repo": "jprekz/rust-any_of",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jprekz/rust-any_of path: /src/lib.rs
use std::any::TypeId;
use std::ops::{Deref, DerefMut};
use std::fmt;
pub struct AnyOf<T: 'static + ?Sized> {
type_id: TypeId,
value: T,
}
impl<T: 'static> AnyOf<T> {
pub fn new(value: T) -> AnyOf<T> {
AnyOf {
type_id: TypeId::... | code_fim | hard | {
"lang": "rust",
"repo": "jprekz/rust-any_of",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0 = v
}
}
#[test]
fn test_ref() {
let anyof: &AnyOf<MyTrait> = &AnyOf::new(MyStruct1(1i32));
assert_eq!(anyof.get(), 1i32);
assert_eq!(anyof.downcast_ref::<MyStruct1>(), Some(&MyStruct1(1i32)));
assert_eq!(anyof.downcast_ref::<MyStruct2... | code_fim | hard | {
"lang": "rust",
"repo": "jprekz/rust-any_of",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: igxactly-forks/rust_xml_oxide path: /src/parser.rs
codingDecl);
let mut EncodingDecl_optional =
ParsingRule::new("EncodingDecl?".to_owned(), RuleType::Optional);
EncodingDecl_optional
.children_names
.push("EncodingDecl".to_owned());
rule_nameRegistry.insert(... | code_fim | hard | {
"lang": "rust",
"repo": "igxactly-forks/rust_xml_oxide",
"path": "/src/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // [4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
let mut NameCharExtraRule = ParsingRule::new("NameCharExtra".to_owned(), RuleType::Chars);
let name_char_extra_rule_ranges_arr = [
('0', '9'),
('a', 'z'),
('\u{0300}', '\u{... | code_fim | hard | {
"lang": "rust",
"repo": "igxactly-forks/rust_xml_oxide",
"path": "/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if rule.rule_name == "STag" || rule.rule_name == "EmptyElemTag"
|| rule.rule_name == "ETag"
{
offset_plus = new_starting_pos - offset;
//println!("offset_plus: {:?}",offset_plus );
remove_nth(iter, offset_plus);
... | code_fim | hard | {
"lang": "rust",
"repo": "igxactly-forks/rust_xml_oxide",
"path": "/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /editor/src/camera/mod.rs
pivot, root);
Self {
pivot,
camera,
yaw: settings.yaw,
pitch: settings.pitch,
rotate: false,
drag_side: 0.0,
drag_up: 0.0,
drag: false,
... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/camera/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn pick<F>(&mut self, options: PickingOptions<'_, F>) -> Option<CameraPickResult>
where
F: FnMut(Handle<Node>, &Node) -> bool,
{
let PickingOptions {
cursor_pos,
graph,
editor_objects_root,
scene_content_root,
scre... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/camera/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /editor/src/camera/mod.rs
pitch: settings.pitch,
rotate: false,
drag_side: 0.0,
drag_up: 0.0,
drag: false,
move_left: false,
move_right: false,
move_forward: false,
... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/camera/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakmeier/div-rs path: /src/class.rs
mod load;
pub use load::*;
use web_sys::HtmlElement;
use crate::ClassStorage;
use crate::DivError;
#[derive(Debug, Hash, Clone, Copy, Eq, PartialEq)]
pub struct JsClassHandle {
index: usize,
}
#[derive(Debug, Hash, Clone, Eq, PartialEq)]
pub struct JsCla... | code_fim | medium | {
"lang": "rust",
"repo": "jakmeier/div-rs",
"path": "/src/class.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.data
.iter()
.position(|ch| ch.name == name)
.map(|index| JsClassHandle { index })
}
}
impl JsClass {
pub(crate) fn attach_new_instance(&self, node: &HtmlElement) {
instantiate_svelte_component(&self.name, node);
}
}<|fim_prefix|>// rep... | code_fim | hard | {
"lang": "rust",
"repo": "jakmeier/div-rs",
"path": "/src/class.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::spawn(|| {
loader::bike_loader();
});
rocket::ignite()
.attach(MyDatabase::fairing())
.mount("/", routes![index])
.mount("/api", routes![get_bike_points])
.launch();
}<|fim_prefix|>// repo: kovacss/city-cycling path: /src/main.rs
#![feature(proc... | code_fim | medium | {
"lang": "rust",
"repo": "kovacss/city-cycling",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kovacss/city-cycling path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
use rocket_contrib::json::Json;
use std::thread;
mod bike_point;
mod connectors;
mod loader;
mod store;
use bike_point::BikePoint;
#[macro_use(bson, doc)]
extern crate bson;
<|fim_suffix|>#[rocket_contrib::da... | code_fim | hard | {
"lang": "rust",
"repo": "kovacss/city-cycling",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_use(bson, doc)]
extern crate bson;
#[macro_use]
extern crate rocket;
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
#[get("/bikes", format = "json")]
fn get_bike_points(_connection: MyDatabase) -> Json<Vec<BikePoint>> {
let bike_points = store::get_bike_points(&*_connection)... | code_fim | medium | {
"lang": "rust",
"repo": "kovacss/city-cycling",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if a tmpdir is already set
let prevtmp = var_os("MYTMP");
if prevtmp.is_some() {
let _p = prevtmp.unwrap();
let prevtmp_path : &Path = Path::new(&_p);
if prevtmp_path.exists() && !want_new {
shell.cd(prevtmp_path);
return;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "eminence/mktmp",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eminence/mktmp path: /src/main.rs
extern crate setenv;
use std::env::{home_dir, var_os, args};
use std::path::{Path, PathBuf, Component};
use std::fs::{create_dir, create_dir_all};
use std::convert::From;
use std::ffi::OsString;
<|fim_suffix|>
// if a tmpdir is already set
let prevtmp... | code_fim | hard | {
"lang": "rust",
"repo": "eminence/mktmp",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: solana-labs/rust-bpf-sysroot path: /src/std/src/sys_common/thread_local_key/tests.rs
use super::{Key, StaticKey};
fn assert_sync<T: Sync>() {}
fn assert_send<T: Send>() {}
#[test]
fn smoke() {
assert_sync::<Key>();
assert_send::<Key>();
<|fim_suffix|> unsafe {
assert!(K1.ge... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/rust-bpf-sysroot",
"path": "/src/std/src/sys_common/thread_local_key/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let k1 = Key::new(None);
let k2 = Key::new(None);
assert!(k1.get().is_null());
assert!(k2.get().is_null());
k1.set(1 as *mut _);
k2.set(2 as *mut _);
assert_eq!(k1.get() as usize, 1);
assert_eq!(k2.get() as usize, 2);
}
#[test]
fn statik() {
static K1: StaticKey = Stat... | code_fim | medium | {
"lang": "rust",
"repo": "solana-labs/rust-bpf-sysroot",
"path": "/src/std/src/sys_common/thread_local_key/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
assert!(K1.get().is_null());
assert!(K2.get().is_null());
K1.set(1 as *mut _);
K2.set(2 as *mut _);
assert_eq!(K1.get() as usize, 1);
assert_eq!(K2.get() as usize, 2);
}
}<|fim_prefix|>// repo: solana-labs/rust-bpf-sysroot path: /src/std/sr... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/rust-bpf-sysroot",
"path": "/src/std/src/sys_common/thread_local_key/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KeAiMianYang/work_repo_training path: /Rust/book/11_01_testing/src/lib.rs
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
// you can add optional args to assert macros, which are passed to format! when panicking
assert_eq!(2 + 2, 4);
}
// #[test]
// fn it_doesn... | code_fim | hard | {
"lang": "rust",
"repo": "KeAiMianYang/work_repo_training",
"path": "/Rust/book/11_01_testing/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// These traits are derivable, and in our case their implementation is simple,
// so we let the compiler automatically implement these traits
#[derive(Debug, PartialEq)]
pub struct Rectangle { length: u32, width: u32, }
impl Rectangle {
pub fn can_hold(&self, other: &Rectangle) -> bool {
self... | code_fim | hard | {
"lang": "rust",
"repo": "KeAiMianYang/work_repo_training",
"path": "/Rust/book/11_01_testing/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.return_home();
for _ in 0..10 {
let txts = self.rule_columns_content.texts();
let ptns = self.rule_columns_bounds.positions();
let (x0, y0) = ptns[0];
let (x1, y1) = ptns[ptns.len() - 2];
for (name, (x, y)) in txts.iter().zip... | code_fim | hard | {
"lang": "rust",
"repo": "sunclx/xuexi",
"path": "/src/local.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ptns = self.rule_bottom_work.positions();
while ptns.len() < 1 {
back();
ptns = self.rule_bottom_work.positions();
}
let (x, y) = ptns[0];
tap(x, y);
}
pub fn run(&self) {
println!("开始本地频道");
self.enter();
... | code_fim | hard | {
"lang": "rust",
"repo": "sunclx/xuexi",
"path": "/src/local.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sunclx/xuexi path: /src/local.rs
use super::android::{back, sleep, swipe, tap, Xpath};
use super::config::Rules;
use super::ui;
pub struct Local {
local_column_name: String,
rules: Rules,
}
impl std::ops::Deref for Local {
type Target = Rules;
fn deref(&self) -> &Self::Target {
<... | code_fim | hard | {
"lang": "rust",
"repo": "sunclx/xuexi",
"path": "/src/local.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clux/volf path: /src/webhook.rs
use serde_json;
use hyper::server::{Request, Response};
use std::io::Read;
use super::{Pull, VolfResult, VolfError, parse_commands};
use super::server::ServerHandle;
// -----------------------------------------------------------------------------
// Minor structs... | code_fim | hard | {
"lang": "rust",
"repo": "clux/volf",
"path": "/src/webhook.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.