Rename trait

This commit is contained in:
Nicolas 2022-04-13 19:41:59 +02:00
parent 3f8e27d313
commit b6a2ae85f4
2 changed files with 6 additions and 6 deletions

View File

@ -1,7 +1,7 @@
use rand::prelude::IteratorRandom; use rand::prelude::IteratorRandom;
use rand::Rng; use rand::Rng;
pub trait Options { pub trait Collection {
fn all() -> Vec<Self> where Self: Sized; fn all() -> Vec<Self> where Self: Sized;
} }
@ -14,7 +14,7 @@ impl<TRng: Rng> Chooser<TRng> {
Self { rng } Self { rng }
} }
pub fn choose<TValue: Options>(&mut self, selection: Vec<TValue>) -> TValue { pub fn choose<TValue: Collection>(&mut self, selection: Vec<TValue>) -> TValue {
let options = if selection.is_empty() { let options = if selection.is_empty() {
TValue::all() TValue::all()
} else { } else {
@ -27,7 +27,7 @@ impl<TRng: Rng> Chooser<TRng> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use rand::rngs::mock::StepRng; use rand::rngs::mock::StepRng;
use crate::{Chooser, Options}; use crate::{Chooser, Collection};
enum MockOptions { enum MockOptions {
First, First,
@ -35,7 +35,7 @@ mod test {
Third Third
} }
impl Options for MockOptions { impl Collection for MockOptions {
fn all() -> Vec<Self> where Self: Sized { fn all() -> Vec<Self> where Self: Sized {
use MockOptions::*; use MockOptions::*;

View File

@ -9,7 +9,7 @@ use crate::animation::circle::CircleAnimation;
use crate::animation::rhombus::RhombusAnimation; use crate::animation::rhombus::RhombusAnimation;
use crate::animation::rotation::RotationAnimation; use crate::animation::rotation::RotationAnimation;
use crate::char::SimpleCharSampler; use crate::char::SimpleCharSampler;
use crate::choose::{Chooser, Options}; use crate::choose::{Chooser, Collection};
use crate::color::{ColorSampler, SimpleColorSampler}; use crate::color::{ColorSampler, SimpleColorSampler};
use crate::fill::circle::CircleFillMode; use crate::fill::circle::CircleFillMode;
use crate::fill::FillMode; use crate::fill::FillMode;
@ -41,7 +41,7 @@ macro_rules! options {
enum $name { enum $name {
$($opt,)* $($opt,)*
} }
impl Options for $name { impl Collection for $name {
fn all() -> Vec<Self> { fn all() -> Vec<Self> {
vec![$($name::$opt,)*] vec![$($name::$opt,)*]
} }