SHARE
TWEET

Untitled

a guest Mar 19th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::mem::size_of;
  2. use std::collections::HashMap;
  3.  
  4. fn main() {
  5.     // What is the size of a pointer?
  6.     dbg!(size_of::<&i64>());
  7.    
  8.     // What is the size of an array with 10 elements of i64?
  9.     dbg!(size_of::<[i64;10]>());
  10.     // And what if I box that large thingy?
  11.     dbg!(size_of::<Box<[i64;10]>>());
  12.    
  13.     // Now, what is the size of a HashMap?
  14.     dbg!(size_of::<HashMap<i32, i32>>());
  15.     dbg!(size_of::<HashMap<String, String>>());
  16.     dbg!(size_of::<HashMap<String, HashMap<String, String>>>());
  17.     // And if I box that again?
  18.     dbg!(size_of::<Box<HashMap<i32, i32>>>());
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top