text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: pace-noge/peautkb path: /firmware/examples/adam_led.rs
#![no_std]
#![no_main]
use cortex_m::peripheral::Peripherals;
use panic_halt as _;
use smart_leds::{brightness, SmartLedsWrite, RGB8};
use stm32f4xx_hal::delay::Delay;
use stm32f4xx_hal::prelude::*;
use stm32f4xx_hal::spi::{NoMiso, NoSck, S... | code_fim | hard | {
"lang": "rust",
"repo": "pace-noge/peautkb",
"path": "/firmware/examples/adam_led.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ((x - a).pow(2) + (y - b).pow(2)) <= radius.pow(2) {
cell.set_ch(BLOCK);
} else {
cell.set_ch(' ');
}
}
term.swap_buffers().unwrap();
}
}<|fim_prefix|>// repo: tempbottle/rustty path: /examples/circle.rs
extern cra... | code_fim | hard | {
"lang": "rust",
"repo": "tempbottle/rustty",
"path": "/examples/circle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut term = Terminal::new().unwrap();
let mut radius = 10isize;
'main: loop {
while let Some(Event::Key(ch)) = term.get_event(0).unwrap() {
match ch {
'q' => break 'main,
'+' => radius += 1,
'-' => radius -= 1,
... | code_fim | hard | {
"lang": "rust",
"repo": "tempbottle/rustty",
"path": "/examples/circle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tempbottle/rustty path: /examples/circle.rs
extern crate rustty;
use rustty::{
Terminal,
Event,
};
const BLOCK: char = '\u{25AA}';
<|fim_suffix|> let (a, b) = (cols / 2, rows / 2);
for (i, cell) in term.iter_mut().enumerate() {
let y = i as isize / cols;
... | code_fim | hard | {
"lang": "rust",
"repo": "tempbottle/rustty",
"path": "/examples/circle.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxtnuk/generic-simd path: /generic-simd/src/arch/arm/mod.rs
//! arm/aarch64 vector types.
#[cfg(feature = "complex")]
mod complex;
#[cfg(feature = "complex")]
pub use complex::*;
use crate::{
arch::{generic, Token},
scalar::Scalar,
shim::{Shim2, Shim4, ShimToken},
vector::{wid... | code_fim | hard | {
"lang": "rust",
"repo": "maxtnuk/generic-simd",
"path": "/generic-simd/src/arch/arm/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>arithmetic_ops! {
feature: Neon::new_unchecked(),
for f32x4:
add -> (vaddq_f32),
sub -> (vsubq_f32),
mul -> (vmulq_f32),
div -> ()
}
#[cfg(target_arch = "aarch64")]
arithmetic_ops! {
feature: Neon::new_unchecked(),
for f64x2:
add -> (vaddq_f64),
... | code_fim | hard | {
"lang": "rust",
"repo": "maxtnuk/generic-simd",
"path": "/generic-simd/src/arch/arm/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO use vdup
let mut v: Self = unsafe { core::mem::zeroed() };
v[0] = from;
v[1] = from;
v
}
}
unsafe impl Vector for f32x4 {
type Scalar = f32;
type Token = Neon;
type Width = crate::vector::width::W4;
type Underlying = float32x4_t;
... | code_fim | hard | {
"lang": "rust",
"repo": "maxtnuk/generic-simd",
"path": "/generic-simd/src/arch/arm/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ImageBarrier {
pub fn new(img: vk::Image) -> Self {
ImageBarrier {
src_stages: vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT,
dst_stages: 0,
barrier: vk::ImageMemoryBarrier {
sType: vk::STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
pNext: std::ptr::null(),
srcAccessMask: 0... | code_fim | hard | {
"lang": "rust",
"repo": "dopitz/vulkanism",
"path": "/nobs-vulkanism-headless/src/cmd/commands/barrier.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn aspect_mask(mut self, aspect: vk::ImageAspectFlags) -> Self {
self.barrier.subresourceRange.aspectMask = aspect;
self
}
pub fn mip_level(mut self, base_level: u32, count: u32) -> Self {
self.barrier.subresourceRange.baseMipLevel = base_level;
self.barrier.subresourceRange.leve... | code_fim | hard | {
"lang": "rust",
"repo": "dopitz/vulkanism",
"path": "/nobs-vulkanism-headless/src/cmd/commands/barrier.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dopitz/vulkanism path: /nobs-vulkanism-headless/src/cmd/commands/barrier.rs
use super::StreamPush;
use crate::cmd::CmdBuffer;
use vk;
/// Conservatively gets pipeline stage flags from acces flags
fn get_stages_from_access(access: vk::AccessFlags) -> vk::PipelineStageFlags {
let mut res = 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "dopitz/vulkanism",
"path": "/nobs-vulkanism-headless/src/cmd/commands/barrier.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn italic(&self) -> bool {
self.italic
}
pub fn bold(&self) -> bool {
self.bold
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn assert_color() {
let target = ThemeConfig::new(SerdeColor::new(29, 20, 45, 72), true, false);
let result ... | code_fim | hard | {
"lang": "rust",
"repo": "Eraden/rider",
"path": "/rider-themes/src/theme_config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eraden/rider path: /rider-themes/src/theme_config.rs
use crate::SerdeColor;
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct ThemeConfig {
color: SerdeColor,
italic: bool,
bold: bool,
}
impl ThemeConfig {
pub fn new(color: SerdeColor, italic: bool, bold: bo... | code_fim | hard | {
"lang": "rust",
"repo": "Eraden/rider",
"path": "/rider-themes/src/theme_config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn assert_color() {
let target = ThemeConfig::new(SerdeColor::new(29, 20, 45, 72), true, false);
let result = target.color().clone();
let expected = SerdeColor::new(29, 20, 45, 72);
assert_eq!(result, expected);
}
#[test]
fn assert_italic() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Eraden/rider",
"path": "/rider-themes/src/theme_config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: weijunji/wcal path: /src/generator/calculator_f.rs
//! Convert the expression AST to `f64`
use crate::lexer::Token;
use crate::parser::ast::*;
trait Calculable {
fn calculate(node: &Self) -> f64;
}
impl Calculable for Expr {
fn calculate(node: &Self) -> f64 {
match node {
... | code_fim | hard | {
"lang": "rust",
"repo": "weijunji/wcal",
"path": "/src/generator/calculator_f.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Calculable for Pair {
fn calculate(node: &Self) -> f64 {
Expr::calculate(&node.expr)
}
}
impl Calculable for Neg {
fn calculate(node: &Self) -> f64 {
-Expr::calculate(&node.expr)
}
}
impl Calculable for AST {
fn calculate(ast: &Self) -> f64 {
Expr::calcul... | code_fim | hard | {
"lang": "rust",
"repo": "weijunji/wcal",
"path": "/src/generator/calculator_f.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = calculator_f::calculate(AST{root: BinOp::new(Number::new(1), Number::new(2), Token::Times)});
assert_eq!(res, 2f64);
}
#[test]
fn test_division() {
let res = calculator_f::calculate(AST{root: BinOp::new(Number::new(4), Number::new(2), Token::Division)});
... | code_fim | hard | {
"lang": "rust",
"repo": "weijunji/wcal",
"path": "/src/generator/calculator_f.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("STAMP: {}", l.number);
}
#[test]
fn test_non_copy_types() {
let l = Label { number: 3 };
print(l);
println!("My label number is: {}", l.number);
}
use std::rc::Rc;
#[test]
fn test_rc() {
let s: Rc<String> = Rc::new("shirataki".to_string());
let t: Rc<String> = s.clone(... | code_fim | hard | {
"lang": "rust",
"repo": "cleonty/programming-rust",
"path": "/ownership/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cleonty/programming-rust path: /ownership/src/main.rs
fn main() {
print_padovan();
}
fn print_padovan() {
let mut padovan = vec![1, 1, 1]; // allocated here
for i in 3..10 {
let next = padovan[i - 3] + padovan[i - 2];
padovan.push(next);
}
println!("P(1..10) ... | code_fim | hard | {
"lang": "rust",
"repo": "cleonty/programming-rust",
"path": "/ownership/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.data.attribs.insert(
glh::StockShader::attrib_name_texture_coords().to_string(),
data,
);
self
}
pub fn vertex_color<'a, T>(&'a mut self, generator: T) -> &'a mut Self
where
T: Fn(&Self, &mut Vec<f32>, usize),
{
... | code_fim | hard | {
"lang": "rust",
"repo": "Hperigo/Pira",
"path": "/src/utils/geo/rect.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hperigo/Pira path: /src/utils/geo/rect.rs
use super::*;
use crate::gl_helper as glh;
pub struct Rect {
pub data: GeometryData,
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}
impl Rect {
pub fn new(x: f32, y: f32, width: f32, height: f32) -> Rect ... | code_fim | hard | {
"lang": "rust",
"repo": "Hperigo/Pira",
"path": "/src/utils/geo/rect.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> command.arg(params.text);
match params.typ {
MessageType::Info => command.arg("--icon=dialog-information"),
MessageType::Warning => command.arg("--icon=dialog-warning"),
MessageType::Error => command.arg("--icon=dialog-error"),
};
command.arg("--title");
comma... | code_fim | hard | {
"lang": "rust",
"repo": "maroider/native-dialog-rs",
"path": "/src/impl/gnu/message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match params.typ {
MessageType::Info => command.arg("--icon=dialog-information"),
MessageType::Warning => command.arg("--icon=dialog-warning"),
MessageType::Error => command.arg("--icon=dialog-error"),
};
command.arg("--title");
command.arg(params.title);
let ... | code_fim | hard | {
"lang": "rust",
"repo": "maroider/native-dialog-rs",
"path": "/src/impl/gnu/message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maroider/native-dialog-rs path: /src/impl/gnu/message.rs
use super::{should_use, UseCommand};
use crate::{Dialog, Error, MessageAlert, MessageConfirm, MessageType, Result};
use std::process::Command;
impl Dialog for MessageAlert<'_> {
type Output = ();
fn show(self) -> Result<Self::Out... | code_fim | hard | {
"lang": "rust",
"repo": "maroider/native-dialog-rs",
"path": "/src/impl/gnu/message.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/style-servo/components/script/dom/htmltablerowelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mo... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/script/dom/htmltablerowelement.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // https://html.spec.whatwg.org/multipage/#dom-tr-bgcolor
make_legacy_color_setter!(SetBgColor, "bgcolor");
// https://html.spec.whatwg.org/multipage/#dom-tr-cells
fn Cells(&self) -> DomRoot<HTMLCollection> {
self.cells.or_init(|| {
let window = window_from_node(self);... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/script/dom/htmltablerowelement.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libdist-rs/libchatter-rs path: /examples/sink-exp/stream/src/main.rs
use clap::{load_yaml, App};
use tokio::{io::AsyncWriteExt, net::{TcpStream}};
use futures::SinkExt;
use tokio_util::codec::FramedWrite;
use util::codec::EnCodec;
use std::{error::Error, time::SystemTime};
use std::fs::File;
use... | code_fim | hard | {
"lang": "rust",
"repo": "libdist-rs/libchatter-rs",
"path": "/examples/sink-exp/stream/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let indicator = vec![0 as u8;1];
let mut senders = Vec::new();
for addr in relays {
let conn = TcpStream::connect(addr).await
.expect("failed to connected one of the relays");
conn.set_nodelay(true).unwrap();
let (_rd, mut wr) = conn
.into_split(... | code_fim | hard | {
"lang": "rust",
"repo": "libdist-rs/libchatter-rs",
"path": "/examples/sink-exp/stream/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
if let TokenResult::Some(_) = self.parse_binding_rest_element()? {
break;
}
if let TokenResult::Some(_) = self.parse_binding_pattern()? {
opt_value!(self.parse_initializer()?);
} else if let TokenResult::Some(_... | code_fim | hard | {
"lang": "rust",
"repo": "loganfsmyth/jsparse-rs",
"path": "/src/parser/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn parse_function_params(&mut self) -> OptResult<()> {
try_value!(self.punc(tokens::PunctuatorToken::ParenOpen));
loop {
if let TokenResult::Some(_) = self.parse_binding_rest_element()? {
break;
}
if let TokenResult::Some(_) = s... | code_fim | hard | {
"lang": "rust",
"repo": "loganfsmyth/jsparse-rs",
"path": "/src/parser/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loganfsmyth/jsparse-rs path: /src/parser/functions.rs
use tokenizer::{Tokenizer, tokens};
use parser::{Parser, Flag, LookaheadResult};
use parser::utils::{OptResult, TokenResult};
// use parser::utils;
impl<'code, T> Parser<'code, T>
where
T: Tokenizer<'code>
{
pub fn parse_function_dec... | code_fim | hard | {
"lang": "rust",
"repo": "loganfsmyth/jsparse-rs",
"path": "/src/parser/functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut fout = try!(File::create(output));
try!(fout.write_fmt(format_args!("{:<30} | MP | W | D | L | P\n", "Team")));
for &(ref nm, st) in &ordered {
try!(fout.write_fmt(
format_args!("{:<30} | {} | {} | {} | {} | {}\n",
nm, st.win + st.l... | code_fim | hard | {
"lang": "rust",
"repo": "scturtle/fun.rs",
"path": "/exercism/tournament.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scturtle/fun.rs path: /exercism/tournament.rs
#![feature(slice_patterns)]
use std::path::Path;
use std::fs::File;
use std::io::{BufRead,BufReader,Write,Error};
use std::collections::HashMap;
#[derive(Copy, Clone)]
struct Status { win: isize, loss: isize, draw: isize }
<|fim_suffix|> let mut... | code_fim | hard | {
"lang": "rust",
"repo": "scturtle/fun.rs",
"path": "/exercism/tournament.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<CliSendTo> for SendTo {
fn from(item: CliSendTo) -> Self {
match item {
CliSendTo::Receiver(cli_receiver) => {
let receiver = Receiver::from(cli_receiver);
SendTo::Receiver(receiver)
}
}
}
}<|fim_prefix|>// repo: Fro... | code_fim | hard | {
"lang": "rust",
"repo": "FroVolod/cli_dialoguer_strum_2",
"path": "/src/command/on_off_line_mode/server/sender/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FroVolod/cli_dialoguer_strum_2 path: /src/command/on_off_line_mode/server/sender/mod.rs
use structopt::StructOpt;
use dialoguer::{
Input,
};
mod receiver;
use receiver::{
Receiver,
CliReceiver,
ActionSubcommand,
};
#[derive(Debug)]
pub struct Sender {
pub sender_account_id... | code_fim | hard | {
"lang": "rust",
"repo": "FroVolod/cli_dialoguer_strum_2",
"path": "/src/command/on_off_line_mode/server/sender/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Enet4/propan path: /src/level/mod.rs
use std::ffi::OsStr;
use std::fs::{File, read_dir};
use std::path::{Path, PathBuf};
use controller::LevelId;
use itertools::process_results;
use na::Vector2;
use serde_json::{from_reader, to_writer_pretty as to_writer};
use util::DynResult;
mod v0;
pub mod i... | code_fim | hard | {
"lang": "rust",
"repo": "Enet4/propan",
"path": "/src/level/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_version<V: Into<String>>(&mut self, v: V) {
self.version = v.into();
}
pub fn map(&self) -> &Map {
&self.map
}
pub fn map_mut(&mut self) -> &mut Map {
&mut self.map
}
pub fn ball_position(&self) -> Vector2<f32> {
Vector2::new(self.b... | code_fim | hard | {
"lang": "rust",
"repo": "Enet4/propan",
"path": "/src/level/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let group_answers: Vec<&str> = vec!["a", "b", "c"];
let yes_count = count_group_questions_all_yes(&group_answers);
assert_eq!(yes_count, 0);
}
#[test]
fn test_count_group_all_yes_example_3() {
let group_answers: Vec<&str> = vec!["ab" , "ac"];
let yes_co... | code_fim | hard | {
"lang": "rust",
"repo": "mvernacc/advent_of_code_2020",
"path": "/day6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvernacc/advent_of_code_2020 path: /day6/src/main.rs
use std::fs;
fn main() {
let text = fs::read_to_string("./input.txt").unwrap();
let group_strings = text
.trim()
.split("\n\n")
.collect::<Vec<&str>>();
let mut groups_answers = Vec::<Vec::<&str>>::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "mvernacc/advent_of_code_2020",
"path": "/day6/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_count_group_with_yes_example_2() {
let group_answers: Vec<&str> = vec!["a", "b", "c"];
let yes_count = count_group_questions_with_a_yes(&group_answers);
assert_eq!(yes_count, 3);
}
#[test]
fn test_count_group_with_yes_example_3() {
let g... | code_fim | hard | {
"lang": "rust",
"repo": "mvernacc/advent_of_code_2020",
"path": "/day6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let record = Record::new(
record::Key::Contig,
record::Value::String(String::from("VCF4.3")),
);
assert_eq!(
Contig::try_from(record),
Err(TryFromRecordError::InvalidRecord)
);
}
#[test]
fn test_try_from_record_f... | code_fim | hard | {
"lang": "rust",
"repo": "luccasmmg/noodles",
"path": "/noodles-vcf/src/header/contig.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luccasmmg/noodles path: /noodles-vcf/src/header/contig.rs
//! VCF header contig record and key.
mod key;
use std::{convert::TryFrom, error, fmt, num};
use indexmap::IndexMap;
use crate::record::chromosome;
use super::{record, Record};
use self::key::Key;
/// A VCF header contig record (`c... | code_fim | hard | {
"lang": "rust",
"repo": "luccasmmg/noodles",
"path": "/noodles-vcf/src/header/contig.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(matches!(
Contig::try_from(record),
Err(TryFromRecordError::InvalidKey(_))
));
}
#[test]
fn test_try_from_record_for_contig_with_an_invalid_id() {
let record = Record::new(
record::Key::Contig,
record::Value::Stru... | code_fim | hard | {
"lang": "rust",
"repo": "luccasmmg/noodles",
"path": "/noodles-vcf/src/header/contig.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix-revwalk/tests/revwalk.rs
mod graph {
mod commit {
#[test]
fn size_of_commit() {
assert_eq!(
std::mem::size_of::<gix_revwalk::graph::<|fim_suffix|>of these, so they shouldn't grow unexpectedly"
)
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-revwalk/tests/revwalk.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>of these, so they shouldn't grow unexpectedly"
)
}
}
}<|fim_prefix|>// repo: Byron/gitoxide path: /gix-revwalk/tests/revwalk.rs
mod graph {
mod commit {
#[test]
fn size_of_commit() {
assert_eq!(
std::mem::size_of::<gix_revwalk::graph... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-revwalk/tests/revwalk.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let net_config: NetbricksConfiguration = get_default_netbricks_config(config);
// Initialize Netbricks and return a handle.
match initialize_system(&net_config) {
Ok(net_context) => {
return net_context;
}
Err(ref err) => {
error!("Error during... | code_fim | hard | {
"lang": "rust",
"repo": "SymbioticLab/Kayak",
"path": "/db/src/bin/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SymbioticLab/Kayak path: /db/src/bin/server.rs
use db::log::*;
use db::e2d2::allocators::CacheAligned;
use db::e2d2::config::{NetbricksConfiguration, PortConfiguration};
use db::e2d2::interface::*;
use db::e2d2::native::zcsi;
use db::e2d2::scheduler::Executable;
use db::e2d2::scheduler::NetBri... | code_fim | hard | {
"lang": "rust",
"repo": "SymbioticLab/Kayak",
"path": "/db/src/bin/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Custom signal handler for stack overflows.
extern "C" fn handle_sigsegv(
_signum: i32,
_siginfo: *mut libc::siginfo_t,
context: *mut libc::c_void,
) {
// We can't do much as it's different stack all together; swapcontext() might help.
// Enter into an infinite while loop so that th... | code_fim | hard | {
"lang": "rust",
"repo": "SymbioticLab/Kayak",
"path": "/db/src/bin/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn armor(&self) -> u32 {
self.armor
}
}<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2015/day21/src/item.rs
#[derive(Debug)]
pub struct Item {
cost: u32,
damage: u32,
armor: u32
}
<|fim_middle|>impl Item {
pub fn new_weapon(cost: u32, damage: u32) -> Item ... | code_fim | hard | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2015/day21/src/item.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2015/day21/src/item.rs
#[derive(Debug)]
pub struct Item {
cost: u32,
damage: u32,
armor: u32
}
impl Item {
pub fn new_weapon(cost: u32, damage: u32) -> Item {
Item { cost: cost, damage: damage, armor: 0 }
}
pub fn new_armor(cos... | code_fim | medium | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2015/day21/src/item.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::pipeline;
#[test]
fn constructs_a_pipeline() {
let actual = pipeline(
r#"
open los_tres_amigos.txt
| from-csv
| get rusty_luck
| into int
| math sum
... | code_fim | hard | {
"lang": "rust",
"repo": "nushell/nushell",
"path": "/crates/nu-test-support/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn shell_os_paths() -> Vec<std::path::PathBuf> {
let mut original_paths = vec![];
if let Some(paths) = std::env::var_os(NATIVE_PATH_ENV_VAR) {
original_paths = std::env::split_paths(&paths).collect::<Vec<_>>();
}
original_paths
}
#[cfg(test)]
mod tests {
use super::pipel... | code_fim | hard | {
"lang": "rust",
"repo": "nushell/nushell",
"path": "/crates/nu-test-support/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-test-support/src/lib.rs
pub mod commands;
pub mod fs;
pub mod locale_override;
pub mod macros;
pub mod playground;
// Needs to be reexported for `nu!` macro
pub use nu_path;
pub struct Outcome {
pub out: String,
pub err: String,
}
#[cfg(windows)]
pub co... | code_fim | hard | {
"lang": "rust",
"repo": "nushell/nushell",
"path": "/crates/nu-test-support/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JoelAtDeluxe/AdventOfCode2015-rust path: /day23/src/main.rs
use day23;
use std::collections::HashMap;
fn main() {
let path = "input.txt";
let data = std::fs::read_to_string(path).unwrap_or_else(|_| panic!("Failed to open: {}", path));
<|fim_suffix|> // part 2
part_2_registers.i... | code_fim | hard | {
"lang": "rust",
"repo": "JoelAtDeluxe/AdventOfCode2015-rust",
"path": "/day23/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut part_2_registers = registers.clone();
//part 1
let result_registers = day23::run(&commands, registers);
println!("Register B after running the program: {}", result_registers.get(&'b').unwrap());
// part 2
part_2_registers.insert('a', 1);
let result_registers = day23:... | code_fim | hard | {
"lang": "rust",
"repo": "JoelAtDeluxe/AdventOfCode2015-rust",
"path": "/day23/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // part 2
part_2_registers.insert('a', 1);
let result_registers = day23::run(&commands, part_2_registers);
println!("Register B after re-running the program: {}", result_registers.get(&'b').unwrap());
}<|fim_prefix|>// repo: JoelAtDeluxe/AdventOfCode2015-rust path: /day23/src/main.rs
use... | code_fim | hard | {
"lang": "rust",
"repo": "JoelAtDeluxe/AdventOfCode2015-rust",
"path": "/day23/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vanhtuan0409/exercism path: /rust/two-bucket/src/lib.rs
use std::cmp::{max, min};
use std::collections::VecDeque;
#[derive(PartialEq, Eq, Debug, Clone, Hash)]
pub enum Bucket {
One,
Two,
}
/// A struct to hold your results in.
#[derive(PartialEq, Eq, Debug)]
pub struct BucketStats {
... | code_fim | hard | {
"lang": "rust",
"repo": "vanhtuan0409/exercism",
"path": "/rust/two-bucket/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ret = vec![];
ret.push(self.next_state(self.bucket1.fill_full(), self.bucket2.clone()));
ret.push(self.next_state(self.bucket1.clone(), self.bucket2.fill_full()));
ret.push(self.next_state(self.bucket1.clone(), self.bucket2.empty()));
ret.push(self.next_stat... | code_fim | hard | {
"lang": "rust",
"repo": "vanhtuan0409/exercism",
"path": "/rust/two-bucket/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.current == 0
}
fn free_space(&self) -> u8 {
self.capacity - self.current
}
fn fill(&self, amount: u8) -> Self {
Self {
current: min(self.current + amount, self.capacity),
..self.to_owned()
}
}
fn remove(&self, amount: ... | code_fim | hard | {
"lang": "rust",
"repo": "vanhtuan0409/exercism",
"path": "/rust/two-bucket/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: des256/classic-e path: /src/gpu/vulkan/fence.rs
// E - GPU (Vulkan) - Fence
// Desmond Germans, 2020
use {
crate::*,
std::{
ptr::null_mut,
mem::MaybeUninit,
rc::Rc,
},
sys_sys::*,
};
<|fim_suffix|>impl Session {
pub fn create_fence(self: &Rc<Self>) ... | code_fim | medium | {
"lang": "rust",
"repo": "des256/classic-e",
"path": "/src/gpu/vulkan/fence.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let info = VkFenceCreateInfo {
sType: VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
pNext: null_mut(),
flags: VK_FENCE_CREATE_SIGNALED_BIT,
};
let mut vk_fence = MaybeUninit::uninit();
match unsafe { vkCreateFence(self.vk_device,&info,null_mut(),v... | code_fim | medium | {
"lang": "rust",
"repo": "des256/classic-e",
"path": "/src/gpu/vulkan/fence.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn reset(&self) {
unsafe { vkResetFences(self.session.vk_device,1,&self.vk_fence) };
}
}
impl Drop for Fence {
fn drop(&mut self) {
unsafe { vkDestroyFence(self.session.vk_device,self.vk_fence,null_mut()) };
}
}<|fim_prefix|>// repo: des256/classic-e path: /src/gpu/vu... | code_fim | hard | {
"lang": "rust",
"repo": "des256/classic-e",
"path": "/src/gpu/vulkan/fence.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jnicklas/graphers path: /graphers_core/src/type_definition.rs
use type_name::TypeName;
use type_kind::TypeKind;
use schema::{Object, Interface, Union, Enum, InputObject, Scalar};
use query::Fragment;
use std::fmt;
use std::error::Error as StdError;
#[derive(Debug, Clone)]
pub enum TypeDefinitio... | code_fim | hard | {
"lang": "rust",
"repo": "jnicklas/graphers",
"path": "/graphers_core/src/type_definition.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn input_object(&self) -> Result<&InputObject, TypeKindError> {
if let &TypeDefinition::InputObject(ref input_object) = self {
Ok(input_object)
} else {
Err(TypeKindError { expected: TypeKind::InputObject, actual: self.kind() })
}
}
pub fn s... | code_fim | hard | {
"lang": "rust",
"repo": "jnicklas/graphers",
"path": "/graphers_core/src/type_definition.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TrAyZeN/rupture path: /src/states/game.rs
use amethyst::{
assets::Handle,
audio::SourceHandle,
controls::{FlyControlTag, HideCursor},
core::{math::Vector3, Transform},
ecs::{Entity, World},
input::{is_key_down, is_mouse_button_down, VirtualKeyCode},
prelude::*,
re... | code_fim | hard | {
"lang": "rust",
"repo": "TrAyZeN/rupture",
"path": "/src/states/game.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn initialize_light(world: &mut World) -> PlayerLight {
let light: Light = PointLight {
color: Rgb::new(1.0, 1.0, 1.0),
intensity: 2.0,
smoothness: 1.0,
..PointLight::default()
}
.into();
let mut transform = Transform::default();
transform.set_translati... | code_fim | hard | {
"lang": "rust",
"repo": "TrAyZeN/rupture",
"path": "/src/states/game.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AnNiran-zz/blockch-ntw-rs path: /src/wire/netaddress.rs
use std::io;
use std::net::{SocketAddr, Ipv6Addr, SocketAddrV4, SocketAddrV6};
use std::time::{Duration, Instant};
use wire::Error{ErrorTORAddress, ErrorAddressLength};
use wire::protocol::{ServiceFlag, IPAddress};
use consensus::encode::{... | code_fim | hard | {
"lang": "rust",
"repo": "AnNiran-zz/blockch-ntw-rs",
"path": "/src/wire/netaddress.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> NetAddress {
timestamp: self.timestamp,
services: self.services,
ip: self.ip,
port: self.port,
}
}
}
implf PartialEq for Address {
fn eq(&self, other: &NetAddress) -> bool {
self.timestamp == other.timestamp &&
... | code_fim | hard | {
"lang": "rust",
"repo": "AnNiran-zz/blockch-ntw-rs",
"path": "/src/wire/netaddress.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
mut wr: Wr,
)-> Result<usize, encode::Error> {
let length = self.timestamp(&mut wr)?
+ self.services.encode(&mut wr)?
+ addr_to_big_endian(self.ip).encode(&mut wr)?
/// Covert port number to big endian from the source endianness
... | code_fim | hard | {
"lang": "rust",
"repo": "AnNiran-zz/blockch-ntw-rs",
"path": "/src/wire/netaddress.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Signs the provided `BlindedToken`
///
/// Returns None if the `BlindedToken` point is not valid.
pub fn sign(&self, P: &BlindedToken) -> Result<SignedToken, TokenError> {
Ok(SignedToken(
(self.k * P
.0
.decompress()
.o... | code_fim | hard | {
"lang": "rust",
"repo": "posix4e/challenge-bypass-ristretto",
"path": "/src/vorpf.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: posix4e/challenge-bypass-ristretto path: /src/vorpf.rs
use core::fmt::Debug;
use clear_on_drop::clear::Clear;
use crypto_mac::MacResult;
use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
use curve25519_dalek::scalar::Scalar;
use digest::generic_array::typenum::U64;
use dig... | code_fim | hard | {
"lang": "rust",
"repo": "posix4e/challenge-bypass-ristretto",
"path": "/src/vorpf.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if view.len() <= offset + index {
Err(format!(
"Out of bound: Maximum index {} is larger than the memory size {}.",
offset + index,
view.len()
))
... | code_fim | hard | {
"lang": "rust",
"repo": "jakub-stastny/wasmer-ruby",
"path": "/src/memory/view.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakub-stastny/wasmer-ruby path: /src/memory/view.rs
//! The `TypedArray`/`MemoryView` WebAssembly classes.
#[rustfmt::skip]
macro_rules! memory_view {
($mod_name:ident over $wasm_type:ty | $bytes_per_element:expr) => {
pub mod $mod_name {
use crate::error::unwrap_or_rai... | code_fim | hard | {
"lang": "rust",
"repo": "jakub-stastny/wasmer-ruby",
"path": "/src/memory/view.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1aim/media-type path: /src/lib.rs
//! # Media TYpe
//!
#![cfg_attr(feature = "inner-bench", feature(test))]
//#![deny(warnings)]
//#![deny(missing_docs)]
//#![deny(missing_debug_implementations)]
#[cfg(all(feature = "inner-bench", test))]
extern crate test;
extern crate percent_encoding;
ext... | code_fim | medium | {
"lang": "rust",
"repo": "1aim/media-type",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod seal {
// trick to make implementing traits in external crates impossible
pub trait Seal {}
}<|fim_prefix|>// repo: 1aim/media-type path: /src/lib.rs
//! # Media TYpe
//!
#![cfg_attr(feature = "inner-bench", feature(test))]
//#![deny(warnings)]
//#![deny(missing_docs)]
//#![deny(missing_deb... | code_fim | medium | {
"lang": "rust",
"repo": "1aim/media-type",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libpasta/libpasta path: /src/key/mod.rs
//! The `key` module is for managing key sources.
//!
//! The idea is that a running application can dynamically insert keys into
//! the key store, which are used for producing and verifying hashes.
#![allow(dead_code)]
<|fim_suffix|>/// Structure used a... | code_fim | hard | {
"lang": "rust",
"repo": "libpasta/libpasta",
"path": "/src/key/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let digest = digest::digest(&digest::SHA512_256, key);
let key_id = BASE64_NOPAD.encode(digest.as_ref());
let _ = self
.store
.write()
.expect("could not get write on key store")
.insert(key_id.clone(), key.to_vec());
key_id
... | code_fim | hard | {
"lang": "rust",
"repo": "libpasta/libpasta",
"path": "/src/key/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: groumache/project-euler-rust path: /src/problem041to050.rs
// What is the largest n-digit pandigital prime below 'max'?
pub mod p041 {
use crate::useful_func::digits::{no_double, num_to_digits};
use crate::useful_func::prime_numbers::primes_range;
pub fn v1(max: u32) -> u32 {
... | code_fim | hard | {
"lang": "rust",
"repo": "groumache/project-euler-rust",
"path": "/src/problem041to050.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if w_sum == p && w_size > sum_len {
prime = p;
sum_len = w_size;
break 'outer;
} else if w_sum >= p {
break 'outer;
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "groumache/project-euler-rust",
"path": "/src/problem041to050.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ofir-popowski/advent_of_code path: /day4/src/validations.rs
pub mod validations {
use regex::Regex;
fn validate_byr(val: &str) -> bool {
match val.parse::<i32>() {
Ok(num) => (1920..=2002).contains(&num),
Err(_) => false,
}
}
fn validate_... | code_fim | hard | {
"lang": "rust",
"repo": "ofir-popowski/advent_of_code",
"path": "/day4/src/validations.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn validate_pid(val: &str) -> bool {
let pattern = Regex::new("^[0-9]{9}$").unwrap();
pattern.is_match(val)
}
#[allow(unused_variables)]
fn validate_cid(val: &str) -> bool {
true
}
pub fn is_field_valid(field_name: &str, val: &str) -> bool {
match ... | code_fim | hard | {
"lang": "rust",
"repo": "ofir-popowski/advent_of_code",
"path": "/day4/src/validations.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let edge_prob = 1. - (1. - g.gen_range(0., 1.)) * (1. - g.gen_range(0., 1.));
let edges = ((nodes as f64).powi(2) * edge_prob) as usize;
let mut gr = Graph::with_capacity(nodes, edges);
let mut nodes = 0;
for _ in 0..tall {
let cur_nodes = g.gen_range(0,... | code_fim | hard | {
"lang": "rust",
"repo": "bluss/bluss.github.io",
"path": "/petgraph/tests/quickcheck.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bluss/bluss.github.io path: /petgraph/tests/quickcheck.rs
let num_pos_post = g.raw_nodes().iter().filter(|n| n.weight >= 0).count();
assert_eq!(num_negs_post, 0);
assert_eq!(removed, num_negs);
assert_eq!(num_negs + g.node_count(), nodes);
assert_eq!(num_pos... | code_fim | hard | {
"lang": "rust",
"repo": "bluss/bluss.github.io",
"path": "/petgraph/tests/quickcheck.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bluss/bluss.github.io path: /petgraph/tests/quickcheck.rs
ter(|n| n.weight >= 0).count();
assert_eq!(num_negs_post, 0);
assert_eq!(removed, num_negs);
assert_eq!(num_negs + g.node_count(), nodes);
assert_eq!(num_pos_post, g.node_count());
// check against... | code_fim | hard | {
"lang": "rust",
"repo": "bluss/bluss.github.io",
"path": "/petgraph/tests/quickcheck.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> SEL59_R::new(((self.bits >> 8) & 0x7f) as u8)
}
}
impl W {
#[doc = "Bits 0:6 - Input (XBARA_INn) to be muxed to XBARA_OUT58 (refer to Functional Description section for input/output assignment)"]
#[inline(always)]
pub fn sel58(&mut self) -> SEL58_W {
SEL58_W { w: self }
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-xbara1/src/sel29.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-xbara1/src/sel29.rs
#[doc = "Reader of register SEL29"]
pub type R = crate::R<u16, super::SEL29>;
#[doc = "Writer for register SEL29"]
pub type W = crate::W<u16, super::SEL29>;
#[doc = "Register SEL29 `reset()`'s with value 0"]
impl crate::ResetV... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-xbara1/src/sel29.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct RatingClient {
client: ::grpcio::Client,
}
impl RatingClient {
pub fn new(channel: ::grpcio::Channel) -> Self {
RatingClient {
client: ::grpcio::Client::new(channel),
}
}
pub fn generate_bill_opt(&self, req: &super::invoice::RatingR... | code_fim | hard | {
"lang": "rust",
"repo": "ExternalReality/invoices",
"path": "/grpc_protocol/src/invoice_grpc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>const METHOD_RATING_GENERATE_BILL: ::grpcio::Method<super::invoice::RatingRequest, super::invoice::RatingReply> = ::grpcio::Method {
ty: ::grpcio::MethodType::Unary,
name: "/Rating/GenerateBill",
req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
resp_mar: ::grpc... | code_fim | hard | {
"lang": "rust",
"repo": "ExternalReality/invoices",
"path": "/grpc_protocol/src/invoice_grpc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ExternalReality/invoices path: /grpc_protocol/src/invoice_grpc.rs
// This file is generated. Do not edit
// @generated
// https://github.com/Manishearth/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy)]
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(box_pointers)]
#![allow(dead_... | code_fim | hard | {
"lang": "rust",
"repo": "ExternalReality/invoices",
"path": "/grpc_protocol/src/invoice_grpc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match state.message_queue.try_recv() {
Ok(ui_message) =>
match ui_message {
UIMessage::Update(update_data) => {
state.text_input.text = format!("{:?}", update_data.operations);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "shohamh/xi-azul",
"path": "/src/editor/ui_model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn text_mouse_down(
state: &mut AppState<EditorUIModel>,
event: WindowEvent<EditorUIModel>,
) -> UpdateScreen {
println!("mouse down event: {:#?}", event.cursor_relative_to_item);
state.add_daemon(Daemon::unique(DaemonCallback(xi_client_daemon)));
UpdateScreen::Redraw
}
fn text_mouse_... | code_fim | hard | {
"lang": "rust",
"repo": "shohamh/xi-azul",
"path": "/src/editor/ui_model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shohamh/xi-azul path: /src/editor/ui_model.rs
use std::string::String;
use azul::prelude::*;
use azul::text_layout::*;
use azul::widgets::text_input::*;
use crossbeam::channel::Receiver;
use futures::future::Future;
use futures::future::ok;
use futures::stream::Stream;
use tokio::runtime::curre... | code_fim | hard | {
"lang": "rust",
"repo": "shohamh/xi-azul",
"path": "/src/editor/ui_model.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leo60228/switchbot path: /src/main.rs
use async_std::prelude::*;
use std::time::Instant;
#[async_std::main]
async fn main() {
let mut capture = switchbot::start_capture().un<|fim_suffix|>64();
let fps = 1.0 / time;
last = now;
println!("{} frames in {:.3} seconds ({:... | code_fim | hard | {
"lang": "rust",
"repo": "leo60228/switchbot",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>64();
let fps = 1.0 / time;
last = now;
println!("{} frames in {:.3} seconds ({:.3}fps)", frames, diff, fps);
}
}<|fim_prefix|>// repo: leo60228/switchbot path: /src/main.rs
use async_std::prelude::*;
use std::time::Instant;
#[async_std::main]
async fn main() {
let mut ca... | code_fim | hard | {
"lang": "rust",
"repo": "leo60228/switchbot",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pjuangph/python2rust path: /12_modules/rust/reexports.rs
mod family {
mod parents {
pub fn call_mom() {}
pub fn call_brother() {}
}
// re-export
pub use self::parents::{call_brother, call_mom};
}
<|fim_suffix|> family::call_mom();
family::call_brother();
... | code_fim | easy | {
"lang": "rust",
"repo": "pjuangph/python2rust",
"path": "/12_modules/rust/reexports.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> family::call_mom();
family::call_brother();
//family::parents::call_brother();
}<|fim_prefix|>// repo: pjuangph/python2rust path: /12_modules/rust/reexports.rs
mod family {
mod parents {
pub fn call_mom() {}
pub fn call_brother() {}
}
<|fim_middle|> // re-export
... | code_fim | medium | {
"lang": "rust",
"repo": "pjuangph/python2rust",
"path": "/12_modules/rust/reexports.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pinkforest/multiparty path: /src/headers.rs
//! Headers
use std::error::Error as StdError;
use std::fmt::{self, Debug, Display};
use std::str;
use bytes::Bytes;
/// Raw unparsed headers
#[derive(Debug, Clone)]
pub struct RawHeaders {
headers: Vec<(Bytes, Bytes)>,
}
impl RawHeaders {
... | code_fim | hard | {
"lang": "rust",
"repo": "pinkforest/multiparty",
"path": "/src/headers.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn ascii_no_cd() {
let headers = vec![(
Bytes::from_static(b"Content-Disposition"),
Bytes::from_static(b"form-data; name=\"abcd\"; filename=\"test.txt\""),
)];
let headers = RawHeaders::new(headers);
let parsed = headers.parse().unwr... | code_fim | hard | {
"lang": "rust",
"repo": "pinkforest/multiparty",
"path": "/src/headers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vinc/littlewing path: /src/lib.rs
//! Little Wing is a chess engine rated at 2050+ ELO, compatible with both UCI
//! and XBoard protocols, with a nice CLI, and a documented library.
//!
//! # Example
//!
//! ```rust
//! use littlewing::chess::*;
//!
//! // Byrne vs Fischer (1956)
//! let fen = "... | code_fim | hard | {
"lang": "rust",
"repo": "vinc/littlewing",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Evaluation algorithms
pub mod eval;
/// Forsyth–Edwards Notation support
pub mod fen;
/// Game engine
pub mod game;
/// Portable Game Notation support
pub mod pgn;
/// Piece move generator
pub mod piece_move_generator;
/// Piece move notation
pub mod piece_move_notation;
/// Piece type
pub mod p... | code_fim | hard | {
"lang": "rust",
"repo": "vinc/littlewing",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_empty_populate_permutations() {
let mut shapley = Shapley::new(1.0);
assert_eq!(shapley.populate_permutations(), vec![vec![]]);
}
#[test]
fn test_populate_permutations() {
let mut shapley = Shapley::new(1.0);
shapley.add_player(Player::n... | code_fim | hard | {
"lang": "rust",
"repo": "djustinf/gtrust",
"path": "/src/shapley.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.