You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
916 B
29 lines
916 B
From 498252a35dd6e1b4f9c0b596dc52e5aee8fac8c4 Mon Sep 17 00:00:00 2001
|
|
From: Fabio Valentini <decathorpe@gmail.com>
|
|
Date: Sun, 23 Jul 2023 22:32:41 +0200
|
|
Subject: [PATCH] Fix logic bug in stream::Stream::filter_map doctest
|
|
|
|
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 2d90362..9ad4eea 100644
|
|
--- a/src/stream/mod.rs
|
|
+++ b/src/stream/mod.rs
|
|
@@ -399,7 +399,7 @@ pub trait Stream {
|
|
///
|
|
/// let (_tx, rx) = mpsc::channel::<i32>(1);
|
|
/// let evens_plus_one = rx.filter_map(|x| {
|
|
- /// if x % 0 == 2 {
|
|
+ /// if x % 2 == 0 {
|
|
/// Some(x + 1)
|
|
/// } else {
|
|
/// None
|
|
--
|
|
2.41.0
|
|
|