This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 604 B View raw
1use crate::Color; 2use rand::{ 3 Rng, 4 distr::{Distribution, StandardUniform}, 5}; 6 7impl Distribution<Color> for StandardUniform { 8 fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Color { 9 let candidates = Color::all(); 10 candidates[rng.random_range(0..candidates.len())] 11 } 12} 13 14impl Color { 15 pub fn random_except(rng: &mut impl Rng, except: Color) -> Self { 16 let candidates = Color::all() 17 .iter() 18 .filter(|&&c| c != except) 19 .cloned() 20 .collect::<Vec<_>>(); 21 candidates[rng.random_range(0..candidates.len())] 22 } 23}