poset 0.1.0

A simple implementation of posets.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// Represents errors that can occur while manipulating posets, such as when the partial order is
/// not a valid partial order.
#[derive(Debug, PartialEq, Eq)]
pub enum PosetError {
    /// Indicates that the poset has no maxima, when it should.
    NoMaxima,
    /// Indicates that the poset has no minima, when it should.
    NoMinima,
}

impl std::fmt::Display for PosetError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            PosetError::NoMaxima => write!(f, "non-empty poset should have a maximal element"),
            PosetError::NoMinima => write!(f, "non-empty poset should have a minimal element"),
        }
    }
}