Skip to content

Commit d53f82c

Browse files
committed
alloc: Forward ExactSizeIterator methods in Iterator for Box<I>
1 parent 705e295 commit d53f82c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/liballoc/boxed.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,14 @@ impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> {
532532
}
533533
}
534534
#[stable(feature = "rust1", since = "1.0.0")]
535-
impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {}
535+
impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {
536+
fn len(&self) -> usize {
537+
(**self).len()
538+
}
539+
fn is_empty(&self) -> bool {
540+
(**self).is_empty()
541+
}
542+
}
536543

537544
#[unstable(feature = "fused", issue = "35602")]
538545
impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
#![feature(core_intrinsics)]
8080
#![feature(custom_attribute)]
8181
#![feature(dropck_parametricity)]
82+
#![cfg_attr(not(test), feature(exact_size_is_empty))]
8283
#![feature(fundamental)]
8384
#![feature(lang_items)]
8485
#![feature(needs_allocator)]

0 commit comments

Comments
 (0)