expression
Consume text records with async Lines
The line adapter yields owned text records without their LF or CRLF terminators, and also returns a final unterminated line. A line length is not automatically bounded. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): one two three Common mistake: Dropping a buffered reader and expecting unread buffered bytes to remain available.
Formal Syntax & Structure
rust syntaxrust
BufReader::new(reader).lines(); lines.next_line().awaitWorking Example
Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() { use tokio::io::{AsyncBufReadExt, BufReader}; let mut lines = BufReader::new(&b"one\r\ntwo\nthree"[..]).lines(); while let Some(line) = lines.next_line().await.unwrap() { println!("{line}"); }}