4 ms·
The two maps with PartialOrd are https://doc.rust-lang.org/collections/struct.BTreeMap.html https://doc.rust-lang.org/collections/struct.BTreeMap.html https:/
by Veedrac 11y ago
The 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.