From f45bdcce69c754a3e5308b71c810e233a100f65c Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 14:20:51 -0500 Subject: [PATCH 01/21] Implement size_hint for BufReader --- library/std/src/io/mod.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index db3b0e2628f2a..0fc99baa66639 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2216,7 +2216,11 @@ impl Read for Chain { unsafe fn initializer(&self) -> Initializer { let initializer = self.first.initializer(); - if initializer.should_initialize() { initializer } else { self.second.initializer() } + if initializer.should_initialize() { + initializer + } else { + self.second.initializer() + } } } @@ -2235,7 +2239,11 @@ impl BufRead for Chain { } fn consume(&mut self, amt: usize) { - if !self.done_first { self.first.consume(amt) } else { self.second.consume(amt) } + if !self.done_first { + self.first.consume(amt) + } else { + self.second.consume(amt) + } } } @@ -2465,6 +2473,17 @@ impl Iterator for Bytes { }; } } + + default fn size_hint(&self) -> (usize, Option) { + (0, None) + } +} + +#[stable(feature = "bufreader_size_hint", since = "1.51.0")] +impl Iterator for Bytes> { + fn size_hint(&self) -> (usize, Option) { + (self.inner.buffer().len(), None) + } } /// An iterator over the contents of an instance of `BufRead` split on a From c3e47d974ab1c1c4d4b00989631586e60d78b554 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 14:43:20 -0500 Subject: [PATCH 02/21] Fix implementation to specialize --- library/std/src/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 0fc99baa66639..e02ee58cdbcb2 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2480,7 +2480,7 @@ impl Iterator for Bytes { } #[stable(feature = "bufreader_size_hint", since = "1.51.0")] -impl Iterator for Bytes> { +impl Iterator for Bytes> { fn size_hint(&self) -> (usize, Option) { (self.inner.buffer().len(), None) } From fa76db3104c11416f125be7fcc27d2435dcb84c5 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 17:37:29 -0500 Subject: [PATCH 03/21] Use helper trait to follow min_specialization rules --- library/std/src/io/mod.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index e02ee58cdbcb2..c98f8e383eda0 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2459,7 +2459,7 @@ pub struct Bytes { } #[stable(feature = "rust1", since = "1.0.0")] -impl Iterator for Bytes { +impl Iterator for Bytes { type Item = Result; fn next(&mut self) -> Option> { @@ -2475,14 +2475,34 @@ impl Iterator for Bytes { } default fn size_hint(&self) -> (usize, Option) { - (0, None) + self.inner.size_hint() } } #[stable(feature = "bufreader_size_hint", since = "1.51.0")] -impl Iterator for Bytes> { +trait SizeHint { + fn lower_bound(&self) -> usize; + + fn upper_bound(&self) -> Option { + None + } + fn size_hint(&self) -> (usize, Option) { - (self.inner.buffer().len(), None) + (self.lower_bound(), self.upper_bound()) + } +} + +#[stable(feature = "bufreader_size_hint", since = "1.51.0")] +impl SizeHint for T { + fn lower_bound(&self) -> usize { + 0 + } +} + +#[stable(feature = "bufreader_size_hint", since = "1.51.0")] +impl SizeHint for BufReader { + fn lower_bound(&self) -> usize { + self.buffer().len() } } From 11c49f6a2a6cc7aa5b0223c4d2ec59fb4fc9b739 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 17:41:42 -0500 Subject: [PATCH 04/21] Add missing generic --- library/std/src/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index c98f8e383eda0..ae01972339498 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2493,7 +2493,7 @@ trait SizeHint { } #[stable(feature = "bufreader_size_hint", since = "1.51.0")] -impl SizeHint for T { +impl SizeHint for T { fn lower_bound(&self) -> usize { 0 } From 260a270f7c531a3b8f951b69c9e793e3afd67c89 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 17:47:25 -0500 Subject: [PATCH 05/21] Move default to trait definition --- library/std/src/io/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index ae01972339498..cd54b8cc5699e 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2481,7 +2481,9 @@ impl Iterator for Bytes { #[stable(feature = "bufreader_size_hint", since = "1.51.0")] trait SizeHint { - fn lower_bound(&self) -> usize; + fn lower_bound(&self) -> usize { + 0 + } fn upper_bound(&self) -> Option { None @@ -2493,11 +2495,7 @@ trait SizeHint { } #[stable(feature = "bufreader_size_hint", since = "1.51.0")] -impl SizeHint for T { - fn lower_bound(&self) -> usize { - 0 - } -} +impl SizeHint for T; #[stable(feature = "bufreader_size_hint", since = "1.51.0")] impl SizeHint for BufReader { From 5f60a3048ed0d6b2b56e253769fbd6593ccb1d71 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 17:52:55 -0500 Subject: [PATCH 06/21] Fix incorrect token --- library/std/src/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index cd54b8cc5699e..53da24409459d 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2495,7 +2495,7 @@ trait SizeHint { } #[stable(feature = "bufreader_size_hint", since = "1.51.0")] -impl SizeHint for T; +impl SizeHint for T {} #[stable(feature = "bufreader_size_hint", since = "1.51.0")] impl SizeHint for BufReader { From eea99f491b6000a836a8887a29d1ce85c666fe47 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 18:45:00 -0500 Subject: [PATCH 07/21] Add default keyword for specialization --- library/std/src/io/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 53da24409459d..712e808a02474 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2481,10 +2481,6 @@ impl Iterator for Bytes { #[stable(feature = "bufreader_size_hint", since = "1.51.0")] trait SizeHint { - fn lower_bound(&self) -> usize { - 0 - } - fn upper_bound(&self) -> Option { None } @@ -2495,7 +2491,11 @@ trait SizeHint { } #[stable(feature = "bufreader_size_hint", since = "1.51.0")] -impl SizeHint for T {} +impl SizeHint for T { + default fn lower_bound(&self) -> usize { + 0 + } +} #[stable(feature = "bufreader_size_hint", since = "1.51.0")] impl SizeHint for BufReader { From 7e56637c749c4427ce0456022ea84e8393e5b0f7 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 19:29:49 -0500 Subject: [PATCH 08/21] Add back lower_bound as memeber --- library/std/src/io/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 712e808a02474..018fe1c52bfb9 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2481,6 +2481,8 @@ impl Iterator for Bytes { #[stable(feature = "bufreader_size_hint", since = "1.51.0")] trait SizeHint { + fn lower_bound(&self) -> usize { + fn upper_bound(&self) -> Option { None } From 442de9ac4531cc31955b62fbbebf80d2b99b4bb0 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 19:43:52 -0500 Subject: [PATCH 09/21] Fix semicolon --- library/std/src/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 018fe1c52bfb9..e9c99e5a62738 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2481,7 +2481,7 @@ impl Iterator for Bytes { #[stable(feature = "bufreader_size_hint", since = "1.51.0")] trait SizeHint { - fn lower_bound(&self) -> usize { + fn lower_bound(&self) -> usize; fn upper_bound(&self) -> Option { None From 1190321b7633369ec9e678d2fe4ac986b8157cc1 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:02:55 -0500 Subject: [PATCH 10/21] Remove exposing private trait --- library/std/src/io/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index e9c99e5a62738..a05adedaed2d6 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2459,7 +2459,7 @@ pub struct Bytes { } #[stable(feature = "rust1", since = "1.0.0")] -impl Iterator for Bytes { +impl Iterator for Bytes { type Item = Result; fn next(&mut self) -> Option> { @@ -2475,7 +2475,7 @@ impl Iterator for Bytes { } default fn size_hint(&self) -> (usize, Option) { - self.inner.size_hint() + (&self.inner as &SizeHint).size_hint() } } From 421b40cd6a72f039b319f8da6b80c67c385e9965 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:09:43 -0500 Subject: [PATCH 11/21] Add dyn for SizeHint cast --- library/std/src/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index a05adedaed2d6..e81bfd27a9ad1 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2475,7 +2475,7 @@ impl Iterator for Bytes { } default fn size_hint(&self) -> (usize, Option) { - (&self.inner as &SizeHint).size_hint() + (&self.inner as &dyn SizeHint).size_hint() } } From 265db94dc29b4e089e134795eac24b1b0a2faab1 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:25:32 -0500 Subject: [PATCH 12/21] Fix formatting --- library/std/src/io/mod.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index e81bfd27a9ad1..766da2ed6264f 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2216,11 +2216,7 @@ impl Read for Chain { unsafe fn initializer(&self) -> Initializer { let initializer = self.first.initializer(); - if initializer.should_initialize() { - initializer - } else { - self.second.initializer() - } + if initializer.should_initialize() { initializer } else { self.second.initializer() } } } @@ -2239,11 +2235,7 @@ impl BufRead for Chain { } fn consume(&mut self, amt: usize) { - if !self.done_first { - self.first.consume(amt) - } else { - self.second.consume(amt) - } + if !self.done_first { self.first.consume(amt) } else { self.second.consume(amt) } } } From 93870c8d5ff5750db2e138f35f783078e8ad8dd0 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:40:10 -0500 Subject: [PATCH 13/21] Remove stable annotation --- library/std/src/io/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 766da2ed6264f..754e22f228821 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2471,7 +2471,6 @@ impl Iterator for Bytes { } } -#[stable(feature = "bufreader_size_hint", since = "1.51.0")] trait SizeHint { fn lower_bound(&self) -> usize; @@ -2484,14 +2483,12 @@ trait SizeHint { } } -#[stable(feature = "bufreader_size_hint", since = "1.51.0")] impl SizeHint for T { default fn lower_bound(&self) -> usize { 0 } } -#[stable(feature = "bufreader_size_hint", since = "1.51.0")] impl SizeHint for BufReader { fn lower_bound(&self) -> usize { self.buffer().len() From 7869371bf1e6ab88bb61771c5dca217cc92ba0c9 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:45:43 -0500 Subject: [PATCH 14/21] Remove unnecessary default keyword --- library/std/src/io/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 754e22f228821..d7fd811cdb64b 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2466,7 +2466,7 @@ impl Iterator for Bytes { } } - default fn size_hint(&self) -> (usize, Option) { + fn size_hint(&self) -> (usize, Option) { (&self.inner as &dyn SizeHint).size_hint() } } @@ -2474,9 +2474,7 @@ impl Iterator for Bytes { trait SizeHint { fn lower_bound(&self) -> usize; - fn upper_bound(&self) -> Option { - None - } + fn upper_bound(&self) -> Option; fn size_hint(&self) -> (usize, Option) { (self.lower_bound(), self.upper_bound()) @@ -2487,6 +2485,10 @@ impl SizeHint for T { default fn lower_bound(&self) -> usize { 0 } + + default fn upper_bound(&self) -> Option { + None + } } impl SizeHint for BufReader { From c8e0f8aaa3e8a21158b596814d8a53cfe604a294 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 10:42:52 -0500 Subject: [PATCH 15/21] Use fully qualified syntax to avoid dyn --- library/std/src/io/mod.rs | 2 +- library/std/src/io/tests.rs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index d7fd811cdb64b..3839f7cd28d17 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2467,7 +2467,7 @@ impl Iterator for Bytes { } fn size_hint(&self) -> (usize, Option) { - (&self.inner as &dyn SizeHint).size_hint() + SizeHint::size_hint(&self.inner) } } diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs index f176c2f088cb3..03ed8ba74c520 100644 --- a/library/std/src/io/tests.rs +++ b/library/std/src/io/tests.rs @@ -1,7 +1,7 @@ use super::{repeat, Cursor, SeekFrom}; use crate::cmp::{self, min}; use crate::io::{self, IoSlice, IoSliceMut}; -use crate::io::{BufRead, Read, Seek, Write}; +use crate::io::{BufRead, BufReader, Read, Seek, Write}; use crate::ops::Deref; #[test] @@ -198,6 +198,26 @@ fn chain_bufread() { cmp_bufread(chain1, chain2, &testdata[..]); } +#[test] +fn bufreader_size_hint() { + let testdata = b"ABCDEFGHIJKL"; + let mut buf_reader = BufReader::new(&testdata[..]); + assert_eq!(buf_reader.buffer().len(), 0); + + let buffer = buf_reader.fill_buf().unwrap(); + let buffer_length = buffer.len(); + + // Check that size hint matches buffer contents + let mut buffered_bytes = buf_reader.bytes(); + let (lower_bound, _upper_bound) = buffered_bytes.size_hint(); + assert_eq!(lower_bound, buffer_length); + + // Check that size hint matches buffer contents after advancing + buffered_bytes.next().unwrap().unwrap(); + let (lower_bound, _upper_bound) = buffered_bytes.size_hint(); + assert_eq!(lower_bound, buffer_length - 1); +} + #[test] fn chain_zero_length_read_is_not_eof() { let a = b"A"; From 96255f82c9209fc2366ef32937c2bb53817687c1 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 15:03:58 -0500 Subject: [PATCH 16/21] Implement SizeHint trait for BufReader, Emtpy, and Chain --- library/std/src/io/buffered/bufreader.rs | 9 ++++++++- library/std/src/io/mod.rs | 20 ++++++++++++++------ library/std/src/io/util.rs | 8 +++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/library/std/src/io/buffered/bufreader.rs b/library/std/src/io/buffered/bufreader.rs index 987371f50ec22..e737a104014f4 100644 --- a/library/std/src/io/buffered/bufreader.rs +++ b/library/std/src/io/buffered/bufreader.rs @@ -1,6 +1,6 @@ use crate::cmp; use crate::fmt; -use crate::io::{self, BufRead, Initializer, IoSliceMut, Read, Seek, SeekFrom, DEFAULT_BUF_SIZE}; +use crate::io::{self, BufRead, Initializer, IoSliceMut, Read, Seek, SeekFrom, SizeHint, DEFAULT_BUF_SIZE}; /// The `BufReader` struct adds buffering to any reader. /// @@ -435,3 +435,10 @@ impl Seek for BufReader { }) } } + +impl SizeHint for BufReader { + fn lower_bound(&self) -> usize { + self.buffer().len() + } +} + diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 3839f7cd28d17..08b258bb816ec 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2239,6 +2239,20 @@ impl BufRead for Chain { } } +impl SizeHint for Chain { + fn lower_bound(&self) -> usize { + SizeHint::lower_bound(&self.first) + SizeHint::lower_bound(&self.second) + } + + fn upper_bound(&self) -> Option { + match (SizeHint::upper_bound(&self.first), SizeHint::upper_bound(&self.second)) { + (Some(first), Some(second)) => Some(first + second), + _ => None, + } + } +} + + /// Reader adaptor which limits the bytes read from an underlying reader. /// /// This struct is generally created by calling [`take`] on a reader. @@ -2491,12 +2505,6 @@ impl SizeHint for T { } } -impl SizeHint for BufReader { - fn lower_bound(&self) -> usize { - self.buffer().len() - } -} - /// An iterator over the contents of an instance of `BufRead` split on a /// particular byte. /// diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index e43ce4cdb4b8e..7de37c67abebc 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -4,7 +4,7 @@ mod tests; use crate::fmt; -use crate::io::{self, BufRead, Initializer, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write}; +use crate::io::{self, BufRead, Initializer, IoSlice, IoSliceMut, Read, Seek, SeekFrom, SizeHint, Write}; /// A reader which is always at EOF. /// @@ -80,6 +80,12 @@ impl fmt::Debug for Empty { } } +impl SizeHint for Empty { + fn upper_bound(&self) -> Option { + Some(0) + } +} + /// A reader which yields one byte over and over and over and over and over and... /// /// This struct is generally created by calling [`repeat()`]. Please From 389e638c054434c4b9df9427dab29b0f325923ac Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 15:04:26 -0500 Subject: [PATCH 17/21] Add tests for SizeHint implementations --- library/std/src/io/tests.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs index 03ed8ba74c520..a85dd0d982715 100644 --- a/library/std/src/io/tests.rs +++ b/library/std/src/io/tests.rs @@ -204,8 +204,8 @@ fn bufreader_size_hint() { let mut buf_reader = BufReader::new(&testdata[..]); assert_eq!(buf_reader.buffer().len(), 0); - let buffer = buf_reader.fill_buf().unwrap(); - let buffer_length = buffer.len(); + let buffer_length = testdata.len(); + buf_reader.fill_buf().unwrap(); // Check that size hint matches buffer contents let mut buffered_bytes = buf_reader.bytes(); @@ -218,6 +218,33 @@ fn bufreader_size_hint() { assert_eq!(lower_bound, buffer_length - 1); } +#[test] +fn empty_size_hint() { + let size_hint = io::empty().bytes().size_hint(); + assert_eq!(size_hint, (0, Some(0))); +} + +#[test] +fn chain_empty_size_hint() { + let chain = io::empty().chain(io::empty()); + let size_hint = chain.bytes().size_hint(); + assert_eq!(size_hint, (0, Some(0))); +} + +#[test] +fn chain_size_hint() { + let testdata = b"ABCDEFGHIJKL"; + let mut buf_reader_1 = BufReader::new(&testdata[..6]); + let mut buf_reader_2 = BufReader::new(&testdata[6..]); + + buf_reader_1.fill_buf().unwrap(); + buf_reader_2.fill_buf().unwrap(); + + let chain = buf_reader_1.chain(buf_reader_2); + let size_hint = chain.bytes().size_hint(); + assert_eq!(size_hint, (testdata.len(), None)); +} + #[test] fn chain_zero_length_read_is_not_eof() { let a = b"A"; From b837f3a99b8dc767c4a6a3216ad3940f23896932 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 15:20:40 -0500 Subject: [PATCH 18/21] Remove trailing newline --- library/std/src/io/buffered/bufreader.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/buffered/bufreader.rs b/library/std/src/io/buffered/bufreader.rs index e737a104014f4..839c64ee5c443 100644 --- a/library/std/src/io/buffered/bufreader.rs +++ b/library/std/src/io/buffered/bufreader.rs @@ -1,6 +1,8 @@ use crate::cmp; use crate::fmt; -use crate::io::{self, BufRead, Initializer, IoSliceMut, Read, Seek, SeekFrom, SizeHint, DEFAULT_BUF_SIZE}; +use crate::io::{ + self, BufRead, Initializer, IoSliceMut, Read, Seek, SeekFrom, SizeHint, DEFAULT_BUF_SIZE, +}; /// The `BufReader` struct adds buffering to any reader. /// @@ -441,4 +443,3 @@ impl SizeHint for BufReader { self.buffer().len() } } - From 81aba388f16502cbb7b305d64de9ccc95057b339 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 15:36:59 -0500 Subject: [PATCH 19/21] Add space for proper indentation --- library/std/src/io/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index 7de37c67abebc..e5e5f29b22d09 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -82,7 +82,7 @@ impl fmt::Debug for Empty { impl SizeHint for Empty { fn upper_bound(&self) -> Option { - Some(0) + Some(0) } } From fc9cd4a14be3ea1d5ee29b495045fa51edfc0810 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 17:48:22 -0500 Subject: [PATCH 20/21] Fix formatting on mod --- library/std/src/io/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 08b258bb816ec..b7ccf9f21efb0 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2244,7 +2244,7 @@ impl SizeHint for Chain { SizeHint::lower_bound(&self.first) + SizeHint::lower_bound(&self.second) } - fn upper_bound(&self) -> Option { + fn upper_bound(&self) -> Option { match (SizeHint::upper_bound(&self.first), SizeHint::upper_bound(&self.second)) { (Some(first), Some(second)) => Some(first + second), _ => None, @@ -2252,7 +2252,6 @@ impl SizeHint for Chain { } } - /// Reader adaptor which limits the bytes read from an underlying reader. /// /// This struct is generally created by calling [`take`] on a reader. From 7674ae1a4e10ab6bafbda57f9fc2175fdf012f5e Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sun, 31 Jan 2021 08:52:57 -0500 Subject: [PATCH 21/21] Fix line length format --- library/std/src/io/util.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index e5e5f29b22d09..f472361f916db 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -4,7 +4,9 @@ mod tests; use crate::fmt; -use crate::io::{self, BufRead, Initializer, IoSlice, IoSliceMut, Read, Seek, SeekFrom, SizeHint, Write}; +use crate::io::{ + self, BufRead, Initializer, IoSlice, IoSliceMut, Read, Seek, SeekFrom, SizeHint, Write, +}; /// A reader which is always at EOF. ///