-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fate of the Rand
trait
#83
Comments
I'd call it |
If we remove I was wondering about
|
Thinking about trait names, Distribution mostly makes sense for floats, and with a stretch for all primitive types. But the name does not feel to me like it fits all sorts of structs. |
Can we say Personally I like option 3 best. With the exception of naming. But I am just thinking out loud... If we end up removing Is a deprecation period something we really need? It is not like crates are forced to update. Or are types and traits from A quick look on github: https://github.com/search?p=1&q=%22impl+Rand+for%22&type=Code&utf8=%E2%9C%93. Many, many are just old copies of |
Personally I like the name
Finally, a suggestion I like! |
Of course In general, there is an issue with not all distributions making sense for all data types, which messes up some deriving I fear. I think In this vein, we cannot turn a
Instead, we need an obnoxious
|
All this to allow the following? let x = rng.sample(Uniform<u32, RangeFull>); This should extend to something like I'm not convinced it's worth it though, because
(Of course one can have things like log-normal with restricted range, but that is effectively two different distributions, with a choice of clamping values down to the restricted range or re-sampling.) If the distribution (e.g. |
I see. If
I take it you'll have a symmetric method for
|
Rust doesn't support default parameters so we have Yes, it requires a symmetric |
Oh, why do you keep adding Yes, this is why |
Yes, I strongly dislike this push for senseless crate separation: An extension trait is a clear harm. Separate docs are a clear harm. What value does a separate crate bring? |
After having had a look at quickcheck's The example mentioned above derive's I ask because I'm very tempted to mark I guess rust-random#148 is related. |
Sounds good to me! I think |
See #83 Required for following changes affecting Rand
Also 👍 from me. I think we can see quickcheck's s |
@dhardy Apologies, I'm only just now seeing your ping. I'm afraid I don't really have enough context to understand the question you're asking me. Can you briefly summarize what input you need from me? |
Nobody is forced to update, and even when |
@BurntSushi That's partly besides the point; I just discovered that |
@dhardy I don't think I've ever used |
Rand has been deprecated and Uniform implemented: rust-random#256 |
For a while now, I've been planning to replace
Rand
with some distribution (Default
in this branch) for most purposes. The two are roughly equivalent; e.g. the one-tuple(T,)
implementation boils down to:Why, you ask?
Distribution
trait, giving more uniform usage (rng.sample(Default)
orrng.sample(Range::new(2, 11))
) and making generic code easierRand::rand
does not support dynamic dispatch due to implicitSized
constraint; fixing this would break allRand
implementations, so we have no reason not to introduce a replacementBut, then, what about people using code like
let v: (u32, u64) = Rand::rand(rng)
?This is what this issue is about; we could:
Rand
completely, forcing users to update (not that hard in many cases;rng.gen()
will still work)Rand
), but leaves duplicate functionalityIs the last option the best?
There is also
rand_derive
; we can probably introduce an alternative based onDistribution
, but I don't know if we should? Apparentlyrand_derive
has no dependent crates.The text was updated successfully, but these errors were encountered: