[][src]Trait batching_queue::Groupable

pub trait Groupable {
    pub fn is_same_group(&self, other: &Self) -> bool;
}

Trait for defining types that can be grouped.

It is assumed that the implementation will be symmetric and groups will be mutually exclusive. Without these, the groups could possibly become fragmentated.

Implementation

Grouping an enum based on its variant:

#[derive(Debug, PartialEq, Eq)]
enum Group {
    G1,
    G2
}

 impl Groupable for Group {
     fn is_same_group(&self, other: &Self) -> bool {
         match (self, other) {
             (Self::G1, Self::G1) | (Self::G2, Self::G2) => true,
             _ => false
         }
     }
 }

It is not at all necessary that the implementer be an enum. It could easily be a struct and groups could be based on their properties.

Required methods

pub fn is_same_group(&self, other: &Self) -> bool[src]

The function returns true if self and other are part of the same group

Loading content...

Implementors

Loading content...