Skip to content

Commit

Permalink
Extend io::AsyncBufReadExt::lines example with invalid UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
newca12 authored and taiki-e committed Oct 25, 2023
1 parent 6667f1b commit de8e42e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions futures-util/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,11 @@ pub trait AsyncBufReadExt: AsyncBufRead {
/// use futures::io::{AsyncBufReadExt, Cursor};
/// use futures::stream::StreamExt;
///
/// let cursor = Cursor::new(b"lorem\nipsum\r\ndolor");
/// let cursor = Cursor::new(b"lorem\nipsum\xc2\r\ndolor");
///
/// let mut lines_stream = cursor.lines().map(|l| l.unwrap());
/// let mut lines_stream = cursor.lines().map(|l| l.unwrap_or(String::from("invalid UTF_8")));
/// assert_eq!(lines_stream.next().await, Some(String::from("lorem")));
/// assert_eq!(lines_stream.next().await, Some(String::from("ipsum")));
/// assert_eq!(lines_stream.next().await, Some(String::from("invalid UTF_8")));
/// assert_eq!(lines_stream.next().await, Some(String::from("dolor")));
/// assert_eq!(lines_stream.next().await, None);
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
Expand Down

0 comments on commit de8e42e

Please sign in to comment.