math/set/
traits.rs

1pub trait Set<E> {
2    fn is_empty(&self) -> bool;
3
4    fn contains(&self, element: &E) -> bool;
5}
6
7pub trait Intersect<S, O> {
8    fn intersect(&self, other: S) -> O;
9
10    fn has_non_empty_intersection_with(&self, other: S) -> bool;
11}
12
13#[derive(Copy, Clone, PartialEq, Eq, Debug)]
14pub enum CountableType {
15    Finite(usize),
16    CountablyInfinite,
17}
18
19#[derive(Copy, Clone, PartialEq, Eq, Debug)]
20pub enum Cardinality {
21    Countable(CountableType),
22    Uncountable,
23}
24
25pub trait Countable {
26    fn count(&self) -> CountableType;
27
28    fn is_finite(&self) -> bool {
29        self.count() != CountableType::CountablyInfinite
30    }
31}
32
33pub trait Finite {
34    fn size(&self) -> usize;
35}
36
37/// Given two sets of the same type that are `Refineable`, their common
38/// refinement can be obtained
39pub trait Refineable<O> {
40    fn get_common_refinement(&self, other: &Self) -> O;
41}