From c5735dc2f4d51688a56b0e7c47daab6864d274c8 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 3 Oct 2018 09:10:04 +0100 Subject: [PATCH] Implement TrustedLen and FusedIterator for DistIter Fixes #618 --- src/distributions/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/distributions/mod.rs b/src/distributions/mod.rs index 03b85a3d8bc..160cd314f9c 100644 --- a/src/distributions/mod.rs +++ b/src/distributions/mod.rs @@ -182,6 +182,8 @@ //! [`Weibull`]: struct.Weibull.html //! [`WeightedIndex`]: struct.WeightedIndex.html +#[cfg(any(rust_1_26, features="nightly"))] +use core::iter; use Rng; pub use self::other::Alphanumeric; @@ -314,6 +316,14 @@ impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> } } +#[cfg(rust_1_26)] +impl<'a, D, R, T> iter::FusedIterator for DistIter<'a, D, R, T> + where D: Distribution, R: Rng + 'a {} + +#[cfg(features = "nightly")] +impl<'a, D, R, T> iter::TrustedLen for DistIter<'a, D, R, T> + where D: Distribution, R: Rng + 'a {} + /// A generic random value distribution, implemented for many primitive types. /// Usually generates values with a numerically uniform distribution, and with a