Cheat Sheet PDF
Cheat Sheet PDF
where T: Sized
len len size 4/8 bytes
cap into_vec
Note: String has same destructor atomic 4/8 bytes
memory layout as Vec<u8>
&T &[T] size
align fn 4/8 bytes
ptr ptr len
method1
method2 heap allocation,
T T T T T T allocation
implies ownership
where T: Sized
len
Note: &str has same
T user defined type
memory layout as &[u8]
enum {A, B, C} deref
Rc<T> Arc<T> Mutex<T>
ptr ptr inner poison T tag A
or
tag B
or
strong weak T strong weak T mutex tag C
Also basis of Result, Cow, etc.
Consider using parking_lot, which
doesn’t allocate the raw mutex
Option<T> Option<T>
tag T T
Cell<T> RefCell<T> or or
T borrow T tag
when T contains pointers
which can't be null
Rust container cheat sheet, by Raph Levien, Copyright 2017 Google Inc., released under Creative Commons BY, 2017-04-21, version 0.0.3