4 ms·
Do you deal with documentation on parts that have been moved out of std, too? Some of the hardest parts of the documentation is the functionality hidden behind
by Veedrac 11y ago
Do you deal with documentation on parts that have been moved out of std, too?
Some of the hardest parts of the documentation is the functionality hidden behind `impl SomeTrait for SomeStruct`. Eg. `impl PartialOrd for BTreeMap`. What on earth does that do? Or the fact you're meant to make a randomly seeded `ChaChaRng` with `OsRng::new().unwrap().gen()`, which is genius but impossible to guess.
- steveklabnik 11y agoIn theory, yes, but I spend most of my time on what's most important, which is the stuff in-tree. I've even been neglecting Cargo, which could use a reorganizaiton at least. Those implementations should absolutely be in the generated documentation, can you maybe point me to some specific pages? Thanks :)
- Veedrac 11y agoThe two maps with PartialOrd are https://doc.rust-lang.org/collections/struct.BTreeMap.html https://doc.rust-lang.org/collections/struct.BTreeMap.html https://doc.rust-lang.org/collections/vec_map/struct.VecMap.html https://doc.rust-lang.org/collections/vec_map/struct.VecMap.... ChaChaRng is http://doc.rust-lang.org/rand/rand/chacha/struct.ChaChaRng.html http://doc.rust-lang.org/rand/rand/chacha/struct.ChaChaRng.h... although the other implementations also need this. The main page for rand should probably have this somewhere on it, too. Thanks for helping :).
- steveklabnik 11y agoThanks. So, I'm not sure what _specifically_ the issue is here with PartialOrd. It has 'impl<K: PartialOrd, V: PartialOrd> PartialOrd for BTreeMap<K, V>', and if you click on PartialOrd, you go to https://doc.rust-lang.org/core/cmp/trait.PartialOrd.html https://doc.rust-lang.org/core/cmp/trait.PartialOrd.html, which has an explanation of what it does. Am I missing something? ChaChaRng _does_ mention OsRng, but a code sample might help, for sure.
- Veedrac 11y ago> I'm not sure what _specifically_ the issue is here with PartialOrd. I know what a partial order is, I just don't know what partial order maps realize. In Python they aren't orderable. > ChaChaRng _does_ mention OsRng It says to use OsRng if cryptographic security is needed, not how to seed with it. The obvious way is something like let osrng = OsRng::new().unwrap(); let mut key = [0u32; 8]; for word in key.iter_mut() { *word = osrng.gen(); } let prng = ChaChaRng::from_seed(&key[..]) which is a pain.
- steveklabnik 11y agoRoger, I see what you're saying, on both counts. Thank you for taking the time to spell it out to me.
- dbaupp 11y agoMaps can be compared lexicographically. BTreeMap and VecMap have a canonical order in which they store their elements so iter::order::cmp(self.iter(), other.iter()) works as an ordering. HashMap in Rust (dict in Python) doesn't have a canonical ordering of elements, so this doesn't make sense.