Skip to content

Instantly share code, notes, and snippets.

View yoshuawuyts's full-sized avatar

Yosh yoshuawuyts

View GitHub Profile
@yoshuawuyts
yoshuawuyts / playground.rs
Created September 16, 2019 02:59 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[derive(Debug, PartialEq)]
enum State {
Waiting { waiting_time: usize },
Filling { rate: usize },
Done,
Failure(String),
}
#[derive(Debug, Clone, Copy)]
enum Event {
@yoshuawuyts
yoshuawuyts / playground.rs
Created September 2, 2019 18:42 — forked from rust-play/playground.rs
Code shared from the Rust Playground
macro_rules! fmt_args {
($($tt:tt)*) => {
_fmt_args_!("",; $($tt)*)
};
}
macro_rules! _fmt_args_ {
($fmt:expr, $($args:expr,)*; ) => {
format_args!($fmt $(,$args)*)
};
@yoshuawuyts
yoshuawuyts / kv-log-macro.rs
Last active September 1, 2019 12:06 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[macro_export]
macro_rules! info {
// info!("...")
($e:expr) => {
$crate::info_impl!(($e));
};
// info!("...", args...)
($e:expr, $($rest:tt)*) => {
$crate::info_impl!(($e) $($rest)*);
@yoshuawuyts
yoshuawuyts / rust.yml
Last active August 25, 2019 09:31
github ci workflow
name: Rust
on: [push, pull_request]
jobs:
test:
name: ${{ matrix.rust }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
#[cli]
struct Args {
/// The language of the text.
#[cli(header = "Content-Language")]
lang: String,
/// The current page's description.
#[cli(dom = "head.description")]
desc: String,
}
// +-----------------------+
// | futures + async/await | --+
// +-----------------------+ +-- Application
// | runtime | --+
// +-----------------------+
// | OS | --+
// +-----------------------+ +-- Platform
// | Hardware | --+
// +-----------------------+
trait AsyncRead {
async fn read(&self, buf: &mut [u8]) -> io::Result<usize>;
}
fn main () {
let mut buf = vec![0; 1024];
let bytes_read = read(&mut buf).await?;
dbg!(buf);
}
@yoshuawuyts
yoshuawuyts / playground.rs
Created July 22, 2019 21:30 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#![feature(async_await)]
use std::{cell::Cell, future::Future, io, net::SocketAddr, pin::Pin};
pub trait TcpStream {}
impl<T: TcpStream + ?Sized> TcpStream for Pin<Box<T>> {}
pub trait Runtime: Send + Sync + 'static {
type TcpStream: TcpStream;
@yoshuawuyts
yoshuawuyts / playground.rs
Created July 22, 2019 21:26 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#![feature(async_await)]
use std::{cell::Cell, future::Future, io, net::SocketAddr, pin::Pin};
pub trait TcpStream {}
impl<T: TcpStream + ?Sized> TcpStream for Pin<Box<T>> {}
pub trait Runtime: Send + Sync + 'static {
type TcpStream: TcpStream;
@yoshuawuyts
yoshuawuyts / arch-linux-install.md
Created May 19, 2019 21:57 — forked from jamesmunns/arch-linux-install.md
Minimal instructions for installing arch linux on an UEFI NVMe system with full system encryption using dm-crypt and luks