From fc680d1cf1074ff1fa29d7b41ac789d37bcdd518 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Mon, 24 Jul 2023 22:51:44 +0200 Subject: [PATCH] Fix logic bug in stream::Stream::filter_map doctest (#2765) The operator for the modulo and the test were swapped, and using "modulo zero" is undefined and results in an unconditional panic, which is now caught with Rust 1.71 (unconditional_panic lint). --- src/stream/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream/mod.rs b/src/stream/mod.rs index 2d90362470..9ad4eea45c 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -399,7 +399,7 @@ pub trait Stream { /// /// let (_tx, rx) = mpsc::channel::(1); /// let evens_plus_one = rx.filter_map(|x| { - /// if x % 0 == 2 { + /// if x % 2 == 0 { /// Some(x + 1) /// } else { /// None