Last active
August 7, 2023 16:45
-
-
Save ClarkeRemy/7fdde966741b86dfd05466ae07b48b40 to your computer and use it in GitHub Desktop.
Swappy
This file contains 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
#[derive(Debug)] | |
enum Switchy<A,B> | |
{ Nil | |
, Cons(A, Box<Switchy<B,A>>) | |
} | |
impl<A,B> Switchy<A,B> | |
{ fn cons(t : A, tail : Switchy<B,A>)->Self | |
{ Self::Cons(t, Box::new(tail)) } | |
} | |
pub fn main() | |
{ type L<A,B> = Switchy<A,B> | |
; let l = L::cons(1, L::cons("horror", L::cons(3, L::cons("why", L::cons(4, L::Nil))))) | |
; println!{"{l:?}"} | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment