text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let input = std::io::stdin();
let mut code = String::new();
input.lock().read_to_string(&mut code).unwrap();
print!("{}", Program::parse(&code).decompile().to_string());
}<|fim_prefix|>// repo: ttencate/aoc2018 path: /src/bin/decompiler.rs
use aoc::vm::Program;
use aoc::vm::decompiler::De... | code_fim | easy | {
"lang": "rust",
"repo": "ttencate/aoc2018",
"path": "/src/bin/decompiler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> b.iter(|| {
let mut vec = Vec::with_capacity(100);
// create a main coroutine, let it spawn 10 sub coroutine
for _ in 0..100 {
let j = go!(|| {
let mut _vec = Vec::with_capacity(100);
for _ in 0..100 {
let _j = go!... | code_fim | hard | {
"lang": "rust",
"repo": "Xudong-Huang/may",
"path": "/benches/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xudong-Huang/may path: /benches/lib.rs
#![cfg(nightly)]
#![feature(test)]
#[macro_use]
extern crate may;
extern crate test;
use may::coroutine::*;
use test::Bencher;
#[bench]
fn yield_bench(b: &mut Bencher) {
b.iter(|| {
scope(|s| {
for _ in 0..1000 {
g... | code_fim | hard | {
"lang": "rust",
"repo": "Xudong-Huang/may",
"path": "/benches/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhangoneone/leetcode path: /001-two-sum/two-sum.rs
// Given an array of integers, return indices of the two numbers such that they add up to a specific target.
//
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
//
// Example:
//
/... | code_fim | medium | {
"lang": "rust",
"repo": "zhangoneone/leetcode",
"path": "/001-two-sum/two-sum.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn two_sum(nums: &mut Vec<i32>, target: i32) -> Vec<i32> {
let mut seen = HashMap::new();
for (i, num) in nums.iter().enumerate() {
if seen.contains_key(num) {
return vec![seen[num] as i32, i as i32];
} else { seen.insert(targ... | code_fim | medium | {
"lang": "rust",
"repo": "zhangoneone/leetcode",
"path": "/001-two-sum/two-sum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set the maximum number of simultaneous connections that this client is allowed to keep open to individual hosts at one time.
///
/// Default: `50`.
/// This number is based on a few random benchmarks and see whatever gave decent perf vs resource use in Orogene.
///
/// Note: Th... | code_fim | hard | {
"lang": "rust",
"repo": "http-rs/surf",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: http-rs/surf path: /src/config.rs
//! Configuration for `HttpClient`s.
use std::sync::Arc;
use std::{collections::HashMap, fmt::Debug, time::Duration};
use http_client::{Config as HttpConfig, HttpClient};
use http_types::headers::{HeaderName, HeaderValues, ToHeaderValues};
use crate::http::Ur... | code_fim | hard | {
"lang": "rust",
"repo": "http-rs/surf",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn map_right<F, U>(self, map: F) -> Either<L, U>
where
F: FnOnce(R) -> U,
{
match self {
Self::Left(left) => Either::Left(left),
Self::Right(right) => Either::Right(map(right)),
}
}
pub fn map_left_or<F, U>(self, default: U, map: F) ... | code_fim | hard | {
"lang": "rust",
"repo": "Kixiron/crunch-lang",
"path": "/crates/crunch-shared/src/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kixiron/crunch-lang path: /crates/crunch-shared/src/utils.rs
use core::{
fmt,
ops::{Deref, DerefMut},
};
use fxhash::FxBuildHasher;
use serde::{Deserialize, Serialize};
cfg_if::cfg_if! {
if #[cfg(feature = "no-std")] {
pub type HashMap<K, V> = hashbrown::HashMap<K, V, FxBuil... | code_fim | hard | {
"lang": "rust",
"repo": "Kixiron/crunch-lang",
"path": "/crates/crunch-shared/src/utils.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> Deref for DbgWrap<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<T> DerefMut for DbgWrap<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<T> AsRef<T> for DbgWrap<T> {
fn as_ref(&self) -> &T {
&sel... | code_fim | hard | {
"lang": "rust",
"repo": "Kixiron/crunch-lang",
"path": "/crates/crunch-shared/src/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>DETAIL = 0b00001000000000000000000000000000;
const TRANSLUCENT = 0b00010000000000000000000000000000;
const LADDER = 0b00100000000000000000000000000000;
const HITBOX = 0b01000000000000000000000000000000;
const MASK_ALL ... | code_fim | hard | {
"lang": "rust",
"repo": "balenamiaa/rust-csgo",
"path": "/src/structs/traceflags.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: balenamiaa/rust-csgo path: /src/structs/traceflags.rs
use bitflags::bitflags;
bitflags! {
#[repr(C)]
pub struct TraceSurf: u32{
const LIGHT = 0b00000000000000000000000000000001;
const SKY2D = 0b00000000000000000000000000000010;
const SKY = 0b0000000... | code_fim | hard | {
"lang": "rust",
"repo": "balenamiaa/rust-csgo",
"path": "/src/structs/traceflags.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: david-sawatzke/xmc1100-rs path: /src/prng.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - PRNG Word Register"]
pub word: WORD,
_reserved1: [u8; 2usize],
#[doc = "0x04 - PRNG Status Check Register"]
pub chk: CHK,
_reserved2: [u8; 6usize]... | code_fim | hard | {
"lang": "rust",
"repo": "david-sawatzke/xmc1100-rs",
"path": "/src/prng.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>th_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about avaliable fields see [ctrl](ctrl) module"]
pub type CTRL = crate::Reg<u16, _CTRL>;
#[allow(missing_docs)]
#[doc(hidden)]
pub stru... | code_fim | hard | {
"lang": "rust",
"repo": "david-sawatzke/xmc1100-rs",
"path": "/src/prng.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-compete/pastbook2/src/bin/186.rs
use proconio::input;
fn main() {
input! {
n: usize,
a: [usize; n],
};
let mut xor = 0_usize;
let mut sum<|fim_suffix|>{
xor ^= a[r];
sum += a[r];
r += 1;
... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-compete/pastbook2/src/bin/186.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>r += 1;
} else {
xor ^= a[l];
sum -= a[l];
}
}
let ans = count;
println!("{}", ans);
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-compete/pastbook2/src/bin/186.rs
use proconio::input;
fn main() {
input! {
n: usize,
a: [... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-compete/pastbook2/src/bin/186.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: robarnold/cryptopals path: /src/s1c4.rs
#[test]
fn challenge() {
use std::string::String;
use util;
use xor;
use std::io::BufRead;
let contents = include_bytes!("s1c4.txt");
let mut best_attempt = None;
let mut decoded_string = String::from("");
for line in contents.lines() {
... | code_fim | hard | {
"lang": "rust",
"repo": "robarnold/cryptopals",
"path": "/src/s1c4.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>empt.clone() {
None => {
decoded_string = decode_result.unwrap();
println!("{}: {}", current_attempt.score, decoded_string);
best_attempt = Some(current_attempt);
}
Some(attempt) => {
if attempt.score < current_attempt.score {
decoded_string = de... | code_fim | hard | {
"lang": "rust",
"repo": "robarnold/cryptopals",
"path": "/src/s1c4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChaosStudyGroup/const-str path: /const-str/src/verify_http.rs
/// Returns a compile-time verified header name string literal.
///
/// # Examples
///
/// ```
/// use <|fim_suffix|>fied_header_name {
($name:literal) => {
$crate::__imp::verified_header_name!($name)
};
}<|fim_middle|... | code_fim | hard | {
"lang": "rust",
"repo": "ChaosStudyGroup/const-str",
"path": "/const-str/src/verify_http.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>!(HeaderName::from_static(name).as_str(), "content-md5");
/// ```
///
#[macro_export]
macro_rules! verified_header_name {
($name:literal) => {
$crate::__imp::verified_header_name!($name)
};
}<|fim_prefix|>// repo: ChaosStudyGroup/const-str path: /const-str/src/verify_http.rs
/// Returns a... | code_fim | medium | {
"lang": "rust",
"repo": "ChaosStudyGroup/const-str",
"path": "/const-str/src/verify_http.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fied_header_name {
($name:literal) => {
$crate::__imp::verified_header_name!($name)
};
}<|fim_prefix|>// repo: ChaosStudyGroup/const-str path: /const-str/src/verify_http.rs
/// Returns a compile-time verified header name string literal.
///
/// # Examples
///
/// ```
/// use http::header:... | code_fim | medium | {
"lang": "rust",
"repo": "ChaosStudyGroup/const-str",
"path": "/const-str/src/verify_http.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
} else {
let status_line = "HTTP/1.1 404 NOT FOUND\r\n";
let content = "<p>404</p>";
let response = format!("{}{}", status_line, content);
stream.write(response.as_bytes()).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "Rolledm/sip-server-rust",
"path": "/src/http.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rolledm/sip-server-rust path: /src/http.rs
use std::net::TcpStream;
use std::io::prelude::*;
use std::fs;
// add rocket.io
pub fn on_http_message_received(mut stream: TcpStream) {
let mut buffer = [0; 512];
stream.read(&mut buffer).unwrap();
<|fim_suffix|> stream.write(response... | code_fim | hard | {
"lang": "rust",
"repo": "Rolledm/sip-server-rust",
"path": "/src/http.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut resp = Response::new();
resp.body("Hello World");
Ok(resp)
}
}
fn main() {
let server = HttpServer(HelloWorld).start("0.0.0.0:9292").unwrap();
server.join().unwrap();
}<|fim_prefix|>// repo: greentornado/app-servers path: /servers/minihttp_server/src/main.rs
e... | code_fim | medium | {
"lang": "rust",
"repo": "greentornado/app-servers",
"path": "/servers/minihttp_server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: greentornado/app-servers path: /servers/minihttp_server/src/main.rs
extern crate may_minihttp;
use std::io;
use may_minihttp::{HttpServer, HttpService, Request, Response};
<|fim_suffix|>impl HttpService for HelloWorld {
fn call(&self, _request: Request) -> io::Result<Response> {
le... | code_fim | easy | {
"lang": "rust",
"repo": "greentornado/app-servers",
"path": "/servers/minihttp_server/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let server = HttpServer(HelloWorld).start("0.0.0.0:9292").unwrap();
server.join().unwrap();
}<|fim_prefix|>// repo: greentornado/app-servers path: /servers/minihttp_server/src/main.rs
extern crate may_minihttp;
use std::io;
use may_minihttp::{HttpServer, HttpService, Request, Respons... | code_fim | hard | {
"lang": "rust",
"repo": "greentornado/app-servers",
"path": "/servers/minihttp_server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mwithoeft/RustUML path: /rust_uml/src/api.rs
pub use parsing;
use api_yew;
use api_htmlfile;
pub struct Api {
_eingabe: Eingaben,
_ausgabe: Ausgaben,
_class_klassen: Vec<parsing::parse_class::Klasse>,
_class_beziehungen: Vec<parsing::parse_class::Beziehung>,
_usecase_typen: ... | code_fim | hard | {
"lang": "rust",
"repo": "mwithoeft/RustUML",
"path": "/rust_uml/src/api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn build_api(_eingabe: Eingaben, _ausgabe: Ausgaben) -> Api {
Api {
_eingabe,
_ausgabe,
_class_klassen: Vec::new(),
_class_beziehungen: Vec::new(),
_usecase_typen: Vec::new(),
_usecase_beziehungen: Vec::new()
}
}
pub enum Eingaben {
WEBTEXT,... | code_fim | hard | {
"lang": "rust",
"repo": "mwithoeft/RustUML",
"path": "/rust_uml/src/api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joshuabenuck/tarnish path: /src/library.rs
pub struct Library {
pub games: Vec<Game>,
}
<|fim_suffix|>pub struct Game {
pub human_name: String,
pub machine_name: String,
pub installer: Option<String>,
pub installed: bool,
pub process: String,
pub icon: String,
pu... | code_fim | medium | {
"lang": "rust",
"repo": "joshuabenuck/tarnish",
"path": "/src/library.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Game {
pub human_name: String,
pub machine_name: String,
pub installer: Option<String>,
pub installed: bool,
pub process: String,
pub icon: String,
pub screenshots: Option<Vec<String>>,
pub trailer: Option<String>,
pub launcher: Launcher,
}<|fim_prefix|>// re... | code_fim | medium | {
"lang": "rust",
"repo": "joshuabenuck/tarnish",
"path": "/src/library.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: merwaaan/cheapo-rs path: /src/keyboard.rs
pub struct Keyboard {
i: bool
}
<|fim_suffix|> pub fn new() -> Keyboard {
Keyboard {
i: true
}
}
pub fn wait(&mut self, reg: u8) {
}
}<|fim_middle|>impl Keyboard {
| code_fim | easy | {
"lang": "rust",
"repo": "merwaaan/cheapo-rs",
"path": "/src/keyboard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn wait(&mut self, reg: u8) {
}
}<|fim_prefix|>// repo: merwaaan/cheapo-rs path: /src/keyboard.rs
pub struct Keyboard {
i: bool
}
impl Keyboard {
<|fim_middle|> pub fn new() -> Keyboard {
Keyboard {
i: true
}
}
| code_fim | medium | {
"lang": "rust",
"repo": "merwaaan/cheapo-rs",
"path": "/src/keyboard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_next_turn(turn: i32, snakes: Vec<Vec<Point2<i32>>>, width: i32, height: i32) -> VecDeque::<(i32, Vec<Vec<Point2<i32>>>)> {
let bodies: Vec<Point2<i32>> = snakes.clone().into_iter().flatten().collect::<Vec<Point2<i32>>>();
return snakes
.iter()
.map(|snake| get_possible_coords(*snak... | code_fim | hard | {
"lang": "rust",
"repo": "bigf00t/rustyrattler",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bigf00t/rustyrattler path: /src/main.rs
use std::collections::VecDeque;
use nalgebra::Point2;
use nalgebra::Vector2;
use itertools::Itertools;
use time::Instant;
use std::thread;
use std::thread::JoinHandle;
fn main() {
let width = 5;
let height = 5;
let mut start_snakes = Vec::new(... | code_fim | hard | {
"lang": "rust",
"repo": "bigf00t/rustyrattler",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leocassarani/mison path: /src/json.rs
use std::str;
#[derive(Debug)]
pub enum Value {
Null,
Bool(bool),
Number(f64),
String(String),
}
impl Value {
pub fn parse(bytes: &[u8]) -> Option<Self> {
if bytes.is_empty() {
return None;
}
if byte... | code_fim | medium | {
"lang": "rust",
"repo": "leocassarani/mison",
"path": "/src/json.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn parse_string(bytes: &[u8]) -> Option<Self> {
let delimiter = bytes.iter().position(|&ch| ch == b'"')?;
str::from_utf8(&bytes[..delimiter])
.map(|s| s.to_string())
.map(Value::String)
.ok()
}
}<|fim_prefix|>// repo: leocassarani/mison path: /s... | code_fim | medium | {
"lang": "rust",
"repo": "leocassarani/mison",
"path": "/src/json.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, PartialEq, Debug, Encode, Decode)]
#[protocol(id = 6386)]
pub struct PlayerStatusUpdateMessage<'a> {
pub account_id: u32,
#[protocol(var)]
pub player_id: u64,
pub status: PlayerStatusVariant<'a>,
}<|fim_prefix|>// repo: Aursen/holomorph path: /protocol/src/messages/game/ch... | code_fim | medium | {
"lang": "rust",
"repo": "Aursen/holomorph",
"path": "/protocol/src/messages/game/character/status/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aursen/holomorph path: /protocol/src/messages/game/character/status/mod.rs
use crate::variants::PlayerStatusVariant;
use protocol_derive::{Decode, Encode};
<|fim_suffix|>#[derive(Clone, PartialEq, Debug, Encode, Decode)]
#[protocol(id = 6386)]
pub struct PlayerStatusUpdateMessage<'a> {
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "Aursen/holomorph",
"path": "/protocol/src/messages/game/character/status/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PBertinJohannet/Neugene path: /src/algogen.rs
//! Module algogen Defines a trait for this.
use crate::graphics::{DrawInstruction, ManyStepDrawable, SingleStepDrawable};
use crate::problems;
use crate::problems::{GenericProblem, ManyStepProblem, SingleStepProblem, Solution};
use rand::prelude::Th... | code_fim | hard | {
"lang": "rust",
"repo": "PBertinJohannet/Neugene",
"path": "/src/algogen.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.problem = prob;
}
fn next_step(&mut self, input: Self::StepParam) {
self.next_gen(input);
}
fn best_sol(&self) -> <P as SingleStepProblem>::Sol {
self.best()
}
fn get_state(&self) -> Vector<f64> {
self.last_res.clone().into_vector()
}
... | code_fim | hard | {
"lang": "rust",
"repo": "PBertinJohannet/Neugene",
"path": "/src/algogen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn best_sol(&self) -> <P as SingleStepProblem>::Sol {
self.best()
}
fn get_state(&self) -> Vector<f64> {
self.last_res.clone().into_vector()
}
fn random(
xsr: &mut ThreadRng,
prob_conf: &<Self as SupervisableSolver<P>>::CreateParam,
) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "PBertinJohannet/Neugene",
"path": "/src/algogen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: newtonseple/sanntid-heis path: /exercises/ex2/ex2.rs
use std::thread;
use std::sync::{Arc, Mutex};
use std::sync::mpsc;
/*
fn main() {
let i = Arc::new(Mutex::new(0));
let i1 = i.clone();
let thread_1 = thread::spawn(move || {
for _ in 0..1000000 {
let mut data ... | code_fim | hard | {
"lang": "rust",
"repo": "newtonseple/sanntid-heis",
"path": "/exercises/ex2/ex2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>enum Cmd {
Inc,
Dec,
Fin,
}
fn main() {
let mut i = 0;
let (server_tx, server_rx) = mpsc::channel();
let (fin_tx, fin_rx) = mpsc::channel();
let tx1 = server_tx.clone();
let tx2 = server_tx.clone();
let _ = thread::spawn(move || {
let mut num_fin = 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "newtonseple/sanntid-heis",
"path": "/exercises/ex2/ex2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn is_query_e_x_t(instance: DOMReference, query: DOMReference) -> bool {
unsafe { 0 != extdisjointtimerquery_is_query_e_x_t(instance, query) }
}
extern "C" {
fn extdisjointtimerquery_begin_query_e_x_t(
instance: DOMReference,
begin_query_e_x_t: f32,
begin_query_e_x_t: D... | code_fim | hard | {
"lang": "rust",
"repo": "kmat1984/web-dom",
"path": "/src/extdisjointtimerquery.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kmat1984/web-dom path: /src/extdisjointtimerquery.rs
#[allow(unused_imports)]
use crate::*;
#[allow(unused_imports)]
use alloc::string::String;
pub const QUERY_COUNTER_BITS_EXT: f32 = 0x8864 as f32;
pub const CURRENT_QUERY_EXT: f32 = 0x8865 as f32;
pub const QUERY_RESULT_EXT: f32 = 0x8866 as f32... | code_fim | hard | {
"lang": "rust",
"repo": "kmat1984/web-dom",
"path": "/src/extdisjointtimerquery.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn delete_query_e_x_t(instance: DOMReference, query: DOMReference) {
unsafe { extdisjointtimerquery_delete_query_e_x_t(instance, query) }
}
extern "C" {
fn extdisjointtimerquery_is_query_e_x_t(
instance: DOMReference,
is_query_e_x_t: DOMReference,
) -> i32;
}
pub fn is_que... | code_fim | hard | {
"lang": "rust",
"repo": "kmat1984/web-dom",
"path": "/src/extdisjointtimerquery.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> reactor.set_event_listener(tcp_token, move |reactor, _| {
let connection = listener.accept().expect("failed to accept");
accepted_connections_count += 1;
println!("{:?}, {:?}", connection, accepted_connections_count);
if accepted_connections_count >=... | code_fim | hard | {
"lang": "rust",
"repo": "jennamagius/transportation",
"path": "/examples/interval.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jennamagius/transportation path: /examples/interval.rs
fn main() {
jenna_reactor::Reactor::run(|reactor| {
let mut accepted_connections_count = 0;
let mut listener = ::mio::net::TcpListener::bind(&"0.0.0.0:7777".parse().unwrap())
.expect("failed to bind");
... | code_fim | hard | {
"lang": "rust",
"repo": "jennamagius/transportation",
"path": "/examples/interval.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/…
// #A Same function as listing 2.24 but with an HTML response<|fim_prefix|>// repo: mfpiccolo/rust_in_action path: /ch_2/listings/2_25_html_esponse.rs
//…
fn hello(_: Request, res: Response<Fresh>) { //#A
re<|fim_middle|>s.send(
b"<div>
<img src=\"https://www.rust-lang.org/logos... | code_fim | medium | {
"lang": "rust",
"repo": "mfpiccolo/rust_in_action",
"path": "/ch_2/listings/2_25_html_esponse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfpiccolo/rust_in_action path: /ch_2/listings/2_25_html_esponse.rs
//…
fn hello(_: Request, res: Response<Fresh>) { //#A
res.send(
b"<div>
<img src=\"https://www.rust-lang.<|fim_suffix|>/…
// #A Same function as listing 2.24 but with an HTML response<|fim_middle|>org/logos... | code_fim | medium | {
"lang": "rust",
"repo": "mfpiccolo/rust_in_action",
"path": "/ch_2/listings/2_25_html_esponse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>org/logos/rust-logo-blk.svg\">
</div>"
).unwrap();
}
//…
// #A Same function as listing 2.24 but with an HTML response<|fim_prefix|>// repo: mfpiccolo/rust_in_action path: /ch_2/listings/2_25_html_esponse.rs
//…
fn hello(_: Request, res: Response<Fresh>) { //#A
re<|fim_middle|>s.send(
... | code_fim | medium | {
"lang": "rust",
"repo": "mfpiccolo/rust_in_action",
"path": "/ch_2/listings/2_25_html_esponse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/map_model/src/config.rs
//! Types representing a map in configuration form.
<|fim_suffix|>mod map_bounds;
mod map_definition;
mod map_header;<|fim_middle|>pub use self::{
map_bounds::MapBounds,
map_definition::{MapDefinition, MapDefinitionHandle},
... | code_fim | medium | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/map_model/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod map_bounds;
mod map_definition;
mod map_header;<|fim_prefix|>// repo: azriel91/autexousious path: /crate/map_model/src/config.rs
//! Types representing a map in configuration form.
<|fim_middle|>pub use self::{
map_bounds::MapBounds,
map_definition::{MapDefinition, MapDefinitionHandle},
... | code_fim | medium | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/map_model/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = ewasm_api::calldata_acquire();
let hash = Keccak256::digest(&data[..]);
ewasm_api::finish_data(&hash[..])
}<|fim_prefix|>// repo: aarlt/ewasm-precompiles path: /keccak256/src/lib.rs
extern crate ewasm_api;
extern crate sha3;
use sha3::{Digest, Keccak256};
#[cfg(not(test))]
#[no... | code_fim | hard | {
"lang": "rust",
"repo": "aarlt/ewasm-precompiles",
"path": "/keccak256/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aarlt/ewasm-precompiles path: /keccak256/src/lib.rs
extern crate ewasm_api;
extern crate sha3;
use sha3::{Digest, Keccak256};
<|fim_suffix|> // charge a base fee plus a word fee for every 256-bit word
let base_fee = 60;
let word_fee = 12;
let total_cost = base_fee + ((length + 3... | code_fim | medium | {
"lang": "rust",
"repo": "aarlt/ewasm-precompiles",
"path": "/keccak256/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HackGT/enzo path: /src/utils/error.rs
use ansi_term::Color::{Purple, Red, Yellow};
use std::convert::From;
use std::error::Error;
use std::fmt;
use std::io;
#[derive(Debug)]
pub struct EnzoError {
kind: EnzoErrorKind,
msg: String,
}
impl EnzoError {
pub fn new<T>(msg: T, kind: Enzo... | code_fim | medium | {
"lang": "rust",
"repo": "HackGT/enzo",
"path": "/src/utils/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let msg = match self {
EnzoErrorKind::FatalError => Red.bold().paint("fatal error"),
EnzoErrorKind::IOError => Red.bold().paint("io error"),
EnzoErrorKind::ConfigError => Yellow.bold().paint("configuration error"),
EnzoErrorKind::GitError => Purple.b... | code_fim | hard | {
"lang": "rust",
"repo": "HackGT/enzo",
"path": "/src/utils/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(all(
feature = "v3_0",
not(feature = "v3_1"),
not(feature = "v3_2"),
))]
fn log_init(self) -> i32 {
unsafe {
lxc_sys::lxc_log_init(
to_cstr(&self.name),
to_cstr(&self.file),
self.level,
... | code_fim | hard | {
"lang": "rust",
"repo": "johnlepikhin/lxc-rs",
"path": "/src/log/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnlepikhin/lxc-rs path: /src/log/mod.rs
mod level;
#[cfg(feature = "v2_1")]
use crate::ffi::to_cstr;
pub use self::level::Level;
pub struct Log {
pub name: String,
pub lxcpath: String,
pub file: String,
pub level: self::Level,
pub prefix: String,
pub quiet: bool,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "johnlepikhin/lxc-rs",
"path": "/src/log/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Anupam-Ashish-Minz/aoc2020_rust path: /src/day8/handling_input.rs
use std::fs;
pub type ParsedInput<T, F> = Vec<(T, F)>;
pub fn read_input_from_file() -> String {
const FILEPATH: &str = "input/day8.input";
let input = fs::read_to_string(FILEPATH).unwrap().to_string();
return input;... | code_fim | medium | {
"lang": "rust",
"repo": "Anupam-Ashish-Minz/aoc2020_rust",
"path": "/src/day8/handling_input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mock_raw_input = "nop +0
acc +1
jmp +4
acc +3
jmp -3
acc -99
acc +1
jmp -4
acc +6".to_string();
let parsed_input = parse_input(mock_raw_input);
let expected_output = vec![
("nop".to_string(), 0),
("acc".to_string(), 1),
("jmp".to_string(), 4)... | code_fim | medium | {
"lang": "rust",
"repo": "Anupam-Ashish-Minz/aoc2020_rust",
"path": "/src/day8/handling_input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sym233/leetcode_problems path: /977. Squares of a Sorted Array/977. Squares of a Sorted Array.rs
impl Solution {
pub fn sorted_squares(nums: Vec<i32>) -> Vec<i32> {
let mut negs = vec![];
let mut res = vec![];
for num in nums {
let sqr = num * num;
... | code_fim | hard | {
"lang": "rust",
"repo": "sym233/leetcode_problems",
"path": "/977. Squares of a Sorted Array/977. Squares of a Sorted Array.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
res.push(sqr);
}
}
res.extend(negs.into_iter().rev());
res
}
}<|fim_prefix|>// repo: sym233/leetcode_problems path: /977. Squares of a Sorted Array/977. Squares of a Sorted Array.rs
impl Solution {
pub fn sorted_squares(nums: Vec<i... | code_fim | hard | {
"lang": "rust",
"repo": "sym233/leetcode_problems",
"path": "/977. Squares of a Sorted Array/977. Squares of a Sorted Array.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Field { connections: HashSet<Direction> },
Monastery,
Road { connections: HashSet<Direction> },
}<|fim_prefix|>// repo: overengineering/rustassonne path: /src/models/feature.rs
use direction::Direction;
use std::collections::HashSet;
/// Game features of a tile used for rule enforceme<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "overengineering/rustassonne",
"path": "/src/models/feature.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: overengineering/rustassonne path: /src/models/feature.rs
use direction::Direction;
use std::collections::HashSet;
/// Game features of a tile used for rule enforceme<|fim_suffix|>q, Clone)]
pub enum Feature {
City {
badge: bool,
connections: HashSet<Direction>,
},
Fi... | code_fim | medium | {
"lang": "rust",
"repo": "overengineering/rustassonne",
"path": "/src/models/feature.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fs.take_and_serve_directory_handle()?;
let fut = fs.for_each_concurrent(None, |req| match req {
IncomingServices::CloudProvider(stream) => cloud_factory.spawn(stream),
IncomingServices::CloudControllerFactory(stream) => {
CloudControllerFactory::new(stream).run()
... | code_fim | hard | {
"lang": "rust",
"repo": "OpenTrustGroup/fuchsia",
"path": "/src/ledger/cloud_provider_memory_diff/src/main.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OpenTrustGroup/fuchsia path: /src/ledger/cloud_provider_memory_diff/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.
#![feature(async_await, await_macro)]
#![recursion_... | code_fim | medium | {
"lang": "rust",
"repo": "OpenTrustGroup/fuchsia",
"path": "/src/ledger/cloud_provider_memory_diff/src/main.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[serde(default)]
pub body: Body,
#[serde(default)]
pub auth: Auth,
#[serde(rename = "header")]
pub headers: Vec<KeyValue>,
}
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
pub struct Url {
pub raw: String
}
#[derive(Clone, Serialize, Deserialize, Debug, Default)]... | code_fim | hard | {
"lang": "rust",
"repo": "kevinswiber/bombardier",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kevinswiber/bombardier path: /src/parser.rs
use crate::file;
use std::process;
use std::collections::HashMap;
use log::{error, warn};
use regex::Regex;
use serde::{Serialize, Deserialize};
use serde_json::{Map, Value};
#[derive(Deserialize, Debug)]
pub struct Root {
#[serde(rename = "item"... | code_fim | hard | {
"lang": "rust",
"repo": "kevinswiber/bombardier",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs
#![feature(generic_associated_types)]
//~^ WARNING the feature `generic_associated_types` is incomplete
<|fim_suffix|>trait Iterable {
type Item<'a>;
type ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //~^ ERROR undeclared lifetime
//~| ERROR lifetime arguments are not allowed for this type [E0109]
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs
#![feature(generic_associate... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
//~^ ERROR undeclared lifetime
//~| ERROR lifetime arguments are not allowed for this type [E0109]
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/rfc1598-generic-associated-types/generic_associated_typ... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
pub fn set_x(&mut self, _x: i32){
self.x = _x
}
pub fn set_y(&mut self, _y: i32){
self.y = _y
}
}<|fim_prefix|>// repo: aloksbd/rust2 path: /src/position.rs
#[derive(Clone)]
pub struct Position{
x: i32,
y: i32,
}
impl Position{
pub fn new() -> Position{
... | code_fim | hard | {
"lang": "rust",
"repo": "aloksbd/rust2",
"path": "/src/position.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aloksbd/rust2 path: /src/position.rs
#[derive(Clone)]
pub struct Position{
x: i32,
y: i32,
}
impl Position{
pub fn new() -> Position{
Position{
<|fim_suffix|> }
pub fn set_x(&mut self, _x: i32){
self.x = _x
}
pub fn set_y(&mut self, _y: i32){
... | code_fim | hard | {
"lang": "rust",
"repo": "aloksbd/rust2",
"path": "/src/position.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbro885/customasm path: /src/asm/mod.rs
mod state;
mod rule;
mod ruleset;
mod invocation;
mod bank;
mod symbol;
pub mod parser;
pub use self::state::Assembler;
pub use self::state::State;
pub use self::state::Context;
pub use self::state::BankRef;
pub use self::st<|fim_suffix|>nvocation::Dat... | code_fim | hard | {
"lang": "rust",
"repo": "jbro885/customasm",
"path": "/src/asm/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>lf::invocation::Invocation;
pub use self::invocation::InvocationKind;
pub use self::invocation::RuleInvocation;
pub use self::invocation::RuleInvocationCandidate;
pub use self::invocation::RuleInvocationArgument;
pub use self::invocation::DataInvocation;
pub use self::invocation::LabelInvocation;
pub use ... | code_fim | hard | {
"lang": "rust",
"repo": "jbro885/customasm",
"path": "/src/asm/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: krautwigundrueben/properwatcher path: /src/crawlers/immowelt.rs
extern crate kuchiki;
extern crate regex;
extern crate reqwest;
extern crate std;
use super::{Crawler, Error};
use crate::crawlers::Metadata;
use crate::models::Encoding;
use crate::models::{ContractType, PropertyData, PropertyType... | code_fim | medium | {
"lang": "rust",
"repo": "krautwigundrueben/properwatcher",
"path": "/src/crawlers/immowelt.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rent = Self::get_text(&result, ".hardfacts_3 .hardfact:nth-child(1) strong")?;
let squaremeters = Self::get_text(&result, ".hardfacts_3 .hardfact:nth-child(2)")?;
let rooms = Self::get_text(&result, ".hardfacts_3 .hardfact:nth-child(3)")?;
let title = Self::get_text(&result, ".listcont... | code_fim | medium | {
"lang": "rust",
"repo": "krautwigundrueben/properwatcher",
"path": "/src/crawlers/immowelt.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Metadata {
name: String::from("immowelt"),
encoding: Encoding::Utf8,
}
}
fn selector(&self) -> &'static str {
".js-object[data-estateid]"
}
fn transform_result(&self, result: NodeDataRef<ElementData>) -> Result<PropertyData, Error> {
let rent = Self::get_text(&result,... | code_fim | medium | {
"lang": "rust",
"repo": "krautwigundrueben/properwatcher",
"path": "/src/crawlers/immowelt.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let buffer: Vec<f64> = (0..1000).map(|x| -500.0 + x as f64).collect();
let mut digest = ParTDigest::new(128, 256, &|| TDigest::new(&k1, &inv_k1, 20.0));
digest.add_buffer(&buffer);
let mut linear_digest = LinearDigest::new();
linear_digest.add_buffer(&buffer);
... | code_fim | hard | {
"lang": "rust",
"repo": "Scratchcat1/approximate-quantiles",
"path": "/src/t_digest/par_t_digest.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Scratchcat1/approximate-quantiles path: /src/t_digest/par_t_digest.rs
use crate::t_digest::centroid::Centroid;
use crate::t_digest::t_digest::TDigest;
use crate::traits::{Digest, OwnedSize};
use num_traits::{Float, NumAssignOps};
use rayon::prelude::*;
#[derive(Clone)]
pub struct ParTDigest<C, ... | code_fim | hard | {
"lang": "rust",
"repo": "Scratchcat1/approximate-quantiles",
"path": "/src/t_digest/par_t_digest.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: data-niklas/cash2 path: /backend/src/values/integer.rs
use crate::error::CashError;
use crate::value::{Value, ValueResult};
use crate::values::{BooleanValue, FloatValue};
#[derive(Debug, Clone)]
pub struct IntegerValue {
pub value: i64,
}
impl IntegerValue {
pub fn boxed(value: i64) ->... | code_fim | hard | {
"lang": "rust",
"repo": "data-niklas/cash2",
"path": "/backend/src/values/integer.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let typename = value.get_type_name();
if let Some(other) = value.downcast_ref::<IntegerValue>() {
self.value &= other.value;
Ok(self)
} else {
CashError::InvalidOperation("bitwise and".to_owned(), "integer ".to_owned() + typename)
... | code_fim | hard | {
"lang": "rust",
"repo": "data-niklas/cash2",
"path": "/backend/src/values/integer.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
E::Ans(ref exp) => format!("{}{}", sp.clone(), exp.p2(sp)),
E::Let(_, T::Unit, ref exp, ref e) => format!("{}{}{}", sp.clone(), exp.p2(sp.clone()), e.p2(sp)),
E::Let(ref id, ref t, ref exp, ref e) => format!("{}{} : {} = {}{}", sp.clone(), id, t.p(), exp.p2(sp.clone()),... | code_fim | hard | {
"lang": "rust",
"repo": "ykws/docs-2",
"path": "/yacc/min_caml_asm_rust/src/ast_print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ykws/docs-2 path: /yacc/min_caml_asm_rust/src/ast_print.rs
use ast::*;
pub trait P {
fn p(&self) -> String;
}
impl P for T {
fn p(&self) -> String {
match *self {
T::Unit => "unit".to_string(),
T::Bool => "bool".to_string(),
T::Int => "int".to_string(),
T::Fun(r... | code_fim | hard | {
"lang": "rust",
"repo": "ykws/docs-2",
"path": "/yacc/min_caml_asm_rust/src/ast_print.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.p2(format!(""))
}
}
impl P for E {
fn p(&self) -> String {
self.p2(format!(""))
}
}
impl P2 for Exp {
fn p2(&self, sp:String) -> String {
let sp2 = format!(" {}", sp);
match *self {
Exp::Nop => format!("nop\n"),
Exp::Set(i) => format!("set {}\n", i),
Exp::Se... | code_fim | hard | {
"lang": "rust",
"repo": "ykws/docs-2",
"path": "/yacc/min_caml_asm_rust/src/ast_print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wotsushi/competitive-programming path: /abc/132/e.rs
macro_rules! get {
(Vec<$t:ty>) => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|t| t.parse::<$t>().unwra... | code_fim | medium | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/abc/132/e.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (N, M) = get!(usize, usize);
let (u, v): (Vec<_>, Vec<_>) = get!(usize, usize; M).into_iter().unzip();
let (S, T) = get!(usize, usize);
// 何歩目かを含めた状態グラフを作成し、BFSにより解を求める
let mut G = vec!(vec!(); 3 * N + 1);
for (x, y) in u.into_iter().zip(v.into_iter()) {
G[x].push((y +... | code_fim | medium | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/abc/132/e.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vision::Fragment::add_client(&mut eng.as_vision_fragment(), cid, pid, region);
warn_on_err!(eng.script_hooks().call_client_login(eng.borrow(), cid));
eng.messages().send_client(cid, ClientResponse::SyncStatus(SyncKind::Ok));
Ok(())
}
pub fn logout(mut eng: EngineRef, cid: ClientId) -> bu... | code_fim | hard | {
"lang": "rust",
"repo": "OliveBloom/everfree-outpost",
"path": "/src/server/logic/client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for cpos in new_region.points().filter(|&p| !old_region.contains(p) || plane_change) {
logic::chunks::load_chunk(eng.borrow(), new_pid, cpos);
}
vision::Fragment::set_client_area(&mut eng.as_vision_fragment(), cid, new_pid, new_region);
for cpos in old_region.points().filter(|&p|... | code_fim | hard | {
"lang": "rust",
"repo": "OliveBloom/everfree-outpost",
"path": "/src/server/logic/client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OliveBloom/everfree-outpost path: /src/server/logic/client.rs
use types::*;
use chunks;
use engine::split::EngineRef;
use logic;
use messages::{ClientResponse, SyncKind};
use world;
use world::Motion;
use world::bundle::{self, Builder};
use world::extra;
use world::object::*;
use vision;
cons... | code_fim | hard | {
"lang": "rust",
"repo": "OliveBloom/everfree-outpost",
"path": "/src/server/logic/client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn end(&self) -> Option<I> { Some(self.end.clone()) }
fn to_range(&self, _: I, _: I) -> ops::Range<I> { self.clone() }
}
impl<I: Clone> AnyRange<I> for ops::RangeFrom<I> {
fn start(&self) -> Option<I> { Some(self.start.clone()) }
fn end(&self) -> Option<I> { None }
}
impl<I: Clone> An... | code_fim | hard | {
"lang": "rust",
"repo": "sellibitze/anyrange",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn start(&self) -> Option<I> { Some(self.start.clone()) }
fn end(&self) -> Option<I> { None }
}
impl<I: Clone> AnyRange<I> for ops::RangeTo<I> {
fn start(&self) -> Option<I> { None }
fn end(&self) -> Option<I> { Some(self.end.clone()) }
}
impl<I> AnyRange<I> for ops::RangeFull {
... | code_fim | hard | {
"lang": "rust",
"repo": "sellibitze/anyrange",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sellibitze/anyrange path: /src/lib.rs
//! This library provides an `AnyRange` trait that unifies the ranges
//! `std::ops::Range`, `std::ops::RangeFrom`, `std::ops::RangeTo`
//! and `std::ops::RangeFull`. It offers a function for converting
//! artibrary kinds of ranges to "concrete" ranges that... | code_fim | medium | {
"lang": "rust",
"repo": "sellibitze/anyrange",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dennisss/dacha path: /pkg/usb/src/hid/keyboard_report.rs
///
///
/// Data format:
/// - Byte 0: Modifiers pressed. Each bit corresponds to:
/// - 0 LEFT CTRL
/// - 1 LEFT SHIFT
/// - 2 LEFT ALT
/// - 3 LEFT GUI
/// - 4 RIGHT CTRL
/// - 5 RIGHT SHIFT
/// - 6 RIGHT ALT
/// - 7 RIGH... | code_fim | hard | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/usb/src/hid/keyboard_report.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.num_keys += 1;
}
}
impl AsRef<[u8]> for StandardKeyboardInputReport {
fn as_ref(&self) -> &[u8] {
&self.data
}
}
enum_def_with_unknown!(KeyCodeUsage u8 =>
Reserved = 0x00,
ErrorRollOver = 0x01,
POSTFail = 0x02,
ErrorUndefined = 0x03,
KeyboardA = 0x04,... | code_fim | hard | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/usb/src/hid/keyboard_report.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::projection_area(vec![vec![2]]), 5);
assert_eq!(Solution::projection_area(vec![vec![1, 2], vec![3, 4]]), 17);
assert_eq!(Solution::projection_area(vec![vec![1, 0], vec![0, 2]]), 8);
}
}<|fim_prefix|>// repo: qinxiaoguang/rs-lc path: /src/solution/l883.rs
use ... | code_fim | hard | {
"lang": "rust",
"repo": "qinxiaoguang/rs-lc",
"path": "/src/solution/l883.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>id[i][j]);
res += 1;
}
}
res += row;
}
res + cols.iter().sum::<i32>()
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_l883() {
assert_eq!(Solution::projection_area(vec![vec![2]]), 5);
asse... | code_fim | hard | {
"lang": "rust",
"repo": "qinxiaoguang/rs-lc",
"path": "/src/solution/l883.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qinxiaoguang/rs-lc path: /src/solution/l883.rs
use super::Solution;
impl Solution {
pub fn projection_area(grid: Vec<Vec<i32>>) -> i32 {
// 投影,只需要用一个数组保存一个方向的投影,其他方向的投影可以在遍历的时候获取结果
let mut res = 0;
let mut cols = vec![0; grid.len()]; // 竖直方向投影,某列的最大<|fim_suffix|>id[i... | code_fim | hard | {
"lang": "rust",
"repo": "qinxiaoguang/rs-lc",
"path": "/src/solution/l883.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fisherdarling/maze_project path: /src/graph.rs
use crate::{
Coord,
Direction::{self, *},
Input,
};
use std::collections::HashMap;
use petgraph::{algo::astar, graph::NodeIndex, Graph};
#[derive(Debug, Clone)]
pub struct Solver {
input: Input,
}
impl Solver {
pub fn new(input... | code_fim | hard | {
"lang": "rust",
"repo": "fisherdarling/maze_project",
"path": "/src/graph.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.