From f62aca2a777d4636e7dc7e4b82d4aa854435dcaf Mon Sep 17 00:00:00 2001 From: 0xmingx Date: Tue, 11 Oct 2022 22:49:43 +0800 Subject: [PATCH] fix bug the `msg` type here is `Message`, don't need `unwrap()`, then wrapping `msg.content` in `Some`, return to fit the `filter_map`'s trait bound: Option --- src/async-rust/tokio/stream.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/async-rust/tokio/stream.md b/src/async-rust/tokio/stream.md index 58b1773a..c7b07753 100644 --- a/src/async-rust/tokio/stream.md +++ b/src/async-rust/tokio/stream.md @@ -184,7 +184,7 @@ got = b"6" let messages = subscriber .into_stream() .filter_map(|msg| match msg { - Ok(msg) if msg.content.len() == 1 => msg.unwrap().content, + Ok(msg) if msg.content.len() == 1 => Some(msg.content), _ => None, }) .take(3);