Skip to content

Instantly share code, notes, and snippets.

@ddfisher
ddfisher / TypeArithmetic.rs
Last active March 19, 2021 14:39
Type-level Arithmetic in Rust
#![feature(core_intrinsics)]
// This requires unstable features to compile so we can print out the type names. The type
// arithmetic itself works fine on stable.
use std::marker::PhantomData;
enum Zero {}
enum Succ<T> {
Succ(PhantomData<T>), // only required to satisfy the compiler