text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>_syntax noprefix\n");
print!(".global main\n");
print!("main:\n");
print!(" mov rax, {}\n", args.nth(1).unwrap());
print!(" ret\n");
return;
}<|fim_prefix|>// repo: ikedaosushi/sandbox path: /rust/osucc/src/main.rs
use std::env;
fn main() {
let mut args = env::args();
if ar... | code_fim | medium | {
"lang": "rust",
"repo": "ikedaosushi/sandbox",
"path": "/rust/osucc/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elsid/CodeBall path: /src/random.rs
use std::char;
use std::marker;
use std::mem;
use std::num::Wrapping as w;
use std::time;
#[allow(bad_style)]
type w64 = w<u64>;
#[allow(bad_style)]
type w32 = w<u32>;
pub trait Sample<Support> {
fn sample<R: Rng>(&mut self, rng: &mut R) -> Support;
}
p... | code_fim | hard | {
"lang": "rust",
"repo": "elsid/CodeBall",
"path": "/src/random.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "i128_support")]
impl Rand for i128 {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> i128 {
rng.gen::<u128>() as i128
}
}
impl Rand for usize {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> usize {
if mem::size_of::<usize>() == 4 {
rng.gen::<u32>() a... | code_fim | hard | {
"lang": "rust",
"repo": "elsid/CodeBall",
"path": "/src/random.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rng.$method_name()
}
}
}
}
}
float_impls! { f64_rand_impls, f64, 53, next_f64 }
float_impls! { f32_rand_impls, f32, 24, next_f32 }
impl Rand for char {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> char {
const CHAR_MASK: u32 = 0x001... | code_fim | hard | {
"lang": "rust",
"repo": "elsid/CodeBall",
"path": "/src/random.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: putuwaw/tlx-toki-answer path: /12. Rekursi/B. Faktorial Ganjil-Genap/b_faktorial_ganjil_genap.rs
fn factorial_gg(n: i32) -> i32 {
if n == 1 {
return 1;
} else if n % 2 == 0 {
return n / 2 * factorial_gg(n - 1);
} else {
return n * factorial_gg(n - 1);
}
}
... | code_fim | easy | {
"lang": "rust",
"repo": "putuwaw/tlx-toki-answer",
"path": "/12. Rekursi/B. Faktorial Ganjil-Genap/b_faktorial_ganjil_genap.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut reader = String::new();
std::io::stdin().read_line(&mut reader).expect("");
let n: i32 = reader.trim().parse().expect("");
println!("{}", factorial_gg(n));
}<|fim_prefix|>// repo: putuwaw/tlx-toki-answer path: /12. Rekursi/B. Faktorial Ganjil-Genap/b_faktorial_ganjil_genap.rs
fn f... | code_fim | easy | {
"lang": "rust",
"repo": "putuwaw/tlx-toki-answer",
"path": "/12. Rekursi/B. Faktorial Ganjil-Genap/b_faktorial_ganjil_genap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match req.key[5..].parse::<u64>() {
Ok(ms) => {
sleep(Duration::from_millis(ms)).await;
}
Err(_) => log::error!("No sleep"),
}
}
let got = txn
.read()
.await
.as_read()
.get(req.key.as_bytes())
... | code_fim | hard | {
"lang": "rust",
"repo": "whiten/repc",
"path": "/src/embed/connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whiten/repc path: /src/embed/connection.rs
use super::dispatch::Request;
use super::types::*;
use crate::dag;
use crate::db;
use async_fn::{AsyncFn2, AsyncFn3};
use async_std::stream::StreamExt;
use async_std::sync::{Receiver, RecvError, RwLock};
use futures::stream::futures_unordered::FuturesUn... | code_fim | hard | {
"lang": "rust",
"repo": "whiten/repc",
"path": "/src/embed/connection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: James-Dao/rs-tproxy path: /rs-tproxy-proxy/src/uds_client.rs
use std::path::PathBuf;
use tokio::io::AsyncReadExt;
use tokio::net::UnixStream;
#[derive(Debug, Clone)]
pub struct UdsDataClient {
pub path: PathBuf,
}
<|fim_suffix|> pub async fn read_into<'a, T: serde::de::Deserialize<'a>>... | code_fim | hard | {
"lang": "rust",
"repo": "James-Dao/rs-tproxy",
"path": "/rs-tproxy-proxy/src/uds_client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match bincode::deserialize(buf.as_slice()) {
Ok(o) => {
tracing::debug!("Deserialize data successfully.");
Ok(o)
}
Err(e) => {
tracing::debug!("Deserialize da... | code_fim | hard | {
"lang": "rust",
"repo": "James-Dao/rs-tproxy",
"path": "/rs-tproxy-proxy/src/uds_client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match Future::poll(future.as_mut(), &mut cx) {
Poll::Ready(val) => break val,
Poll::Pending => parker.park(),
}
}
}<|fim_prefix|>// repo: ryym/rust-futures-explained path: /src/exec.rs
use crate::{parker::Parker, waker::MyWaker};
use std::{
futur... | code_fim | hard | {
"lang": "rust",
"repo": "ryym/rust-futures-explained",
"path": "/src/exec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryym/rust-futures-explained path: /src/exec.rs
use crate::{parker::Parker, waker::MyWaker};
use std::{
future::Future,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let parker = Arc::new(Parker::default());
let my... | code_fim | medium | {
"lang": "rust",
"repo": "ryym/rust-futures-explained",
"path": "/src/exec.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> ::std::result::Result<S::Ok, S::Error>
where S: Serializer
{
let mut map = serializer.serialize_map(Some(1))?;
map.serialize_key("description")?;
map.serialize_value(self.description())?;
ma... | code_fim | hard | {
"lang": "rust",
"repo": "GyrosOfWar/blog",
"path": "/src/errors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GyrosOfWar/blog path: /src/errors.rs
use r2d2;
use std::io;
use std::error::Error as StdError;
use diesel;
use serde::{Serialize, Serializer};
use serde::ser::SerializeMap;
error_chain! {
foreign_links {
Io(io::Error);
DbTimeout(r2d2::GetTimeout);
Reqwest(::reqwest:... | code_fim | medium | {
"lang": "rust",
"repo": "GyrosOfWar/blog",
"path": "/src/errors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BalzGuenat/rustcache path: /src/main.rs
#![allow(unused_imports)]
extern crate threadpool;
use std::str;
use std::io;
use std::io::prelude::*;
use std::io::{Error, ErrorKind};
use std::net::{TcpListener, TcpStream, SocketAddr};
use std::collections::HashMap;
use std::sync::mpsc;
use std::sync... | code_fim | hard | {
"lang": "rust",
"repo": "BalzGuenat/rustcache",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("GET");
let key = &pkg.data[..];
let map = maplock.lock().unwrap();
match map.get(&key.to_vec()) {
Some(valpkg) => {
let val = valpkg.val();
println!("snd {} -> {}", desc(key), desc(val));
let val_len = &[valpkg.val_len() as u8];
... | code_fim | hard | {
"lang": "rust",
"repo": "BalzGuenat/rustcache",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let keylen = pkg.data[0] as usize;
// let mut key = Vec::with_capacity(keylen);
// unsafe { key.set_len(keylen) };
// key.copy_from_slice(&pkg.data[1..1+keylen]);
let key = pkg.data[1..1+keylen].to_vec();
// let msgbuf = &pkg.data[..];
// let key = &msgbuf[1..keylen+1];
/... | code_fim | hard | {
"lang": "rust",
"repo": "BalzGuenat/rustcache",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ceciliacsilva/wasm-fire path: /src/js.rs
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
pub fn alert(s: &str);
}
#[wasm_bindgen]
pub fn say_hi(){
alert("Hello.");
}
<|fim_suffix|>#[wasm_bindgen(module = "/defined-in-js.js")]
extern "C" {
pub fn pause();
}<|fim_middle|>#[wa... | code_fim | medium | {
"lang": "rust",
"repo": "ceciliacsilva/wasm-fire",
"path": "/src/js.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen(module = "/defined-in-js.js")]
extern "C" {
pub fn pause();
}<|fim_prefix|>// repo: ceciliacsilva/wasm-fire path: /src/js.rs
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
pub fn alert(s: &str);
}
<|fim_middle|>#[wasm_bindgen]
pub fn say_hi(){
alert("Hello.");
}
#[wa... | code_fim | medium | {
"lang": "rust",
"repo": "ceciliacsilva/wasm-fire",
"path": "/src/js.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: llogiq/rustimization path: /src/minimizer.rs
use cg_minimizer::CG;
use lbfgsb_minimizer::Lbfgsb;
pub struct Funcmin<'a>{
x:&'a mut Vec<f64>,
f:&'a Fn(&Vec<f64>)->f64,
g:&'a Fn(&Vec<f64>)->Vec<f64>,
tol:f64,
verbose: bool,
method: &'a str,
max_iter: u32
}
impl<'a> Func... | code_fim | hard | {
"lang": "rust",
"repo": "llogiq/rustimization",
"path": "/src/minimizer.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>t_verbosity(ver);
minf.set_tolerance(self.tol);
minf.max_iteration(self.max_iter);
minf.minimize();
}
else if self.method== "cg"{
let mut minf = CG::new(&mut self.x,&self.f,&self.g);
minf.set_verbosity(... | code_fim | hard | {
"lang": "rust",
"repo": "llogiq/rustimization",
"path": "/src/minimizer.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if enable {
stream1_chan1.cr.modify(|_, w| w.en().enabled());
} else {
stream1_chan1.cr.modify(|_, w| w.en().disabled());
}
// #[cfg(feature = "rttdebug")]
// rprintln!("09 dma2_cr: {:#b}", stream1_chan1.cr.read().bits());
}
/// Ena... | code_fim | hard | {
"lang": "rust",
"repo": "tstellanova/px4flow_bsp",
"path": "/src/dcmi.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tstellanova/px4flow_bsp path: /src/dcmi.rs
with a 64x64, 8 bits per pixel capture
pub fn default(dcmi: pac::DCMI) -> Self {
Self::new(dcmi, DEFAULT_IMG_WIDTH, DEFAULT_IMG_HEIGHT, DEFAULT_BITS_PER_PIXEL)
}
/// Create a new DcmiWrapper with configured frame dimensions
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "tstellanova/px4flow_bsp",
"path": "/src/dcmi.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tstellanova/px4flow_bsp path: /src/dcmi.rs
I with a 64x64, 8 bits per pixel capture
pub fn default(dcmi: pac::DCMI) -> Self {
Self::new(dcmi, DEFAULT_IMG_WIDTH, DEFAULT_IMG_HEIGHT, DEFAULT_BITS_PER_PIXEL)
}
/// Create a new DcmiWrapper with configured frame dimensions
pu... | code_fim | hard | {
"lang": "rust",
"repo": "tstellanova/px4flow_bsp",
"path": "/src/dcmi.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SuperFluffy/telamon path: /telamon-gen/src/lexer/ffi.rs
#![allow(dead_code)]
use ::libc;
use ::ir;
use std::fmt;
/// A [yyscan](https://westes.github.io/flex/manual/About-yyscan_005ft.html) type is the internal
/// representation of a [yylex_init](https://westes.github.io/flex/manual/Init-and-... | code_fim | hard | {
"lang": "rust",
"repo": "SuperFluffy/telamon",
"path": "/telamon-gen/src/lexer/ffi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub enum YyToken {
ValueIdent,
ChoiceIdent,
Var,
Doc,
CmpOp,
InvalidToken,
Code,
CounterKind,
Bool,
CounterVisibility,
And,
Trigger,
When,
Alias,
Counter,
Define,
Enum,
Equal,
Forall,
I... | code_fim | hard | {
"lang": "rust",
"repo": "SuperFluffy/telamon",
"path": "/telamon-gen/src/lexer/ffi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<Y> Spanned<Y> {
pub fn new(data: Y) -> Spanned<Y> {
Spanned {
beg: Position::default(),
end: Position::default(),
data,
}
}
}
pub type YyExtraType = Spanned<YyLval>;
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub enum YyToken {
ValueIden... | code_fim | hard | {
"lang": "rust",
"repo": "SuperFluffy/telamon",
"path": "/telamon-gen/src/lexer/ffi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsISubstitutingProtocolHandler.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsISubstitutingProtocolHandler.idl
//
#[repr(C)]
pub struct nsISubstitutingProtocolHandler {
vtable: *const nsISubstitutingProtocolHandlerVTable,
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsISubstitutingProtocolHandler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl nsISubstitutingProtocolHandler {
#[inline]
pub fn coerce<T: nsISubstitutingProtocolHandlerCoerce>(&self) -> &T {
T::coerce_from(self)
}
}
impl ::std::ops::Deref for nsISubstitutingProtocolHandler {
type Target = nsIProtocolHandler;
#[inline]
fn deref(&self) -> &nsIPro... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsISubstitutingProtocolHandler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* [must_use] boolean hasSubstitution (in ACString root); */
pub hasSubstitution: unsafe extern "C" fn (this: *const nsISubstitutingProtocolHandler, root: *const nsACString, _retval: *mut bool) -> nsresult,
/* [must_use] AUTF8String resolveURI (in nsIURI resURI); */
pub resolveURI: unsafe... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsISubstitutingProtocolHandler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DFlipFlop {
pub fn new(creator: &mut NodeCreator) -> DFlipFlop {
let top = NotSRLatch::new(creator);
let bottom = NotSRLatch::new(creator);
let output = NotSRLatch::new(creator);
let ander = AndGate::new(creator);
let clock = ander.a;
... | code_fim | hard | {
"lang": "rust",
"repo": "PeterReid/logicsim",
"path": "/src/storage.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let clock = bits[0].clock;
for bit in (&bits[1..]).iter() {
creator.link(clock, bit.clock, STANDARD_DELAY);
}
Register {
inputs: bits.iter().map(|bit| { return bit.data }).collect(),
outputs: bits.iter().map(|bit| { return... | code_fim | hard | {
"lang": "rust",
"repo": "PeterReid/logicsim",
"path": "/src/storage.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PeterReid/logicsim path: /src/storage.rs
use sim::{LineState, NodeIndex, NodeCreator, NodeCollection, PropogationDelay, STANDARD_DELAY};
use logic_gates::{NandGate, AndGate};
use arena::Arena;
#[derive(Debug)]
pub struct NotSRLatch {
pub not_s: NodeIndex,
pub not_r: NodeInd... | code_fim | hard | {
"lang": "rust",
"repo": "PeterReid/logicsim",
"path": "/src/storage.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aleru/tokio path: /tokio-net/src/process/unix/orphan.rs
use crossbeam_queue::SegQueue;
use std::io;
use std::process::ExitStatus;
/// An interface for waiting on a process to exit.
pub(crate) trait Wait {
/// Get the identifier for this process or diagnostics.
fn id(&self) -> u32;
/... | code_fim | hard | {
"lang": "rust",
"repo": "Aleru/tokio",
"path": "/tokio-net/src/process/unix/orphan.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len == 0 {
return;
}
let mut orphans = Vec::with_capacity(len);
while let Ok(mut orphan) = self.queue.pop() {
match orphan.try_wait() {
Ok(Some(_)) => {}
Err(e) => error!(
message = "leaking orp... | code_fim | hard | {
"lang": "rust",
"repo": "Aleru/tokio",
"path": "/tokio-net/src/process/unix/orphan.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lineCode/GameServer_Rust path: /server/src/mgr/mod.rs
pub mod game_mgr;
pub mod timer_mgr;
use num_enum::IntoPrimitive;
use num_enum::TryFromPrimitive;
///房间类型
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(u8)]
pub enum RoomType {
None = 0, ... | code_fim | medium | {
"lang": "rust",
"repo": "lineCode/GameServer_Rust",
"path": "/server/src/mgr/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn into_u32(self) -> u32 {
let res: u8 = self.into();
res as u32
}
pub fn is_match_type(self) -> bool {
self == RoomType::OneVOneVOneVOneMatch || self == RoomType::WorldBoseMatch
}
}<|fim_prefix|>// repo: lineCode/GameServer_Rust path: /server/src/mgr/mod.rs
p... | code_fim | medium | {
"lang": "rust",
"repo": "lineCode/GameServer_Rust",
"path": "/server/src/mgr/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raftario/aoc2020 path: /src/d06.rs
use std::collections::HashSet;
pub fn parse_input<'a>(
input: &'a str,
) -> impl Iterator<Item = impl Iterator<Item = HashSet<char>> + 'a> + 'a {
input.<|fim_suffix|> .filter(|s| !s.is_empty())
.map(|s| s.chars().collect())
})
}<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "raftario/aoc2020",
"path": "/src/d06.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>split("\n\n").filter(|s| !s.is_empty()).map(|s| {
s.split('\n')
.filter(|s| !s.is_empty())
.map(|s| s.chars().collect())
})
}<|fim_prefix|>// repo: raftario/aoc2020 path: /src/d06.rs
use std::collections::HashSet;
pub fn parse_input<'a>(
input: &'a str,
) -><|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "raftario/aoc2020",
"path": "/src/d06.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> .filter(|s| !s.is_empty())
.map(|s| s.chars().collect())
})
}<|fim_prefix|>// repo: raftario/aoc2020 path: /src/d06.rs
use std::collections::HashSet;
pub fn parse_input<'a>(
input: &'a str,
) -><|fim_middle|> impl Iterator<Item = impl Iterator<Item = HashSet<char>> + 'a> + 'a {
... | code_fim | medium | {
"lang": "rust",
"repo": "raftario/aoc2020",
"path": "/src/d06.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> g.set_edge((0, 1), w2[2]);
assert_eq!(g.is_symmetric(), true);
}
#[test]
#[should_panic]
fn test_graph_construction_2() {
let w: Vec<Option<f64>> = vec![None, Some(1.0f64)];
super::Digraph::from_vec(&w);
}
#[test]
fn test_graph_construction_3()... | code_fim | hard | {
"lang": "rust",
"repo": "equescalculi/matrixgraph",
"path": "/src/digraph.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: equescalculi/matrixgraph path: /src/digraph.rs
// Copyright 2015 Marius Ritter
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This... | code_fim | hard | {
"lang": "rust",
"repo": "equescalculi/matrixgraph",
"path": "/src/digraph.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GraphAlgorithms<Digraph> for Digraph {
fn johnson_graph(&self) -> Result<(Digraph, Vec<f64>), GraphErrors> {
let size = self.size();
let mut eweights: Vec<Option<f64>> = self.weights.clone();
for i in 0..size {
eweights.insert(size * (i + 1) + i, None);
... | code_fim | hard | {
"lang": "rust",
"repo": "equescalculi/matrixgraph",
"path": "/src/digraph.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args: Vec<String> = env::args().collect();
let program = args[0].clone();
let matches = match opts.parse(&args[1..]) {
Ok(m) => { m }
Err(f) => { panic!(f.to_string()) }
};
if matches.opt_present("h") {
print_usage(&program, opts);
return;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "MarkOfLark/tcc-rs",
"path": "/examples/tcc-date.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarkOfLark/tcc-rs path: /examples/tcc-date.rs
extern crate time;
extern crate getopts;
extern crate tcc;
use time::{Timespec};
use getopts::Options;
use std::env;
fn print_usage(program: &str, opts: Options) {
let brief = format!("Usage: {} [options]",program);
print!("{}", opts.usag... | code_fim | medium | {
"lang": "rust",
"repo": "MarkOfLark/tcc-rs",
"path": "/examples/tcc-date.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ealasu/rust-rawspeed path: /src/raw_image.rs
use std::slice;
use std::os::raw::c_void;
use ndarray::ArrayView2;
use ndarray::ShapeBuilder;
use libc::c_int;
use rawspeed_sys as ffi;
use ::camera_metadata::{CameraMetadata, DEFAULT_CAMERA_METADATA};
#[derive(Debug, Fail)]
#[fail(display = "failed ... | code_fim | hard | {
"lang": "rust",
"repo": "ealasu/rust-rawspeed",
"path": "/src/raw_image.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let img = RawImage::decode(&test_data(), false).unwrap();
let res = img.view_uncropped();
assert_eq!(res.shape()[0], 3708);
assert_eq!(res.shape()[1], 5568);
let expected_points = [2045, 2043, 2058, 2984];
let actual_points = [
res[[0, 0]],
... | code_fim | hard | {
"lang": "rust",
"repo": "ealasu/rust-rawspeed",
"path": "/src/raw_image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn view_uncropped() {
let img = RawImage::decode(&test_data(), false).unwrap();
let res = img.view_uncropped();
assert_eq!(res.shape()[0], 3708);
assert_eq!(res.shape()[1], 5568);
let expected_points = [2045, 2043, 2058, 2984];
let actual_poi... | code_fim | hard | {
"lang": "rust",
"repo": "ealasu/rust-rawspeed",
"path": "/src/raw_image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sadiqmmm/artichoke path: /artichoke-backend/src/extn/stdlib/delegate.rs
use artichoke_core::load::LoadSources;
use crate::class;
use crate::{Artichoke, ArtichokeError};
pub fn init(interp: &Artichoke) -> Res<|fim_suffix|>p.def_rb_source_file(b"delegate.rb", &include_bytes!("delegate.rb")[..])?... | code_fim | hard | {
"lang": "rust",
"repo": "sadiqmmm/artichoke",
"path": "/artichoke-backend/src/extn/stdlib/delegate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>p.def_rb_source_file(b"delegate.rb", &include_bytes!("delegate.rb")[..])?;
Ok(())
}
pub struct Delegator;
pub struct SimpleDelegator;<|fim_prefix|>// repo: sadiqmmm/artichoke path: /artichoke-backend/src/extn/stdlib/delegate.rs
use artichoke_core::load::LoadSources;
use crate::class;
use crate::{Ar... | code_fim | hard | {
"lang": "rust",
"repo": "sadiqmmm/artichoke",
"path": "/artichoke-backend/src/extn/stdlib/delegate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let db = CoreDbMemoryImpl::open("kvs");
let range_db = RangeDbImpl::from(db);
let mut aggregator = PlasmaAggregator::new(
Address::zero(),
Address::zero(),
Address::zero(),
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
range_db,
... | code_fim | medium | {
"lang": "rust",
"repo": "hustnn/plasma-rust-framework",
"path": "/clients/examples/plasma_aggregator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let db = CoreDbMemoryImpl::open("kvs");
let range_db = RangeDbImpl::from(db);
let mut aggregator = PlasmaAggregator::new(
Address::zero(),
Address::zero(),
Address::zero(),
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
r... | code_fim | medium | {
"lang": "rust",
"repo": "hustnn/plasma-rust-framework",
"path": "/clients/examples/plasma_aggregator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hustnn/plasma-rust-framework path: /clients/examples/plasma_aggregator.rs
use bincode::serialize;
use ethereum_types::Address;
use ovm::types::StateUpdateList;
use plasma_clients::plasma::PlasmaAggregator;
use plasma_core::data_structure::abi::Decodable;
use plasma_core::data_structure::abi::Enc... | code_fim | medium | {
"lang": "rust",
"repo": "hustnn/plasma-rust-framework",
"path": "/clients/examples/plasma_aggregator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>y)]
pub unsafe extern "C" fn bam_hdr_destroy(h: *mut bam_hdr_t) {
sam_hdr_destroy(h as _)
}<|fim_prefix|>// repo: 38/d4-format path: /d4-hts/src/alignment/htslib.rs
#![allow(non_upper_case_globals)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(improper_ctype... | code_fim | medium | {
"lang": "rust",
"repo": "38/d4-format",
"path": "/d4-hts/src/alignment/htslib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 38/d4-format path: /d4-hts/src/alignment/htslib.rs
#![allow(non_upper_case_globals)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(improper_ctypes)]
#![allow(clippy::redundant_static_lifetimes)]
#![a<|fim_suffix|>y)]
pub unsafe extern "C" fn bam_hdr_dest... | code_fim | medium | {
"lang": "rust",
"repo": "38/d4-format",
"path": "/d4-hts/src/alignment/htslib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>llow(clippy::upper_case_acronyms)]
include!("../../generated/hts.rs");
#[cfg(no_bam_hdr_destroy)]
pub unsafe extern "C" fn bam_hdr_destroy(h: *mut bam_hdr_t) {
sam_hdr_destroy(h as _)
}<|fim_prefix|>// repo: 38/d4-format path: /d4-hts/src/alignment/htslib.rs
#![allow(non_upper_case_globals)]
#![allo... | code_fim | medium | {
"lang": "rust",
"repo": "38/d4-format",
"path": "/d4-hts/src/alignment/htslib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cmal/rust-practise-questions path: /answer/chapter_06/overload_add/src/main.rs
use fsize::fsize;
use std::fmt::{ Result, Formatter, Display };
use std::ops::Add;
<|fim_suffix|> Self {
int: self.int + rhs.int,
flt: self.flt + rhs.flt
}
}
}
fn main() {
... | code_fim | hard | {
"lang": "rust",
"repo": "cmal/rust-practise-questions",
"path": "/answer/chapter_06/overload_add/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Add<Self> for Num {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self {
int: self.int + rhs.int,
flt: self.flt + rhs.flt
}
}
}
fn main() {
let n1 = Num { int: 3, flt: 0.0 };
let n2 = Num { int: 0, flt: 2.5 };
println!("{}", n1... | code_fim | medium | {
"lang": "rust",
"repo": "cmal/rust-practise-questions",
"path": "/answer/chapter_06/overload_add/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n1 = Num { int: 3, flt: 0.0 };
let n2 = Num { int: 0, flt: 2.5 };
println!("{}", n1 + n2);
}<|fim_prefix|>// repo: cmal/rust-practise-questions path: /answer/chapter_06/overload_add/src/main.rs
use fsize::fsize;
use std::fmt::{ Result, Formatter, Display };
use std::ops::Add;
struct Num ... | code_fim | medium | {
"lang": "rust",
"repo": "cmal/rust-practise-questions",
"path": "/answer/chapter_06/overload_add/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zrneely/wamp_async path: /src/serializer/json.rs
use crate::message::*;
use crate::serializer::*;
pub use serde_json::error::Error;
use serde_json::{from_slice, to_vec};
<|fim_suffix|> match from_slice(v) {
Ok(v) => Ok(v),
Err(e) => Err(SerializerError::Deserializ... | code_fim | hard | {
"lang": "rust",
"repo": "zrneely/wamp_async",
"path": "/src/serializer/json.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match from_slice(v) {
Ok(v) => Ok(v),
Err(e) => Err(SerializerError::Deserialization(e.to_string())),
}
}
}<|fim_prefix|>// repo: zrneely/wamp_async path: /src/serializer/json.rs
use crate::message::*;
use crate::serializer::*;
pub use serde_json::error::Error;... | code_fim | hard | {
"lang": "rust",
"repo": "zrneely/wamp_async",
"path": "/src/serializer/json.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chyyuu/zCore path: /zCore/src/arch/mod.rs
#[cfg(target_arch = "x86_64")]
pub mod x86_64;
#[cf<|fim_suffix|>fg(target_arch = "riscv64")]
pub use self::riscv::*;<|fim_middle|>g(target_arch = "x86_64")]
pub use self::x86_64::*;
#[cfg(target_arch = "riscv64")]
pub mod riscv;
#[c | code_fim | medium | {
"lang": "rust",
"repo": "chyyuu/zCore",
"path": "/zCore/src/arch/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[cfg(target_arch = "riscv64")]
pub mod riscv;
#[cfg(target_arch = "riscv64")]
pub use self::riscv::*;<|fim_prefix|>// repo: chyyuu/zCore path: /zCore/src/arch/mod.rs
#[cfg(target_arch = "x86_64")]
pub mod x86_64;
#[cf<|fim_middle|>g(target_arch = "x86_64")]
pub use self::x86_64::*;
| code_fim | easy | {
"lang": "rust",
"repo": "chyyuu/zCore",
"path": "/zCore/src/arch/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chyyuu/zCore path: /zCore/src/arch/mod.rs
#[cfg(target_arch = "x86_64")]
pub mod x86_64;
#[cfg(target_arch = "x86_64")]
pub use self::x86_64::*;
<|fim_suffix|>fg(target_arch = "riscv64")]
pub use self::riscv::*;<|fim_middle|>
#[cfg(target_arch = "riscv64")]
pub mod riscv;
#[c | code_fim | easy | {
"lang": "rust",
"repo": "chyyuu/zCore",
"path": "/zCore/src/arch/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fireforge/rustup.rs path: /src/rustup/lib.rs
extern crate rustup_dist;
#[macro_use]
extern crate rustup_utils;
extern crate hyper;
extern crate regex;
extern crate itertools;
<|fim_suffix|>mod errors;
mod override_db;
mod toolchain;
mod config;
mod env_var;
mod install;<|fim_middle|>pub use err... | code_fim | medium | {
"lang": "rust",
"repo": "Fireforge/rustup.rs",
"path": "/src/rustup/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod errors;
mod override_db;
mod toolchain;
mod config;
mod env_var;
mod install;<|fim_prefix|>// repo: Fireforge/rustup.rs path: /src/rustup/lib.rs
extern crate rustup_dist;
#[macro_use]
extern crate rustup_utils;
extern crate hyper;
extern crate regex;
extern crate itertools;
<|fim_middle|>pub use err... | code_fim | medium | {
"lang": "rust",
"repo": "Fireforge/rustup.rs",
"path": "/src/rustup/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_configurable(&mut self, flag: bool) {
if flag {
self.configurable = true;
}
}
pub fn set_enumerable(&mut self, flag: bool) {
if flag {
self.enumerable = true;
}
}
pub fn expand(&self, name: &str, cfg: &Config) -> Toke... | code_fim | hard | {
"lang": "rust",
"repo": "cibingeorge/rquickjs",
"path": "/macro/src/bind/property.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cibingeorge/rquickjs path: /macro/src/bind/property.rs
use super::{BindConst, BindFn1};
use crate::{Config, TokenStream};
use quote::quote;
use syn::spanned::Spanned;
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct BindProp {
pub val: Option<BindConst>,
pub get: Option<BindFn... | code_fim | hard | {
"lang": "rust",
"repo": "cibingeorge/rquickjs",
"path": "/macro/src/bind/property.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: semtexzv/kstream path: /src/task/mod.rs
use crate::{KStream, Config, KVStore, KTable};
use crate::format::Format;
use crate::stream::topic::{RawConsumer, TypedConsumer, TypedProducer, RawProducer};
use crate::stream::{StreamItem, KSink, Map, Filter};
use serde::export::PhantomData;
use crate::t... | code_fim | hard | {
"lang": "rust",
"repo": "semtexzv/kstream",
"path": "/src/task/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn to<KF, VF>(mut self, name: &str) -> !
where KF: Format<Item=S::Key>,
VF: Format<Item=S::Value>
{
let mut sink = TypedProducer::<KF, VF> {
raw: RawProducer::new(&self.cfg, name),
_marker: PhantomData,
};
info!("Sink... | code_fim | hard | {
"lang": "rust",
"repo": "semtexzv/kstream",
"path": "/src/task/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GameList {
pub fn list(conn: &Connection) -> Result<Vec<Game>> {
let mut stmt = conn.prepare("SELECT * FROM Games;")?;
let result = stmt.query_map(NO_PARAMS, |row| {
Ok(Game {
id: row.get(0)?,
stake_amount: row.get(1)?,
... | code_fim | hard | {
"lang": "rust",
"repo": "HeGoLo/Rust-Warp-Example",
"path": "/src/models/game.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = rand::thread_rng();
let from_zero_to_one = rng.gen::<f64>(); // [0, 1)
let condition: bool = from_zero_to_one >= odd; // Include = because ) from_zero_to_one
let win = if condition {
debug!("You lost the gamble.");
false
} else {
debug!("You won t... | code_fim | hard | {
"lang": "rust",
"repo": "HeGoLo/Rust-Warp-Example",
"path": "/src/models/game.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HeGoLo/Rust-Warp-Example path: /src/models/game.rs
// https://www.macmillandictionary.com/us/thesaurus-category/american/money-involved-in-gambling
// https://www.begambleaware.org/understanding-gambling/gambling-words-and-phrases-explained/
use rusqlite::{params, Connection, Result, NO_PARAMS}... | code_fim | hard | {
"lang": "rust",
"repo": "HeGoLo/Rust-Warp-Example",
"path": "/src/models/game.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tkmct/kadrs path: /src/response.rs
use {
crate::{node::NodeInfo, request::Request, rpc::Rpc},
arrayvec::ArrayVec,
serde::{Deserialize, Serialize},
};
const K: usize = 10;
#[derive(Debug, Serialize, Deserialize)]
pub enum ResponseBody {
PONG,
VALUE(Vec<u8>),
NODES(Vec<No... | code_fim | medium | {
"lang": "rust",
"repo": "tkmct/kadrs",
"path": "/src/response.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)]
pub struct Response {
request_rpc: Rpc,
from: NodeInfo,
to: Option<NodeInfo>,
body: Option<ResponseBody>,
}
impl Response {
pub fn new(from: NodeInfo, to: Option<NodeInfo>, rpc: Rpc, body: Option<ResponseBody>) -> Self {
Self {
... | code_fim | medium | {
"lang": "rust",
"repo": "tkmct/kadrs",
"path": "/src/response.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_body(&mut self, body: Option<ResponseBody>) {
self.body = body
}
pub fn from_request(req: Request) -> Self {
Self {
from: req.get_to().clone(),
to: req.get_from().map(|f| f.clone()),
request_rpc: req.get_rpc().clone(),
... | code_fim | hard | {
"lang": "rust",
"repo": "tkmct/kadrs",
"path": "/src/response.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if num < 1 {
println!("{} you need to input the number more than 1 or *", style("info:").red());
continue;
}
break num.to_string();
}
};
upper
}<|fim_prefix|>// repo: hibi221b/repo-matome path: /src/select_bound.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "hibi221b/repo-matome",
"path": "/src/select_bound.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hibi221b/repo-matome path: /src/select_bound.rs
use std::io;
use console::style;
pub fn select_lower_bound() -> String {
let lower = loop {
let mut s = String::new();
io::stdin().read_line(&mut s).expect("cannot read line");
let num: u64 = match s.trim().parse()... | code_fim | hard | {
"lang": "rust",
"repo": "hibi221b/repo-matome",
"path": "/src/select_bound.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ruddickmg/bb8-memcached path: /src/client.rs
use memcache_async::ascii;
use std::io;
use std::ops::{Deref, DerefMut};
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::net::{TcpStream, UnixStream};
use url::Url;
use std::fmt::Display;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "Ruddickmg/bb8-memcached",
"path": "/src/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> DerefMut for StreamCompat<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl<T: AsyncRead> futures::AsyncRead for StreamCompat<T> {
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Res... | code_fim | hard | {
"lang": "rust",
"repo": "Ruddickmg/bb8-memcached",
"path": "/src/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let actual_index = index + (self.offset as i32);
&mut self.v[actual_index as usize]
}
}
#[snippet("_integer_indexed_vec_trait", include = "_integer_indexed_vec_index_mut")]
trait IntoIntegerIndexedVec {
type Output;
#[warn(dead_code)]
fn into_i32_indexed_vec(self, offset:... | code_fim | hard | {
"lang": "rust",
"repo": "kinodjnz/cp-snippet",
"path": "/src/integer_indexed_vec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[warn(dead_code)]
fn into_i32_indexed_vec(self, offset: usize) -> IntegerIndexedVec<T> {
IntegerIndexedVec::new(self, offset)
}
}
#[test]
fn test_i32_indexed_vec() {
let v = std::iter::successors(Some(0), |&n| Some(n+1))
.take(10)
.collect::<Vec<_>>().into_i32_ind... | code_fim | hard | {
"lang": "rust",
"repo": "kinodjnz/cp-snippet",
"path": "/src/integer_indexed_vec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kinodjnz/cp-snippet path: /src/integer_indexed_vec.rs
use cargo_snippet::snippet;
#[snippet("_integer_indexed_vec_struct")]
#[derive(Debug, Clone)]
struct IntegerIndexedVec<T> {
v: Vec<T>,
offset: usize,
}
#[snippet("_integer_indexed_vec_impl", include = "_integer_indexed_vec_struct")]... | code_fim | hard | {
"lang": "rust",
"repo": "kinodjnz/cp-snippet",
"path": "/src/integer_indexed_vec.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
container: None,
stdin: false,
stdout: true,
stderr: true,
tty: false,
max_stdin_buf_size: None,
max_stdout_buf_size: None,
max_stderr_buf_size: None,
}
}
}
#[cfg(feature = "ws")]
im... | code_fim | hard | {
"lang": "rust",
"repo": "NAlexPear/kube-rs",
"path": "/kube/src/api/subresource.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NAlexPear/kube-rs path: /kube/src/api/subresource.rs
{
let req = self.resource.get_scale(name)?;
self.client.request::<Scale>(req).await
}
/// Update the scale subresource
pub async fn patch_scale<P: serde::Serialize>(
&self,
name: &str,
pp: ... | code_fim | hard | {
"lang": "rust",
"repo": "NAlexPear/kube-rs",
"path": "/kube/src/api/subresource.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set `tty` field.
pub fn tty(mut self, enable: bool) -> Self {
self.tty = enable;
self
}
/// Set `max_stdin_buf_size` field.
pub fn max_stdin_buf_size(mut self, size: usize) -> Self {
self.max_stdin_buf_size = Some(size);
self
}
/// Set `max... | code_fim | hard | {
"lang": "rust",
"repo": "NAlexPear/kube-rs",
"path": "/kube/src/api/subresource.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/maps/icon_local_library.rs
pub struct IconLocalLibrary {
props: crate::Props,
}
impl yew::Component for IconLocalLibrary {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::p... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/maps/icon_local_library.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[enum_derive(rayon::ParallelIterator, rayon::IndexedParallelIterator, rayon::ParallelExtend)]
enum Rayon<A, B> {
A(A),
B(B),
}
fn main() {}<|fim_prefix|>// repo: taiki-e/auto_enums path: /tests/run-pass/rayon.rs
extern crate rayon_crate as rayon;
<|fim_middle|>use auto_enums::enum_derive;
| code_fim | easy | {
"lang": "rust",
"repo": "taiki-e/auto_enums",
"path": "/tests/run-pass/rayon.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: taiki-e/auto_enums path: /tests/run-pass/rayon.rs
extern crate rayon_crate as rayon;
<|fim_suffix|>#[enum_derive(rayon::ParallelIterator, rayon::IndexedParallelIterator, rayon::ParallelExtend)]
enum Rayon<A, B> {
A(A),
B(B),
}
fn main() {}<|fim_middle|>use auto_enums::enum_derive;
| code_fim | easy | {
"lang": "rust",
"repo": "taiki-e/auto_enums",
"path": "/tests/run-pass/rayon.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astro/rust-protobuf-iter path: /src/value64.rs
use byteorder::{ByteOrder, LittleEndian};
/// Encapsulated for From
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct Value64<'a> {
pub data: &'a [u8]
}
impl<'a> From<Value64<'a>> for u32 {
fn from(value64: Value64<'a>) -> u32 {
L... | code_fim | medium | {
"lang": "rust",
"repo": "astro/rust-protobuf-iter",
"path": "/src/value64.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> LittleEndian::read_u64(&value64.data) as u32
}
}
impl<'a> From<Value64<'a>> for i32 {
fn from(value64: Value64<'a>) -> i32 {
LittleEndian::read_i64(&value64.data) as i32
}
}
impl<'a> From<Value64<'a>> for u64 {
fn from(value64: Value64<'a>) -> u64 {
LittleEndian::... | code_fim | medium | {
"lang": "rust",
"repo": "astro/rust-protobuf-iter",
"path": "/src/value64.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: morr0ne/oa path: /src/v3/paths.rs
use indexmap::IndexMap;
<|fim_suffix|>pub type PathsObject = IndexMap<String, ReferenceObjectOr<PathsItemObject>>; // TODO: Specification Extensions. // TODO: better implement this object<|fim_middle|>use super::{PathsItemObject, ReferenceObjectOr};
| code_fim | easy | {
"lang": "rust",
"repo": "morr0ne/oa",
"path": "/src/v3/paths.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type PathsObject = IndexMap<String, ReferenceObjectOr<PathsItemObject>>; // TODO: Specification Extensions. // TODO: better implement this object<|fim_prefix|>// repo: morr0ne/oa path: /src/v3/paths.rs
use indexmap::IndexMap;
<|fim_middle|>use super::{PathsItemObject, ReferenceObjectOr};
| code_fim | easy | {
"lang": "rust",
"repo": "morr0ne/oa",
"path": "/src/v3/paths.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trkhanh/web-frameworks path: /rust/actix/src/main.rs
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
<|fim_suffix|>#[actix_rt::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.route("/", web::get().to(|| HttpResponse::Ok()))... | code_fim | medium | {
"lang": "rust",
"repo": "trkhanh/web-frameworks",
"path": "/rust/actix/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", val + 1);
}
}
impl Bindable<i32> for Plus2 {
fn run(&self, val: &i32) {
println!("{}", val + 2);
}
}
impl Bindable<i32> for Plus3 {
fn run(&self, val: &i32) {
println!("{}", val + 3);
}
}
fn main() {
let binded = Plus1().bind(Plus2()).bind(Pl... | code_fim | hard | {
"lang": "rust",
"repo": "Foreverhighness/Design-Pattern-Cpp",
"path": "/Modern/1.SOLID/OCP.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", val + 3);
}
}
fn main() {
let binded = Plus1().bind(Plus2()).bind(Plus3().bind(Plus1()));
binded.run(&1);
}<|fim_prefix|>// repo: Foreverhighness/Design-Pattern-Cpp path: /Modern/1.SOLID/OCP.rs
#![allow(dead_code)]
trait Bindable<T> {
fn run(&self, &T);
}
struct Bi... | code_fim | hard | {
"lang": "rust",
"repo": "Foreverhighness/Design-Pattern-Cpp",
"path": "/Modern/1.SOLID/OCP.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Foreverhighness/Design-Pattern-Cpp path: /Modern/1.SOLID/OCP.rs
#![allow(dead_code)]
trait Bindable<T> {
fn run(&self, &T);
}
struct Binded<'a, T> {
a : Box<dyn Bindable<T> + 'a>,
b : Box<dyn Bindable<T> + 'a>,
}
impl<'a, B: 'a> Binded<'a, B> {
fn new<T, U>(a: T, b: U) -> Self
... | code_fim | hard | {
"lang": "rust",
"repo": "Foreverhighness/Design-Pattern-Cpp",
"path": "/Modern/1.SOLID/OCP.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pablobm/rust-experiments path: /euler/rust/p006/src/main.rs
fn main() {
let target : u64 = 100;
let mut acc;
acc = 0;
for i in 1..target+1 {
acc = acc + i.pow(2);
}
let sum_of_sq = acc;
println!("Sum of squares: {}", sum_of_sq);
<|fim_suffix|> println!("{... | code_fim | medium | {
"lang": "rust",
"repo": "pablobm/rust-experiments",
"path": "/euler/rust/p006/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", sq_of_sum - sum_of_sq);
}<|fim_prefix|>// repo: pablobm/rust-experiments path: /euler/rust/p006/src/main.rs
fn main() {
let target : u64 = 100;
let mut acc;
acc = 0;
for i in 1..target+1 {
acc = acc + i.pow(2);
}
let sum_of_sq = acc;
println!("Sum o... | code_fim | medium | {
"lang": "rust",
"repo": "pablobm/rust-experiments",
"path": "/euler/rust/p006/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (image_fill, rest_fill) = (2, 10);
let watched = cx.service.watched_by_movie(&movie.id);
let mut actions = w::Row::new().spacing(SPACE);
let any_confirm = self.watch.is_confirm()
|| self
.remove_last_watch
.as_ref()
... | code_fim | hard | {
"lang": "rust",
"repo": "udoprog/ontv",
"path": "/src/comps/movie_item.rs",
"mode": "spm",
"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.