Skip to content

Commit f392082

Browse files
newca12taiki-e
authored andcommitted
Extend io::AsyncBufReadExt::lines example with invalid UTF-8
1 parent 2f2ec39 commit f392082

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

futures-util/src/io/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,11 +804,11 @@ pub trait AsyncBufReadExt: AsyncBufRead {
804804
/// use futures::io::{AsyncBufReadExt, Cursor};
805805
/// use futures::stream::StreamExt;
806806
///
807-
/// let cursor = Cursor::new(b"lorem\nipsum\r\ndolor");
807+
/// let cursor = Cursor::new(b"lorem\nipsum\xc2\r\ndolor");
808808
///
809-
/// let mut lines_stream = cursor.lines().map(|l| l.unwrap());
809+
/// let mut lines_stream = cursor.lines().map(|l| l.unwrap_or(String::from("invalid UTF_8")));
810810
/// assert_eq!(lines_stream.next().await, Some(String::from("lorem")));
811-
/// assert_eq!(lines_stream.next().await, Some(String::from("ipsum")));
811+
/// assert_eq!(lines_stream.next().await, Some(String::from("invalid UTF_8")));
812812
/// assert_eq!(lines_stream.next().await, Some(String::from("dolor")));
813813
/// assert_eq!(lines_stream.next().await, None);
814814
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();

0 commit comments

Comments
 (0)