]> git.lizzy.rs Git - rust.git/blob - src/docs/redundant_allocation.txt
Auto merge of #9425 - kraktus:patch-1, r=xFrednet
[rust.git] / src / docs / redundant_allocation.txt
1 ### What it does
2 Checks for use of redundant allocations anywhere in the code.
3
4 ### Why is this bad?
5 Expressions such as `Rc<&T>`, `Rc<Rc<T>>`, `Rc<Arc<T>>`, `Rc<Box<T>>`, `Arc<&T>`, `Arc<Rc<T>>`,
6 `Arc<Arc<T>>`, `Arc<Box<T>>`, `Box<&T>`, `Box<Rc<T>>`, `Box<Arc<T>>`, `Box<Box<T>>`, add an unnecessary level of indirection.
7
8 ### Example
9 ```
10 fn foo(bar: Rc<&usize>) {}
11 ```
12
13 Better:
14
15 ```
16 fn foo(bar: &usize) {}
17 ```