rust-random / rand

A Rust library for random number generation.
https://crates.io/crates/rand
Other
1.68k stars 431 forks source link

Rename Rng -> RngExt, RngCore -> Rng #1288

Closed dhardy closed 1 year ago

dhardy commented 1 year ago

For review, as mentioned in #1273. Effects:

My opinion is now against this change:

Still, I'll leave it here in case anyone wishes to review the changes. (Note that a couple of simplifications could be made without the trait rename; e.g. replacing R: RngCore with R: Rng in some places.)

dhardy commented 1 year ago

R: Rng + Sized is exactly equivalent to R: RngCore + Sized (prior to this rename).

This is not the case when using virtual dispatch: dyn RngCore implies a vtable over methods next_u32, next_u64, fill_bytes, try_fill_bytes (intended usage). But dyn Rng implies a vtable over gen_bool, gen_ratio` (all other methods are generic and hence excluded).

So if we do not use this rename:

If we do use this rename:

dhardy commented 1 year ago

Does anyone have further thoughts on this, or shall we just reject it? (Primary rationale: it's a big breaking change for little gain.)

@vks @newpavlov @tarcieri and anyone else who wishes to comment (open discussion)

tarcieri commented 1 year ago

I think I'm happy with just #1273 which will allow us to migrate from CryptoRngCore -> CryptoRng everywhere