Skip to content

Instantly share code, notes, and snippets.

View AzureMarker's full-sized avatar

Mark Drobnak AzureMarker

View GitHub Profile
@AzureMarker
AzureMarker / spawn_pinned.rs
Last active November 26, 2021 21:56
spawn_pinned variant which uses catch_unwind when creating the task, to protect the worker from panics.
use std::fmt;
use std::fmt::{Debug, Formatter};
use std::future::Future;
use std::panic::UnwindSafe;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use tokio::runtime::Builder;
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
use tokio::task::{spawn_local, JoinHandle, LocalSet};
@AzureMarker
AzureMarker / spawn_pinned.rs
Created November 26, 2021 20:02
First attempt at making a spawn_pinned function that is totally synchronous.
use std::fmt;
use std::fmt::{Debug, Formatter};
use std::future::Future;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use tokio::runtime::{Builder, Runtime};
use tokio::task::{spawn_local, JoinHandle, LocalSet};
/// A handle to a local pool, used for spawning `!Send` tasks.
#[derive(Clone)]
@AzureMarker
AzureMarker / multiple_interfaces.rs
Created September 28, 2021 01:37
A proof-of-concept for accessing the same shaku component through multiple interfaces.
use shaku::{module, Component, HasComponent, Interface, Module, ModuleBuildContext};
use std::sync::Arc;
trait Fizz: Interface {
fn fizz(&self);
}
trait Buzz: Interface {
fn buzz(&self);
}
@AzureMarker
AzureMarker / euler_34.rs
Last active June 14, 2017 15:50
Solution to Project Euler #34
fn main() {
let mut digits = [0; 5];
let mut factorial_cache = [0; 10];
let mut sum = 0;
find_special(&mut digits, 0, &mut |digits| {
let target = target(digits);
// 0!, 1! and 2! aren't sums
if target == 0 || target == 1 || target == 2 {

Keybase proof

I hereby claim:

  • I am AzureMarker on github.
  • I am mcat12 (https://keybase.io/mcat12) on keybase.
  • I have a public key whose fingerprint is F1F2 7C3D C691 B86E 06D1 1B78 7E11 8838 141B 6B56

To claim this, I am signing this object: