This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use pin_project::*; | |
use pin_utils::*; | |
use std::future::Future; | |
use std::ops::{Deref, DerefMut}; | |
use std::pin::Pin; | |
use std::task::Context; | |
use std::task::Poll; | |
async fn with_context<F, A>(f: F) -> A | |
where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::error::Error; | |
use libc::c_void; | |
fn main() -> Result<(), Box<dyn Error>> { | |
show_maps()?; | |
let allocation = unsafe { allocate_cursed_ringbuffer(1) }; | |
println!("{:p}", allocation); | |
show_maps()?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(generator_trait)] | |
#![feature(generators)] | |
use std::ops::{Generator, GeneratorState}; | |
use std::pin::Pin; | |
use futures::pin_mut; | |
struct GeneratorIteratorImpl<T>(T); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title></title> | |
<meta charset="utf-8"> | |
<style> | |
h1 { | |
font-family: "Verdana", sans-serif; | |
font-weight: normal; | |
font-size: 8em; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bindkey -e | |
setopt NO_BEEP | |
export HISTFILE=~/.history | |
export HISTSIZE=1000 | |
export SAVEHIST=1000 | |
setopt APPEND_HISTORY | |
setopt HIST_IGNORE_SPACE | |
setopt HIST_IGNORE_ALL_DUPS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::time::Instant; | |
// From jakobrs/primes, using the kimwalisch/primesieve library | |
use primesieve::PrimesieveIterator; | |
fn main() { | |
for n in 5..=20 { | |
let count = ((5. / 4. * n as f64).exp() / n as f64) as u64; | |
let before = Instant::now(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(allocator_api)] | |
#![feature(strict_provenance)] | |
use std::{ | |
alloc::{Allocator, Global, Layout}, | |
marker::PhantomData, | |
mem::ManuallyDrop, | |
ops::{Index, IndexMut}, | |
ptr::NonNull, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! define_macros_inner { | |
($words:ident, $out:ident, $d:tt) => { | |
macro_rules! read { | |
() => { | |
$words.next().unwrap().parse().unwrap() | |
}; | |
($t:ty) => { | |
$words.next().unwrap().parse::<$t>().unwrap() | |
}; | |
($t:ty, $n:expr) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::Write; | |
#[rustfmt::skip] | |
macro_rules! define_read { | |
($words:ident) => { | |
macro_rules! read { | |
() => { | |
$words.next().unwrap().parse().unwrap() | |
}; | |
($t:ty) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{ | |
borrow::Cow, | |
fs::File, | |
io::Read, | |
path::{Path, PathBuf}, | |
}; | |
use anyhow::{Context, Result}; | |
use clap::Parser; | |
use regex::Regex; |