text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: mystor/rust-cpp path: /test/src/inner/explicit_path.rs
use cpp::cpp;
pub fn explicit_path(im_explicit_path: i32) -> i32 {
unsafe {
cpp!([im<|fim_suffix|> return im_explicit_path;
})
}
}<|fim_middle|>_explicit_path as "int"] -> i32 as "int" {
| code_fim | easy | {
"lang": "rust",
"repo": "mystor/rust-cpp",
"path": "/test/src/inner/explicit_path.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return im_explicit_path;
})
}
}<|fim_prefix|>// repo: mystor/rust-cpp path: /test/src/inner/explicit_path.rs
use cpp::cpp;
pub fn explicit_path(im_explicit_path: i32) -> i32 {
unsafe {
cpp!([im<|fim_middle|>_explicit_path as "int"] -> i32 as "int" {
| code_fim | easy | {
"lang": "rust",
"repo": "mystor/rust-cpp",
"path": "/test/src/inner/explicit_path.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plotters-rs/plotters path: /plotters/src/coord/ranged1d/combinators/mod.rs
mod ckps;
pub use ckps::{BindKeyPointMethod, BindKeyPoints, WithKeyPointMethod, WithKeyPoints};
mod group_by;
pub use group_by::{GroupBy, ToGroupByRange};
<|fim_suffix|>mod logarithmic;
pub use logarithmic::{IntoLogRang... | code_fim | easy | {
"lang": "rust",
"repo": "plotters-rs/plotters",
"path": "/plotters/src/coord/ranged1d/combinators/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod linspace;
pub use linspace::{IntoLinspace, Linspace};
mod logarithmic;
pub use logarithmic::{IntoLogRange, LogCoord, LogScalable};
#[allow(deprecated)]
pub use logarithmic::LogRange;
mod nested;
pub use nested::{BuildNestedCoord, NestedRange, NestedValue};
mod partial_axis;
pub use partial_axis::{... | code_fim | medium | {
"lang": "rust",
"repo": "plotters-rs/plotters",
"path": "/plotters/src/coord/ranged1d/combinators/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>debug::MM, "memory low before: {}", stringify!($e));
Err(alloc::AllocError)
} else {
let x = box $e;
if alloc::is_memory_low() {
dbg!(debug::CORE|debug::MM, "memory low after: {}", stringify!($e));
mem::drop(x);
E... | code_fim | hard | {
"lang": "rust",
"repo": "scialex/reenix",
"path": "/kernel/mm/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scialex/reenix path: /kernel/mm/macros.rs
// TODO Copyright Header
//! Macro's for failable allocation
/// Allocates a value. If it seems that we are likely to run out of memory we will return
/// Err(AllocError), otherwise Ok(val). It is not nessecarially gaurenteed to work.
///
/// NOTE This... | code_fim | hard | {
"lang": "rust",
"repo": "scialex/reenix",
"path": "/kernel/mm/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Override HasLength::is_empty
fn is_empty(&self) -> bool {
false
}
}
let x = Foo;
assert!(!x.is_empty());
}
#[test]
fn impl_from() {
struct Foo {
s: String,
}
impl From<String> for Foo {
fn from(s: String) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "WeAreRust/rust-course-material",
"path": "/05-traits-and-generics/examples/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WeAreRust/rust-course-material path: /05-traits-and-generics/examples/src/lib.rs
//! Rust Workshop 5
//! Generics Types and Traits
#![allow(dead_code, unused_imports, unused_variables)]
//
// Generic Functions
//
#[test]
fn generic_function() {
// Fn with generic type T
fn do_foo<T>(x... | code_fim | hard | {
"lang": "rust",
"repo": "WeAreRust/rust-course-material",
"path": "/05-traits-and-generics/examples/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markrepedersen/compute_server path: /validation/src/lib.rs
use csv::{ReaderBuilder, Result as CSVResult, StringRecord};
use std::path::Path;
<|fim_suffix|> let mut reader = ReaderBuilder::new().has_headers(true).from_path(path)?;
let mut record = StringRecord::new();
while reader.re... | code_fim | hard | {
"lang": "rust",
"repo": "markrepedersen/compute_server",
"path": "/validation/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut reader = ReaderBuilder::new().has_headers(true).from_path(path)?;
let mut record = StringRecord::new();
while reader.read_record(&mut record)? {
if record.is_empty() {
panic!("empty");
}
let _first = record.get(0).unwrap();
}
Ok(())
}<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "markrepedersen/compute_server",
"path": "/validation/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.meta
}
async fn read_all(&mut self) -> Result<Vec<u8>, Error> {
Ok(self.data.clone())
}
}
pub struct RamStorage {
files: HashMap<Path, RamFile>,
}
impl RamStorage {
pub fn new() -> Self {
Self {
files: HashMap::new(),
}
}
}
#[as... | code_fim | hard | {
"lang": "rust",
"repo": "ushitora-anqou/asynq_old",
"path": "/src/aqfs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ushitora-anqou/asynq_old path: /src/aqfs.rs
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Error {
// Generic
Unexpected(String),
NotImplemented,
... | code_fim | hard | {
"lang": "rust",
"repo": "ushitora-anqou/asynq_old",
"path": "/src/aqfs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zipper97412/vulkano-render path: /src/components.rs
use specs::*;
#[derive(Clone, Debug)]
pub struct CompPosition(pub i32, pub i32)<|fim_suffix|>ype Storage = VecStorage<CompPosition>;
}<|fim_middle|>;
impl Component for CompPosition {
t | code_fim | easy | {
"lang": "rust",
"repo": "zipper97412/vulkano-render",
"path": "/src/components.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>;
impl Component for CompPosition {
type Storage = VecStorage<CompPosition>;
}<|fim_prefix|>// repo: zipper97412/vulkano-render path: /src/components.rs
use specs::*;
#[derive(Clone, Debug)]
<|fim_middle|>pub struct CompPosition(pub i32, pub i32) | code_fim | easy | {
"lang": "rust",
"repo": "zipper97412/vulkano-render",
"path": "/src/components.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ype Storage = VecStorage<CompPosition>;
}<|fim_prefix|>// repo: zipper97412/vulkano-render path: /src/components.rs
use specs::*;
#[derive(Clone, Debug)]
pub struct CompPosition(pub i32, pub i32)<|fim_middle|>;
impl Component for CompPosition {
t | code_fim | easy | {
"lang": "rust",
"repo": "zipper97412/vulkano-render",
"path": "/src/components.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Copy each input image at the correct location in the output image.
for img in images {
imgbuf.copy_from(img, accumulated_width, 0).unwrap();
accumulated_width += img.width();
}
imgbuf
}<|fim_prefix|>// repo: image-rs/image path: /examples/concat/main.rs
use image::{Gen... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/image",
"path": "/examples/concat/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: image-rs/image path: /examples/concat/main.rs
use image::{GenericImage, GenericImageView, ImageBuffer, Pixel, Primitive};
/// Example showcasing a generic implementation of image concatenation.
///
/// The example images are coming from https://placeholder.com/
///
/// Run from the root of the ... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/image",
"path": "/examples/concat/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The final height is the maximum height from the input images.
let img_height_out: u32 = images.iter().map(|im| im.height()).max().unwrap_or(0);
// Initialize an image buffer with the appropriate size.
let mut imgbuf = image::ImageBuffer::new(img_width_out, img_height_out);
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/image",
"path": "/examples/concat/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if configurations.verbose_mode {
progress =
(100.0_f64 * (record_num + 1) as f64 / input.num_records as f64) as usize;
if progress != old_progress {
println!("Progress: {}%", progress);
old_progress = progress;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jblindsay/whitebox-tools",
"path": "/whitebox-plugins/src/travelling_salesman_problem/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jblindsay/whitebox-tools path: /whitebox-plugins/src/travelling_salesman_problem/main.rs
/*
Authors: Prof. John Lindsay
Created: 23/02/2022
Last Modified: 06/05/2022
License: MIT
*/
extern crate tsp_rs;
use tsp_rs::Tour;
use tsp_rs::Metrizable;
use std::env;
use std::f64;
use std::io::{Error, ... | code_fim | hard | {
"lang": "rust",
"repo": "jblindsay/whitebox-tools",
"path": "/whitebox-plugins/src/travelling_salesman_problem/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r reading their attributes.
//! - **libraries** The shared libraries that enable the plugin API
//!
//! ## Integrations
//!
//! Integrations are different implementations of the user API. Examples of possible integrations
//! include
//!
//! - a JSON REST API
//! - gRPC
//! - a C static library
//! - Pyth... | code_fim | hard | {
"lang": "rust",
"repo": "kmdouglass/kpal",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kmdouglass/kpal path: /src/lib.rs
//! KPAL is an extensible control system for physical computing.
//!
//! # Overview
//!
//! KPAL allows you to control and read data from peripherals attached to a computer such as your
//! desktop or Raspberry Pi. It acts as an interface between users and indiv... | code_fim | hard | {
"lang": "rust",
"repo": "kmdouglass/kpal",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pop-os/bustd path: /src/errno.rs
use cfg_if::cfg_if;
use libc::{self, c_int};
<|fim_suffix|>pub fn errno() -> i32 {
unsafe { (*_errno()) as i32 }
}<|fim_middle|>cfg_if! {
if #[cfg(target_os = "android")] {
unsafe fn _errno() -> *mut c_int {
libc::__errno()
}
... | code_fim | hard | {
"lang": "rust",
"repo": "pop-os/bustd",
"path": "/src/errno.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn errno() -> i32 {
unsafe { (*_errno()) as i32 }
}<|fim_prefix|>// repo: pop-os/bustd path: /src/errno.rs
use cfg_if::cfg_if;
use libc::{self, c_int};
<|fim_middle|>cfg_if! {
if #[cfg(target_os = "android")] {
unsafe fn _errno() -> *mut c_int {
libc::__errno()
}
... | code_fim | hard | {
"lang": "rust",
"repo": "pop-os/bustd",
"path": "/src/errno.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: domain-independent-dp/didp-rs path: /dypdl-heuristic-search/src/dual_bound_cabs.rs
use super::f_evaluator_type::FEvaluatorType;
use super::search_algorithm::{
beam_search, Cabs, CabsParameters, CostNode, FNode, Search, SearchInput, SuccessorGenerator,
};
use dypdl::{variable_type, Transition... | code_fim | hard | {
"lang": "rust",
"repo": "domain-independent-dp/didp-rs",
"path": "/dypdl-heuristic-search/src/dual_bound_cabs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_evaluator = move |node: &FNode<_>, transition, primal_bound| {
node.generate_successor_node(
transition,
&model,
&h_evaluator,
&f_evaluator,
primal_bound,
)
};
let beam_search = move |i... | code_fim | hard | {
"lang": "rust",
"repo": "domain-independent-dp/didp-rs",
"path": "/dypdl-heuristic-search/src/dual_bound_cabs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hagsteel/deso3d path: /rust/src/dragndrop.rs
use gdnative::Vector2;
use legion::prelude::*;
use legion::systems::schedule::Builder;
use crate::input::{MouseButton, LMB};
const TILE_SIZE: f32 = 16.;
fn pos_to_coords(pos: Vector2) -> Vector2 {
(pos / TILE_SIZE).floor()
}
fn coords_to_pos(c... | code_fim | hard | {
"lang": "rust",
"repo": "hagsteel/deso3d",
"path": "/rust/src/dragndrop.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let snapped_pos = snap_to_pos(mouse_pos);
unsafe { unit.0.set_position(snapped_pos, false) };
}
})
}
fn drag_unit() -> Box<dyn Runnable> {
SystemBuilder::new("drag formation unit")
.write_resource::<MouseButton>()
.read_resource::<Fo... | code_fim | hard | {
"lang": "rust",
"repo": "hagsteel/deso3d",
"path": "/rust/src/dragndrop.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn deselect_unit() -> Box<dyn Runnable> {
SystemBuilder::new("deselect formation unit")
.read_resource::<MouseButton>()
.read_resource::<FormationUI>()
.with_query(<Write<FormationUnit>>::query().filter(tag::<FormationUnitSelected>()))
.build_thread_local(|cmd, world, (... | code_fim | hard | {
"lang": "rust",
"repo": "hagsteel/deso3d",
"path": "/rust/src/dragndrop.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tolgaio/tcpip-rs path: /src/ip/v6/mod.rs
pub mod address;
use super::protocol::IpProtocol;
use address::IP6Address;
use bitreader::BitReader;
use std::fmt;
use std::vec::Vec;
#[derive(Debug, PartialEq)]
pub struct IP6 {
ds: u8,
ecn: u8,
flow_label: u32,
payload_length: u16,
... | code_fim | hard | {
"lang": "rust",
"repo": "tolgaio/tcpip-rs",
"path": "/src/ip/v6/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let source = match &self.source {
None => "No source".to_string(),
Some(s) => format!("{}", s),
};
let dest = match &self.dest {
None => "No dest".to_string(),
Some(d) => format!("{}", d),
};
let protocol = match &self... | code_fim | hard | {
"lang": "rust",
"repo": "tolgaio/tcpip-rs",
"path": "/src/ip/v6/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for IP6 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let source = match &self.source {
None => "No source".to_string(),
Some(s) => format!("{}", s),
};
let dest = match &self.dest {
None => "No dest".to_string(),... | code_fim | hard | {
"lang": "rust",
"repo": "tolgaio/tcpip-rs",
"path": "/src/ip/v6/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: themadprofessor/swamp_bot path: /src/conf.rs
use failure::Error;
use serenity::model::id::{GuildId, ChannelId};
use std::str::FromStr;
#[derive(Debug, Clone, Hash, PartialEq)]
pub struct Config {
pub discord_token: String,
pub guild_id: GuildId,
pub channel_id: ChannelId,
pub t... | code_fim | hard | {
"lang": "rust",
"repo": "themadprofessor/swamp_bot",
"path": "/src/conf.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> .and_then(|id| u64::from_str(&id).map_err(Error::from))
.map(GuildId)?,
channel_id: conf.get_str("channel_id")
.map_err(Error::from)
.and_then(|id| u64::from_str(&id).map_err(Error::from))
.map(ChannelId)?,
te... | code_fim | hard | {
"lang": "rust",
"repo": "themadprofessor/swamp_bot",
"path": "/src/conf.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Error message produced during a kernel panic due to the kernel encountering
/// a registered kernel-object with a dangling handle.
pub const DANGLING_HANDLE_ERROR: &str =
"Kernel invariant failed: dangling handle.";
/// Error message produced during a kernel panic due to the kernel failing to
///... | code_fim | hard | {
"lang": "rust",
"repo": "DominicPM/supervisionary",
"path": "/kernel/src/kernel_panic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DominicPM/supervisionary path: /kernel/src/kernel_panic.rs
//! # Kernel panic messages
//!
//! The Supervisionary kernel has a number of failure modes: ordinarily a system
//! call will produce a defined error code in response to some recoverable
//! error. For example, if passed a kernel handl... | code_fim | hard | {
"lang": "rust",
"repo": "DominicPM/supervisionary",
"path": "/kernel/src/kernel_panic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msyksphinz-self/swimmer_rust path: /src/main.rs
use std::io::{Write};
use std::{env};
extern crate getopts;
use getopts::Options;
mod core_base;
mod riscv_core;
mod riscv_insts;
mod riscv_insts_int;
mod riscv_insts_fpu;
mod riscv_insts_amo;
mod riscv_insts_mem;
mod riscv_csr;
mod riscv_csr_bit... | code_fim | hard | {
"lang": "rust",
"repo": "msyksphinz-self/swimmer_rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> Result<(), Box<std::error::Error>> {
let args = parse_args();
let xlen = match args.rv_arch {
Some(rv_arch_str) => match rv_arch_str.as_str() {
"rv32" => 32,
"rv64" => 64,
_ => panic!("Unknown XLEN! Should specify rv32 or rv64"),
},... | code_fim | hard | {
"lang": "rust",
"repo": "msyksphinz-self/swimmer_rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bartlomieju/dprint path: /crates/dprint/src/environment/environment.rs
use std::path::PathBuf;
use async_trait::async_trait;
use bytes::Bytes;
use super::super::types::ErrBox;
#[async_trait]
pub trait Environment : Clone + std::marker::Send + 'static {
fn read_file(&self, file_path: &PathBu... | code_fim | medium | {
"lang": "rust",
"repo": "bartlomieju/dprint",
"path": "/crates/dprint/src/environment/environment.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn cwd(&self) -> Result<PathBuf, ErrBox>;
fn log(&self, text: &str);
fn log_error(&self, text: &str);
fn log_verbose(&self, text: &str);
async fn download_file(&self, url: &str) -> Result<Bytes, ErrBox>;
fn get_cache_dir(&self) -> Result<PathBuf, ErrBox>;
fn get_time_secs(&self... | code_fim | medium | {
"lang": "rust",
"repo": "bartlomieju/dprint",
"path": "/crates/dprint/src/environment/environment.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn log_error(&self, text: &str);
fn log_verbose(&self, text: &str);
async fn download_file(&self, url: &str) -> Result<Bytes, ErrBox>;
fn get_cache_dir(&self) -> Result<PathBuf, ErrBox>;
fn get_time_secs(&self) -> u64;
fn get_selection(&self, items: &Vec<String>) -> Result<usize, E... | code_fim | hard | {
"lang": "rust",
"repo": "bartlomieju/dprint",
"path": "/crates/dprint/src/environment/environment.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: potatosalad/exercism path: /rust/proverb/src/lib.rs
pub fn build_proverb(list: &[&str]) -> String {
if list.is_empty() {
return String::new();
}
let mut<|fim_suffix|>erm = prev;
while let Some(next) = iter.next() {
text.push(format!("For want of a {} the {} was lo... | code_fim | medium | {
"lang": "rust",
"repo": "potatosalad/exercism",
"path": "/rust/proverb/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>erm = prev;
while let Some(next) = iter.next() {
text.push(format!("For want of a {} the {} was lost.", prev, next));
prev = next;
}
text.push(format!("And all for the want of a {}.", term));
text.join("\n")
}<|fim_prefix|>// repo: potatosalad/exercism path: /rust/proverb/... | code_fim | medium | {
"lang": "rust",
"repo": "potatosalad/exercism",
"path": "/rust/proverb/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod import;
pub use import::*;
mod export;
pub use export::*;<|fim_prefix|>// repo: kelvinfan001/ostree-rs-ext path: /lib/src/tar/mod.rs
//! # Losslessly export and import ostree commits as tar archives
//!
//! Convert an ostree commit into a tarball stream, and import
//! it again.
<|fim_middle|>//#![d... | code_fim | medium | {
"lang": "rust",
"repo": "kelvinfan001/ostree-rs-ext",
"path": "/lib/src/tar/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kelvinfan001/ostree-rs-ext path: /lib/src/tar/mod.rs
//! # Losslessly export and import ostree commits as tar archives
//!
//! Convert an ostree commit into a tarball stream, and import
//! it again.
<|fim_suffix|>mod import;
pub use import::*;
mod export;
pub use export::*;<|fim_middle|>//#![d... | code_fim | medium | {
"lang": "rust",
"repo": "kelvinfan001/ostree-rs-ext",
"path": "/lib/src/tar/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let g = ValueCommitment(pallas::Affine::generator());
assert_eq!(identity + g, g);
}
#[test]
fn add_assign() {
let _init_guard = zebra_test::init();
let mut identity = ValueCommitment(pallas::Affine::identity());
let g = ValueCommitment(pallas::Affin... | code_fim | hard | {
"lang": "rust",
"repo": "ZcashFoundation/zebra",
"path": "/zebra-chain/src/orchard/commitment.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZcashFoundation/zebra path: /zebra-chain/src/orchard/commitment.rs
//! Note and value commitments.
use std::{fmt, io};
use group::{
ff::{FromUniformBytes, PrimeField},
prime::PrimeCurveAffine,
GroupEncoding,
};
use halo2::{
arithmetic::{Coordinates, CurveAffine},
pasta::pal... | code_fim | hard | {
"lang": "rust",
"repo": "ZcashFoundation/zebra",
"path": "/zebra-chain/src/orchard/commitment.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: notdanilo/gpu path: /src/code/programs/raster_program.rs
use crate::prelude::*;
use crate::Context;
use crate::Program;
use crate::FragmentShader;
use crate::VertexShader;
use crate::VertexArrayObject;
use crate::Framebuffer;
/// A program for rasterizing `VertexArrayObject`s in a target `Fram... | code_fim | hard | {
"lang": "rust",
"repo": "notdanilo/gpu",
"path": "/src/code/programs/raster_program.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn indexed_raster(&self, framebuffer: &Framebuffer, vertex_array_object: &VertexArrayObject, raster_geometry: RasterGeometry, n_indices: usize) {
unsafe {
framebuffer.bind();
self.use_();
vertex_array_object.bind();
gl::Enable(gl::PROGRAM_POI... | code_fim | hard | {
"lang": "rust",
"repo": "notdanilo/gpu",
"path": "/src/code/programs/raster_program.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = input;
input[1] = noun;
input[2] = verb;
let mut i = 0;
loop {
let next = input[i];
if next == 99 {
break;
}
if next == 1 {
let arg1_pos = input[i + 1];
let arg2_pos = input[i + 2];
let re... | code_fim | hard | {
"lang": "rust",
"repo": "Tejpbit/advent-of-code-2019",
"path": "/src/days/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tejpbit/advent-of-code-2019 path: /src/days/day02.rs
use super::day::Day;
pub struct Day02 {}
impl Day02 {
pub fn new() -> Day02 {
Day02 {}
}
}
impl Day for Day02 {
fn part1(&self, input: &str) -> Result<String, &str> {
let input = input
.split(",")
... | code_fim | hard | {
"lang": "rust",
"repo": "Tejpbit/advent-of-code-2019",
"path": "/src/days/day02.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_computer(input: Vec<usize>, noun: usize, verb: usize) -> usize {
let mut input = input;
input[1] = noun;
input[2] = verb;
let mut i = 0;
loop {
let next = input[i];
if next == 99 {
break;
}
if next == 1 {
let arg1_pos = i... | code_fim | hard | {
"lang": "rust",
"repo": "Tejpbit/advent-of-code-2019",
"path": "/src/days/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // `String`の普通のメソッドは`Rc<String>`にも直接実行可能
assert!(s.contains("oo"));
assert_eq!(t.find("f"), Some(0));
println!("u={}", u);
// Rcポインタに所有される値は不変となる。
}<|fim_prefix|>// repo: ShinNakamura/studying_rust path: /src/bin/rc.rs
/// 所有権の共有。参照カウンタ
/// > プログラミングRUST P.87
/// cargo run --bin rc
... | code_fim | medium | {
"lang": "rust",
"repo": "ShinNakamura/studying_rust",
"path": "/src/bin/rc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // `Rc<T>`の値は、ヒープ上に確保したTとそれに付随する参照カウンタを指すポインタ
let s: Rc<String> = Rc::new("foo".to_string());
// `Rc<T>`を`clone`してもヒープ上のT値はクローンされず、
// 同じものを指すポインタが作られ参照カウンタがインクリメントされる
let t: Rc<String> = s.clone();
let u: Rc<String> = s.clone();
// Rc型のポインタ自体には通常の所有権ルールが適用される
// `String`... | code_fim | medium | {
"lang": "rust",
"repo": "ShinNakamura/studying_rust",
"path": "/src/bin/rc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShinNakamura/studying_rust path: /src/bin/rc.rs
/// 所有権の共有。参照カウンタ
/// > プログラミングRUST P.87
/// cargo run --bin rc
<|fim_suffix|> // `Rc<T>`を`clone`してもヒープ上のT値はクローンされず、
// 同じものを指すポインタが作られ参照カウンタがインクリメントされる
let t: Rc<String> = s.clone();
let u: Rc<String> = s.clone();
// Rc型のポインタ自体... | code_fim | medium | {
"lang": "rust",
"repo": "ShinNakamura/studying_rust",
"path": "/src/bin/rc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scifi6546/golem path: /src/surface.rs
use crate::*;
/// A framebuffer that allows render-to-texture
pub struct Surface {
pub(crate) ctx: Context,
pub(crate) id: GlFramebuffer,
pub(crate) texture: Texture,
}
impl Surface {
/// Create a new Surface to render to, backed by the giv... | code_fim | hard | {
"lang": "rust",
"repo": "scifi6546/golem",
"path": "/src/surface.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the pixel data and write it to a buffer
///
/// The surface must be bound first, see [`Surface::bind`].
///
/// The ColorFormat determines how many bytes each pixel is: 3 bytes for RGB and 4 for RGBA. The
/// slice needs have a length of `(width - x) * (height - y) * ColorF... | code_fim | hard | {
"lang": "rust",
"repo": "scifi6546/golem",
"path": "/src/surface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get a reference to the bound texture
pub fn texture(&self) -> &Texture {
&self.texture
}
/// Get a mutable reference to the bound texture
pub fn texture_mut(&mut self) -> &mut Texture {
&mut self.texture
}
/// Check if this surface is bound to be operated ... | code_fim | hard | {
"lang": "rust",
"repo": "scifi6546/golem",
"path": "/src/surface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wildarch/strontium path: /src/uart/mod.rs
use core::intrinsics::{volatile_load, volatile_store};
use core::mem;
pub mod channel;
use rpi_const::GPIO_BASE;
// Controls actuation of pull up/down to ALL GPIO pins.
const GPPUD: usize = (GPIO_BASE + 0x94);
// Controls actuation of pull up/down for... | code_fim | hard | {
"lang": "rust",
"repo": "wildarch/strontium",
"path": "/src/uart/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline]
unsafe fn mmio_write(addr: usize, data: u32){
volatile_store(addr as *mut u32, data);
}
#[inline]
unsafe fn mmio_read(addr: usize) -> u32 {
volatile_load(addr as *mut u32)
}
pub fn putc(byte: u8){
unsafe {
while mmio_read(UART0_FR) & (1 << 5) != 0 { }
mmio_write(UART0_... | code_fim | hard | {
"lang": "rust",
"repo": "wildarch/strontium",
"path": "/src/uart/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> eframe::run_native(Box::new(app));
}<|fim_prefix|>// repo: ChangeCaps/neo-musix path: /src/main.rs
mod app;
mod audio_clip;
mod audio_engine;
mod audio_source;
mod main_panel;
mod top_panel;
<|fim_middle|>fn main() {
simple_logger::SimpleLogger::from_env().init().unwrap();
let app = app::App... | code_fim | medium | {
"lang": "rust",
"repo": "ChangeCaps/neo-musix",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChangeCaps/neo-musix path: /src/main.rs
mod app;
mod audio_clip;
mod audio_engine;
mod audio_source;
mod main_panel;
mod top_panel;
<|fim_suffix|> eframe::run_native(Box::new(app));
}<|fim_middle|>fn main() {
simple_logger::SimpleLogger::from_env().init().unwrap();
let app = app::App... | code_fim | medium | {
"lang": "rust",
"repo": "ChangeCaps/neo-musix",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create a buffer and serialize our nodes into it
w.write(
XmlEvent::start_element("Say")
.attr("voice", self.voice.to_str())
.attr("language", self.language)
.attr("loop", &self.count.to_string()),
)?;
w.write(se... | code_fim | hard | {
"lang": "rust",
"repo": "leshow/twilio-async",
"path": "/twiml/src/say.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leshow/twilio-async path: /twiml/src/say.rs
use crate::*;
use xml::{
writer::{EventWriter, XmlEvent},
EmitterConfig,
};
#[derive(Debug)]
pub struct Say<'a> {
voice: Voice,
count: usize,
language: &'a str,
body: &'a str,
}
#[derive(Debug)]
#[allow(non_camel_case_types)]
... | code_fim | hard | {
"lang": "rust",
"repo": "leshow/twilio-async",
"path": "/twiml/src/say.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create a buffer and serialize our nodes into it
let mut writer = Vec::new();
{
let mut w = EmitterConfig::new()
.write_document_declaration(false)
.create_writer(&mut writer);
self.write(&mut w)?;
}
Ok(Stri... | code_fim | hard | {
"lang": "rust",
"repo": "leshow/twilio-async",
"path": "/twiml/src/say.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcoffin/vulkan-device-filter path: /vulkan-sys/build.rs
extern crate bindgen;
extern crate pkg_config;
use std::env;
use std::path::PathBuf;
fn main() {
let _vulkan = pkg_config::probe_library("vulkan")
.expect("Error finding vulkan with pkg-config");
<|fim_suffix|> bindings
... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/vulkan-device-filter",
"path": "/vulkan-sys/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let out_path: PathBuf = env::var("OUT_DIR").unwrap().into();
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect(&format!("Error writing bindings to {}", out_path.display()));
}<|fim_prefix|>// repo: mcoffin/vulkan-device-filter path: /vulkan-sys/build.rs
extern crate b... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/vulkan-device-filter",
"path": "/vulkan-sys/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wyc/deptrust path: /src/drivers/npm/mod.rs
mod npm_semver;
use crate::pest;
#[macro_use]
use crate::pest_derive;
use lazy_static::lazy_static;
use std::collections::BTreeMap as Map; // BTreeMap is ordered
use serde::{Serialize, Deserialize};
use serde_json;
use ser... | code_fim | hard | {
"lang": "rust",
"repo": "wyc/deptrust",
"path": "/src/drivers/npm/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_parse_npm() {
let path = "src/drivers/npm/fixtures/npm-6.14.5-package.json";
// let path = env::current_dir().unwrap();
// println!("{}", path.to_str().unwrap());
let metadata = fs::metadata(path).unwrap();
assert!(metadata.is_file());
... | code_fim | hard | {
"lang": "rust",
"repo": "wyc/deptrust",
"path": "/src/drivers/npm/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn c_repeat_range(
&mut self,
expr: &Expr,
greedy: bool,
min: u32,
max: u32,
) -> CompileResult {
let (min, max) = (u32_to_usize(min), u32_to_usize(max));
let hole = try!(self.c_concat(iter::repeat(expr).take(min)));
if min == max {
... | code_fim | hard | {
"lang": "rust",
"repo": "oli-obk/regex",
"path": "/src/compile.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let hole2 = if greedy {
self.fill_split(split, Some(goto1), None)
} else {
self.fill_split(split, None, Some(goto1))
};
Ok(Hole::Many(vec![hole1, hole2]))
}
fn c_repeat_zero_or_more(
&mut self,
expr: &Expr,
greedy: bo... | code_fim | hard | {
"lang": "rust",
"repo": "oli-obk/regex",
"path": "/src/compile.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oli-obk/regex path: /src/compile.rs
or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::collections::HashSet;
use std::iter;
use syntax::{Expr, Repeater, CharClass, ClassRange};
use Erro... | code_fim | hard | {
"lang": "rust",
"repo": "oli-obk/regex",
"path": "/src/compile.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aviansie-ben/hootc path: /hootc/src/main.rs
extern crate libhootc as lib;
use std::io::{self, Read};
use lib::analysis::error::PrettyError;
use lib::analysis::analyze_module;
use lib::lex::Lexer;
use lib::log::Log;
use lib::parse::parse_module;
use lib::types::{PrettyType, TypeId};
fn main() ... | code_fim | hard | {
"lang": "rust",
"repo": "aviansie-ben/hootc",
"path": "/hootc/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut out = std::fs::File::create(std::path::Path::new(&args[2])).unwrap();
let mut ctx = lib::codegen::amd64::write::WriteContext::new(&module.syms, &module.types);
let fileno = ctx.add_file(input_filename.to_str().unwrap(), &mut out).unwrap();
lib::codegen::amd64::write::write_start_... | code_fim | hard | {
"lang": "rust",
"repo": "aviansie-ben/hootc",
"path": "/hootc/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn in_sight(xa: usize, ya: usize, ast_map: &Vec<Vec<bool>>) -> BTreeMap<Angle, (usize, usize, f64)>{
let mut slope_hash = BTreeMap::new();
for (y, row) in ast_map.iter().enumerate() {
for (x, ast_here) in row.iter().enumerate() {
if !(xa == x && ya == y) && *ast_here {
... | code_fim | hard | {
"lang": "rust",
"repo": "ofrank123/AoC2019",
"path": "/prob10_2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ofrank123/AoC2019 path: /prob10_2/src/main.rs
use std::fs;
use std::f64;
use std::i64;
use std::usize;
use std::collections::BTreeMap;
use std::cmp::Ordering;
#[derive(Debug)]
struct Angle(f64);
impl Angle {
fn canonicalize(&self) -> i64 {
(self.0 * 10000.0).round() as i64
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ofrank123/AoC2019",
"path": "/prob10_2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Debug for Term {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", show_precedence_dbr(self, 0))
}
}
fn show_precedence_dbr(term: &Term, context_precedence: usize) -> String {
match term {
Var(0) => "undefined".to_owned(),
Var(i) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "ljedrz/lambda_calculus",
"path": "/src/term.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ljedrz/lambda_calculus path: /src/term.rs
(a backslash).
#[cfg(feature = "backslash_lambda")]
pub const LAMBDA: char = '\\';
/// The character used to display lambda abstractions. The default is the Greek letter 'λ', but it
/// can also be set to a '\' (backslash) using `features = ["backslash_... | code_fim | hard | {
"lang": "rust",
"repo": "ljedrz/lambda_calculus",
"path": "/src/term.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the right-hand side term of an application. Consumes `self`.
///
/// # Example
/// ```
/// use lambda_calculus::*;
///
/// assert_eq!(app(Var(1), Var(2)).rhs(), Ok(Var(2)));
/// ```
/// # Errors
///
/// Returns a `TermError` if `self` is not an `App`... | code_fim | hard | {
"lang": "rust",
"repo": "ljedrz/lambda_calculus",
"path": "/src/term.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knpwrs/learning-rust path: /code/c08-02-strings/src/main.rs
fn main() {
let mut mutable_string = String::new();
// Any type that implements the Display trait has a to_string method
let s = "initial contents".to_string();
// UTF-8
let hello = String::from("こんにちは");
mutabl... | code_fim | hard | {
"lang": "rust",
"repo": "knpwrs/learning-rust",
"path": "/code/c08-02-strings/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut lo = String::from("lo");
lo.push('l');
println!("{}", lo);
let s1 = String::from("foo");
let s2 = String::from("bar");
// coerce &String to &str
let s3 = s1 + &s2; // s1 moved here and cannot be used
println!("{}", s2); // s2 still valid
println!("{}", s3);
... | code_fim | medium | {
"lang": "rust",
"repo": "knpwrs/learning-rust",
"path": "/code/c08-02-strings/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait MTOps {
type AccountId;
type MachineId;
type FaultType;
type Balance;
fn mt_machine_offline(
reporter: Self::AccountId,
committee: Vec<Self::AccountId>,
machine_id: Self::MachineId,
fault_type: Self::FaultType,
);
fn mt_change_staked_b... | code_fim | hard | {
"lang": "rust",
"repo": "PinkDiamond1/DeepBrainChain-MainChain",
"path": "/traits/online-profile-machine/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PinkDiamond1/DeepBrainChain-MainChain path: /traits/online-profile-machine/src/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::vec::Vec;
// lease-committee_ops
pub trait OCOps {
type AccountId;
type MachineId;
type CommitteeUploadInfo;
type Balance;
fn oc_boo... | code_fim | hard | {
"lang": "rust",
"repo": "PinkDiamond1/DeepBrainChain-MainChain",
"path": "/traits/online-profile-machine/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc261/src/bin/f.rs
use std::collections::{BTreeMap, BTreeSet};
use fenwicktree::*;
use proconio::{input, marker::Usize1};
fn f(a: &[usize]) -> usize {
let mut count = 0;
let c = a
.iter()
.copied()
.collect::<B... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc261/src/bin/f.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bit = FenwickTree::new(5, 0i64);
// [1, 2, 3, 4, 5]
for i in 0..5 {
bit.add(i, i as i64 + 1);
}
assert_eq!(bit.sum(0, 5), 15);
assert_eq!(bit.sum(0, 4), 10);
assert_eq!(bit.sum(1, 3), 5);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc261/src/bin/f.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Attach request handler for incoming requests
service_fs
.for_each_concurrent(None, |request: IncomingRequest| async move {
match request {
IncomingRequest::Echo(stream) => handle_echo_request(stream).await,
}
})
.await;
Ok(())... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/examples/components/routing/rust/echo_server/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Component is serving and ready to handle incoming requests
component::health().set_ok();
// Attach request handler for incoming requests
service_fs
.for_each_concurrent(None, |request: IncomingRequest| async move {
match request {
IncomingRequest::Ec... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/examples/components/routing/rust/echo_server/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /examples/components/routing/rust/echo_server/src/main.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// [START imports]
use anyhow::{self, Context};
us... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/examples/components/routing/rust/echo_server/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FMarno/AdventOfCode2019 path: /fourteen/src/main.rs
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader, Lines};
fn main() -> std::io::Result<()> {
let f = File::open("fourteen/input")?;
let reader = BufReader::new(f);
let recipes = create_recipes(read... | code_fim | hard | {
"lang": "rust",
"repo": "FMarno/AdventOfCode2019",
"path": "/fourteen/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
struct Recipe {
pack_size: i64,
ingredients: Vec<(i64, String)>,
}
fn create_recipes<T>(lines: Lines<T>) -> HashMap<String, Recipe>
where
T: Sized + BufRead,
{
let mut recipes = HashMap::new();
for line in lines.filter_map(|l| l.ok()) {
let sides: Vec<_> = lin... | code_fim | hard | {
"lang": "rust",
"repo": "FMarno/AdventOfCode2019",
"path": "/fourteen/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// r = 0;
// if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {
// v1.set( - vFrom.y, vFrom.x, 0 );
// } else {
// v1.set( 0, - vFrom.z, vFrom.y );
// }
// } else {
// v1.crossVectors( vFrom, vTo );
// }
// this._x = v1.x;
// this._y = v1.y;
// this._z... | code_fim | hard | {
"lang": "rust",
"repo": "pit-rpg/Viz",
"path": "/src/math/quaternion.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pit-rpg/Viz path: /src/math/quaternion.rs
use helpers::Nums;
use super::{Vector3, Matrix4, RotationOrders, Euler};
#[derive(Clone, Debug)]
pub struct Quaternion<T> {
pub x: T,
pub y: T,
pub z: T,
pub w: T,
}
#[allow(dead_code)]
impl <T> Quaternion<T>
where T: Nums
{
pub fn new() -> Self {... | code_fim | hard | {
"lang": "rust",
"repo": "pit-rpg/Viz",
"path": "/src/math/quaternion.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nusic-fm/mirror-contracts path: /packages/mirror_protocol/src/collector.rs
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
pub owner: String,
pub distribution_contract: Stri... | code_fim | hard | {
"lang": "rust",
"repo": "nusic-fm/mirror-contracts",
"path": "/packages/mirror_protocol/src/collector.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// TODO: Delete when moneymarket is upgraded to std 0.14
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum MoneyMarketCw20HookMsg {
/// Return stable coins to a user
/// according to exchange rate
RedeemStable {},
}
// We defin... | code_fim | medium | {
"lang": "rust",
"repo": "nusic-fm/mirror-contracts",
"path": "/packages/mirror_protocol/src/collector.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmumn/minnehack-blockchain-check-in path: /src/blockchain/serialize.rs
use std::io::{Result, Write};
use blockchain::Block;
use util::write_u64_to;
<|fim_suffix|> let l = self.data.len();
assert!(l < 256);
w.write_all(&[l as u8])?;
w.write_all(&self.data)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "acmumn/minnehack-blockchain-check-in",
"path": "/src/blockchain/serialize.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let l = self.data.len();
assert!(l < 256);
w.write_all(&[l as u8])?;
w.write_all(&self.data)?;
w.write_all(&self.hash.0)
}
}<|fim_prefix|>// repo: acmumn/minnehack-blockchain-check-in path: /src/blockchain/serialize.rs
use std::io::{Result, Write};
use blockc... | code_fim | hard | {
"lang": "rust",
"repo": "acmumn/minnehack-blockchain-check-in",
"path": "/src/blockchain/serialize.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn compute_dependencies(
results: &Results<'tcx, FlowAnalysis<'mir, 'tcx>>,
targets: Vec<(Place<'tcx>, Location)>,
direction: Direction,
) -> Vec<(IndexSet<Location>, Vec<Span>)> {
let analysis = &results.analysis;
let body = analysis.body;
// Extract dependencies for each place at the given ... | code_fim | hard | {
"lang": "rust",
"repo": "VaibhavDS19/flowistry",
"path": "/src/flow/dependencies.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VaibhavDS19/flowistry path: /src/flow/dependencies.rs
use super::dataflow::{FlowAnalysis, FlowDomain};
use crate::core::{
config::Range,
indexed::IndexSet,
indexed_impls::{location_arg, LocationSet},
utils::{self},
};
use log::debug;
use rustc_index::bit_set::BitSet;
use rustc_middle::m... | code_fim | hard | {
"lang": "rust",
"repo": "VaibhavDS19/flowistry",
"path": "/src/flow/dependencies.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> From<std::sync::PoisonError<T>> for Error {
fn from(_: std::sync::PoisonError<T>) -> Self {
Self::PoisonedLockError
}
}
impl From<ParseIntError> for Error {
fn from(_: ParseIntError) -> Self {
// this is used for parsing integers from the a packet string
Self::... | code_fim | medium | {
"lang": "rust",
"repo": "likewhatevs/rust-socketio",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likewhatevs/rust-socketio path: /src/error.rs
use base64::DecodeError;
use std::{num::ParseIntError, str};
use thiserror::Error;
use websocket::{client::ParseError, WebSocketError};
/// Enumeration of all possible errors in the `socket.io` context.
#[derive(Error, Debug)]
#[non_exhaustive]
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "likewhatevs/rust-socketio",
"path": "/src/error.rs",
"mode": "psm",
"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.