text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>impl<F, T> Translate<T> for Attributes<F>
where
F: Flavor,
T: Translator<Source = F>,
{
type Out = Attributes<T::Target>;
/// Translate into different flavor.
fn translate(self, diag: &mut Diagnostics, translator: &T) -> Result<Attributes<T::Target>> {
Ok(Attributes {
... | code_fim | hard | {
"lang": "rust",
"repo": "reproto/reproto",
"path": "/lib/core/src/attributes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chom-parser/chom path: /src/lexing/token/delimiter.rs
macro_rules! delimiter {
($($a:literal, $b:literal : $name:ident),*) => {
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Delimiter {
$(
$name
),*
}
<|fim_suffix|> pub fn ident(&self) -> crate::Ident ... | code_fim | hard | {
"lang": "rust",
"repo": "chom-parser/chom",
"path": "/src/lexing/token/delimiter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn name(&self) -> &'static str {
match self {
$(
Self::$name => stringify!($name)
),*
}
}
pub fn ident(&self) -> crate::Ident {
crate::Ident::new(self.name()).unwrap()
}
}
};
}
delimiter! {
'(', ')': Parenthesis,
'[', ']': Bracket,
'{', '}': Braces
}<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "chom-parser/chom",
"path": "/src/lexing/token/delimiter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn ident(&self) -> crate::Ident {
crate::Ident::new(self.name()).unwrap()
}
}
};
}
delimiter! {
'(', ')': Parenthesis,
'[', ']': Bracket,
'{', '}': Braces
}<|fim_prefix|>// repo: chom-parser/chom path: /src/lexing/token/delimiter.rs
macro_rules! delimiter {
($($a:literal, $b:literal... | code_fim | hard | {
"lang": "rust",
"repo": "chom-parser/chom",
"path": "/src/lexing/token/delimiter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl InteruptHandler {
pub const fn new() -> InteruptHandler {
InteruptHandler {
idt: [IdtEntry::MISSING; IDT_ENTRIES]
}
}
pub fn add_handler(&mut self, int_no: usize,
func: extern "x86-interrupt" fn (&mut ExceptionStackFrame))
{
if int_no < IDT_ENTRIES {
self.idt[int_no] = IdtEntry::ne... | code_fim | hard | {
"lang": "rust",
"repo": "jbreitbart/eduOS-rs",
"path": "/src/arch/x86_64/irq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbreitbart/eduOS-rs path: /src/arch/x86_64/irq.rs
blicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all cop... | code_fim | hard | {
"lang": "rust",
"repo": "jbreitbart/eduOS-rs",
"path": "/src/arch/x86_64/irq.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbreitbart/eduOS-rs path: /src/arch/x86_64/irq.rs
charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// di... | code_fim | hard | {
"lang": "rust",
"repo": "jbreitbart/eduOS-rs",
"path": "/src/arch/x86_64/irq.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r {
/// `reference` is not pointing to a valid location in the document.
#[error("missing reference target for reference {reference}")]
MissingReferenceTarget {
#[allow(missing_docs)]
reference: String,
},
}<|fim_prefix|>// repo: Br1ght0ne/oac path: /crates/parser/src/erro... | code_fim | medium | {
"lang": "rust",
"repo": "Br1ght0ne/oac",
"path": "/crates/parser/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Br1ght0ne/oac path: /crates/parser/src/error.rs
use thiserror::Error;
/// A convenience wrapper for [std::result::Result] where E is [Error].
pub type Result<T, E = E<|fim_suffix|>reference {reference}")]
MissingReferenceTarget {
#[allow(missing_docs)]
reference: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "Br1ght0ne/oac",
"path": "/crates/parser/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(get_yes_answers("abc") == 3);
assert!(get_yes_answers("a\nb\nc") == 3);
assert!(get_yes_answers("ab\nac") == 3);
assert!(get_yes_answers("a\na\na\na") == 1);
assert!(get_yes_answers("b") == 1);
}
#[test]
fn count_everyone_answer_yes() {
... | code_fim | hard | {
"lang": "rust",
"repo": "royvegard/aoc_2020",
"path": "/src/day06.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match persons.split_first() {
Some((first, others)) => {
for c in first.chars() {
if others.len() > 0 {
let mut found_in_all_others = true;
for other in others {
if !other.contains(c) {
... | code_fim | hard | {
"lang": "rust",
"repo": "royvegard/aoc_2020",
"path": "/src/day06.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: royvegard/aoc_2020 path: /src/day06.rs
use aoc_runner_derive::aoc;
use std::collections::HashSet;
#[aoc(day6, part1)]
fn solve_part1(input: &str) -> u32 {
let forms = input.split("\n\n").collect::<Vec<&str>>();
let mut sum_of_yes = 0;
for form in forms {
sum_of_yes += get_y... | code_fim | hard | {
"lang": "rust",
"repo": "royvegard/aoc_2020",
"path": "/src/day06.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: santokalayil/DRUID-LEARN path: /src/widgets/mod.rs
pub mod titlebar;
pub mod custom_widget;
pub mod frame<|fim_suffix|>ub mod menu;
pub mod list_tile;
pub mod responsible_tilebutton;
pub mod main_view;
// pub mod sidebar_button;<|fim_middle|>;
pub mod split;
pub mod sidebar;
pub mod too... | code_fim | easy | {
"lang": "rust",
"repo": "santokalayil/DRUID-LEARN",
"path": "/src/widgets/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>lebutton;
pub mod main_view;
// pub mod sidebar_button;<|fim_prefix|>// repo: santokalayil/DRUID-LEARN path: /src/widgets/mod.rs
pub mod titlebar;
pub mod custom_widget;
pub mod frame;
pub mod split;
pub mod sidebar;
pub mod tool_tab;
p<|fim_middle|>ub mod menu;
pub mod list_tile;
pub mod respo... | code_fim | easy | {
"lang": "rust",
"repo": "santokalayil/DRUID-LEARN",
"path": "/src/widgets/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ubnt-intrepid/tokio-libssh2 path: /xtask/src/main.rs
use std::{ffi::OsString, path::PathBuf};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
enum Arg {
/// Run a script.
Script {
/// The script name
#[structopt(name = "command", parse(from_os_str))]
comman... | code_fim | hard | {
"lang": "rust",
"repo": "ubnt-intrepid/tokio-libssh2",
"path": "/xtask/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn project_root() -> anyhow::Result<PathBuf> {
Ok(std::path::Path::new(&env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(1)
.ok_or_else(|| anyhow::anyhow!("missing ancestor"))?
.to_owned())
}<|fim_prefix|>// repo: ubnt-intrepid/tokio-libssh2 path: /xtask/src... | code_fim | hard | {
"lang": "rust",
"repo": "ubnt-intrepid/tokio-libssh2",
"path": "/xtask/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let json_str = r#"
{
"Nonce":{"id":"Alice", "value":10}
}
"#;
let msg: Message = serde_json::from_str(json_str).unwrap();
println!("{:?}", msg);
}<|fim_prefix|>// repo: beber89/dapp-mine-scenario path: /src/tests.rs
use crate::message::Message;
<|fim_middle|> #[test]
f... | code_fim | easy | {
"lang": "rust",
"repo": "beber89/dapp-mine-scenario",
"path": "/src/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beber89/dapp-mine-scenario path: /src/tests.rs
use crate::message::Message;
<|fim_suffix|> let json_str = r#"
{
"Nonce":{"id":"Alice", "value":10}
}
"#;
let msg: Message = serde_json::from_str(json_str).unwrap();
println!("{:?}", msg);
}<|fim_middle|> #[test]
f... | code_fim | easy | {
"lang": "rust",
"repo": "beber89/dapp-mine-scenario",
"path": "/src/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new <W> (num_threads: usize, new_worker: W) -> StatePool<RawMessage, ()> where W: Fn(Vec<Sender<RawMessage>>) -> QueuePoolWorker {
let (done, wait) = channel();
let _workers = (0..num_threads).map(|_| {
channel()
}).collect::<Vec<_>>();
let contacts... | code_fim | hard | {
"lang": "rust",
"repo": "aaliang/rqueue",
"path": "/src/threadpool.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aaliang/rqueue path: /src/threadpool.rs
use std::sync::mpsc::{Sender, Receiver, channel};
use std::thread;
use protocol::{get_message, RawMessage};
use slice_map::SliceMap;
use std::collections::{HashSet, HashMap};
use std::net::{SocketAddr, TcpStream};
use mio::tcp::TcpStream as MioTcpStream;
u... | code_fim | hard | {
"lang": "rust",
"repo": "aaliang/rqueue",
"path": "/src/threadpool.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// locally cached mapping of topics (a bunch of bytes) to a collection of subcriber info (tcp
/// sockets)
topic_map: SliceMap<HashMap<SocketAddr, TcpStream>>,
/// locally cached mapping of socket addresses to a collection of topics
interest_map: HashMap<SocketAddr, HashSet<Vec<u8>... | code_fim | hard | {
"lang": "rust",
"repo": "aaliang/rqueue",
"path": "/src/threadpool.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jlgerber/jsprest path: /src/jsp_result.rs
use actix_web::{Error, HttpRequest, HttpResponse, Responder};
//use actix_web::Result as AWResult;
use serde::Serialize;
use std::fmt::Debug;
use crate::JspRestError;
#[derive(Debug, Serialize)]
pub struct JspResult<I: Serialize + Debug> {
//links
... | code_fim | medium | {
"lang": "rust",
"repo": "jlgerber/jsprest",
"path": "/src/jsp_result.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
extern crate rand;
pub mod bufread;
pub mod read;
pub mod stream;
pub mod write;<|fim_prefix|>// repo: valarauca/car path: /car_compress/algo/brotli2-rs/src/lib.rs
//! Brotli Compression/Decompression for Rust
//!
//! This crate is a binding to the [off... | code_fim | medium | {
"lang": "rust",
"repo": "valarauca/car",
"path": "/car_compress/algo/brotli2-rs/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: valarauca/car path: /car_compress/algo/brotli2-rs/src/lib.rs
//! Brotli Compression/Decompression for Rust
//!
//! This crate is a binding to the [official brotli implementation][brotli] and
//! provides in-memory and I/O streams for Rust wrappers.
//!
//! [brotli]: https://github.com/google/bro... | code_fim | medium | {
"lang": "rust",
"repo": "valarauca/car",
"path": "/car_compress/algo/brotli2-rs/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rectinajh/rust-leetcode path: /src/interview/a3/t2.rs
/*
已有方法 rand7 可生成 1 到 7 范围内的均匀随机整数,试写一个方法 rand10 生成 1 到 10 范围内的均匀随机整数。
<|fim_suffix|>
提示:
rand7 已定义。
传入参数: n 表示 rand10 的调用次数。
进阶:
rand7()调用次数的 期望值 是多少 ?
你能否尽量少调用 rand7() ?
*/
use rand::random;
struct Solution {}
#[allow(dead_code)]
fn r... | code_fim | medium | {
"lang": "rust",
"repo": "rectinajh/rust-leetcode",
"path": "/src/interview/a3/t2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
进阶:
rand7()调用次数的 期望值 是多少 ?
你能否尽量少调用 rand7() ?
*/
use rand::random;
struct Solution {}
#[allow(dead_code)]
fn rand7() -> i32 {
let r: i32 = random();
r % 7 + 1
}
impl Solution {
#[allow(dead_code)]
pub fn count_substrings(_s: String) -> i32 {
0
}
}<|fim_prefix|>// repo: recti... | code_fim | easy | {
"lang": "rust",
"repo": "rectinajh/rust-leetcode",
"path": "/src/interview/a3/t2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r: i32 = random();
r % 7 + 1
}
impl Solution {
#[allow(dead_code)]
pub fn count_substrings(_s: String) -> i32 {
0
}
}<|fim_prefix|>// repo: rectinajh/rust-leetcode path: /src/interview/a3/t2.rs
/*
已有方法 rand7 可生成 1 到 7 范围内的均匀随机整数,试写一个方法 rand10 生成 1 到 10 范围内的均匀随机整数。
不要使用系统的... | code_fim | medium | {
"lang": "rust",
"repo": "rectinajh/rust-leetcode",
"path": "/src/interview/a3/t2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
#[ignore]
/// decode with five rails
fn test_decode_with_five_rails() {
process_decode_case("EIEXMSMESAORIWSCE", 5, "EXERCISMISAWESOME");
}
#[test]
#[ignore]
/// decode with six rails
fn test_decode_with_six_rails() {
process_decode_case(
"13371411423814896622543954101833547098617... | code_fim | hard | {
"lang": "rust",
"repo": "exercism/rust",
"path": "/exercises/practice/rail-fence-cipher/tests/rail-fence-cipher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exercism/rust path: /exercises/practice/rail-fence-cipher/tests/rail-fence-cipher.rs
//! Tests for rail-fence-cipher
//!
//! Generated by [script][script] using [canonical data][canonical-data]
//!
//! [script]: https://github.com/exercism/rust/blob/main/bin/init_exercise.py
//! [canonical-data]... | code_fim | hard | {
"lang": "rust",
"repo": "exercism/rust",
"path": "/exercises/practice/rail-fence-cipher/tests/rail-fence-cipher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> it.sort();
let head = it.first();
let last = it.last();
match head {
Some(h) => match last {
Some(l) => h + l,
_ => panic!("No last element"),
},
_ => panic!("No head element"),
}
}<|fim_prefix|>// repo: icyJoseph/advent-of-code path: ... | code_fim | hard | {
"lang": "rust",
"repo": "icyJoseph/advent-of-code",
"path": "/2020/nine/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'outer: loop {
let slice = &list[start..];
end = start + 1;
let mut acc = 0;
for item in slice {
acc = acc + item;
if acc == weakness {
break 'outer;
}
if acc > weakness {
break;
... | code_fim | hard | {
"lang": "rust",
"repo": "icyJoseph/advent-of-code",
"path": "/2020/nine/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icyJoseph/advent-of-code path: /2020/nine/src/lib.rs
extern crate one;
use one::find_complement;
pub fn part_one(list: &Vec<i64>) -> i64 {
let preamble = 25;
let mut pivot: usize = 0;
loop {
let current = list[pivot + preamble];
let slice = &list[pivot..pivot + pre... | code_fim | hard | {
"lang": "rust",
"repo": "icyJoseph/advent-of-code",
"path": "/2020/nine/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/examples/route53/src/bin/route53-helloworld.rs
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use route53::{Client, Region};
use aws_config::meta::region::RegionProviderChain;
use structopt::S... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/examples/route53/src/bin/route53-helloworld.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for hz in hosted_zones.hosted_zones.unwrap_or_default() {
let zone_name = hz.name.as_deref().unwrap_or_default();
let zone_id = hz.id.as_deref().unwrap_or_default();
println!("Zone ID : {}, Zone Name : {}", zone_id, zone_name);
}
Ok(())
}<|fim_prefix|>// repo: mnts26/... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/examples/route53/src/bin/route53-helloworld.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpcsdk/rust.cpclib path: /cpclib/src/cpc/z80.rs
///! Manage z80 CPU
///! Could be used to simulate or generate code
use std::mem::swap;
use std::fmt::Debug;
use std::fmt;
pub trait HasValue {
type ValueType;
/// Retreive the stored value
fn value(&self) -> Self::ValueType;
fn... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib/src/cpc/z80.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn d(&mut self)-> &mut Register8 {
let tmp = self.de();
tmp.high()
}
pub fn e(&mut self)-> &mut Register8 {
let tmp = self.de();
tmp.low()
}
pub fn h(&mut self)-> &mut Register8 {
let tmp = self.hl();
tmp.high()
}
pub fn l(&mut se... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib/src/cpc/z80.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>er;
pub mod variable_handler;
pub mod undefined_handler;
pub mod assign_handler;
pub mod identifier_handler;
pub mod if_handler;
pub mod array_handler;<|fim_prefix|>// repo: arielhenryson/cheetah path: /cheetah_lib/src/executor/handlers/mod.rs
pub mod return_handler;
pub mod block_handler;
pub mod binary... | code_fim | medium | {
"lang": "rust",
"repo": "arielhenryson/cheetah",
"path": "/cheetah_lib/src/executor/handlers/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arielhenryson/cheetah path: /cheetah_lib/src/executor/handlers/mod.rs
pub mod return_handler;
pub mod block_handler;
pub mod binary_expression_handler;
pub mod number_handler;
pub mod function_handler;
pub mod call_handl<|fim_suffix|>dler;
pub mod identifier_handler;
pub mod if_handler;
pub mod ... | code_fim | medium | {
"lang": "rust",
"repo": "arielhenryson/cheetah",
"path": "/cheetah_lib/src/executor/handlers/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>dler;
pub mod identifier_handler;
pub mod if_handler;
pub mod array_handler;<|fim_prefix|>// repo: arielhenryson/cheetah path: /cheetah_lib/src/executor/handlers/mod.rs
pub mod return_handler;
pub mod block_handler;
pub mod binary_expression_handler;
pub mod number_handler;
pub mod function_handler;
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "arielhenryson/cheetah",
"path": "/cheetah_lib/src/executor/handlers/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (name, svc) in compose.services.iter() {
if svc.build.is_none() {
compose.podman.run(vec!["pull".to_string(), svc.image.clone().unwrap()]);
}
}
Ok(())
}
}<|fim_prefix|>// repo: semtexzv/podcomp path: /src/cmds/pull.rs
use crate::prel... | code_fim | medium | {
"lang": "rust",
"repo": "semtexzv/podcomp",
"path": "/src/cmds/pull.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: semtexzv/podcomp path: /src/cmds/pull.rs
use crate::prelude::*;
use crate::cmds::Command;
use crate::compose::Compose;
use crate::GlobalOpts;
#[derive(Debug, Clone, StructOpt)]
pub struct PullOpts {
#[structopt(long = "ignore-pull-failures")]
ignore_failures: bool,
#[structopt(long ... | code_fim | medium | {
"lang": "rust",
"repo": "semtexzv/podcomp",
"path": "/src/cmds/pull.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tpdlqj965/github_practice path: /src/main.rs
use std::fs::File;
use std::io;
use std::io::prelude::*;
fn main() {
let mut f = File::open("kim.fasta").expect("Can't open this file.");
let mut contents = String::new();
f.read_to_string(&mut contents)
.expect("Can't read this... | code_fim | medium | {
"lang": "rust",
"repo": "tpdlqj965/github_practice",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tokens: Vec<&str> = contents.split("\n").collect();
let mut buffer = String::new();
for (index. char) in tokens[1].chars().enumerate() {
let str1:String = (&char).to_string();
if index % n == 0 {
if index != 0 {
buffer.push_str(&str1);
... | code_fim | hard | {
"lang": "rust",
"repo": "tpdlqj965/github_practice",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rnestler/gerber-types-rs path: /examples/two-boxes.rs
//! Example from spec chapter 2.12.1
extern crate gerber_types;
use std::io::stdout;
use gerber_types::{Command};
use gerber_types::{ExtendedCode, Unit, FileAttribute, GenerationSoftware, Part, Polarity,
ApertureDefiniti... | code_fim | hard | {
"lang": "rust",
"repo": "rnestler/gerber-types-rs",
"path": "/examples/two-boxes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let cf = CoordinateFormat::new(2, 5);
let commands: Vec<Command> = vec![
FunctionCode::GCode(
GCode::Comment("Ucamco ex. 1: Two square boxes".to_string())
).into(),
ExtendedCode::CoordinateFormat(cf).into(),
ExtendedCode::Unit(Unit::Millimete... | code_fim | hard | {
"lang": "rust",
"repo": "rnestler/gerber-types-rs",
"path": "/examples/two-boxes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cf = CoordinateFormat::new(2, 5);
let commands: Vec<Command> = vec![
FunctionCode::GCode(
GCode::Comment("Ucamco ex. 1: Two square boxes".to_string())
).into(),
ExtendedCode::CoordinateFormat(cf).into(),
ExtendedCode::Unit(Unit::Millimeters).into(),
... | code_fim | hard | {
"lang": "rust",
"repo": "rnestler/gerber-types-rs",
"path": "/examples/two-boxes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pyigyli/WebAssembly-JRPG path: /src/game/animation/mod.rs
pub mod character;
pub mod enemy;
use crate::game::battle::state::BattleState;
<|fim_suffix|>#[derive(Clone, Copy)]
pub enum Animation {
StartTurn,
EndTurn,
Attack,
Hurt(for<'a> fn(&'a mut BattleState, f64), f64),
HurtSelf(for... | code_fim | medium | {
"lang": "rust",
"repo": "pyigyli/WebAssembly-JRPG",
"path": "/src/game/animation/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Copy)]
pub enum Animation {
StartTurn,
EndTurn,
Attack,
Hurt(for<'a> fn(&'a mut BattleState, f64), f64),
HurtSelf(for<'a> fn(&'a mut BattleState, f64), f64),
Dead,
Victory,
Flee,
WalkTile(Direction),
NpcWalkTile(Direction)
}<|fim_prefix|>// repo: pyigyli/WebAssembly-JRP... | code_fim | medium | {
"lang": "rust",
"repo": "pyigyli/WebAssembly-JRPG",
"path": "/src/game/animation/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PSeitz/rust-hdbconnect path: /src/types_impl/lob/blob.rs
use super::fetch::fetch_a_lob_chunk;
use crate::conn::AmConnCore;
use crate::protocol::parts::AmRsCore;
use crate::protocol::ServerUsage;
use crate::{HdbError, HdbResult};
use std::boxed::Box;
use std::collections::VecDeque;
use std::io::W... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/rust-hdbconnect",
"path": "/src/types_impl/lob/blob.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.total_byte_length
}
fn cur_buf_len(&self) -> usize {
self.data.len()
}
#[allow(clippy::cast_possible_truncation)]
fn fetch_next_chunk(&mut self) -> HdbResult<()> {
if self.is_data_complete {
return Err(HdbError::Impl("fetch_next_chunk(): alrea... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/rust-hdbconnect",
"path": "/src/types_impl/lob/blob.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> trace!("into_bytes()");
self.load_complete()?;
Ok(Vec::from(self.data))
}
}
// Support for streaming
impl std::io::Read for BLobHandle {
fn read(&mut self, mut buf: &mut [u8]) -> std::io::Result<usize> {
let buf_len = buf.len();
trace!("BLobHandle::read() w... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/rust-hdbconnect",
"path": "/src/types_impl/lob/blob.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Newton step, repeating increases accuracy
y = y * ( THREE_HALFS - ( half_x * y * y ) ); // 1st iteration
// this can be removed
// y = y * ( THREE_HALFS - ( half_x * y * y ) ); // 2nd iteration
return y;
}
}
impl Square for f32 {
#[inline(always)]
fn sq(self) -> f32 { self*self }
}
#[de... | code_fim | hard | {
"lang": "rust",
"repo": "q2p/tiny_lib",
"path": "/src/util.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: q2p/tiny_lib path: /src/util.rs
use core::num::NonZeroI8;
use core::ops::*;
use core::cmp::Ordering;
use core::f32::consts::PI;
use crate::matrices::*;
use crate::vector::*;
#[inline(always)]
pub fn projection_matrix(fov_degrees:f32, aspect_ratio:f32, plane_near:f32, plane_far:f32) -> Matrix4x4... | code_fim | hard | {
"lang": "rust",
"repo": "q2p/tiny_lib",
"path": "/src/util.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline(always)]
fn gt(&self, other: &NonZeroSignum) -> bool { (*self) > (other.0.get() as $t) }
#[inline(always)]
fn ge(&self, other: &NonZeroSignum) -> bool { (*self) >= (other.0.get() as $t) }
}
impl_assign!($t);
)*
}
}
macro_rules! impl_signum_unsigned {
($real:ty, $temp:ty... | code_fim | hard | {
"lang": "rust",
"repo": "q2p/tiny_lib",
"path": "/src/util.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Transform {
pub fn identity() -> Transform {
Transform {
decomp: Decomposed::one()
}
}
pub fn from_rot<A: Angle + Into<Rad<f32>>>(angle: A) -> Transform {
Transform {
decomp: Decomposed {
scale: 1.0,
disp: ve... | code_fim | medium | {
"lang": "rust",
"repo": "shivshank/easy_canvas",
"path": "/easy_canvas/src/transform.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_rot<A: Angle + Into<Rad<f32>>>(angle: A) -> Transform {
Transform {
decomp: Decomposed {
scale: 1.0,
disp: vec2(0.0 , 0.0),
rot: Rotation2::from_angle(angle)
}
}
}
}<|fim_prefix|>// repo: shivshank/... | code_fim | medium | {
"lang": "rust",
"repo": "shivshank/easy_canvas",
"path": "/easy_canvas/src/transform.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shivshank/easy_canvas path: /easy_canvas/src/transform.rs
use cgmath::prelude::*;
use cgmath::{Decomposed, Basis2, Rotation2, Vector2, vec2, Transform as CgMathTransformTrait, Rad};
#[derive(Debug, Clone, Copy)]
pub struct Transform {
decomp: Decomposed<Vector2<f32>, Basis2<f32>>
}
<|fim_s... | code_fim | medium | {
"lang": "rust",
"repo": "shivshank/easy_canvas",
"path": "/easy_canvas/src/transform.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Serialize)]
pub struct PostSplit(pub Split);
impl Request for PostSplit {
type Body = Split;
type Response = EmptyResponse;
const METHOD: Method = Method::POST;
fn endpoint(&self) -> Cow<str> {
Cow::Borrowed("/splits")
}
fn body(&self) -> RequestBo... | code_fim | hard | {
"lang": "rust",
"repo": "Overmuse/datastore",
"path": "/client/src/routes/splits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Overmuse/datastore path: /client/src/routes/splits.rs
use crate::request::{EmptyResponse, Request, RequestBody};
use chrono::NaiveDate;
use datastore_core::Split;
use reqwest::Method;
use serde::Serialize;
use std::borrow::Cow;
#[derive(Debug, Default, Clone, Serialize)]
pub struct GetSplits {
... | code_fim | medium | {
"lang": "rust",
"repo": "Overmuse/datastore",
"path": "/client/src/routes/splits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..(m-n+1) {
let x = haystack.get(i..(i+n));
// println!("{}", x.unwrap());
match x {
Some(s) => {
if (s == needle) {
ans = i as i32;
break;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "fujiehuang/leetcode-rust",
"path": "/28.implement-str-str.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fujiehuang/leetcode-rust path: /28.implement-str-str.rs
/*
* @lc app=leetcode id=28 lang=rust
*
* [28] Implement strStr()
*/
// @lc code=start
use std::collections::LinkedList;
impl Solution {
pub fn str_str(haystack: String, needle: String) -> i32 {
let m = haystack.len();
... | code_fim | hard | {
"lang": "rust",
"repo": "fujiehuang/leetcode-rust",
"path": "/28.implement-str-str.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lnicola/serde_fix path: /fix50sp2/src/leg_payment_stub_end_date_business_center_grp.rs
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct LegPaymentStubEndDateBusinessCenterGrp {
/// NoLegPaymentStubEndDateBusinessCenters
#[ser... | code_fim | medium | {
"lang": "rust",
"repo": "lnicola/serde_fix",
"path": "/fix50sp2/src/leg_payment_stub_end_date_business_center_grp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>aymentStubEndDateBusinessCenter>>,
}
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct LegPaymentStubEndDateBusinessCenter {
/// Required if NoLegPaymentStubEndDateBusinessCenters(42495) > 0.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "42496")]
... | code_fim | medium | {
"lang": "rust",
"repo": "lnicola/serde_fix",
"path": "/fix50sp2/src/leg_payment_stub_end_date_business_center_grp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Drumato/Depth path: /src/compile/backend/reaching.rs
use super::Optimizer;
use crate::compile::ir::tac::Operand;
use std::collections::BTreeSet;
impl Optimizer {
pub fn reaching_definition(&mut self) {
let mut reach_in: Vec<BTreeSet<Operand>> = vec![BTreeSet::new(); self.tacs.len()... | code_fim | hard | {
"lang": "rust",
"repo": "Drumato/Depth",
"path": "/src/compile/backend/reaching.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ne());
for s in self.cfg.pred[idx].iter() {
reach_in[idx] = &reach_in[idx] | &reach_out[*s];
}
reach_out[idx] = &self.cfg.used[idx] | &(&reach_in[idx] - &self.cfg.def[idx]);
}
let mut chg_flg: bool = true;
... | code_fim | hard | {
"lang": "rust",
"repo": "Drumato/Depth",
"path": "/src/compile/backend/reaching.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> generate_random_parameters(c, rng).unwrap()
};
// Prepare the verification key (for proof verification)
let pvk = prepare_verifying_key(¶ms.vk);
println!("Creating proofs...");
// Create an instance of circuit
let c = CubeDemo::<Bls12> {
x: <Bls12 as ScalarEn... | code_fim | hard | {
"lang": "rust",
"repo": "hotlightline/Bellman-examples",
"path": "/src/cube.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hotlightline/Bellman-examples path: /src/cube.rs
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use rand_core::OsRng;
use ff::*;
use pairing::Engine;
use pairing::bls12_381::Bls12;
use bellman::{Circuit, ConstraintSystem, SynthesisError};
use bellman::groth16::{
... | code_fim | hard | {
"lang": "rust",
"repo": "hotlightline/Bellman-examples",
"path": "/src/cube.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn node() {
let result = Node::from_list(get_list());
assert_eq!(result.len(), 8);
}
#[test]
fn group() {
let result = Group::from_list(get_list());
assert_eq!(result.len(), 8);
}<|fim_prefix|>// repo: pontuslaestadius/pathtracer path: /src/tests/from_list.rs
use crate::*;
// Li... | code_fim | hard | {
"lang": "rust",
"repo": "pontuslaestadius/pathtracer",
"path": "/src/tests/from_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = Coordinate::from_list(get_list());
assert_eq!(result.len(), 8);
}
#[test]
fn node() {
let result = Node::from_list(get_list());
assert_eq!(result.len(), 8);
}
#[test]
fn group() {
let result = Group::from_list(get_list());
assert_eq!(result.len(), 8);
}<|fim_prefix|>... | code_fim | hard | {
"lang": "rust",
"repo": "pontuslaestadius/pathtracer",
"path": "/src/tests/from_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pontuslaestadius/pathtracer path: /src/tests/from_list.rs
use crate::*;
// List used for calling from_list tests.
fn get_list<'a>() -> &'a [(i16, i16); 8] {
&[
(0, 0), // Default test,
(100, 100), // Two positive values test,
(50, -50), // One positi... | code_fim | medium | {
"lang": "rust",
"repo": "pontuslaestadius/pathtracer",
"path": "/src/tests/from_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/redshiftdata/src/error_meta.rs
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[non_exhaustive]
#[derive(std::fmt::Debug)]
pub enum Error {
ActiveStatementsExceededException(crate::error::ActiveStatementsExceededException),
... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/redshiftdata/src/error_meta.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PacktPublishing/Rust-High-Performance path: /Chapter02/example3.rs
use std::time::Duration;
use std::thread;
fn is_the_car_in_place() -> bool {
unimplemented!()
}
fn is_the_bolt_in_place() -> bool {
unimplemented!()
}
fn move_arm_to_new_door() {
unimplemented!();
}
fn move_arm_to_ca... | code_fim | hard | {
"lang": "rust",
"repo": "PacktPublishing/Rust-High-Performance",
"path": "/Chapter02/example3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<DoorMachine<PlacingDoor>> for DoorMachine<WaitingCar> {
fn from(st: DoorMachine<PlacingDoor>) -> DoorMachine<WaitingCar> {
move_arm_to_car();
while !is_the_bolt_in_place() {
turn_bolt();
}
DoorMachine { state: WaitingCar }
}
}
// Will panic
f... | code_fim | hard | {
"lang": "rust",
"repo": "PacktPublishing/Rust-High-Performance",
"path": "/Chapter02/example3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loganintech/rtx-notifier path: /src/scraping/bestbuy.rs
use async_trait::async_trait;
use lazy_static::lazy_static;
use regex::{Regex, RegexBuilder};
use reqwest::header::HeaderMap;
use crate::{error::NotifyError, product::Product, scraping::ScrapingProvider};
<|fim_suffix|>pub struct BestBuyS... | code_fim | hard | {
"lang": "rust",
"repo": "loganintech/rtx-notifier",
"path": "/src/scraping/bestbuy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn handle_response(
&'a self,
resp: reqwest::Response,
product: &'a Product,
) -> Result<Product, NotifyError> {
let resp = resp
.text()
.await
.map_err(|_| NotifyError::HTMLParseFailed)?;
// If we can't find the so... | code_fim | hard | {
"lang": "rust",
"repo": "loganintech/rtx-notifier",
"path": "/src/scraping/bestbuy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = Ok(2);
assert_eq!(
convert!(res, ok => Message::created, UserErrorHandler::default()),
Ok(Message::created(2))
);
}
#[test]
fn test_server_error() {
let res: Result<usize, _> = Err(Error2::ServerError);
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "boydjohnson/tide-errors",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boydjohnson/tide-errors path: /src/macros.rs
#[macro_export]
macro_rules! convert {
($res:ident, ok => $f:expr, $($conversion:expr),+) => {
{
let mut converter = $crate::conversions::Converter::default();
$(
converter.add_conversion($conversio... | code_fim | hard | {
"lang": "rust",
"repo": "boydjohnson/tide-errors",
"path": "/src/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> UserErrorHandler
}
}
impl<T> ConversionHandler<T, Error, Error2> for UserErrorHandler {
fn possibly_convert(
&mut self,
res: &Result<T, Error2>,
) -> Option<Result<Message<T, Error>, Error2>> {
match res {
Err... | code_fim | hard | {
"lang": "rust",
"repo": "boydjohnson/tide-errors",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl convert::From<Tuple<PatternId>> for Pattern {
fn from(t: Tuple<PatternId>) -> Pattern { Pattern::Tuple(t) }
}<|fim_prefix|>// repo: matthieu-m/stysh path: /stysh-compile/src/model/hir/pattern.rs
//! Patterns
use std::convert;
use crate::basic::com;
use crate::model::hir::*;
/// A Pattern
#[d... | code_fim | medium | {
"lang": "rust",
"repo": "matthieu-m/stysh",
"path": "/stysh-compile/src/model/hir/pattern.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matthieu-m/stysh path: /stysh-compile/src/model/hir/pattern.rs
//! Patterns
use std::convert;
use crate::basic::com;
use crate::model::hir::*;
/// A Pattern
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub enum Pattern {
/// A constructor.
Constructor(Tuple<Pat... | code_fim | medium | {
"lang": "rust",
"repo": "matthieu-m/stysh",
"path": "/stysh-compile/src/model/hir/pattern.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//
// From Implementations
//
impl convert::From<Tuple<PatternId>> for Pattern {
fn from(t: Tuple<PatternId>) -> Pattern { Pattern::Tuple(t) }
}<|fim_prefix|>// repo: matthieu-m/stysh path: /stysh-compile/src/model/hir/pattern.rs
//! Patterns
use std::convert;
use crate::basic::com;
use crate::... | code_fim | medium | {
"lang": "rust",
"repo": "matthieu-m/stysh",
"path": "/stysh-compile/src/model/hir/pattern.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spyder-ide/pysyntect path: /src/loading.rs
/// Public functions to load syntax definitions and highlighting themes
// PyO3 imports
use pyo3::prelude::*;
// Syntect imports
use syntect::parsing::SyntaxSet;
use syntect::highlighting::ThemeSet;
// Local imports
use crate::base::syntax::SyntaxSet... | code_fim | hard | {
"lang": "rust",
"repo": "spyder-ide/pysyntect",
"path": "/src/loading.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Load syntax highlighting themes defined in .tmTheme format.
///
/// Parameters
/// ------
/// folder: str
/// Path that points to a folder that contains syntax highlighting themes.
///
/// Returns
/// -------
/// theme_set:
/// Handle to a map of theme handles, mapped by the theme names.
///
... | code_fim | hard | {
"lang": "rust",
"repo": "spyder-ide/pysyntect",
"path": "/src/loading.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Load syntax defintion files in .sublime-syntax format located on a folder.
///
/// Parameters
/// ------
/// folder: str
/// Path that points to a folder containing syntax definition files.
///
/// Returns
/// -------
/// syntax_set: SyntaxSet
/// Handle to a list of syntax definition objects... | code_fim | medium | {
"lang": "rust",
"repo": "spyder-ide/pysyntect",
"path": "/src/loading.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
(self.0)();
}
}
}
// TODO: Modify this comment to include links to relevant docs/issues
// On Mac, TLS cannot be accessed while a dynamic library is being loaded (at least, that's what it
// appears from our own experimentation with DYLD_INSERT_LIBRARIES). Unfort... | code_fim | hard | {
"lang": "rust",
"repo": "cormacrelf/allocators-rs",
"path": "/alloc-tls/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Use #[cold] to make it more likely that LLVM won't inline the call to with_slow in with,
// which would bloat the instruction cache.
#[doc(hidden)]
#[cold]
pub unsafe fn with_slow<R, F: FnOnce(&T) -> R>(&self, f: F) -> Option<R> {
let slot = self.slot.get();
match &*... | code_fim | hard | {
"lang": "rust",
"repo": "cormacrelf/allocators-rs",
"path": "/alloc-tls/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cormacrelf/allocators-rs path: /alloc-tls/src/lib.rs
the LICENSE-APACHE file) or
// the MIT license (the LICENSE-MIT file) at your option. This file may not be
// copied, modified, or distributed except according to those terms.
//! Allocator-safe thread-local storage.
//!
//! `alloc-tls` imple... | code_fim | hard | {
"lang": "rust",
"repo": "cormacrelf/allocators-rs",
"path": "/alloc-tls/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut v1 = vec![1, 10, 5, 1, 2, 11, 2, 40];
println!("befor sort -> {:?}", v1);
v1.sort();
println!("after sort -> {:?}", v1);
v1.dedup(); // remove duplicated elements
println!("after dedup -> {:?}", v1);
assert_eq!(v1, &[1, 2, 5, 10, 11, 40]);
}
#[allow(dead_code)]
pub fn a... | code_fim | hard | {
"lang": "rust",
"repo": "avnigenc/rust",
"path": "/src/include_me.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avnigenc/rust path: /src/include_me.rs
#[allow(dead_code)]
pub fn array() {
let array = [10, 11, 12, 13];
println!("first -> {}", array[0]);
for i in 0..array.len() {
println!("[{}] -> {}", i, array[i]);
}
println!("len -> {}", array.len());
}
#[allow(dead_code)... | code_fim | hard | {
"lang": "rust",
"repo": "avnigenc/rust",
"path": "/src/include_me.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
pub fn more_about_vectors() {
let mut v1 = vec![10, 20, 30, 40];
v1.pop();
let mut v2 = Vec::new();
v2.push(10);
v2.push(20);
v2.push(30);
assert_eq!(v1, v2);
v2.extend(0..2);
assert_eq!(v2, &[10, 20, 30, 0, 1]);
let mut v1 = vec![1, 10, 5, 1... | code_fim | hard | {
"lang": "rust",
"repo": "avnigenc/rust",
"path": "/src/include_me.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
#[test]
fn returns_vec() {
let transactions = mocks::MockTransactions {
vec: std::vec![mocks::MockTransaction { value: 42 }, mocks::MockTransaction { value: 43 }]
};
assert_eq!(transactions.vec().length, 2)
}
}<|fim_prefix|>// repo:... | code_fim | easy | {
"lang": "rust",
"repo": "DICAPITATOR/ZK-snark_blockchain",
"path": "/chain/src/transactions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(transactions.vec().length, 2)
}
}<|fim_prefix|>// repo: DICAPITATOR/ZK-snark_blockchain path: /chain/src/transactions.rs
use std;
pub trait Transactions {
type Transaction : std::convert::AsRef<[u8]>;
fn vec(&self) -> std::vec::Vec<&Self::Transaction>;
}
<|fim_middle|>#[... | code_fim | hard | {
"lang": "rust",
"repo": "DICAPITATOR/ZK-snark_blockchain",
"path": "/chain/src/transactions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DICAPITATOR/ZK-snark_blockchain path: /chain/src/transactions.rs
use std;
pub trait Transactions {
type Transaction : std::convert::AsRef<[u8]>;
fn vec(&self) -> std::vec::Vec<&Self::Transaction>;
}
#[cfg(test)]
use super::mocks;
#[cfg(test)]
mod tests {
#[test]
fn returns_ve... | code_fim | medium | {
"lang": "rust",
"repo": "DICAPITATOR/ZK-snark_blockchain",
"path": "/chain/src/transactions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtrain157/rust-graphql-example path: /src/db/models/team.rs
use diesel::QueryableByName;
<|fim_suffix|>#[derive(QueryableByName)]
#[table_name = "teams"]
pub struct Team {
pub id: i32,
pub name: String,
}<|fim_middle|>pub use crate::db::schema::teams;
| code_fim | easy | {
"lang": "rust",
"repo": "dtrain157/rust-graphql-example",
"path": "/src/db/models/team.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(QueryableByName)]
#[table_name = "teams"]
pub struct Team {
pub id: i32,
pub name: String,
}<|fim_prefix|>// repo: dtrain157/rust-graphql-example path: /src/db/models/team.rs
use diesel::QueryableByName;
<|fim_middle|>pub use crate::db::schema::teams;
| code_fim | easy | {
"lang": "rust",
"repo": "dtrain157/rust-graphql-example",
"path": "/src/db/models/team.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wtnb75/benchy path: /src/rusage.rs
use libc::{c_long, getrusage, rusage, suseconds_t, time_t, timeval, RUSAGE_CHILDREN, RUSAGE_SELF};
use std::fmt;
use std::ops::Sub;
#[derive(Debug, Copy, Clone)]
pub struct Usage {
utime: f64,
stime: f64,
max_rss: isize,
ix_rss: isize,
id_r... | code_fim | hard | {
"lang": "rust",
"repo": "wtnb75/benchy",
"path": "/src/rusage.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rusage {
ru_utime: timeval {
tv_sec: 0 as time_t,
tv_usec: 0 as suseconds_t,
},
ru_stime: timeval {
tv_sec: 0 as time_t,
tv_usec: 0 as suseconds_t,
},
ru_maxrss: 0 as c_long,... | code_fim | hard | {
"lang": "rust",
"repo": "wtnb75/benchy",
"path": "/src/rusage.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl error::Error for XmlError {
fn description(&self) -> &str {
match *self {
XmlError::UnknownTag => "unknown MathML tag",
}
}
}<|fim_prefix|>// repo: openstax/math-editor-sprint path: /übertool/src/format/mathml/error.rs
use std::error;
use std::fmt;
#[derive(Debug)]
pub enum XmlErr... | code_fim | medium | {
"lang": "rust",
"repo": "openstax/math-editor-sprint",
"path": "/übertool/src/format/mathml/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: openstax/math-editor-sprint path: /übertool/src/format/mathml/error.rs
use std::error;
use std::fmt;
#[derive(Debug)]
pub enum XmlError {
UnknownTag,
}
impl fmt::Display for XmlError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{:?}", self)
}
}
<|fim_suffi... | code_fim | medium | {
"lang": "rust",
"repo": "openstax/math-editor-sprint",
"path": "/übertool/src/format/mathml/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: areteCocoa/yasl_compiler path: /src/lib.rs
mod lexer;
mod parser;
use lexer::{LexerResult, LexerError};
use lexer::read_file;
pub use parser::{Parser, ParserResult};
<|fim_suffix|> println!("<YASLC> Successful lexical analysis of file. Parsing.");
let mut parser = Parser::new_with_tok... | code_fim | hard | {
"lang": "rust",
"repo": "areteCocoa/yasl_compiler",
"path": "/src/lib.rs",
"mode": "psm",
"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.