auto: rand::Rand: a trait implemented by types that can be randomly generated#4801
Closed
z0w0 wants to merge 1 commit intorust-lang:incomingfrom
z0w0:randomtrait
Closed
auto: rand::Rand: a trait implemented by types that can be randomly generated#4801z0w0 wants to merge 1 commit intorust-lang:incomingfrom z0w0:randomtrait
z0w0 wants to merge 1 commit intorust-lang:incomingfrom
z0w0:randomtrait
Conversation
randomly generated Also adds Rng::gen() for generating any type that implements the Rand trait
Contributor
|
Awesome. I was literally writing this trait up yesterday! Glad you beat me to it. |
Contributor
|
(Future reference: non-uniform sampling is important and gets very ... subtle, and very interesting, when dealing with more complex structures. See: http://algo.inria.fr/flajolet/Publications/DuFlLoSc04.pdf for examples) |
bors
added a commit
that referenced
this pull request
Feb 5, 2013
Also adds Rng::gen() for generically generating any type that implements the Rand trait. There's no way to generate things with a length (for e.g. strings or vectors), because I can't think of an elegant way to do that. Maybe have a RandLen trait that inherits Rand? This can be used for a quickcheck mechanism I'm working on.
bors
added a commit
that referenced
this pull request
Feb 7, 2013
Also adds Rng::gen() for generically generating any type that implements the Rand trait. There's no way to generate things with a length (for e.g. strings or vectors), because I can't think of an elegant way to do that. Maybe have a RandLen trait that inherits Rand? This can be used for a quickcheck mechanism I'm working on.
RalfJung
pushed a commit
to RalfJung/rust
that referenced
this pull request
Jan 4, 2026
Automatic Rustup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also adds Rng::gen() for generically generating any type that implements the Rand trait. There's no way to generate things with a length (for e.g. strings or vectors), because I can't think of an elegant way to do that. Maybe have a RandLen trait that inherits Rand?
This can be used for a quickcheck mechanism I'm working on.