Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(never_type)]
- use std::mem::{size_of};
- #[derive(Debug, Copy, Clone)]
- enum Singleton { Zero }
- #[derive(Debug, Copy, Clone)]
- enum Empty {}
- fn main() {
- let singleton_box = Box::new(Singleton::Zero);
- let never_box = unsafe { std::mem::transmute::<Box<()>, Box<Empty>>(Box::new(())) };
- let bang_box = unsafe { std::mem::transmute::<Box<()>, Box<!>>(Box::new(())) };
- println!("size_of::<()> = {}", size_of::<()>());
- println!("size_of::<Singleton> = {}", size_of::<Singleton>());
- println!("size_of::<Empty> = {}", size_of::<Empty>());
- println!("size_of::<!> = {}", size_of::<!>());
- println!("value of Box<Singleton> = {:?}", singleton_box);
- println!("value of Box<Never> = {:?}", never_box);
- println!("value of Box<!> = {:?}", bang_box);
- }
Add Comment
Please, Sign In to add comment