text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>// Super buggy rn
fn binomial_probability_info() {
loop {
let mut continue_execution: bool = true;
println!("BINOMIAL PROBABILITY");
println!("0. Exit");
println!("1. Binomial Probability Formula");
println!("2. Binomial Probability Distribution Generator");
... | code_fim | hard | {
"lang": "rust",
"repo": "chungmcl/statscalc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chungmcl/statscalc path: /src/main.rs
use std::io;
use std::io::Write;
mod general_funcs;
mod central_tendency;
mod measures_of_variation;
mod measures_of_position;
mod arrangements;
mod probability_distributions;
mod binomial_probability;
mod normal_distributions;
fn main() {
loop {
... | code_fim | hard | {
"lang": "rust",
"repo": "chungmcl/statscalc",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: transparencies/automerge-rs path: /perf/src/main.rs
use std::{
fs::File,
io::Read,
time::{Duration, Instant},
};
use automerge::{Backend, Frontend, InvalidChangeRequest, LocalChange, Path, Primitive};
use automerge_frontend::Value;
use maplit::hashmap;
use rand::Rng;
use smol_str::S... | code_fim | hard | {
"lang": "rust",
"repo": "transparencies/automerge-rs",
"path": "/perf/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = Instant::now();
let doc1_insert_change = doc1
.change::<_, _, InvalidChangeRequest>(None, |d| {
let weight = if len > 100 {
if len > 1000 {
0.45
} else {
0.55
... | code_fim | hard | {
"lang": "rust",
"repo": "transparencies/automerge-rs",
"path": "/perf/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if matches.opt_present("u") {
state.underline = true;
} else {
state.underline = false;
}
if matches.opt_present("b") {
state.bold = true;
} else {
state.bold = false;
}
if matches.opt_present("condensed") {
state.condensed = true;
... | code_fim | hard | {
"lang": "rust",
"repo": "player999/escpctl",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: player999/escpctl path: /src/main.rs
use std::io;
use std::io::{Read, Write};
use std::env;
extern crate iconv;
extern crate getopts;
#[derive(Copy, Clone, PartialEq)]
enum CharacterTable {
CP866,
CP437
}
#[derive(Copy, Clone, PartialEq)]
enum TypeFace {
Draft,
Roman,
Serif... | code_fim | hard | {
"lang": "rust",
"repo": "player999/escpctl",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(columns <= 80);
let mut epson_command: Vec<u8> = vec![0x1B, 0x51];
epson_command.push(columns as u8);
let sz = io::stdout().write(epson_command.as_slice()).unwrap();
assert_eq!(epson_command.len(), sz);
}
fn set_font(f: TypeFace) {
let epson_command: Vec<u8> = match f {
... | code_fim | hard | {
"lang": "rust",
"repo": "player999/escpctl",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let head = self.head();
let [dx, dy] = self.direction.as_tuple();
[head[0] + dx, head[1] + dy]
}
pub fn render(&self, alive: bool, gl: &mut GlGraphics, transform: Matrix2d) {
let color = if alive { COLOR_SNAKE } else { COLOR_DEAD_SNAKE };
for pos in &self.p... | code_fim | hard | {
"lang": "rust",
"repo": "JonathanMurray/rust-snake",
"path": "/src/entities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JonathanMurray/rust-snake path: /src/entities.rs
use common;
use common::Direction;
use common::{Color, Position, CELL_WIDTH};
use graphics::types::Matrix2d;
use opengl_graphics::GlGraphics;
use std::fmt::Debug;
const COLOR_SNAKE: Color = [1.0, 1.0, 0.0, 1.0];
const COLOR_DEAD_SNAKE: Color = [1... | code_fim | hard | {
"lang": "rust",
"repo": "JonathanMurray/rust-snake",
"path": "/src/entities.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn position_one_step_forward(&self) -> Position {
let head = self.head();
let [dx, dy] = self.direction.as_tuple();
[head[0] + dx, head[1] + dy]
}
pub fn render(&self, alive: bool, gl: &mut GlGraphics, transform: Matrix2d) {
let color = if alive { COLOR_SNAKE }... | code_fim | hard | {
"lang": "rust",
"repo": "JonathanMurray/rust-snake",
"path": "/src/entities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanwallawalla-forks/nushell path: /crates/nu-command/src/commands/math/command.rs
use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{Signature, UntaggedValue};
pub struct Command;
impl WholeStreamCommand for Command {
fn name(&self) -> &... | code_fim | hard | {
"lang": "rust",
"repo": "seanwallawalla-forks/nushell",
"path": "/crates/nu-command/src/commands/math/command.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct TestCase {
description: &'static str,
values: Vec<Value>,
expected_err: Option<ShellError>,
// Order is: average, minimum, maximum, median, summation
expected_res: Vec<Result<Value, ShellError>>,
}
let tt: Vec<TestC... | code_fim | hard | {
"lang": "rust",
"repo": "seanwallawalla-forks/nushell",
"path": "/crates/nu-command/src/commands/math/command.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BrentClarke/swc path: /ecmascript/minifier/src/debug.rs
use swc_common::sync::Lrc;
use swc_common::SourceMap;
use swc_common::SyntaxContext;
use swc_ecma_ast::Ident;
use swc_ecma_ast::StrKind;
use swc_ecma_codegen::text_writer::JsWriter;
use swc_ecma_codegen::Emitter;
use swc_ecma_utils::drop_sp... | code_fim | hard | {
"lang": "rust",
"repo": "BrentClarke/swc",
"path": "/ecmascript/minifier/src/debug.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> n.sym = format!("{}{:?}", n.sym, n.span.ctxt).into();
n.span.ctxt = SyntaxContext::empty();
}
fn visit_mut_str_kind(&mut self, n: &mut StrKind) {
*n = Default::default();
}
}
pub(crate) fn dump<N>(node: &N) -> String
where
N: swc_ecma_codegen::Node + Clone + Visit... | code_fim | hard | {
"lang": "rust",
"repo": "BrentClarke/swc",
"path": "/ecmascript/minifier/src/debug.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let hit_record = world.hit(ray, 0.001, std::f64::MAX);
match hit_record {
Some(rec) => {
let (attenuation, scattered, scatter) = rec.material.scatter(ray, &rec);
if scatter && depth < 50 {
return attenuation * color(&scattered, world, depth + 1);
... | code_fim | hard | {
"lang": "rust",
"repo": "tebari/rayitos",
"path": "/src/renderers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tebari/rayitos path: /src/renderers.rs
use crate::hittables::{Dielectric, Hittable, HittableList, Lambertian, Metal, Sphere};
use crate::image::{color_float_to_u8, Image, Pixel, Tile};
use crate::ray::Ray;
use crate::rng::{random_f64, random_in_unit_sphere};
use crate::vector::Vector3;
use num_c... | code_fim | hard | {
"lang": "rust",
"repo": "tebari/rayitos",
"path": "/src/renderers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tiles = multithread_render(width, height, camera, world, tiles);
Image::from_tiles(width, height, tiles)
}
pub fn draw_trio(width: u32, height: u32) -> Image {
let height_float = height as f64;
let width_float = width as f64;
let lookfrom = Vector3::new(3.0, 3.0, 2.0);
let lo... | code_fim | hard | {
"lang": "rust",
"repo": "tebari/rayitos",
"path": "/src/renderers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn new_cell() -> Cell<'static> {
Cell {
value: ExcelValue::None,
formula: "".to_string(),
reference: "".to_string(),
style: "".to_string(),
cell_type: "".to_string(),
raw_value: "".to_string(),
}
}
fn empty_row(num_cols: u16, this_row: usize) -> Opt... | code_fim | hard | {
"lang": "rust",
"repo": "techwoes/xl",
"path": "/src/ws.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: techwoes/xl path: /src/ws.rs
es are a little trickier to get right. So we use the style
/// information when we can.
/// - Lastly, the `date_system` is used to determine what date we are looking at for cells that
/// contain date values. See the documentation for the `DateSystem`... | code_fim | hard | {
"lang": "rust",
"repo": "techwoes/xl",
"path": "/src/ws.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: techwoes/xl path: /src/ws.rs
trings` argument should be reference to the vector of strings used in the xlsx. As
/// background, xlsx files do not store strings directly in each spreadsheet's xml file.
/// Instead, there is a special file that contains all the strings in the workbook ... | code_fim | hard | {
"lang": "rust",
"repo": "techwoes/xl",
"path": "/src/ws.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackgerrits/vowpalwabbit-rs path: /vowpalwabbit/src/hash.rs
use byteorder::{LittleEndian, ReadBytesExt};
use std::io::Cursor;
fn fmix(mut h: u32) -> u32 {
h ^= h >> 16;
h = h.wrapping_mul(0x85eb_ca6b);
h ^= h >> 13;
h = h.wrapping_mul(0xc2b2_ae35);
h ^= h >> 16;
h
}
#[a... | code_fim | hard | {
"lang": "rust",
"repo": "jackgerrits/vowpalwabbit-rs",
"path": "/vowpalwabbit/src/hash.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Test truth values calculated using C++ implementation.
#[test]
fn fmix_tests() {
assert_eq!(fmix(0), 0);
assert_eq!(fmix(1), 1364076727);
assert_eq!(fmix(5), 3423425485);
assert_eq!(fmix(2147483647), 4190899880);
assert_eq!(fmix(4294967295), 218008351... | code_fim | hard | {
"lang": "rust",
"repo": "jackgerrits/vowpalwabbit-rs",
"path": "/vowpalwabbit/src/hash.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: normanlorrain/tectonic path: /src/bin/tectonic/v2cli.rs
ge_enum_variant)]
#[derive(Debug, StructOpt)]
enum Commands {
#[structopt(name = "build")]
/// Build a document
Build(BuildCommand),
#[structopt(name = "bundle")]
/// Commands relating to this document’s TeX file bundle... | code_fim | hard | {
"lang": "rust",
"repo": "normanlorrain/tectonic",
"path": "/src/bin/tectonic/v2cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if is_config_test_mode_activated() {
tt_note!(status, "not opening `{}` -- test mode", out_file.display());
} else {
tt_note!(status, "opening `{}`", out_file.display());
if let Err(e) = open::that(&out_file) {
... | code_fim | hard | {
"lang": "rust",
"repo": "normanlorrain/tectonic",
"path": "/src/bin/tectonic/v2cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: normanlorrain/tectonic path: /src/bin/tectonic/v2cli.rs
omizations.always_stderr);
Box::new(sb) as Box<dyn StatusBackend>
} else {
let mut sb = PlainStatusBackend::new(chatter_level);
sb.always_stderr(customizations.always_stderr);
Box::new(sb) as Box<dyn Stat... | code_fim | hard | {
"lang": "rust",
"repo": "normanlorrain/tectonic",
"path": "/src/bin/tectonic/v2cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cogciprocate/ocl path: /ocl/ocl-extras/src/work_pool_old.rs
use std::thread::{self, JoinHandle};
use futures::{executor, SinkExt, StreamExt, Future};
use futures::channel::mpsc::{self, Sender};
use futures_cpupool::{CpuPool, Builder as CpuPoolBuilder};
use tokio_core::reactor::Core;
#[cfg(featur... | code_fim | hard | {
"lang": "rust",
"repo": "cogciprocate/ocl",
"path": "/ocl/ocl-extras/src/work_pool_old.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.reactor_tx.take().unwrap().close().unwrap();
self._reactor_thread.take().unwrap().join().expect("error joining reactor thread");
}
}
// /// A remote control for `WorkPoolOld` used to submit futures needing completion.
// #[derive(Clone)]
// pub struct WorkPoolOldRemote {
// ... | code_fim | hard | {
"lang": "rust",
"repo": "cogciprocate/ocl",
"path": "/ocl/ocl-extras/src/work_pool_old.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Drop for WorkPoolOld {
fn drop(&mut self) {
self.reactor_tx.take().unwrap().close().unwrap();
self._reactor_thread.take().unwrap().join().expect("error joining reactor thread");
}
}
// /// A remote control for `WorkPoolOld` used to submit futures needing completion.
// #[der... | code_fim | hard | {
"lang": "rust",
"repo": "cogciprocate/ocl",
"path": "/ocl/ocl-extras/src/work_pool_old.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hsk/rucc path: /src/main.rs
extern crate rucc;
use rucc::version_info;
use rucc::parser;
use rucc::codegen;
extern crate regex;
use regex::Regex;
fn main() {
let args: Vec<String> = std::env::args().collect();
<|fim_suffix|> println!("\nllvm-ir test output:");
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "hsk/rucc",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.len() < 2 {
version_info::show_version();
version_info::show_usage();
} else {
let ref input_file_name = args[1];
let ast = parser::run_file(input_file_name.to_string());
for node in &ast {
node.show();
}
println!("\nllv... | code_fim | medium | {
"lang": "rust",
"repo": "hsk/rucc",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.values.pop();
}
fn top(&self) -> i32 {
*self.values.last().unwrap()
}
fn get_min(&self) -> i32 {
let mut min = self.values[0];
for &num in &self.values[1..] {
if num < min {
min = num;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Frezc/leetcode-solutions",
"path": "/src/n0155_min_stack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Frezc/leetcode-solutions path: /src/n0155_min_stack.rs
/**
* [155] Min Stack
*
* Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
*
* push(x) -- Push element x onto stack.
* pop() -- Removes the element on top of the stack.
* top() -- G... | code_fim | hard | {
"lang": "rust",
"repo": "Frezc/leetcode-solutions",
"path": "/src/n0155_min_stack.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let yaml = load_yaml!("cli.yaml");
let app = App::from_yaml(yaml)
.version(VERSION)
.setting(AppSettings::ArgRequiredElseHelp);
let matches = app.get_matches();
let config = Config::new(&matches).unwrap();
let result = execute_handler(config);
print_r... | code_fim | hard | {
"lang": "rust",
"repo": "hpcsc/raws",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hpcsc/raws path: /src/main.rs
#[macro_use]
extern crate clap;
extern crate raws;
extern crate ini;
extern crate shellexpand;
use clap::{App, AppSettings};
use ini::Ini;
<|fim_suffix|>fn main() {
let yaml = load_yaml!("cli.yaml");
let app = App::from_yaml(yaml)
.version(VERSION... | code_fim | hard | {
"lang": "rust",
"repo": "hpcsc/raws",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: io12/brainfsym path: /lib/src/path_group.rs
use crate::ast;
use crate::cached_solver::CachedSolver;
use crate::cached_solver::Error;
use crate::state::ConcreteState;
use crate::state::State;
use crate::state::SymBytes;
use std::cmp::Ordering;
use std::rc::Rc;
pub struct PathGroup<'ctx> {
n... | code_fim | hard | {
"lang": "rust",
"repo": "io12/brainfsym",
"path": "/lib/src/path_group.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_rev() {
let cfg = z3::Config::new();
let ctx = z3::Context::new(&cfg);
let mut solver = CachedSolver::new();
let prog = ast::Prog::from_str("+[>,]+[<.-]").unwrap();
let mut path_group = PathGroup::make_entry(&ctx, Rc::new(prog), 16);
... | code_fim | hard | {
"lang": "rust",
"repo": "io12/brainfsym",
"path": "/lib/src/path_group.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cfg = z3::Config::new();
let ctx = z3::Context::new(&cfg);
let mut solver = CachedSolver::new();
let prog = ast::Prog::from_str("+[>,]+[<.-]").unwrap();
let mut path_group = PathGroup::make_entry(&ctx, Rc::new(prog), 16);
let res = path_group
... | code_fim | hard | {
"lang": "rust",
"repo": "io12/brainfsym",
"path": "/lib/src/path_group.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matteo-briani/stm32ral path: /src/stm32f4/stm32f410/interrupts.rs
extern crate bare_metal;
#[cfg(feature = "rt")]
extern "C" {
fn PVD();
fn TAMP_STAMP();
fn RTC_WKUP();
fn FLASH();
fn RCC();
fn EXTI0();
fn EXTI1();
fn EXTI2();
fn EXTI3();
fn EXTI4();
f... | code_fim | hard | {
"lang": "rust",
"repo": "matteo-briani/stm32ral",
"path": "/src/stm32f4/stm32f410/interrupts.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Available interrupts for this device
#[repr(u8)]
#[derive(Clone, Copy)]
#[allow(non_camel_case_types)]
pub enum Interrupt {
/// 1: PVD through EXTI line detection interrupt
PVD = 1,
/// 2: Tamper and TimeStamp interrupts through the EXTI line
TAMP_STAMP = 2,
/// 3: RTC Wakeup inter... | code_fim | hard | {
"lang": "rust",
"repo": "matteo-briani/stm32ral",
"path": "/src/stm32f4/stm32f410/interrupts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FastFieldCodecSerializer for BitpackedFastFieldSerializer {
const NAME: &'static str = "Bitpacked";
const ID: u8 = 1;
/// Serializes data with the BitpackedFastFieldSerializer.
///
/// The serializer in fact encode the values by bitpacking
/// `(val - min_value)`.
///
... | code_fim | hard | {
"lang": "rust",
"repo": "windoze/tantivy",
"path": "/fastfield_codecs/src/bitpacked.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: windoze/tantivy path: /fastfield_codecs/src/bitpacked.rs
use std::io::{self, Write};
use common::BinarySerializable;
use tantivy_bitpacker::{compute_num_bits, BitPacker, BitUnpacker};
use crate::{FastFieldCodecReader, FastFieldCodecSerializer, FastFieldDataAccess, FastFieldStats};
/// Dependi... | code_fim | hard | {
"lang": "rust",
"repo": "windoze/tantivy",
"path": "/fastfield_codecs/src/bitpacked.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_with_codec_data_sets() {
let data_sets = get_codec_test_data_sets();
for (mut data, name) in data_sets {
create_and_validate(&data, name);
data.reverse();
create_and_validate(&data, name);
}
}
#[test]
fn bitpa... | code_fim | hard | {
"lang": "rust",
"repo": "windoze/tantivy",
"path": "/fastfield_codecs/src/bitpacked.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xb10ckdev/forest path: /src/json/signature.rs
// Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
pub mod json {
use crate::shim::crypto::{Signature, SignatureType};
use base64::{prelude::BASE64_STANDARD, Engine};
use serde::{de, Deserialize, Deseri... | code_fim | hard | {
"lang": "rust",
"repo": "0xb10ckdev/forest",
"path": "/src/json/signature.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let serialized = serde_json::to_string(&SignatureJsonRef(&signature)).unwrap();
let parsed: SignatureJson = serde_json::from_str(&serialized).unwrap();
assert_eq!(signature, parsed.0);
}
#[quickcheck]
fn signaturetype_roundtrip(sigtype: SignatureType) {
let ser... | code_fim | hard | {
"lang": "rust",
"repo": "0xb10ckdev/forest",
"path": "/src/json/signature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cindyzwang/yelp-scraper path: /src/main.rs
mod fusion;
#[macro_use] extern crate prettytable;
extern crate reqwest;
extern crate scraper;
extern crate clap;
extern crate indicatif;
extern crate serde;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
use clap::{Arg, App};
use in... | code_fim | hard | {
"lang": "rust",
"repo": "cindyzwang/yelp-scraper",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut count: u32 = 0;
for keyword in keywords.iter() {
sleep(Duration::from_millis(500));
let url = yelp_business_page_url.to_owned() + "?q=" + keyword;
let mut resp = client.get(&url).send().expect("Connection error: business page");
let body = resp.text().expect... | code_fim | hard | {
"lang": "rust",
"repo": "cindyzwang/yelp-scraper",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn find_mode(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {
let mut count: HashMap<i32, i32> = HashMap::new();
Solution::recursive(&root, &mut count);
if let Some(max) = count.iter().map(|x| x.1).max() {
count.iter().filter(|x| x.1 == max).ma... | code_fim | medium | {
"lang": "rust",
"repo": "monkeylyf/interviewjam",
"path": "/tree/leetcode_find_node_in_binary_search_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: monkeylyf/interviewjam path: /tree/leetcode_find_node_in_binary_search_tree.rs
/**
* Given a binary search tree (BST) with duplicates, find all the mode(s) (the
* most frequently occurred element) in the given BST.
*
* Assume a BST is defined as follows:
*
* The left subtree of a node cont... | code_fim | medium | {
"lang": "rust",
"repo": "monkeylyf/interviewjam",
"path": "/tree/leetcode_find_node_in_binary_search_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ndrsllwngr/aussieplusplus path: /src/lexer/lexer.rs
use anyhow::Result;
use thiserror::Error;
use crate::token::{Kind, Token};
use super::source::Source;
pub struct Lexer<T>
where
T: Source,
{
src: T,
line: usize,
}
impl<'a, T: Source> Lexer<T> {
pub fn new(src: T) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "ndrsllwngr/aussieplusplus",
"path": "/src/lexer/lexer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn peek_is(&mut self, c: char) -> bool {
match self.peek() {
Some(ch) => ch.to_ascii_lowercase().eq(&c),
None => false,
}
}
/// Can be called multiple times to peek more than one
/// character ahead
fn peek_multi(&mut self) -> Option<char> {
... | code_fim | hard | {
"lang": "rust",
"repo": "ndrsllwngr/aussieplusplus",
"path": "/src/lexer/lexer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(e) = probe_rs_gdb_server::run(&session, instances.iter()) {
eprintln!("During the execution of GDB an error was encountered:");
eprintln!("{e:?}");
}
Ok(())
}<|fim_prefix|>// repo: oxidecomputer/probe-rs path: /cli/src/gdb.rs
use std::sync::Mutex;
use std::time::Du... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/probe-rs",
"path": "/cli/src/gdb.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/probe-rs path: /cli/src/gdb.rs
use std::sync::Mutex;
use std::time::Duration;
use probe_rs_cli_util::common_options::ProbeOptions;
pub fn run_gdb_server(
common: ProbeOptions,
connection_string: Option<&str>,
reset_halt: bool,
) -> anyhow::Result<()> {
let mut ses... | code_fim | medium | {
"lang": "rust",
"repo": "oxidecomputer/probe-rs",
"path": "/cli/src/gdb.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let session = Mutex::new(session);
if let Err(e) = probe_rs_gdb_server::run(&session, instances.iter()) {
eprintln!("During the execution of GDB an error was encountered:");
eprintln!("{e:?}");
}
Ok(())
}<|fim_prefix|>// repo: oxidecomputer/probe-rs path: /cli/src/gdb.rs... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/probe-rs",
"path": "/cli/src/gdb.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aa-ryan/Comp-Prog path: /gift_fixing_1399B/src/main.rs
fn main() {
let mut number_of_test_cases = String::new();
std::io::stdin()
.read_line(&mut number_of_test_cases)
.expect("Value not found");
let number_of_test_cases: i64 = match number_of_tes... | code_fim | hard | {
"lang": "rust",
"repo": "aa-ryan/Comp-Prog",
"path": "/gift_fixing_1399B/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if number_of_gifts as usize != candy.len() || candy.len() != oranges.len() {
return ()
}
let mut count : i64 = 0;
for i in 0usize..number_of_gifts as usize {
count += std::cmp::max(candy[i] - min_value_candy, oranges[i] - min_value_oranges);
}
println!("{}", cou... | code_fim | hard | {
"lang": "rust",
"repo": "aa-ryan/Comp-Prog",
"path": "/gift_fixing_1399B/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fbrv/youki path: /tests/rust-integration-tests/integration_test/src/tests/lifecycle/kill.rs
use anyhow::Result;
use super::get_result_from_output;
use crate::utils::kill_container;
use std::path::Path;
pub fn kill(project_path: &Path, id: &str) -> Result<<|fim_suffix|>ecute kill command")
... | code_fim | medium | {
"lang": "rust",
"repo": "fbrv/youki",
"path": "/tests/rust-integration-tests/integration_test/src/tests/lifecycle/kill.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ecute kill command")
.wait_with_output();
get_result_from_output(res)
}<|fim_prefix|>// repo: fbrv/youki path: /tests/rust-integration-tests/integration_test/src/tests/lifecycle/kill.rs
use anyhow::Result;
use super::get_result_from_output;
use crate::utils::kill_con<|fim_middle|>tainer;
use... | code_fim | medium | {
"lang": "rust",
"repo": "fbrv/youki",
"path": "/tests/rust-integration-tests/integration_test/src/tests/lifecycle/kill.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "GAM:\n");
for (idx,spline) in self.splines.iter().enumerate(){
write!(f, "\t {} \t", idx);
spline.fmt(f);
write!(f, "\n");
}
write!(f, "\toffset = {}", self.offset)
}
}
impl fmt::Display for Spline {
fn fmt(&self, f: &... | code_fim | hard | {
"lang": "rust",
"repo": "nboyd/satspline",
"path": "/src/gam.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nboyd/satspline path: /src/gam.rs
use std::cmp::Ordering;
use std::f64;
use std::fmt;
fn cmp_f64(a : &f64, b : &f64) -> Ordering {a.partial_cmp(b).expect("NaN!")}
#[derive(Debug, Clone, Default)]
pub struct Spline {
pub locations : Vec<f64>,
pub weights : Vec<f64>,
}
impl Spline {
... | code_fim | hard | {
"lang": "rust",
"repo": "nboyd/satspline",
"path": "/src/gam.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
thread 'rustc' panicked at 'Undefined comparison between Remaining and Write', vir/src/legacy/ast/common.rs:132:33
stack backtrace:
0: rust_begin_unwind
at /rustc/8007b506ac5da629f223b755f5a5391edd5f6d01/library/std/src/panicking.rs:517:5
1: core::panicking::panic_fmt
at... | code_fim | medium | {
"lang": "rust",
"repo": "ani003/prusti_panic_test",
"path": "/panic_examples/others/common_132.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ani003/prusti_panic_test path: /panic_examples/others/common_132.rs
enum Path<'a> {
Map { parent: &'a Path<'a> },
Unknown { parent: &'a Path<'a> },
}
struct Deserializer<'a> {
path: Path<'a>,
}
impl<'a> Deserializer<'a> {
fn next_value_seed(&self)
{
let mut value_de... | code_fim | medium | {
"lang": "rust",
"repo": "ani003/prusti_panic_test",
"path": "/panic_examples/others/common_132.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ddmin/CodeSnippets path: /RS/game/rust-quest/src/main.rs
use rand::Rng;
use std::fmt;
use std::io::{stdin, stdout, Write};
mod ability;
mod character;
mod screen;
use character::{Character, HeroClass, MonsterClass};
use screen::{clear, pause, read};
use ability::Ability;
use ability::AbilityC... | code_fim | hard | {
"lang": "rust",
"repo": "ddmin/CodeSnippets",
"path": "/RS/game/rust-quest/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("What is your name, hero?");
print!("> ");
read(&mut name);
println!();
name = name.trim().to_string();
println!("Greetings {}.", name);
println!();
println!("Choose your class:");
println!(" 1. Mage");
println!(" 2. Priest");
println!(" 3. Rogue")... | code_fim | hard | {
"lang": "rust",
"repo": "ddmin/CodeSnippets",
"path": "/RS/game/rust-quest/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut boss = Character::monster(
"Fungus Giant".to_string(),
[1000, 1001],
MonsterClass::Flora,
vec![
Ability::new("Spores".to_string(), AbilityClass::Attack, 150),
Ability::new("Attack Growth".to_string(), AbilityClass::Buff(0), 5),
... | code_fim | hard | {
"lang": "rust",
"repo": "ddmin/CodeSnippets",
"path": "/RS/game/rust-quest/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: a5ob7r/ym path: /src/de.rs
use std::collections::HashMap;
use crate::token;
#[derive(Eq, PartialEq, Debug)]
pub enum Value {
Object(HashMap<String, Value>),
Array(Vec<Value>),
String(String),
Number(String),
Bool(bool),
Null,
}
pub struct Deserializer<'a> {
tokeniz... | code_fim | hard | {
"lang": "rust",
"repo": "a5ob7r/ym",
"path": "/src/de.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ,
if !self.tokenizer.eat_token(token::Token::Comma) {
break;
}
}
Err(token::Error::InvalidToken)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_deserializer_parse() {
// simple object
let ... | code_fim | hard | {
"lang": "rust",
"repo": "a5ob7r/ym",
"path": "/src/de.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadowmint/relay path: /src/testing/relay_test_harness.rs
use relay_core::events::client_event::ClientEvent;
use relay_core::events::master_event::MasterEvent;
use relay_core::events::master_event::MasterExternalEvent;
use relay_core::events::client_event::ClientExternalEvent;
use relay_core::mo... | code_fim | hard | {
"lang": "rust",
"repo": "shadowmint/relay",
"path": "/src/testing/relay_test_harness.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check join passed
match client.receiver.recv() {
Ok(r) => {
match r {
ClientEvent::External(er) => {
match er {
ClientExternalEvent::TransactionResult { transa... | code_fim | hard | {
"lang": "rust",
"repo": "shadowmint/relay",
"path": "/src/testing/relay_test_harness.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check init passed
match client.receiver.recv() {
Ok(r) => {
match r {
ClientEvent::External(er) => {
match er {
ClientExternalEvent::TransactionResult { transa... | code_fim | hard | {
"lang": "rust",
"repo": "shadowmint/relay",
"path": "/src/testing/relay_test_harness.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alegr37/steam-web-api-rs path: /src/web_api.rs
pub use crate::credentials::*;
use anyhow::{bail, Result};
use bytes::Bytes;
use thiserror::Error;
use url::Url;
mod dota2_automated_tourney_api;
mod dota2_fantasy_api;
mod dota2_match_api;
mod dota2_match_stats_api;
mod dota2_stream_system_api;
mo... | code_fim | hard | {
"lang": "rust",
"repo": "Alegr37/steam-web-api-rs",
"path": "/src/web_api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn build_url(&mut self, path: &str) -> Result<Url, Error> {
let mut url = match self.config.endpoint.join(path) {
Ok(url) => url,
_ => return Err(Error::UrlError),
};
let key = match self.credentials.get_key() {
Ok(key) => key,
_ ... | code_fim | hard | {
"lang": "rust",
"repo": "Alegr37/steam-web-api-rs",
"path": "/src/web_api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wasmerio/wasmer path: /lib/wasix/src/os/task/signal.rs
use std::time::Duration;
use wasmer_wasix_types::types::Signal;
#[derive(thiserror::Error, Debug)]
#[error("Signal could not be delivered")]
pub struct SignalDeliveryError;
<|fim_suffix|>#[derive(Debug)]
pub struct WasiSignalInterval {
... | code_fim | hard | {
"lang": "rust",
"repo": "wasmerio/wasmer",
"path": "/lib/wasix/src/os/task/signal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
#[derive(Debug)]
pub struct WasiSignalInterval {
/// Signal that will be raised
pub signal: Signal,
/// Time between the signals
pub interval: Duration,
/// Flag that indicates if the signal should repeat
pub repeat: bool,
/// Last time that a signal was triggered
pub la... | code_fim | hard | {
"lang": "rust",
"repo": "wasmerio/wasmer",
"path": "/lib/wasix/src/os/task/signal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> protection_cfg,
ssid: b"fake-ssid".to_vec(),
rates: vec![0x82, 0x84, 0x8b, 0x96, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c],
ies_overrides: IesOverrides::new(),
}
}
fn derive_rsne(protection_cfg: FakeProtectionCfg) -> Option<Vec<u8>> {
match protection_cfg {
... | code_fim | hard | {
"lang": "rust",
"repo": "xzlinux/fuchsia",
"path": "/src/connectivity/wlan/lib/common/rust/src/test_utils/fake_stas.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xzlinux/fuchsia path: /src/connectivity/wlan/lib/common/rust/src/test_utils/fake_stas.rs
// Copyright 2021 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.
use {
crate::{
ie::{self, IeTy... | code_fim | hard | {
"lang": "rust",
"repo": "xzlinux/fuchsia",
"path": "/src/connectivity/wlan/lib/common/rust/src/test_utils/fake_stas.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> match protection_cfg {
FakeProtectionCfg::Wpa3Enterprise => Some(fake_wpa3_enterprise_192_bit_rsne()),
FakeProtectionCfg::Wpa2Enterprise => Some(fake_wpa2_enterprise_rsne()),
FakeProtectionCfg::Wpa3 => Some(fake_wpa3_rsne()),
FakeProtectionCfg::Wpa3Transition => Some(fa... | code_fim | hard | {
"lang": "rust",
"repo": "xzlinux/fuchsia",
"path": "/src/connectivity/wlan/lib/common/rust/src/test_utils/fake_stas.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<TrustedPropertiesError> for ProgramError {
fn from(e: TrustedPropertiesError) -> Self {
ProgramError::Custom(e as u32)
}
}<|fim_prefix|>// repo: Sun870905/trusted-properties-marketplace-solana path: /src/program-rust/src/error.rs
/// error.rs -> program specific errors
use thiserror::Error... | code_fim | hard | {
"lang": "rust",
"repo": "Sun870905/trusted-properties-marketplace-solana",
"path": "/src/program-rust/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sun870905/trusted-properties-marketplace-solana path: /src/program-rust/src/error.rs
/// error.rs -> program specific errors
use thiserror::Error;
use solana_program::program_error::ProgramError;
#[derive(Error, Debug, Copy, Clone)]
pub enum TrustedPropertiesError {
/// Invalid instruction
... | code_fim | hard | {
"lang": "rust",
"repo": "Sun870905/trusted-properties-marketplace-solana",
"path": "/src/program-rust/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>self
.
name
(
)
=
=
other
.
name
(
)
}
}
impl
Eq
for
DeltaCookie
{
}
impl
Hash
for
DeltaCookie
{
fn
hash
<
H
:
Hasher
>
(
&
self
state
:
&
mut
H
)
{
self
.
name
(
)
.
hash
(
state
)
;
}
}
impl
Borrow
<
str
>
for
DeltaCookie
{
fn
borrow
(
&
self
)
-
>
&
str
{
self
.
name
(
)
}
}<|fim_prefix|>// repo: marco... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/cookie/src/delta.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/cookie/src/delta.rs
use
std
:
:
ops
:
:
{
Deref
DerefMut
}
;
use
std
:
:
hash
:
:
{
Hash
Hasher
}
;
use
std
:
:
borrow
:
:
Borrow
;
use
crate
:
:
Cookie
;
#
[
derive
(
Clone
Debug
)
]
pub
struct
DeltaCookie
{
pub
cookie
:
C... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/cookie/src/delta.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl VrpSource for OriginsHistory {
type FullIter = AddressOriginsIter;
type DiffIter = DiffIter;
fn ready(&self) -> bool {
self.is_active()
}
fn notify(&self) -> State {
let history = self.0.read().unwrap();
State::from_parts(history.session, history.serial()... | code_fim | hard | {
"lang": "rust",
"repo": "reschke/routinator",
"path": "/src/origins.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns a slice with the address origins added by this diff.
pub fn announce(&self) -> &[AddressOrigin] {
self.announce.as_ref()
}
/// Returns a slice with the address origins removed by this diff.
pub fn withdraw(&self) -> &[AddressOrigin] {
self.withdraw.as_ref()... | code_fim | hard | {
"lang": "rust",
"repo": "reschke/routinator",
"path": "/src/origins.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reschke/routinator path: /src/origins.rs
Some(cmp::Ordering::Greater) => return None,
Some(cmp::Ordering::Equal) => break,
_ => continue
}
}
// We already know that the serial’s diff wasn’t last, so unwrap is
//... | code_fim | hard | {
"lang": "rust",
"repo": "reschke/routinator",
"path": "/src/origins.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raywiis/Advent-of-Code-2019 path: /src/bin/13.rs
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,... | code_fim | hard | {
"lang": "rust",
"repo": "raywiis/Advent-of-Code-2019",
"path": "/src/bin/13.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -... | code_fim | hard | {
"lang": "rust",
"repo": "raywiis/Advent-of-Code-2019",
"path": "/src/bin/13.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raywiis/Advent-of-Code-2019 path: /src/bin/13.rs
,1005,381,540,21202,-4,-1,-1,22201,-3,-1,-3,2207,-3,-4,381,1006,381,529,22101,0,-3,-7,109,-8,2105,1,0,109,4,1202,-2,38,566,201,-3,566,566,101,639,566,566,2102,1,-1,0,204,-3,204,-2,204,-1,109,-4,2106,0,0,109,3,1202,-1,38,594,201,-2,594,594,101,639,... | code_fim | hard | {
"lang": "rust",
"repo": "raywiis/Advent-of-Code-2019",
"path": "/src/bin/13.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: top-gg/rust-sdk path: /src/autoposter.rs
use crate::{client::InnerClient, NewStats};
use core::time::Duration;
use std::sync::Arc;
use tokio::{
sync::Mutex,
task::{spawn, JoinHandle},
time::sleep,
};
/// A struct that lets you automate the process of posting bot statistics to the [Top.gg]... | code_fim | hard | {
"lang": "rust",
"repo": "top-gg/rust-sdk",
"path": "/src/autoposter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(new_data) = &*lock {
let _ = client.post_stats(new_data).await;
}
}
}),
data: current_thread_data,
}
}
/// Feeds new bot stats to the autoposter. The autoposter will automatically post it to the [Top.gg](https://top.gg) servers in in... | code_fim | hard | {
"lang": "rust",
"repo": "top-gg/rust-sdk",
"path": "/src/autoposter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_solve(&mut self, s: Solve) -> Result<()> {
let max = s.iter().count().saturating_sub(1);
self.max = max;
self.solve = Some(s);
self.update_properties()?;
Ok(())
}
pub fn clear_solve(&mut self) -> Result<()> {
self.solve.take();
... | code_fim | hard | {
"lang": "rust",
"repo": "pepijnd/sudoku_web_solver",
"path": "/websolver/src/ui/model/info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pepijnd/sudoku_web_solver path: /websolver/src/ui/model/info.rs
use solver::{output::SolveStep, solvers::Solver, Options, Solve, StateMod, Sudoku};
use webelements::Result;
use crate::util::Measure;
#[derive(Debug, Clone, Copy)]
pub enum Stat {
Tech,
Steps,
Guesses,
GSteps,
... | code_fim | hard | {
"lang": "rust",
"repo": "pepijnd/sudoku_web_solver",
"path": "/websolver/src/ui/model/info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc106/src/bin/d.rs
use fenwicktree::*;
use proconio::input;
fn main() {
input! {
n: usize,
m: usize,
q: usize,
mut lr: [(usize, usize); m],
pq: [(usize, usize); q],
};
lr.sort();
lr.rever... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc106/src/bin/d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod fenwicktree {
// Reference: https://en.wikipedia.org/wiki/Fenwick_tree
pub struct FenwickTree<T> {
n: usize,
ary: Vec<T>,
e: T,
}
impl<T: Clone + std::ops::AddAssign<T>> FenwickTree<T> {
pub fn new(n: usize, e: T) -> Self {
FenwickTree {... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc106/src/bin/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iximeow/yaxpeax-msp430 path: /src/lib.rs
s, &mut NullSink)
}
}
#[derive(Clone, PartialEq, Eq)]
pub struct MSP430FieldDescription {
desc: Option<&'static str>,
value: MSP430Field,
// an opaque identifier to link different parts of FieldDescription at different offsets.
id: u3... | code_fim | hard | {
"lang": "rust",
"repo": "iximeow/yaxpeax-msp430",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (opcode_idx, operands) = ((instrword & 0x0380) >> 7, instrword & 0x7f);
match opcode_idx {
x if x < 6 => {
inst.opcode = [
Opcode::RRC,
Opcode::SWPB,
... | code_fim | hard | {
"lang": "rust",
"repo": "iximeow/yaxpeax-msp430",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn decode_with_annotation<
T: Reader<<MSP430 as Arch>::Address, <MSP430 as Arch>::Word>,
S: DescriptionSink<Self::FieldDescription>
>(&self, inst: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), <MSP430 as Arch>::DecodeError> {
let fullword = words.next()?.0;
... | code_fim | hard | {
"lang": "rust",
"repo": "iximeow/yaxpeax-msp430",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shun159/vr_types path: /src/vr_messages/vr_vrf_assign.rs
// Copyright 2020 Eishun Kondoh
// SPDX-License-Identifier: Apache-2.0
use super::error::CodecError;
use super::sandesh::SandeshOp;
use super::vr_types::VrSandesh;
use super::vr_types_binding::vr_vrf_assign_req;
use std::convert::TryInto;... | code_fim | hard | {
"lang": "rust",
"repo": "shun159/vr_types",
"path": "/src/vr_messages/vr_vrf_assign.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn read(buf: Vec<u8>) -> Result<VrfAssignRequest, CodecError> {
let decoder: vr_vrf_assign_req = vr_vrf_assign_req::new();
let rxfer = decoder.read(&buf)?;
let mut var: VrfAssignRequest = VrfAssignRequest::default();
var.read_length = rxfer as usize;
var.op ... | code_fim | hard | {
"lang": "rust",
"repo": "shun159/vr_types",
"path": "/src/vr_messages/vr_vrf_assign.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>memory;
pub mod pids;
pub mod transformer;<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/agent/rustjail/src/cgroups/systemd/subsystem/mod.rs
// Copyright 2021-2022 Kata Contributors
//
// SPDX-License-Identifier: Apache-2.0
<|fim_middle|>//
pub mod cpu;
pub mod cpuset;
pub mod | code_fim | easy | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/agent/rustjail/src/cgroups/systemd/subsystem/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>//
pub mod cpu;
pub mod cpuset;
pub mod memory;
pub mod pids;
pub mod transformer;<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/agent/rustjail/src/cgroups/systemd/subsystem/mod.rs
// Copyright 2021-2022 Kata Contributors
<|fim_middle|>//
// SPDX-License-Identifier: Apache-2.0
| code_fim | easy | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/agent/rustjail/src/cgroups/systemd/subsystem/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/agent/rustjail/src/cgroups/systemd/subsystem/mod.rs
// Copyright 2021-2022 Kata Contributors
//
// SPDX-License-Identifier: Apache-2.0
<|fim_suffix|>memory;
pub mod pids;
pub mod transformer;<|fim_middle|>//
pub mod cpu;
pub mod cpuset;
pub mod | code_fim | easy | {
"lang": "rust",
"repo": "kata-containers/kata-containers",
"path": "/src/agent/rustjail/src/cgroups/systemd/subsystem/mod.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.