Skip to content

Commit 3a29aed

Browse files
committed
result_map_or_into_option: add good and bad examples
1 parent 91759a7 commit 3a29aed

File tree

1 file changed

+7
-2
lines changed
  • clippy_lints/src/methods

1 file changed

+7
-2
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,13 @@ declare_clippy_lint! {
340340
///
341341
/// **Example:**
342342
/// ```rust
343-
/// # let opt = Some(1);
344-
/// # let r = opt.map_or(None, Some);
343+
/// # Bad
344+
/// let r: Result<u32, &str> = Ok(1);
345+
/// assert_eq!(Some(1), r.map_or(None, Some));
346+
///
347+
/// # Good
348+
/// let r: Result<u32, &str> = Ok(1);
349+
/// assert_eq!(Some(1), r.ok());
345350
/// ```
346351
pub RESULT_MAP_OR_INTO_OPTION,
347352
style,

0 commit comments

Comments
 (0)