1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-25 23:49:54 +02:00

Vec::new() doesn't allocate (#2026)

So remove it from the list of things to look on that allocate, and
replace with `vec![]`, which does allocate (if given any elements).
This commit is contained in:
Chayim Refael Friedman 2024-04-25 16:40:36 +03:00 committed by GitHub
parent 402ac3a202
commit 5633dd52a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,7 +22,7 @@ fn main() {
<details> <details>
- The idea of `Clone` is to make it easy to spot where heap allocations are - The idea of `Clone` is to make it easy to spot where heap allocations are
occurring. Look for `.clone()` and a few others like `Vec::new` or `Box::new`. occurring. Look for `.clone()` and a few others like `vec!` or `Box::new`.
- It's common to "clone your way out" of problems with the borrow checker, and - It's common to "clone your way out" of problems with the borrow checker, and
return later to try to optimize those clones away. return later to try to optimize those clones away.