Auto merge of #8262 - 1nF0rmed:chore-update-borrowed-box-doc, r=camsteffen
Improve documentation for `borrowed-box` lint fixes #8161 Updates documentation to elaborate more on how removing Box from a function parameter can generalize the function. changelog: none
This commit is contained in:
commit
88f5be2041
@ -167,8 +167,9 @@
|
||||
/// Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// Any `&Box<T>` can also be a `&T`, which is more
|
||||
/// general.
|
||||
/// A `&Box<T>` parameter requires the function caller to box `T` first before passing it to a function.
|
||||
/// Using `&T` defines a concrete type for the parameter and generalizes the function, this would also
|
||||
/// auto-deref to `&T` at the function call site if passed a `&Box<T>`.
|
||||
///
|
||||
/// ### Example
|
||||
/// ```rust,ignore
|
||||
|
Loading…
Reference in New Issue
Block a user