text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>Manager;
pub use self::texture_manager::TextureManager;<|fim_prefix|>// repo: mateuszgiza/rust-sdl2-extras path: /src/managers/mod.rs
mod resource_manager;
mod font_manager;
mod texture_ma<|fim_middle|>nager;
pub use self::resource_manager::{ ResourceLoader, ResourceManager };
pub use self::font_manager... | code_fim | medium | {
"lang": "rust",
"repo": "mateuszgiza/rust-sdl2-extras",
"path": "/src/managers/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mateuszgiza/rust-sdl2-extras path: /src/managers/mod.rs
mod resource_manager;
mod font_manager;
mod texture_ma<|fim_suffix|>Manager;
pub use self::texture_manager::TextureManager;<|fim_middle|>nager;
pub use self::resource_manager::{ ResourceLoader, ResourceManager };
pub use self::font_manager... | code_fim | medium | {
"lang": "rust",
"repo": "mateuszgiza/rust-sdl2-extras",
"path": "/src/managers/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r, ResourceManager };
pub use self::font_manager::FontManager;
pub use self::texture_manager::TextureManager;<|fim_prefix|>// repo: mateuszgiza/rust-sdl2-extras path: /src/managers/mod.rs
mod resource_manager;
mod font_manager;
mod texture_ma<|fim_middle|>nager;
pub use self::resource_manager::{ Resourc... | code_fim | easy | {
"lang": "rust",
"repo": "mateuszgiza/rust-sdl2-extras",
"path": "/src/managers/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samuwen/rusty_axe65 path: /src/configuration.rs
use crate::common::*;
use crate::lexer::lex;
use crate::token::{Token, TokenType};
use std::fs::write;
pub fn generate_config_data(config_file: &String) -> Configuration {
let mut tokens = lex(config_file, false);
let to_file = tokens.clone();... | code_fim | hard | {
"lang": "rust",
"repo": "samuwen/rusty_axe65",
"path": "/src/configuration.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SegmentEntryBuilder {
fn load(mut self, load: &String) -> SegmentEntryBuilder {
self.load = Some(load.to_owned());
self
}
fn seg_type(mut self, seg_type: SegType) -> SegmentEntryBuilder {
self.seg_type = Some(seg_type);
self
}
fn define(mut self, define: bool) -> SegmentEn... | code_fim | hard | {
"lang": "rust",
"repo": "samuwen/rusty_axe65",
"path": "/src/configuration.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn identifier<'a>(source: &'a str) -> IResult<&'a str, &'a str, VerboseError<&'a str>> {
take_while1(|c: char| c.is_alphanumeric() || c == '.' || c == '_')(source)
}<|fim_prefix|>// repo: LaplaceKorea/vicis path: /src/ir/module/name/parser.rs
use super::Name;
use crate::ir::util::{spaces, string_... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/vicis",
"path": "/src/ir/module/name/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LaplaceKorea/vicis path: /src/ir/module/name/parser.rs
use super::Name;
use crate::ir::util::{spaces, string_literal};
use nom::{
branch::alt, bytes::complete::take_while1, character::complete::digit1, combinator::map,
error::VerboseError, sequence::preceded, IResult,
};
<|fim_suffix|>p... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/vicis",
"path": "/src/ir/module/name/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Handler;
pub use self::path_handler::PathHandler;
pub use self::query_string_handler::QueryStringHandler;<|fim_prefix|>// repo: benbrunton/pusoy_dos_server path: /project/src/handlers/mod.rs
mod generic_handler;
mod path_handler;
mod query_str<|fim_middle|>ing_handler;
pub use self::generic_handler::Gen... | code_fim | easy | {
"lang": "rust",
"repo": "benbrunton/pusoy_dos_server",
"path": "/project/src/handlers/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benbrunton/pusoy_dos_server path: /project/src/handlers/mod.rs
mod generic_handler;
mod path_handler;
mod query_str<|fim_suffix|>Handler;
pub use self::path_handler::PathHandler;
pub use self::query_string_handler::QueryStringHandler;<|fim_middle|>ing_handler;
pub use self::generic_handler::Gen... | code_fim | easy | {
"lang": "rust",
"repo": "benbrunton/pusoy_dos_server",
"path": "/project/src/handlers/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>b use self::query_string_handler::QueryStringHandler;<|fim_prefix|>// repo: benbrunton/pusoy_dos_server path: /project/src/handlers/mod.rs
mod generic_handler;
mod path_handler;
mod query_str<|fim_middle|>ing_handler;
pub use self::generic_handler::GenericHandler;
pub use self::path_handler::PathHandler... | code_fim | medium | {
"lang": "rust",
"repo": "benbrunton/pusoy_dos_server",
"path": "/project/src/handlers/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
kind: Kind::Request,
id: 0,
route: String::new(),
data: vec![],
compressed: false,
err: false,
}
}
}<|fim_prefix|>// repo: tfgco/pitaya-rs path: /src/pitaya_core/src/message.rs
// A MessageKind can be eithe... | code_fim | medium | {
"lang": "rust",
"repo": "tfgco/pitaya-rs",
"path": "/src/pitaya_core/src/message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tfgco/pitaya-rs path: /src/pitaya_core/src/message.rs
// A MessageKind can be either a Request that receives a response
// or a Notify, in which the server calls an RPC without expecting response.
#[derive(Debug, PartialEq)]
pub enum Kind {
Request = 0,
Notify = 1,
}
<|fim_suffix|>impl ... | code_fim | hard | {
"lang": "rust",
"repo": "tfgco/pitaya-rs",
"path": "/src/pitaya_core/src/message.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while left < right {
//println!("{},{}",left,right);
cap = max(cap,min(height[left],height[right])*((right-left) as i32));
//如果左边高度小,就移动左指针(向右移动)
//如果右边高度小,就移动右指针(向左移动)
if height[left] < height[right] {
left+=1;
... | code_fim | medium | {
"lang": "rust",
"repo": "ydsh/BrushNotes",
"path": "/leetcode/11.盛最多水的容器.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ydsh/BrushNotes path: /leetcode/11.盛最多水的容器.rs
/*
* @lc app=leetcode.cn id=11 lang=rust
*
* [11] 盛最多水的容器
*/
// @lc code=start
impl Solution {
pub fn max_area(height: Vec<i32>) -> i32 {
use std::cmp::max;
use std::cmp::min;
let n = height.len();
let mut cap... | code_fim | medium | {
"lang": "rust",
"repo": "ydsh/BrushNotes",
"path": "/leetcode/11.盛最多水的容器.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zakcutner/coordination-2021 path: /src/ring/rumpsteak.rs
use super::Value;
use crate::sleep;
use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender};
use rumpsteak::{session, try_session, End, Message, Receive, Role, Roles, Send};
use std::{error::Error, result};
type Result<T> = resul... | code_fim | hard | {
"lang": "rust",
"repo": "zakcutner/coordination-2021",
"path": "/src/ring/rumpsteak.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn ring_b<const SLEEP: bool>(role: &mut B) -> Result<()> {
let x = 3;
try_session(role, |s: RingB<'_, _>| async {
let (Value(y), s) = s.receive().await?;
sleep::<SLEEP>().await;
let s = s.send(Value(x)).await?;
assert_eq!(y, 2);
Ok(((), s))
})
... | code_fim | hard | {
"lang": "rust",
"repo": "zakcutner/coordination-2021",
"path": "/src/ring/rumpsteak.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match code {
0 => Ok(Self::Default),
1 => Ok(Self::FullRange),
2 => Ok(Self::LimitedRange),
_ => Err(()),
}
}
}<|fim_prefix|>// repo: sigmaSd/libv4l-rs path: /src/format/quantization.rs
use std::convert::TryFrom;
use std::fmt;
#[derive(... | code_fim | medium | {
"lang": "rust",
"repo": "sigmaSd/libv4l-rs",
"path": "/src/format/quantization.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigmaSd/libv4l-rs path: /src/format/quantization.rs
use std::convert::TryFrom;
use std::fmt;
#[derive(Debug, Copy, Clone)]
#[repr(u32)]
/// Quantization for the colorspace.
///
/// The driver decides this for capture streams and the user sets
/// it for output streams.
pub enum Quantization {
... | code_fim | hard | {
"lang": "rust",
"repo": "sigmaSd/libv4l-rs",
"path": "/src/format/quantization.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Self::Default => write!(f, "default"),
Self::FullRange => write!(f, "full range"),
Self::LimitedRange => write!(f, "limited range"),
}
}
}
impl TryFrom<u32> for Quantization {
type Error = ();
fn try_from(code: u32) -> Result<S... | code_fim | medium | {
"lang": "rust",
"repo": "sigmaSd/libv4l-rs",
"path": "/src/format/quantization.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>;
pub const SpvDecoration__SpvDecorationNonWritable: SpvDecoration_ = 24;
pub const SpvDecoration__SpvDecorationNonReadable: SpvDecoration_ = 25;
pub const SpvDecoration__SpvDecorationUniform: SpvDecoration_ = 26;
pub const SpvDecoration__SpvDecorationUniformId: SpvDecoration_ = 27;
pub const SpvDecoratio... | code_fim | hard | {
"lang": "rust",
"repo": "gwihlidal/spirv-reflect-rs",
"path": "/gen/bindings.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gwihlidal/spirv-reflect-rs path: /gen/bindings.rs
onKHR:
SpvRayQueryIntersection_ = 1;
pub const SpvRayQueryIntersection__SpvRayQueryIntersectionMax: SpvRayQueryIntersection_ =
2147483647;
pub type SpvRayQueryIntersection_ = ::std::os::raw::c_uint;
pub use self::SpvRayQueryIntersection_ ... | code_fim | hard | {
"lang": "rust",
"repo": "gwihlidal/spirv-reflect-rs",
"path": "/gen/bindings.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ability__SpvCapabilityMeshShadingNV: SpvCapability_ = 5266;
pub const SpvCapability__SpvCapabilityImageFootprintNV: SpvCapability_ = 5282;
pub const SpvCapability__SpvCapabilityFragmentBarycentricNV: SpvCapability_ = 5284;
pub const SpvCapability__SpvCapabilityComputeDerivativeGroupQuadsNV: SpvCapability_... | code_fim | hard | {
"lang": "rust",
"repo": "gwihlidal/spirv-reflect-rs",
"path": "/gen/bindings.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidszotten/advent-of-code-2020 path: /src/bin/day03.rs
use anyhow::{bail, Error, Result};
use aoc2020::coor::Coor;
use aoc2020::dispatch;
use std::convert::TryFrom;
#[derive(Debug, Clone, Copy)]
enum Tile {
Open,
Tree,
}
impl TryFrom<char> for Tile {
type Error = Error;
fn t... | code_fim | hard | {
"lang": "rust",
"repo": "davidszotten/advent-of-code-2020",
"path": "/src/bin/day03.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let map = Map::new(input)?;
let step = STEPS[1];
Ok(map.traverse(step))
}
fn part2(input: &str) -> Result<usize> {
let map = Map::new(input)?;
Ok(STEPS.iter().map(|s| map.traverse(*s)).product())
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "..##.......
#...#... | code_fim | hard | {
"lang": "rust",
"repo": "davidszotten/advent-of-code-2020",
"path": "/src/bin/day03.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: teromene/activityrust path: /src/entities/collectionpage.rs
use crate::content::*;
use crate::entities::collection::ActivityStreamCollection;
use crate::entities::entity::{
ActivityStreamEntity, ActivityStreamEntityType, BoxedActivityStreamEntity,
};
use crate::traits::properties::*;
use cra... | code_fim | hard | {
"lang": "rust",
"repo": "teromene/activityrust",
"path": "/src/entities/collectionpage.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.next
}
fn set_next<S, T: MaybeOptional<S>>(&mut self, next: T)
where
ActivityStreamEntity: From<S>,
{
if let Some(next) = next.get_optional() {
self.next = Some(Box::new(ActivityStreamEntity::from(next)));
}
}
fn get_prev(&self) -... | code_fim | hard | {
"lang": "rust",
"repo": "teromene/activityrust",
"path": "/src/entities/collectionpage.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_prev<S, T: MaybeOptional<S>>(&mut self, prev: T)
where
ActivityStreamEntity: From<S>,
{
if let Some(prev) = prev.get_optional() {
self.prev = Some(Box::new(ActivityStreamEntity::from(prev)));
}
}
}
generate_basics!(
ActivityStreamCollectionPa... | code_fim | hard | {
"lang": "rust",
"repo": "teromene/activityrust",
"path": "/src/entities/collectionpage.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl BluetoothNode {
pub fn new(address: Address) -> BluetoothNode {
BluetoothNode {
address: address
}
}
}
impl Node for UdpNode {
fn address(&self) -> Address {
self.address
}
fn send(&self, message: &str) {
println!("Sending via UDP: {}"... | code_fim | hard | {
"lang": "rust",
"repo": "zacstewart/heterogeneous-collections-in-rust",
"path": "/src/trait_objects.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zacstewart/heterogeneous-collections-in-rust path: /src/trait_objects.rs
use super::Address;
use std::collections::HashMap;
pub struct Bucket {
nodes: HashMap<Address, Box<Node>>
}
impl Bucket {
pub fn new() -> Bucket {
Bucket {
nodes: HashMap::new()
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "zacstewart/heterogeneous-collections-in-rust",
"path": "/src/trait_objects.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let udp_node = UdpNode::new(0);
let bluetooth_node = BluetoothNode::new(1);
bucket.insert(Box::new(udp_node));
bucket.insert(Box::new(bluetooth_node));
}
#[test]
fn get_node() {
let mut bucket = Bucket::new();
let udp_node = UdpNode::new(0);
... | code_fim | hard | {
"lang": "rust",
"repo": "zacstewart/heterogeneous-collections-in-rust",
"path": "/src/trait_objects.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _x in 0..22{ //impresión de caracteres para la separación
print!("-");
}
println!();
for x in booleanos.iter(){ //Itera con cada valor booleano (true, false) e imprime su valor actual, ademas realiza la operacion or
for y in booleanos.iter(){
printl... | code_fim | medium | {
"lang": "rust",
"repo": "upslp-teoriacomputacional/170113",
"path": "/demostracion/170113-compuertas.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: upslp-teoriacomputacional/170113 path: /demostracion/170113-compuertas.rs
/*
*Nombre: Yair Briones de la Rosa
*Matricula: 170113
*Carrera: ITI
*Descripción: Programa que inicializa una lista de posibles
valores booleanos a fin de llevar a cabo las operaciones
... | code_fim | hard | {
"lang": "rust",
"repo": "upslp-teoriacomputacional/170113",
"path": "/demostracion/170113-compuertas.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cupnfish/my-leetcode-rust path: /src/structs/list_node.rs
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
<|fim_suffix|>#[macro_export]
macro_rules! list[
() => (Option::<Box<$crate::structs::list_no... | code_fim | hard | {
"lang": "rust",
"repo": "Cupnfish/my-leetcode-rust",
"path": "/src/structs/list_node.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! list[
() => (Option::<Box<$crate::structs::list_node::ListNode>>::None);
($x:expr) => (Some(Box::new($crate::structs::list_node::ListNode::new($x))));
($x:expr, $($xs:expr),+) => (Some(Box::new($crate::structs::list_node::ListNo... | code_fim | hard | {
"lang": "rust",
"repo": "Cupnfish/my-leetcode-rust",
"path": "/src/structs/list_node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nspace_alias = &full_name[..sep];
let cname = &full_name[sep + 1..];
for (g_alias, g_nspace) in &crate::G.entity_search_dirs {
if g_alias == nspace_alias {
return Some(format!("{}{}", g_nspace, cname));
}
}
None
}<|fim_prefix|>// repo: awoimbee/sf4_upda... | code_fim | hard | {
"lang": "rust",
"repo": "awoimbee/sf4_updater",
"path": "/src/php/resolve_namespace.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awoimbee/sf4_updater path: /src/php/resolve_namespace.rs
use std::path::Path;
/// full_name: Namespace\MyBundle\ClassThing
/// Returns path (../root_fd/src/namespace/MyBundle/ClassThing.php)
/// search_dir is optional, it's the first directory to look for the class in
pub fn namespace_to_path(f... | code_fim | hard | {
"lang": "rust",
"repo": "awoimbee/sf4_updater",
"path": "/src/php/resolve_namespace.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* Here where the magic starts. */
let input = "The quick brown fox jumps over the lazy dog.";
uprintln!(tx, "\r\nHere we hash: \"{}\"", input);
let hash = sha256::Hash::hash(&input.as_bytes());
uprintln!(tx, "Hash: {:x?}", hash);
// infinite echo loop
... | code_fim | hard | {
"lang": "rust",
"repo": "miketlk/rust_f469_disco_ex",
"path": "/examples/hashes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if let Some(dp) = stm32::Peripherals::take(){
let gpiob = dp.GPIOB.split(); // UART3
// Set up the system clock. We want to run at 180MHz for this one.
let rcc = dp.RCC.constrain();
let clocks = rcc.cfgr.sysclk(180.mhz()).freeze();
let tx = gpiob.pb10.into_a... | code_fim | hard | {
"lang": "rust",
"repo": "miketlk/rust_f469_disco_ex",
"path": "/examples/hashes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: miketlk/rust_f469_disco_ex path: /examples/hashes.rs
//! Test of bitcoin_hashes on the board.
//! Prints sha256 of a fixed sentence to serial port
#![no_main]
#![no_std]
#![allow(unused_extern_crates)]
extern crate panic_halt;
// hardware specific
use cortex_m_rt::entry;
use stm32f4xx_hal as ... | code_fim | hard | {
"lang": "rust",
"repo": "miketlk/rust_f469_disco_ex",
"path": "/examples/hashes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>by those services utilizing
/// the IAM condition feature.
#[prost(message, optional, tag = "8")]
pub destination_attributes:
::core::option::Option<super::super::rpc::context::attribute_context::Peer>,
}
/// Location information about a resource.
#[derive(Clone, PartialEq, ::prost::Me... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.audit.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/googapis path: /googapis/genproto/google.cloud.audit.rs
/// Common audit log format for Google Cloud Platform API operations.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AuditLog {
/// The name of the API service performing the operation. For example,
/// `"compute... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.audit.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
#[should_panic]
fn negative_parse_from_empty_bytes() {
Metainfo::from_bytes(b"").unwrap();
}
#[test]
#[should_panic]
fn negative_parse_with_no_piece_length() {
let tracker = "udp://dummy_domain.com:8989";
let pieces = [0u8; sha::SHA_HASH_LEN];
... | code_fim | hard | {
"lang": "rust",
"repo": "GGist/bip-rs",
"path": "/bip_metainfo/src/metainfo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let meta_paths: &Path = meta_file.path();
let supp_paths: PathBuf = supp_file.2.as_ref().unwrap().iter().fold(PathBuf::new(), |mut buf, item| {
let item: &str = item;
buf.push(item);
buf
});
assert_eq!(meta_pat... | code_fim | hard | {
"lang": "rust",
"repo": "GGist/bip-rs",
"path": "/bip_metainfo/src/metainfo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GGist/bip-rs path: /bip_metainfo/src/metainfo.rs
created_by: Option<String>,
creation_date: Option<i64>,
info: Info,
}
impl Metainfo {
/// Read a `Metainfo` from metainfo file bytes.
pub fn from_bytes<B>(bytes: B) -> ParseResult<Metainfo>
where B: AsRef<[u8]>
{
... | code_fim | hard | {
"lang": "rust",
"repo": "GGist/bip-rs",
"path": "/bip_metainfo/src/metainfo.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
redis_connection::RedisConnection::new().init();
let mut thread_started = false;
let mut _sync_thread = thread::spawn(|| {});
let _server = thread::Builder::new().name("server".to_owned()).spawn(move || {
listen("127.0.0.1:12345", move |sender| {
if !thread_... | code_fim | hard | {
"lang": "rust",
"repo": "YuichiroSato/Scratch",
"path": "/rust/ping_pong/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YuichiroSato/Scratch path: /rust/ping_pong/src/main.rs
#![feature(plugin, decl_macro)]
#![feature(custom_derive)]
#![plugin(rocket_codegen)]
extern crate rocket;
extern crate rocket_contrib;
extern crate rustc_serialize;
extern crate ws;
<|fim_suffix|>fn main() {
redis_connection::RedisCon... | code_fim | hard | {
"lang": "rust",
"repo": "YuichiroSato/Scratch",
"path": "/rust/ping_pong/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.delay((us as u32).micros())
}
}
impl<TIM: Instance, const FREQ: u32> DelayMs<u8> for Delay<TIM, FREQ> {
/// Sleep for `ms` milliseconds
fn delay_ms(&mut self, ms: u8) {
self.delay((ms as u32).millis())
}
}
impl<TIM: Instance, const FREQ: u32> Periodic for Counter<TIM,... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32f1xx-hal",
"path": "/src/timer/hal_02.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32f1xx-hal path: /src/timer/hal_02.rs
//! Delay implementation based on general-purpose 32 bit timers and System timer (SysTick).
//!
//! TIM2 and TIM5 are a general purpose 32-bit auto-reload up/downcounter with
//! a 16-bit prescaler.
use embedded_hal::{
blocking::delay::{Dela... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32f1xx-hal",
"path": "/src/timer/hal_02.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.get_duty(channel)
}
fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty) {
self.set_duty(channel, duty)
}
/// If `0` returned means max_duty is 2^16
fn get_max_duty(&self) -> Self::Duty {
self.get_max_duty()
}
fn get_period(&self) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32f1xx-hal",
"path": "/src/timer/hal_02.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nagaBoulevard/wasp path: /src/lexer/mod.rs
pub mod atom;
pub mod token;
use ::core::Core;
use self::atom::Atom;
use self::token::Token;
const SEXPR_START: char = '(';
const SEXPR_END : char = ')';
const VEC_START : char = '[';
const VEC_END : char = ']';
// SPECIALS {{{
const SPECIALS... | code_fim | hard | {
"lang": "rust",
"repo": "nagaBoulevard/wasp",
"path": "/src/lexer/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// parse a number
/// a number must follow the syntax "\d[\d_]*(.\d[\d_]*)?"
/// thus floats are supported.
/// This parser also handles the 'num.num' (decimal)
/// and 'num:num' (range) syntax.
/// In this way, both the '.' and ':' chars can be used as standalone
/// operato... | code_fim | hard | {
"lang": "rust",
"repo": "nagaBoulevard/wasp",
"path": "/src/lexer/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// parse a number
/// a number must follow the syntax "\d[\d_]*(.\d[\d_]*)?"
/// thus floats are supported.
/// This parser also handles the 'num.num' (decimal)
/// and 'num:num' (range) syntax.
/// In this way, both the '.' and ':' chars can be used as standalone
/// operat... | code_fim | hard | {
"lang": "rust",
"repo": "nagaBoulevard/wasp",
"path": "/src/lexer/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ture_detected!("avx512f"));
MMMKernel!(f32, avx512_mmm_f32_48x4; 48, 4; 64, 4; 0, 0; no_prefetch, is_x86_feature_detected!("avx512f"));
MMMKernel!(f32, avx512_mmm_f32_64x3; 64, 3; 64, 4; 0, 0; no_prefetch, is_x86_feature_detected!("avx512f"));
MMMKernel!(f32, avx512_mmm_f32_80x2; 80, 2; 64, 4; 0, 0; no_pr... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/linalg/src/x86_64_fma/mmm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sonos/tract path: /linalg/src/x86_64_fma/mmm.rs
use crate::frame::mmm::*;
MMMKernel!(f32, fma_mmm_f32_8x8; 8, 8; 32, 4; 0, 0; no_prefetch, is_x86_feature_detected!("fma"));
MMMKernel!(f32, fma_mmm_f32_16x6; 16, 6; 32, 4; 0, 0; no_prefetch, is_x86_feature_detected!("fma"));
MMMKernel!(f32, fma_m... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/linalg/src/x86_64_fma/mmm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magiclen/validators path: /validators/src/errors/base64.rs
use core::fmt::{self, Display, Formatter};
#[cfg(feature = "std")]
use std::error::Error;
<|fim_suffix|> match self {
Base64Error::Invalid => f.write_str("invalid Base64"),
Base64Error::PaddingMust => f.wr... | code_fim | hard | {
"lang": "rust",
"repo": "magiclen/validators",
"path": "/validators/src/errors/base64.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Base64Error::Invalid => f.write_str("invalid Base64"),
Base64Error::PaddingMust => f.write_str("padding not found"),
Base64Error::PaddingNotAllow => f.write_str("padding not allowed"),
}
}
}
#[cfg(feature = "std")]
impl Error for Base64... | code_fim | medium | {
"lang": "rust",
"repo": "magiclen/validators",
"path": "/validators/src/errors/base64.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(DaysCoin {
created: Decodable::consensus_decode(&mut d)?,
})
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("not enough arguments");
process::exit(1)... | code_fim | hard | {
"lang": "rust",
"repo": "LeMarwin/bitcoin-utxo",
"path": "/examples/days.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LeMarwin/bitcoin-utxo path: /examples/days.rs
// The example calculates average days UTXO set left unspend
extern crate bitcoin;
extern crate bitcoin_utxo;
use futures::pin_mut;
use futures::stream;
use futures::SinkExt;
use tokio::time::Duration;
use rocksdb::DB;
use std::error::Error;
use s... | code_fim | hard | {
"lang": "rust",
"repo": "LeMarwin/bitcoin-utxo",
"path": "/examples/days.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let len = self.created.consensus_encode(writer)?;
Ok(len)
}
}
impl Decodable for DaysCoin {
fn consensus_decode<D: io::Read>(mut d: D) -> Result<Self, encode::Error> {
Ok(DaysCoin {
created: Decodable::consensus_decode(&mut d)?,
})
}
}
#[tokio::main... | code_fim | hard | {
"lang": "rust",
"repo": "LeMarwin/bitcoin-utxo",
"path": "/examples/days.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_object_message() {
let msg = r#"{
"secret": "shh",
"config": {"var1":"a"}
}"#;
let command: RemoteCommand = json::decode(msg).unwrap();
let expect = "{\"var1\":\"a\"}";
assert_eq!(expect, get_extra_vars(msg).unwrap()... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/deployer",
"path": "/src/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steveklabnik/deployer path: /src/message.rs
use rustc_serialize::json;
use rustc_serialize::json::DecodeResult;
use std::collections::BTreeMap;
use std::string;
#[derive(RustcDecodable, Clone, Debug)]
pub struct RemoteCommand {
pub secret: String,
pub target: Option<String>,
pub hos... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/deployer",
"path": "/src/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmrath/tower-web path: /tests/multi_resource.rs
use tower_web::impl_web;
mod support;
use crate::support::*;
#[derive(Clone, Debug)]
struct One;
#[derive(Clone, Debug)]
struct Two;
#[derive(Clone, Debug)]
struct Three;
#[derive(Clone, Debug)]
struct Four;
impl_web! {
impl One {
... | code_fim | medium | {
"lang": "rust",
"repo": "mmrath/tower-web",
"path": "/tests/multi_resource.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use tower_service::NewService;
let mut web = ::tower_web::ServiceBuilder::new()
.resource(One)
.resource(Two)
.resource(Three)
.resource(Four)
.build_new_service()
.new_service()
.wait().unwrap();
for path in &["/one", "/two", "/three",... | code_fim | hard | {
"lang": "rust",
"repo": "mmrath/tower-web",
"path": "/tests/multi_resource.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::max_area(vec![1, 8, 6, 2, 5, 4, 8, 3, 7]), 49);
assert_eq!(Solution::max_area(vec![1, 1]), 1);
assert_eq!(Solution::max_area(vec![4, 3, 2, 1, 4]), 16);
assert_eq!(Solution::max_area(vec![1, 2, 1]), 2);
}
}<|fim_prefix|>// repo: fengkx/leetcode path... | code_fim | medium | {
"lang": "rust",
"repo": "fengkx/leetcode",
"path": "/rust/container_with_most_water/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fengkx/leetcode path: /rust/container_with_most_water/src/lib.rs
struct Solution;
impl Solution {
pub fn max_area(height: Vec<i32>) -> i32 {
let len = height.len();
let mut left = 0;
let mut right = len - 1;
<|fim_suffix|> #[test]
fn test_max_area() {
... | code_fim | hard | {
"lang": "rust",
"repo": "fengkx/leetcode",
"path": "/rust/container_with_most_water/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hannobraun/rustecs path: /rustecs/src/lib.rs
use std::collections::HashMap;
pub type EntityId = u32;
pub type Components<T> = HashMap<EntityId, T>;
pub fn components<T>() -> Components<T> {
HashMap::new()
}
pub trait EntityContainer<E> {
fn add(&mut self, entity: E) -> EntityId;
fn imp... | code_fim | medium | {
"lang": "rust",
"repo": "hannobraun/rustecs",
"path": "/rustecs/src/lib.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn import(&mut self, id: EntityId, entity: E) {
self.imported.push((id, entity));
}
pub fn remove(&mut self, id: EntityId) {
self.removed.push(id);
}
pub fn apply<Es: EntityContainer<E>>(&mut self, entities: &mut Es) {
loop {
match self.imported.pop() {
Some((id, entity)) =>
e... | code_fim | hard | {
"lang": "rust",
"repo": "hannobraun/rustecs",
"path": "/rustecs/src/lib.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Chris1221/scJaccard path: /tests/main.rs
use assert_cmd::prelude::*;
use std::process::Command;
fn sc_jaccard() -> std::process::Command {
Command::cargo_bin("scJaccard").unwrap()
}
#[test]
fn help() {
sc_jaccard().arg("-h").assert().success();
}
#[test]
fn test_success_run() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Chris1221/scJaccard",
"path": "/tests/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_full_output() {
let out = sc_jaccard()
.args(&["-i", "example_data/test.mtx", "--atac", "example_data/target.bed.gz", "--barcodes", "example_data/test.tsv", "--nchr", "1", "--loglevel", "warn", "--bed", "example_data/test.bed", "--cores", "1", "--full"])
.assert();
le... | code_fim | hard | {
"lang": "rust",
"repo": "Chris1221/scJaccard",
"path": "/tests/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lloydmeta/elasticsearch-rs path: /elasticsearch/src/namespace_clients/ilm.rs
s."]
pub fn source(mut self, source: Option<String>) -> Self {
self.source = source;
self
}
}
impl Sender for IlmGetStatus {
fn send(self) -> Result<ElasticsearchResponse, ElasticsearchError>... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/elasticsearch-rs",
"path": "/elasticsearch/src/namespace_clients/ilm.rs",
"mode": "psm",
"license": "DOC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lloydmeta/elasticsearch-rs path: /elasticsearch/src/namespace_clients/ilm.rs
pretty: None,
source: None,
}
}
#[doc = "Include the stack trace of returned errors."]
pub fn error_trace(mut self, error_trace: Option<bool>) -> Self {
self.error_trace = erro... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/elasticsearch-rs",
"path": "/elasticsearch/src/namespace_clients/ilm.rs",
"mode": "psm",
"license": "DOC",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = "/_ilm/policy/{policy}";
let method = HttpMethod::Put;
let query_string = {
#[derive(Serialize)]
struct QueryParamsStruct {
#[serde(rename = "error_trace")]
error_trace: Option<bool>,
#[serde(rename ... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/elasticsearch-rs",
"path": "/elasticsearch/src/namespace_clients/ilm.rs",
"mode": "spm",
"license": "DOC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Laegluin/mikrorechner path: /simulator/src/support.rs
use crate::memory::{Word, WORD_BYTES};
<|fim_suffix|>pub fn to_hex_octets(bytes: &[u8]) -> String {
let mut string: String = bytes.iter().map(|byte| format!("{:02x} ", byte)).collect();
string.pop();
string
}<|fim_middle|>pub fn ... | code_fim | medium | {
"lang": "rust",
"repo": "Laegluin/mikrorechner",
"path": "/simulator/src/support.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn to_hex_octets(bytes: &[u8]) -> String {
let mut string: String = bytes.iter().map(|byte| format!("{:02x} ", byte)).collect();
string.pop();
string
}<|fim_prefix|>// repo: Laegluin/mikrorechner path: /simulator/src/support.rs
use crate::memory::{Word, WORD_BYTES};
<|fim_middle|>pub fn ... | code_fim | medium | {
"lang": "rust",
"repo": "Laegluin/mikrorechner",
"path": "/simulator/src/support.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug)]
enum Value {
Number(i64),
Register(String),
}
struct VM {
stack_pointer: i64,
instructions: Vec<Instruction>,
registers: HashMap<String, i64>,
}
impl From<&String> for Value {
fn from(value: &String) -> Self {
if let Ok(res) = i64::from_str(value) ... | code_fim | hard | {
"lang": "rust",
"repo": "VadimGaltsev/AssemblerInterpreter",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VadimGaltsev/AssemblerInterpreter path: /src/main.rs
use std::collections::HashMap;
use std::str::FromStr;
fn main() {
println!(
"{:?}",
simple_assembler(vec![
"mov c 12",
"mov b 0",
"mov a 200",
"dec a",
"inc b",
... | code_fim | hard | {
"lang": "rust",
"repo": "VadimGaltsev/AssemblerInterpreter",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(res) = i64::from_str(value) {
Value::Number(res)
} else {
Value::Register(value.clone())
}
}
}
#[derive(Clone, Debug)]
struct RawInstruction(Instruction, Register);
impl From<Vec<String>> for RawInstruction {
fn from(raw: Vec<String>) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "VadimGaltsev/AssemblerInterpreter",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rukai/canon_collision path: /canon_collision_lib/src/entity_def/mod.rs
pub mod dave;
pub mod item;
pub mod player;
pub mod projectile;
pub mod toriel;
pub mod toriel_fireball;
pub mod toriel_oven;
use strum::IntoEnumIterator;
use treeflection::{ContextVec, KeyedContextVec, Node, NodeRunner, Nod... | code_fim | hard | {
"lang": "rust",
"repo": "rukai/canon_collision",
"path": "/canon_collision_lib/src/entity_def/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for HurtBox {
fn default() -> HurtBox {
HurtBox {
bkb_add: 0.0,
kbg_add: 0.0,
damage_mult: 1.0,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Node)]
pub struct HitBox {
pub shield_damage: f32,
pub damage: f32,
pub... | code_fim | hard | {
"lang": "rust",
"repo": "rukai/canon_collision",
"path": "/canon_collision_lib/src/entity_def/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Tech {
fn default() -> Self {
Tech {
active_window: 20,
locked_window: 20,
}
}
}
#[derive(Clone, Serialize, Deserialize, Node)]
pub struct LCancel {
pub active_window: u64,
pub frame_skip: u8,
pub normal_land: bool,
}
impl Defa... | code_fim | hard | {
"lang": "rust",
"repo": "rukai/canon_collision",
"path": "/canon_collision_lib/src/entity_def/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: schickling/challenges path: /coffee-time-challenges/01-two-bases/main.rs
fn main () {
for x in range(0i, 9) {
for y in range(0i, 9) {
for z in range(0i, 9) {
if check(x, y, z) {
println!("{} {} {}", x, y, z);
}
... | code_fim | easy | {
"lang": "rust",
"repo": "schickling/challenges",
"path": "/coffee-time-challenges/01-two-bases/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x * 10 * 10 + y * 10 + z == z * 9 * 9 + y * 9 + x
}<|fim_prefix|>// repo: schickling/challenges path: /coffee-time-challenges/01-two-bases/main.rs
fn main () {
for x in range(0i, 9) {
for y in range(0i, 9) {
for z in range(0i, 9) {
if check(x, y, z) {
... | code_fim | easy | {
"lang": "rust",
"repo": "schickling/challenges",
"path": "/coffee-time-challenges/01-two-bases/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: S-YOU/wyhash-rs path: /examples/hasher_trait.rs
// Example using the `core::hash::Hasher` interface.
// (Same as using `std::hash::Hasher`)
<|fim_suffix|> let mut hasher = WyHash::with_seed(3);
hasher.write(&[0, 1, 2]);
assert_eq!(0xb0f9_4152_0b1a_d95d, hasher.finish());
}<|fim_middl... | code_fim | easy | {
"lang": "rust",
"repo": "S-YOU/wyhash-rs",
"path": "/examples/hasher_trait.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut hasher = WyHash::with_seed(3);
hasher.write(&[0, 1, 2]);
assert_eq!(0xb0f9_4152_0b1a_d95d, hasher.finish());
}<|fim_prefix|>// repo: S-YOU/wyhash-rs path: /examples/hasher_trait.rs
// Example using the `core::hash::Hasher` interface.
// (Same as using `std::hash::Hasher`)
use core::h... | code_fim | easy | {
"lang": "rust",
"repo": "S-YOU/wyhash-rs",
"path": "/examples/hasher_trait.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/rustdoc/inline-default-methods.rs
// aux-build:inline-default-methods.rs
// ignore-cross-compile
<|fim_suffix|>// @has inline_default_methods/trait.Foo.html
// @has - '//*[@class="rust trait"]' 'fn bar(&self);'
// @has - '//*[@class="rust trait"]'... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/rustdoc/inline-default-methods.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: payload/bitworks path: /bitworks/src/systems/simple_spawner.rs
use bevy::prelude::*;
use crate::*;
pub struct SimpleSpawnerPlugin;
impl Plugin for SimpleSpawnerPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_system_to_stage(CoreStage::PreUpdate, simple_spawner_system.syst... | code_fim | hard | {
"lang": "rust",
"repo": "payload/bitworks",
"path": "/bitworks/src/systems/simple_spawner.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cmds.entity(entity)
.insert(Name::new("Belt"))
.insert(*pos)
.insert(Belt {
segments: vec![segment],
items: vec![],
output: None,
})
... | code_fim | hard | {
"lang": "rust",
"repo": "payload/bitworks",
"path": "/bitworks/src/systems/simple_spawner.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn query(&self) -> &Vec<(String, String)> {
&self.query
}
}<|fim_prefix|>// repo: ComputerCampLuv/recwid path: /src/api/orders/create_order/request.rs
use crate::dispatchable::{Dispatchable, Method};
use serde_json::Value;
pub struct Request {
body: Value,
query: Vec<(String, St... | code_fim | medium | {
"lang": "rust",
"repo": "ComputerCampLuv/recwid",
"path": "/src/api/orders/create_order/request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn body(&self) -> &serde_json::Value {
&self.body
}
fn query(&self) -> &Vec<(String, String)> {
&self.query
}
}<|fim_prefix|>// repo: ComputerCampLuv/recwid path: /src/api/orders/create_order/request.rs
use crate::dispatchable::{Dispatchable, Method};
use serde_json::Valu... | code_fim | hard | {
"lang": "rust",
"repo": "ComputerCampLuv/recwid",
"path": "/src/api/orders/create_order/request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ComputerCampLuv/recwid path: /src/api/orders/create_order/request.rs
use crate::dispatchable::{Dispatchable, Method};
use serde_json::Value;
<|fim_suffix|> fn body(&self) -> &serde_json::Value {
&self.body
}
fn query(&self) -> &Vec<(String, String)> {
&self.query
... | code_fim | hard | {
"lang": "rust",
"repo": "ComputerCampLuv/recwid",
"path": "/src/api/orders/create_order/request.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (hi.1).0 >= l && (hi.1).1 <= r {
s += 1;
}
}
println!("{}", s);
}
}<|fim_prefix|>// repo: hinagis/abc174 path: /src/bin/f.rs
fn main() {
proconio::input! {
n: usize,
q: usize,
mut c: [usize; n],
lr: [(usize, usize); q... | code_fim | medium | {
"lang": "rust",
"repo": "hinagis/abc174",
"path": "/src/bin/f.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hinagis/abc174 path: /src/bin/f.rs
fn main() {
proconio::input! {
n: usize,
q: usize,
mut c: [usize; n],
lr: [(usize, usize); q],
}
let mut h = std::collections::HashMap::new();
for i in 0..n {
(*h.entry(c[i]).or_in<|fim_suffix|> if (hi.1)... | code_fim | medium | {
"lang": "rust",
"repo": "hinagis/abc174",
"path": "/src/bin/f.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> map["peter"].clear(); //~ ERROR
map["peter"] = "0".to_string(); //~ ERROR
let _ = &mut map["peter"]; //~ ERROR
}<|fim_prefix|>// repo: unnsa/rust path: /src/test/ui/borrowck/index-mut-help.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-le... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/ui/borrowck/index-mut-help.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unnsa/rust path: /src/test/ui/borrowck/index-mut-help.rs
// Copyright 2018 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-APACHE or
// h... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/ui/borrowck/index-mut-help.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<F> Display for HandlerImpl<F> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.function_name)
}
}
impl<I: Debug, C, F> Handler<I, C> for HandlerImpl<F>
where
F: FnOnce(Client, Response, C, Logger) -> Receiver<Indeterminate<I, C>> + Send + Sync + Copy,... | code_fim | hard | {
"lang": "rust",
"repo": "blackboard/scrappy-do",
"path": "/src/handler.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.debug_struct("HandlerImpl")
.field("function", &self.function_name)
.finish()
}
}
impl<F> Display for HandlerImpl<F> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.function_name)
}
}
impl<I: Debug, C, F> Handler<I, C> f... | code_fim | hard | {
"lang": "rust",
"repo": "blackboard/scrappy-do",
"path": "/src/handler.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blackboard/scrappy-do path: /src/handler.rs
use crate::callback::Indeterminate;
use reqwest::{Client, Response};
use slog::Logger;
use std::fmt::{self, Debug, Display};
use tokio::sync::mpsc::Receiver;
/// Converts HTTP responses into items or HTTP requests.
///
/// It is the job of the caller ... | code_fim | hard | {
"lang": "rust",
"repo": "blackboard/scrappy-do",
"path": "/src/handler.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut v: Vec<T> = Vec::new();
for ii in 0..self.len() {
v.append(&mut self[ii].clone().flatten());
}
v
}
fn transpose(&self) -> Self {
//TODO: implement correctly
self.clone()
}
}
// <<<<<<<<<<<<< Operators <<<<<<<<<<<<<
// >>>>>>... | code_fim | hard | {
"lang": "rust",
"repo": "Surpris/rs-deep",
"path": "/src/dlfs01/common/operators.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Surpris/rs-deep path: /src/dlfs01/common/operators.rs
//! ops
//!
//! operators
use super::math::MathFunc;
use super::util::cast_t2u;
use num_traits::{Float, Num, NumCast};
type Vec2d<T> = Vec<Vec<T>>;
type Vec3d<T> = Vec<Vec2d<T>>;
type Vec4d<T> = Vec<Vec3d<T>>;
// >>>>>>>>>>>>> Operators >>... | code_fim | hard | {
"lang": "rust",
"repo": "Surpris/rs-deep",
"path": "/src/dlfs01/common/operators.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lyuboraykov/rust-exercises path: /tests/integration_test.rs
extern crate service_utils;
use service_utils::islands::Territory;
<|fim_suffix|> let mut territory = Territory::new();
assert_eq!(territory.add_land(0, 0), 1);
assert_eq!(territory.add_land(2, 0), 2);
assert_eq!(territ... | code_fim | easy | {
"lang": "rust",
"repo": "lyuboraykov/rust-exercises",
"path": "/tests/integration_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.