text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let prelude_offset = prelude_size::<AndFramePrelude>();
let index_offset = (index - 1) * mem::size_of::<Addr>();
unsafe {
let ptr = mem::transmute::<&mut AndFrame, *const u8>(self);
let ptr = ptr as usize + prelude_offset + index_offset;
&mut *... | code_fim | hard | {
"lang": "rust",
"repo": "GavinMendelGleason/scryer-prolog",
"path": "/src/prolog/machine/stack.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GavinMendelGleason/scryer-prolog path: /src/prolog/machine/stack.rs
use crate::prolog::machine::machine_indices::*;
use crate::prolog::machine::raw_block::*;
use core::marker::PhantomData;
use std::mem;
use std::ops::{Index, IndexMut};
use std::ptr;
struct StackTraits {}
impl RawBlockTraits ... | code_fim | hard | {
"lang": "rust",
"repo": "GavinMendelGleason/scryer-prolog",
"path": "/src/prolog/machine/stack.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Do the same, but give each point a unique colour.
let n_points = 7;
let points_colored = (0..n_points).map(|i| {
let fract = i as f32 / n_points as f32;
let phase = fract;
let x = radius * (TAU * phase).cos();
let y = radius * (TAU * phase).sin();
let... | code_fim | hard | {
"lang": "rust",
"repo": "MacTuitui/nannou",
"path": "/examples/draw/draw_polygon.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MacTuitui/nannou path: /examples/draw/draw_polygon.rs
use nannou::prelude::*;
fn main() {
nannou::sketch(view).run()
}
fn view(app: &App, frame: Frame) {
// Begin drawing
let win = app.window_rect();
let t = app.time;
let draw = app.draw();
<|fim_suffix|> // Create an `... | code_fim | medium | {
"lang": "rust",
"repo": "MacTuitui/nannou",
"path": "/examples/draw/draw_polygon.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn ownership_move_with_tuple(m_string : String, m_string_2: String) -> (String, String){
//yadda yadda
(m_string, m_string_2)
}
//To use something without borrowing ownership, use references
//Borrowed things can not be modified
fn get_len_reference(s : &String) -> usize{
s.len()
//s.push... | code_fim | hard | {
"lang": "rust",
"repo": "SantiagoMunoz/RustByExample",
"path": "/ownership/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SantiagoMunoz/RustByExample path: /ownership/src/main.rs
fn main() {
let mut s = String::from("Hello");
s.push_str(", world!");
println!("{}",s);
let s2 = s.clone(); //Otherwise ownership gets moved and s stops being valid
println!("{}", s);
let x = 1;
let y = x; ... | code_fim | hard | {
"lang": "rust",
"repo": "SantiagoMunoz/RustByExample",
"path": "/ownership/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Function: {}",some_string);
}
fn take_n_return_ownership(some_string: String) -> String{
println!("Function: {}",some_string);
some_string
}
fn give_ownership() -> String{
let some_string = String::from("Otra cosa");
some_string
}
fn ownership_move_with_tuple(m_string ... | code_fim | hard | {
"lang": "rust",
"repo": "SantiagoMunoz/RustByExample",
"path": "/ownership/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>_NAME: &'static str = "VK_IMG_filter_cubic";<|fim_prefix|>// repo: Pctg-x8/interlude path: /vk/defs/src/filter_cubic_img.rs
//! VK_IMG_filter_cubic extensions
pub const VK_IMG_FILTER_CUBIC_SPEC_VERSION: usize =<|fim_middle|> 1;
pub static VK_IMG_FILTER_CUBIC_EXTENSION | code_fim | easy | {
"lang": "rust",
"repo": "Pctg-x8/interlude",
"path": "/vk/defs/src/filter_cubic_img.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pctg-x8/interlude path: /vk/defs/src/filter_cubic_img.rs
//! VK_IMG_filter_cubic extensions
pub const VK_IMG_FILTER_CUBIC_SPEC_VERSION: usize =<|fim_suffix|>_NAME: &'static str = "VK_IMG_filter_cubic";<|fim_middle|> 1;
pub static VK_IMG_FILTER_CUBIC_EXTENSION | code_fim | easy | {
"lang": "rust",
"repo": "Pctg-x8/interlude",
"path": "/vk/defs/src/filter_cubic_img.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 1;
pub static VK_IMG_FILTER_CUBIC_EXTENSION_NAME: &'static str = "VK_IMG_filter_cubic";<|fim_prefix|>// repo: Pctg-x8/interlude path: /vk/defs/src/filter_cubic_img.rs
//! VK_IMG_filter_cubic extensions
pub con<|fim_middle|>st VK_IMG_FILTER_CUBIC_SPEC_VERSION: usize = | code_fim | easy | {
"lang": "rust",
"repo": "Pctg-x8/interlude",
"path": "/vk/defs/src/filter_cubic_img.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustic-games/jilu path: /src/changelog/contributor.rs
use serde::Serialize;
use std::cmp::Ordering;
/// The contributor to a change.
#[derive(Debug, Serialize, Eq, PartialEq, PartialOrd)]
pub(crate) struct Contributor {
pub(crate) name: String,
pub(crate) email: String,
}
impl Ord for ... | code_fim | medium | {
"lang": "rust",
"repo": "rustic-games/jilu",
"path": "/src/changelog/contributor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.name.cmp(&other.name)
}
}
impl From<(&str, &str)> for Contributor {
fn from((name, email): (&str, &str)) -> Self {
Self {
name: name.to_owned(),
email: email.to_owned(),
}
}
}<|fim_prefix|>// repo: rustic-games/jilu path: /src/changelog/co... | code_fim | medium | {
"lang": "rust",
"repo": "rustic-games/jilu",
"path": "/src/changelog/contributor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/1019_next_larger_nodes.rs
impl Solution {
pub fn next_larger_nodes(head: Option<Box<ListNode>>) -> Vec<i32> {
let mut h = &head;
let mut ret = vec![];
let mut stack: Vec<(usize, i32)> = vec![];
while let Some(ref... | code_fim | hard | {
"lang": "rust",
"repo": "HerringtonDarkholme/leetcode",
"path": "/src/1019_next_larger_nodes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
stack.push((ret.len(), n.val));
ret.push(0);
h = &n.next;
}
ret
}
}<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/1019_next_larger_nodes.rs
impl Solution {
pub fn next_larger_nodes(head: Option<Box<ListNode>>) -> Vec<... | code_fim | hard | {
"lang": "rust",
"repo": "HerringtonDarkholme/leetcode",
"path": "/src/1019_next_larger_nodes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn predict(&self, opponent: &Opponent) -> Option<Vec<Card>>;
}<|fim_prefix|>// repo: dareagle/Strategy-Card-Game-AI-Competition path: /contest-2020-07-CEC/Chad/agent/src/predictors/mod.rs
use crate::model::{Card, Opponent, Player};
mod empty;
pub use empty::EmptyPredictor;
<|fim_middle|>pub trait P... | code_fim | medium | {
"lang": "rust",
"repo": "dareagle/Strategy-Card-Game-AI-Competition",
"path": "/contest-2020-07-CEC/Chad/agent/src/predictors/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dareagle/Strategy-Card-Game-AI-Competition path: /contest-2020-07-CEC/Chad/agent/src/predictors/mod.rs
use crate::model::{Card, Opponent, Player};
<|fim_suffix|> fn predict(&self, opponent: &Opponent) -> Option<Vec<Card>>;
}<|fim_middle|>mod empty;
pub use empty::EmptyPredictor;
pub trait P... | code_fim | medium | {
"lang": "rust",
"repo": "dareagle/Strategy-Card-Game-AI-Competition",
"path": "/contest-2020-07-CEC/Chad/agent/src/predictors/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe{
tonc_stolen::tonccpy(
memmap::vid_mem as *mut u8, GBA_IMG as *const u8, GBA_IMG.len());
tonc_stolen::tonccpy(
memmap::pal_bg_mem as *mut u8, GBA_PAL as *const u8, GBA_PAL.len());
}
// Sets the mode.
let mut mode4 = gfx::Mode4::new();
let mut keys = ... | code_fim | hard | {
"lang": "rust",
"repo": "tbelaire/rusty-TONC",
"path": "/key_demo/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tbelaire/rusty-TONC path: /key_demo/src/main.rs
#![feature(lang_items, no_std, core, core_slice_ext)]
#![no_std]
#![no_main]
extern crate gba;
mod lang;
pub use lang::{__aeabi_unwind_cpp_pr0, __aeabi_unwind_cpp_pr1};
use gba::*;
use gba::input::Keys;
use core::mem;
const GBA_IMG : &'stat... | code_fim | hard | {
"lang": "rust",
"repo": "tbelaire/rusty-TONC",
"path": "/key_demo/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[no_mangle]
pub extern "C" fn main(_: i32, _: *const *const i8) -> i32 {
unsafe{
tonc_stolen::tonccpy(
memmap::vid_mem as *mut u8, GBA_IMG as *const u8, GBA_IMG.len());
tonc_stolen::tonccpy(
memmap::pal_bg_mem as *mut u8, GBA_PAL as *const u8, GBA_PAL.len());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "tbelaire/rusty-TONC",
"path": "/key_demo/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cstml/Rust-Linked-List path: /src/test.rs
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
<|fim_suffix|> assert_eq!(true,true);
}
}<|fim_middle|> #[test]
fn it_still_works() {
| code_fim | easy | {
"lang": "rust",
"repo": "cstml/Rust-Linked-List",
"path": "/src/test.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(true,true);
}
}<|fim_prefix|>// repo: cstml/Rust-Linked-List path: /src/test.rs
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
<|fim_middle|> assert_eq!(2 + 2, 4);
}
#[test]
fn it_still_works() {
| code_fim | medium | {
"lang": "rust",
"repo": "cstml/Rust-Linked-List",
"path": "/src/test.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_still_works() {
assert_eq!(true,true);
}
}<|fim_prefix|>// repo: cstml/Rust-Linked-List path: /src/test.rs
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
<|fim_middle|> assert_eq!(2 + 2, 4);
}
| code_fim | easy | {
"lang": "rust",
"repo": "cstml/Rust-Linked-List",
"path": "/src/test.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(parsed_event.event_id, event.event_id);
assert_eq!(parsed_event.room_id, event.room_id);
assert_eq!(parsed_event.sender, event.sender);
assert_eq!(parsed_event.state_key, event.state_key);
assert_eq!(parsed_event.origin_server_ts, event.origin_server_ts);... | code_fim | hard | {
"lang": "rust",
"repo": "kroeckx/ruma",
"path": "/crates/ruma-events/src/room/pinned_events.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kroeckx/ruma path: /crates/ruma-events/src/room/pinned_events.rs
//! Types for the *m.room.pinned_events* event.
use ruma_events_macros::EventContent;
use ruma_identifiers::EventId;
use serde::{Deserialize, Serialize};
use crate::StateEvent;
/// Used to "pin" particular events in a room for o... | code_fim | hard | {
"lang": "rust",
"repo": "kroeckx/ruma",
"path": "/crates/ruma-events/src/room/pinned_events.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> content.pinned.push(EventId::new(server_name));
content.pinned.push(EventId::new(server_name));
let event = StateEvent {
content: content.clone(),
event_id: EventId::new(server_name),
origin_server_ts: MilliSecondsSinceUnixEpoch(1_432_804_485_88... | code_fim | hard | {
"lang": "rust",
"repo": "kroeckx/ruma",
"path": "/crates/ruma-events/src/room/pinned_events.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theswiftfox/sparkle-rs path: /src/engine/mod.rs
"Loaded scene in {} ms",
renderer.clock.elapsed().as_millis()
);
renderer.clock = Instant::now();
}
Err(_) => {
println!("Error lo... | code_fim | hard | {
"lang": "rust",
"repo": "theswiftfox/sparkle-rs",
"path": "/src/engine/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let null_srv: [*mut dx11::ID3D11ShaderResourceView; 2] =
[std::ptr::null_mut(), std::ptr::null_mut()];
unsafe {
(*ctx).PSSetShaderResources(0, 2, null_srv.as_ptr());
}
let targets = deferred_pre.get_render_targets();
... | code_fim | hard | {
"lang": "rust",
"repo": "theswiftfox/sparkle-rs",
"path": "/src/engine/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theswiftfox/sparkle-rs path: /src/engine/mod.rs
se)
.expect("Error setting camera pos");
let ssao = match self.settings.ssao {
true => 1,
false => 0,
};
... | code_fim | hard | {
"lang": "rust",
"repo": "theswiftfox/sparkle-rs",
"path": "/src/engine/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (_, containee) in rhs.iter() {
if closure.contains(containee) {
closure.insert(container.to_string());
added_any = true;
}
}
}
if !added_any {
break;
}
}
println!("{}", closure.len());
println!("{}", recursive_count(&rules, "sh... | code_fim | hard | {
"lang": "rust",
"repo": "IreneKnapp/2020-advent-of-code",
"path": "/07/src/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IreneKnapp/2020-advent-of-code path: /07/src/main.rs
use advent_lib::prelude::*;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
fn main() -> Result<()> {
let mut args = std::env::args();
if args.len() != 2 {
eprintln!("Usage: advent input");
}
let _ = args.next();... | code_fim | hard | {
"lang": "rust",
"repo": "IreneKnapp/2020-advent-of-code",
"path": "/07/src/main.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let mut added_any = false;
for (container, rhs) in rules.iter() {
if closure.contains(container) {
continue;
}
for (_, containee) in rhs.iter() {
if closure.contains(containee) {
closure.insert(container.to_string());
added_any = true... | code_fim | hard | {
"lang": "rust",
"repo": "IreneKnapp/2020-advent-of-code",
"path": "/07/src/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shybyte/chord-detection-rust path: /examples/visualize-spectrum-wav.rs
extern crate sdl2;
extern crate chord_detection;
extern crate goertzel;
extern crate pitch_calc;
extern crate hound;
use sdl2::render::Canvas;
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
us... | code_fim | hard | {
"lang": "rust",
"repo": "shybyte/chord-detection-rust",
"path": "/examples/visualize-spectrum-wav.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, a_mag) in ggram.gromagram.iter().enumerate() {
canvas.set_draw_color(Color::RGB(255, 0, 0));
let y = (i as u32) * bar_height + start_y;
canvas.draw_rect(Rect::new(0, y as i32, (a_mag * 2000.0) as u32, bar_height)).unwrap();
}
... | code_fim | hard | {
"lang": "rust",
"repo": "shybyte/chord-detection-rust",
"path": "/examples/visualize-spectrum-wav.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !audio_frames.is_empty() {
// eprintln!("audio_frames = {:?}", audio_frames.len());
canvas.set_draw_color(Color::RGB(0, 0, 0));
canvas.clear();
let (_w, h) = canvas.output_size().unwrap();
let middle_h = (h / 2) as i32;
l... | code_fim | hard | {
"lang": "rust",
"repo": "shybyte/chord-detection-rust",
"path": "/examples/visualize-spectrum-wav.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oskar404/code-drill path: /rs/solutions.rs
// Write a program that outputs all possibilities to put + or - or nothing
// between the numbers 1, 2, ..., 9 (in this order) such that the result is
// always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100.
const NUMBERS: [i32; 9] = [1,2,3,4,5,6... | code_fim | hard | {
"lang": "rust",
"repo": "oskar404/code-drill",
"path": "/rs/solutions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
// Initialize buffer with first value
let mut buf: Vec<i32> = Vec::new();
buf.push(NUMBERS[0]);
recurse(&buf, 1);
}
fn recurse(buf: &Vec<i32>, idx: usize) {
// Check if we have recursed to depth
if idx >= NUMBERS.len() {
let sum = buf.iter().sum();
if ... | code_fim | medium | {
"lang": "rust",
"repo": "oskar404/code-drill",
"path": "/rs/solutions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Hash for Ref {
fn hash<H: Hasher>(&self, state: &mut H) {
self.inner.hash(state);
}
}<|fim_prefix|>// repo: Maigo/cxx path: /syntax/impls.rs
use crate::syntax::{Ref, Ty1};
use std::hash::{Hash, Hasher};
impl Eq for Ty1 {}
impl PartialEq for Ty1 {
fn eq(&self, other: &Ty1) -> bo... | code_fim | hard | {
"lang": "rust",
"repo": "Maigo/cxx",
"path": "/syntax/impls.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.inner == other.inner
}
}
impl Hash for Ref {
fn hash<H: Hasher>(&self, state: &mut H) {
self.inner.hash(state);
}
}<|fim_prefix|>// repo: Maigo/cxx path: /syntax/impls.rs
use crate::syntax::{Ref, Ty1};
use std::hash::{Hash, Hasher};
impl Eq for Ty1 {}
impl PartialEq fo... | code_fim | medium | {
"lang": "rust",
"repo": "Maigo/cxx",
"path": "/syntax/impls.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Maigo/cxx path: /syntax/impls.rs
use crate::syntax::{Ref, Ty1};
use std::hash::{Hash, Hasher};
impl Eq for Ty1 {}
impl PartialEq for Ty1 {
fn eq(&self, other: &Ty1) -> bool {
<|fim_suffix|>impl PartialEq for Ref {
fn eq(&self, other: &Ref) -> bool {
self.inner == other.inner
... | code_fim | hard | {
"lang": "rust",
"repo": "Maigo/cxx",
"path": "/syntax/impls.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mk10969/rust-sample path: /src/main.rs
extern crate chrono;
extern crate chrono_tz;
use chrono::Utc;
use chrono_tz::Asia::Tokyo;
use cron::Schedule;
use dotenv::dotenv;
use std::{env, str::FromStr};
<|fim_suffix|> log::info!(
"-> datetime: {} now: {} diff: {}",
... | code_fim | hard | {
"lang": "rust",
"repo": "mk10969/rust-sample",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::info!(
"-> datetime: {} now: {} diff: {}",
datetime,
tokyo_now,
datetime - tokyo_now
);
tokio::time::sleep(core::time::Duration::from_secs(1)).await;
}
});
join_handle.await?;
Ok((... | code_fim | hard | {
"lang": "rust",
"repo": "mk10969/rust-sample",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mashtizadeh/wasmtime path: /examples/multi.rs
//! This is an example of working with mulit-value modules and dealing with
//! multi-value functions.
//!
//! Note that the `Func::wrap*` interfaces cannot be used to return multiple
//! values just yet, so we need to use the more dynamic `Func::new... | code_fim | hard | {
"lang": "rust",
"repo": "mashtizadeh/wasmtime",
"path": "/examples/multi.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Call `$round_trip_many`.
println!("Calling export \"round_trip_many\"...");
let round_trip_many = instance
.get_func("round_trip_many")
.ok_or(format_err!("failed to find export `round_trip_many`"))?;
let args = vec![
Val::I64(0),
Val::I64(1),
Val... | code_fim | hard | {
"lang": "rust",
"repo": "mashtizadeh/wasmtime",
"path": "/examples/multi.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RoflMalovski/yakuza-freecam path: /likeadragon/lib/src/globals.rs
#![allow(non_upper_case_globals)]
use memory_rs::scoped_no_mangle;
use std::sync::atomic::AtomicUsize;
scoped_no_mangle! {
// Pointer to the camera struct (the lookat is at +0x80 offset
g_camera_struct: usize = 0;
/... | code_fim | hard | {
"lang": "rust",
"repo": "RoflMalovski/yakuza-freecam",
"path": "/likeadragon/lib/src/globals.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern "C" {
pub static asm_get_camera_data: u8;
pub static asm_get_timestop: u8;
pub static asm_get_controller: u8;
}<|fim_prefix|>// repo: RoflMalovski/yakuza-freecam path: /likeadragon/lib/src/globals.rs
#![allow(non_upper_case_globals)]
use memory_rs::scoped_no_mangle;
use std::sync::ato... | code_fim | hard | {
"lang": "rust",
"repo": "RoflMalovski/yakuza-freecam",
"path": "/likeadragon/lib/src/globals.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mistodon/jamjar path: /src/web.rs
use std::sync::{Mutex, MutexGuard};
use winit::dpi::PhysicalSize;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TouchPhase {
Start,
End,
Cancel,
Move,
}
#[non_exhaustive]
pub enum WebEvent {
Resized(PhysicalSize<u32>),
KeyTyped... | code_fim | hard | {
"lang": "rust",
"repo": "mistodon/jamjar",
"path": "/src/web.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(target_arch = "wasm32")]
pub(crate) unsafe fn log_event(event: WebEvent) {
ensure_events().push(event);
}
pub fn poll_events() -> impl Iterator<Item = WebEvent> {
let events = unsafe { ensure_events().drain(..).collect::<Vec<_>>() };
events.into_iter()
}<|fim_prefix|>// repo: mistodon/j... | code_fim | hard | {
"lang": "rust",
"repo": "mistodon/jamjar",
"path": "/src/web.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) unsafe fn ensure_events() -> MutexGuard<'static, Vec<WebEvent>> {
if WEB_EVENTS.is_none() {
WEB_EVENTS = Some(Mutex::new(Vec::new()));
}
WEB_EVENTS.as_mut().unwrap().lock().unwrap()
}
#[cfg(target_arch = "wasm32")]
pub(crate) unsafe fn log_event(event: WebEvent) {
ensur... | code_fim | medium | {
"lang": "rust",
"repo": "mistodon/jamjar",
"path": "/src/web.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: omallassi/apis-catalog path: /server/src/dao/repo_envs/mod.rs
extern crate failure;
extern crate rusqlite;
extern crate time;
extern crate uuid;
use uuid::Uuid;
use rusqlite::NO_PARAMS;
use rusqlite::{params, Connection, Result};
//use rustbreak::{FileDatabase, deser::Ron};
use log::debug;
p... | code_fim | hard | {
"lang": "rust",
"repo": "omallassi/apis-catalog",
"path": "/server/src/dao/repo_envs/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn add_env(
config: &super::super::settings::Database,
name: &str,
description: &str,
) -> Result<()> {
let mut db_path = String::from(&config.rusqlite_path);
db_path.push_str("/apis-catalog-all.db");
{
debug!("Creating env [{}] into Env_Database [{:?}]", name, db_path)... | code_fim | hard | {
"lang": "rust",
"repo": "omallassi/apis-catalog",
"path": "/server/src/dao/repo_envs/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let conn = Connection::open(db_path)?;
// conn.execute(
// "CREATE TABLE IF NOT EXISTS envs (
// id UUID NOT NULL UNIQUE,
// name TEXT NOT NULL UNIQUE,
// description TEXT NOT NULL)",
// NO_PARAMS,
// )?;
let mut stmt = conn.prepare("SE... | code_fim | hard | {
"lang": "rust",
"repo": "omallassi/apis-catalog",
"path": "/server/src/dao/repo_envs/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: comfortablynick/sysinfo path: /src/uptime.rs
/* Output system uptime */
use getopts::Options;
use std::{
io::{self, Write},
ops::Sub,
};
use systemstat::{Platform, System};
fn print_help(command: &str, opts: Options) {
const DESC: &str = "Print uptime in specified format.";
let ... | code_fim | hard | {
"lang": "rust",
"repo": "comfortablynick/sysinfo",
"path": "/src/uptime.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sys = System::new();
let uptime = sys.uptime()?;
let duration = chrono::Duration::from_std(uptime)?;
let stdout = io::stdout();
let mut cout = stdout.lock();
write!(cout, "↑")?;
// push weeks
let fmt_weeks = matches.opt_present("weeks");
if duration.num_weeks() > 0 ... | code_fim | hard | {
"lang": "rust",
"repo": "comfortablynick/sysinfo",
"path": "/src/uptime.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sx.send(5).unwrap();
sx.send(10).unwrap();
sx.send(2).unwrap();
sx.send(0).unwrap();
println!("{} {} {}",
r1.recv().unwrap(),
r2.recv().unwrap(),
r3.recv().unwrap());
println!("{} {} {}",
r1.recv().unwrap(),
r2.recv(... | code_fim | medium | {
"lang": "rust",
"repo": "TyOverby/many2many",
"path": "/examples/basic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TyOverby/many2many path: /examples/basic.rs
extern crate many2many;
use many2many::mchannel;
fn main() {
let (sx, rx)= mchannel();
<|fim_suffix|>
sx.send(5).unwrap();
sx.send(10).unwrap();
sx.send(2).unwrap();
sx.send(0).unwrap();
println!("{} {} {}",
r1.r... | code_fim | medium | {
"lang": "rust",
"repo": "TyOverby/many2many",
"path": "/examples/basic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
sx.send(5).unwrap();
sx.send(10).unwrap();
sx.send(2).unwrap();
sx.send(0).unwrap();
println!("{} {} {}",
r1.recv().unwrap(),
r2.recv().unwrap(),
r3.recv().unwrap());
println!("{} {} {}",
r1.recv().unwrap(),
r2.recv... | code_fim | medium | {
"lang": "rust",
"repo": "TyOverby/many2many",
"path": "/examples/basic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uniphil/portmidi-rs path: /examples/list_devices.rs
extern crate "portmidi" as pm;
fn main() {
match get_devices() {
Err(e) => println!("{:?}", e),
Ok(d) => print_devices(d)
}
}
fn get_devices() -> pm::PortMidiResult<Vec<pm::DeviceInfo>> {
try!(pm::initialize());
... | code_fim | medium | {
"lang": "rust",
"repo": "uniphil/portmidi-rs",
"path": "/examples/list_devices.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Id Name Input? Output?");
println!("=======================================");
for d in devices.into_iter() {
println!("{:<3} {:<20} {:<6} {:<6}", d.device_id, d.name, d.input, d.output);
}
}<|fim_prefix|>// repo: uniphil/portmidi-rs path: /examples/list... | code_fim | hard | {
"lang": "rust",
"repo": "uniphil/portmidi-rs",
"path": "/examples/list_devices.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> log.push_str(&format!("exit_status: {:?}\n", res.status));
log.push_str(&format!("duration: {}ms\n", duration.as_millis()));
log.push_str(&format!("start: {}\n",
start_utc.to_rfc3339_opts(chrono::SecondsFormat::Micros, true)));
log.push_str(&format!("finish: {}",
... | code_fim | hard | {
"lang": "rust",
"repo": "fluffysquirrels/monitor-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fluffysquirrels/monitor-rs path: /src/lib.rs
#[macro_use]
extern crate log;
pub mod collector_pool;
pub mod config;
mod core_types;
pub mod log_store;
pub mod metric_store;
mod notifier;
pub mod remote;
pub mod scheduler;
mod signal;
mod time_utils;
pub mod collector {
//! Protobuf types f... | code_fim | hard | {
"lang": "rust",
"repo": "fluffysquirrels/monitor-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mexus/pastebin path: /bin/src/mongo_impl.rs
//! `MongoDB` wrapper that implements `DbInterface`.
use bson::{self, Bson};
use chrono::{DateTime, Utc};
use mongo_driver::{CommandAndFindOptions, MongoError};
use mongo_driver::client::ClientPool;
use mongo_driver::collection::{Collection, FindAndMo... | code_fim | hard | {
"lang": "rust",
"repo": "mexus/pastebin",
"path": "/bin/src/mongo_impl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result =
ids.find_and_modify(&doc!("_id": "paste"),
FindAndModifyOperation::Upsert(&doc!("$inc": { "counter": 1i64 })),
Some(&opts))?;
let entry = result.get_document("value")?;
Ok(entry.get_i64("coun... | code_fim | hard | {
"lang": "rust",
"repo": "mexus/pastebin",
"path": "/bin/src/mongo_impl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruoshui-git/cyb-playfair path: /src/main.rs
use cyb_playfair::Playfair;
use std::{env, process};
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 4 {
eprintln!("program encode/decode [text] [key]");
process::exit(1);
}
<|fim_suffix|> //... | code_fim | medium | {
"lang": "rust",
"repo": "ruoshui-git/cyb-playfair",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let text = args[2].as_str();
let encoder = Playfair::new(args[3].as_str());
// let result = ;
println!(
"{}",
match args[1].as_str() {
"encode" => encoder.encode(text),
"decode" => encoder.decode(text),
_ => {
eprintln!("... | code_fim | medium | {
"lang": "rust",
"repo": "ruoshui-git/cyb-playfair",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yuhonghong95721/anonify path: /core/bc-connector/src/traits.rs
#![allow(dead_code)]
use std::{
path::Path,
sync::Arc,
};
use sgx_types::sgx_enclave_id_t;
use anonify_types::{RawJoinGroupTx, RawInstructionTx, RawHandshakeTx};
use anonify_common::AccessRight;
use anonify_runtime::{traits:... | code_fim | hard | {
"lang": "rust",
"repo": "yuhonghong95721/anonify",
"path": "/core/bc-connector/src/traits.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_account(&self, index: usize) -> Result<SignerAddress>;
/// Send an encrypted instruction of state transition to blockchain nodes.
fn send_instruction<ST, F>(
&self,
access_right: AccessRight,
signer: SignerAddress,
state_info: StateInfo<'_, ST>,
... | code_fim | hard | {
"lang": "rust",
"repo": "yuhonghong95721/anonify",
"path": "/core/bc-connector/src/traits.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[rustler::nif(schedule = "DirtyIo")]
fn close(container: ResourceArc<XqliteConnection>) -> CloseResult {
let mut mconn = container.0.lock().unwrap();
if !mconn.is_none() {
// Take out the connection so it becomes None in the resource
// as it is being closed early.
let con... | code_fim | hard | {
"lang": "rust",
"repo": "dimitarvp/xqlite",
"path": "/native/xqlitenif/src/close.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimitarvp/xqlite path: /native/xqlitenif/src/close.rs
use rusqlite::Connection;
use rustler::resource::ResourceArc;
use rustler::{Encoder, Env, Term};
use crate::atoms::{already_closed, cannot_close, error, ok};
use crate::shared::XqliteConnection;
<|fim_suffix|>#[rustler::nif(schedule = "Dirt... | code_fim | hard | {
"lang": "rust",
"repo": "dimitarvp/xqlite",
"path": "/native/xqlitenif/src/close.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut mconn = container.0.lock().unwrap();
if !mconn.is_none() {
// Take out the connection so it becomes None in the resource
// as it is being closed early.
let conn: Connection = mconn.take().unwrap();
match conn.close() {
Ok(()) => CloseResult::Suc... | code_fim | medium | {
"lang": "rust",
"repo": "dimitarvp/xqlite",
"path": "/native/xqlitenif/src/close.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!("Sylph-Verifier v{} by LymeeFairy", env!("CARGO_PKG_VERSION"));
println!("Licenced under the Apache license, version 2.0");
println!();
startup::start();
std::process::exit(0); // Just in case.
}<|fim_prefix|>// repo: efeban/sylph-verifier path: /src/main.rs
#![w... | code_fim | medium | {
"lang": "rust",
"repo": "efeban/sylph-verifier",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: efeban/sylph-verifier path: /src/main.rs
#![warn(unused_extern_crates)]
#![recursion_limit="128"]
#![feature(nll, box_patterns, match_default_bindings, never_type, integer_atomics, fnbox,
universal_impl_trait, conservative_impl_trait, dyn_trait, const_fn, try_trait)]
#![deny(unused_mu... | code_fim | hard | {
"lang": "rust",
"repo": "efeban/sylph-verifier",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_use] extern crate enumset;
#[macro_use] extern crate failure;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate log;
#[macro_use] extern crate serde_derive;
#[macro_use] mod errors;
mod commands;
mod core;
mod database;
mod error_report;
mod logger;
mod roblox;
mod startup;
mod ut... | code_fim | hard | {
"lang": "rust",
"repo": "efeban/sylph-verifier",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO: differentiate between errors
Box::new(
client
.get(url.clone())
.send()
.and_then(|response| {
let real_url = response.url().clone();
response
.into_body()
.concat2()
... | code_fim | hard | {
"lang": "rust",
"repo": "forgerpl/webcrawl",
"path": "/crawler/src/fetcher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("Fetching {}", url);
// TODO: differentiate between errors
Box::new(
client
.get(url.clone())
.send()
.and_then(|response| {
let real_url = response.url().clone();
response
.into_body()
... | code_fim | medium | {
"lang": "rust",
"repo": "forgerpl/webcrawl",
"path": "/crawler/src/fetcher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forgerpl/webcrawl path: /crawler/src/fetcher.rs
use crate::error::*;
use crate::ty::{AsStr, FetchBuffer};
use futures::{Future, Stream};
use log::*;
use reqwest::r#async::{Chunk, Client};
use std::str::from_utf8;
use url::Url;
<|fim_suffix|>/// Simple document fetcher, based on reqwest library
... | code_fim | medium | {
"lang": "rust",
"repo": "forgerpl/webcrawl",
"path": "/crawler/src/fetcher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl From<nix::Error> for ShMemErr {
fn from(e: nix::Error) -> Self {
ShMemErr::Unix(e)
}
}
} else {
panic!("Invalid platform!");
}
}<|fim_prefix|>// repo: CarterFendley/typed_shmem path: /src/error.rs
pub type Result<T> = std::resul... | code_fim | hard | {
"lang": "rust",
"repo": "CarterFendley/typed_shmem",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ShMemErr::Unix(e)
}
}
} else {
panic!("Invalid platform!");
}
}<|fim_prefix|>// repo: CarterFendley/typed_shmem path: /src/error.rs
pub type Result<T> = std::result::Result<T, ShMemErr>;
cfg_if::cfg_if! {
if #[cfg(windows)] {
#[derive(Debug... | code_fim | medium | {
"lang": "rust",
"repo": "CarterFendley/typed_shmem",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CarterFendley/typed_shmem path: /src/error.rs
pub type Result<T> = std::result::Result<T, ShMemErr>;
cfg_if::cfg_if! {
if #[cfg(windows)] {
#[derive(Debug)]
pub enum ShMemErr {
Windows(String),
}
} else if #[cfg(unix)] {
#[derive(Debug)]
... | code_fim | medium | {
"lang": "rust",
"repo": "CarterFendley/typed_shmem",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deltaphc/raylib-rs path: /samples/options.rs
// #[macro_use]
// extern crate structopt;
pub use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "example", about = "An example of StructOpt usage.")]
pub struct Opt {
#[structopt(short = "w", long = "width", default_value... | code_fim | hard | {
"lang": "rust",
"repo": "deltaphc/raylib-rs",
"path": "/samples/options.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|>height)
.title(name)
.build();
let logo = raylib::prelude::Image::load_image("static/logo.png").unwrap();
rl.set_window_icon(&logo);
rl.set_target_fps(self.fps);
(rl, thread)
}
}<|fim_prefix|>// repo: deltaphc/raylib-rs path: /samples/options.rs... | code_fim | hard | {
"lang": "rust",
"repo": "deltaphc/raylib-rs",
"path": "/samples/options.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Implements the `Mul` trait for `Real` with `&Vector3`
impl<'a> Mul<&'a Vector3> for Real {
type Output = Vector3;
fn mul(self, rhs: &'a Vector3) -> Vector3 {
Vector3 {
x: self * rhs.x,
y: self * rhs.y,
z: self * rhs.z,
pad: 0.0
}... | code_fim | hard | {
"lang": "rust",
"repo": "reesmanp/cyclone_rs",
"path": "/src/core/vector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
x: 0.0,
y: 0.0,
z: 0.0,
pad: 0.0
}
}
}
/// Implements the `Add` trait for `Vector3` with `Self`
impl Add<Self> for Vector3 {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self {
x: self.x + rhs... | code_fim | hard | {
"lang": "rust",
"repo": "reesmanp/cyclone_rs",
"path": "/src/core/vector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reesmanp/cyclone_rs path: /src/core/vector.rs
use crate::types::Real;
use std::ops::{Add, Mul, Div, Sub};
use std::clone::Clone;
#[allow(dead_code)]
/// Struct representing 3-Dimensional vectors
pub struct Vector3 {
pub x: Real,
pub y: Real,
pub z: Real,
pub pad: Real
}
/// Imp... | code_fim | hard | {
"lang": "rust",
"repo": "reesmanp/cyclone_rs",
"path": "/src/core/vector.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: betrusted-io/betrusted-ec path: /sw/betrusted-hal/src/lib.rs
#![no_std]
extern crate bitflags;
extern crate volatile;
extern crate utralib;
extern crate riscv;
<|fim_suffix|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_middle|>pub mod hal_... | code_fim | hard | {
"lang": "rust",
"repo": "betrusted-io/betrusted-ec",
"path": "/sw/betrusted-hal/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ikubetoomuzik/advent_of_code path: /2022/src/bin/day_one_two.rs
use aoc_2022::bubble_sort;
use std::io::read_to_string;
fn main() -> std::io::Result<()> {
let mut elve_calories: Vec<u32> = vec![0];
let mut num_elves = 0;
let file = std::fs::File::open("files/input_day1")?;
for... | code_fim | medium | {
"lang": "rust",
"repo": "ikubetoomuzik/advent_of_code",
"path": "/2022/src/bin/day_one_two.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> bubble_sort(&mut elve_calories);
println!(
"The total carried by the top 3 elves is: {}",
elve_calories[..3].iter().sum::<u32>()
);
Ok(())
}<|fim_prefix|>// repo: ikubetoomuzik/advent_of_code path: /2022/src/bin/day_one_two.rs
use aoc_2022::bubble_sort;
use std::io::read_... | code_fim | medium | {
"lang": "rust",
"repo": "ikubetoomuzik/advent_of_code",
"path": "/2022/src/bin/day_one_two.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rap
(
)
;
assert_eq
!
(
1
metrics
.
injection_queue_depth
(
)
)
;
let
rt
=
threaded
(
)
;
let
handle
=
rt
.
handle
(
)
.
clone
(
)
;
let
metrics
=
rt
.
metrics
(
)
;
/
/
First
we
need
to
block
the
runtime
workers
let
(
tx1
rx1
)
=
std
:
:
sync
:
:
mpsc
:
:
channel
(
)
;
let
(
tx2
rx2
)
=
std
:
:
sync
:
:
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/rt_metrics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio/tests/rt_metrics.rs
#
!
[
warn
(
rust_2018_idioms
)
]
#
!
[
cfg
(
all
(
feature
=
"
full
"
tokio_unstable
)
)
]
use
tokio
:
:
runtime
:
:
Runtime
;
use
tokio
:
:
time
:
:
{
self
Duration
}
;
#
[
test
]
fn
num_workers
(
)
{
let
rt
=
basic
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/rt_metrics.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vangroan/vuur path: /crates/vuur_parse/src/block.rs
use vuur_lexer::TokenKind;
use crate::{stmt::DefStmt, syntax_err, Parse};
#[derive(Debug)]
pub struct Block {
pub stmts: Vec<DefStmt>,
}
impl Parse for Block {
type Output = Self;
fn parse(input: &mut crate::stream::TokenStream)... | code_fim | hard | {
"lang": "rust",
"repo": "vangroan/vuur",
"path": "/crates/vuur_parse/src/block.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(kind) => Err(syntax_err(format!(
"unexpected token {}; block closing brace must be followed by newline, semicolon or eof.",
kind
))),
}
}
}<|fim_prefix|>// repo: vangroan/vuur path: /crates/vuur_parse/src/block.rs
use vuur_lexer::To... | code_fim | hard | {
"lang": "rust",
"repo": "vangroan/vuur",
"path": "/crates/vuur_parse/src/block.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some(token) = input.peek() {
match token.kind {
T::Newline | T::Whitespace => {
// When the statement starts with a newline, it's blank.
input.next_token();
continue;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "vangroan/vuur",
"path": "/crates/vuur_parse/src/block.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Dramsim3Wrapper<'a> {
pub fn send(&mut self, addr: u64, is_write: bool) -> bool {
unsafe {
let dramsim_ptr = self.data as *mut libc::c_void;
let ret = dramsim3_send(dramsim_ptr, addr, is_write as libc::boolean_t);
match ret {
0 => fa... | code_fim | hard | {
"lang": "rust",
"repo": "shenjiangqiu/dramsim3-wrapper",
"path": "/src/wrapper/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shenjiangqiu/dramsim3-wrapper path: /src/wrapper/mod.rs
use libc;
mod extern_api;
use extern_api::*;
#[cfg(test)]
mod tests {
use std::collections::HashSet;
#[test]
fn get_channel_id_test() {
use super::Dramsim3Wrapper;
let mut dramsim = Dramsim3Wrapper::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "shenjiangqiu/dramsim3-wrapper",
"path": "/src/wrapper/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match dramsim3_available(dramsim_ptr, addr, is_write as libc::boolean_t) {
0 => false,
_ => true,
}
}
}
pub fn get_channel_id(&mut self, addr: u64) -> i32 {
unsafe {
let dramsim_ptr = self.data as *mut libc::c_void... | code_fim | hard | {
"lang": "rust",
"repo": "shenjiangqiu/dramsim3-wrapper",
"path": "/src/wrapper/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>erialize, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Interval {
Second,
Minute,
Day,
}<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /crates/openlimits-binance/src/model/interval.rs
use serde::Deserialize;
use serde::Serialize;
/// This enu<|fim_middle|>m represents a ... | code_fim | easy | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/crates/openlimits-binance/src/model/interval.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>E")]
pub enum Interval {
Second,
Minute,
Day,
}<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /crates/openlimits-binance/src/model/interval.rs
use serde::Deserialize;
use serde::Serialize;
/// This enum represents a time interval
#[derive(Debug, Serialize, Des<|fim_middle|>erialize, Clone... | code_fim | easy | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/crates/openlimits-binance/src/model/interval.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /crates/openlimits-binance/src/model/interval.rs
use serde::Deserialize;
use serde::Serialize;
/// This enu<|fim_suffix|>erialize, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Interval {
Second,
Minute,
Day,
}<|fim_middle|>m represents a ... | code_fim | easy | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/crates/openlimits-binance/src/model/interval.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kyledj/llamadb path: /src/queryplan/source.rs
use identifier::Identifier;
pub struct TableOrSubquery
{
pub source_id: u32,
pub out_column_names: Vec<Identifier>
}
pub struct SourceScope<'a>
{
parent: Option<&'a SourceScope<'a>>,
tables: Vec<TableOrSubquery>,
table_aliases: ... | code_fim | hard | {
"lang": "rust",
"repo": "kyledj/llamadb",
"path": "/src/queryplan/source.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn tables(&self) -> &[TableOrSubquery] { &self.tables }
pub fn get_column_offset(&self, column_name: &Identifier) -> Option<(u32, u32)> {
let mut candidates = get_candidates(self.tables.iter(), column_name);
candidates.extend(self.parent.and_then(|parent| {
parent... | code_fim | hard | {
"lang": "rust",
"repo": "kyledj/llamadb",
"path": "/src/queryplan/source.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> candidates.extend(self.parent.and_then(|parent| {
parent.get_column_offset(column_name)
}).into_iter());
if candidates.len() == 1 {
Some(candidates[0])
} else {
None
}
}
pub fn get_table_column_offset(&self, table_name: ... | code_fim | hard | {
"lang": "rust",
"repo": "kyledj/llamadb",
"path": "/src/queryplan/source.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.