io: add get_mut, get_ref and into_inner to Lines (#2450)

This commit is contained in:
Hanif Ariffin 2020-04-30 06:44:19 -04:00 committed by GitHub
parent 45773c5641
commit 7a89d66513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,24 @@ where
poll_fn(|cx| Pin::new(&mut *self).poll_next_line(cx)).await
}
/// Obtain a mutable reference to the underlying reader
pub fn get_mut(&mut self) -> &mut R {
&mut self.reader
}
/// Obtain a reference to the underlying reader
pub fn get_ref(&mut self) -> &R {
&self.reader
}
/// Unwraps this `Lines<R>`, returning the underlying reader.
///
/// Note that any leftover data in the internal buffer is lost.
/// Therefore, a following read from the underlying reader may lead to data loss.
pub fn into_inner(self) -> R {
self.reader
}
}
impl<R> Lines<R>