fix: upgrade everywhere to rand 0.9

This commit is contained in:
nobody 2025-12-12 21:34:06 -08:00
commit 8911e582d8
Signed by: GrocerPublishAgent
GPG key ID: D460CD54A9E3AB86
10 changed files with 65 additions and 97 deletions

View file

@ -26,9 +26,9 @@ impl RecordingRng {
}
impl LseqRng for RecordingRng {
fn gen_bool(&mut self, p: f64) -> bool {
fn random_bool(&mut self, p: f64) -> bool {
// Use fully qualified syntax to call rand::Rng method
let result = Rng::gen_bool(&mut self.inner, p);
let result = Rng::random_bool(&mut self.inner, p);
// Record a float that TypeScript's `f < p` would produce the same result
// If result is true, we need f < p, so use p/2
// If result is false, we need f >= p, so use (1 + p) / 2
@ -37,9 +37,9 @@ impl LseqRng for RecordingRng {
result
}
fn gen_range(&mut self, range: std::ops::Range<u64>) -> u64 {
fn random_range(&mut self, range: std::ops::Range<u64>) -> u64 {
// Use fully qualified syntax to call rand::Rng method
let result: u64 = Rng::gen_range(&mut self.inner, range.clone());
let result: u64 = Rng::random_range(&mut self.inner, range.clone());
// Record a float that TypeScript's `Math.floor(f * range_size)` would produce the same result
// For result r in [0, range_size), we need floor(f * range_size) = r
// So f should be in [r/range_size, (r+1)/range_size)
@ -137,7 +137,7 @@ fn main() {
let idx = if state.is_empty() {
0
} else {
Rng::gen_range(&mut position_rng, 0..=state.len())
Rng::random_range(&mut position_rng, 0..=state.len())
};
// Derive beforeKey and afterKey from the insertion index