Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/xtask/src/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,11 @@ fn verify_ssh_connectivity(sh: &Shell, port: u16, key_path: &Utf8Path) -> Result

/// Generate a random alphanumeric suffix for VM names
fn generate_random_suffix() -> String {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz0123456789";
(0..8)
.map(|_| {
let idx = rng.gen_range(0..CHARSET.len());
let idx = rng.random_range(0..CHARSET.len());
CHARSET[idx] as char
})
.collect()
Comment on lines +494 to 501
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this is a correct fix for the deprecation warning, this implementation can be made more idiomatic and concise by using SliceRandom::choose to pick a random character directly from the CHARSET.

Here's how you could refactor the function body:

const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz0123456789";
(0..8)
    .map(|_| *CHARSET.choose(&mut rand::rng()).unwrap() as char)
    .collect()

This would require adding use rand::seq::SliceRandom; at the top of the file. Since this change is outside the diff, I'm providing this as a suggestion for you to consider.

Expand Down