From e07f8ecfbd2d3494a9dc17ea05b8c256d81ea410 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 6 Feb 2019 14:35:29 +0000 Subject: [PATCH] Relax Sized bounds of sample_iter functions --- src/distributions/mod.rs | 4 ++-- src/lib.rs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/distributions/mod.rs b/src/distributions/mod.rs index 6e2d6c7bad2..cb85389607b 100644 --- a/src/distributions/mod.rs +++ b/src/distributions/mod.rs @@ -259,7 +259,7 @@ pub trait Distribution { /// } /// ``` fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> - where Self: Sized, R: Rng + where R: Rng + ?Sized { DistIter { distr: self, @@ -284,7 +284,7 @@ impl<'a, T, D: Distribution> Distribution for &'a D { /// /// [`sample_iter`]: Distribution::sample_iter #[derive(Debug)] -pub struct DistIter<'a, D: 'a, R: 'a, T> { +pub struct DistIter<'a, D: 'a + ?Sized, R: 'a + ?Sized, T> { distr: &'a D, rng: &'a mut R, phantom: ::core::marker::PhantomData, diff --git a/src/lib.rs b/src/lib.rs index 9c0482f328e..ed84573251c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -290,8 +290,9 @@ pub trait Rng: RngCore { /// println!("Not a 6; rolling again!"); /// } /// ``` - fn sample_iter<'a, T, D: Distribution>(&'a mut self, distr: &'a D) - -> distributions::DistIter<'a, D, Self, T> where Self: Sized + fn sample_iter<'a, T, D>(&'a mut self, distr: &'a D) + -> distributions::DistIter<'a, D, Self, T> + where D: Distribution + ?Sized { distr.sample_iter(self) }