Add example of false positive to PTR_ARG docs.

Fixes #214
This commit is contained in:
Ryan Wiedemann 2020-08-10 08:50:20 -06:00 committed by GitHub
parent c576bedc41
commit 3e3e50bf0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,14 +36,27 @@
/// argument may also fail to compile if you change the argument. Applying /// argument may also fail to compile if you change the argument. Applying
/// this lint on them will fix the problem, but they may be in other crates. /// this lint on them will fix the problem, but they may be in other crates.
/// ///
/// One notable example of a function that may cause issues, and which cannot
/// easily be changed due to beinng in the standard library is `Vec::contains`.
/// when called on a `Vec<Vec<T>>`. If a `&Vec` is passed to that method then
/// it will compile, but if a `&[T]` is passed then it will not compile.
///
/// ```ignore
/// fn cannot_take_a_slice(v: &Vec<u8>) -> bool {
/// let vec_of_vecs: Vec<Vec<u8>> = some_other_fn();
///
/// vec_of_vecs.contains(v)
/// }
/// ```
///
/// Also there may be `fn(&Vec)`-typed references pointing to your function. /// Also 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 /// 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 /// suggestions. You then have the choice to undo your changes or change the
/// type of the reference. /// type of the reference.
/// ///
/// Note that if the function is part of your public interface, there may be /// Note that if the function is part of your public interface, there may be
/// other crates referencing it you may not be aware. Carefully deprecate the /// other crates referencing it, of which you may not be aware. Carefully
/// function before applying the lint suggestions in this case. /// deprecate the function before applying the lint suggestions in this case.
/// ///
/// **Example:** /// **Example:**
/// ```ignore /// ```ignore