diff options
| author | bors <bors@rust-lang.org> | 2016-12-07 07:15:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-12-07 07:15:31 +0000 |
| commit | 5938eba4e30b766751483e93776a87a4db1681f4 (patch) | |
| tree | 1e497c14aaafb3a0471925118e5efb62963eb66b /src/liballoc/boxed.rs | |
| parent | 02ea82ddb8315249067afb2f800d62b4ca1f7678 (diff) | |
| parent | d53f82c1d037bf224a72a11747e7788f14b52db5 (diff) | |
| download | rust-5938eba4e30b766751483e93776a87a4db1681f4.tar.gz rust-5938eba4e30b766751483e93776a87a4db1681f4.zip | |
Auto merge of #38149 - bluss:is-empty, r=alexcrichton
Forward more ExactSizeIterator methods and `is_empty` edits - Forward ExactSizeIterator methods in more places, like `&mut I` and `Box<I>` iterator impls. - Improve `VecDeque::is_empty` itself (see commit 4) - All the collections iterators now have `len` or `is_empty` forwarded if doing so is a benefit. In the remaining cases, they already use a simple size hint (using something like a stored `usize` value), which is sufficient for the default implementation of len and is_empty.
Diffstat (limited to 'src/liballoc/boxed.rs')
| -rw-r--r-- | src/liballoc/boxed.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index d10d7a5e58d..addb056f534 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -535,7 +535,14 @@ impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {} +impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> { + fn len(&self) -> usize { + (**self).len() + } + fn is_empty(&self) -> bool { + (**self).is_empty() + } +} #[unstable(feature = "fused", issue = "35602")] impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {} |
