text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> {
let file_lock = ExclusiveFlock::wait_lock(&file)?;
// file_lock, type: FlockLock<&File>
println!("{:?}", file_lock);
} // auto unlock ExclusiveFlock
file.sync_all()?;
Ok( () )
}<|fim_prefix|>// repo: clucompany/cluFlock path: /examples/exclusive_slice_file.rs
use cluFlock::ExclusiveFlock;... | code_fim | medium | {
"lang": "rust",
"repo": "clucompany/cluFlock",
"path": "/examples/exclusive_slice_file.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>(
b
'
-
'
)
if
!
only_literal
=
>
{
self
.
ptr
+
=
1
;
/
/
-
if
self
.
is_identifier_start
(
)
{
self
.
ptr
+
=
1
;
let
id
=
self
.
get_identifier_unchecked
(
)
;
let
attribute
=
self
.
get_attribute_accessor
(
)
?
;
let
arguments
=
self
.
get_call_arguments
(
)
?
;
Ok
(
ast
:
:
InlineExpression
:
:
TermR... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/fluent-syntax/src/parser/expression.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn
get_call_arguments
(
&
mut
self
)
-
>
Result
<
Option
<
ast
:
:
CallArguments
<
S
>
>
>
{
self
.
skip_blank
(
)
;
if
!
self
.
take_byte_if
(
b
'
(
'
)
{
return
Ok
(
None
)
;
}
let
mut
positional
=
vec
!
[
]
;
let
mut
named
=
vec
!
[
]
;
let
mut
argument_names
=
vec
!
[
]
;
self
.
skip_blank
(
)
;
whil... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/fluent-syntax/src/parser/expression.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/fluent-syntax/src/parser/expression.rs
use
super
:
:
errors
:
:
{
ErrorKind
ParserError
}
;
use
super
:
:
{
core
:
:
Parser
core
:
:
Result
slice
:
:
Slice
}
;
use
crate
:
:
ast
;
impl
<
'
s
S
>
Parser
<
S
>
where
S
:
Slice
<
'
s
>
{
pub
(
supe... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/fluent-syntax/src/parser/expression.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let exp_part = Part {
start: NaiveTime::from_hms(8,0,0),
stop: Some(NaiveTime::from_hms(11, 30, 0)),
factor: None
};
let r = super::part("08:00-11:30".as_bytes());
assert_eq!(r, IResult::Done(&b""[..], exp_part));
}
#[test]
... | code_fim | hard | {
"lang": "rust",
"repo": "marwahaha/reti",
"path": "/storage/src/legacy_parser.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marwahaha/reti path: /storage/src/legacy_parser.rs
use nom::{digit, multispace, not_line_ending, IResult};
use chrono::{NaiveDate, NaiveTime};
use data::{Part, Day};
use std;
#[derive(Debug,PartialEq,Eq,Clone)]
pub enum ParserError {
IgnoreLine,
DayParseError,
EmptyLine
}
//impl F... | code_fim | hard | {
"lang": "rust",
"repo": "marwahaha/reti",
"path": "/storage/src/legacy_parser.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(super::date("2017-03-21".as_bytes()),
IResult::Done(&b""[..], NaiveDate::from_ymd(2017, 3, 21)));
}
#[test]
fn test_parse_time() {
assert_eq!(super::time("16:43".as_bytes()),
IResult::Done(&b""[..], NaiveTime::from_hms(16, 43, 0)));
... | code_fim | hard | {
"lang": "rust",
"repo": "marwahaha/reti",
"path": "/storage/src/legacy_parser.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvanbem/oot-explorer path: /oot-explorer-game-data/src/macros.rs
@parse Struct {
name: $name
size: $size
align_bits: $align_bits
is_end: $is_end
prev_field: (Some($field_name))
fields: [
... | code_fim | hard | {
"lang": "rust",
"repo": "mvanbem/oot-explorer",
"path": "/oot-explorer-game-data/src/macros.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvanbem/oot-explorer path: /oot-explorer-game-data/src/macros.rs
addr: oot_explorer_vrom::VromAddr,
}
::paste::paste! {
#[allow(dead_code)]
impl $name {
$(
compile_interfaces!(@emit_field_accessor $field);
... | code_fim | hard | {
"lang": "rust",
"repo": "mvanbem/oot-explorer",
"path": "/oot-explorer-game-data/src/macros.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Remainder of input.
$($tail:tt)*
) => {
compile_interfaces! {
// We are now parsing a union.
@parse Union {
name: $name
size: $size
align_bits: $align_bits
is_end: $is_end
... | code_fim | hard | {
"lang": "rust",
"repo": "mvanbem/oot-explorer",
"path": "/oot-explorer-game-data/src/macros.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aswanthpp/RUST-Sample-Programs path: /Sample Codes/structure.rs
struct character {
name : String,
life : u32
}
fn main(){
impl character{
fn new(name : String) -> Character {
<|fim_suffix|>// Resolve this code issue with declaration of structure<|fim_middle|> return Character{ name: nam... | code_fim | medium | {
"lang": "rust",
"repo": "aswanthpp/RUST-Sample-Programs",
"path": "/Sample Codes/structure.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Resolve this code issue with declaration of structure<|fim_prefix|>// repo: aswanthpp/RUST-Sample-Programs path: /Sample Codes/structure.rs
struct character {
name : String,
life : u32
}
fn main(){
impl character{
fn new(name : String) -> Character {
return Character{ name: name , life:100};... | code_fim | medium | {
"lang": "rust",
"repo": "aswanthpp/RUST-Sample-Programs",
"path": "/Sample Codes/structure.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub struct Indexer {
pub index: SpellIndex,
writer: IndexWriter,
}
impl Indexer {
pub fn new(index: SpellIndex) -> tantivy::Result<Idx> {
Ok(Arc::new(Self {
writer: index.tantivy_index.writer(50_000_000)?,
index,
... | code_fim | hard | {
"lang": "rust",
"repo": "isaacthefallenapple/spell5erver",
"path": "/src/db.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn commit(&mut self) -> tantivy::Result<()> {
self.writer.commit()?;
Ok(())
}
pub async fn search(&self, query_text: &str) -> tantivy::Result<Vec<String>> {
self.index.search(query_text)
}
}
/* lazy_static! {
static ... | code_fim | hard | {
"lang": "rust",
"repo": "isaacthefallenapple/spell5erver",
"path": "/src/db.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isaacthefallenapple/spell5erver path: /src/db.rs
use crate::spell::Spell;
use std::{collections::HashMap, fs, path::Path, sync::Arc};
use tokio::sync::Mutex;
pub type Db = Arc<HashMap<String, Spell>>;
pub fn build(path: impl AsRef<Path>) -> Db {
let data = fs::File::open(path.as_ref()).exp... | code_fim | hard | {
"lang": "rust",
"repo": "isaacthefallenapple/spell5erver",
"path": "/src/db.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern crate coherence_lib as lib;
use lib::*;
use std::rc::Rc;
struct Local;
impl Remote1<u32> for f64 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Remote1<u32> for f64 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.rs
#![feature(re_rebalance_coher... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.rs
#![feature(re_rebalance_coherence)]
<|fim_suffix|>impl Remote1<u32> for f64 {
//~^ ERROR only traits defined in the current crate
// | can be implemented for arbitrary types [E0117]
}
fn m... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akegalj/algorithms_playground path: /advent-of-code/2021/day9/part1.rs
use std::cmp::{max, min};
use std::collections::HashSet;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let reader = BufReader::new(File::open("input").unwrap());
let coords = reader
.lines... | code_fim | hard | {
"lang": "rust",
"repo": "akegalj/algorithms_playground",
"path": "/advent-of-code/2021/day9/part1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let coord = coords.get(y).unwrap().get(x).unwrap();
if coord < &up && coord < &down && coord < &left && coord < &right {
res += (1 + coord);
}
}
}
println!("{}", res);
}<|fim_prefix|>// repo: akegalj/algorithms_playground path: /advent-... | code_fim | hard | {
"lang": "rust",
"repo": "akegalj/algorithms_playground",
"path": "/advent-of-code/2021/day9/part1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if coord < &up && coord < &down && coord < &left && coord < &right {
res += (1 + coord);
}
}
}
println!("{}", res);
}<|fim_prefix|>// repo: akegalj/algorithms_playground path: /advent-of-code/2021/day9/part1.rs
use std::cmp::{max, min};
use std::col... | code_fim | hard | {
"lang": "rust",
"repo": "akegalj/algorithms_playground",
"path": "/advent-of-code/2021/day9/part1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline]
unsafe fn emit_results(results: Vec<SuggestItem>) {
let num_items: [u8; 4] = transmute(results.len() as u32);
let mut payload: Vec<u8> = vec![num_items[0], num_items[1], num_items[2], num_items[3]];
for suggest_item in results {
let item = suggest_item.encode();
let ... | code_fim | hard | {
"lang": "rust",
"repo": "Devmacs/spellchecker-wasm",
"path": "/src/spellchecker_wasm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Devmacs/spellchecker-wasm path: /src/spellchecker_wasm.rs
use std::mem::transmute;
use std::slice;
use std::str;
use crate::sym_spell::sym_spell::SymSpell;
use crate::sym_spell::verbosity::Verbosity;
use crate::sym_spell::Encode;
use crate::sym_spell::suggested_item::SuggestItem;
static mut SY... | code_fim | hard | {
"lang": "rust",
"repo": "Devmacs/spellchecker-wasm",
"path": "/src/spellchecker_wasm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn login(
realm_id: Uuid,
login: LoginUser,
repo: &impl Repository
) -> Result<Self, Error> {
repo.find_realm_user_by_username_password(realm_id, login)
}
}<|fim_prefix|>// repo: davedray/gatekeeper path: /domain/src/users/model.rs
use chrono::{DateTime, Ut... | code_fim | hard | {
"lang": "rust",
"repo": "davedray/gatekeeper",
"path": "/domain/src/users/model.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davedray/gatekeeper path: /domain/src/users/model.rs
use chrono::{DateTime, Utc};
use uuid::Uuid;
use crate::{Repository, Error};
pub struct User {
id: Uuid,
realm_id: Uuid,
pub username: String,
pub banned: bool,
pub suspended_until: Option<DateTime<Utc>>,
pub created_a... | code_fim | medium | {
"lang": "rust",
"repo": "davedray/gatekeeper",
"path": "/domain/src/users/model.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let j = set2
.range(..=(a[i], n))
.last()
.copied()
.map(|(_, j)| j + 1)
.unwrap_or(0);
dp[i] = dp[i].max(seg2.fold(j..i) - a[i]);
seg1.update(i, if i == 0 { -a[i] } else { dp[i - 1] - a[i] });
seg2.update(i, if i... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/codequeen2023-final-open/src/bin/e/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> seg1.update(i, if i == 0 { -a[i] } else { dp[i - 1] - a[i] });
seg2.update(i, if i == 0 { a[i] } else { dp[i - 1] + a[i] });
set1.insert((a[i], Reverse(i)));
set2.insert((a[i], i));
}
println!("{}", dp[n - 1]);
}<|fim_prefix|>// repo: ia7ck/competitive-programming ... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/codequeen2023-final-open/src/bin/e/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/codequeen2023-final-open/src/bin/e/main.rs
use std::{cmp::Reverse, collections::BTreeSet};
use proconio::input;
use segment_tree::SegmentTree;
fn main() {
input! {
n: usize,
a: [i64; n],
};
<|fim_suffix|> let j = set... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/codequeen2023-final-open/src/bin/e/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vanille-N/qsort path: /src/lib.rs
#[cfg(test)]
#[macro_use]
extern crate more_asserts;
#[allow(dead_code)]
mod qsort {
mod internal {
extern "C" {
pub fn swap(tab: *mut i64, i: usize, j: usize);
pub fn choose_pivot(tab: *const i64, lo: usize, hi: usize) -> i6... | code_fim | hard | {
"lang": "rust",
"repo": "Vanille-N/qsort",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_qsort_aux() {
let mut tab = vec![
101, 105, 104, 5, 3, 9, 1, 7, 2, 5, 6, 7, 1, 2, -207, -203, -206,
];
qsort_aux(&mut tab, 3, 14);
assert_sorted(&tab[3..14]);
}
#[test]
fn test_qsort() {
let mut tab1 = vec![1, 3, 8, 1, 7, 9, 3, 8, 5, 7, 1];
let mut tab2 = v... | code_fim | hard | {
"lang": "rust",
"repo": "Vanille-N/qsort",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Because mongo doesn't enforce an scheme, this trait discourages unsafe
/// deserialization of data, preventing data corruption. Unsafe
/// `Deserialization` structures can implement the `IntoDocument` trait for
/// easy validation of data
pub trait IntoDocument<D>
where
D: Document,
{
type Err;
... | code_fim | medium | {
"lang": "rust",
"repo": "Altair-Bueno/fuzzy-disco",
"path": "/disco-core/src/mongo/traits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Altair-Bueno/fuzzy-disco path: /disco-core/src/mongo/traits.rs
/// The Document trait marks structs as "mongo approved", which means they are
/// designed for consistency on a mongodb database
pub trait Document {}
/// The `IntoDocument` trait allows external data structures to be transformed
/... | code_fim | medium | {
"lang": "rust",
"repo": "Altair-Bueno/fuzzy-disco",
"path": "/disco-core/src/mongo/traits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_longest_path(nodes: &Vec<Node>, nodeID: i32, visited: *bool) -> i32{
let uintID = nodeID.to_uint().expect("Error, something had a negative node id");
unsafe{
let newAddr: uint = (visited as uint) + (uintID as uint);
let newAddrP: *mut bool = newAddr as *mut bool;
*newAddrP = true;... | code_fim | hard | {
"lang": "rust",
"repo": "logicchains/LPATHBench",
"path": "/rsold.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: logicchains/LPATHBench path: /rsold.rs
extern crate time;
use std::io::File;
use std::io::BufferedReader;
use time::precise_time_ns;
#[deriving(Clone, Show)]
struct Route{
dest: i32,
cost: i32
}
#[deriving(Clone, Show)]
struct Node {
neighbours: Vec<Route>
}
fn read_places(num_nodes: &... | code_fim | hard | {
"lang": "rust",
"repo": "logicchains/LPATHBench",
"path": "/rsold.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amethyst/legion path: /benches/benchmarks.rs
use criterion::*;
use itertools::*;
use legion::*;
#[derive(Copy, Clone, Debug, PartialEq)]
struct A(f32);
#[derive(Copy, Clone, Debug, PartialEq)]
struct B(f32);
#[derive(Copy, Clone, Debug, PartialEq)]
struct C(f32);
#[derive(Copy, Clone, Debug,... | code_fim | hard | {
"lang": "rust",
"repo": "amethyst/legion",
"path": "/benches/benchmarks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> b.iter(|| {
for mut c in query.iter_chunks_mut(&mut world) {
unsafe {
c.component_slice_mut::<Position>()
.unwrap()
.get_unchecked_mut(0)
.0 = 0.0
};
... | code_fim | hard | {
"lang": "rust",
"repo": "amethyst/legion",
"path": "/benches/benchmarks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match (actual, expected) {
(
List {
open_position: lhs_open_position,
open_content: lhs_start_content,
children: lhs_children,
close_content: lhs_end_content,
close_posit... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/difftastic",
"path": "/src/line_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/difftastic path: /src/line_parser.rs
//! A fallback "parser" for plain text.
use typed_arena::Arena;
use crate::{positions::SingleLineSpan, syntax::Syntax};
/// Split `s` by lines, and treat each line as an atom.
///
/// This is a fallback for files that we don't know how to parse.
pu... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/difftastic",
"path": "/src/line_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if lhs_start_content != rhs_start_content {
dbg!(lhs_start_content, rhs_start_content);
return false;
}
if lhs_end_content != rhs_end_content {
dbg!(lhs_end_content, rhs_end_content);
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/difftastic",
"path": "/src/line_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>I_MEM_BUF13_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u32) -> &'a mut W {
self.w.bits = (self.w.bits & !0xffff_ffff) | ((value as u32) & 0xffff_ffff);
self.w
}
}
impl R {
#[doc = "Bits 0:31"]
#[inline(always)]... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/spi_mem/spi_mem_w13.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/spi_mem/spi_mem_w13.rs
#[doc = "Reader of register SPI_MEM_W13"]
pub type R = crate::R<u32, super::SPI_MEM_W13>;
#[doc = "Writer for register SPI_MEM_W13"]
pub type W = crate::W<u32, super::SPI_MEM_W13>;
#[doc = "Register SPI_MEM_W13 `reset()`'s with value ... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/spi_mem/spi_mem_w13.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sstanfield/igrillmon path: /src/main.rs
extern crate rumqtt;
use rumqtt::{MqttClient, MqttOptions, Notification, QoS};
use std::fs::File;
use std::io::{Read, Write};
use std::net::{TcpListener, TcpStream};
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::{Duration, SystemTime};
str... | code_fim | hard | {
"lang": "rust",
"repo": "sstanfield/igrillmon",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut f = File::open("resources/index.html").expect("index.html not found");
let mut contents = String::new();
f.read_to_string(&mut contents).expect("something went wrong reading index.html");
let response = format!("HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n{}\... | code_fim | hard | {
"lang": "rust",
"repo": "sstanfield/igrillmon",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..self.sampler.spp {
img.as_block().blocks().parallelize().for_each(|mut block| {
let sampler = self.sampler.for_block(i, &block);
for pos in block.pixels() {
let mut sampler = sampler.for_pixel(pos);
l... | code_fim | medium | {
"lang": "rust",
"repo": "johannesvollmer/fission",
"path": "/src/integrator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johannesvollmer/fission path: /src/integrator.rs
use crate::camera::*;
use crate::core::*;
use crate::image::*;
use crate::sampler::*;
use crate::scene::*;
use crate::tracer::*;
<|fim_suffix|> let pos = F2::from(pos) + sampler.next_2d();
let ray = self.sce... | code_fim | hard | {
"lang": "rust",
"repo": "johannesvollmer/fission",
"path": "/src/integrator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DanWicki/w3b path: /w3b-abi/src/decode/error.rs
use std::{error::Error, fmt};
use w3b_types_core::hex::HexError;
#[derive(PartialEq)]
pub enum DecodeError {
Hex {
inner: HexError,
},
UnexpectedChar {
char: char,
index: usize,
expected: Vec<char>,
... | code_fim | hard | {
"lang": "rust",
"repo": "DanWicki/w3b",
"path": "/w3b-abi/src/decode/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for DecodeError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
impl Error for DecodeError {}
impl From<HexError> for DecodeError {
#[inline]
fn from(inner: HexError) -> Self {
DecodeError::He... | code_fim | hard | {
"lang": "rust",
"repo": "DanWicki/w3b",
"path": "/w3b-abi/src/decode/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/twang path: /examples/saw.rs
use twang::{gen::Saw, mono::Mono64, Audio, Hz};
mod wav;
<|fim_suffix|> let mut saw = Saw::new(Hz(220.0)); // A4
let mut out = Audio::<Mono64>::with_silence(48_000, 48_000 * 5);
out.generate(&mut saw);
wav::write(out, "saw.wav").expect("Faile... | code_fim | easy | {
"lang": "rust",
"repo": "isgasho/twang",
"path": "/examples/saw.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<P: txpool::ChainApi, C> MergedMining<P, C> {
/// Create new `MergedMining` given client and transaction pool.
pub fn new(client: Arc<C>, pool: Arc<Pool<P>>) -> Self {
MergedMining { client, pool }
}
}
impl<P, C> MergedMiningApi for MergedMining<P, C>
where
C: traits::ProvideR... | code_fim | medium | {
"lang": "rust",
"repo": "RainFallsSilent/substrate-auxpow-template",
"path": "/rpc/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Submit the solved auxpow of an auxiliary block.
#[rpc(name = "submitauxblock")]
fn submit_auxpow(&self, auxpow: String) -> Result<Index>;
}
/// An implementation of MergedMining specific RPC methods.
pub struct MergedMining<P: txpool::ChainApi, C> {
client: Arc<C>,
pool: Arc<Pool<... | code_fim | hard | {
"lang": "rust",
"repo": "RainFallsSilent/substrate-auxpow-template",
"path": "/rpc/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RainFallsSilent/substrate-auxpow-template path: /rpc/src/lib.rs
use std::sync::Arc;
use client::blockchain::HeaderBackend;
use codec::Encode;
use jsonrpc_core::{Error, ErrorCode, Result};
use jsonrpc_derive::rpc;
use node_primitives::{AccountId, AccountNonceApi, Block, BlockId, Index};
use sr_p... | code_fim | hard | {
"lang": "rust",
"repo": "RainFallsSilent/substrate-auxpow-template",
"path": "/rpc/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn has_gap<F>(sensors: &[Sensor], full_size: i64, get_shadow: F) -> bool
where
F: Fn(&Sensor) -> Option<Span<i64>>,
{
let mut shadows: BinaryHeap<_> = sensors
.iter()
.filter_map(|x| get_shadow(x).map(Reverse))
.collect();
let mut cur_span = shadows.pop().unwr... | code_fim | hard | {
"lang": "rust",
"repo": "tocklime/aoc-rs",
"path": "/aoc/src/solutions/y2022/day15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tocklime/aoc-rs path: /aoc/src/solutions/y2022/day15.rs
use std::{
cmp::Reverse,
collections::{BTreeSet, BinaryHeap, HashSet},
};
use aoc_harness::*;
use nom::{
bytes::complete::tag,
character::complete::{self, newline},
combinator::all_consuming,
multi::many1,... | code_fim | hard | {
"lang": "rust",
"repo": "tocklime/aoc-rs",
"path": "/aoc/src/solutions/y2022/day15.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = POOL
.lock()
.futures
.remove(&id);
}
}
/// Spawn a future.
pub fn spawn<F: 'static + Send + Future<Item = (), Error = ()>>(f: F) {
let spawn = executor::spawn(Box::new(f) as Boxed);
let mut guard = POOL.lock();
let id = guard.next();
... | code_fim | hard | {
"lang": "rust",
"repo": "overdrivenpotato/stasis",
"path": "/rust/stasis/src/futures/v01.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: overdrivenpotato/stasis path: /rust/stasis/src/futures/v01.rs
//! Support for `futures 0.1.x`.
use std::{
collections::HashMap,
sync::Arc,
};
use futures_v01x::{
executor::{self, Notify, Spawn},
Async,
Future,
};
use global::Global;
type Boxed = Box<Future<Item = (), Error... | code_fim | hard | {
"lang": "rust",
"repo": "overdrivenpotato/stasis",
"path": "/rust/stasis/src/futures/v01.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: royalmustard/breadx path: /src/auto/xf86vidmode.rs
let (screen, sz): (Card16, usize) = <Card16>::from_bytes(&bytes[index..])?;
index += sz;
let (size, sz): (Card16, usize) = <Card16>::from_bytes(&bytes[index..])?;
index += sz;
Some((
GetGammaRa... | code_fim | hard | {
"lang": "rust",
"repo": "royalmustard/breadx",
"path": "/src/auto/xf86vidmode.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut index: usize = 0;
log::trace!("Deserializing GetDotClocksRequest from byte buffer");
let (req_type, sz): (u8, usize) = <u8>::from_bytes(&bytes[index..])?;
index += sz;
index += 1;
let (length, sz): (u16, usize) = <u16>::from_bytes(&bytes[index..])?;
... | code_fim | hard | {
"lang": "rust",
"repo": "royalmustard/breadx",
"path": "/src/auto/xf86vidmode.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// 스프라이트에 대한 랜더링
/// 가상화면에 출력하는 것을 전제로 함
pub fn render(&self, canvas: &mut WindowCanvas, texture_manager: &TextureManager) {
let texture = texture_manager.textures.get(&self.texture_id).unwrap();
canvas
.copy_ex(
texture,
Some(self.... | code_fim | hard | {
"lang": "rust",
"repo": "siabard/sdl_isometric",
"path": "/src/texture_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siabard/sdl_isometric path: /src/texture_manager.rs
use crate::constant::*;
use crate::*;
use sdl2::image::LoadTexture;
use sdl2::rect::Point;
use sdl2::rect::Rect;
use sdl2::render::Texture;
use sdl2::render::TextureCreator;
use sdl2::render::WindowCanvas;
use sdl2::video::WindowContext;
use st... | code_fim | hard | {
"lang": "rust",
"repo": "siabard/sdl_isometric",
"path": "/src/texture_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Texture 를 추가함
pub fn add_texture(&mut self, texture_id: String, texture: Texture<'a>) {
self.textures.insert(texture_id, texture);
}
/// Texture 를 삭제함
pub fn remove_texture(&mut self, texture_id: String) {
self.textures.remove(&texture_id);
}
}
/// Texture의 일부... | code_fim | hard | {
"lang": "rust",
"repo": "siabard/sdl_isometric",
"path": "/src/texture_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (1, 2, 3, 4);
#{"foo": 42, "bar": [1, 2, 3, 4]};
}
};
}<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/tests/vm_not_used.rs
prelude!();
#[test]
fn test_not_used() {
let _: () = rune! {
pub fn main() {
0;
4.1;
'a';
... | code_fim | medium | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/tests/vm_not_used.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/tests/vm_not_used.rs
prelude!();
#[test]
fn test_not_used() {
let _: () = rune! {
pub fn <|fim_suffix|> (1, 2, 3, 4);
#{"foo": 42, "bar": [1, 2, 3, 4]};
}
};
}<|fim_middle|>main() {
0;
4.1;
... | code_fim | medium | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/tests/vm_not_used.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zbraniecki/l20n.rs path: /src/ftl/entries/parser.rs
f.bump();
self.bump();
}
fn get_entity(&mut self, entries: &mut Map<String, Value>) {
let id = self.get_identifier();
self.skip_line_ws(true);
if !self.peek_char_eq('=') {
panic!();
... | code_fim | hard | {
"lang": "rust",
"repo": "zbraniecki/l20n.rs",
"path": "/src/ftl/entries/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zbraniecki/l20n.rs path: /src/ftl/entries/parser.rs
derive(Debug)]
pub enum ParserError {
Generic,
}
pub struct Parser<'a> {
source: MultiPeek<str::Chars<'a>>,
}
impl<'a> Parser<'a> {
pub fn new(source: &str) -> Parser {
Parser { source: multipeek(source.chars()) }
}
... | code_fim | hard | {
"lang": "rust",
"repo": "zbraniecki/l20n.rs",
"path": "/src/ftl/entries/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> continue;
}
_ => {
buffer.push(ch);
}
}
}
None => break,
}
self.bump();
}
if quote_de... | code_fim | hard | {
"lang": "rust",
"repo": "zbraniecki/l20n.rs",
"path": "/src/ftl/entries/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Select only pre-shared keys with given identifiers.
pub fn filter_psks<'a>(psks: &'a Psks, psk_ids: &'_ PskIds) -> Vec<IPsk<'a>> {
psk_ids
.iter()
.filter_map(|psk_id| psks.get_key_value(psk_id))
.collect::<Vec<(&PskId, &Psk)>>()
}<|fim_prefix|>// repo: iota-community/strea... | code_fim | hard | {
"lang": "rust",
"repo": "iota-community/streams",
"path": "/iota-streams-core/src/psk.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Entry in a PSK container, just a convenience type synonym.
pub type IPsk<'a> = (&'a PskId, &'a Psk);
/// Container for pre-shared keys.
pub type Psks = HashMap<PskId, Psk>;
/// Container (set) of pre-shared key identifiers.
pub type PskIds = Vec<PskId>;
/// Select only pre-shared keys with given id... | code_fim | hard | {
"lang": "rust",
"repo": "iota-community/streams",
"path": "/iota-streams-core/src/psk.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iota-community/streams path: /iota-streams-core/src/psk.rs
//! Pre-shared key is a secret symmetric key shared between two parties and is used for
//! (session) key exchange.
use crate::prelude::{
generic_array::{
typenum::{
U16,
U32,
},
Gener... | code_fim | medium | {
"lang": "rust",
"repo": "iota-community/streams",
"path": "/iota-streams-core/src/psk.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use time::TimeUnit;
#[derive(Clone, Debug, Default, PartialEq)]
pub struct RadioConfig {
pub phy: Option<Phy>,
pub cbw: Option<Cbw>,
pub primary_chan: Option<u8>,
}
impl RadioConfig {
pub fn new(phy: Phy, cbw: Cbw, primary_chan: u8) -> Self {
RadioConfig { phy: Some(phy), cbw... | code_fim | medium | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/connectivity/wlan/lib/common/rust/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RadioConfig {
pub fn new(phy: Phy, cbw: Cbw, primary_chan: u8) -> Self {
RadioConfig { phy: Some(phy), cbw: Some(cbw), primary_chan: Some(primary_chan) }
}
pub fn to_fidl(&self) -> fidl_sme::RadioConfig {
let (cbw, _) = self.cbw.or(Some(Cbw::Cbw20)).unwrap().to_fidl();
... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/connectivity/wlan/lib/common/rust/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: winksaville/fuchsia path: /src/connectivity/wlan/lib/common/rust/src/lib.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Crate wlan-common hosts common libraries
//! to be ... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/src/connectivity/wlan/lib/common/rust/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn returns_expected_1000() {
assert_close(square_area_to_circle(1000.0), 785.3981633974482, 1e-8);
}<|fim_prefix|>// repo: MariuszBielecki288728/rust-course path: /lab01/task3/src/main.rs
use std::f64::consts;
fn square_area_to_circle(size: f64) -> f64 {
consts::PI * size / 4.
}
fn asse... | code_fim | hard | {
"lang": "rust",
"repo": "MariuszBielecki288728/rust-course",
"path": "/lab01/task3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_close(square_area_to_circle(100.0), 78.53981633974483, 1e-8);
}
#[test]
fn returns_expected_2() {
assert_close(square_area_to_circle(2.0), 1.5707963267948966, 1e-8);
}
#[test]
fn returns_expected_1000() {
assert_close(square_area_to_circle(1000.0), 785.3981633974482, 1e-8);
}<|fim_pre... | code_fim | hard | {
"lang": "rust",
"repo": "MariuszBielecki288728/rust-course",
"path": "/lab01/task3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MariuszBielecki288728/rust-course path: /lab01/task3/src/main.rs
use std::f64::consts;
fn square_area_to_circle(size: f64) -> f64 {
consts::PI * size / 4.
}
fn assert_close(a:f64, b:f64, epsilon:f64) {
assert!( (a-b).abs() < epsilon, format!("Expected: {}, got: {}",b,a) );
}
<|fim_suf... | code_fim | medium | {
"lang": "rust",
"repo": "MariuszBielecki288728/rust-course",
"path": "/lab01/task3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sunnysingh97g/CtCI-rust path: /src/bin/ch2-p6_check-palindrome.rs
// Palindrome: Implement a function to check if a linked list is a
// palindrome.
extern crate cracking;
use cracking::LinkedList;
use std::vec::Vec;
pub trait CheckPalindrome<T> {
fn is_palindrome(&self) -> bool;
fn is_p... | code_fim | hard | {
"lang": "rust",
"repo": "sunnysingh97g/CtCI-rust",
"path": "/src/bin/ch2-p6_check-palindrome.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut list = LinkedList::new();
list.append('a');
list.append('b');
list.append('c');
assert!(!list.is_palindrome_iterative());
list.append('c');
list.append('b');
list.append('a');
assert!(list.is_palindrome_iterative());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "sunnysingh97g/CtCI-rust",
"path": "/src/bin/ch2-p6_check-palindrome.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> job.call_box();
}
}),
}
}
}
pub struct ThreadPool {
workers: Vec<Worker>,
sender: mpsc::Sender<Job>,
}
impl ThreadPool {
fn new(size: usize) -> ThreadPool {
assert!(size > 0);
let mut workers = Vec::with_capacity(si... | code_fim | hard | {
"lang": "rust",
"repo": "funkjunky/rust-webserver",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: funkjunky/rust-webserver path: /src/main.rs
use std::io::prelude::*;
use std::fs;
use std::net::TcpListener;
use std::net::TcpStream;
use std::thread;
use std::time::Duration;
use std::sync::mpsc;
use std::sync::Arc;
use std::sync::Mutex;
fn main() {
let listener = TcpListener::bind("127.0.... | code_fim | hard | {
"lang": "rust",
"repo": "funkjunky/rust-webserver",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = std::io::stdin();
to_fn_once(move|| { s.read_to_end(&mut Vec::new()); });
//~^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/cannot-mutate-captured-non-mut-var.rs
#![feature(unboxed_clos... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/cannot-mutate-captured-non-mut-var.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/cannot-mutate-captured-non-mut-var.rs
#![feature(unboxed_closures)]
use std::io::Read;
<|fim_suffix|>
fn main() {
let x = 1;
to_fn_once(move|| { x = 2; });
//~^ ERROR: cannot assign to `x`, as it is not declared as mutable
let... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/cannot-mutate-captured-non-mut-var.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("", str::from_utf8(&Command::new("rustc").current_dir(&out).arg("nondefault_global.rs").output().unwrap().stderr).unwrap());
}
#[test]
fn nondefault_struct() {
let out = env!("OUT_DIR");
DirBuilder::new().recursive(true).create(&out).unwrap();
let mut file = File::create(&Path... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/vk-rs",
"path": "/vk_generator/tests/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvark/vk-rs path: /vk_generator/tests/lib.rs
extern crate vk_generator;
extern crate vk_api;
use std::path::Path;
use std::fs::{File, DirBuilder};
use std::process::Command;
use std::io::Write;
use std::str;
use vk_generator::{VkVersion, GenConfig};
#[test]
fn default_global() {
let out =... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/vk-rs",
"path": "/vk_generator/tests/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file = File::create(&Path::new(&out).join("nondefault_global.rs")).unwrap();
writeln!(file, "{}", include_str!("./libc_dummy.rs")).unwrap();
writeln!(file, "fn main() {{}} mod vk {{").unwrap();
vk_generator::VkRegistry::new(vk_api::VK_XML)
.gen_global(&mut file,
... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/vk-rs",
"path": "/vk_generator/tests/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tokens = list
.split(delim)
.filter_map(|s| s.parse::<u16>().ok())
.collect::<Vec<u16>>();
reg.copy_from_slice(&tokens);
}
fn main() -> Result<(), Box<dyn Error>> {
// parse input
let mut samples = Vec::<Sample>::with_capacity(900);
let mut program = Vec::<[u16; 4]>::with_capaci... | code_fim | hard | {
"lang": "rust",
"repo": "legends2k/advent-of-code",
"path": "/2018/day_16/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(debug_assertions))]
macro_rules! debug_print {
($( $args:expr ),*) => {};
}
impl Debug for Jump<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{} --> {}", self.opcode, self.name)
}
}
#[derive(Default, Debug, Copy, Clone)]
struct Sample {
pre: [u16; 4],
ins... | code_fim | hard | {
"lang": "rust",
"repo": "legends2k/advent-of-code",
"path": "/2018/day_16/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: legends2k/advent-of-code path: /2018/day_16/src/main.rs
use std::{
error::Error,
fmt::{self, Debug, Formatter},
io::{self, BufRead},
};
struct Cpu<'a> {
reg: [u16; 4],
// operations jump table
ops: [Jump<'a>; 16],
}
#[derive(Clone, Copy)]
struct Jump<'a> {
opcode: i8,
name: &'a... | code_fim | hard | {
"lang": "rust",
"repo": "legends2k/advent-of-code",
"path": "/2018/day_16/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tribe-health/wallet.rs path: /wallet/examples/threads.rs
// Copyright 2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! cargo run --example threads --release
// In this example we will spam transactions from multiple threads simultaneously to our own address
use std::env;
use dot... | code_fim | hard | {
"lang": "rust",
"repo": "tribe-health/wallet.rs",
"path": "/wallet/examples/threads.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let results = futures::future::try_join_all(threads).await?;
for thread in results {
if let Err(e) = thread {
println!("{e}");
// Sync when getting an error, because that's probably when no outputs are available anymore
println!("... | code_fim | hard | {
"lang": "rust",
"repo": "tribe-health/wallet.rs",
"path": "/wallet/examples/threads.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if balance.base_coin.available == 0 {
panic!("Account has no available balance");
}
for _ in 0..1000 {
let mut threads = Vec::new();
for n in 0..10 {
let account_ = account.clone();
let address_ = *address.as_ref();
threads.push(asy... | code_fim | hard | {
"lang": "rust",
"repo": "tribe-health/wallet.rs",
"path": "/wallet/examples/threads.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /crates/cache/src/worker.rs
t);
}
#[inline]
fn send_cache_event(&self, event: CacheEvent) {
let sent_event = self.sender.try_send(event.clone());
if let Err(ref err) = sent_event {
info!(
"Failed to send as... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/crates/cache/src/worker.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /crates/cache/src/worker.rs
},
Unrecognized {
path: PathBuf,
is_dir: bool,
},
}
macro_rules! unwrap_or_warn {
($result:expr, $cont:stmt, $err_msg:expr, $path:expr) => {
match $result {
Ok(val) => val,
... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/crates/cache/src/worker.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(ext) => {
// check if valid lock
let recognized = ext.starts_with("wip-")
&& !is_fs_lock_expired(
Some(&entry),
... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/crates/cache/src/worker.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmcph4/enceladus path: /src/queue.rs
use crate::error::EnceladusError;
pub trait Queue<T: Sized + Eq + Clone>: Eq + Clone {
fn new() -> Self;
<|fim_suffix|> fn pop(&mut self) -> Result<T, EnceladusError>;
fn peek(&self) -> Result<&T, EnceladusError>;
fn length(&self) -> Result<us... | code_fim | medium | {
"lang": "rust",
"repo": "jmcph4/enceladus",
"path": "/src/queue.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn pop(&mut self) -> Result<T, EnceladusError>;
fn peek(&self) -> Result<&T, EnceladusError>;
fn length(&self) -> Result<usize, EnceladusError>;
}<|fim_prefix|>// repo: jmcph4/enceladus path: /src/queue.rs
use crate::error::EnceladusError;
pub trait Queue<T: Sized + Eq + Clone>: Eq + Clone {... | code_fim | medium | {
"lang": "rust",
"repo": "jmcph4/enceladus",
"path": "/src/queue.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn length(&self) -> Result<usize, EnceladusError>;
}<|fim_prefix|>// repo: jmcph4/enceladus path: /src/queue.rs
use crate::error::EnceladusError;
pub trait Queue<T: Sized + Eq + Clone>: Eq + Clone {
fn new() -> Self;
fn push(&mut self, elem: T) -> Result<(), EnceladusError>;
fn pop(&mut ... | code_fim | easy | {
"lang": "rust",
"repo": "jmcph4/enceladus",
"path": "/src/queue.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> InnerEventTag {
id: self.id,
name: self.name,
description: self.description,
}
}
}
#[derive(Debug, GraphQLObject)]
pub struct InnerEventTag {
id: i32,
name: String,
description: Option<String>,
}<|fim_prefix|>// repo: torbencarstens/even... | code_fim | medium | {
"lang": "rust",
"repo": "torbencarstens/event-manager-backend",
"path": "/src/models/event.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: torbencarstens/event-manager-backend path: /src/models/event.rs
use chrono::NaiveDateTime;
use crate::database::{self, Location, Organizer};
use crate::graphql::graphqli64::GraphQLi64;
<|fim_suffix|>impl Into<InnerEventTag> for database::Tag {
fn into(self) -> InnerEventTag {
Inner... | code_fim | hard | {
"lang": "rust",
"repo": "torbencarstens/event-manager-backend",
"path": "/src/models/event.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let passwords: Vec<i32> = (min..max)
.filter(|x| dup.is_match(&x.to_string()) && asc.is_match(&x.to_string()))
.map(|x| x)
.collect();
println!("{}",passwords.len());
}<|fim_prefix|>// repo: blueyleader/AdventOfCode2019 path: /d4_p1/src/main.rs
use regex::Regex;
fn main() {
// le... | code_fim | medium | {
"lang": "rust",
"repo": "blueyleader/AdventOfCode2019",
"path": "/d4_p1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blueyleader/AdventOfCode2019 path: /d4_p1/src/main.rs
use regex::Regex;
fn main() {
// let input = "347312-805915";
let min = 347312;
let max = 805915;
<|fim_suffix|> let passwords: Vec<i32> = (min..max)
.filter(|x| dup.is_match(&x.to_string()) && asc.is_match(&x.to_string()... | code_fim | medium | {
"lang": "rust",
"repo": "blueyleader/AdventOfCode2019",
"path": "/d4_p1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_sample_message() -> &'static str {
"MSH|^~\\&|GHH LAB|ELAB-3|GHH OE|BLDG4|200202150930||ORU^R01|CNTRL-3456|P|2.4\rPID|||555-44-4444||EVERYWOMAN^EVE^E^^^^L|JONES|19620320|F|||153 FERNWOOD DR.^^STATESVILLE^OH^35292||(206)3345232|(206)752-121||||AC555444444||67-A4335^OH^20030520\rOBR|1|845439^GHH ... | code_fim | hard | {
"lang": "rust",
"repo": "gistia/rust-hl7",
"path": "/examples/demo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.