bitart: Use choose also for random color

This commit is contained in:
Juergen Stuber
2026-03-18 19:55:15 +01:00
parent 18025b76a5
commit 70aff62912

View File

@@ -28,15 +28,15 @@ fn random_color<R: Rng>(rng: &mut R) -> Color {
let b = rng.random::<u8>(); let b = rng.random::<u8>();
let c = 0; let c = 0;
let (r, g, b) = match rng.random_range(0..6) { let permutations = [
0 => (a, b, c), (a, b, c),
1 => (a, c, b), (a, c, b),
2 => (b, a, c), (b, a, c),
3 => (b, c, a), (b, c, a),
4 => (c, a, b), (c, a, b),
5 => (c, b, a), (c, b, a),
_ => unreachable!(), ];
}; let &(r, g, b) = permutations.choose(rng).unwrap();
Color::new(r, g, b) Color::new(r, g, b)
} }