Fix logic bug in stream::Stream::filter_map doctest

epel9
Fabio Valentini 2 years ago
parent e3cf961d73
commit 7d8fa4b6a5
No known key found for this signature in database
GPG Key ID: 5AC5F572E5D410AF

@ -0,0 +1,28 @@
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

@ -13,6 +13,8 @@ Summary: Implementation of futures and streams featuring zero allocations
License: MIT OR Apache-2.0
URL: https://crates.io/crates/futures
Source: %{crates_source}
# https://github.com/rust-lang/futures-rs/pull/2765
Patch: 0001-Fix-logic-bug-in-stream-Stream-filter_map-doctest.patch
BuildRequires: rust-packaging >= 21

Loading…
Cancel
Save