From 4cf2bf4b40900ea39dbb8c19c2ba0ed97ef3cfb3 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 18 Jan 2024 07:42:17 +1100 Subject: [PATCH] io: Make Take::read_to_end public Currently `Take::read_to_end` is private forcing users to use our "custom" `read_to_limit`, for seasoned Rust hackers `foo.take(16).read_to_end(buf)` make be more unsurprising. Make `read_to_end` public. --- io/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/io/src/lib.rs b/io/src/lib.rs index 696118f2..b52c5bdb 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -89,9 +89,10 @@ pub struct Take<'a, R: Read + ?Sized> { } impl<'a, R: Read + ?Sized> Take<'a, R> { + /// Reads all bytes until EOF from the underlying reader into `buf`. #[cfg(any(feature = "alloc", feature = "std"))] #[inline] - fn read_to_end(&mut self, buf: &mut Vec) -> Result { + pub fn read_to_end(&mut self, buf: &mut Vec) -> Result { let mut read: usize = 0; let mut chunk = [0u8; 64]; loop {