From 7a89d6651348c510546ad238a2ae74032de19de8 Mon Sep 17 00:00:00 2001 From: Hanif Ariffin Date: Thu, 30 Apr 2020 06:44:19 -0400 Subject: [PATCH] io: add get_mut, get_ref and into_inner to Lines (#2450) --- tokio/src/io/util/lines.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tokio/src/io/util/lines.rs b/tokio/src/io/util/lines.rs index f0e75de4b..be4e86648 100644 --- a/tokio/src/io/util/lines.rs +++ b/tokio/src/io/util/lines.rs @@ -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`, 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 Lines