Skip to content

Commit

Permalink
Merge pull request #620 from dhardy/fused
Browse files Browse the repository at this point in the history
Implement TrustedLen and FusedIterator for DistIter
  • Loading branch information
dhardy committed Oct 3, 2018
2 parents 7aec8e2 + c5735dc commit fbd9ec3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/distributions/mod.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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<T>, R: Rng + 'a {}

#[cfg(features = "nightly")]
impl<'a, D, R, T> iter::TrustedLen for DistIter<'a, D, R, T>
where D: Distribution<T>, R: Rng + 'a {}


/// A generic random value distribution, implemented for many primitive types.
/// Usually generates values with a numerically uniform distribution, and with a
Expand Down

0 comments on commit fbd9ec3

Please sign in to comment.