Skip to content

Commit 539fcf0

Browse files
committed
Try #3368:
2 parents c8308c9 + 232a483 commit 539fcf0

File tree

1 file changed

+8
-1
lines changed
  • clippy_lints/src/methods

1 file changed

+8
-1
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,14 @@ declare_clippy_lint! {
568568
/// **Why is this bad?** Using the Index trait (`[]`) is more clear and more
569569
/// concise.
570570
///
571-
/// **Known problems:** None.
571+
/// **Known problems:** Not a replacement for error handling: Using either
572+
/// `.unwrap()` or the Index trait (`[]`) carries the risk of causing a `panic`
573+
/// if the value being accessed is `None`. If the use of `.get().unwrap()` is a
574+
/// temporary placeholder for dealing with the `Option` type, then this does
575+
/// not mitigate the need for error handling. If there is a chance that `.get()`
576+
/// will be `None` in your program, then it is advisable that the `None` case
577+
/// is handled in a future refactor instead of using `.unwrap()` or the Index
578+
/// trait.
572579
///
573580
/// **Example:**
574581
/// ```rust

0 commit comments

Comments
 (0)