// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::mem::size_of; trait Trait {} fn main() { // Closures - || assert_eq!(size_of::<||>(), size_of::>()); // Functions assert_eq!(size_of::(), size_of::>()); assert_eq!(size_of::(), size_of::>()); // Slices - &str / &[T] / &mut [T] assert_eq!(size_of::<&str>(), size_of::>()); assert_eq!(size_of::<&[int]>(), size_of::>()); assert_eq!(size_of::<&mut [int]>(), size_of::>()); // Traits - Box / &Trait / &mut Trait assert_eq!(size_of::>(), size_of::>>()); assert_eq!(size_of::<&Trait>(), size_of::>()); assert_eq!(size_of::<&mut Trait>(), size_of::>()); // Pointers - Box assert_eq!(size_of::>(), size_of::>>()); // The optimization can't apply to raw pointers assert!(size_of::>() != size_of::<*const int>()); assert!(Some(0 as *const int).is_some()); // Can't collapse None to null }