1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-24 07:21:05 +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>
- 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
return later to try to optimize those clones away.