text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: SolarLiner/gargantua path: /gargantua/src/texture.rs
use color::consts::SYSTEM_SRGB;
use color::Color;
use image::{open, DynamicImage, GenericImageView, Pixel};
use nalgebra::Vector2;
use crate::utils::rgba_to_color;
#[derive(Clone, Debug)]
pub enum TextureMode {
Clamp,
Repeat,
Transparent,... | code_fim | hard | {
"lang": "rust",
"repo": "SolarLiner/gargantua",
"path": "/gargantua/src/texture.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pvva/leetcode-rust path: /problems_0001_0100/examples/36_valid_sudoku.rs
/*
https://leetcode.com/problems/valid-sudoku/
Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
Each row must contain the digits 1-9 without repetiti... | code_fim | hard | {
"lang": "rust",
"repo": "pvva/leetcode-rust",
"path": "/problems_0001_0100/examples/36_valid_sudoku.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in 0..9 as usize {
let mut row: usize = 0;
for y in 0..9 as usize {
match board[x][y] {
'.' => continue,
c => {
let i = 1 << (c as usize - '0' as usize);
let bi = (... | code_fim | hard | {
"lang": "rust",
"repo": "pvva/leetcode-rust",
"path": "/problems_0001_0100/examples/36_valid_sudoku.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TestCase {
pub fn new(file_path: PathBuf) -> TestCase {
TestCase { file_path }
}
/// runs the input file by compiling it to gcc
/// and returns the status code of the resulting
/// program
fn gcc_workdir(&self) -> io::Result<PathBuf> {
let dir = self.workdir()?... | code_fim | hard | {
"lang": "rust",
"repo": "NLincoln/u-cc",
"path": "/u-cc-test/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(self.workdir()?.join(self.filename()?.with_extension("o")))
}
fn asm_file_path(&self) -> io::Result<PathBuf> {
Ok(self.workdir()?.join(self.filename()?.with_extension("asm")))
}
fn executable_file_path(&self) -> io::Result<PathBuf> {
Ok(self.workdir()?.join("out"... | code_fim | hard | {
"lang": "rust",
"repo": "NLincoln/u-cc",
"path": "/u-cc-test/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NLincoln/u-cc path: /u-cc-test/src/main.rs
use colored::*;
use std::path::{Path, PathBuf};
use std::{env, fs, io};
fn workdir() -> io::Result<PathBuf> {
let pid = std::process::id();
let temp_dir = std::env::temp_dir().join(&format!("u-cc-test-{}", pid));
if !temp_dir.exists() {
... | code_fim | hard | {
"lang": "rust",
"repo": "NLincoln/u-cc",
"path": "/u-cc-test/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hlfbt/apn-db path: /src/cache.rs
use std::borrow::Cow;
use std::fs::{create_dir_all, File};
use std::path::{PathBuf, Path};
use std::error::Error;
use std::io::{Write, Read};
pub struct ApnFile {
path: String,
url: String
}
impl ApnFile {
pub fn new(path: &str, url: &str) -> ApnFil... | code_fim | hard | {
"lang": "rust",
"repo": "hlfbt/apn-db",
"path": "/src/cache.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut body: String = match reqwest::get(&self.url) {
Ok(mut req) => match req.text() {
Ok(text) => text,
_ => return Err("unable to fetch response")
},
_ => return Err("unable to place request")
};
let decoded_b... | code_fim | hard | {
"lang": "rust",
"repo": "hlfbt/apn-db",
"path": "/src/cache.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nhatquangsin/steit path: /steit/src/impls/tuple.rs
#![allow(non_snake_case)]
use std::io::{self, Read};
use crate::{
de::{Deserialize, Reader},
rt::SizeCache,
ser::Serialize,
wire_fmt::{HasWireType, WireType},
};
macro_rules! impl_tuple {
( $( $name:ident )+ ) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "nhatquangsin/steit",
"path": "/steit/src/impls/tuple.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl<$($name: Deserialize),+> Deserialize for ($($name),+) {
fn merge(&mut self, reader: &mut Reader<impl io::Read>) -> io::Result<()> {
$(let $name = $name::deserialize_nested($name::WIRE_TYPE, reader)?;)+
*self = ($($name),+);
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "nhatquangsin/steit",
"path": "/steit/src/impls/tuple.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ChunkWriter {
pub fn write(mut self, done_offset: u64, buf: &[u8]) {
unimplemented!()
}
}
// impl Deref for ChunkWriter {}
// impl DerefMut for ChunkWriter {}<|fim_prefix|>// repo: AhmedKorim/atomic-file path: /src/chunk_writer.rs
use crate::AtomicFile;
use std::ops::DerefMut;
<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "AhmedKorim/atomic-file",
"path": "/src/chunk_writer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AhmedKorim/atomic-file path: /src/chunk_writer.rs
use crate::AtomicFile;
use std::ops::DerefMut;
<|fim_suffix|>impl ChunkWriter {
pub fn write(mut self, done_offset: u64, buf: &[u8]) {
unimplemented!()
}
}
// impl Deref for ChunkWriter {}
// impl DerefMut for ChunkWriter {}<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "AhmedKorim/atomic-file",
"path": "/src/chunk_writer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mazurwiktor/memlyzer path: /src/message.rs
use std::cmp::Ordering;
#[derive(Debug, Clone)]
pub struct Message {
pub content: String,
magic_number: u32,
}
<|fim_suffix|>impl PartialOrd for Message {
fn partial_cmp(&self, other: &Message) -> Option<Ordering> {
Some(self.cmp(o... | code_fim | hard | {
"lang": "rust",
"repo": "mazurwiktor/memlyzer",
"path": "/src/message.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PartialEq for Message {
fn eq(&self, other: &Message) -> bool {
self.magic_number == other.magic_number
}
}
impl Eq for Message {}
impl Ord for Message {
fn cmp(&self, other: &Message) -> Ordering {
self.magic_number.cmp(&other.magic_number)
}
}
impl PartialOrd for ... | code_fim | medium | {
"lang": "rust",
"repo": "mazurwiktor/memlyzer",
"path": "/src/message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.magic_number.cmp(&other.magic_number)
}
}
impl PartialOrd for Message {
fn partial_cmp(&self, other: &Message) -> Option<Ordering> {
Some(self.cmp(other))
}
}<|fim_prefix|>// repo: mazurwiktor/memlyzer path: /src/message.rs
use std::cmp::Ordering;
#[derive(Debug, Clone)... | code_fim | hard | {
"lang": "rust",
"repo": "mazurwiktor/memlyzer",
"path": "/src/message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pulakk/learning-rust path: /8 - Common collections/exercises/mean-median-mode/src/main.rs
use std::io::{Write, stdout, stdin};
use std::collections::HashMap;
fn main() {
let mut input = String::new();
print!("Enter a list of numbers: ");
// example input: 22 120 23 100 24 22 23 24
... | code_fim | hard | {
"lang": "rust",
"repo": "pulakk/learning-rust",
"path": "/8 - Common collections/exercises/mean-median-mode/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut frequency = HashMap::new();
for number in numbers { *(frequency.entry(number).or_insert(0)) += 1 };
println!("Frequency of occurence: {:?}", frequency);
println!(
"Mode: {:?}",
frequency.iter()
.fold(
(&0i32, &0i32),
|a, b... | code_fim | medium | {
"lang": "rust",
"repo": "pulakk/learning-rust",
"path": "/8 - Common collections/exercises/mean-median-mode/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Median is {}", if size % 2 == 0 {
(numbers[(size/2) as usize] + numbers[(size-1) as usize/2]) as f64 / 2f64
} else {
numbers[(size/2) as usize] as f64
});
let mut frequency = HashMap::new();
for number in numbers { *(frequency.entry(number).or_insert(0)) += 1... | code_fim | medium | {
"lang": "rust",
"repo": "pulakk/learning-rust",
"path": "/8 - Common collections/exercises/mean-median-mode/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use crate::{
data_binding::{DataBindingStore, DataBindingMap},
button::*,
view::*,
image::*,
label::*,
slider::*,
check_box::*,
drop_down::*,
radio_button::*,
text_input::*,
link_label::*,
list_view::*,
slide_panel::*,
desktop_window::*,
scro... | code_fim | hard | {
"lang": "rust",
"repo": "makepad/makepad",
"path": "/widgets/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makepad/makepad path: /widgets/src/lib.rs
pub use makepad_draw::makepad_platform;
pub use makepad_draw;
pub use makepad_derive_widget;
pub use makepad_draw::*;
pub use makepad_derive_widget::*;
pub mod button;
pub mod label;
pub mod image;
pub mod link_label;
pub mod drop_down;
pub mod popup_m... | code_fim | hard | {
"lang": "rust",
"repo": "makepad/makepad",
"path": "/widgets/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn live_design(cx: &mut Cx) {
makepad_draw::live_design(cx);
crate::debug_view::live_design(cx);
crate::fold_header::live_design(cx);
crate::splitter::live_design(cx);
crate::base::live_design(cx);
crate::theme_desktop_dark::live_design(cx);
crate::slider::live_design(cx);... | code_fim | hard | {
"lang": "rust",
"repo": "makepad/makepad",
"path": "/widgets/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if limit is 0, destroying
match limit {
Some(v) if v <= 0.0 => {
state.destroy_component(&cmp);
},
_ => ()
};
}
}
/// Spawns an entity on a spawner.
/// Does not update any of th... | code_fim | hard | {
"lang": "rust",
"repo": "tomaka/declmagic",
"path": "/src/mechanics/system/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // updating limit
match limit {
Some(limit) => { state.set(&cmp, "limit", ::entities::Number(limit)).ok(); },
None => ()
};
// if limit is 0, destroying
match limit {
Some(v) if v <= 0.0 => {
... | code_fim | hard | {
"lang": "rust",
"repo": "tomaka/declmagic",
"path": "/src/mechanics/system/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomaka/declmagic path: /src/mechanics/system/mod.rs
use entities::{ EntitiesState, EntitiesHelper, EntityID, ComponentID, NativeComponentType };
use std::collections::{ HashSet, HashMap };
use resources::ResourcesLoader;
use self::extern_content::ExternContentSystem;
use log;
mod extern_conte... | code_fim | hard | {
"lang": "rust",
"repo": "tomaka/declmagic",
"path": "/src/mechanics/system/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mandubian/ad-rust path: /src/af/trigo.rs
extern crate libc;
extern crate arrayfire as af;
extern crate time;
// use std::marker::PhantomData;
use self::af::*;
use std::rc::Rc;
use std::cell::RefCell;
use af::autograd::*;
<|fim_suffix|> let xe = self.x.eval(ctx);
let xev = &xe.borrow(... | code_fim | hard | {
"lang": "rust",
"repo": "mandubian/ad-rust",
"path": "/src/af/trigo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, E : 'a> Sin<'a, E> {
fn new(x: &'a E) -> Sin<'a, E> {
Sin { x : x }
}
}
impl<'a, E : 'a + Expr<SharedCtx, SharedValue>> Expr<SharedCtx, SharedValue> for Sin<'a, E> {
fn eval(&self, ctx: & SharedCtx) -> SharedValue {
let xe = self.x.eval(ctx);
let xev = &xe.borrow().value;
... | code_fim | medium | {
"lang": "rust",
"repo": "mandubian/ad-rust",
"path": "/src/af/trigo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-datetime/zoneinfo-data path: /src/data/Pacific/Kiritimati.rs
// ------
// This file is autogenerated!
// Any changes you make may be overwritten.
// ------
use std::borrow::Cow;
use datetime::zone::{StaticTimeZone, FixedTimespanSet, FixedTimespan};
pub static ZONE: StaticTimeZone<'stati... | code_fim | hard | {
"lang": "rust",
"repo": "rust-datetime/zoneinfo-data",
"path": "/src/data/Pacific/Kiritimati.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>is_dst: false,
name: Cow::Borrowed("LINT"),
}),
(788954400, FixedTimespan { // 1995-01-01T10:00:00.000 UTC
offset: 50400, // UTC offset 50400, DST offset 0
is_dst: false,
name: Cow::Borrowed("LINT"),
}),
]},
};<|fim_prefix|>... | code_fim | hard | {
"lang": "rust",
"repo": "rust-datetime/zoneinfo-data",
"path": "/src/data/Pacific/Kiritimati.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beijaflor/wasm-markdown-bench path: /wasm-markdown/benches/bench.rs
#![feature(test)]
extern crate test;
fn strait_string(source_text: &str) -> String {
<|fim_suffix|>fn reverse_string(source_text: &str) -> String {
let chers = source_text.chars();
chers.rev().collect()
}
#[bench]
fn wasm... | code_fim | medium | {
"lang": "rust",
"repo": "beijaflor/wasm-markdown-bench",
"path": "/wasm-markdown/benches/bench.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let str = "abcdefghijklmnopqrstu";
b.iter(|| strait_string(str))
}
#[bench]
fn wasm_markdown_reverse_string_bench(b: &mut test::Bencher) {
let str = "abcdefghijklmnopqrstu";
b.iter(|| reverse_string(str))
}<|fim_prefix|>// repo: beijaflor/wasm-markdown-bench path: /wasm-markdown/benches/bench.rs... | code_fim | medium | {
"lang": "rust",
"repo": "beijaflor/wasm-markdown-bench",
"path": "/wasm-markdown/benches/bench.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn wasm_markdown_reverse_string_bench(b: &mut test::Bencher) {
let str = "abcdefghijklmnopqrstu";
b.iter(|| reverse_string(str))
}<|fim_prefix|>// repo: beijaflor/wasm-markdown-bench path: /wasm-markdown/benches/bench.rs
#![feature(test)]
extern crate test;
fn strait_string(source_text: &s... | code_fim | medium | {
"lang": "rust",
"repo": "beijaflor/wasm-markdown-bench",
"path": "/wasm-markdown/benches/bench.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: caemor/epd-waveshare path: /src/epd5in65f/mod.rs
//! A simple Driver for the Waveshare 6.65 inch (F) E-Ink Display via SPI
//!
//! # References
//!
//! - [Datasheet](https://www.waveshare.com/wiki/5.65inch_e-Paper_Module_(F))
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/m... | code_fim | hard | {
"lang": "rust",
"repo": "caemor/epd-waveshare",
"path": "/src/epd5in65f/mod.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn wait_busy_low(&mut self, delay: &mut DELAY) {
self.interface.wait_until_idle(delay, false);
}
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
let w = self.width();
let h = self.height();
self.command(spi, Command::TconResolution)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "caemor/epd-waveshare",
"path": "/src/epd5in65f/mod.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Diggsey/aoc2019 path: /src/bin/day14a.rs
use std::collections::{HashSet, HashMap};
const INPUT: &str = include_str!("../../inputs/day14.txt");
#[derive(Debug, Clone)]
struct Component {
material: String,
amount: i64,
}
impl Component {
fn new(s: &str) -> Self {
let mut s =... | code_fim | hard | {
"lang": "rust",
"repo": "Diggsey/aoc2019",
"path": "/src/bin/day14a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut reactions = HashMap::new();
for line in INPUT.lines() {
let reaction = Reaction::new(line);
let output_material = reaction.output.material.clone();
reactions.insert(output_material, reaction);
}
let mut process = Process {
reactions,
amounts... | code_fim | hard | {
"lang": "rust",
"repo": "Diggsey/aoc2019",
"path": "/src/bin/day14a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cliff-db/cliffpack path: /src/loader.rs
use super::error::PluginReadError;
use super::reader::PluginReader;
use super::PluginMeta;
use std::io::{BufReader, Read};
pub enum PluginToken {
Meta(PluginMeta),
Code(CodeContext),
}
pub struct CodeContext {
pub name: String,
pub conten... | code_fim | hard | {
"lang": "rust",
"repo": "cliff-db/cliffpack",
"path": "/src/loader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<R: Read> PluginLoader<R> {
pub fn new(r: PluginReader<BufReader<R>>) -> Result<PluginLoader<R>, PluginReadError> {
let mut read: PluginReader<BufReader<R>> = r;
read.verify_magic_number()?;
read.verify_file_version()?;
Ok(PluginLoader {
read,
... | code_fim | hard | {
"lang": "rust",
"repo": "cliff-db/cliffpack",
"path": "/src/loader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::{BoundType, LowerBound, Normalizable, Range, RangeBound, UpperBound};
use super::BoundType::{Exclusive, Inclusive};
#[test]
fn test_range_bound_lower_lt() {
fn check(val1: isize, inc1: BoundType, val2: isize, inc2: BoundType, expected: bool) {
let a: RangeBo... | code_fim | hard | {
"lang": "rust",
"repo": "sfackler/rust-postgres-range",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sfackler/rust-postgres-range path: /src/lib.rs
ne)
);
('[' $l:expr,; ')') => (
$crate::Range::new(
Some($crate::RangeBound::new($l,
$crate::BoundType::Inclusive)), None)
);
('(' $l:expr, $h:expr; ')') => (
$crate::Range::new(
... | code_fim | hard | {
"lang": "rust",
"repo": "sfackler/rust-postgres-range",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sfackler/rust-postgres-range path: /src/lib.rs
! range {
(empty) => ($crate::Range::empty());
('(',; ')') => ($crate::Range::new(None, None));
('(', $h:expr; ')') => (
$crate::Range::new(None,
Some($crate::RangeBound::new($h,
$crate::BoundType::Exc... | code_fim | hard | {
"lang": "rust",
"repo": "sfackler/rust-postgres-range",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stianeklund/rustcube path: /src/cpu/tbr.rs
// Time Base Register (TBR)
// DUMB timer
// TODO: put some thought into this
enum_from_primitive! {
#[derive(Debug)]
pub enum TBR {
TBL = 268,
TBU = 269,
UNKNOWN = -1
}
}
#[derive(Default, Debug)]
pub struct Tbr ... | code_fim | medium | {
"lang": "rust",
"repo": "stianeklund/rustcube",
"path": "/src/cpu/tbr.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn u(&self) -> u32 {
(self.tbr >> 32) as u32
}
}<|fim_prefix|>// repo: stianeklund/rustcube path: /src/cpu/tbr.rs
// Time Base Register (TBR)
// DUMB timer
// TODO: put some thought into this
enum_from_primitive! {
#[derive(Debug)]
pub enum TBR {
TBL = 268,
... | code_fim | medium | {
"lang": "rust",
"repo": "stianeklund/rustcube",
"path": "/src/cpu/tbr.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mattish/learning_rust_with_gfx path: /src/camera.rs
use vecmath;
pub struct Camera{
position: [f32;3],
up: [f32;3]
}
impl Camera{
pub fn set(&mut self, x: f32,y: f32,z: f32){
self.position[0] = x;
self.position[1] = y;
self.position[2] = z;
}
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "Mattish/learning_rust_with_gfx",
"path": "/src/camera.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_perspectivei(height: u32, width: u32) -> [[f32;4]; 4]{
let f_height = height as f32;
let f_width = width as f32;
get_perspective(f_height, f_width)
}
pub fn get_perspective(height: f32, width: f32) -> [[f32; 4]; 4] {
use std::f32;
let aspect_ratio = height/ width;
let ... | code_fim | hard | {
"lang": "rust",
"repo": "Mattish/learning_rust_with_gfx",
"path": "/src/camera.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> [
[f * aspect_ratio , 0.0, 0.0 , 0.0],
[ 0.0 , f , 0.0 , 0.0],
[ 0.0 , 0.0, (zfar+znear)/(zfar-znear) , 1.0],
[ 0.0 , 0.0, -(2.0*zfar*znear)/(z... | code_fim | medium | {
"lang": "rust",
"repo": "Mattish/learning_rust_with_gfx",
"path": "/src/camera.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bmwill/tonic path: /tests/integration_tests/tests/status.rs
use bytes::Bytes;
use futures_util::FutureExt;
use http::Uri;
use integration_tests::mock::MockStream;
use integration_tests::pb::{
test_client, test_server, test_stream_client, test_stream_server, Input, InputStream, Output,
Ou... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tests/integration_tests/tests/status.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(stream.message().await.unwrap_err().message(), "foo");
assert_eq!(stream.message().await.unwrap(), None);
}
#[tokio::test]
async fn status_from_server_stream_with_source() {
trace_init();
let channel = Endpoint::try_from("http://[::]:50051")
.unwrap()
.connect_... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tests/integration_tests/tests/status.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn stream_call(
&self,
_: Request<InputStream>,
) -> Result<Response<Self::StreamCallStream>, Status> {
let s = futures::stream::iter(vec![
Err::<OutputStream, _>(Status::unavailable("foo")),
Err::<OutputStream, _>(S... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tests/integration_tests/tests/status.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Resource> DerefMut for Created<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<T: Resource> Responder<'static> for Created<T> {
fn respond_to(self, request: &Request) -> Result<Response<'static>, Status> {
let query = match Query::from_request(... | code_fim | hard | {
"lang": "rust",
"repo": "ttdonovan/json-api-rs",
"path": "/rocket/src/response.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttdonovan/json-api-rs path: /rocket/src/response.rs
use std::io::Cursor;
use std::iter::FromIterator;
use std::ops::{Deref, DerefMut};
use json_api::{self, Error, Resource};
use json_api::doc::Object;
use rocket::Outcome;
use rocket::http::Status;
use rocket::request::{FromRequest, Request};
us... | code_fim | hard | {
"lang": "rust",
"repo": "ttdonovan/json-api-rs",
"path": "/rocket/src/response.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfcorbett/aoc2019 path: /d12b/src/main.rs
extern crate num;
use num::PrimInt;
use std::{
fs::File,
io::{Read, Result},
path::Path,
};
fn read_whole_file(s: impl AsRef<Path>) -> Result<String> {
let mut file = File::open(s)?;
let mut s = String::new();
file.read_to_stri... | code_fim | hard | {
"lang": "rust",
"repo": "jfcorbett/aoc2019",
"path": "/d12b/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pos: Vec<Vec<i32>> = vec![vec![-1, 0, 2], vec![2, -10, -7], vec![4, -8, 8], vec![3, 5, -1]];
let mut vlc: Vec<Vec<i32>> = vec![vec![0, 0, 0], vec![0, 0, 0], vec![0, 0, 0], vec![0, 0, 0]];
moondance(&mut pos, &mut vlc);
assert_eq!(pos, vec![vec![2, -1, 1], vec![3, -7... | code_fim | hard | {
"lang": "rust",
"repo": "jfcorbett/aoc2019",
"path": "/d12b/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_moondance() {
let mut pos: Vec<Vec<i32>> = vec![vec![-1, 0, 2], vec![2, -10, -7], vec![4, -8, 8], vec![3, 5, -1]];
let mut vlc: Vec<Vec<i32>> = vec![vec![0, 0, 0], vec![0, 0, 0], vec![0, 0, 0], vec![0, 0, 0]];
moondance(&mut pos, &mut vlc);
assert_eq... | code_fim | hard | {
"lang": "rust",
"repo": "jfcorbett/aoc2019",
"path": "/d12b/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::cmp::PartialEq for Table {
fn eq(&self, other: &Self) -> bool {
self.handle == other.handle
}
}
impl std::cmp::Eq for Table {}
impl<'a> Exportable<'a> for Table {
fn get_self_from_extern(_extern: &'a Extern) -> Result<&'a Self, ExportError> {
match _extern {
... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/wasmer",
"path": "/lib/api/src/sys/externals/table.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/wasmer path: /lib/api/src/sys/externals/table.rs
use crate::sys::exports::{ExportError, Exportable};
use crate::sys::externals::Extern;
use crate::sys::store::{AsStoreMut, AsStoreRef};
use crate::sys::TableType;
use crate::Value;
use crate::{sys::RuntimeError, ExternRef, Function};
u... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/wasmer",
"path": "/lib/api/src/sys/externals/table.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match _extern {
Extern::Table(table) => Ok(table),
_ => Err(ExportError::IncompatibleType),
}
}
}
/// Check the example from <https://github.com/wasmerio/wasmer/issues/3197>.
#[test]
fn test_table_grow_issue_3197() {
use crate::{imports, Instance, Module, S... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/wasmer",
"path": "/lib/api/src/sys/externals/table.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Derive the `as_str()` method using the `AsRef<str>` implementation of the type.
#[proc_macro_derive(AsStrAsRefStr, attributes(ruma_enum))]
pub fn derive_as_str_as_ref_str(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
expand_as_str_as_ref_str(&input.... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-macros/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma-macros/src/lib.rs
-clippy/issues/9029
#![allow(clippy::derive_partial_eq_without_eq)]
use identifiers::expand_id_zst;
use proc_macro::TokenStream;
use proc_macro2 as pm2;
use quote::quote;
use ruma_identifiers_validation::{
device_key_id, event_id, key_id, mxc_u... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-macros/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> output.into()
}
/// Compile-time checked `MxcUri` construction.
#[proc_macro]
pub fn mxc_uri(input: TokenStream) -> TokenStream {
let IdentifierInput { dollar_crate, id } = parse_macro_input!(input as IdentifierInput);
assert!(mxc_uri::validate(&id.value()).is_ok(), "Invalid mxc://");
le... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-macros/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let encryptor = self.encryptor.as_ref().unwrap();
let mut decrypted_messages = Vec::with_capacity(polled_messages.messages.len());
for message in polled_messages.messages.iter() {
let payload = encryptor.decrypt(&message.payload);
if payload.is_err() {
... | code_fim | hard | {
"lang": "rust",
"repo": "iggy-rs/iggy",
"path": "/streaming/src/systems/messages.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iggy-rs/iggy path: /streaming/src/systems/messages.rs
use crate::models::messages::PolledMessages;
use crate::polling_consumer::PollingConsumer;
use crate::systems::system::System;
use bytes::Bytes;
use iggy::error::Error;
use iggy::identifier::Identifier;
use iggy::messages::poll_messages::Poll... | code_fim | hard | {
"lang": "rust",
"repo": "iggy-rs/iggy",
"path": "/streaming/src/systems/messages.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut polled_messages = topic
.get_messages(consumer, partition_id, strategy, count)
.await?;
if polled_messages.messages.is_empty() {
return Ok(polled_messages);
}
let offset = polled_messages.messages.last().unwrap().offset;
... | code_fim | hard | {
"lang": "rust",
"repo": "iggy-rs/iggy",
"path": "/streaming/src/systems/messages.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self{
sprite_sheet: None
}
}
}<|fim_prefix|>// repo: rijkvp/Rust-Game-2020 path: /src/resources/sprite_sheet.rs
use amethyst::assets::Handle;
use amethyst::renderer::*;
<|fim_middle|>
pub struct SpriteSheetHolder
{
pub sprite_sheet: Option<Handle<SpriteSheet>>
}
impl... | code_fim | medium | {
"lang": "rust",
"repo": "rijkvp/Rust-Game-2020",
"path": "/src/resources/sprite_sheet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rijkvp/Rust-Game-2020 path: /src/resources/sprite_sheet.rs
use amethyst::assets::Handle;
use amethyst::renderer::*;
<|fim_suffix|>impl Default for SpriteSheetHolder {
fn default() -> Self {
Self{
sprite_sheet: None
}
}
}<|fim_middle|>pub struct SpriteSheetHo... | code_fim | medium | {
"lang": "rust",
"repo": "rijkvp/Rust-Game-2020",
"path": "/src/resources/sprite_sheet.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn malloc_med() {
let _g = MSYNC.lock();
let p = unsafe { krmalloc(1024 * 1024) };
assert_ne!(p, ptr::null_mut());
unsafe {
krfree(p);
}
}
#[test]
fn malloc_free_malloc() {
let _g = MSYNC.lock();
let p = unsaf... | code_fim | hard | {
"lang": "rust",
"repo": "dancrossnyc/rxv64",
"path": "/ulib/src/malloc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dancrossnyc/rxv64 path: /ulib/src/malloc.rs
// Lightly modified K&R allocator. Note that sizes are in "units",
// not bytes.
use core::cmp;
use core::mem;
use core::ptr;
#[repr(C)]
#[derive(Debug)]
struct Header {
next: *mut Header,
nunits: usize,
}
impl Header {
pub fn new(nunits... | code_fim | hard | {
"lang": "rust",
"repo": "dancrossnyc/rxv64",
"path": "/ulib/src/malloc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>const MAX_COUNT: u32 = 10;
struct TestItems {
cache_mgr: SimpleCacheManager,
remove_calls: Rc<RefCell<Vec<String>>>,
}
fn setup() -> TestItems {
let SqlCacheInterfaceTestItems {
sql_mgr,
remove_calls,
} = super::setup_db();
let db = Rc::new(RefCell::new(sql_mgr));
... | code_fim | hard | {
"lang": "rust",
"repo": "aplbrain/bossphorus",
"path": "/src/db/tests/simple_cache_manager.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aplbrain/bossphorus path: /src/db/tests/simple_cache_manager.rs
/*
Copyright 2020 The Johns Hopkins University Applied Physics Laboratory
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of th... | code_fim | hard | {
"lang": "rust",
"repo": "aplbrain/bossphorus",
"path": "/src/db/tests/simple_cache_manager.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let key = "coll/exp/chan";
let num_reqs = MAX_COUNT + 5;
let requests: Vec<String> = (0..num_reqs)
.map(|i| format!("{}/{}/{}", config::CUBOID_ROOT_PATH, key, i))
.collect();
for (i, req) in requests.iter().enumerate() {
cache_mgr.log_request(req.to_string());
... | code_fim | hard | {
"lang": "rust",
"repo": "aplbrain/bossphorus",
"path": "/src/db/tests/simple_cache_manager.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(parse("web {dat = 3 }"),
Expr::NewStruct("web".to_string(),
vec![("dat".to_string(), Expr::Num(3))]));
assert_eq!(parse("dummy {}"), Expr::NewStruct("dummy".to_string(), Vec::new()));
}
#[test]
fn lvalue_member_te... | code_fim | hard | {
"lang": "rust",
"repo": "koba-e964/rust-tigress",
"path": "/src/parse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: koba-e964/rust-tigress path: /src/parse.rs
use ast::{Expr, Op};
/*
* Example: ([(1, +), (2, -)], 4) ==> (4 + 1) - 2
*/
pub fn fold_to_ast<T, F>(va: (Vec<(Expr, T)>, Expr), fold: F) -> Expr
where F: Fn(T, Expr, Expr) -> Expr, T: Copy {
let (x, y) = va;
let mut ast = y;
for (e, t) ... | code_fim | hard | {
"lang": "rust",
"repo": "koba-e964/rust-tigress",
"path": "/src/parse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(parse("if 4 then if 5 then 3 else 2"),
Expr::IfNode(Box::new(Expr::Num(4)),
Box::new(Expr::IfNode(Box::new(Expr::Num(5)), Box::new(Expr::Num(3)), Box::new(Expr::Num(2)))),
Box::new(Expr::Nil)));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "koba-e964/rust-tigress",
"path": "/src/parse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jedisct1/rust-ct-codecs path: /src/lib.rs
//! Constant-time codecs.
#![cfg_attr(not(feature = "std"), no_std)]
#![forbid(unsafe_code)]
mod base64;
mod error;
mod hex;
pub use base64::*;
pub use error::*;
pub use hex::*;
pub trait Encoder {
/// Length of `bin_len` bytes after encoding.
... | code_fim | hard | {
"lang": "rust",
"repo": "jedisct1/rust-ct-codecs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Decoder {
/// Decode `encoded` into `bin`.
/// The output buffer can be larger than required; the returned slice is
/// a view of the buffer with the correct length.
/// `ignore` is an optional set of characters to ignore.
fn decode<'t, IN: AsRef<[u8]>>(
bin: &'t mut ... | code_fim | hard | {
"lang": "rust",
"repo": "jedisct1/rust-ct-codecs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ekirshey/rusty_rogue path: /src/world/direction.rs
use utils::Vec2;
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Direction {
North,
East,
South,
West
}
impl Direction {
pub fn get_direction(val : usize) -> Direction {
match val {
1 => Direction::Nor... | code_fim | hard | {
"lang": "rust",
"repo": "ekirshey/rusty_rogue",
"path": "/src/world/direction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn rotate_cw_n(&mut self, n : usize) {
for i in 0..n {
self.rotate_cw();
}
}
pub fn rotate_ccw(&mut self) {
match *self {
Direction::North => *self = Direction::West,
Direction::West => *self = Direction::South,
Direc... | code_fim | hard | {
"lang": "rust",
"repo": "ekirshey/rusty_rogue",
"path": "/src/world/direction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn rotate_cw(&mut self) {
match *self {
Direction::North => *self = Direction::East,
Direction::East => *self = Direction::South,
Direction::South => *self = Direction::West,
Direction::West => *self = Direction::North,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ekirshey/rusty_rogue",
"path": "/src/world/direction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ans = if n == 1 {0} else {1};
println!("{}", ans)
}<|fim_prefix|>// repo: konamilk/atcoder-abc178 path: /src/bin/a.rs
use proconio::input;
// use proconio::marker::Chars;
<|fim_middle|>fn main() {
input!{
n:i32
}
| code_fim | easy | {
"lang": "rust",
"repo": "konamilk/atcoder-abc178",
"path": "/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: konamilk/atcoder-abc178 path: /src/bin/a.rs
use proconio::input;
// use proconio::marker::Chars;
<|fim_suffix|> let ans = if n == 1 {0} else {1};
println!("{}", ans)
}<|fim_middle|>fn main() {
input!{
n:i32
}
| code_fim | easy | {
"lang": "rust",
"repo": "konamilk/atcoder-abc178",
"path": "/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thorhs/mk66f18 path: /src/ftm1/outinit.rs
d `CH0OI`"]
pub struct CH0OI_W<'a> {
w: &'a mut W,
}
impl<'a> CH0OI_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: CH0OI_A) -> &'a mut W {
{
self.bit(variant.into())
... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/ftm1/outinit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match variant {
CH5OI_A::_0 => false,
CH5OI_A::_1 => true,
}
}
}
#[doc = "Reader of field `CH5OI`"]
pub type CH5OI_R = crate::R<bool, CH5OI_A>;
impl CH5OI_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> CH5OI_... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/ftm1/outinit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niuez/cp-rust-library path: /src/data_structures/implicit_avl_tree/node_macro.rs
#[macro_export]
macro_rules! build_implicit_node_struct {
($node:ident, $($elem:ident: $t:ty,)*) => {
struct $node {
parent: Parent<$node>,
child: [Child<$node>; 2],
$... | code_fim | hard | {
"lang": "rust",
"repo": "niuez/cp-rust-library",
"path": "/src/data_structures/implicit_avl_tree/node_macro.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! impl_implicit_leaf_trait {
($node:ident, $leaf:ident, $val_type:ty, $($elem:tt)* ) => {
impl Leaf for $leaf {
type Value = $val_type;
fn value(&self) -> &Self::Value { &self.val }
fn value_mut(&mut self) -> &mut Self::Value { &mu... | code_fim | hard | {
"lang": "rust",
"repo": "niuez/cp-rust-library",
"path": "/src/data_structures/implicit_avl_tree/node_macro.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: recrack/open.gl-tutorials path: /src/c3_multitexture.rs
extern mod glfw3;
extern mod glcore;
extern mod stb_image;
use cast::transmute;
use ptr::{is_null, null, to_unsafe_ptr};
use str::as_c_str;
use sys::size_of;
use vec::raw::to_ptr;
use glcore::*;
use stb_image::image::load_with_depth;
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "recrack/open.gl-tutorials",
"path": "/src/c3_multitexture.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> glUniform1i(glGetUniformLocation(shaderProgram, as_c_str("texKitten", |s| s)), 0);
unsafe {
glTexImage2D(
GL_TEXTURE_2D, 0,
GL_RGB as GLint,
image.width as GLsizei,
... | code_fim | hard | {
"lang": "rust",
"repo": "recrack/open.gl-tutorials",
"path": "/src/c3_multitexture.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lpxxn/rust_example path: /practice/r5ownship/src/lib.rs
// enum 只有包含的元素都是基础元素时,才会实现Copy
#[derive(Debug)]
#[derive(Copy, Clone)]
enum TestEnum {
//RETYPE(String),
// ------ this field does not implement `Copy`
RETYPE2(u32),
}
#[test]
fn it_works() {
let a = A;
let b = ... | code_fim | hard | {
"lang": "rust",
"repo": "lpxxn/rust_example",
"path": "/practice/r5ownship/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> C{
a:self.a.clone(),
..*self
}
}
}
// 解注释看编译器提示
//impl Copy for C {}<|fim_prefix|>// repo: lpxxn/rust_example path: /practice/r5ownship/src/lib.rs
// enum 只有包含的元素都是基础元素时,才会实现Copy
#[derive(Debug)]
#[derive(Copy, Clone)]
enum TestEnum {
//RETYPE(String),
... | code_fim | hard | {
"lang": "rust",
"repo": "lpxxn/rust_example",
"path": "/practice/r5ownship/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alichtman/lsd path: /src/flags/symlinks.rs
//! This module defines the [NoSymlink] flag. To set it up from [Cli], a [Config] and its
//! [Default] value, use the [configure_from](Configurable::configure_from) method.
use super::Configurable;
use crate::app::Cli;
use crate::config_file::Config;... | code_fim | hard | {
"lang": "rust",
"repo": "alichtman/lsd",
"path": "/src/flags/symlinks.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_from_config_true() {
let mut c = Config::with_none();
c.no_symlink = Some(true);
assert_eq!(Some(NoSymlink(true)), NoSymlink::from_config(&c));
}
#[test]
fn test_from_config_false() {
let mut c = Config::with_none();
c.no_symlink... | code_fim | hard | {
"lang": "rust",
"repo": "alichtman/lsd",
"path": "/src/flags/symlinks.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut c = Config::with_none();
c.no_symlink = Some(true);
assert_eq!(Some(NoSymlink(true)), NoSymlink::from_config(&c));
}
#[test]
fn test_from_config_false() {
let mut c = Config::with_none();
c.no_symlink = Some(false);
assert_eq!(Some(NoSym... | code_fim | hard | {
"lang": "rust",
"repo": "alichtman/lsd",
"path": "/src/flags/symlinks.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // See https://docs.rs/env_logger/0.7.0/env_logger/ for details on controlling the log output
env_logger::builder()
.format(|buf, record| {
writeln!(
buf,
"{}",
// "[{}] \n {}",
// record.module_path().unwrap(),
... | code_fim | medium | {
"lang": "rust",
"repo": "lebensterben/ed_join",
"path": "/src/bin.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lebensterben/ed_join path: /src/bin.rs
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
use env_logger;
use std::io::Write;
<|fim_suffix|> // Parsing CLI Argument and get configurations
let config: cli::Config = cli::parse_config().unwrap_or_else(|err| {
epr... | code_fim | hard | {
"lang": "rust",
"repo": "lebensterben/ed_join",
"path": "/src/bin.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match ed_join(&config.doc_x, &config.doc_y, config.q, config.tau) {
Ok(()) => Ok(()),
Err(e) => Err(e),
}
}<|fim_prefix|>// repo: lebensterben/ed_join path: /src/bin.rs
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
use env_logger;
use std::io::Write;
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "lebensterben/ed_join",
"path": "/src/bin.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Streaming decoder for decoding a [`Message`] from a stream.
#[non_exhaustive]
#[derive(Default, Debug)]
pub struct MessageFrameDecoder {
prelude: [u8; PRELUDE_LENGTH_BYTES_USIZE],
prelude_read: bool,
}
impl MessageFrameDecoder {
/// Returns a new `MessageFrameDecoder`.
pub fn new() ->... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/smithy-eventstream/src/frame.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/smithy-eventstream/src/frame.rs
as usize;
const MESSAGE_CRC_LENGTH_BYTES: u32 = size_of::<u32>() as u32;
const MAX_HEADER_NAME_LEN: usize = 255;
const MIN_HEADER_LEN: usize = 2;
pub type SignMessageError = Box<dyn StdError + Send + Sync + 'static>;
/// Signs an ... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/smithy-eventstream/src/frame.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Reads a header from the given `buffer`.
fn read_from<B: Buf>(mut buffer: B) -> Result<(Header, usize), Error> {
if buffer.remaining() < MIN_HEADER_LEN {
return Err(Error::InvalidHeadersLength);
}
let mut counting_buf = CountBuf::new(&mut buffer);
le... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/smithy-eventstream/src/frame.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ric2b/Vivaldi-browser path: /chromium/third_party/rust/clap/v3/crate/src/build/app_settings.rs
) => m,
/// Err(err) => {
/// if err.use_stderr() {
/// let _ = err.print();
///
/// eprintln!("\nPress [ENTER] / [RETURN] to continue...");
... | code_fim | hard | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/clap/v3/crate/src/build/app_settings.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Deprecated, replaced with [`AppSettings::HidePossibleValues`]
#[deprecated(
since = "3.0.0",
note = "Replaced with AppSettings::HidePossibleValues"
)]
#[doc(hidden)]
HidePossibleValuesInHelp,
/// Deprecated, this is now the default
#[deprecated(since = "3.0... | code_fim | hard | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/clap/v3/crate/src/build/app_settings.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Deprecated, this is now the default
#[deprecated(since = "3.0.0", note = "This is now the default")]
#[doc(hidden)]
UnifiedHelp,
/// If the cmd is already built, used for caching.
#[doc(hidden)]
Built,
/// If the cmd's bin name is already built, used for caching.
... | code_fim | hard | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/clap/v3/crate/src/build/app_settings.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /services/mgmt/costmanagement/src/lib.rs
#![allow(clippy::module_inception)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::ptr_arg)]
#![allow(clippy::large_enum_variant)]
#![allow(clippy::derive_partial_eq_without_eq)]
#[cfg(feature = "package-preview-2023... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/services/mgmt/costmanagement/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.