text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: alexcrichton/regalloc.rs path: /lib/src/analysis_reftypes.rs
//! Performs a simple taint analysis, to find all live ranges that are reftyped.
use crate::data_structures::*;
use crate::sparse_set::{SparseSet, SparseSetU};
use std::{fmt, hash::Hash};
use log::debug;
use smallvec::SmallVec;
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/regalloc.rs",
"path": "/lib/src/analysis_reftypes.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Mark a given RangeId as being reffy.
fn mark_reffy(&mut self, range_id: &Self::RangeId);
}
pub(crate) fn core_reftypes_analysis<RA: ReftypeAnalysis>(
analysis: &mut RA,
move_info: &MoveInfo,
// As supplied by the client
reftype_class: RegClass,
reftyped_vregs: &Vec<Virtua... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/regalloc.rs",
"path": "/lib/src/analysis_reftypes.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn as_regex_replace(&self) -> &RegexReplace {
match self {
Literal::Replace(regex_replace) => ®ex_replace,
Literal::ReplaceAll(regex_replace) => ®ex_replace,
_ => panic!("expected a Literal::Replace or Literal::ReplaceAll"),
}
}
}
#[derive(serde_derive::Deserialize)]
p... | code_fim | medium | {
"lang": "rust",
"repo": "TracerBench/tracerbench-serve",
"path": "/request-key/src/request_key/literal_table.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Literal::Replace(regex_replace) => ®ex_replace,
Literal::ReplaceAll(regex_replace) => ®ex_replace,
_ => panic!("expected a Literal::Replace or Literal::ReplaceAll"),
}
}
}
#[derive(serde_derive::Deserialize)]
pub struct LiteralTable(Vec<Literal>);
impl Lite... | code_fim | hard | {
"lang": "rust",
"repo": "TracerBench/tracerbench-serve",
"path": "/request-key/src/request_key/literal_table.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TracerBench/tracerbench-serve path: /request-key/src/request_key/literal_table.rs
use super::regex_replace::RegexReplace;
use super::regex_test::RegexTest;
#[derive(serde_derive::Deserialize)]
#[serde(tag = "type", content = "content")]
pub enum Literal {
String(String),
Match(RegexTest),
... | code_fim | hard | {
"lang": "rust",
"repo": "TracerBench/tracerbench-serve",
"path": "/request-key/src/request_key/literal_table.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn geometry(&self) -> vk::AccelerationStructureGeometryKHR;
fn primitives_count(&self) -> u32;
}<|fim_prefix|>// repo: evopen/maligog path: /src/acceleration_structure/mod.rs
mod aabb_geometry;
mod triangle_geometry;
mod blas_instance;
mod bottom;
mod instance_geometry;
mod top;
pub use aabb_ge... | code_fim | medium | {
"lang": "rust",
"repo": "evopen/maligog",
"path": "/src/acceleration_structure/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evopen/maligog path: /src/acceleration_structure/mod.rs
mod aabb_geometry;
mod triangle_geometry;
mod blas_instance;
mod bottom;
mod instance_geometry;
mod top;
<|fim_suffix|>pub trait Geometry {
fn build_range_info(&self) -> vk::AccelerationStructureBuildRangeInfoKHR;
fn geometry(&sel... | code_fim | hard | {
"lang": "rust",
"repo": "evopen/maligog",
"path": "/src/acceleration_structure/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/pwm1/sm3dismap1/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u16,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u16,
}
impl super::SM3DISMAP1 {
#[doc = r" Modifies the contents of the register"]
#[... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/pwm1/sm3dismap1/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> const OFFSET: u8 = 4;
((self.bits >> OFFSET) & MASK as u16) as u8
};
DIS1BR { bits }
}
#[doc = "Bits 8:11 - PWM_X Fault Disable Mask 1"]
#[inline]
pub fn dis1x(&self) -> DIS1XR {
let bits = {
const MASK: u8 = 15;
const OFFSET: ... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/pwm1/sm3dismap1/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline(always)]
fn box_blur_h(tcl: &mut [Color], scl: &mut [Color], w: usize, h: usize, r: usize) {
let iarr: f32 = 1.0 / (r + r + 1) as f32;
for i in 0..h {
let mut ti: usize = i * w;
let mut li: usize = ti;
let mut ri: usize = ti + r;
let fv = MathColor::new(tc... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/orbclient",
"path": "/src/blur.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redox-os/orbclient path: /src/blur.rs
// SPDX-License-Identifier: MIT
/*
Inspired from http://blog.ivank.net/fastest-gaussian-blur.html the algorithm 4.
The struct MathColor is needed for the calculate with bigger numbers, the Color struct save the r,g,b values with a u8.
*/
#[cfg(not(feature ... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/orbclient",
"path": "/src/blur.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in (w - r)..w {
val += lv - MathColor::new(tcl[li]);
scl[ti] = val.get_multiplied_color(iarr);
ti += 1;
li += 1;
}
}
}
#[inline(always)]
fn box_blur_t(tcl: &mut [Color], scl: &mut [Color], w: usize, h: usize, r: usize) {
let ia... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/orbclient",
"path": "/src/blur.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub type pthread_spinlock_t = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct pthread_barrier_t {
pub _bindgen_data_: [u64; 4usize],
}
impl pthread_barrier_t {
pub unsafe fn __size(&mut self)
-> *mut [::std::os::raw::c_char; 32usize] {
let raw: *... | code_fim | hard | {
"lang": "rust",
"repo": "doyoubi/forestkv",
"path": "/libforestdb-sys/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct pthread_condattr_t {
pub _bindgen_data_: [u32; 1usize],
}
impl pthread_condattr_t {
pub unsafe fn __size(&mut self) -> *mut [::std::os::raw::c_char; 4usize] {
let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
... | code_fim | hard | {
"lang": "rust",
"repo": "doyoubi/forestkv",
"path": "/libforestdb-sys/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doyoubi/forestkv path: /libforestdb-sys/src/lib.rs
fdb_fileops_handle)>,
pub ctx: *mut ::std::os::raw::c_void,
}
impl ::std::default::Default for filemgr_ops {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
pub type fdb_filemgr_ops_t = filemgr_ops;
#[repr(C)... | code_fim | hard | {
"lang": "rust",
"repo": "doyoubi/forestkv",
"path": "/libforestdb-sys/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some(t) = stack.memories.pop() {
for data in &module.memories.get(t).data_segments {
stack.push_data(*data);
}
}
while let Some(d) = stack.datas.pop() {
let d = module.data.get(d);
... | code_fim | hard | {
"lang": "rust",
"repo": "fitzgen/walrus",
"path": "/src/passes/used.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fitzgen/walrus path: /src/passes/used.rs
use crate::ir::*;
use crate::map::IdHashSet;
use crate::{ActiveDataLocation, Data, DataId, DataKind, Element, ExportItem, Function, InitExpr};
use crate::{FunctionId, FunctionKind, Global, GlobalId};
use crate::{GlobalKind, ImportKind, Memory, MemoryId, T... | code_fim | hard | {
"lang": "rust",
"repo": "fitzgen/walrus",
"path": "/src/passes/used.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zackmdavis/Exercises_A path: /r_dailyprogrammer/easy_0183.rs
// https://www.reddit.com/r/dailyprogrammer/comments/2igfj9/10062014_challenge_183_easy_semantic_version_sort/
// Easy #183: Semantic Version Sort
use std::cmp::Ordering;
use std::error::Error;
#[derive(Debug, Eq, PartialEq, Partia... | code_fim | hard | {
"lang": "rust",
"repo": "zackmdavis/Exercises_A",
"path": "/r_dailyprogrammer/easy_0183.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[ignore] // TODO make this pass
#[test]
fn concerning_version_comparison() {
assert!(Version::new_release(5, 0, 0) > Version::new_release(4, 9, 10));
assert!(Version::new_release(5, 0, 0) >
Version::new_prerelease(5, 0, 0, "rc1".to_owned()));
assert_eq!(Version::new_prerelease(5, ... | code_fim | hard | {
"lang": "rust",
"repo": "zackmdavis/Exercises_A",
"path": "/r_dailyprogrammer/easy_0183.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
pub fn bezier(x: f32, pts: &mut [Point2]) {
let s = x;
let t = 1.0 - s;
let n = pts.len();
for i in 0..n - 1 {
pts[i] = pts[i] * s + pts[i + 1] * t;
}
bezier(x, &mut pts[..n - 1]);
}
*/<|fim_prefix|>// repo: CasualX/shade path: /src/d2/curve.rs
use super::Point2;
#[inline]
pub fn bezier2(x: f... | code_fim | hard | {
"lang": "rust",
"repo": "CasualX/shade",
"path": "/src/d2/curve.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CasualX/shade path: /src/d2/curve.rs
use super::Point2;
#[inline]
pub fn bezier2(x: f32, p1: Point2, p2: Point2, p3: Point2) -> Point2 {
let s = x;
let t = 1.0 - s;
let term1 = p1 * (s * s);
let term2 = p2 * (s * t + s * t);
let term3 = p3 * (t * t);
term1 + term2 + term3
}
<|fim_suffix|... | code_fim | hard | {
"lang": "rust",
"repo": "CasualX/shade",
"path": "/src/d2/curve.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whsha/discord-bot path: /src/commands.rs
use crate::config::{Config, StaticConfig};
use crate::grade::Grade;
use crate::platform::Platform;
use serenity::framework::standard::{
help_commands,
macros::{command, group, help},
Args, CommandGroup, CommandResult, HelpOptions,
};
use seren... | code_fim | hard | {
"lang": "rust",
"repo": "whsha/discord-bot",
"path": "/src/commands.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Inform the user of their new status, aswell as how to join the beta program
match &platform {
Some(platform) => {
msg.channel_id.send_message(&ctx, |m| {
m.embed(|e| {
... | code_fim | hard | {
"lang": "rust",
"repo": "whsha/discord-bot",
"path": "/src/commands.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut hmm = HMM::new(
obs,
init_dist_hat,
trans_mat_hat,
emit_mat_hat,
iteration
);
hmm.train();
println!("==================== Testing HMM ====================");
println!("Actual init_mat\n{:?}", model.init_dist);
println!("Estimate... | code_fim | hard | {
"lang": "rust",
"repo": "TangoJP/rusty_hmm",
"path": "/tests/test_hmm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TangoJP/rusty_hmm path: /tests/test_hmm.rs
use rusty_hmm::hmm::HMM;
use rusty_hmm::utility::eexpo;
use ndarray::Axis;
mod common;
#[test]
// #[ignore]
fn test_hmm1() {
let (model,
(init_dist_hat,
trans_mat_hat,
emit_mat_hat)
) = common::case1();
let ... | code_fim | hard | {
"lang": "rust",
"repo": "TangoJP/rusty_hmm",
"path": "/tests/test_hmm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KodrAus/log-enrich path: /examples/basic.rs
/*!
Try setting the `RUST_LOG` environment variable to `info` and run this example.
*/
#[macro_use]
extern crate log;
extern crate log_enrich;
use log_enrich::sync::logger;
fn main() {
log_enrich::init();
<|fim_suffix|> logger().... | code_fim | hard | {
"lang": "rust",
"repo": "KodrAus/log-enrich",
"path": "/examples/basic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger()
.enrich("correlation", "Some Id")
.enrich("operation", "request")
.scope(|| {
info!("handling a request for {}", "Timmy");
logger().enrich("operation", "database").scope(|| {
info!("doing database stu... | code_fim | medium | {
"lang": "rust",
"repo": "KodrAus/log-enrich",
"path": "/examples/basic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wisespace-io/fenrir path: /src/wigle/model.rs
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NetworkGeocodingStatus {
NetworkGeocodingSuccess(NetworkGeocodingResponse),
Netwo... | code_fim | hard | {
"lang": "rust",
"repo": "wisespace-io/fenrir",
"path": "/src/wigle/model.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Address {
pub road: String,
pub suburb: String,
pub city_district: String,
pub city: String,
pub county: String,
pub postcode: String,
pub country: String,
pub country_code: String
}
#[derive(Debug, Serialize, Des... | code_fim | hard | {
"lang": "rust",
"repo": "wisespace-io/fenrir",
"path": "/src/wigle/model.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct WifiNetworkResponse {
pub success: bool,
#[serde(rename = "totalResults")]
pub total_results: u32,
pub first: u32,
pub last: u32,
#[serde(rename = "resultCount")]
pub result_count: u32,
pub results: Vec<WifiNetwork>... | code_fim | hard | {
"lang": "rust",
"repo": "wisespace-io/fenrir",
"path": "/src/wigle/model.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>d stage;
pub mod storage;
pub mod worker;<|fim_prefix|>// repo: JakeSCahill/chronicle.rs path: /chronicle-storage/src/lib.rs
extern crate chronicle_common;
pub mod c<|fim_middle|>luster;
pub mod connection;
pub mod dashboard;
pub mod node;
pub mod ring;
pub mo | code_fim | medium | {
"lang": "rust",
"repo": "JakeSCahill/chronicle.rs",
"path": "/chronicle-storage/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>oard;
pub mod node;
pub mod ring;
pub mod stage;
pub mod storage;
pub mod worker;<|fim_prefix|>// repo: JakeSCahill/chronicle.rs path: /chronicle-storage/src/lib.rs
extern crate chronicle_common;
pub mod c<|fim_middle|>luster;
pub mod connection;
pub mod dashb | code_fim | easy | {
"lang": "rust",
"repo": "JakeSCahill/chronicle.rs",
"path": "/chronicle-storage/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JakeSCahill/chronicle.rs path: /chronicle-storage/src/lib.rs
extern crate chronicle_common;
pub mod cluster;
pub mod connection;
pub mod dashb<|fim_suffix|>d stage;
pub mod storage;
pub mod worker;<|fim_middle|>oard;
pub mod node;
pub mod ring;
pub mo | code_fim | easy | {
"lang": "rust",
"repo": "JakeSCahill/chronicle.rs",
"path": "/chronicle-storage/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> while iptr < len {
let mut count : usize = 1;
if let Some(c) = bf.code.chars().nth(iptr) {
match c {
'>' => dptr += 1,
'<' => dptr -= 1,
'+' => bf.data[dptr] += 1,
'-' => bf.data[dptr] -= 1,
'.'... | code_fim | hard | {
"lang": "rust",
"repo": "ikbenlike/brainfuck",
"path": "/brainfuck.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ikbenlike/brainfuck path: /brainfuck.rs
use std::fs::File;
use std::env;
use std::io::Read;
struct BrainFuck {
code : String,
data : [u8; 30000]
}
fn read_string(path : String) -> String {
use std::io::prelude::*;
let mut file = File::open(path).expect("No such file!");
let... | code_fim | hard | {
"lang": "rust",
"repo": "ikbenlike/brainfuck",
"path": "/brainfuck.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sile/xhttp2 path: /src/priority.rs
use std::io::{Read, Write};
use byteorder::{ByteOrder, BigEndian};
use futures::{Future, Poll};
use handy_async::io::{AsyncRead, AsyncWrite};
use handy_async::io::futures::{ReadExact, WriteAll};
use {Result, ErrorKind, Error};
use stream::StreamId;
#[derive(D... | code_fim | hard | {
"lang": "rust",
"repo": "sile/xhttp2",
"path": "/src/priority.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Priority {
is_exclusive: false,
stream_dependency: StreamId::connection_control_stream_id(),
weight: Weight::from_weight_minus_one(15),
}
}
}
#[derive(Debug)]
pub struct WritePriority<W>(WriteAll<W, [u8; 5]>);
impl<W: Write> Future for WritePriority... | code_fim | hard | {
"lang": "rust",
"repo": "sile/xhttp2",
"path": "/src/priority.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn load_csv(&self,
path: &str,
table_name: &str,
chunk_size: usize,
extractors: Vec<(String, Extractor)>) -> impl Future<Item=(), Error=oneshot::Canceled> {
let (sender, receiver) = oneshot::channel();
... | code_fim | hard | {
"lang": "rust",
"repo": "dropbox/ruba",
"path": "/src/ruba.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dropbox/ruba path: /src/ruba.rs
use std::str;
use std::sync::Arc;
// use rocksdb::{DB, Options, WriteBatch, IteratorMode, Direction};
// use tempdir::TempDir;
use QueryResult;
use QueryError;
use disk_store::db::*;
use disk_store::noop_storage::NoopStorage;
use engine::query_task::QueryTask;
us... | code_fim | hard | {
"lang": "rust",
"repo": "dropbox/ruba",
"path": "/src/ruba.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn table_stats(&self) -> impl Future<Item=Vec<TableStats>, Error=oneshot::Canceled> {
let inner = self.inner_ruba.clone();
let (task, receiver) = Task::from_fn(move || inner.stats());
self.schedule(task);
receiver
}
fn schedule<T: Task + 'static>(&self, tas... | code_fim | hard | {
"lang": "rust",
"repo": "dropbox/ruba",
"path": "/src/ruba.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
shape_1.last().unwrap(),
shape_2.first().unwrap(),
"Tensor shapes dont match for multiplication: {:?} and {:?}",
shape_1,
shape_2
);
let m1: ndarray::ArrayView<f32, Ix2> = m1.view().into_dimensionality().unwrap();
let m2: ndarray::ArrayV... | code_fim | medium | {
"lang": "rust",
"repo": "tiberiusferreira/Autograd-Experiments",
"path": "/src/tensor_backends/ndarray_backend/matmul2d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tiberiusferreira/Autograd-Experiments path: /src/tensor_backends/ndarray_backend/matmul2d.rs
use ndarray::prelude::*;
pub fn mm_ndarray(
m1: ndarray::ArrayView<f32, IxDyn>,
m2: ndarray::ArrayView<f32, IxDyn>,
) -> ndarray::Array<f32, IxDyn> {
let shape_1 = m1.shape();
let shape_... | code_fim | medium | {
"lang": "rust",
"repo": "tiberiusferreira/Autograd-Experiments",
"path": "/src/tensor_backends/ndarray_backend/matmul2d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrisbutcher/gameboy path: /src/fps.rs
extern crate time;
pub struct Counter {
frames: i32,
last_time: time::Instant,
print_fps: bool,
}
<|fim_suffix|> self.frames = 0;
self.last_time = time::Instant::now();
}
}
}<|fim_middle|>impl Counter {
pub fn new(print_fps: bool)... | code_fim | hard | {
"lang": "rust",
"repo": "chrisbutcher/gameboy",
"path": "/src/fps.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.frames = 0;
self.last_time = time::Instant::now();
}
}
}<|fim_prefix|>// repo: chrisbutcher/gameboy path: /src/fps.rs
extern crate time;
pub struct Counter {
frames: i32,
last_time: time::Instant,
print_fps: bool,
}
<|fim_middle|>impl Counter {
pub fn new(print_fps: bool)... | code_fim | hard | {
"lang": "rust",
"repo": "chrisbutcher/gameboy",
"path": "/src/fps.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: A2Williams/csci3055u-project-template path: /real-app/app/src/main.rs
use std::io::prelude::*;
use std::fs;
use std::net::TcpStream;
use std::net::TcpListener;
fn main() {
<|fim_suffix|> for stream in listener.incoming() {
let stream = stream.unwrap();
handle_connection(stre... | code_fim | medium | {
"lang": "rust",
"repo": "A2Williams/csci3055u-project-template",
"path": "/real-app/app/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // create a buffer for handling requests
let mut buffer = [0; 512];
// read the HTTP request
stream.read(&mut buffer).unwrap();
println!("Request: {}", String::from_utf8_lossy(&buffer[..]));
// response to the HTTP request with our HTML
let content = fs::read_to_string("rust.... | code_fim | medium | {
"lang": "rust",
"repo": "A2Williams/csci3055u-project-template",
"path": "/real-app/app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // follow chunk length with CRLF
buf[bytes_read] = CR;
buf[bytes_read + 1] = LF;
bytes_read += 2;
// copy chunk into buf
buf[bytes_read..bytes_read + chunk_lengt... | code_fim | hard | {
"lang": "rust",
"repo": "traviscross/async-h1",
"path": "/src/server.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: traviscross/async-h1 path: /src/server.rs
unked::ChunkedDecoder;
use crate::date::fmt_http_date;
use crate::{MAX_HEADERS, MAX_HEAD_LENGTH};
const CR: u8 = b'\r';
const LF: u8 = b'\n';
/// Accept a new incoming HTTP/1.1 connection.
///
/// Supports `KeepAlive` requests by default.
pub async fn ... | code_fim | hard | {
"lang": "rust",
"repo": "traviscross/async-h1",
"path": "/src/server.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ensure we have at least room for 1 byte in our buffer
if buffer_remaining == 0 {
break;
}
// we must allocate a separate buffer for the chunk data
// since we first need to know i... | code_fim | hard | {
"lang": "rust",
"repo": "traviscross/async-h1",
"path": "/src/server.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iota-community/streams path: /iota-streams-app/src/message/preparsed.rs
use anyhow::Result;
use core::fmt;
use super::*;
use iota_streams_core::sponge::prp::PRP;
use iota_streams_ddml::command::unwrap;
/// Message context preparsed for unwrapping.
pub struct PreparsedMessage<'a, F, Link> {
... | code_fim | hard | {
"lang": "rust",
"repo": "iota-community/streams",
"path": "/iota-streams-app/src/message/preparsed.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, F, Link> fmt::Debug for PreparsedMessage<'a, F, Link>
where
Link: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{{header: {:?}, ctx: {:?}}}", self.header, "self.ctx")
}
}<|fim_prefix|>// repo: iota-community/streams path: /iota-streams-ap... | code_fim | hard | {
"lang": "rust",
"repo": "iota-community/streams",
"path": "/iota-streams-app/src/message/preparsed.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: analogrelay/crustyclr path: /ecma355metadata/src/pe/pe_magic.rs
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
pub struct PeMagic(u16);
<|fim_suffix|> pub fn is_pe32plus(self) -> bool { self == PeMagic::PE32PLUS }
}
impl ::std::fmt::Display for PeMagic {
fn fmt(&self, f: &mut ::std::fmt::... | code_fim | medium | {
"lang": "rust",
"repo": "analogrelay/crustyclr",
"path": "/ecma355metadata/src/pe/pe_magic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_pe32plus(self) -> bool { self == PeMagic::PE32PLUS }
}
impl ::std::fmt::Display for PeMagic {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
match self {
&PeMagic::PE32 => f.write_str("PE32"),
&PeMagic::PE32PLUS => f.write... | code_fim | medium | {
"lang": "rust",
"repo": "analogrelay/crustyclr",
"path": "/ecma355metadata/src/pe/pe_magic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nouvadam/pathtracer path: /src/material/mod.rs
//! Ways of scattering/refracting incoming rays.
mod dielectric;
mod isotropic;
mod lambertian;
mod light_source;
mod metalic;
pub use dielectric::Dielectric;
pub use isotropic::Isotropic;
pub use lambertian::Lambertian;
pub use light_source::Ligh... | code_fim | hard | {
"lang": "rust",
"repo": "nouvadam/pathtracer",
"path": "/src/material/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Various functions needed to compute reflections, refractions etc.
/// Returns reflected, mirrored direction.
///
/// `v` - Incoming Ray.
///
/// `n` - Vector normal to the surface.
pub fn reflect(v: V3<f32>, n: V3<f32>) -> V3<f32> {
v - n * v.dot(n) * 2.0
}
/// Refraction using Snell's law. Retur... | code_fim | hard | {
"lang": "rust",
"repo": "nouvadam/pathtracer",
"path": "/src/material/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/generator/borrowing.rs
#![feature(generators, generator_trait)]
use std::ops::Generator;
use std::pin::Pin;
<|fim_suffix|> let _b = {
let a = 3;
|| {
yield &a
//~^ ERROR: `a` does not live long enough... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/generator/borrowing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _b = {
let a = 3;
|| {
yield &a
//~^ ERROR: `a` does not live long enough
}
};
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/generator/borrowing.rs
#![feature(generators, generator_trait)]
use std::ops::Generator;
u... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/generator/borrowing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e self::essentials::LifeRules;
use super::utils;<|fim_prefix|>// repo: shaddysignal/rust-life path: /src/life/mod.rs
mod universe;
mod essentials;
pub use self::universe::Universe;
pub use self::essentials::Cell;
<|fim_middle|>pub use self::essentials::CellFormFactor;
pub us | code_fim | easy | {
"lang": "rust",
"repo": "shaddysignal/rust-life",
"path": "/src/life/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaddysignal/rust-life path: /src/life/mod.rs
mod universe;
mod essentials;
pub use self::uni<|fim_suffix|>e self::essentials::LifeRules;
use super::utils;<|fim_middle|>verse::Universe;
pub use self::essentials::Cell;
pub use self::essentials::CellFormFactor;
pub us | code_fim | medium | {
"lang": "rust",
"repo": "shaddysignal/rust-life",
"path": "/src/life/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::essentials::CellFormFactor;
pub use self::essentials::LifeRules;
use super::utils;<|fim_prefix|>// repo: shaddysignal/rust-life path: /src/life/mod.rs
mod universe;
mod essentials;
pub use self::uni<|fim_middle|>verse::Universe;
pub use self::essentials::Cell;
| code_fim | easy | {
"lang": "rust",
"repo": "shaddysignal/rust-life",
"path": "/src/life/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SeSodesa/rustla path: /src/parser/tests/test_class.rs
/*!
A submodule for testing the class directive.
Copyright © 2020 Santtu Söderholm
*/
use super::*;
#[cfg(test)]
#[test]
fn class_01() {
let src =
"
.. class:: class1 class2 class3
This paragraph will receive the above class
attri... | code_fim | hard | {
"lang": "rust",
"repo": "SeSodesa/rustla",
"path": "/src/parser/tests/test_class.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> doctree = parser.parse().unwrap_tree();
doctree = doctree.walk_to_root();
doctree.print_tree();
if let TreeNodeType::Class { classes, .. } = doctree
.shared_child(0).unwrap().shared_data() {
assert_eq!(classes.join(" ").as_str(), "class1 class2 class3");
if let Tr... | code_fim | medium | {
"lang": "rust",
"repo": "SeSodesa/rustla",
"path": "/src/parser/tests/test_class.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jochasinga/rust-noob path: /day1/variable/src/main.rs
fn main() {
// `let` keyword declares a new variable.
// Rust will warn you about any unused variables you declare.
// Below reads "declare variable `name` of (inferred) type `String` and
// bind it to the value "Pan".
... | code_fim | hard | {
"lang": "rust",
"repo": "jochasinga/rust-noob",
"path": "/day1/variable/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Immutability is a very important topic in functional programming.
// Imagine a program that runs something as serious as an autopilot software
// for a real airplane. What happens if a global variable (meaning a variable
// that can be accessed from anywhere in a program) is mutable, an... | code_fim | medium | {
"lang": "rust",
"repo": "jochasinga/rust-noob",
"path": "/day1/variable/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vadim-kovalyov/allow-me path: /examples/json.rs
use allow_me::{Decision, PolicyBuilder, Request, Result};
fn main() -> Result<()> {
let json = r#"{
"statements": [
{
"effect": "allow",
"identities": [
"actor_a"
... | code_fim | hard | {
"lang": "rust",
"repo": "vadim-kovalyov/allow-me",
"path": "/examples/json.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Evaluate the request.
match policy.evaluate(&request)? {
Decision::Allowed => println!("Allowed"),
Decision::Denied => {
panic!("Denied!")
}
};
Ok(())
}<|fim_prefix|>// repo: vadim-kovalyov/allow-me path: /examples/json.rs
use allow_me::{Decision, P... | code_fim | hard | {
"lang": "rust",
"repo": "vadim-kovalyov/allow-me",
"path": "/examples/json.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // DANGER ZONE, read
// https://doc.rust-lang.org/std/mem/fn.transmute.html
// and
// https://doc.rust-lang.org/nomicon/transmutes.html
let output = deserializer
.take_u64_array(serializer.get_bytes())
.unwrap()
.0;
assert... | code_fim | hard | {
"lang": "rust",
"repo": "krampenschiesser/cbor_enhanced",
"path": "/core/examples/zerocopy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: krampenschiesser/cbor_enhanced path: /core/examples/zerocopy.rs
use cbor_enhanced::*;
fn main() {
let input: &str = r"Hello world";
let mut serializer = Serializer::new();
let deserializer = Deserializer::new();
<|fim_suffix|> #[cfg(feature = "iana_std")]
{
serializ... | code_fim | hard | {
"lang": "rust",
"repo": "krampenschiesser/cbor_enhanced",
"path": "/core/examples/zerocopy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "iana_std")]
{
serializer.reset();
let data = [42u64; 200];
let input: &[u64] = &data;
#[cfg(target_endian = "little")]
{
serializer.write_u64_le_array(input);
}
#[cfg(target_endian = "big")]
{
... | code_fim | hard | {
"lang": "rust",
"repo": "krampenschiesser/cbor_enhanced",
"path": "/core/examples/zerocopy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/pin-utils/src/stack_pin.rs
/
/
/
Pins
a
value
on
the
stack
.
/
/
/
/
/
/
#
Example
/
/
/
/
/
/
rust
/
/
/
#
use
pin_utils
:
:
pin_mut
;
/
/
/
#
use
core
:
:
pin
:
:
Pin
;
/
/
/
#
struct
<|fim_suffix|>t
{
(
(
x
:
ident
)
*
(
)
?
)
=
>
{
(
/
/
Mo... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/pin-utils/src/stack_pin.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>t
{
(
(
x
:
ident
)
*
(
)
?
)
=
>
{
(
/
/
Move
the
value
to
ensure
that
it
is
owned
let
mut
x
=
x
;
/
/
Shadow
the
original
binding
so
that
it
can
'
t
be
directly
accessed
/
/
ever
again
.
#
[
allow
(
unused_mut
)
]
let
mut
x
=
unsafe
{
crate
:
:
core_reexport
:
:
pin
:
:
Pin
:
:
new_unchecked
(
&
mut
x
)... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/pin-utils/src/stack_pin.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let code = totp.ascii_secret(&secret_ascii).generate();
println!("{}", code);
}<|fim_prefix|>// repo: enkhee-Osiris/totp path: /src/main.rs
use otp::totp::TOTP;
fn main() {
let secret = vec![
49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48,
];
... | code_fim | easy | {
"lang": "rust",
"repo": "enkhee-Osiris/totp",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: enkhee-Osiris/totp path: /src/main.rs
use otp::totp::TOTP;
fn main() {
let secret = vec![
49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48,
];
let secret_ascii = "12345678901234567890".to_owned();
let secret_hex = "31323334353637383930313233... | code_fim | easy | {
"lang": "rust",
"repo": "enkhee-Osiris/totp",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: logicchains/LPATHBench path: /rs.rs
#![feature(slicing_syntax)]
#![allow(deprecated)]
extern crate time;
extern crate test;
use time::{precise_time_ns};
use std::{cmp};
use tree::{Node};
mod tree {
use std::io::{BufferedReader, File};
use std::{mem};
use std::cell::{Cell};
p... | code_fim | hard | {
"lang": "rust",
"repo": "logicchains/LPATHBench",
"path": "/rs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tree = tree::read_places();
let start_time = precise_time_ns();
let path = get_longest_path(tree.nodes(), &tree.nodes()[0]);
let duration = (precise_time_ns() - start_time) / 1000000;
println!("{} LANGUAGE Rust {}", path, duration);
}<|fim_prefix|>// repo: logicchains/LPATHBench p... | code_fim | hard | {
"lang": "rust",
"repo": "logicchains/LPATHBench",
"path": "/rs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cur.visited.set(false);
max
}
fn main() {
let tree = tree::read_places();
let start_time = precise_time_ns();
let path = get_longest_path(tree.nodes(), &tree.nodes()[0]);
let duration = (precise_time_ns() - start_time) / 1000000;
println!("{} LANGUAGE Rust {}", path, duration... | code_fim | hard | {
"lang": "rust",
"repo": "logicchains/LPATHBench",
"path": "/rs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn solve_two(input: Vec<String>) {
let mut positions: Vec<Vec<i64>> = Vec::new();
let mut velocities: Vec<Vec<i64>> = Vec::new();
let mut gravity: Vec<Vec<i64>> = Vec::new();
for i in input {
velocities.push([0, 0, 0].to_vec());
gravity.push([0, 0, 0].to_vec());
po... | code_fim | hard | {
"lang": "rust",
"repo": "ArneVogel/aoc19",
"path": "/day12/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArneVogel/aoc19 path: /day12/src/main.rs
extern crate num;
use crate::num::Integer;
use std::collections::HashSet;
use std::env;
use std::io::{self, BufRead};
fn generate_gravity(positions: Vec<Vec<i64>>) -> Vec<Vec<i64>> {
let mut gravity: Vec<Vec<i64>> = Vec::new();
for (i, planet) i... | code_fim | hard | {
"lang": "rust",
"repo": "ArneVogel/aoc19",
"path": "/day12/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return axis;
}
fn solve_two(input: Vec<String>) {
let mut positions: Vec<Vec<i64>> = Vec::new();
let mut velocities: Vec<Vec<i64>> = Vec::new();
let mut gravity: Vec<Vec<i64>> = Vec::new();
for i in input {
velocities.push([0, 0, 0].to_vec());
gravity.push([0, 0, 0].t... | code_fim | hard | {
"lang": "rust",
"repo": "ArneVogel/aoc19",
"path": "/day12/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jkaessens/TheVault path: /src/main.rs
#[macro_use]
extern crate diesel;
mod config;
mod run;
mod web;
mod vaultdb;
mod samplesheet;
mod schema;
mod models;
use std::path::PathBuf;
use std::{collections::HashMap, error::Error, io::BufRead};
use diesel::PgConnection;
use env_logger::Env;
use st... | code_fim | hard | {
"lang": "rust",
"repo": "jkaessens/TheVault",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(samplesheet) = &samplesheet {
info!("Writing sample sheet to {}...", samplesheet.display());
match samplesheet.extension().unwrap().to_str().unwrap() {
"xlsx" => ss.write_xlsx(&overrides.iter().map(|s| s.as_ref()).collect::<Vec<&str>>(), samplesheet)?,
... | code_fim | hard | {
"lang": "rust",
"repo": "jkaessens/TheVault",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("You can choose from the following characters:\n - GoodArcherRogue\n - GoodMeleeRogue\n - GoodSwordsman\n - GoodTank");
// let mut heroes: Vec<Character> = squad::squad_from_file(hero_filepath, &character_folder);
let mut heroes: Vec<Character> = squad::squad_from_input(&character_fo... | code_fim | hard | {
"lang": "rust",
"repo": "Adam-Diehl/rust_strategy_rpg",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Adam-Diehl/rust_strategy_rpg path: /src/main.rs
#![allow(dead_code)]
// Imports => external packages
use colored::*;
use std::env;
use std::path::Path;
// Imports => internal packages
mod configs;
mod character;
mod combat;
mod input;
mod modifiers;
mod targeting;
mod squad;
use character::Ch... | code_fim | medium | {
"lang": "rust",
"repo": "Adam-Diehl/rust_strategy_rpg",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut villains: Vec<Character> = squad::squad_from_file(villain_filepath, &character_folder);
println!("You must defeat a squad of evil-doers consisting of the following characters: ");
for villains in villains.iter() {
villains.print_pretty_stats();
}
println!("You can choo... | code_fim | hard | {
"lang": "rust",
"repo": "Adam-Diehl/rust_strategy_rpg",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: templar721/website-wasm path: /src/data/project_list.rs
use lazy_static::lazy_static;
use serde_derive::Deserialize;
use std::collections::HashMap;
use std::sync::Mutex;
use yew::prelude::*;
use super::projects::{game_of_life, joshuto, ruiji, space_farmer_bot, website};
lazy_static! {
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "templar721/website-wasm",
"path": "/src/data/project_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub static PROJECT_LIST: ProjectListType = [
Project {
name: "Joshuto",
description: "Terminal File Manager",
url: "https://github.com/kamiyaa/joshuto",
languages: &["Rust"],
owner: "kamiyaa",
repo_name: "joshuto",
preview_url: "https://github.co... | code_fim | hard | {
"lang": "rust",
"repo": "templar721/website-wasm",
"path": "/src/data/project_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! resp_code {
($r:ident) => {
if !$r.success {
return Err($r.first_line);
}
};
}
#[macro_export]
macro_rules! parse_match {
($e:expr, $i:expr) => {
$e.name($i).expect(womp!()).as_str().parse().expect(womp!())
};
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "GallagherCommaJack/pushpop",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GallagherCommaJack/pushpop path: /src/util.rs
#[macro_export]
macro_rules! womp {
() => {
&format!("{}:{}:{}", file!(), line!(), column!())
};
($message:expr) => {
&format!("{}:{}:{} {}", file!(), line!(), column!(), $message)
};
}
<|fim_suffix|>#[macro_export]
m... | code_fim | hard | {
"lang": "rust",
"repo": "GallagherCommaJack/pushpop",
"path": "/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rebo/seed path: /src/app/subs/url_requested.rs
use crate::browser::Url;
use std::{cell::Cell, rc::Rc};
pub type PreventDefault = bool;
// ------ UrlRequested sub ------
/// Subscribe to url requests. Requests are fired on a link click.
///
/// # Example
///
/// ```rust,no_run
///orders.subscr... | code_fim | medium | {
"lang": "rust",
"repo": "rebo/seed",
"path": "/src/app/subs/url_requested.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for UrlRequest {
fn default() -> Self {
UrlRequest(Rc::new(Cell::new(UrlRequestStatus::Unhandled)))
}
}
impl UrlRequest {
/// Flag the url request as unhandled.
/// - Seed prevents page refresh, pushes the route and fires `UrlChanged` notification.
/// - It's the ... | code_fim | hard | {
"lang": "rust",
"repo": "rebo/seed",
"path": "/src/app/subs/url_requested.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
GameError::GeneralError(ref msg) => write!(fmt, "{}", msg),
}
}
}
impl Error for GameError {
fn description(&self) -> &str {
match *self {
GameError::GeneralError(ref msg) => msg,
}
}
}
type GameResult<T> = result::Result<T... | code_fim | medium | {
"lang": "rust",
"repo": "neosam/textgame",
"path": "/src/gameerror.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for GameError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
GameError::GeneralError(ref msg) => write!(fmt, "{}", msg),
}
}
}
impl Error for GameError {
fn description(&self) -> &str {
match *self {
Ga... | code_fim | medium | {
"lang": "rust",
"repo": "neosam/textgame",
"path": "/src/gameerror.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neosam/textgame path: /src/gameerror.rs
use std::result;
use std::fmt;
use std::error::Error;
<|fim_suffix|> match *self {
GameError::GeneralError(ref msg) => msg,
}
}
}
type GameResult<T> = result::Result<T, GameError>;<|fim_middle|>#[derive(Debug)]
pub enum Gam... | code_fim | hard | {
"lang": "rust",
"repo": "neosam/textgame",
"path": "/src/gameerror.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cmccord-dev/aoc2020 path: /src/days/day9.rs
use itertools::Itertools;
use crate::DayTrait;
type Input = u64;
type Output = u64;
const NUM: usize = 25;
#[derive(Default)]
pub struct Day {}
impl DayTrait<Input, Output> for Day {
fn get_num(&self) -> usize {
<|fim_suffix|> match input[... | code_fim | hard | {
"lang": "rust",
"repo": "cmccord-dev/aoc2020",
"path": "/src/days/day9.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let target = self.part1(input.clone());
let mut start = 0;
let mut end = 1;
let mut sum = input[0]+input[1];
loop {
match sum.cmp(&target) {
std::cmp::Ordering::Less => {
end += 1;
sum += input[end]... | code_fim | hard | {
"lang": "rust",
"repo": "cmccord-dev/aoc2020",
"path": "/src/days/day9.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input.windows(NUM+1).find(|x| {
let val = x[NUM];
match x[..NUM].iter().tuple_combinations().find(|(&y,&z)| y+z==val) {
Some(_) => false,
None => true
}
}).unwrap()[NUM]
}
fn part2(&self, input: Vec<Input>) -> Out... | code_fim | hard | {
"lang": "rust",
"repo": "cmccord-dev/aoc2020",
"path": "/src/days/day9.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let adj = edges[v].drain().collect::<Vec<_>>();
for w in adj {
edges[w].remove(&v);
if edges[w].is_empty() {
ans += 1;
}
}
}
println!("{}", ans);
}
}<|fim_prefix|>// repo: ia7ck/competitive... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/abc302/src/bin/e/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc302/src/bin/e/main.rs
use std::collections::HashSet;
use proconio::{input, marker::Usize1, fastout};
#[fastout]
fn main() {
input! {
n: usize,
q: usize,
};
let mut ans = n;
let mut edges = vec![HashSet::new(); n];... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/abc302/src/bin/e/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The name of the enum. This is a made up name on MySQL.
pub fn name(self) -> &'a str {
&self.get().name
}
/// The variants of the enum.
pub fn variants(self) -> impl ExactSizeIterator<Item = EnumVariantWalker<'a>> {
super::range_for_key(&self.schema.enum_variants, s... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/schema-engine/sql-schema-describer/src/walkers/enum.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prisma/prisma-engines path: /schema-engine/sql-schema-describer/src/walkers/enum.rs
use crate::{Enum, EnumId, EnumVariant, EnumVariantId, Walker};
/// Traverse an enum.
pub type EnumWalker<'a> = Walker<'a, EnumId>;
/// Traverse an enum variant.
pub type EnumVariantWalker<'a> = Walker<'a, EnumV... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/schema-engine/sql-schema-describer/src/walkers/enum.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.