RS.CLIPPY.PTR_ARG
Fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively
What it does
This lint checks for function arguments of type &String, &Vec,
&PathBuf, and Cow<_>. It will also suggest you replace .clone() calls
with the appropriate .to_owned()/to_string() calls.
Why is this bad?
Requiring the argument to be of the specific type
makes the function less useful for no benefit; slices in the form of &[T]
or &str usually suffice and can be obtained from other types, too.
Known problems
There may be fn(&Vec)-typed references pointing to your function.
If you have them, you will get a compiler error after applying this lint's
suggestions. You then have the choice to undo your changes or change the
type of the reference.
Note that if the function is part of your public interface, there may be other crates referencing it, of which you may not be aware. Carefully deprecate the function before applying the lint suggestions in this case.
Example
fn foo(&Vec<u32>) { .. }
Use instead:
fn foo(&[u32]) { .. }