use std::cell::RefCell; use libc::malloc; pub mod error; pub mod parse; #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct PissAmount { to_piss: u128 } #[derive(Copy, Clone, Debug)] pub enum Toliet { Rust, Lazy, Unsafe } fn leak_rust(amount: usize) { Vec::::with_capacity(amount).leak(); } thread_local!(static TOLIET: RefCell>> = RefCell::new(Vec::new())); fn leak_lazy(amount: usize) { TOLIET.with(|t| { t.borrow_mut().push(Vec::::with_capacity(amount)); }) } fn leak_unsafe(amount: usize) { unsafe { malloc(amount); } } fn leak_match(amount: usize, method: Toliet) { match method { Toliet::Rust => leak_rust(amount), Toliet::Lazy => leak_lazy(amount), Toliet::Unsafe => leak_unsafe(amount), } } pub fn leak>(amount: T, method: Toliet) { let num: u128 = amount.into().to_piss; let count = num / usize::MAX as u128; for _ in 0..count { leak_match(usize::MAX, method); } leak_match((num % usize::MAX as u128) as usize, method); } pub async fn leak_async>(amount: T, method: Toliet) { leak(amount, method); }