Skip to content

fix: import rand::RngExt so pick compiles after rand 0.10 bump#223

Open
andrew-tawfeek wants to merge 1 commit into
clearloop:mainfrom
andrew-tawfeek:fix/rand-rngext-import
Open

fix: import rand::RngExt so pick compiles after rand 0.10 bump#223
andrew-tawfeek wants to merge 1 commit into
clearloop:mainfrom
andrew-tawfeek:fix/rand-rngext-import

Conversation

@andrew-tawfeek
Copy link
Copy Markdown

@andrew-tawfeek andrew-tawfeek commented Jun 2, 2026

main currently fails to compile. The rand 0.10 upgrade in #220 moved random_range off the Rng trait and into the new RngExt trait, but src/cmd/pick.rs still imports rand::Rng:

error[E0599]: no method named `random_range` found for struct `ThreadRng` in the current scope
   --> src/cmd/pick.rs:89:53
    |
 89 |     let problem = &problems[rand::rng().random_range(0..problems.len())];
    |                                         ^^^^^^^^^^^^
    |
help: trait `RngExt` which provides `random_range` is implemented but not in scope; perhaps you want to import it
    |
  2 + use rand::RngExt;

cargo build --release fails on a clean checkout of main.

This is fixed by importing rand::RngExt instead of rand::Rng in the pick handler — that's the trait now providing random_range in rand 0.10. It's verified by checking cargo build --release succeeds, and leetcode pick (random pick) works as before.

The rand 0.10 bump (clearloop#220) moved `random_range` off the `Rng` trait into
the new `RngExt` trait, so `src/cmd/pick.rs` no longer compiles on `main`:

    error[E0599]: no method named `random_range` found for struct `ThreadRng`
    help: trait `RngExt` which provides `random_range` is implemented but
          not in scope; perhaps you want to import it

Import `RngExt` instead of `Rng` in the `pick` handler.
@andrew-tawfeek andrew-tawfeek force-pushed the fix/rand-rngext-import branch from 2865f09 to 109730f Compare June 2, 2026 05:31
@andrew-tawfeek andrew-tawfeek marked this pull request as ready for review June 2, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant