Compile-time construction of Peano axioms-based natural numbers and addition, multiplication, and exponentiation defined through them within Rust. (Mirrored from Codeberg)

make _0 the unit type

+1 -1
+1 -1
src/lib.rs
··· 2 2 pub struct Succ<T>(T); 3 3 4 4 // Inductively define naturals 5 - pub type _0 = Succ<()>; 5 + pub type _0 = (); 6 6 impl Nat for _0 {} 7 7 impl<T: Nat> Nat for Succ<T> {} 8 8