version: Use fastrand v2.0.0

This commit is contained in:
John Nunley 2023-07-03 07:59:34 -07:00 committed by GitHub
parent 4a1e18daf9
commit abb7a4e9ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -39,7 +39,7 @@ wayland-sys = "0.30.0"
x11rb = { version = "0.12.0", features = ["allow-unsafe-code", "shm"], optional = true }
[target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox", target_os = "linux", target_os = "freebsd"))))'.dependencies]
fastrand = { version = "1.8.0", optional = true }
fastrand = { version = "2.0.0", optional = true }
[target.'cfg(target_os = "windows")'.dependencies.windows-sys]
version = "0.48.0"

View file

@ -49,9 +49,12 @@ fn create_memfile() -> File {
};
use std::iter;
// Use a cached RNG to avoid hammering the thread local.
let mut rng = fastrand::Rng::new();
for _ in 0..=4 {
let mut name = String::from("softbuffer-");
name.extend(iter::repeat_with(fastrand::alphanumeric).take(7));
name.extend(iter::repeat_with(|| rng.alphanumeric()).take(7));
name.push('\0');
let name = unsafe { CStr::from_bytes_with_nul_unchecked(name.as_bytes()) };