text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: Alexhuszagh/bdb path: /src/db/uniprot/fasta.rs
.as_slice(),
b" SV=", to_bytes(&record.sequence_version)?.as_slice()
)?;
Ok(())
}
/// Export the TrEMBL header to FASTA.
///
/// Don't deduplicate this with SwissProt, they're very different
/// formats and we need to differentiate ... | code_fim | hard | {
"lang": "rust",
"repo": "Alexhuszagh/bdb",
"path": "/src/db/uniprot/fasta.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// WRITER -- DEFAULT
#[inline(always)]
fn init_cb<T: Write>(writer: &mut T, delimiter: u8)
-> Result<TextWriterState<T>>
{
Ok(TextWriterState::new(writer, delimiter))
}
#[inline(always)]
fn export_cb<'a, T: Write>(writer: &mut TextWriterState<T>, record: &'a Record)
-> Result<()>
{
write... | code_fim | hard | {
"lang": "rust",
"repo": "Alexhuszagh/bdb",
"path": "/src/db/uniprot/fasta.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alexhuszagh/bdb path: /src/db/uniprot/fasta.rs
tions during record exportation to string,
/// to minimize costly library calls.
#[inline]
fn estimate_record_size(record: &Record) -> usize {
// The vocabulary size is actually 20, overestimate to adjust for number export.
const FASTA_VOCAB... | code_fim | hard | {
"lang": "rust",
"repo": "Alexhuszagh/bdb",
"path": "/src/db/uniprot/fasta.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_cpu(&mut cpu, &mut nes, None);
}<|fim_prefix|>// repo: ykafia/Nes-Emulator-Rust path: /src/main.rs
mod components;
mod test;
mod utils;
use components::*;
use test::*;
fn main() {
<|fim_middle|> let mut nes = NesData::new();
let mut cpu = CPU6502::new();
| code_fim | medium | {
"lang": "rust",
"repo": "ykafia/Nes-Emulator-Rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ykafia/Nes-Emulator-Rust path: /src/main.rs
mod components;
mod test;
mod utils;
use components::*;
use test::*;
<|fim_suffix|> test_cpu(&mut cpu, &mut nes, None);
}<|fim_middle|>fn main() {
let mut nes = NesData::new();
let mut cpu = CPU6502::new();
| code_fim | medium | {
"lang": "rust",
"repo": "ykafia/Nes-Emulator-Rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/80433.rs
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
struct E {}
trait TestMut {
type Output<'a>;
fn test_mut(&mut self) -> Self::Output<'static>;
}
<|fim_suffix|>fn test_simpler(_: impl TestMut<Output = usize>) {}
fn main() {
... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/glacier",
"path": "/fixed/80433.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> todo!()
}
}
fn test_simpler(_: impl TestMut<Output = usize>) {}
fn main() {
test_simpler(E {});
}<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/80433.rs
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
struct E {}
<|fim_middle|>trait TestMut {
type Outpu... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/glacier",
"path": "/fixed/80433.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/lowpan/service/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.
//! LoWPAN Service for Fuchsia
pub mod inspect;
pub mod servic... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/lowpan/service/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Creates a new inspector object. This will create the "root" node in the
// inspect tree to which further children objects can be added.
let inspector = fuchsia_inspect::Inspector::new();
inspect_runtime::serve(&inspector, &mut fs)?;
let inspect_tree = Arc::new(inspect::LowpanService... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/lowpan/service/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexhenning/networktables-rs path: /src/errors.rs
use super::SequenceNumber;
use std::error::Error;
use std::error::FromError;
use std::io::IoError;
pub type NtResult<T> = Result<T, NtError>;
#[deriving(PartialEq,Eq,Show,Clone)]
pub enum NtErrorKind {
UnsupportedType(u8),
StringConver... | code_fim | hard | {
"lang": "rust",
"repo": "alexhenning/networktables-rs",
"path": "/src/errors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.kind {
NetworkProblem(ref err) => Some(&*err as &Error),
_ => None,
}
}
}
impl FromError<IoError> for NtError {
fn from_error(err: IoError) -> NtError {
NtError{kind: NetworkProblem(err)}
}
}<|fim_prefix|>// repo: alexhenning/networkt... | code_fim | hard | {
"lang": "rust",
"repo": "alexhenning/networktables-rs",
"path": "/src/errors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn create_tri_inds(&self) -> (Vec<usize>, Vec<usize>, Vec<f64>) {
let mut rows: Vec<usize> = Vec::with_capacity(WIN_SIZE * self.ncol * self.nrow);
let mut cols: Vec<usize> = Vec::with_capacity(WIN_SIZE * self.ncol * self.nrow);
let mut data: Vec<f64> = Vec::with_capacity(WIN_SI... | code_fim | hard | {
"lang": "rust",
"repo": "JackZhouSz/mediaComputing",
"path": "/image_matting/src/method/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JackZhouSz/mediaComputing path: /image_matting/src/method/mod.rs
pub mod image_method;
pub const WIN_LEN: usize = 3;
pub const WIN_SIZE: usize = WIN_LEN * WIN_LEN;
use crate::linear;
use linear::{M33, V3};
use crate::{matrix_able_ops_for_whole, matrix_math_ops_for_single_elem, matrix_double_i... | code_fim | hard | {
"lang": "rust",
"repo": "JackZhouSz/mediaComputing",
"path": "/image_matting/src/method/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if i > j {
rows.push(w.global_idx[i]);
cols.push(w.global_idx[j]);
data.push(w.inner_mat[(i, j)]);
rows.push(w.global_idx[j]);
cols.push(w.global_idx[i]);
... | code_fim | hard | {
"lang": "rust",
"repo": "JackZhouSz/mediaComputing",
"path": "/image_matting/src/method/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct GrayCodeFlipIterator {
length: u64,
current_index: u64,
max_index: u64,
}
impl GrayCodeFlipIterator {
fn new(GrayCodeFlip { length }: GrayCodeFlip) -> Self {
Self {
length,
current_index: 0,
max_index: 1 << len... | code_fim | hard | {
"lang": "rust",
"repo": "ban-m/gray_code",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ban-m/gray_code path: /src/lib.rs
#[derive(Debug, Clone, Copy)]
pub struct GrayCode {
length: u64,
}
impl GrayCode {
pub fn new(length: u64) -> Self {
Self { length }
}
}
#[derive(Debug, Clone, Copy)]
pub struct GrayCodeFlip {
length: u64,
}
impl GrayCodeFlip {
pub... | code_fim | hard | {
"lang": "rust",
"repo": "ban-m/gray_code",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
#[test]
fn zero_dig() {
let mut gc = GrayCode::new(0).into_iter();
assert_eq!(gc.next(), None);
}
#[test]
fn one_dig() {
let mut gc = GrayCode::new(1).... | code_fim | hard | {
"lang": "rust",
"repo": "ban-m/gray_code",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{} ({})", self.path.display(), self.io_error)
}
}
impl Error for DupError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
Some(&self.io_error)
}
}<|fim_prefix|>// repo: ttempleton/dupcheck path: /src/duperror.rs
use std::error::Error;
use std::fmt;
use std::... | code_fim | medium | {
"lang": "rust",
"repo": "ttempleton/dupcheck",
"path": "/src/duperror.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttempleton/dupcheck path: /src/duperror.rs
use std::error::Error;
use std::fmt;
use std::io;
use std::path::PathBuf;
#[derive(Debug)]
pub struct DupError {
path: PathBuf,
io_error: io::Error,
}
impl DupError {
pub fn new(path: PathBuf, io_error: io::Error) -> DupError {
Dup... | code_fim | medium | {
"lang": "rust",
"repo": "ttempleton/dupcheck",
"path": "/src/duperror.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DupError {
pub fn new(path: PathBuf, io_error: io::Error) -> DupError {
DupError { path, io_error }
}
}
impl fmt::Display for DupError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{} ({})", self.path.display(), self.io_error)
}
}
imp... | code_fim | medium | {
"lang": "rust",
"repo": "ttempleton/dupcheck",
"path": "/src/duperror.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xadic/rocket-pastebin path: /src/main.rs
#[macro_use]
extern crate rocket;
mod paste_id;
use paste_id::PasteId;
use rocket::data::{Data, ToByteUnit};
use rocket::response::Debug;
use rocket::tokio::fs::File;
// Home page
#[get("/")]
fn index() -> &'static str {
"
USAGE
<|fim_suffix|>... | code_fim | medium | {
"lang": "rust",
"repo": "xadic/rocket-pastebin",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Upload route
#[post("/", data = "<paste>")]
async fn upload(paste: Data<'_>) -> std::io::Result<String, Debug<std::io::Error>> {
let id = PasteId::new(5);
let filename = format!("upload/{id}", id = id);
let url = format!("{host}/{id}\n", host = "http://localhost:8000", id = id);
// Wri... | code_fim | hard | {
"lang": "rust",
"repo": "xadic/rocket-pastebin",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Saran51/akri path: /discovery-handlers/debug-echo/src/lib.rs
pub mod discovery_handler;
#[macro_use]
extern crate serde_derive;
/// Name debugEcho discovery handlers use when registering with the Agent
pub const DISCOVERY_HA<|fim_suffix|>ment variable that is set in debug echo brokers. Contain... | code_fim | hard | {
"lang": "rust",
"repo": "Saran51/akri",
"path": "/discovery-handlers/debug-echo/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> instances on nodes rather than ones visible to multiple nodes
pub const DEBUG_ECHO_INSTANCES_SHARED_LABEL: &str = "DEBUG_ECHO_INSTANCES_SHARED";
/// Name of environment variable that is set in debug echo brokers. Contains the description of
/// the device.
pub const DEBUG_ECHO_DESCRIPTION_LABEL: &str = "... | code_fim | medium | {
"lang": "rust",
"repo": "Saran51/akri",
"path": "/discovery-handlers/debug-echo/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ment variable that is set in debug echo brokers. Contains the description of
/// the device.
pub const DEBUG_ECHO_DESCRIPTION_LABEL: &str = "DEBUG_ECHO_DESCRIPTION";<|fim_prefix|>// repo: Saran51/akri path: /discovery-handlers/debug-echo/src/lib.rs
pub mod discovery_handler;
#[macro_use]
extern crate se... | code_fim | hard | {
"lang": "rust",
"repo": "Saran51/akri",
"path": "/discovery-handlers/debug-echo/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut controller = GameBoardController::new(board);
let game_view_settings = GameBoardViewSettings::new();
let board_view = GameBoardView::new(game_view_settings);
while let Some(event) = events.next(&mut window) {
controller.event(
board_view.settings.position,
... | code_fim | hard | {
"lang": "rust",
"repo": "joshradin/sudoku",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod advanced_solver;
mod game_board;
mod game_board_controller;
mod game_board_view;
pub mod game_creator;
mod game_settings;
pub mod validity;
fn main() {
let board: GameBoard;
let app = App::new("Sudoku")
.arg(
Arg::with_name("byte_string")
.help("Uses a... | code_fim | hard | {
"lang": "rust",
"repo": "joshradin/sudoku",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joshradin/sudoku path: /src/main.rs
#![deny(missing_docs)]
//! A Sudoku game
#[macro_use]
extern crate bitfield;
#[macro_use]
extern crate serde;
use std::str::FromStr;
use clap::{App, Arg};
use glutin_window::{GlutinWindow, OpenGL};
use opengl_graphics::{Filter, GlGraphics, GlyphCache, Text... | code_fim | hard | {
"lang": "rust",
"repo": "joshradin/sudoku",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn unpack_normal_11_10_11_no_normalize(pckd: f32) -> Vec3 {
let p = pckd.to_bits();
Vec3::new(
unpack_unorm(p, 11),
unpack_unorm(p >> 11, 10),
unpack_unorm(p >> 21, 11),
) * 2.0
- Vec3::ONE
}<|fim_prefix|>// repo: EmbarkStudios/kajiya path: /crates/lib/rust... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/kajiya",
"path": "/crates/lib/rust-shaders/src/pack_unpack.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EmbarkStudios/kajiya path: /crates/lib/rust-shaders/src/pack_unpack.rs
#![allow(dead_code)]
use macaw::Vec3;
fn unpack_unorm(pckd: u32, bit_count: u32) -> f32 {
<|fim_suffix|> let max_val = (1u32 << bit_count) - 1;
(val.clamp(0.0, 1.0) * max_val as f32) as u32
}
pub fn unpack_normal_11... | code_fim | medium | {
"lang": "rust",
"repo": "EmbarkStudios/kajiya",
"path": "/crates/lib/rust-shaders/src/pack_unpack.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> req.push(second_byte);
req.append(&mut bytes);
}
let mask: [u8; 4] = rand::random();
req.append(&mut mask.to_vec());
let payload_buffer = self.payload.as_bytes();
let mut payload_buffer = mask_data(mask, &payload_buffer);
r... | code_fim | hard | {
"lang": "rust",
"repo": "SickanK/discord-bot-rust",
"path": "/src/websockets/frame.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> req.push(first_byte);
if self.payload_length < 126 {
second_byte |= self.payload_length as u8;
req.push(second_byte);
} else {
let mut shift = match self.payload_length {
0..=65535 => 16,
_ => 64,
... | code_fim | hard | {
"lang": "rust",
"repo": "SickanK/discord-bot-rust",
"path": "/src/websockets/frame.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SickanK/discord-bot-rust path: /src/websockets/frame.rs
use super::opcode::RFC6455Opcode;
use rand;
#[derive(Debug, Clone)]
pub struct WSFrame {
pub fin: bool,
pub mask: bool,
pub opcode: RFC6455Opcode,
pub payload_length: usize,
pub payload: String,
}
impl WSFr... | code_fim | hard | {
"lang": "rust",
"repo": "SickanK/discord-bot-rust",
"path": "/src/websockets/frame.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub fn metadata(&self) -> DictionaryRef {
unsafe { DictionaryRef::wrap((*self.as_ptr()).metadata) }
}
#[inline]
pub fn set_metadata(&mut self, value: Dictionary) {
unsafe { (*self.as_mut_ptr()).metadata = value.disown() }
}
#[inline]
pub fn side_... | code_fim | hard | {
"lang": "rust",
"repo": "zmwangx/rust-ffmpeg",
"path": "/src/util/frame/mod.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub fn is_corrupt(&self) -> bool {
self.flags().contains(Flags::CORRUPT)
}
#[inline]
pub fn packet(&self) -> Packet {
unsafe {
Packet {
duration: (*self.as_ptr()).pkt_duration,
position: (*self.as_ptr()).pkt_pos,
... | code_fim | hard | {
"lang": "rust",
"repo": "zmwangx/rust-ffmpeg",
"path": "/src/util/frame/mod.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zmwangx/rust-ffmpeg path: /src/util/frame/mod.rs
pub mod side_data;
pub use self::side_data::SideData;
pub mod video;
pub use self::video::Video;
pub mod audio;
pub use self::audio::Audio;
pub mod flag;
pub use self::flag::Flags;
use ffi::*;
use {Dictionary, DictionaryRef};
#[derive(Partial... | code_fim | hard | {
"lang": "rust",
"repo": "zmwangx/rust-ffmpeg",
"path": "/src/util/frame/mod.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn iter_fn ()->u32{
let c = Counter::new()
.zip(Counter::new().skip(1))
.map(|(a, b)|a*b)
.filter(|x|x%3 == 0);
println!("{:?}",&c);
c.sum()
}<|fim_prefix|>// repo: 90designer/RustStudy path: /Study001/first_rs/17.... | code_fim | hard | {
"lang": "rust",
"repo": "90designer/RustStudy",
"path": "/Study001/first_rs/17.迭代器/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 90designer/RustStudy path: /Study001/first_rs/17.迭代器/lib.rs
#[derive(Debug)]
pub struct Counter{
pub count :u32,
}
impl Counter {
fn new()->Counter{
<|fim_suffix|>pub fn iter_fn ()->u32{
let c = Counter::new()
.zip(Counter::new().skip(1))
.m... | code_fim | hard | {
"lang": "rust",
"repo": "90designer/RustStudy",
"path": "/Study001/first_rs/17.迭代器/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qiangshou007/rust-trustnote path: /src/graph.rs
use error::Result;
use rusqlite::Connection;
use storage;
#[derive(Debug, Clone)]
pub struct UnitProps {
pub unit: String,
pub level: u32,
pub latest_included_mc_index: Option<u32>,
pub main_chain_index: Option<u32>,
pub is_on_... | code_fim | hard | {
"lang": "rust",
"repo": "qiangshou007/rust-trustnote",
"path": "/src/graph.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'go_down: loop {
let start_unit_list = start_units
.iter()
.map(|s| format!("'{}'", s))
.collect::<Vec<_>>()
.join(", ");
let sql = format!(
"SELECT units.unit, unit_authors.address AS author_in_list \
FROM paren... | code_fim | hard | {
"lang": "rust",
"repo": "qiangshou007/rust-trustnote",
"path": "/src/graph.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_334_solution() {
assert_eq!(true, Solution::increasing_triplet(vec![1, 2, 3, 4, 5]));
assert_eq!(false, Solution::increasing_triplet(vec![5, 4, 3, 2, 1]));
assert_eq!(true, Solution::increasing_triplet(vec![2, 1, 5... | code_fim | hard | {
"lang": "rust",
"repo": "tommady/leetcode",
"path": "/rust/src/p334_increasing_triplet_subsequence.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tommady/leetcode path: /rust/src/p334_increasing_triplet_subsequence.rs
// Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i j k and nums[i] nums[j] nums[k]. If no such indices exists, return false. Example 1: Input: nums = [1,2,3,4,5] Output: tru... | code_fim | medium | {
"lang": "rust",
"repo": "tommady/leetcode",
"path": "/rust/src/p334_increasing_triplet_subsequence.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_334_solution() {
assert_eq!(true, Solution::increasing_triplet(vec![1, 2, 3, 4, 5]));
assert_eq!(false, Solution::increasing_triplet(vec![5, 4, 3, 2, 1]));
assert_eq!(true, Solution::increasing_triplet(vec![2, 1, 5, 0, 4, 6]));
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "tommady/leetcode",
"path": "/rust/src/p334_increasing_triplet_subsequence.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut reversed_adjlist = vec![vec![]; adjlist.len()];
for node in 0..adjlist.len() {
for child in adjlist[node].iter() {
reversed_adjlist[*child].push(node);
}
}
reversed_adjlist
}
/// Build stack with finish times
fn dfs(
node: usize,
adjlist: &Vec<Vec<usize>>,
visited_no... | code_fim | hard | {
"lang": "rust",
"repo": "Lyr-7D1h/rust_graph_theory",
"path": "/graph_theory/kosaraju.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let counts = read_input();
let amount_nodes = counts[0];
let amount_edges = counts[1];
let adjlist = build_adjlist(amount_nodes, amount_edges);
let strong_components = kosaraju(adjlist);
let mut odd_count = 0;
let mut even_count = 0;
for comp in strong_components.iter() {
if comp.1.... | code_fim | hard | {
"lang": "rust",
"repo": "Lyr-7D1h/rust_graph_theory",
"path": "/graph_theory/kosaraju.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lyr-7D1h/rust_graph_theory path: /graph_theory/kosaraju.rs
use std::{collections::HashMap, io};
fn read_input() -> Vec<usize> {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
input = input.trim().to_string();
let input: Vec<&str> = input.split(" ").collect()... | code_fim | hard | {
"lang": "rust",
"repo": "Lyr-7D1h/rust_graph_theory",
"path": "/graph_theory/kosaraju.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pingcap/grpc-rust path: /http2/src/client_conf.rs
use std::time::Duration;
#[derive(Default, Debug, Clon<|fim_suffix|><String>,
pub connection_timeout: Option<Duration>
}<|fim_middle|>e)]
pub struct HttpClientConf {
/// TCP_NODELAY
pub no_delay: Option<bool>,
pub thread_name: Op... | code_fim | medium | {
"lang": "rust",
"repo": "pingcap/grpc-rust",
"path": "/http2/src/client_conf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|><String>,
pub connection_timeout: Option<Duration>
}<|fim_prefix|>// repo: pingcap/grpc-rust path: /http2/src/client_conf.rs
use std::time::Duration;
#[derive(Default, Debug, Clon<|fim_middle|>e)]
pub struct HttpClientConf {
/// TCP_NODELAY
pub no_delay: Option<bool>,
pub thread_name: Op... | code_fim | medium | {
"lang": "rust",
"repo": "pingcap/grpc-rust",
"path": "/http2/src/client_conf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielverkamp/crosvm path: /src/crosvm/sys/unix/config.rs
renderer_next"))]
pub fn parse_gpu_render_server_options(
s: &str,
) -> Result<crate::crosvm::sys::GpuRenderServerParameters, String> {
use crate::crosvm::sys::GpuRenderServerParameters;
let mut path: Option<PathBuf> = None;
... | code_fim | hard | {
"lang": "rust",
"repo": "danielverkamp/crosvm",
"path": "/src/crosvm/sys/unix/config.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielverkamp/crosvm path: /src/crosvm/sys/unix/config.rs
type(&self) -> VfioType {
self.dev_type
}
pub fn guest_address(&self) -> Option<PciAddress> {
self.params
.get("guest-address")
.and_then(|addr| PciAddress::from_str(addr).ok())
}
... | code_fim | hard | {
"lang": "rust",
"repo": "danielverkamp/crosvm",
"path": "/src/crosvm/sys/unix/config.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
assert!(from_key_values::<GpuDisplayParameters>("width=500").is_err());
}
{
assert!(from_key_values::<GpuDisplayParameters>("height=500").is_err());
}
{
assert!(from_key_values::<GpuDisplayParameters>("windowed,width=500").is_er... | code_fim | hard | {
"lang": "rust",
"repo": "danielverkamp/crosvm",
"path": "/src/crosvm/sys/unix/config.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let json_out = json!({
"es": dos.es,
"total_dos": dos.total_dos,
"orbital_dos": dos.orbital_dos,
"xlabel": xlabel,
"ylabel": ylabel,
"caption": caption,
"t_index": t_index,
"u": u,
"theta_deg": theta_deg,
});
let mut file... | code_fim | hard | {
"lang": "rust",
"repo": "tflovorn/blg_moire",
"path": "/src/bin/blg_moire_dos.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tflovorn/blg_moire path: /src/bin/blg_moire_dos.rs
extern crate num_complex;
extern crate ndarray;
extern crate itertools;
#[macro_use]
extern crate serde_json;
extern crate tightbinding;
extern crate blg_moire;
use std::f64::consts::PI;
use std::fs::File;
use std::io::Write;
use num_complex::C... | code_fim | hard | {
"lang": "rust",
"repo": "tflovorn/blg_moire",
"path": "/src/bin/blg_moire_dos.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let theta_deg = theta * 180.0 / PI;
let caption = format!(
r"$T_{} \, ; \, U / w = {:.2} \, ; \, \theta = {:.3}$ deg.",
t_index + 1,
u,
theta_deg
);
let json_out = json!({
"es": dos.es,
"total_dos": dos.total_dos,
"orbital_dos": dos.... | code_fim | hard | {
"lang": "rust",
"repo": "tflovorn/blg_moire",
"path": "/src/bin/blg_moire_dos.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Cursor { x, y, direction: Dir::S, visited: Vec::new(), steps: 0 }
}
fn pos(&self) -> (usize, usize) {
(self.x, self.y)
}
fn visit(&mut self, ch: char) {
self.visited.push(ch);
}
fn next_pos(&self, direction: &Dir) -> (usize, usize) {
let (dx, dy) = m... | code_fim | hard | {
"lang": "rust",
"repo": "modernserf/aoc-2017",
"path": "/day-19/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: modernserf/aoc-2017 path: /day-19/src/main.rs
fn main() {
let contents = include_str!("input.txt");
let plane = Plane::from_string(&contents);
let cursor = plane.traverse();
println!("part 1: {}", cursor.visited_str());
println!("part 2: {}", cursor.steps);
}
#[derive(Debug)... | code_fim | hard | {
"lang": "rust",
"repo": "modernserf/aoc-2017",
"path": "/day-19/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Plane {
fn from_string(s: &str) -> Plane {
let data = s.lines()
.map(|l| {
l.chars()
.map(|ch| Path::parse(ch))
.collect::<Vec<Path>>()
})
.collect::<Vec<Vec<Path>>>();
Plane { data }
... | code_fim | hard | {
"lang": "rust",
"repo": "modernserf/aoc-2017",
"path": "/day-19/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl<S: Store> Counterstore for ClientCounterstore<S> {
fn create_starting_at(
&mut self,
location: Location,
starting_at: impl Into<Counter>,
) -> Result<CounterId> {
let id = CounterId::new(&mut self.rng);
self.write_counter(location, id, starting_at.in... | code_fim | hard | {
"lang": "rust",
"repo": "trussed-dev/trussed",
"path": "/src/store/counterstore.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trussed-dev/trussed path: /src/store/counterstore.rs
use littlefs2::{
path,
path::{Path, PathBuf},
};
use rand_chacha::ChaCha8Rng;
use crate::{
error::{Error, Result},
store::{self, Store},
types::{CounterId, Location},
};
pub struct ClientCounterstore<S>
where
S: Store... | code_fim | hard | {
"lang": "rust",
"repo": "trussed-dev/trussed",
"path": "/src/store/counterstore.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
location: Location,
starting_at: impl Into<Counter>,
) -> Result<CounterId>;
fn create(&mut self, location: Location) -> Result<CounterId> {
self.create_starting_at(location, Self::DEFAULT_START_AT)
}
fn increment(&mut self, id: CounterId) -> Resu... | code_fim | hard | {
"lang": "rust",
"repo": "trussed-dev/trussed",
"path": "/src/store/counterstore.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forklifters/Sanka path: /src/tracker/announce.rs
use std::net::{SocketAddrV4, SocketAddrV6};
use std::time::Duration;
use tracker::torrent::{Stats, Peers};
pub struct Announce {
pub info_hash: String,
pub peer_id: String,
pub passkey: Option<String>,
pub ipv4: Option<SocketAddr... | code_fim | hard | {
"lang": "rust",
"repo": "forklifters/Sanka",
"path": "/src/tracker/announce.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AnnounceResponse {
pub fn new(peers: Peers, stats: Stats, compact: bool, announce_int: Duration, min_announce_int: Duration) -> AnnounceResponse {
AnnounceResponse {
peers: peers,
stats: stats,
compact: compact,
announce_int: announce_int,
... | code_fim | hard | {
"lang": "rust",
"repo": "forklifters/Sanka",
"path": "/src/tracker/announce.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YuhanLiin/Advent-of-Code-2020 path: /src/day2.rs
"4-7 f: xfffkvfqzwhcfwkhq".to_owned(),
"4-10 q: qqqqqcqbqqq".to_owned(),
"14-15 s: lgszsdststlpgjbs".to_owned(),
"7-12 s: sspbsssskfns".to_owned(),
"7-8 d: cdddqpnd".to_owned(),
... | code_fim | hard | {
"lang": "rust",
"repo": "YuhanLiin/Advent-of-Code-2020",
"path": "/src/day2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> "3-16 w: drcbwtvqgbppbwzvm".to_owned(),
"8-10 d: ddbddddzdddddkpd".to_owned(),
"8-9 m: mmmmmmmmmmmm".to_owned(),
"1-3 l: glll".to_owned(),
"7-11 x: fxrxxdxxxqxnxx".to_owned(),
"6-7 d: ddddxgdd".to_owned(),
"7-8 g: hgggbggg".t... | code_fim | hard | {
"lang": "rust",
"repo": "YuhanLiin/Advent-of-Code-2020",
"path": "/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>(),
"3-11 n: vlntglzvvcnngn".to_owned(),
"3-8 v: rpgckwptlvdqsrqqt".to_owned(),
"6-11 q: qdqdkqvkvhdrdqm".to_owned(),
"9-12 b: khbmbgbbvbqb".to_owned(),
"9-10 g: gtggggggczgg".to_owned(),
"3-5 c: zqctcs".to_owned(),
"15-18... | code_fim | hard | {
"lang": "rust",
"repo": "YuhanLiin/Advent-of-Code-2020",
"path": "/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_secs(secs: u64) -> Self {
Self(Seconds::from_secs(secs))
}
pub fn as_secs(&self) -> u64 {
self.0.as_u64()
}
}
impl From<Duration> for Age {
fn from(dur: Duration) -> Self {
Age(Seconds::from(dur))
}
}
impl From<Age> for Duration {
fn ... | code_fim | medium | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/headers/src/common/age.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/headers/src/common/age.rs
use std::time::Duration;
use util::Seconds;
<|fim_suffix|>
pub fn as_secs(&self) -> u64 {
self.0.as_u64()
}
}
impl From<Duration> for Age {
fn from(dur: Duration) -> Se... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/headers/src/common/age.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn as_secs(&self) -> u64 {
self.0.as_u64()
}
}
impl From<Duration> for Age {
fn from(dur: Duration) -> Self {
Age(Seconds::from(dur))
}
}
impl From<Age> for Duration {
fn from(age: Age) -> Self {
age.0.into()
}
}<|fim_prefix|>// repo: marco-c/geck... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/headers/src/common/age.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> env_logger::init().unwrap();
info!("starting up");
let server_config = ServerConfig::read();
let (mut server_handler, mut ev_loop) = Server::new(server_config);
info!("starting event loop");
ev_loop.run(&mut server_handler).unwrap();
}<|fim_prefix|>// repo: oldtree2008/floki path:... | code_fim | hard | {
"lang": "rust",
"repo": "oldtree2008/floki",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oldtree2008/floki path: /src/main.rs
#![allow(dead_code)]
#![feature(slice_patterns)]
#![cfg_attr(test, feature(test))]
#[cfg(test)] extern crate test;
#[cfg(test)] extern crate redis;
<|fim_suffix|> env_logger::init().unwrap();
info!("starting up");
let server_config = ServerConfig... | code_fim | hard | {
"lang": "rust",
"repo": "oldtree2008/floki",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(test))]
pub fn main() {
use config::ServerConfig;
use server::Server;
env_logger::init().unwrap();
info!("starting up");
let server_config = ServerConfig::read();
let (mut server_handler, mut ev_loop) = Server::new(server_config);
info!("starting event loop");
ev... | code_fim | medium | {
"lang": "rust",
"repo": "oldtree2008/floki",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
trait G {
fn m(&self);
}
struct X;
impl F for X {
fn m(&self) {
println!("I am F");
}
}
impl G for X {
fn m(&self) {
println!("I am G");
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "rustkas/error-index",
"path": "/main_tests/tests/e0034.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl F for X {
fn m(&self) {
println!("I am F");
}
}
impl G for X {
fn m(&self) {
println!("I am G");
}
}
let f = X;
F::m(&f); // it displays "I am F"
G::m(&f); // it d... | code_fim | hard | {
"lang": "rust",
"repo": "rustkas/error-index",
"path": "/main_tests/tests/e0034.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustkas/error-index path: /main_tests/tests/e0034.rs
// #![allow(unused)]
/*
cargo test --test e0034
cargo test --test e0034 with_error -- --nocapture
cargo test --test e0034 without_error1 -- --nocapture
*/
/*
The compiler doesn't know what method to call because more than one method has the... | code_fim | hard | {
"lang": "rust",
"repo": "rustkas/error-index",
"path": "/main_tests/tests/e0034.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[doc = "Getter for the `position` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement/position)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlProgressEleme... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_HtmlProgressElement.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ld of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement/max)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlProgressElement`*"]
pub fn max(this: &HtmlProgressElement... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_HtmlProgressElement.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_HtmlProgressElement.rs
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = HtmlElement , extends = Element , extends = Node , extends ... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_HtmlProgressElement.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ScottBailey/project_euler path: /p0006/src/main.rs
// https://projecteuler.net/problem=6
/*
The sum of the squares of the first ten natural numbers is,
1^2+2^2+...+10^2=385
The square of the sum of the first ten natural numbers is,
(1+2+...+10)^2=552=3025
Hence the difference between t... | code_fim | medium | {
"lang": "rust",
"repo": "ScottBailey/project_euler",
"path": "/p0006/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let max : u64 = 100;
let mut sum1 : u64 = 0;
let mut sum2 : u64 = 0;
for i in 1..=max {
sum1 += i*i;
sum2 += i;
}
sum2 *= sum2;
println!("{} - {} = {}", sum2, sum1, sum2-sum1);
}<|fim_prefix|>// repo: ScottBailey/project_euler path: /p0006/src/main.rs
// htt... | code_fim | medium | {
"lang": "rust",
"repo": "ScottBailey/project_euler",
"path": "/p0006/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let token = client_credentials_flow::perform(
http_client.clone(),
&client_id,
&client_secret,
&[&format!(
"https://{storage_account_name}.blob.core.windows.net/.default"
)],
&tenant_id,
)
.await?;
println!("token received: {toke... | code_fim | medium | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/identity/examples/client_credentials_flow_blob.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /sdk/identity/examples/client_credentials_flow_blob.rs
use azure_core::date;
use azure_identity::client_credentials_flow;
use time::OffsetDateTime;
use std::env;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let client_... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/identity/examples/client_credentials_flow_blob.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dt = OffsetDateTime::now_utc();
let time = date::to_rfc1123(&dt);
println!("x-ms-date ==> {time}");
let resp = reqwest::Client::new()
.get(&format!(
"https://{storage_account_name}.blob.core.windows.net/{container_name}?restype=container&comp=list"
))
... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/identity/examples/client_credentials_flow_blob.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/abi_stable_crates path: /abi_stable/src/std_types/slices.rs
use std::{
borrow::Borrow,
io::{self, BufRead, Read},
marker::PhantomData,
ops::{Deref, Index},
};
#[allow(unused_imports)]
use core_extensions::prelude::*;
use serde::{Deserialize, Deserializer, Serializ... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/abi_stable_crates",
"path": "/abi_stable/src/std_types/slices.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> *self
}
}
impl<'a, T> Default for RSlice<'a, T> {
fn default() -> Self {
(&[][..]).into()
}
}
impl<'a, T> IntoIterator for RSlice<'a, T> {
type Item = &'a T;
type IntoIter = ::std::slice::Iter<'a, T>;
fn into_iter(self) -> ::std::slice::Iter<'a, T> {
sel... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/abi_stable_crates",
"path": "/abi_stable/src/std_types/slices.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T: 'a> Deref for RSlice<'a, T> {
type Target = [T];
fn deref(&self) -> &Self::Target {
self.as_slice()
}
}
impl_into_rust_repr! {
impl['a, T] Into<&'a [T]> for RSlice<'a, T> {
fn(this){
this.as_slice()
}
}
}
////////////////////
impl<'a... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/abi_stable_crates",
"path": "/abi_stable/src/std_types/slices.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vtselfa/gps-server path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
extern crate chrono;
extern crate gps_lib;
extern crate lazy_static;
extern crate log;
extern crate regex;
extern crate rust_decimal;
extern crate serde_json;
extern crate strum;
... | code_fim | hard | {
"lang": "rust",
"repo": "vtselfa/gps-server",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let state: &types::State = state.inner();
match serde_json::to_string(state) {
Err(e) => {
let msg = format!("Could not serialize program state: {}", e);
error!("{}", msg);
Err(response::status::Custom::<String>(
Status::InternalServerErr... | code_fim | hard | {
"lang": "rust",
"repo": "vtselfa/gps-server",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *state.replacing_state.write().unwrap() = true;
let state = state.inner();
state.next_public_token.swap(0, Ordering::SeqCst);
state.next_item_id.store(0, Ordering::SeqCst);
state.wsids.write().unwrap().clear();
state.public_tokens.write().unwrap().clear();
state.transactions.w... | code_fim | hard | {
"lang": "rust",
"repo": "vtselfa/gps-server",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbowles/snips-nlu-ontology path: /snips-nlu-ontology-parsers-ffi-macros/src/lib.rs
extern crate failure;
extern crate libc;
extern crate serde;
extern crate serde_json;
extern crate snips_nlu_ontology;
extern crate snips_nlu_ontology_ffi_macros;
extern crate snips_nlu_ontology_parsers;
#[macro_u... | code_fim | hard | {
"lang": "rust",
"repo": "jbowles/snips-nlu-ontology",
"path": "/snips-nlu-ontology-parsers-ffi-macros/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[no_mangle]
pub extern "C" fn snips_nlu_ontology_persist_gazetteer_entity_parser(
ptr: *const $crate::CGazetteerEntityParser,
path: *const ::libc::c_char,
) -> ::ffi_utils::SNIPS_RESULT {
wrap!($crate::persist_gazetteer_entity_parser(ptr, path))... | code_fim | hard | {
"lang": "rust",
"repo": "jbowles/snips-nlu-ontology",
"path": "/snips-nlu-ontology-parsers-ffi-macros/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::BlackoutError as Error;
use super::{BlackoutError, CommandError, CommonOpts, RebootType, Test, TestStep};
use {
async_trait::async_trait,
fuchsia_async as fasync,
std::{
os::unix::process::ExitStatusExt,
proces... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/tools/blackout/blackout-host/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /tools/blackout/blackout-host/src/lib.rs
nd
/// stderr of the command.
#[derive(Debug, Error)]
#[error(
"failed to run command: {}\n\
stdout:\n\
{}\n\
stderr:\n\
{}",
_0,
_1,
_2
)]
pub struct Comma... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/tools/blackout/blackout-host/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Add a test step for generating load on the device using the `test` subcommand on the target
/// binary. This load doesn't terminate. After `duration`, it checks to make sure the command is
/// still running, then return.
pub fn load_step(&mut self, duration: Option<Duration>) -> &mut S... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/tools/blackout/blackout-host/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, H> SignedBufferDecoder<'a, H> where H: Hasher + Default {
fn new(s: &'a SignedBuffer<'a, H>, offset: usize) -> Self {
SignedBufferDecoder {
s: s,
state: State::Header { remaining: s.header_magic_bytes.len() },
offset: offset,
hasher: Def... | code_fim | hard | {
"lang": "rust",
"repo": "hashmismatch/signed_buffer.rs",
"path": "/src/sign.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hashmismatch/signed_buffer.rs path: /src/sign.rs
use prelude::v1::*;
use base::*;
use structs::*;
use siphasher::sip::SipHasher24;
use packed_struct::*;
#[derive(Debug)]
pub struct SignedBuffer<'a, H> {
size: BufferSize,
header_magic_bytes: &'a[u8],
trailer_magic_bytes: &'a[u8],
_hashe... | code_fim | hard | {
"lang": "rust",
"repo": "hashmismatch/signed_buffer.rs",
"path": "/src/sign.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if remaining == 1 {
Ok(State::Trailer { checksum: checksum, payload_offset: start_offset, remaining: self.s.trailer_magic_bytes.len() })
} else {
Ok(State::Payload { checksum: checksum, start_offset: start_offset, remaining: remaining... | code_fim | hard | {
"lang": "rust",
"repo": "hashmismatch/signed_buffer.rs",
"path": "/src/sign.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johannesvollmer/tray_rust path: /src/geometry/intersection.rs
//! Defines the Intersection type which stores information about
//! a full intersection, eg. hit info about the geometry and instance
//! that was intersected
<|fim_suffix|>impl<'a, 'b> Intersection<'a, 'b> {
/// Construct the I... | code_fim | hard | {
"lang": "rust",
"repo": "johannesvollmer/tray_rust",
"path": "/src/geometry/intersection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Stores information about an intersection that occured with some instance
/// of geometry in the scene
#[derive(Clone, Copy)]
pub struct Intersection<'a, 'b> {
/// The differential geometry holding information about the piece of geometry
/// that was hit
pub dg: DifferentialGeometry<'a>,
... | code_fim | medium | {
"lang": "rust",
"repo": "johannesvollmer/tray_rust",
"path": "/src/geometry/intersection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn init() {}
pub fn read_raw(&mut self) -> Vec<String> {
let mut raw = Vec::new();
let mut reader = BufReader::new(&self.fd);
let length = reader.seek(SeekFrom::End(0)).unwrap();
if length > 80000 {
reader.seek(SeekFrom::End(-80000)).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "darval/viewerator",
"path": "/src/log_display.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: darval/viewerator path: /src/log_display.rs
use log::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::io::Seek;
use std::io::SeekFrom;
pub struct LogDisplay {
fd: File,
}
impl Default for LogDisplay {
fn default() -> LogDisplay {
<|fim_suffix|> pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "darval/viewerator",
"path": "/src/log_display.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.