From d53f82c1d037bf224a72a11747e7788f14b52db5 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Sat, 3 Dec 2016 21:42:03 +0100 Subject: [PATCH] alloc: Forward ExactSizeIterator methods in Iterator for Box --- src/liballoc/boxed.rs | 9 ++++++++- src/liballoc/lib.rs | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 28f4dda1408..6d7a9b1d1f9 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -532,7 +532,14 @@ impl DoubleEndedIterator for Box { } } #[stable(feature = "rust1", since = "1.0.0")] -impl ExactSizeIterator for Box {} +impl ExactSizeIterator for Box { + fn len(&self) -> usize { + (**self).len() + } + fn is_empty(&self) -> bool { + (**self).is_empty() + } +} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for Box {} diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 0d450184ed8..acce4ce0358 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -79,6 +79,7 @@ #![feature(core_intrinsics)] #![feature(custom_attribute)] #![feature(dropck_parametricity)] +#![cfg_attr(not(test), feature(exact_size_is_empty))] #![feature(fundamental)] #![feature(lang_items)] #![feature(needs_allocator)]