| Crates.io | rand06-compat |
| lib.rs | rand06-compat |
| version | 0.1.0 |
| created_at | 2025-03-17 20:11:31.616514+00 |
| updated_at | 2025-03-17 20:11:31.616514+00 |
| description | Compatibility wrapper between `rand_core` 0.6 and 0.9 |
| homepage | |
| repository | https://github.com/tlsnotary/tlsn-utils |
| max_upload_size | |
| id | 1595876 |
| size | 24,548 |
This crate provides a compatibility wrapper between versions 0.6 and 0.9 of rand_core.
no_std ⚠️Supporting fallible RNGs is tricky to do in a clean manner. This compat wrapper hardcodes an error code of 1 in the case that the RNG fails.
PRs welcome for a better solution.
use rand_core_06::RngCore as RngCore06;
use rand_core::OsRng;
use rand06_compat::Rand0_6CompatExt;
// This function requires an RNG implementing the `0.6` trait.
fn foo<R>(rng: &mut R) where R: RngCore06 {
let num: u32 = rng.next_u32();
println!("random number: {}", num);
}
// Pass in the RNG from `0.9` using compat trait.
foo(&mut OsRng.compat())