Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate gen_iter and add iteration examples #286

Merged
merged 1 commit into from
Mar 7, 2018

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented Mar 7, 2018

As discussed in #275, these changes are all that we need, I think.

I put this documentation on the Rng trait; I'm not quite sure if that's the best option. The library documentation at the top if lib.rs could also be revised, potentially.

@pitdicker
Copy link
Contributor

Looks good to me! A bit sad for the time you spent figuring out and testing alternatives...

Shall I try to merge?

@dhardy
Copy link
Member Author

dhardy commented Mar 7, 2018

Speaking of alternatives, there's still all your FP code in my experimental branch... have to figure out whether we'll use that at some point.

@burdges
Copy link
Contributor

burdges commented Mar 7, 2018

You could always add some convenience method in the future, so roughly like:

pub trait Rng: RngCore + Sized {
    ...
    fn samples_iter<T,D: Distribution<T>>(&mut self,dist: D) -> impl Iterator<item=T> {
        ::std::iter::repeat(()).map(|()| self.sample(&dist))
    }

I wrote &dist to avoid D: Copy or whatever. I'd imagine multiple reference layers get optimized into one reference, but not sure.

@pitdicker pitdicker merged commit f37e851 into rust-random:master Mar 7, 2018
@dhardy dhardy deleted the iter-doc branch March 14, 2018 16:39
pitdicker added a commit that referenced this pull request Apr 4, 2018
Deprecate gen_iter and add iteration examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants