From b6730e95f9a823f8cb8982d09ebb1fd9bae0913c Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 14:20:51 -0500 Subject: [PATCH 01/20] 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 3f5b7c0b29be6..0d8cb31cbbf78 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2213,7 +2213,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() + } } } @@ -2232,7 +2236,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) + } } } @@ -2462,6 +2470,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 1a97be6f95669b709db61e65ec772ee57456d79b Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 14:43:20 -0500 Subject: [PATCH 02/20] 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 0d8cb31cbbf78..a16e764b7832f 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2477,7 +2477,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 6d90d994a9ed7e1c354998cc16bb3a74b389f693 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 17:37:29 -0500 Subject: [PATCH 03/20] 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 a16e764b7832f..fb846855694ba 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2456,7 +2456,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> { @@ -2472,14 +2472,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 edcd2ba522a02b27d416186f927b6572f52971a9 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 17:41:42 -0500 Subject: [PATCH 04/20] 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 fb846855694ba..77a2e713b84a8 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2490,7 +2490,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 33586747a1f90b0f080e319c8b42972ee5d458bd Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 17:47:25 -0500 Subject: [PATCH 05/20] 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 77a2e713b84a8..d642137708060 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2478,7 +2478,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 @@ -2490,11 +2492,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 f28dd81f5e171ad005e96bde92692b5d539523ab Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 17:52:55 -0500 Subject: [PATCH 06/20] 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 d642137708060..16cd45671e449 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2492,7 +2492,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 5c427c05eb50ea5cc64825265165bee319ee4c91 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 18:45:00 -0500 Subject: [PATCH 07/20] 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 16cd45671e449..9a8e61c2158d9 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2478,10 +2478,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 } @@ -2492,7 +2488,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 d4704c74b69ff0d58bc21369777ffcb0bc187bdb Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 19:29:49 -0500 Subject: [PATCH 08/20] 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 9a8e61c2158d9..1819b70dcb451 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2478,6 +2478,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 3ad20e5cfcf2f03f021a8cad33509fd10b1ef27f Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 19:43:52 -0500 Subject: [PATCH 09/20] 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 1819b70dcb451..3f4134b690cfa 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2478,7 +2478,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 284f4bbce4e74ae05d296078c654e12b5d8818c1 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:02:55 -0500 Subject: [PATCH 10/20] 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 3f4134b690cfa..6f82f3afa585f 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2456,7 +2456,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> { @@ -2472,7 +2472,7 @@ impl Iterator for Bytes { } default fn size_hint(&self) -> (usize, Option) { - self.inner.size_hint() + (&self.inner as &SizeHint).size_hint() } } From af4be91920fb50226e18fb4f605514ecc76cb2f7 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:09:43 -0500 Subject: [PATCH 11/20] 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 6f82f3afa585f..46dd6a358f801 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2472,7 +2472,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 5881fc97030faa3f92c541223bcb5ab7cbb8202b Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:25:32 -0500 Subject: [PATCH 12/20] 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 46dd6a358f801..c2a7baa5eceec 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2213,11 +2213,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() } } } @@ -2236,11 +2232,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 6c8f0a6f0eb54a70aeaab8a2b07e1dc09f726c63 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:40:10 -0500 Subject: [PATCH 13/20] 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 c2a7baa5eceec..397841c3cc1ed 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2468,7 +2468,6 @@ impl Iterator for Bytes { } } -#[stable(feature = "bufreader_size_hint", since = "1.51.0")] trait SizeHint { fn lower_bound(&self) -> usize; @@ -2481,14 +2480,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 8321b9a6bd805d5724a63015679c8ea83a6cf8dd Mon Sep 17 00:00:00 2001 From: Xavientois Date: Fri, 15 Jan 2021 20:45:43 -0500 Subject: [PATCH 14/20] 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 397841c3cc1ed..619372bfb5c8c 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2463,7 +2463,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() } } @@ -2471,9 +2471,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()) @@ -2484,6 +2482,10 @@ impl SizeHint for T { default fn lower_bound(&self) -> usize { 0 } + + default fn upper_bound(&self) -> Option { + None + } } impl SizeHint for BufReader { From 6040a527432c9bfa8e76e3b0a2e1a388c7ee1cd5 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 10:42:52 -0500 Subject: [PATCH 15/20] 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 619372bfb5c8c..6281e92b2c556 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2464,7 +2464,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 2c683ffdad6cdd74542f7d56b2976a8d4efe9825 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 15:03:58 -0500 Subject: [PATCH 16/20] 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 16c18d6e14645..32ecebefc8ad7 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. /// @@ -422,3 +422,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 6281e92b2c556..54a696251d1b1 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2236,6 +2236,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. @@ -2488,12 +2502,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 db845457c9672..f877a9d9d12fe 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, Write}; +use crate::io::{self, BufRead, Initializer, IoSlice, IoSliceMut, Read, SizeHint, Write}; /// A reader which is always at EOF. /// @@ -65,6 +65,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 a5447264e7b63abe6ce9553e39495543f3a91e9a Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 15:04:26 -0500 Subject: [PATCH 17/20] 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 b23feaa2684901ab24892f3eb2a6587039c3767c Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 15:20:40 -0500 Subject: [PATCH 18/20] 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 32ecebefc8ad7..ea7edf1ec39a3 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. /// @@ -428,4 +430,3 @@ impl SizeHint for BufReader { self.buffer().len() } } - From 88bc1d4d0752acedc6eb005218565dab6ad8193c Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 15:36:59 -0500 Subject: [PATCH 19/20] 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 f877a9d9d12fe..1e1baf438a2c0 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -67,7 +67,7 @@ impl fmt::Debug for Empty { impl SizeHint for Empty { fn upper_bound(&self) -> Option { - Some(0) + Some(0) } } From e948522aeb5fd20b0ff3b0672250df5d07e0e431 Mon Sep 17 00:00:00 2001 From: Xavientois Date: Sat, 16 Jan 2021 17:48:22 -0500 Subject: [PATCH 20/20] 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 54a696251d1b1..16e6691607c13 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2241,7 +2241,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, @@ -2249,7 +2249,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.