From 729030f387a14a1f05486bbc0c2bb4064da5df07 Mon Sep 17 00:00:00 2001 From: zhangzhonglai Date: Wed, 15 Jun 2022 14:54:57 +0800 Subject: [PATCH] fix: filter_map requires to return an 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);