File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,29 @@ pub trait BufRead {
59
59
/// #
60
60
/// # Ok(()) }) }
61
61
/// ```
62
+ ///
63
+ /// Multiple successful calls to `read_until` append all bytes up to and including to `buf`:
64
+ /// ```
65
+ /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
66
+ /// #
67
+ /// use async_std::io::BufReader;
68
+ /// use async_std::prelude::*;
69
+ ///
70
+ /// let from: &[u8] = b"append\nexample\n";
71
+ /// let mut reader = BufReader::new(from);
72
+ /// let mut buf = vec![];
73
+ ///
74
+ /// let mut size = reader.read_until(b'\n', &mut buf).await?;
75
+ /// assert_eq!(size, 7);
76
+ /// assert_eq!(buf, b"append\n");
77
+ ///
78
+ /// size += reader.read_until(b'\n', &mut buf).await?;
79
+ /// assert_eq!(size, from.len());
80
+ ///
81
+ /// assert_eq!(buf, from);
82
+ /// #
83
+ /// # Ok(()) }) }
84
+ /// ```
62
85
fn read_until < ' a > (
63
86
& ' a mut self ,
64
87
byte : u8 ,
You can’t perform that action at this time.
0 commit comments