text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> &mut self,
viewport: &mut Viewport,
instance: u64,
out_surface: &mut u64,
) -> i32;
}
/// Used to get the current Contexts [`PlatformViewportContext`].
fn get_platform_ctx() -> &'static mut PlatformViewportContext {
unsafe {
// should be safe as it is impos... | code_fim | hard | {
"lang": "rust",
"repo": "burtonageo/imgui-rs",
"path": "/imgui/src/platform_io.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: burtonageo/imgui-rs path: /imgui/src/platform_io.rs
estroyWindow);
assert_field_offset!(renderer_set_window_size, Renderer_SetWindowSize);
assert_field_offset!(renderer_render_window, Renderer_RenderWindow);
assert_field_offset!(renderer_swap_buffers, Renderer_SwapBuffers);
asse... | code_fim | hard | {
"lang": "rust",
"repo": "burtonageo/imgui-rs",
"path": "/imgui/src/platform_io.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Maxime2/libtransport path: /src/generic_test.rs
/// # Fantom Libtransport/generic_tests
///
/// This file contains a set of generic tests which can be used to test the functionality of the
/// Transport trait. This file contains a bunch of dummy data which can be quickly used for any
/// Transpo... | code_fim | hard | {
"lang": "rust",
"repo": "Maxime2/libtransport",
"path": "/src/generic_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Stub not used in tests to satisfy PeerList trait
Ok(())
}
// Allows iteration over the peer list.
fn iter(&self) -> Iter<'_, Self::P> {
self.peers.iter()
}
// Allows a mutable iteration over the peer list.
fn iter_mut(&mut self) -> IterMut<'_, Self::P> {
... | code_fim | hard | {
"lang": "rust",
"repo": "Maxime2/libtransport",
"path": "/src/generic_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/traits/trait-object-lifetime-first.rs
// run-pass
use std::fmt::Display;
<|fim_suffix|>fn main() {
let x: &(dyn 'static + Display) = &BYTE;
let y: Box<dyn 'static + Display> = Box::new(BYTE);
let xstr = format!("{}", x);
let yst... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/traits/trait-object-lifetime-first.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x: &(dyn 'static + Display) = &BYTE;
let y: Box<dyn 'static + Display> = Box::new(BYTE);
let xstr = format!("{}", x);
let ystr = format!("{}", y);
assert_eq!(xstr, "33");
assert_eq!(ystr, "33");
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/traits/... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/traits/trait-object-lifetime-first.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tobni/inject-rs path: /examples/calling.rs
use ::inject::{call, container, inject, Container};
<|fim_suffix|> Self(0)
}
}
#[inject]
fn acts_on_service(service: Service) -> isize {
2 + service.0
}
fn main() {
let container = container![|container: &Container| Ok(Service(3))]... | code_fim | medium | {
"lang": "rust",
"repo": "tobni/inject-rs",
"path": "/examples/calling.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let container = container![|container: &Container| Ok(Service(3))];
let result = call!(&container, acts_on_service).unwrap();
assert_eq!(result, 5)
}<|fim_prefix|>// repo: tobni/inject-rs path: /examples/calling.rs
use ::inject::{call, container, inject, Container};
struct Service(isize);
... | code_fim | easy | {
"lang": "rust",
"repo": "tobni/inject-rs",
"path": "/examples/calling.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 2 + service.0
}
fn main() {
let container = container![|container: &Container| Ok(Service(3))];
let result = call!(&container, acts_on_service).unwrap();
assert_eq!(result, 5)
}<|fim_prefix|>// repo: tobni/inject-rs path: /examples/calling.rs
use ::inject::{call, container, inject, Con... | code_fim | medium | {
"lang": "rust",
"repo": "tobni/inject-rs",
"path": "/examples/calling.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JungleComputing/constellation-rust path: /src/error.rs
//! Module for handling Errors and Results
use std::{error, fmt, result};
<|fim_suffix|>impl fmt::Display for ConstellationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "THIS IS AN ERROR")
}
}
imp... | code_fim | medium | {
"lang": "rust",
"repo": "JungleComputing/constellation-rust",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for ConstellationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "THIS IS AN ERROR")
}
}
impl error::Error for ConstellationError {
// TODO Add methods/functions to identify error
fn cause(&self) -> Option<&error::Error> {
// Gen... | code_fim | medium | {
"lang": "rust",
"repo": "JungleComputing/constellation-rust",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let totals = state.player_hands.iter().map(|hand| hand_total(&hand));
loop {
let dealer_total = hand_total(&state.dealer_hand);
if dealer_total.0 >= 17 { break; }
if let Some(card) = state.deck.deal_card() {
state.dealer_hand.push(card);
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "ElectricCoffee/Blackjack",
"path": "/src/game/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ElectricCoffee/Blackjack path: /src/game/mod.rs
mod state;
mod flow;
pub use self::state::State;
pub use self::flow::{Winning, Flow};
use std::io::{self, Write};
use rand::ThreadRng;
use parser;
use commands::Command::*;
use cards::{Card, Deck};
/// Plays the game
pub fn play(state: &mut Sta... | code_fim | hard | {
"lang": "rust",
"repo": "ElectricCoffee/Blackjack",
"path": "/src/game/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if state.player_hands.iter()
.map(|hand| hand_total(&hand))
.any(|tpl| tpl.0 <= 21) {
Flow::Continue
} else {
Flow::Loss
}
}
// split the hand in two
fn handle_split(state: &mut State) -> Flow {
println!("Split unhandled");
Flow::Continu... | code_fim | hard | {
"lang": "rust",
"repo": "ElectricCoffee/Blackjack",
"path": "/src/game/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fratorgano/advent_of_code_2020 path: /day08/src/lib.rs
// It's really bad, don't bother reading it.
// First I tried doing with strings and slicing them, got in trouble with the borrow checker and couldn't solve it.
// Rewrote most of the code, now it's a real mess
pub fn input_to_instructions(... | code_fim | hard | {
"lang": "rust",
"repo": "fratorgano/advent_of_code_2020",
"path": "/day08/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(accumulator) = run_program(&instructions) {
part2 = accumulator;
break;
}
swap_operations(&mut instructions[i]);
}
part2
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn day08_test() {
let input = "nop +0
acc +1
jmp... | code_fim | hard | {
"lang": "rust",
"repo": "fratorgano/advent_of_code_2020",
"path": "/day08/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn reg_sync<F>(rt: &mut JsRuntime, name: &'static str, op_fn: F)
where
F: Fn(&mut OpState, Value, Option<ZeroCopyBuf>) -> Result<Value, AnyError>
+ 'static,
{
rt.register_op(name, metrics_op(name, op_sync(op_fn)));
}<|fim_prefix|>// repo: juzi5201314/deno path: /cli/ops/mod.rs
// Copyright 20... | code_fim | hard | {
"lang": "rust",
"repo": "juzi5201314/deno",
"path": "/cli/ops/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juzi5201314/deno path: /cli/ops/mod.rs
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
pub mod errors;
pub mod runtime_compiler;
<|fim_suffix|>pub fn reg_async<F, R>(rt: &mut JsRuntime, name: &'static str, op_fn: F)
where
F: Fn(Rc<RefCell<OpState>>, Value, Option<Z... | code_fim | hard | {
"lang": "rust",
"repo": "juzi5201314/deno",
"path": "/cli/ops/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qezz/jss-rs path: /prepare-style-derive/src/merge.rs
use common::{StructField, optioned_type, field_to_name_and_ty };
use proc_macro2::{Ident, TokenStream};
use syn::{DataStruct, Fields};
// @TODO: What if user style need override exists param?
// Maybe try setting override by prepared Vec<Targ... | code_fim | medium | {
"lang": "rust",
"repo": "qezz/jss-rs",
"path": "/prepare-style-derive/src/merge.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_impl_trait_tokens(struct_id: Ident, data_struct: DataStruct) -> TokenStream {
let expressions = get_collect_expressions(data_struct);
quote! {
use std::ops::Add;
impl Add for #struct_id {
type Output = #struct_id;
fn add(self, other: #struct_id) -> #struct_id {
... | code_fim | medium | {
"lang": "rust",
"repo": "qezz/jss-rs",
"path": "/prepare-style-derive/src/merge.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ragingwind/wasm-hnpwa path: /src/view.rs
pub mod element;
use super::console::*;
use crate::types::*;
use crate::view::element::Element;
pub enum ViewMessage {
ShowNews(Vec<News>, &'static str, u32),
ShowUser(User, &'static str, &'static str),
ShowComment(Item, &'static str, u32),
}
pub... | code_fim | hard | {
"lang": "rust",
"repo": "ragingwind/wasm-hnpwa",
"path": "/src/view.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(mut div) = Element::create_element("div") {
section.append_child(&mut div);
if let Some(mut ul) = Element::create_element("ul") {
div.append_child(&mut ul);
let mut items = String::new();
for item in news.iter() {
let points = ... | code_fim | hard | {
"lang": "rust",
"repo": "ragingwind/wasm-hnpwa",
"path": "/src/view.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nocproject/noc path: /rust/agent/src/collectors/memory/collector.rs
// ---------------------------------------------------------------------
// memory collector implementation
// ---------------------------------------------------------------------
// Copyright (C) 2007-2021 The NOC Project
// S... | code_fim | medium | {
"lang": "rust",
"repo": "nocproject/noc",
"path": "/rust/agent/src/collectors/memory/collector.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl Collectable for MemoryCollector {
const NAME: &'static str = "memory";
type Output = MemoryOut;
async fn collect(&self) -> Result<Status, AgentError> {
let sys = System::new();
let ts = Self::get_timestamp();
let memory = sys
.memory()
... | code_fim | medium | {
"lang": "rust",
"repo": "nocproject/noc",
"path": "/rust/agent/src/collectors/memory/collector.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Decoder for NetlinkCodec {
type Item = (NetlinkMessageHeader, BytesMut);
type Error = io::Error;
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
if src.len() < mem::size_of::<NetlinkMessageHeader>() {
Ok(None)
} else {
... | code_fim | medium | {
"lang": "rust",
"repo": "mcoffin/proc-listener",
"path": "/src/nl.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcoffin/proc-listener path: /src/nl.rs
use bytes::BytesMut;
use byteorder::{NativeEndian, ReadBytesExt};
use tokio_codec::{Decoder, Encoder};
use std::io;
use std::mem;
pub const NLMSG_DONE: u16 = 0x3;
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct NetlinkMessageHeader {
pub len: u32,... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/proc-listener",
"path": "/src/nl.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>deselect();
getBody(116).select();
getJoint(51).deselect();
getJoint(15).select();<|fim_prefix|>// repo: szdenny/jbox2d path: /jbox2d-testbed/src/main/resources/tank.json-backups/tank.json-scriptLog.rs
//Started script log at 03/13/20 14:51:32
getJoint(29).select();
getJoint(29).de<|fim_middle|>select()... | code_fim | medium | {
"lang": "rust",
"repo": "szdenny/jbox2d",
"path": "/jbox2d-testbed/src/main/resources/tank.json-backups/tank.json-scriptLog.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: szdenny/jbox2d path: /jbox2d-testbed/src/main/resources/tank.json-backups/tank.json-scriptLog.rs
//Started script log at 03/13/20 14:51:32
getJoint(29).select();
getJoint(29).de<|fim_suffix|>etBody(97).select();
getBody(97).deselect();
getBody(109).select();
getBody(109).deselect();
getBody(116... | code_fim | medium | {
"lang": "rust",
"repo": "szdenny/jbox2d",
"path": "/jbox2d-testbed/src/main/resources/tank.json-backups/tank.json-scriptLog.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agmcleod/adventofcode-2018 path: /17/src/main.rs
extern crate read_input;
use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::Write;
fn get_range_numbers(second_coord: &str, coord_name: &str) -> Vec<i32> {
second_coord
.replace(coord_name, "")
... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/adventofcode-2018",
"path": "/17/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in min_x..=max_x {
if clay_walls_found == 2 {
watered_area.insert((x, vec.1));
} else {
falling_water.insert((x, vec.1));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/adventofcode-2018",
"path": "/17/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write_map(
"17/claymap.txt",
deepest_clay,
min_x,
max_x,
&full_clay_map,
&watered_area,
&falling_water,
);
loop {
if let Some(mut vec) = current_vector.pop() {
failing_vectors.insert(vec.clone());
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/adventofcode-2018",
"path": "/17/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: starcoinorg/starcoin path: /vm/resource-viewer/src/lib.rs
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
fat_type::{FatStructType, FatType},
resolver:... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/vm/resource-viewer/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _i in 0..indent {
write!(f, " ")?;
}
Ok(())
}
fn pretty_print_value(
f: &mut Formatter,
value: &AnnotatedMoveValue,
indent: u64,
) -> std::fmt::Result {
match value {
AnnotatedMoveValue::Bool(b) => write!(f, "{}", b),
AnnotatedMoveValue::U8(v) => wr... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/vm/resource-viewer/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn pretty_print_ability_modifiers(f: &mut Formatter, abilities: AbilitySet) -> std::fmt::Result {
for ability in abilities {
match ability {
Ability::Copy => write!(f, "copy ")?,
Ability::Drop => write!(f, "drop ")?,
Ability::Store => write!(f, "store ")?,
... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/vm/resource-viewer/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns true if any user-agent was seen.
fn seen_any_agent(&self) -> bool {
self.seen_global_agent || self.seen_specific_agent
}
/// Extract the matchable part of a user agent string, essentially stopping at
/// the first invalid character.
/// Example: 'Googlebot/2.1'... | code_fim | hard | {
"lang": "rust",
"repo": "let4be/robotstxt",
"path": "/src/matcher.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.seen_global_agent || self.seen_specific_agent
}
/// Extract the matchable part of a user agent string, essentially stopping at
/// the first invalid character.
/// Example: 'Googlebot/2.1' becomes 'Googlebot'
fn extract_user_agent(user_agent: &str) -> &str {
// Al... | code_fim | hard | {
"lang": "rust",
"repo": "let4be/robotstxt",
"path": "/src/matcher.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: let4be/robotstxt path: /src/matcher.rs
botsMatchStrategy};
///
/// type Target = LongestMatchRobotsMatchStrategy;
/// assert_eq!(true, Target::matches("/", "/"));
/// assert_eq!(true, Target::matches("/abc", "/"));
/// assert_eq!(false, Target::matches("/", "/abc"));
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "let4be/robotstxt",
"path": "/src/matcher.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bsrk1013/rust path: /generic_trait_lifetime/src/main.rs
extern crate generic_trait_lifetime;
use crate::generic_trait_lifetime::Summarizable;
use generic_trait_lifetime::NewsArticle;
use generic_trait_lifetime::Tweet;
use std::fmt::Display;
use std::fmt::Formatter;
struct Point<T, U> {
x: ... | code_fim | hard | {
"lang": "rust",
"repo": "bsrk1013/rust",
"path": "/generic_trait_lifetime/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> largest_test2();
largest_test();
generic_test();
trait_test();
lifetime_test();
lifetime_test2();
}
fn lifetime_test() {
let string1 = String::from("abcdefg");
let string2 = String::from("xyz");
{
let result = longest(string1.as_str(), string2.as_str());
... | code_fim | hard | {
"lang": "rust",
"repo": "bsrk1013/rust",
"path": "/generic_trait_lifetime/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_program(num: i64, tx: mpsc::Sender<i64>, rx: mpsc::Receiver<i64>) {
let program: Vec<Op> = input.lines().map(|s| Op::from_str(s).unwrap()).collect();
let mut registers: HashMap<char, i64> = HashMap::new();
let mut ip: i64 = 0;
let mut send_count: i64 = 0;
for c in ('a' as u8)..... | code_fim | hard | {
"lang": "rust",
"repo": "czak/aoc",
"path": "/2017/rust/src/bin/day18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: czak/aoc path: /2017/rust/src/bin/day18.rs
use std::collections::HashMap;
use std::str::FromStr;
use std::thread;
use std::sync::mpsc;
#[allow(non_camel_case_types)]
#[derive(Debug)]
enum Op {
sndi(i64),
sndr(char),
seti(char, i64),
setr(char, char),
addi(char, i64),
add... | code_fim | hard | {
"lang": "rust",
"repo": "czak/aoc",
"path": "/2017/rust/src/bin/day18.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> send_count += 1;
println!("p{} sent {} (#{})", num, registers[&x], send_count);
},
&Op::seti(x, y) => {
registers.insert(x, y);
},
&Op::setr(x, y) => {
registers.insert(x, registers[&y]);
... | code_fim | hard | {
"lang": "rust",
"repo": "czak/aoc",
"path": "/2017/rust/src/bin/day18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod modules;
// should not be executed
#[wasm_bindgen(start)]
fn start() {
panic!();
}<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /tests/worker/main.rs
#![cfg(target_arch = "wasm32")]
extern crate js_sys;
extern crate wasm_bindgen;
extern crate wasm_bindgen_test;
<|fim_middle|>use wasm_... | code_fim | medium | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/tests/worker/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /tests/worker/main.rs
#![cfg(target_arch = "wasm32")]
extern crate js_sys;
extern crate wasm_bindgen;
extern crate wasm_bindgen_test;
<|fim_suffix|>pub mod modules;
// should not be executed
#[wasm_bindgen(start)]
fn start() {
panic!();
}<|fim_middle|>use wasm_... | code_fim | medium | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/tests/worker/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Prototype for FlameThrowerExplosion {
const TYPE: Option<&'static str> = Some("flame-thrower-explosion");
}<|fim_prefix|>// repo: jgraef/rustorio path: /rustorio-core/src/prototypes/prototypes/flame_thrower_explosion.rs
use serde::{Deserialize, Serialize};
use crate::prototypes::{Prototype, Vis... | code_fim | hard | {
"lang": "rust",
"repo": "jgraef/rustorio",
"path": "/rustorio-core/src/prototypes/prototypes/flame_thrower_explosion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// slow_down_factor :: double
slow_down_factor: f64,
}
impl Prototype for FlameThrowerExplosion {
const TYPE: Option<&'static str> = Some("flame-thrower-explosion");
}<|fim_prefix|>// repo: jgraef/rustorio path: /rustorio-core/src/prototypes/prototypes/flame_thrower_explosion.rs
use serde::... | code_fim | medium | {
"lang": "rust",
"repo": "jgraef/rustorio",
"path": "/rustorio-core/src/prototypes/prototypes/flame_thrower_explosion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgraef/rustorio path: /rustorio-core/src/prototypes/prototypes/flame_thrower_explosion.rs
use serde::{Deserialize, Serialize};
use crate::prototypes::{Prototype, Visitor};
use crate::types::*; // TODO: Import only specific types
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct FlameT... | code_fim | medium | {
"lang": "rust",
"repo": "jgraef/rustorio",
"path": "/rustorio-core/src/prototypes/prototypes/flame_thrower_explosion.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aespiral/sharpener-cli path: /src/config.rs
use crate::error::*;
use serde::{Deserialize, Serialize};
use std::env;
use std::fs::File;
use std::path::PathBuf;
<|fim_suffix|> let home = env::var("HOME").map(PathBuf::from).unwrap();
home.join(".sharpener-config")
}
pub fn ... | code_fim | medium | {
"lang": "rust",
"repo": "aespiral/sharpener-cli",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn create(token: String) -> Result<Self> {
let filename = Self::get_path();
let file = File::create(&filename).context(OpenConfigFile { filename })?;
let config = Self { token };
serde_json::to_writer_pretty(file, &config).context(ConfigWrite {})?;
Ok(config... | code_fim | hard | {
"lang": "rust",
"repo": "aespiral/sharpener-cli",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>)
}
pub fn connection_pool(profile: &str, id: &str) -> db::ConnectionPool {
let mut settings = settings(profile).db;
settings.url.push_str(id);
db::new_connection_pool(&settings).expect("failed to connect to db")
}<|fim_prefix|>// repo: satelit-project/satelit-import path: /_tests/common/mod... | code_fim | medium | {
"lang": "rust",
"repo": "satelit-project/satelit-import",
"path": "/_tests/common/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: satelit-project/satelit-import path: /_tests/common/mod.rs
use satelit_import::{db, settings};
pub fn settings(profile: &str) -> settings::Settings {
let profile = set<|fim_suffix|>)
}
pub fn connection_pool(profile: &str, id: &str) -> db::ConnectionPool {
let mut settings = settings(p... | code_fim | medium | {
"lang": "rust",
"repo": "satelit-project/satelit-import",
"path": "/_tests/common/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0164_maximum_gap/comparison_sort.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
pub fn maximum_gap(nums: Vec<i32>) -> i32 {
let mut n... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0164_maximum_gap/comparison_sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SetTheorist/rust-special-functions path: /sf_impl/src/orthopoly/legendre.rs
use crate::orthopoly::*;
use crate::poly::Poly;
use crate::traits::*;
use crate::trig::*;
empty_type!(Legendre);
impl<V:RealValue+Trig+Float> OrthogonalPolynomial<V> for Legendre<V> {
fn domain(&self) -> (V, V) {
... | code_fim | hard | {
"lang": "rust",
"repo": "SetTheorist/rust-special-functions",
"path": "/sf_impl/src/orthopoly/legendre.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poly(&self, n: isize) -> Poly<V> {
match n {
0 => Poly(vec![ι(1)]),
1 => Poly(vec![ι(0),ι(1)]),
_ => {
let mut t0 = Poly(vec![ι(1)]);
let mut t1 = Poly(vec![ι(0),ι(1)]);
for k in 2..=n {
// TODO: polynomials need ergonomics work!
let m... | code_fim | hard | {
"lang": "rust",
"repo": "SetTheorist/rust-special-functions",
"path": "/sf_impl/src/orthopoly/legendre.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let props_ty = quote_spanned!(ty.span()=> <#ty as ::yew::html::BaseComponent>::Properties);
let children_renderer = if children.is_empty() {
None
} else {
Some(quote! { ::yew::html::ChildrenRenderer::new(#children) })
};
let build_props = pro... | code_fim | hard | {
"lang": "rust",
"repo": "kuy/yew",
"path": "/packages/yew-macro/src/html_tree/html_component.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kuy/yew path: /packages/yew-macro/src/html_tree/html_component.rs
use super::{HtmlChildrenTree, TagTokens};
use crate::{props::ComponentProps, PeekValue};
use boolinator::Boolinator;
use proc_macro2::Span;
use quote::{quote, quote_spanned, ToTokens};
use syn::buffer::Cursor;
use syn::parse::{Par... | code_fim | hard | {
"lang": "rust",
"repo": "kuy/yew",
"path": "/packages/yew-macro/src/html_tree/html_component.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> TagTokens::parse_start_content(input, |input, tag| {
let ty = input.parse()?;
let props = input.parse()?;
Ok(Self { tag, ty, props })
})
}
}
struct HtmlComponentClose {
tag: TagTokens,
_ty: Type,
}
impl HtmlComponentClose {
fn to_spanne... | code_fim | hard | {
"lang": "rust",
"repo": "kuy/yew",
"path": "/packages/yew-macro/src/html_tree/html_component.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hoodmane/rust-webgl path: /src/shader/glyph_shader.rs
use std::convert::TryInto;
use wasm_bindgen::JsValue;
use web_sys::{
WebGl2RenderingContext,
WebGlVertexArrayObject,
};
use lyon::geom::math::{Point};
use lyon::tessellation::{VertexBuffers};
#[allow(unused_imports)]
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "hoodmane/rust-webgl",
"path": "/src/shader/glyph_shader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let num_fill_triangles = num_fill_triangles.try_into().unwrap();
let num_stroke_triangles = num_stroke_triangles.try_into().unwrap();
self.glyph_map.push(ShaderGlyphHeader {
index,
num_fill_triangles,
num_stroke_triangles,
padding ... | code_fim | hard | {
"lang": "rust",
"repo": "hoodmane/rust-webgl",
"path": "/src/shader/glyph_shader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // If the bidder pot account is empty, this bid is invalid.
if accounts.bidder_pot.data_is_empty() {
return Err(AuctionError::BidderPotDoesNotExist.into());
}
// Confirm we're looking at the real SPL account for this bidder.
let mut bidder_pot = BidderPot::from_account_info(ac... | code_fim | hard | {
"lang": "rust",
"repo": "staccnft/metaplex",
"path": "/rust/auction/program/src/processor/claim_bid.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if auction.authority != *accounts.authority.key {
return Err(AuctionError::InvalidAuthority.into());
}
// User must have won the auction in order to claim their funds. Check early as the rest of the
// checks will be for nothing otherwise.
if auction.is_winner(accounts.bidder.... | code_fim | hard | {
"lang": "rust",
"repo": "staccnft/metaplex",
"path": "/rust/auction/program/src/processor/claim_bid.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: staccnft/metaplex path: /rust/auction/program/src/processor/claim_bid.rs
//! Claim bid winnings into a target SPL account, only the authorised key can do this, though the
//! target can be any SPL account.
use crate::{
errors::AuctionError,
processor::{AuctionData, BidderMetadata, Bidde... | code_fim | hard | {
"lang": "rust",
"repo": "staccnft/metaplex",
"path": "/rust/auction/program/src/processor/claim_bid.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct S;
struct Z;
struct W;
let x = SS(S, Z, W);
match x { SS(S, ..) => {} }
match x { SS(.., W) => {} }
match x { SS(S, .., W) => {} }
match x { SS(.., Z, _) => {} }
}
fn main() {
tuple();
tuple_struct();
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/binding/pat-tuple-5.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/binding/pat-tuple-5.rs
// run-pass
fn tuple() {
struct S;
struct Z;
struct W;
let x = (S, Z, W);
match x { (S, ..) => {} }
match x { (.., W) => {} }
match x { (S, .., W) => {} }
match x { (.., Z, _) => {} }
}
fn ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/binding/pat-tuple-5.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if emergency price exists, return it, otherwise return latest price from oracle.
Self::get_emergency_price(asset_id).or_else(|| {
match T::LiquidStakingCurrenciesProvider::get_staking_currency()
.zip(T::LiquidStakingCurrenciesProvider::get_liquid_currency())
... | code_fim | hard | {
"lang": "rust",
"repo": "DiamondNetwork/parallel",
"path": "/pallets/prices/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DiamondNetwork/parallel path: /pallets/prices/src/lib.rs
// Copyright 2021 Parallel Finance Developer.
// This file is part of Parallel Finance.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obta... | code_fim | hard | {
"lang": "rust",
"repo": "DiamondNetwork/parallel",
"path": "/pallets/prices/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match T::LiquidStakingCurrenciesProvider::get_staking_currency()
.zip(T::LiquidStakingCurrenciesProvider::get_liquid_currency())
{
Some((staking_currency, liquid_currency)) if &liquid_currency == asset_id => {
T::Source::get_no_op(&staking_currency).... | code_fim | hard | {
"lang": "rust",
"repo": "DiamondNetwork/parallel",
"path": "/pallets/prices/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>: Option<Vec <crate::models::SnapshotLockExtended>>,
}<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/snapshot_locks.rs
#[allow(unused_imports)]
use serde_json::Value;
#[de<|fim_middle|>rive(Debug, Serialize, Deserialize)]
pub struct SnapshotLocks {
#[serde(rename = "locks")]
pub lo... | code_fim | medium | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/snapshot_locks.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/snapshot_locks.rs
#[allow(unused_imports)]
use serde_json::Value;
#[de<|fim_suffix|>: Option<Vec <crate::models::SnapshotLockExtended>>,
}<|fim_middle|>rive(Debug, Serialize, Deserialize)]
pub struct SnapshotLocks {
#[serde(rename = "locks")]
pub lo... | code_fim | medium | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/snapshot_locks.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use eframe::egui::{self, FontDefinitions, FontFamily,TextStyle};
use std::borrow::Borrow;
use std::collections::BTreeMap;
use std::io::Write;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{Receiver, Sender};
pub fn install_fonts(egui_ctx: &egui::CtxRef) {
let mut fonts = FontDefinitions::default()... | code_fim | hard | {
"lang": "rust",
"repo": "pickanameforlove/DataStructureandAlgorithminRust",
"path": "/src/TextEditor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
use eframe::egui::{self, FontDefinitions, FontFamily,TextStyle};
use std::borrow::Borrow;
use std::collections::BTreeMap;
use std::io::Write;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{Receiver, Sender};
pub fn install_fonts(egui_ctx: &egui::CtxRef) {
let mut fonts = FontDefinitions::defaul... | code_fim | hard | {
"lang": "rust",
"repo": "pickanameforlove/DataStructureandAlgorithminRust",
"path": "/src/TextEditor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pickanameforlove/DataStructureandAlgorithminRust path: /src/TextEditor.rs
use eframe::epi;
use eframe::egui::containers::*;
use tauri_hotkey::{parse_hotkey, HotkeyManager};
use native_dialog::{FileDialog, MessageDialog, MessageType};
use std::fs;
pub struct TextEditor {
pub content : String,... | code_fim | hard | {
"lang": "rust",
"repo": "pickanameforlove/DataStructureandAlgorithminRust",
"path": "/src/TextEditor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>) => x,
Err(_) => {
let to_send = format!("*{}* is not a valid dice roll.", arguments);
msg.reply(&ctx.http, &to_send).await?;
return Ok(());
}
};
let to_send = format!("Rolling *{}...*\nResults: **{}**", arguments, dice.roll());
msg.reply(&c... | code_fim | medium | {
"lang": "rust",
"repo": "JustAnotherStrange/CafeBot",
"path": "/src/misc/dice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JustAnotherStrange/CafeBot path: /src/misc/dice.rs
use cute_dnd_dice::Roll;
use serenity::{
framework::standard::{macros::command, Args, CommandResult},
model::prelude::*,
prelude::*,
};
#[command]
#[aliases("d")]
async fn dice(ctx: &Context, msg: &Message, args: Args) -> CommandRes... | code_fim | medium | {
"lang": "rust",
"repo": "JustAnotherStrange/CafeBot",
"path": "/src/misc/dice.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: srenatus/rust-tree-sitter path: /build.rs
extern crate cc;
use std::env;
use std::path::PathBuf;
fn main() {
let mut config = cc::Build::new();
let root_path: PathBuf = ["vendor", "tree-sitter"].iter().collect();
<|fim_suffix|> config.files(source_filenames.iter().map(|source_filen... | code_fim | hard | {
"lang": "rust",
"repo": "srenatus/rust-tree-sitter",
"path": "/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> config.file(root_path.join("externals").join("utf8proc").join("utf8proc.c"));
if env::var("RUST_TREE_SITTER_TEST").is_ok() {
let parser_dir: PathBuf = ["fixtures", "tree-sitter-rust", "src"].iter().collect();
config
.file(parser_dir.join("parser.c"))
.file(... | code_fim | medium | {
"lang": "rust",
"repo": "srenatus/rust-tree-sitter",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>*/
pub struct Service<W: Worker> {
requester: deque::Worker<W::Input>,
receiver: mpsc::Receiver<(W::Input, W::Output)>,
}
impl<W: Worker> Service<W> {
pub fn from_iter<I>(name: &str, workers: I) -> Self
where
I: IntoIterator<Item = W>,
{
let (request_inserter, request... | code_fim | hard | {
"lang": "rust",
"repo": "qm3ster/Notcraft",
"path": "/src/engine/job.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qm3ster/Notcraft path: /src/engine/job.rs
use crossbeam::deque::{self, Steal};
use std::{
collections::VecDeque,
sync::{mpsc, Arc, Mutex},
thread,
};
pub trait Worker: Send + 'static {
type Input: Send + 'static;
type Output: Send + 'static;
fn compute(&mut self, input:... | code_fim | hard | {
"lang": "rust",
"repo": "qm3ster/Notcraft",
"path": "/src/engine/job.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Service {
requester: request_inserter,
receiver: response_rx,
}
}
pub fn new(name: &str, num_workers: usize, worker: W) -> Self
where
W: Clone,
{
use std::iter;
Self::from_iter(name, iter::repeat(worker).take(num_workers))
... | code_fim | hard | {
"lang": "rust",
"repo": "qm3ster/Notcraft",
"path": "/src/engine/job.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raygon-renderer/thermite path: /crates/thermite/src/mask.rs
use crate::*;
use core::fmt;
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct Mask<S: Simd, V>(V, PhantomData<S>);
/// Small integer representation of a mask using individual bits
#[repr(transparent)]
pub struct BitMask<S: Simd... | code_fim | hard | {
"lang": "rust",
"repo": "raygon-renderer/thermite",
"path": "/crates/thermite/src/mask.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns a bitmask that can be trivially evaluated to all/any/none/etc.
///
/// The can be useful for reusing a mask value for branching
#[inline(always)]
pub fn bitmask(self) -> BitMask<S, V> {
BitMask {
mask: self.0.bitmask(),
vec: PhantomData,
... | code_fim | hard | {
"lang": "rust",
"repo": "raygon-renderer/thermite",
"path": "/crates/thermite/src/mask.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// For each lane, if the mask lane is truthy then swap the corresponding lanes in `a` and `b`
#[inline(always)]
pub fn swap<U>(self, a: &mut U, b: &mut U)
where
V: SimdCastTo<S, U>,
U: SimdVector<S>,
{
let mask = V::cast_mask(self).value();
let a2 = *a... | code_fim | hard | {
"lang": "rust",
"repo": "raygon-renderer/thermite",
"path": "/crates/thermite/src/mask.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PegasisForever/rust_todo path: /src/api/tools.rs
use actix_web::HttpResponse;
use actix_web::http::StatusCode;
use crate::api::error::ServerError;
use std::backtrace::Backtrace;
pub trait ServerUnwrap {
type Item;
fn without_error<F: FnOnce() -> ServerError>(self, error_fn: F) -> Result... | code_fim | medium | {
"lang": "rust",
"repo": "PegasisForever/rust_todo",
"path": "/src/api/tools.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.map_err(|_| { error_fn() })
}
}
pub trait ServerUnwrapError {
type Item;
fn with_error(self) -> Result<Self::Item, ServerError>;
}
impl<T, E: 'static + std::error::Error> ServerUnwrapError for Result<T, E> {
type Item = T;
fn with_error(self) -> Result<Self::Item, Serve... | code_fim | medium | {
"lang": "rust",
"repo": "PegasisForever/rust_todo",
"path": "/src/api/tools.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: omerbenamram/mft path: /src/csv.rs
use crate::attribute::header::ResidentialHeader;
use crate::attribute::{FileAttributeFlags, MftAttributeType};
use crate::entry::EntryFlags;
use crate::{MftAttribute, MftEntry, MftParser};
use serde::Serialize;
use chrono::{DateTime, Utc};
use std::io::{Read... | code_fim | hard | {
"lang": "rust",
"repo": "omerbenamram/mft",
"path": "/src/csv.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// All of these fields are present for entries that have an 0x10 attribute.
pub standard_info_flags: Option<FileAttributeFlags>,
pub standard_info_last_modified: Option<DateTime<Utc>>,
pub standard_info_last_access: Option<DateTime<Utc>>,
pub standard_info_created: Option<DateTime<Utc... | code_fim | hard | {
"lang": "rust",
"repo": "omerbenamram/mft",
"path": "/src/csv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub fn main() -> () {
let timer = Timer::default();
let mut rng:StdRng = SeedableRng::from_seed([
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2,
3, 4,
]);
let framebuffer = HyperPixel::new("#screen");
let mut pixel... | code_fim | medium | {
"lang": "rust",
"repo": "ds604/hyperpixel",
"path": "/examples/static/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ds604/hyperpixel path: /examples/static/src/lib.rs
use hyperpixel::*;
use rand::rngs::StdRng;
use rand::Rng;
use rand::SeedableRng;
use web_timer::*;
use js_ffi::*;
<|fim_suffix|>#[no_mangle]
pub fn main() -> () {
let timer = Timer::default();
let mut rng:StdRng = SeedableRng::from_seed... | code_fim | medium | {
"lang": "rust",
"repo": "ds604/hyperpixel",
"path": "/examples/static/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: couchbaselabs/couchbase-rs path: /couchbase/integration/test_functions.rs
use crate::tests::*;
use crate::util::TestConfig;
use crate::TestResult;
use futures::Future;
use std::pin::Pin;
use std::sync::Arc;
// Sad panda noises
pub fn tests(config: Arc<TestConfig>) -> Vec<TestFn> {
vec![
... | code_fim | hard | {
"lang": "rust",
"repo": "couchbaselabs/couchbase-rs",
"path": "/couchbase/integration/test_functions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Box::pin(kv::test_durability_persist_to_majority_get_any_replica(
config.clone(),
)),
),
TestFn::new(
"test_durability_majority_persist_on_master_get_any_replica",
Box::pin(
kv::test_durability_majority_persist_on... | code_fim | hard | {
"lang": "rust",
"repo": "couchbaselabs/couchbase-rs",
"path": "/couchbase/integration/test_functions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgarte/leaf path: /src/tasks.rs
//! Task handling routes.
use rocket::request::{FlashMessage, LenientForm};
use rocket::response::{content, Flash, Redirect};
use rocket::{Route, State};
use leaf::models::{NewTask, Store};
use crate::auth::{self, User, UserOrToken};
use crate::form::TasksForm;... | code_fim | hard | {
"lang": "rust",
"repo": "jgarte/leaf",
"path": "/src/tasks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Complete any checked tasks
store
.complete(&form.completed_ids)
.map_err(|_err| Flash::error(Redirect::to("/"), "Failed to complete tasks"))?;
Ok(Redirect::to("/"))
}<|fim_prefix|>// repo: jgarte/leaf path: /src/tasks.rs
//! Task handling routes.
use rocket::request::{Fla... | code_fim | hard | {
"lang": "rust",
"repo": "jgarte/leaf",
"path": "/src/tasks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>usize],
#[doc = "0x04 - Force network core off"]
pub forceoff: crate::Reg<self::network::forceoff::FORCEOFF_SPEC>,
}
#[doc = r"Register block"]
#[doc = "ULP network core control"]
pub mod network;
#[doc = "RESETREAS register accessor: an alias for `Reg<RESETREAS_SPEC>`"]
pub type RESETREAS = crate... | code_fim | medium | {
"lang": "rust",
"repo": "nrf-rs/nrf5340-pac",
"path": "/nrf5340-app-pac/src/reset_ns.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nrf-rs/nrf5340-pac path: /nrf5340-app-pac/src/reset_ns.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
_reserved0: [u8; 1024usize],
#[doc = "0x400 - Reset reason"]
pub resetreas: crate::Reg<resetreas::RESETREAS_SPEC><|fim_suffix|> mod network;
#[doc = "RESETREAS r... | code_fim | hard | {
"lang": "rust",
"repo": "nrf-rs/nrf5340-pac",
"path": "/nrf5340-app-pac/src/reset_ns.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sria91-rlox/rlox-35 path: /src/main.rs
mod chunk;
mod compiler;
mod debug;
mod scanner;
mod value;
mod vm;
use std::io::{self, BufRead, Read, Write};
fn main() {
let mut vm = vm::init_vm();
let args: Vec<String> = std::env::args().collect();
if args.len() == 1 {
repl(&mut ... | code_fim | medium | {
"lang": "rust",
"repo": "sria91-rlox/rlox-35",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_file(path: &str, vm: &mut vm::VM) {
let source = read_file(path).expect(&format!("Error reading file at {}", path));
let result = vm.interpret(&source);
match result {
vm::InterpretResult::InterpretCompileError => std::process::exit(65),
vm::InterpretResult::InterpretRu... | code_fim | hard | {
"lang": "rust",
"repo": "sria91-rlox/rlox-35",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T: DeserializeOwned + Clone> Iterator for CollectionReader<'a, T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
if self.collection.is_none() {
return None;
}
if self.collection.as_ref().unwrap().value.is_empty() {
return None... | code_fim | hard | {
"lang": "rust",
"repo": "marcusball/microsoft-todo-export",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marcusball/microsoft-todo-export path: /src/main.rs
#[macro_use]
extern crate serde;
#[macro_use]
extern crate derive_more;
use std::io;
use serde::de::DeserializeOwned;
mod error;
mod api;
use api::Collection;
use error::Result;
const GRAPH_BASE_URI: &str = "https://graph.microsoft.com/beta... | code_fim | hard | {
"lang": "rust",
"repo": "marcusball/microsoft-todo-export",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Fetch the requested collection from the given `url`.
/// Append the received collection items into the `items` property.
fn fetch_inner<S: AsRef<str>>(&mut self, url: S) -> Result<usize> {
self.collection = Some(self.client
.get(url.as_ref())
.bearer_auth(... | code_fim | hard | {
"lang": "rust",
"repo": "marcusball/microsoft-todo-export",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jorian/komodorpc-rust-client path: /src/rpcconn/response.rs
use std::result::Result as StdResult;
use std::{error::Error as StdError, fmt};
#[derive(Debug, Deserialize, PartialEq)]
pub struct RpcError {
pub code: i32,
pub message: String,
}
#[derive(Debug, Deserialize, PartialEq)]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "jorian/komodorpc-rust-client",
"path": "/src/rpcconn/response.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.