heap領域で確保される型
Rustは通常スタック領域に値を確保するが、一部の型はヒープ領域で内部の値を確保し、その参照を返す。
Containers:
- Box
- Rc
- Arc
Collections types:
- Vec, VecDeque
- String
- HashMap, HashSet
- BTreeMap, BTreeSet
Concurrency:
- thread::spawn(): the closure is boxed so it can be passed as a pointer into the new thread’s environment (required by the C-based thread APIs)
- JoinHandle: the return value of the closure passed to thread::spawn() is returned as a pointer (same)
- Sender/SyncSender & Receiver
I/O:
- BufReader
- The TCP streams are buffered at the OS level, I don’t know how much Rust has a say in those buffer sizes
- stdin, stdout, and stderr use global heap-allocated buffers (which you interact with whenever you invoke println!() or panic!())
FFI:
- CString
- OsString