logos icon indicating copy to clipboard operation
logos copied to clipboard

Range's `Ord` implementation

Open arnaudgolfouse opened this issue 3 years ago • 0 comments

Hello ! Running clippy on the code, it triggered clippy::derive_ord_xor_partial_ord in logos-derive/src/graph/range.rs:

#[derive(PartialOrd)]
pub struct Range { // although from what I can tell Range is not actually exported, so maybe it isn't so bad.
    pub start: u8,
    pub end: u8
}

impl Ord for Range {
    fn cmp(&self, other: &Self) -> Ordering {
        self.start.cmp(&other.start)
    }
}

Indeed Ord's documentation explicitly states that Ord and PartialOrd must agree, which is not the case here... Is this normal, maybe done for a particular optimization ?

arnaudgolfouse avatar Sep 12 '21 12:09 arnaudgolfouse