Skip to content

Commit 061a483

Browse files
author
Michael Rutter
committed
added downsides to "known problems" for get_unwrap lint
1 parent 457e7f1 commit 061a483

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

+8-1
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 syntax (`[]`) 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 eventually handled in a future refactor instead of using `.unwrap()`
578+
/// or the Index syntax.
572579
///
573580
/// **Example:**
574581
/// ```rust

0 commit comments

Comments
 (0)