text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>/// Copy the contents of `transactions_root` field to `output`. Key assumption: exactly 32 bytes of
/// memory have been allocated at the address pointed-to by `output`.
#[no_mangle]
pub unsafe extern "C" fn ergo_lib_block_header_transactions_root(
block_header_ptr: ConstBlockHeaderPtr,
output: *m... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/bindings/ergo-lib-c/src/block_header.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ergoplatform/sigma-rust path: /bindings/ergo-lib-c/src/block_header.rs
//! Block header
use paste::paste;
use ergo_lib_c_core::{
block_header::{
block_header_from_json, block_header_id, block_header_transactions_root, block_id_from_str,
BlockHeader, BlockHeaderPtr, BlockId, ... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/bindings/ergo-lib-c/src/block_header.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Delete `BlockId`
#[no_mangle]
pub unsafe extern "C" fn ergo_lib_block_id_delete(ptr: BlockIdPtr) {
delete_ptr(ptr)
}
make_collection!(BlockHeaders, BlockHeader);
make_ffi_eq!(BlockHeader);
make_collection!(BlockIds, BlockId);
make_ffi_eq!(BlockId);<|fim_prefix|>// repo: ergoplatform/sigma-rust p... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/bindings/ergo-lib-c/src/block_header.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pourplusquoi/db-rust path: /src/buffer/buffer_pool_manager.rs
s on disk, to read a disk page into the buffer pool and pin
// it, also to unpin a page in the buffer pool.
use crate::buffer::lru_replacer::LRUReplacer;
use crate::buffer::replacer::Replacer;
use crate::common::config::PageId;
use c... | code_fim | hard | {
"lang": "rust",
"repo": "pourplusquoi/db-rust",
"path": "/src/buffer/buffer_pool_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pourplusquoi/db-rust path: /src/buffer/buffer_pool_manager.rs
d::ops::Drop;
// Struct members are split into |data| and |actor|, because this makes it
// possible to hold mutable borrow on |actor| while acquiring mutable/immutable
// borrow on |data|.
pub struct BufferPoolManager<T, R>
where
... | code_fim | hard | {
"lang": "rust",
"repo": "pourplusquoi/db-rust",
"path": "/src/buffer/buffer_pool_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // All the pages are pinned, the buffer pool is full.
for _ in 10..15 {
assert!(bpm.new_page().is_err());
}
// Upin the first five pages, add them to LRU list, set as dirty.
for i in 0..5 {
assert!(bpm
.unpin_page(i + HEADER_... | code_fim | hard | {
"lang": "rust",
"repo": "pourplusquoi/db-rust",
"path": "/src/buffer/buffer_pool_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: srijs/rust-simdop path: /src/arch/arm/neon/i32x4.rs
extern crate llvmint;
use super::super::super::super::*;
use super::super::super::super::core::*;
use super::super::NEON;
<|fim_suffix|> unsafe {
Multi::wrap(llvmint::arm::neon_vpadd_v4i32(a.unwrap(), b.unwrap()))
}
}
}<|fim_mi... | code_fim | hard | {
"lang": "rust",
"repo": "srijs/rust-simdop",
"path": "/src/arch/arm/neon/i32x4.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
Multi::wrap(llvmint::arm::neon_vpadd_v4i32(a.unwrap(), b.unwrap()))
}
}
}<|fim_prefix|>// repo: srijs/rust-simdop path: /src/arch/arm/neon/i32x4.rs
extern crate llvmint;
use super::super::super::super::*;
use super::super::super::super::core::*;
use super::super::NEON;
impl Set... | code_fim | medium | {
"lang": "rust",
"repo": "srijs/rust-simdop",
"path": "/src/arch/arm/neon/i32x4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sugyan/leetcode path: /others/july-leetcoding-challenge/week-1/3382/lib.rs
pub struct Solution {}
impl Solution {
pub fn plus_one(digits: Vec<i32>) -> Vec<i32> {
let mut digits: Vec<i32> = digits;
let mut idx = digits.len() - 1;
loop {
if digits[idx] == 9... | code_fim | medium | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/july-leetcoding-challenge/week-1/3382/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(vec![1, 2, 4], Solution::plus_one(vec![1, 2, 3]));
}
#[test]
fn example_2() {
assert_eq!(vec![4, 3, 2, 2], Solution::plus_one(vec![4, 3, 2, 1]));
}
}<|fim_prefix|>// repo: sugyan/leetcode path: /others/july-leetcoding-challenge/week-1/3382/lib.rs
pub struct Sol... | code_fim | medium | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/july-leetcoding-challenge/week-1/3382/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn example_2() {
assert_eq!(vec![4, 3, 2, 2], Solution::plus_one(vec![4, 3, 2, 1]));
}
}<|fim_prefix|>// repo: sugyan/leetcode path: /others/july-leetcoding-challenge/week-1/3382/lib.rs
pub struct Solution {}
impl Solution {
pub fn plus_one(digits: Vec<i32>) -> Vec<i32> {... | code_fim | medium | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/july-leetcoding-challenge/week-1/3382/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Smithay/smithay path: /src/wayland/dmabuf/dispatch.rs
use std::sync::{atomic::AtomicBool, Mutex};
use tracing::error;
use wayland_protocols::wp::linux_dmabuf::zv1::server::{
zwp_linux_buffer_params_v1, zwp_linux_dmabuf_feedback_v1, zwp_linux_dmabuf_v1,
};
use wayland_server::{
protocol... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/wayland/dmabuf/dispatch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(surface) = data.surface.as_ref().and_then(|s| s.upgrade().ok()) {
compositor::with_states(&surface, |states| {
if let Some(surface_state) = states.data_map.get::<SurfaceDmabufFeedbackState>() {
surface_stat... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/wayland/dmabuf/dispatch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flammel/rustasata path: /benches/benchmark.rs
#[macro_use]
extern crate criterion;
extern crate rustasata;
use criterion::Criterion;
use rustasata::parser::parse_file;
use rustasata::solver::Solver;
<|fim_suffix|>criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);<|fim_m... | code_fim | hard | {
"lang": "rust",
"repo": "flammel/rustasata",
"path": "/benches/benchmark.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);<|fim_prefix|>// repo: flammel/rustasata path: /benches/benchmark.rs
#[macro_use]
extern crate criterion;
extern crate rustasata;
use criterion::Criterion;
use rustasata::parser::parse_file;
use rustasata::solver::Solver;
<|fim_m... | code_fim | hard | {
"lang": "rust",
"repo": "flammel/rustasata",
"path": "/benches/benchmark.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // s + "s"
s.push_str("s");
s
}<|fim_prefix|>// repo: hessifer/Rust path: /rust_lab_local/borrowing/src/main.rs
fn main() {
let mut s = String::from("book");
<|fim_middle|> println!("The value of s is now {}.", pluralize(&mut s));
}
// Add appropriate parameters, return values, and... | code_fim | medium | {
"lang": "rust",
"repo": "hessifer/Rust",
"path": "/rust_lab_local/borrowing/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hessifer/Rust path: /rust_lab_local/borrowing/src/main.rs
fn main() {
let mut s = String::from("book");
println!("The value of s is now {}.", pluralize(&mut s));
}
<|fim_suffix|> // s + "s"
s.push_str("s");
s
}<|fim_middle|>// Add appropriate parameters, return values, and... | code_fim | medium | {
"lang": "rust",
"repo": "hessifer/Rust",
"path": "/rust_lab_local/borrowing/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: google/tock-on-titan path: /third_party/futures-util/src/stream/try_stream/try_concat.rs
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::stream::TryStream;
use futures_core::task::{Context, Poll};
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Future for the [`try_... | code_fim | medium | {
"lang": "rust",
"repo": "google/tock-on-titan",
"path": "/third_party/futures-util/src/stream/try_stream/try_concat.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<St> Future for TryConcat<St>
where
St: TryStream,
St::Ok: Extend<<St::Ok as IntoIterator>::Item> + IntoIterator + Default,
{
type Output = Result<St::Ok, St::Error>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop {
match ready... | code_fim | hard | {
"lang": "rust",
"repo": "google/tock-on-titan",
"path": "/third_party/futures-util/src/stream/try_stream/try_concat.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn push(&mut self, col: Column) {
self.data.push(col);
}
pub fn data(&self) -> &Vec<Column> {
&self.data
}
pub fn names(&self) -> Vec<&'static str> {
self.data.iter().map(|v| v.name).collect()
}
pub fn validate_params(
&self,
params: &[Param]
) -> Result<(), ValidateParamsError> {... | code_fim | medium | {
"lang": "rust",
"repo": "fire-lib/fire-postgres",
"path": "/fire-postgres/src/table/info.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn validate_params(
&self,
params: &[Param]
) -> Result<(), ValidateParamsError> {
'param_loop: for param in params {
for col in &self.data {
if param.name != col.name {
continue
}
if param.kind == col.kind {
continue 'param_loop
} else {
return Err(ValidateP... | code_fim | hard | {
"lang": "rust",
"repo": "fire-lib/fire-postgres",
"path": "/fire-postgres/src/table/info.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fire-lib/fire-postgres path: /fire-postgres/src/table/info.rs
use super::column::Column;
use crate::query::Param;
#[derive(Debug, Clone)]
pub struct Info {
data: Vec<Column>
}
impl Info {
pub fn new(data: Vec<Column>) -> Self {
Self { data }
}
<|fim_suffix|> if param.kind == col.ki... | code_fim | hard | {
"lang": "rust",
"repo": "fire-lib/fire-postgres",
"path": "/fire-postgres/src/table/info.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /lib/bobbin-build/src/lib.rs
//! This crate provides build-time functionality.
use std::env;
use std::io;
use std::fs;
use std::path::{PathBuf, Path};
/// Searches for a linker script in `link/` based on enabled Cargo features and copies it to the top
/// crate's bui... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/lib/bobbin-build/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for dir_entry in ld_dir.as_ref().read_dir()? {
if let Ok(dir_entry) = dir_entry {
let path = dir_entry.path();
if let Some(ext) = path.extension() {
if ext == "ld"{
let var = format!("CARGO_FEATURE_{}", path.file_stem().unwrap().to_st... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/lib/bobbin-build/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn empty_profile(typ: &str) -> Result<String, String> {
let p = match typ {
"null" => {
serde_json::from_str(NULL_PROFILE).map_err(|e| format!("error reading skeleton {}", e))
}
"rust" => Ok(Profile::default()),
_ => Err(String::from("only: null, create,... | code_fim | medium | {
"lang": "rust",
"repo": "fiji-flo/person-cli-rs",
"path": "/src/create.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn create_new_user(
user_id: String,
primary_email: String,
first_name: String,
last_name: Option<String>,
) -> Result<Profile, Error> {
let now = &Utc::now();
let mut p: Profile = serde_json::from_str(NULL_PROFILE)?;
p.primary_email.value = Some(primary_email);
update_... | code_fim | hard | {
"lang": "rust",
"repo": "fiji-flo/person-cli-rs",
"path": "/src/create.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fiji-flo/person-cli-rs path: /src/create.rs
use chrono::DateTime;
use chrono::Utc;
use cis_profile::schema::Display;
use cis_profile::schema::Metadata;
use cis_profile::schema::Profile;
use failure::Error;
const NULL_PROFILE: &str = include_str!("data/user_profile_null.json");
fn update_metada... | code_fim | medium | {
"lang": "rust",
"repo": "fiji-flo/person-cli-rs",
"path": "/src/create.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut window: Window = WindowSettings::new("mandelbrot", [200, 200])
.graphics_api(opengl)
.exit_on_esc(true)
.build()
.unwrap();
let zl = ZoomLocation {
re: -1.74999841099374081749002,
im: -0.00000000000000165712469,
zoom: 100.0,
... | code_fim | hard | {
"lang": "rust",
"repo": "selfint/rust-mandelbrot-set",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_app(RenderMode::Slow);
run_app(RenderMode::Fast);
}
fn run_app(render_mode: RenderMode) {
let opengl = OpenGL::V3_2;
let mut window: Window = WindowSettings::new("mandelbrot", [200, 200])
.graphics_api(opengl)
.exit_on_esc(true)
.build()
.unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "selfint/rust-mandelbrot-set",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: selfint/rust-mandelbrot-set path: /src/main.rs
use std::time::Instant;
use angular_units::Deg;
use glutin_window::GlutinWindow as Window;
use graphics::*;
use opengl_graphics::{GlGraphics, OpenGL};
use piston::event_loop::{EventSettings, Events};
use piston::input::{RenderArgs, RenderEvent, Upd... | code_fim | hard | {
"lang": "rust",
"repo": "selfint/rust-mandelbrot-set",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jlikhuva/Formation path: /src/splay_tree.rs
entry from
/// a key value tuple
///
/// # Example
///
/// ```
/// let entry: Entry<&str, usize> = ("usa", 245).into();
/// ```
fn from(e: (K, V)) -> Self {
Entry { key: e.0, value: e.1 }
}
}
/// A single no... | code_fim | hard | {
"lang": "rust",
"repo": "jlikhuva/Formation",
"path": "/src/splay_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> todo!()
}
fn transplant(nodes: &mut Nodes<K, V>, left: SplayNodeIdx) {
todo!()
}
fn swap_remove(nodes: &mut Nodes<K, V>, delete_idx: SplayNodeIdx) -> Option<V> {
todo!()
}
}
/// Implementation of the bottom up splay operation
impl<K: Ord, V> SplayTree<K, V> {... | code_fim | hard | {
"lang": "rust",
"repo": "jlikhuva/Formation",
"path": "/src/splay_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jlikhuva/Formation path: /src/splay_tree.rs
igZig(ChildType),
/// A node is in a ZigZag configuration if
/// it is left child of a right child or
/// a right child of a left child
ZigZag(ChildType),
}
/// We use the new type index pattern to make our code more
/// understandabl... | code_fim | hard | {
"lang": "rust",
"repo": "jlikhuva/Formation",
"path": "/src/splay_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn custom(desc: &'static str, func: impl Fn(&Item) -> bool + 'static) -> Filter {
Filter::Custom { desc: s(desc), func: Rc::new(func) }
}<|fim_prefix|>// repo: cyb0124/OCRemote path: /server/RustImpl/src/config_util.rs
use super::item::{Filter, Item};
use flexstr::LocalStr;
use std::rc::Rc;
<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "cyb0124/OCRemote",
"path": "/server/RustImpl/src/config_util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyb0124/OCRemote path: /server/RustImpl/src/config_util.rs
use super::item::{Filter, Item};
use flexstr::LocalStr;
use std::rc::Rc;
<|fim_suffix|>pub fn custom(desc: &'static str, func: impl Fn(&Item) -> bool + 'static) -> Filter {
Filter::Custom { desc: s(desc), func: Rc::new(func) }
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "cyb0124/OCRemote",
"path": "/server/RustImpl/src/config_util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: masonk/advent2017 path: /src/11/11.1.rs
// --- Day 11: Hex Ed ---
// Crossing the bridge, you've barely reached the other side of the stream when a program comes up to you, clearly in distress. "It's my child process," she says, "he's gotten lost in an infinite grid!"
// Fortunately for he... | code_fim | hard | {
"lang": "rust",
"repo": "masonk/advent2017",
"path": "/src/11/11.1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lateral = (other.right - self.right).abs();
let vertical = (other.up - self.right).abs();
(lateral * 2.0 + (vertical - lateral).max(0.0)).ceil()
}
}
fn process_move_list<'a, T>(cursor: &mut HexVector, moves: T, start: &HexVector) -> (f32, HexVector)
where T: Int... | code_fim | hard | {
"lang": "rust",
"repo": "masonk/advent2017",
"path": "/src/11/11.1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let is_mouse_over = bounds.contains(cursor_position);
let (checkbox_border, checkbox_box) = (
Primitive::Quad {
bounds: checkbox_bounds,
background: Background::Color([0.6, 0.6, 0.6].into()),
border_radius: 6,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "simlay/iced",
"path": "/wgpu/src/renderer/widget/checkbox.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simlay/iced path: /wgpu/src/renderer/widget/checkbox.rs
use crate::{Primitive, Renderer};
use iced_native::{
checkbox, text, text::HorizontalAlignment, text::VerticalAlignment, Align,
Background, Checkbox, Column, Layout, Length, MouseCursor, Node,
Point, Rectangle, Row, Text, Widget... | code_fim | hard | {
"lang": "rust",
"repo": "simlay/iced",
"path": "/wgpu/src/renderer/widget/checkbox.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match ext.to_lowercase().as_str() {
"lua" => Box::new(LuaScript::new(&path)),
"p8" => Box::new(P8Script::new(&path)),
"rs8" => Box::new(Wars8Binary::new(&path)),
"wasm" => Box::new(WasmBinary::new(&path)),
_ => panic!("Unknown format: {}"... | code_fim | hard | {
"lang": "rust",
"repo": "EliseZeroTwo/WARS-8",
"path": "/src/cart/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EliseZeroTwo/WARS-8 path: /src/cart/mod.rs
pub mod lua_script;
pub mod p8_script;
pub mod wars_8_binary;
pub mod wasm_binary;
use lua_script::LuaScript;
use p8_script::P8Script;
use crate::runtime::Runtime;
use self::{wars_8_binary::Wars8Binary, wasm_binary::WasmBinary};
pub trait Cart: Send ... | code_fim | hard | {
"lang": "rust",
"repo": "EliseZeroTwo/WARS-8",
"path": "/src/cart/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub mod crypto;
pub mod dsync;
pub mod ellipses;
pub mod encrypt;
pub mod endpoint;
pub mod erasure;
pub mod errors;
pub mod etag;
pub mod event;
pub mod format;
pub mod fs;
pub mod globals;
pub mod hash;
pub mod http;
pub mod iam;
pub mod io;
pub mod jwt;
pub mod lock;
pub mod logger;
pub mod macros;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "01intelligence/hulk",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 01intelligence/hulk path: /src/lib.rs
#![feature(test)]
#![feature(backtrace)]
#![feature(backtrace_frames)]
#![feature(type_name_of_val)]
#![feature(once_cell)]
#![feature(duration_constants)]
#![feature(destructuring_assignment)]
#![feature(assert_matches)]
#![feature(trait_alias)]
#![feature(... | code_fim | hard | {
"lang": "rust",
"repo": "01intelligence/hulk",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>t;
pub mod object;
pub mod objectcache;
pub mod pool;
pub mod prelude;
pub mod proto;
pub mod pubsub;
pub mod router;
pub mod rpc;
pub mod s3select;
pub mod s3utils;
pub mod serde;
pub mod signals;
pub mod storage;
pub mod strset;
pub(crate) mod sys;
pub mod tags;
pub mod trie;
pub mod utils;
pub mod vers... | code_fim | hard | {
"lang": "rust",
"repo": "01intelligence/hulk",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[doc(hidden)]
pub struct RTDCallBuilder {
inner: Call
}
impl RTDCallBuilder {
pub fn build(&self) -> Call { self.inner.clone() }
pub fn id(&mut self, id: i64) -> &mut Self {
self.inner.id = id;
self
}
pub fn user_id(&mut self, user_id: i64) -> &mut Self {
self.inner.user_... | code_fim | hard | {
"lang": "rust",
"repo": "fewensa/rtdlib",
"path": "/src/types/call.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_video(&self) -> bool { self.is_video }
pub fn state(&self) -> &CallState { &self.state }
}
#[doc(hidden)]
pub struct RTDCallBuilder {
inner: Call
}
impl RTDCallBuilder {
pub fn build(&self) -> Call { self.inner.clone() }
pub fn id(&mut self, id: i64) -> &mut Self {
self.in... | code_fim | hard | {
"lang": "rust",
"repo": "fewensa/rtdlib",
"path": "/src/types/call.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fewensa/rtdlib path: /src/types/call.rs
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
/// Describes a call
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Call {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: Strin... | code_fim | hard | {
"lang": "rust",
"repo": "fewensa/rtdlib",
"path": "/src/types/call.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(x) = mc.instructions.get(&key) {
let mut sig = 0u64;
for elem in x.iter() {
let bitindex = match cd.signals.get(elem) {
Some(&x) => x,
None => return Err(GenError::InvalidSignalName),
};
... | code_fim | hard | {
"lang": "rust",
"repo": "YukeSi/mips-x",
"path": "/mcgen/src/gen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YukeSi/mips-x path: /mcgen/src/gen.rs
use serde::{Serialize, Deserialize};
use std::collections::BTreeMap;
/// Definitions of control signals.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ControlDefinition {
/// Mappings from signals to their bit indices.
///
/// Vali... | code_fim | hard | {
"lang": "rust",
"repo": "YukeSi/mips-x",
"path": "/mcgen/src/gen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spaceships/combustion path: /src/clock.rs
use std::fmt;
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use std::time::{Duration, Instant};
pub struct Clock {
init: isize,
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
}
fn spawn_updater_thread(
time_left: Arc<... | code_fim | hard | {
"lang": "rust",
"repo": "spaceships/combustion",
"path": "/src/clock.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Clock {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let csecs = self.time_remaining();
let secs = csecs / 100;
if secs <= 0 {
let min = -secs / 60;
write!(f, "-{:01}:{:02}", min, (-secs) - min * 60)
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "spaceships/combustion",
"path": "/src/clock.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn time_remaining(&self) -> isize {
*self.time_left.lock().unwrap()
}
}
impl fmt::Display for Clock {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let csecs = self.time_remaining();
let secs = csecs / 100;
if secs <= 0 {
let min = -sec... | code_fim | hard | {
"lang": "rust",
"repo": "spaceships/combustion",
"path": "/src/clock.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write(&mut self, frame: &Mat<BGR>) -> Result<()> {
ensure!(
frame.n_cols() == self.width,
UserInput {
msg: format!("width incompatible - frame: {}, video: {}", frame.n_cols(), self.width)
}
);
ensure!(
fram... | code_fim | hard | {
"lang": "rust",
"repo": "section77/airhobot",
"path": "/cv/src/videoio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: section77/airhobot path: /cv/src/videoio.rs
use crate::*;
use opencv::videoio::{
VideoCapture as OpencvVideoCapture, VideoCaptureTrait, VideoWriter as OpencvVideoWriter, VideoWriterTrait, CAP_ANY,
};
use snafu::ensure;
use std::path::Path;
pub struct VideoCapture {
inner: OpencvVideoCap... | code_fim | hard | {
"lang": "rust",
"repo": "section77/airhobot",
"path": "/cv/src/videoio.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn send_level(port: &mut SerialPort, level: &String) -> bool {
let mut buf = String::new();
let mut should_send = false;
for b in port.bytes() {
match std::char::from_u32(b.unwrap() as u32).unwrap() {
'\n' if buf.trim() == "ready" => {
should_send = true;
... | code_fim | hard | {
"lang": "rust",
"repo": "leroycep/arduino-game",
"path": "/level_editor/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buf = String::new();
let mut should_send = false;
for b in port.bytes() {
match std::char::from_u32(b.unwrap() as u32).unwrap() {
'\n' if buf.trim() == "ready" => {
should_send = true;
break;
},
'\n' => buf.cl... | code_fim | hard | {
"lang": "rust",
"repo": "leroycep/arduino-game",
"path": "/level_editor/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leroycep/arduino-game path: /level_editor/src/main.rs
extern crate serial;
use std::env;
use std::io;
use std::time::Duration;
use std::process::exit;
use std::thread::sleep;
use std::io::prelude::*;
use serial::prelude::*;
fn main() {
let args: Vec<String> = env::args().skip(1).collect(... | code_fim | hard | {
"lang": "rust",
"repo": "leroycep/arduino-game",
"path": "/level_editor/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SergejJurecko/native-ui path: /src/os/macos/mod.rs
// #[cfg(target_os = "macos")]
extern crate cocoa;
use self::cocoa::appkit::{NSApp, NSApplication, NSApplicationDefined};
use self::cocoa::appkit::{NSEvent, NSEventModifierFlags, NSEventSubtype};
use self::cocoa::base::nil;
use self::cocoa::foun... | code_fim | hard | {
"lang": "rust",
"repo": "SergejJurecko/native-ui",
"path": "/src/os/macos/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn init(cfg: Option<::Config>) {
unsafe {
let app = NSApp();
app.activateIgnoringOtherApps_(1);
let cfg = cfg.unwrap_or_default();
Tray::tray_only(cfg.tray_only);
}
}
pub(crate) fn post_empty_event() {
unsafe {
let event =
NSE... | code_fim | medium | {
"lang": "rust",
"repo": "SergejJurecko/native-ui",
"path": "/src/os/macos/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn post_empty_event() {
unsafe {
let event =
NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_(
nil,
NSApplicationDefined,
NSPoint::new(0.0, 0.0),
NSE... | code_fim | hard | {
"lang": "rust",
"repo": "SergejJurecko/native-ui",
"path": "/src/os/macos/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hawkw/mycelium path: /hal-x86_64/src/framebuffer.rs
use core::{
fmt,
ops::{Deref, DerefMut},
};
use hal_core::framebuffer::{Draw, RgbColor};
use volatile::Volatile;
pub struct Framebuffer<'buf, B: Deref<Target = [u8]>> {
/// A reference to the framebuffer itself.
///
/// Thi... | code_fim | hard | {
"lang": "rust",
"repo": "hawkw/mycelium",
"path": "/hal-x86_64/src/framebuffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
PixelKind::Bgr => [blue, green, red, 0],
PixelKind::Rgb => [red, green, blue, 0],
PixelKind::Gray => [Self::rgb_to_luminance(red, green, blue), 0, 0, 0],
}
}
fn rgb_to_luminance(r: u8, g: u8, b: u8) -> u8 {
// Thanks to @mys... | code_fim | hard | {
"lang": "rust",
"repo": "hawkw/mycelium",
"path": "/hal-x86_64/src/framebuffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_pixel(&mut self, x: usize, y: usize, color: RgbColor) -> &mut Self {
self.set_pixel_rgb(x, y, color)
}
fn scroll_vert(&mut self, amount: isize) -> &mut Self {
if amount < 0 {
todo!("eliza: handle negatives!")
}
let amount_px = (amount as usiz... | code_fim | hard | {
"lang": "rust",
"repo": "hawkw/mycelium",
"path": "/hal-x86_64/src/framebuffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanchen1991/rune path: /crates/rune/src/ast/expr_return.rs
use crate::ast;
use crate::{Parse, Spanned, ToTokens};
/// A return statement `r<|fim_suffix|>eturn {
/// The return token.
pub return_: ast::Return,
/// An optional expression to return.
#[rune(iter)]
pub expr: Opt... | code_fim | medium | {
"lang": "rust",
"repo": "seanchen1991/rune",
"path": "/crates/rune/src/ast/expr_return.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>eturn {
/// The return token.
pub return_: ast::Return,
/// An optional expression to return.
#[rune(iter)]
pub expr: Option<Box<ast::Expr>>,
}<|fim_prefix|>// repo: seanchen1991/rune path: /crates/rune/src/ast/expr_return.rs
use crate::ast;
use crate::{Parse, Spanned, ToTokens};
///... | code_fim | medium | {
"lang": "rust",
"repo": "seanchen1991/rune",
"path": "/crates/rune/src/ast/expr_return.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new(previous: Option<Block>)
-> Block {
Block {
num: chain::get_block_count(),
time: clock::get_time_now(),
text: String::new(),
hash: String::new(),
prev_hash: match previous {
Some(block) => {
let hash: &str = &*b... | code_fim | medium | {
"lang": "rust",
"repo": "AppliedPoetics/pilcrow",
"path": "/src/blocks/block.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn calc_hash(&mut self) {
let mut hashed = String::new();
let mut hasher = Sha256::default();
let mut hashable = self.num.to_string();
hashable.push_str(&self.time);
hashable.push_str(&self.text);
hashable.push_str(&self.prev_hash);
hasher.input(hashable);
le... | code_fim | hard | {
"lang": "rust",
"repo": "AppliedPoetics/pilcrow",
"path": "/src/blocks/block.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AppliedPoetics/pilcrow path: /src/blocks/block.rs
use crate::chain;
use crate::clock;
use sha2::{Sha256, Digest};
use serde::{Serialize, Deserialize};
use serde_json;
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Block {
pub num: usize,
pub time: String,
pub text: S... | code_fim | hard | {
"lang": "rust",
"repo": "AppliedPoetics/pilcrow",
"path": "/src/blocks/block.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> StateStack<T> {
pub fn new(task: T) -> Self {
StateStack { stack: vec![task] }
}
pub fn transition(&mut self, op: StackOp<T>) {
match op {
StackOp::None => {}
StackOp::Done => {
self.stack.pop();
}
StackOp... | code_fim | medium | {
"lang": "rust",
"repo": "mbillingr/halite3-bot",
"path": "/src/pda.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn transition(&mut self, op: StackOp<T>) {
match op {
StackOp::None => {}
StackOp::Done => {
self.stack.pop();
}
StackOp::Push(task) => self.stack.push(task),
StackOp::Override(task) => {
self.stack... | code_fim | medium | {
"lang": "rust",
"repo": "mbillingr/halite3-bot",
"path": "/src/pda.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbillingr/halite3-bot path: /src/pda.rs
#[derive(Debug)]
pub enum StackOp<T> {
None,
Done,
Push(T),
Override(T),
}
#[derive(Debug)]
pub struct StateStack<T> {
stack: Vec<T>,
}
impl<T> Default for StateStack<T> {
fn default() -> Self {
StateStack { stack: vec![]... | code_fim | hard | {
"lang": "rust",
"repo": "mbillingr/halite3-bot",
"path": "/src/pda.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alekssamos/rust_telegram_bot path: /src/main.rs
#![feature(proc_macro, conservative_impl_trait, generators)]
extern crate futures as original_futures;
extern crate telegram_bot;
extern crate tokio_core;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern ... | code_fim | hard | {
"lang": "rust",
"repo": "alekssamos/rust_telegram_bot",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn main() {
let mut core = Core::new().unwrap();
let token = env::var("TELEGRAM_BOT_TOKEN").unwrap();
let api = Arc::new(Api::configure(token).build(core.handle()).unwrap());
let client = Arc::new(Client::new(&core.handle()));
let future = update_stream(api.clone(), client.clone());
... | code_fim | hard | {
"lang": "rust",
"repo": "alekssamos/rust_telegram_bot",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut core = Core::new().unwrap();
let token = env::var("TELEGRAM_BOT_TOKEN").unwrap();
let api = Arc::new(Api::configure(token).build(core.handle()).unwrap());
let client = Arc::new(Client::new(&core.handle()));
let future = update_stream(api.clone(), client.clone());
... | code_fim | hard | {
"lang": "rust",
"repo": "alekssamos/rust_telegram_bot",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonwingfield/reefmon path: /aquamon/src/devices/gpio.rs
use std::io as io;
use sysfs_gpio::{Pin, Direction};
use sysfs_gpio::Error as GpioError;
use std::error::Error;
use std::io::ErrorKind;
pub struct GpioPin {
pin: Pin,
active_low: bool,
}
fn from_gpio_error(e: GpioError) -> io::Err... | code_fim | hard | {
"lang": "rust",
"repo": "jonwingfield/reefmon",
"path": "/aquamon/src/devices/gpio.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn turn_off(&mut self) -> io::Result<()> {
self.pin.set_value(if self.active_low { 1 } else { 0 }).map_err(from_gpio_error)
}
pub fn status(&mut self) -> io::Result<bool> {
self.pin.get_value().map(|val| (self.active_low && val == 0) || (!self.active_low && val != 0)).map_... | code_fim | hard | {
"lang": "rust",
"repo": "jonwingfield/reefmon",
"path": "/aquamon/src/devices/gpio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lehnart/rust-games path: /pong/src/main.rs
use std::time::SystemTime;
use audio::Audio;
use collide::Collide;
use engine::audio::init_audio;
use engine::graphics::Window;
use event::handle_event;
use logic::Logic;
use crate::graphics::Graphics;
mod graphics;
mod event;
mod collide;
mod audio;... | code_fim | medium | {
"lang": "rust",
"repo": "Lehnart/rust-games",
"path": "/pong/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> logic.update(dt);
if logic.is_over() {
break 'game_loop;
}
collide.collide_ball_and_wall(&mut logic);
collide.collide_ball_and_racket(&mut logic);
graphics.update(&logic, &window);
graphics.draw(&mut window, &ttf_context);
}
}<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "Lehnart/rust-games",
"path": "/pong/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kylewlacy/glitter path: /src/macros.rs
// Used to specify checks that shouldn't fail (but might in unsafe)
macro_rules! dbg_gl_error {
($($pat:pat => $msg:expr),*) => {
if cfg!(debug_assertions) {
let err = $crate::Context::get_error();
match err {
... | code_fim | hard | {
"lang": "rust",
"repo": "kylewlacy/glitter",
"path": "/src/macros.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Create a Rust enum that maps to an OpenGL enum.
macro_rules! gl_enum {
(
$(#[$attr:meta])*
pub gl_enum $name:ident {
$(
$(#[$variant_attr:meta])*
pub const $variant:ident as $const_name:ident = $value:expr
),+
}
) =... | code_fim | hard | {
"lang": "rust",
"repo": "kylewlacy/glitter",
"path": "/src/macros.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(reader
.lines()
.filter_map(|x| x.unwrap().parse::<i32>().ok())
.sum())
}
fn main() {
ProblemHarness::new(AOC_PROBLEM, &solve).solve()
}<|fim_prefix|>// repo: bpicolo/aoc2018 path: /src/day1/part1/main.rs
use aoc::ProblemHarness;
use std::fs::File;
use std::io::{BufRe... | code_fim | medium | {
"lang": "rust",
"repo": "bpicolo/aoc2018",
"path": "/src/day1/part1/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bpicolo/aoc2018 path: /src/day1/part1/main.rs
use aoc::ProblemHarness;
use std::fs::File;
use std::io::{BufRead, BufReader};
static AOC_PROBLEM: &'static str = "1.1";
fn solve(reader: &mut BufReader<File>) -> Result<i32, String> {
Ok(reader
.lines()
.filter_map(|x| x.unwra... | code_fim | easy | {
"lang": "rust",
"repo": "bpicolo/aoc2018",
"path": "/src/day1/part1/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn solve(reader: &mut BufReader<File>) -> Result<i32, String> {
Ok(reader
.lines()
.filter_map(|x| x.unwrap().parse::<i32>().ok())
.sum())
}
fn main() {
ProblemHarness::new(AOC_PROBLEM, &solve).solve()
}<|fim_prefix|>// repo: bpicolo/aoc2018 path: /src/day1/part1/main.rs
... | code_fim | easy | {
"lang": "rust",
"repo": "bpicolo/aoc2018",
"path": "/src/day1/part1/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S, P> Stream for Parse<S, P>
where
S: Stream<Item = ServerControll>,
P: Parser,
{
type Item = ServerControll;
type Error = S::Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
match try_ready!(self.stream.poll()) {
Some(ServerControll::Comman... | code_fim | medium | {
"lang": "rust",
"repo": "azul/Samotop",
"path": "/src/protocol/parse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azul/Samotop path: /src/protocol/parse.rs
use grammar::Parser;
use model::command::SmtpCommand;
use model::controll::ServerControll;
use tokio::prelude::*;
pub trait IntoParse
where
Self: Sized,
{
fn parse<P>(self, parser: P) -> Parse<Self, P> {
Parse::new(self, parser)
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "azul/Samotop",
"path": "/src/protocol/parse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match try_ready!(self.stream.poll()) {
Some(ServerControll::Command(SmtpCommand::Unknown(line))) => {
match self.parser.command(&line) {
Ok(cmd) => Ok(Async::Ready(Some(ServerControll::Command(cmd)))),
_ => Ok(Async::Ready(Some(Se... | code_fim | hard | {
"lang": "rust",
"repo": "azul/Samotop",
"path": "/src/protocol/parse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for selected_element in element.select(&selector) {
// let html_element = element.value(); // html_element : : scraper::node::Element
elements.push(selected_element);
}
if elements.len() == 0 {
return None;
}
return Some(elements)... | code_fim | hard | {
"lang": "rust",
"repo": "fshaikh/schoolify",
"path": "/crawler/src/services/html_parser_service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_element_text(&self, element: &ElementRef) -> Option<String> {
let text = element.text().collect::<Vec<_>>();
if text.len() == 0 {
return None;
}
return Some(text[0].to_string());
}
pub fn get_attr(&self, element: &ElementRef, attr_name: &... | code_fim | hard | {
"lang": "rust",
"repo": "fshaikh/schoolify",
"path": "/crawler/src/services/html_parser_service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fshaikh/schoolify path: /crawler/src/services/html_parser_service.rs
use scraper::{element_ref::ElementRef, Html, Selector};
use crate::models::error::Error;
pub mod html_names {
pub const HREF: &str = "href";
pub const A: &str = "a";
pub const SPAN: &str = "span";
}
pub struct Ht... | code_fim | hard | {
"lang": "rust",
"repo": "fshaikh/schoolify",
"path": "/crawler/src/services/html_parser_service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn tickle() {
let regs: &mut Registers = unsafe { mem::transmute(WDOG) };
regs.refresh.write(REFRESH::KEY::Key1);
regs.refresh.write(REFRESH::KEY::Key2);
}
pub struct Wdog;
impl hil::watchdog::Watchdog for Wdog {
fn start(&self, period: usize) {
start(period);
}
fn st... | code_fim | hard | {
"lang": "rust",
"repo": "techhazard/tock-teensy",
"path": "/chips/mk20/src/wdog.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: techhazard/tock-teensy path: /chips/mk20/src/wdog.rs
//! Implementation of the MK20 hardware watchdog timer
use core::mem;
use kernel::hil;
use regs::wdog::*;
#[inline]
fn unlock() {
let regs: &mut Registers = unsafe { mem::transmute(WDOG) };
regs.unlock.write(UNLOCK::KEY::Key1);
... | code_fim | hard | {
"lang": "rust",
"repo": "techhazard/tock-teensy",
"path": "/chips/mk20/src/wdog.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dothanthitiendiettiende/rust-kernelcache-extractor path: /src/bin/kcache_extract.rs
extern crate clap;
extern crate kcacheext;
use clap::{App, Arg};
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let matches = App::new("kcache_extract")
.version(env!... | code_fim | hard | {
"lang": "rust",
"repo": "dothanthitiendiettiende/rust-kernelcache-extractor",
"path": "/src/bin/kcache_extract.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match kcacheext::extract_from_file(input_filename) {
Ok(decoded) => match output_file.write_all(&decoded) {
Err(why) => panic!(
"couldn't write to {}: {}",
output_filename,
why.description()
),
Ok(_) => println!(... | code_fim | hard | {
"lang": "rust",
"repo": "dothanthitiendiettiende/rust-kernelcache-extractor",
"path": "/src/bin/kcache_extract.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> )
.get_matches();
let input_filename = matches.value_of("input").unwrap();
let output_filename = matches.value_of("output").unwrap();
let mut output_file = match File::create(output_filename) {
// The `description` method of `io::Error` returns a string that
// descri... | code_fim | hard | {
"lang": "rust",
"repo": "dothanthitiendiettiende/rust-kernelcache-extractor",
"path": "/src/bin/kcache_extract.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>t two: f64 = 3.0 * (n - 1.0);
let three: f64 = 1.0;
println!("{:.10}", (one + two + three) / (n * n * n));
}<|fim_prefix|>// repo: tonyu0/rust-compro path: /ABC/028D.rs
use std::io::*;
fn main() {
let mut s: String = String::new();
std::io::stdin().read_to_string(&mut s).ok()<|fim_middl... | code_fim | hard | {
"lang": "rust",
"repo": "tonyu0/rust-compro",
"path": "/ABC/028D.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tonyu0/rust-compro path: /ABC/028D.rs
use std::io::*;
fn main() {
let mut s: String = String::new();
std::io::stdin().read_to_string(&mut s).ok()<|fim_suffix|>t two: f64 = 3.0 * (n - 1.0);
let three: f64 = 1.0;
println!("{:.10}", (one + two + three) / (n * n * n));
}<|fim_middl... | code_fim | hard | {
"lang": "rust",
"repo": "tonyu0/rust-compro",
"path": "/ABC/028D.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/flake8_async/rules/mod.rs
pub(crate) use blocking_http_call::*;
pub(crate) use blocking_os_call::*;
pub(crate) use open_sleep_or<|fim_suffix|>locking_os_call;
mod open_sleep_or_subprocess_call;<|fim_middle|>_subprocess_call::*;
mod blocking_http_call;... | code_fim | easy | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/flake8_async/rules/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>locking_os_call;
mod open_sleep_or_subprocess_call;<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/flake8_async/rules/mod.rs
pub(crate) use blocking_http_call::*;
pub(crate) us<|fim_middle|>e blocking_os_call::*;
pub(crate) use open_sleep_or_subprocess_call::*;
mod blocking_http_call;... | code_fim | medium | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/flake8_async/rules/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>l = 0,
Comic = 10,
Novel = 11,
Book = 16,
TalkDrip = 18,
Movie = 21,
Broadcast = 22,
}<|fim_prefix|>// repo: apersomany/kakaopage path: /src/enums/category.rs
use serde_repr::*;
#[derive(Debug, Serialize_repr, De<|fim_middle|>serialize_repr)]
#[repr(u8)]
pub enum Category {
A... | code_fim | easy | {
"lang": "rust",
"repo": "apersomany/kakaopage",
"path": "/src/enums/category.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apersomany/kakaopage path: /src/enums/category.rs
use serde_repr::*;
#[derive(Debug, Serialize_repr, De<|fim_suffix|>l = 0,
Comic = 10,
Novel = 11,
Book = 16,
TalkDrip = 18,
Movie = 21,
Broadcast = 22,
}<|fim_middle|>serialize_repr)]
#[repr(u8)]
pub enum Category {
A... | code_fim | easy | {
"lang": "rust",
"repo": "apersomany/kakaopage",
"path": "/src/enums/category.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.