text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: frankhart2018/rust-by-example path: /6-conversion/from-and-into-1/src/main.rs
/*
The From trait allows for a type to define how to create itself
from another type, hence providing a very simple mechanism for converting
between several types
There are numerous implementations of... | code_fim | hard | {
"lang": "rust",
"repo": "frankhart2018/rust-by-example",
"path": "/6-conversion/from-and-into-1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Compiling");
let compile_result = kohi.compile(None);
let status = if run_class == "--no-run"{
println!("No class passed, will not run");
compile_result
}else{
compile_result.and_then(move |kohi|{
kohi.run(run_class)
})
};... | code_fim | medium | {
"lang": "rust",
"repo": "Eroc33/kohi",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let compile_result = kohi.compile(None);
let status = if run_class == "--no-run"{
println!("No class passed, will not run");
compile_result
}else{
compile_result.and_then(move |kohi|{
kohi.run(run_class)
})
};
match status{
Err(e... | code_fim | medium | {
"lang": "rust",
"repo": "Eroc33/kohi",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eroc33/kohi path: /src/main.rs
extern crate kohi;
use kohi::Kohi;
fn main() {
let run_class = std::env::args().nth(1).unwrap_or("--no-run".to_owned());
<|fim_suffix|> let compile_result = kohi.compile(None);
let status = if run_class == "--no-run"{
println!("No cla... | code_fim | hard | {
"lang": "rust",
"repo": "Eroc33/kohi",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SimonSapin/lopdf path: /src/creator.rs
use super::{Document, Object, ObjectId};
impl Document {
/// Create an object ID.
pub fn new_object_id(&mut self) -> ObjectId {
self.max_id += 1;
(self.max_id, 0)
}
/// Add PDF object into document's object list.
pub fn add_object<T: Into<Object>... | code_fim | hard | {
"lang": "rust",
"repo": "SimonSapin/lopdf",
"path": "/src/creator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut doc = Document::new();
doc.version = "1.5".to_string();
let info_id = doc.add_object(
Dictionary::from_iter(vec![
("Title", Object::String(b"Create PDF document example".to_vec(), StringFormat::Literal)),
("Creator", Object::String(b"https://crates.io/crates/lopdf".to_vec(), StringForma... | code_fim | hard | {
"lang": "rust",
"repo": "SimonSapin/lopdf",
"path": "/src/creator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::{Dictionary, Stream, StringFormat};
use super::content::*;
use Object::Reference;
use std::iter::FromIterator;
use chrono::prelude::Local;
let mut doc = Document::new();
doc.version = "1.5".to_string();
let info_id = doc.add_object(
Dictionary::from_iter(vec![
("Title", Object::St... | code_fim | hard | {
"lang": "rust",
"repo": "SimonSapin/lopdf",
"path": "/src/creator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilsmartel/pick path: /src/main.rs
use std::io::prelude::*;
use std::io::Read;
fn main() -> std::io::Result<()> {
let args = Opt::from_args();
if args.line_number == 0 {
eprintln!("line number must be > 0");
std::process::exit(1);
}
<|fim_suffix|>#[derive(Debug, Str... | code_fim | hard | {
"lang": "rust",
"repo": "nilsmartel/pick",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "pick", about = "Pick a specific line from stdin or a file")]
struct Opt {
#[structopt()]
line_number: usize,
/// optional input file, defaults to stdin
#[structopt(short = "f",... | code_fim | hard | {
"lang": "rust",
"repo": "nilsmartel/pick",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// just to make sure that panicking really emits "panic_bounds_check" somewhere in the IR
// CHECK-LABEL: @test_check
#[no_mangle]
pub fn test_check(y: &[i32]) -> i32 {
// CHECK: panic_bounds_check
y[12]
}<|fim_prefix|>// repo: unnsa/rust path: /src/test/codegen/slice-position-bounds-check.rs
// ... | code_fim | hard | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/codegen/slice-position-bounds-check.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match arr.iter().position(|x| x == a) {
Some(p) => {
Ok(p)
},
None => Err(()),
}
}
// CHECK-LABEL: @position_no_bounds_check
#[no_mangle]
pub fn position_no_bounds_check(y: &mut [u32], x: &u32, z: &u32) -> bool {
// This contains "call assume" so we cannot ... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/codegen/slice-position-bounds-check.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unnsa/rust path: /src/test/codegen/slice-position-bounds-check.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACH... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/codegen/slice-position-bounds-check.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x: i64 = try!(args[0].decode());
let y: i64 = x / 3 - 2;
Ok((atoms::ok(), y).encode(env))
}<|fim_prefix|>// repo: onno-vos-dev/aoc_2019 path: /rust_nif_src/src/lib.rs
#[macro_use] extern crate rustler;
#[macro_use] extern crate lazy_static;
use rustler::{Env, Term, NifResult, Encoder};
... | code_fim | medium | {
"lang": "rust",
"repo": "onno-vos-dev/aoc_2019",
"path": "/rust_nif_src/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn fuel<'a>(env: Env<'a>, args: &[Term<'a>]) -> NifResult<Term<'a>> {
let x: i64 = try!(args[0].decode());
let y: i64 = x / 3 - 2;
Ok((atoms::ok(), y).encode(env))
}<|fim_prefix|>// repo: onno-vos-dev/aoc_2019 path: /rust_nif_src/src/lib.rs
#[macro_use] extern crate rustler;
#[macro_use] exte... | code_fim | medium | {
"lang": "rust",
"repo": "onno-vos-dev/aoc_2019",
"path": "/rust_nif_src/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: onno-vos-dev/aoc_2019 path: /rust_nif_src/src/lib.rs
#[macro_use] extern crate rustler;
#[macro_use] extern crate lazy_static;
<|fim_suffix|>fn fuel<'a>(env: Env<'a>, args: &[Term<'a>]) -> NifResult<Term<'a>> {
let x: i64 = try!(args[0].decode());
let y: i64 = x / 3 - 2;
Ok((atoms::... | code_fim | hard | {
"lang": "rust",
"repo": "onno-vos-dev/aoc_2019",
"path": "/rust_nif_src/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn access_field() {
let mut x = Name { field: 1 };
assert_eq!(x.field, 1);
assert_eq!((&x).field, 1); // deref coercions
assert_eq!((&&x).field, 1); // deref coercions
assert_eq!((&&&x).field, 1); // deref coercions
x.field += 1;
(&... | code_fim | hard | {
"lang": "rust",
"repo": "redtankd/rust-test",
"path": "/syntax/basic/src/deref_coercions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(x.field, 1);
assert_eq!((&x).field, 1); // deref coercions
assert_eq!((&&x).field, 1); // deref coercions
assert_eq!((&&&x).field, 1); // deref coercions
x.field += 1;
(&mut x).field += 1; // deref coercions
(&mut &mut x).field += 1; // d... | code_fim | hard | {
"lang": "rust",
"repo": "redtankd/rust-test",
"path": "/syntax/basic/src/deref_coercions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redtankd/rust-test path: /syntax/basic/src/deref_coercions.rs
// Rust's deref coercions
#[cfg(test)]
mod test {
struct Name {
field: u32,
}
impl Name {
fn f(&mut self) -> u32 {
<|fim_suffix|> #[test]
fn access_field() {
let mut x = Name { field: 1 };... | code_fim | hard | {
"lang": "rust",
"repo": "redtankd/rust-test",
"path": "/syntax/basic/src/deref_coercions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pventuzelo/fuzzcheck-rs path: /fuzzcheck_serializer/src/lib.rs
// TODO: explain why it is a macro
// TODO: pass the path to serde to macro?
// e.g. define_serde_serializer!(other_crate::serde)
/// Defines a struct called `SerdeSerializer<T>` that implements the
/// `Serializer` trait using serd... | code_fim | hard | {
"lang": "rust",
"repo": "pventuzelo/fuzzcheck-rs",
"path": "/fuzzcheck_serializer/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.ext
}
fn from_data(&self, data: &[u8]) -> Option<Self::Value> {
Some(data.into())
}
fn to_data(&self, value: &Self::Value) -> Vec<u8> {
value.clone()
}
}<|fim_prefix|>// repo: pventuzelo/fuzzcheck-rs path: /fuzzcheck_serializer/src/lib.rs
// TODO: explain ... | code_fim | hard | {
"lang": "rust",
"repo": "pventuzelo/fuzzcheck-rs",
"path": "/fuzzcheck_serializer/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct ByteSerializer {
ext: &'static str,
}
impl ByteSerializer {
pub fn new(ext: &'static str) -> Self {
Self { ext }
}
}
impl fuzzcheck::Serializer for ByteSerializer {
type Value = Vec<u8>;
fn extension(&self) -> &str {
self.ext
}
fn from_data(&self, d... | code_fim | medium | {
"lang": "rust",
"repo": "pventuzelo/fuzzcheck-rs",
"path": "/fuzzcheck_serializer/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use error::MsgProcessingError;
pub use object_ident::ObjectIdent;
pub use pdu_error_status::PduErrorStatus;
pub use pdu_type::PduType;
pub use scoped_pdu::ScopedPdu;
pub use scoped_pdu_data::ScopedPduData;
pub use snmp_msg::SnmpMsg;
pub use var_bind::{VarBind, VarValue};
/// Type alias for the result... | code_fim | hard | {
"lang": "rust",
"repo": "davedufresne/modern_snmp",
"path": "/src/snmp_mp/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davedufresne/modern_snmp path: /src/snmp_mp/src/lib.rs
#![doc(html_root_url = "https://docs.rs/snmp_mp/0.1.0")]
//! # Primitives to send and receive SNMP messages.
//!
//! Supported PDU types:
//!
//! * GetRequest
//! * GetNextRequest
//! * GetBulkRequest
//! * Response
//! * SetRequest
//! * S... | code_fim | hard | {
"lang": "rust",
"repo": "davedufresne/modern_snmp",
"path": "/src/snmp_mp/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Smithay/smithay path: /src/utils/ids.rs
macro_rules! id_gen {
($func_name:ident, $id_name:ident, $ids_name:ident) => {
static $id_name: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
lazy_static::lazy_static! {
static ref $ids_name: std::... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/utils/ids.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let id = loop {
let new_id = $id_name.fetch_update(
std::sync::atomic::Ordering::SeqCst,
std::sync::atomic::Ordering::SeqCst,
|mut id| {
while ids.iter().any(|k| *k == id) {
... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/utils/ids.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>&[u8]) -> Result<usize, PartialResult>;
}<|fim_prefix|>// repo: rozaliev/netbuf path: /src/writer.rs
use std::io;
pub struct PartialResult(p<|fim_middle|>ub usize, pub io::IoError);
pub trait NetWriter {
fn write(&mut self, buf: | code_fim | medium | {
"lang": "rust",
"repo": "rozaliev/netbuf",
"path": "/src/writer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rozaliev/netbuf path: /src/writer.rs
use std::io;
pub struct PartialResult(p<|fim_suffix|>&[u8]) -> Result<usize, PartialResult>;
}<|fim_middle|>ub usize, pub io::IoError);
pub trait NetWriter {
fn write(&mut self, buf: | code_fim | medium | {
"lang": "rust",
"repo": "rozaliev/netbuf",
"path": "/src/writer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gen0083/atcoder_python path: /rust/arc164/src/bin/a.rs
use proconio::input;
fn main() {
input! {
t: i32,
}
let mut three = vec![1_i128; 38];
for i in 1..38 {
three[i] = three[i - 1] * 3;
}
for _ in 0..t {
input! { n: i128, k: i128,}
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "gen0083/atcoder_python",
"path": "/rust/arc164/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if target <= i {
println!("No");
break;
}
for &th in three.iter().rev() {
if th > target {
continue;
}
target -= th;
i -= 1;
break;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "gen0083/atcoder_python",
"path": "/rust/arc164/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
target -= th;
i -= 1;
break;
}
if i < 0 {
println!("No");
break;
}
}
}
}<|fim_prefix|>// repo: gen0083/atcoder_python path: /rust/arc164/src/bin/a.rs
use proconio::input;
... | code_fim | hard | {
"lang": "rust",
"repo": "gen0083/atcoder_python",
"path": "/rust/arc164/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn multiply(self, other: Color) -> Color {
Color {
r: dmul255(self.r, other.r),
g: dmul255(self.g, other.g),
b: dmul255(self.b, other.b),
a: dmul255(self.a, other.a),
}
}
}
fn dmul255(a: u8, b: u8) -> u8 { (((a as f32 / 255.0) * (b a... | code_fim | hard | {
"lang": "rust",
"repo": "2xsaiko/assetc",
"path": "/layergen/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2xsaiko/assetc path: /layergen/src/main.rs
use std::collections::HashMap;
use std::fs::File;
use std::path::{Path, PathBuf};
use clap::{app_from_crate, Arg};
use image::{ImageBuffer, RgbaImage, Rgba, ImageFormat};
use serde::{Deserialize, Deserializer};
use serde::de::Error;
fn main() {
le... | code_fim | hard | {
"lang": "rust",
"repo": "2xsaiko/assetc",
"path": "/layergen/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dvberkel/TIS-100.superoptimizer path: /src/optimizer.rs
//! Will find the shortest program to problem
use super::TIS_100::{Node,Program};
use super::iterator::{ProgramIterator};
use super::check::check;
/// Configuration for the optimize function
pub struct Config {
/// The maximum allowed... | code_fim | hard | {
"lang": "rust",
"repo": "dvberkel/TIS-100.superoptimizer",
"path": "/src/optimizer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match optimize(node, expected_output, config) {
Some(program) => assert_eq!(Program(vec![
Instruction::MOV(Source::Literal(0), Destination::Port),
Instruction::ADD(Source::Port),
]), program),
_ => assert!(false)
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "dvberkel/TIS-100.superoptimizer",
"path": "/src/optimizer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut next: i32;
let mut curr = 1;
let mut last = 0;
loop {
if curr > limit {
break;
}
print!("{} ", curr);
next = curr + last;
last = curr;
curr = next;
}
println!();
}<|fim_prefix|>// repo: AbhinavRobinson/rust-learnin... | code_fim | medium | {
"lang": "rust",
"repo": "AbhinavRobinson/rust-learning",
"path": "/beginner 1-17/8.Fibonacci/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AbhinavRobinson/rust-learning path: /beginner 1-17/8.Fibonacci/src/main.rs
use std::io;
fn main() {
println!("Enter number to find fibonaaci to it:");
<|fim_suffix|> let mut next: i32;
let mut curr = 1;
let mut last = 0;
loop {
if curr > limit {
break;
... | code_fim | medium | {
"lang": "rust",
"repo": "AbhinavRobinson/rust-learning",
"path": "/beginner 1-17/8.Fibonacci/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: starcoinorg/starcoin path: /cmd/starcoin/src/dev/subscribe_cmd.rs
use crate::cli_state::CliState;
use crate::StarcoinOpt;
use anyhow::Result;
use clap::Parser;
use futures::{TryStream, TryStreamExt};
use scmd::{CommandAction, ExecContext};
use starcoin_rpc_api::types::pubsub::EventFilter;
use st... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/cmd/starcoin/src/dev/subscribe_cmd.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The column's value to show for the split and column with the specified
/// index. The columns are specified from right to left. You may not provide an
/// out of bounds index.
#[no_mangle]
pub extern "C" fn SplitsComponentState_column_value(
this: &SplitsComponentState,
index: usize,
colum... | code_fim | hard | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/capi/src/splits_component_state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LiveSplit/livesplit-core path: /capi/src/splits_component_state.rs
//! The state object that describes a single segment's information to visualize.
use super::{output_str, output_vec};
use livesplit_core::component::splits::State as SplitsComponentState;
use std::io::Write;
use std::os::raw::c_... | code_fim | hard | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/capi/src/splits_component_state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The semantic coloring information the column's value carries of the segment
/// and column with the specified index. The columns are specified from right to
/// left. You may not provide an out of bounds index.
#[no_mangle]
pub extern "C" fn SplitsComponentState_column_semantic_color(
this: &Split... | code_fim | hard | {
"lang": "rust",
"repo": "LiveSplit/livesplit-core",
"path": "/capi/src/splits_component_state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut click_events = button.on_click();
spawn_local(async move {
while let Some(_) = click_events.next().await {
console::log!("Click!");
}
console::log!("Event stream cleaned up")
});
let remove_event_target_button = document
.query_selecto... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/examples/events/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut remove_clicks = remove_event_target_button.on_click();
spawn_local(async move {
remove_clicks.next().await;
button.disconnect();
});
Ok(())
}<|fim_prefix|>// repo: RSSchermer/ARWA path: /examples/events/src/main.rs
#![feature(async_closure)]
use arwa::dom::{sel... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/examples/events/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RSSchermer/ARWA path: /examples/events/src/main.rs
#![feature(async_closure)]
use arwa::dom::{selector, ChildNode, ParentNode};
use arwa::ui::UiEventTarget;
use arwa::window::window;
use arwa::{console, spawn_local};
use futures::StreamExt;
use wasm_bindgen::{JsError, JsValue};
fn main() -> Re... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/examples/events/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eijebong/async-tftp-rs path: /src/tests/rrq.rs
#![cfg(feature = "external-client-tests")]
use futures::channel::oneshot;
use smol::Task;
use super::external_client::*;
use super::handlers::*;
use crate::server::TftpServerBuilder;
fn transfer(file_size: usize, block_size: Option<u16>) {
<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "Eijebong/async-tftp-rs",
"path": "/src/tests/rrq.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn transfer_more_than_block() {
transfer(512 + 1, None);
transfer(512 + 123, None);
transfer(512 + 511, None);
transfer(1024 + 1, Some(1024));
transfer(1024 + 123, Some(1024));
transfer(1024 + 1023, Some(1024));
}
#[test]
fn transfer_1mb() {
transfer(1024 * 1024, None)... | code_fim | hard | {
"lang": "rust",
"repo": "Eijebong/async-tftp-rs",
"path": "/src/tests/rrq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn transfer_less_than_block() {
transfer(1, None);
transfer(123, None);
transfer(511, None);
transfer(1023, Some(1024));
}
#[test]
fn transfer_block() {
transfer(512, None);
transfer(1024, Some(1024));
}
#[test]
fn transfer_more_than_block() {
transfer(512 + 1, None);... | code_fim | hard | {
"lang": "rust",
"repo": "Eijebong/async-tftp-rs",
"path": "/src/tests/rrq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // bellman ford
let inf = i64::pow(10, 18);
let mut dist = vec![inf; graph.len()];
dist[from_v] = 0;
let mut updated = true;
for _ in 0..graph.len() {
updated = false;
for v in &vertices {
for &(u, d) in &graph[*v] {
if dist[*v] + d < dis... | code_fim | hard | {
"lang": "rust",
"repo": "nohtaray/competitive-programming.rs",
"path": "/graph.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nohtaray/competitive-programming.rs path: /graph.rs
/// Bellman Ford
/// 関係ない負閉路を無視する版。
#[allow(dead_code)]
fn bellman_ford(graph: &[Vec<(usize, i64)>], from_v: usize, to_v: usize) -> Option<i64> {
/// graph 上で from_v から到達できるかどうかのベクタ
fn reachable(graph: &[Vec<(usize, i64)>], from_v: usiz... | code_fim | hard | {
"lang": "rust",
"repo": "nohtaray/competitive-programming.rs",
"path": "/graph.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // from_v から到達でき、かつ to_v へ到達できる頂点のみ考える
// これら以外には負閉路があっても関係ない
let mut vertices: Vec<usize> = vec![];
let mut rev: Vec<Vec<(usize, i64)>> = vec![vec![]; graph.len()];
for (v, edges) in graph.iter().enumerate() {
for &(u, d) in edges {
rev[u].push((v, d));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "nohtaray/competitive-programming.rs",
"path": "/graph.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ove {
let addr = "127.0.0.1:8080".to_string();
TcpStream::connect(addr).await
});
thread::sleep(time::Duration::from_secs(1));
}
}<|fim_prefix|>// repo: JayHelton/learning_playground path: /rust/cpu_test/src/bin/load.rs
use std::thread;
use std::time;
use tokio... | code_fim | medium | {
"lang": "rust",
"repo": "JayHelton/learning_playground",
"path": "/rust/cpu_test/src/bin/load.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JayHelton/learning_playground path: /rust/cpu_test/src/bin/load.rs
use std::thread;
use std::time;
use tokio::net::TcpStream;
#[tokio::main]
async fn ma<|fim_suffix|>ove {
let addr = "127.0.0.1:8080".to_string();
TcpStream::connect(addr).await
});
thread:... | code_fim | medium | {
"lang": "rust",
"repo": "JayHelton/learning_playground",
"path": "/rust/cpu_test/src/bin/load.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sts10/advent-of-code-2018 path: /src/bin/day05.rs
use std::fs::File;
use std::io;
use std::io::prelude::*;
fn main() {
let test_polymer: String = "dabAcCaCBAcCcaDA".to_string();
let mut p_vec: Vec<char> = vec![];
for c in test_polymer.chars() {
p_vec.push(c);
}
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "sts10/advent-of-code-2018",
"path": "/src/bin/day05.rs",
"mode": "psm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cash: f32 = 100.0;
for prices in price_pairs{
println!("Start Cash {} Buy:{} Sell:{}", cash, prices.0, prices.1);
cash = cash * (prices.1/prices.0);
println!("End Cash {}", cash)
}
}<|fim_prefix|>// repo: antsol20/rust_btc path: /src/main.rs
use chrono::{Na... | code_fim | hard | {
"lang": "rust",
"repo": "antsol20/rust_btc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let datestamp = &entry["timestamp"].as_str().unwrap()[..10];
let week_day = NaiveDate::parse_from_str(datestamp, date_fmt).unwrap().weekday();
let btc = entry["rate"].as_str().unwrap().parse::<f32>().unwrap();
if week_day == Weekday::Fri{
price_pair.0 = btc;
... | code_fim | hard | {
"lang": "rust",
"repo": "antsol20/rust_btc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antsol20/rust_btc path: /src/main.rs
use chrono::{NaiveDate, Datelike, Weekday};
use reqwest;
use serde_json;
use serde_json::Value;
use std::io::Read;
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() != 3{
println!("Usage: rust_btc [start-date] [end... | code_fim | hard | {
"lang": "rust",
"repo": "antsol20/rust_btc",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(target_arch = "wasm32")]
Error::RequestError => write!(f, "Http request failed"),
}
}
}
impl StdError for Error {
fn description(&self) -> &str {
match *self {
Error::RefOverflow => "Refcnt overflow",
Error::RefUnderflow => "Re... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/zbox",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Error::NoContent => -1040,
Error::InvalidArgument => -1050,
Error::InvalidPath => -1051,
Error::NotFound => -1052,
Error::AlreadyExists => -1053,
Error::IsRoot => -1054,
Error::IsDir => -1055,
Error::IsFile =>... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/zbox",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/zbox path: /src/error.rs
, Display, Formatter};
use std::io::Error as IoError;
use std::result;
use rmp_serde::decode::Error as DecodeError;
use rmp_serde::encode::Error as EncodeError;
#[cfg(feature = "storage-sqlite")]
use libsqlite3_sys::Error as SqliteError;
#[cfg(feature = "stora... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/zbox",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rezural/building-blocks path: /crates/building_blocks_storage/src/chunk_tree/lod_view.rs
use crate::{
array::ArrayCopySrc,
dev_prelude::{
AmbientExtent, ChunkKey, ChunkStorage, ChunkTree, ChunkTreeBuilder, FillExtent, ForEach,
ForEachMut, ForEachMutPtr, Get, GetMut, GetMu... | code_fim | hard | {
"lang": "rust",
"repo": "rezural/building-blocks",
"path": "/crates/building_blocks_storage/src/chunk_tree/lod_view.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// ██████╗ ██████╗ ██████╗ ██╗ ██╗
// ██╔════╝██╔═══██╗██╔══██╗╚██╗ ██╔╝
// ██║ ██║ ██║██████╔╝ ╚████╔╝
// ██║ ██║ ██║██╔═══╝ ╚██╔╝
// ╚██████╗╚██████╔╝██║ ██║
// ╚═════╝ ╚═════╝ ╚═╝ ╚═╝
impl<'a, Delegate, N, T: 'a, Usr: 'a, Bldr: 'a, Store: 'a> ReadExtent<'a, N>
for C... | code_fim | hard | {
"lang": "rust",
"repo": "rezural/building-blocks",
"path": "/crates/building_blocks_storage/src/chunk_tree/lod_view.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> chunk_iters.into_iter()
}
}
// If `Array` supports writing from type Src, then so does ChunkTree.
impl<Delegate, N, T, Usr, Bldr, Store, Src> WriteExtent<N, Src> for ChunkTreeLodView<Delegate>
where
Delegate: DerefMut<Target = ChunkTree<N, T, Bldr, Store>>,
PointN<N>: IntegerPoint<N>,... | code_fim | hard | {
"lang": "rust",
"repo": "rezural/building-blocks",
"path": "/crates/building_blocks_storage/src/chunk_tree/lod_view.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = get_file_contents("data/day06.txt")?;
let iter = input.lines().chunks(|line: &&str| !line.trim().is_empty());
// For part 1:
// For each group, we can do a flat map of the lines to get the chars.
// Flatmap will inline all the char iterators together so when we collect the... | code_fim | medium | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2020",
"path": "/src/bin/day06.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // For part 2:
// The subtotal for each group is the number of characters where the count matches the
// number of lines.
// As we iterate over the lines, track the line count, and also add the characters of each line
// into a hashmap, incrementing a count each time.
// After that... | code_fim | hard | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2020",
"path": "/src/bin/day06.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForgottenMaster/aoc-2020 path: /src/bin/day06.rs
use {
aoc::{
io::file::get_file_contents,
iter::chunks::ProvideChunks, // extends the iterator with the chunks method
},
std::{
collections::{HashMap, HashSet},
io::Result,
},
};
fn main() -> Result... | code_fim | medium | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2020",
"path": "/src/bin/day06.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T, D> Convolution<T, D>
where
T: CrateFloat,
D: Dimension,
{
}<|fim_prefix|>// repo: Surpris/rs-deep path: /src/dlfs01/common/layers/convolution.rs
//! convolution
//!
//! Convolution layer
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::super::util::C... | code_fim | hard | {
"lang": "rust",
"repo": "Surpris/rs-deep",
"path": "/src/dlfs01/common/layers/convolution.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Surpris/rs-deep path: /src/dlfs01/common/layers/convolution.rs
//! convolution
//!
//! Convolution layer
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
<|fim_suffix|>impl<T, D> Convolution<T, D>
where
T: CrateFloat,
D: Dimension,
{
}<|fim_middle|>use super::... | code_fim | hard | {
"lang": "rust",
"repo": "Surpris/rs-deep",
"path": "/src/dlfs01/common/layers/convolution.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) async fn outgoing<'a>(
mode: TLSRewriterMode,
compressor: &mut (dyn Compressor + Send + 'static),
_ss: &TLSConnectionSharedState,
cp: CryptoParameters,
mut hdr: tls::RecordHeader,
mut body: tls_record_parser::ParseRecordBody<'a, ()>,
) -> Result<()> {
loop {
... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/balboa",
"path": "/balboa/rewriter/src/tls_rewriter/mangling.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GaloisInc/balboa path: /balboa/rewriter/src/tls_rewriter/mangling.rs
use super::{
utils::{DefaultInputMacVerifier, PassthruOutputTagMangler},
Result,
};
use crate::{
tls,
tls_rewriter::{
rocky_crypto::CryptoParameters,
shared_state::TLSConnectionSharedState,
... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/balboa",
"path": "/balboa/rewriter/src/tls_rewriter/mangling.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vkulichenko/database path: /src/sql_engine/src/dml/select.rs
// Copyright 2020 Alex Dukhno
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apa... | code_fim | hard | {
"lang": "rust",
"repo": "vkulichenko/database",
"path": "/src/sql_engine/src/dml/select.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'sc, P: BackendStorage> SelectCommand<'sc, P> {
pub(crate) fn new(
raw_sql_query: &'sc str,
query: Box<Query>,
storage: Arc<Mutex<FrontendStorage<P>>>,
session: Arc<dyn Sender>,
) -> SelectCommand<'sc, P> {
SelectCommand {
raw_sql_query,
... | code_fim | hard | {
"lang": "rust",
"repo": "vkulichenko/database",
"path": "/src/sql_engine/src/dml/select.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/security/lib/scrutiny/plugins/src/core/controller/package_extract.rs
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::core::collection:... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/lib/scrutiny/plugins/src/core/controller/package_extract.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn url_matches_pkg_name(&self, pkg: &Package) -> bool {
self.url.name() == &pkg.name
}
fn url_matches_pkg_variant(&self, pkg: &Package) -> bool {
self.url.variant() == pkg.variant.as_ref()
}
fn url_matches_package_hash(&self, pkg: &Package) -> bool {
self.url.... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/lib/scrutiny/plugins/src/core/controller/package_extract.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::main]
async fn main() {
get_locations().await;
}<|fim_prefix|>// repo: dshomoye/rick-and-morty path: /examples/locations.rs
extern crate rick_and_morty as rm;
<|fim_middle|>// example of getting all locations
async fn get_locations() -> () {
let c = rm::location::get_all().await;
ma... | code_fim | hard | {
"lang": "rust",
"repo": "dshomoye/rick-and-morty",
"path": "/examples/locations.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dshomoye/rick-and-morty path: /examples/locations.rs
extern crate rick_and_morty as rm;
<|fim_suffix|>#[tokio::main]
async fn main() {
get_locations().await;
}<|fim_middle|>// example of getting all locations
async fn get_locations() -> () {
let c = rm::location::get_all().await;
ma... | code_fim | hard | {
"lang": "rust",
"repo": "dshomoye/rick-and-morty",
"path": "/examples/locations.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rschmitt/heatseeker path: /src/args.rs
use std::env;
pub struct Args {
pub initial_search: String,
pub help: bool,
pub use_first: bool,
pub version: bool,
pub full_screen: bool,
pub filter_only: bool,
}
<|fim_suffix|> let initial_search = match matches.opt_str("searc... | code_fim | hard | {
"lang": "rust",
"repo": "rschmitt/heatseeker",
"path": "/src/args.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let help = matches.opt_present("help");
if help {
print_usage(&args[0], &opts);
}
let version = matches.opt_present("version");
let full_screen = matches.opt_present("full-screen");
Some(Args {
initial_search,
help,
use_first: matches.opt_present("... | code_fim | hard | {
"lang": "rust",
"repo": "rschmitt/heatseeker",
"path": "/src/args.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wtfleming/rust-ray-tracer path: /ray_tracer_lib/src/mathf/shapes.rs
use crate::material::Material;
use crate::mathf::intersection::Intersection;
use crate::mathf::matrix::Matrix;
use crate::mathf::ray::Ray;
use crate::mathf::vector3::Vector3;
use std::fmt;
use std::sync::Arc;
pub trait Shape: f... | code_fim | hard | {
"lang": "rust",
"repo": "wtfleming/rust-ray-tracer",
"path": "/ray_tracer_lib/src/mathf/shapes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> static mut SAVED_RAY: Ray = Ray {
origin: crate::mathf::vector3::ORIGIN,
direction: crate::mathf::vector3::VECTOR_Y_UP,
};
#[derive(Debug)]
pub struct TestShape {
material: Material,
transform: Matrix,
inverse_transform: Matrix,
}
impl Shap... | code_fim | hard | {
"lang": "rust",
"repo": "wtfleming/rust-ray-tracer",
"path": "/ray_tracer_lib/src/mathf/shapes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gaku-sei/zagreus-identity-provider path: /zagreus/src/api/mod.rs
/// The private endpoints (plus an explicit refe<|fim_suffix|>n;
pub mod login;
pub mod logout;
pub mod public;<|fim_middle|>rence to the public endpoint).
/// Used only inside the webapp.
pub mod consent;
pub mod invitatio | code_fim | medium | {
"lang": "rust",
"repo": "gaku-sei/zagreus-identity-provider",
"path": "/zagreus/src/api/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>n;
pub mod login;
pub mod logout;
pub mod public;<|fim_prefix|>// repo: gaku-sei/zagreus-identity-provider path: /zagreus/src/api/mod.rs
/// The private endpoints (plus an explicit reference to the public endpoint).
/// Used only insi<|fim_middle|>de the webapp.
pub mod consent;
pub mod invitatio | code_fim | easy | {
"lang": "rust",
"repo": "gaku-sei/zagreus-identity-provider",
"path": "/zagreus/src/api/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct ActorSet {
laser_actor: Addr<LaserActor>
}
fn main() -> Result<(), Error> {
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
env_logger::init();
println!("Hello Pointy!");
// start actors
let sys = System::new("pointy");
// start... | code_fim | medium | {
"lang": "rust",
"repo": "Voxelot/pointy",
"path": "/server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Voxelot/pointy path: /server/src/main.rs
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
<|fim_suffix|> std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
env_logger::init();
println!("Hello Pointy!");
// start actors
let ... | code_fim | hard | {
"lang": "rust",
"repo": "Voxelot/pointy",
"path": "/server/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // start actors
let sys = System::new("pointy");
// start workers
let actor_set: ActorSet = ActorSet {
laser_actor: LaserActor::default().start()
};
// init webservice
ws::start(actor_set).unwrap();
sys.run()
}<|fim_prefix|>// repo: Voxelot/pointy path: /server/src... | code_fim | medium | {
"lang": "rust",
"repo": "Voxelot/pointy",
"path": "/server/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/flate2-rs path: /src/lib.rs
//! A DEFLATE-based stream compression/decompression library
//!
//! This library provides support for compression and decompression of
//! DEFLATE-based streams:
//!
//! * the DEFLATE format itself
//! * the zlib format
//! * gzip
//!
//! These three format... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/flate2-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> _assert_send_sync::<read::DeflateEncoder<&[u8]>>();
_assert_send_sync::<read::DeflateDecoder<&[u8]>>();
_assert_send_sync::<read::ZlibEncoder<&[u8]>>();
_assert_send_sync::<read::ZlibDecoder<&[u8]>>();
_assert_send_sync::<read::GzEncoder<&[u8]>>();
_assert_send_sync::<read::GzDecod... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/flate2-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>onse::Value::BeginBlock(app.begin_block(req)),
Value::CheckTx(req) => response::Value::CheckTx(app.check_tx(req)),
Value::DeliverTx(req) => response::Value::DeliverTx(app.deliver_tx(req)),
Value::EndBlock(req) => response::Value::EndBlock(app.end_block(req)),
... | code_fim | hard | {
"lang": "rust",
"repo": "tiannian/tendermint-sys",
"path": "/tendermint-sys/src/abci/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>apshotChunk(req) => {
response::Value::ApplySnapshotChunk(app.apply_snapshot_chunk(req).await)
}
}),
}
}
#[cfg(feature = "sync")]
pub fn sync_dispatch<A>(app: &mut A, request: Request) -> Response
where
A: SyncApplication + ?Sized,
{
use request::Value;
... | code_fim | hard | {
"lang": "rust",
"repo": "tiannian/tendermint-sys",
"path": "/tendermint-sys/src/abci/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tiannian/tendermint-sys path: /tendermint-sys/src/abci/mod.rs
use tm_protos::abci::{request, response, Request, Response};
#[cfg(feature = "async")]
use tm_abci::Application;
#[cfg(feature = "sync")]
use tm_abci::SyncApplication;
#[cfg(feature = "async")]
pub async fn dispatch<A>(app: &mut A,... | code_fim | hard | {
"lang": "rust",
"repo": "tiannian/tendermint-sys",
"path": "/tendermint-sys/src/abci/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForPrakWS19-20/forprak_rust_ws_19-20 path: /src/main.rs
use std::fs::File;
use std::io::Write;
use Foprak::{Student, BFA, Point, RTree, MBRect};
fn main() {
let mut rtree = RTree::new(4,"test_insert",1000,3);
let point1 = Point::new(vec![1.0,1.0,1.0]);
rtree.insert(point1.clone(... | code_fim | hard | {
"lang": "rust",
"repo": "ForPrakWS19-20/forprak_rust_ws_19-20",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nr_2 = bfa_1.reserve();
bfa_1.update(nr_2,Student::vec_to_block(student_2.serialize()));
let student_3 = Student::deserialize( & bfa_1.get(nr_1).contents);
println!("{:?}", student_3);*/
let s1 = Student::new("ling", "feng", 2719983);
let s2 = Student::new("yanping", "long... | code_fim | hard | {
"lang": "rust",
"repo": "ForPrakWS19-20/forprak_rust_ws_19-20",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nr_1 = bfa_1.reserve();
bfa_1.update(nr_1,Student::vec_to_block(student_1.serialize()));
let nr_2 = bfa_1.reserve();
bfa_1.update(nr_2,Student::vec_to_block(student_2.serialize()));
let student_3 = Student::deserialize( & bfa_1.get(nr_1).contents);
println!("{:?}", stud... | code_fim | hard | {
"lang": "rust",
"repo": "ForPrakWS19-20/forprak_rust_ws_19-20",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shwnchpl/redditDailyProgrammer path: /Challenge249/Intermediate/GeneticHello.rs
// Compiled in rustc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02)
// Solution to the problem posted here: https://www.reddit.com/r/dailyprogrammer/comments/40rs67/20160113_challenge_249_intermediate_hello_wo... | code_fim | hard | {
"lang": "rust",
"repo": "shwnchpl/redditDailyProgrammer",
"path": "/Challenge249/Intermediate/GeneticHello.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Enter a string: ");
let mut fit_string = "".to_string();
let mut stdin = io::stdin();
let _ = stdin.read_line(&mut fit_string);
fit_string.pop();
let mut test_vec: Vec<char> = Genetics::generate_random(fit_string.len());
let fit_vec: Vec<char> = fit_string.chars().... | code_fim | hard | {
"lang": "rust",
"repo": "shwnchpl/redditDailyProgrammer",
"path": "/Challenge249/Intermediate/GeneticHello.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for mesh in &scene.meshes {
let material = &scene.materials[mesh.material_i];
let uniforms = uniform! {
world_to_clip: camera.world_to_clip().into_array(),
u_light: [-1.0, 0.4, 0.9f32],
u_is_emissive: material.is_emissive,
... | code_fim | hard | {
"lang": "rust",
"repo": "ItsHoff/Rusty",
"path": "/src/gl_renderer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ItsHoff/Rusty path: /src/gl_renderer.rs
use glium::backend::Facade;
use glium::{uniform, DrawParameters, Surface};
use crate::camera::Camera;
use crate::float::IntoArray;
use crate::scene::GPUScene;
pub struct GLRenderer {
shader: glium::Program,
}
impl GLRenderer {
pub fn new<F: Faca... | code_fim | hard | {
"lang": "rust",
"repo": "ItsHoff/Rusty",
"path": "/src/gl_renderer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tracing_subscriber::fmt::init();
start_app(db_url.as_str()).await
}<|fim_prefix|>// repo: wolf4ood/agenda-rs path: /src/application/src/main.rs
use agenda_web::start_app;
use dotenv::dotenv;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenv().ok();
let db_url = <|fim_middle|... | code_fim | medium | {
"lang": "rust",
"repo": "wolf4ood/agenda-rs",
"path": "/src/application/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>std::env::var("DATABASE_URL").expect("env DATABASE_URL not found");
tracing_subscriber::fmt::init();
start_app(db_url.as_str()).await
}<|fim_prefix|>// repo: wolf4ood/agenda-rs path: /src/application/src/main.rs
use agenda_web::start_app;
use dotenv::dotenv;
#[actix_web::main]
async<|fim_middle|... | code_fim | medium | {
"lang": "rust",
"repo": "wolf4ood/agenda-rs",
"path": "/src/application/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wolf4ood/agenda-rs path: /src/application/src/main.rs
use agenda_web::start_app;
use dotenv::dotenv;
#[actix_web::main]
async<|fim_suffix|>tracing_subscriber::fmt::init();
start_app(db_url.as_str()).await
}<|fim_middle|> fn main() -> std::io::Result<()> {
dotenv().ok();
let db_url =... | code_fim | medium | {
"lang": "rust",
"repo": "wolf4ood/agenda-rs",
"path": "/src/application/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_transforms_base/src/tests.rs
use swc_common::{
comments::SingleThreadedComments,
errors::{Handler, HANDLER},
sync::Lrc,
FileName, SourceMap,
};
use swc_ecma_ast::{Pat, *};
use swc_ecma_codegen::Emitter;
use swc_ecma_parser::{error::Error, le... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_transforms_base/src/tests.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let PatOrExpr::Pat(pat) = n {
if let Pat::Expr(expr) = *pat {
return PatOrExpr::Expr(expr);
}
n = PatOrExpr::Pat(pat);
}
n
}
}
pub(crate) fn test_transform<F, P>(
syntax: Syntax,
tr: F,
input: &str,
expect... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_transforms_base/src/tests.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.