]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/large_types_passed_by_value.txt
Rollup merge of #101790 - TaKO8Ki:do-not-suggest-placeholder-to-const-and-static...
[rust.git] / src / tools / clippy / src / docs / large_types_passed_by_value.txt
1 ### What it does
2 Checks for functions taking arguments by value, where
3 the argument type is `Copy` and large enough to be worth considering
4 passing by reference. Does not trigger if the function is being exported,
5 because that might induce API breakage, if the parameter is declared as mutable,
6 or if the argument is a `self`.
7
8 ### Why is this bad?
9 Arguments passed by value might result in an unnecessary
10 shallow copy, taking up more space in the stack and requiring a call to
11 `memcpy`, which can be expensive.
12
13 ### Example
14 ```
15 #[derive(Clone, Copy)]
16 struct TooLarge([u8; 2048]);
17
18 fn foo(v: TooLarge) {}
19 ```
20
21 Use instead:
22 ```
23 fn foo(v: &TooLarge) {}
24 ```