From: Ian Jackson Date: Thu, 25 Mar 2021 01:13:09 +0000 (+0000) Subject: geometry: Relax Ord to PartialOrd X-Git-Tag: otter-0.5.0~432 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2474c9e68277850a76fa3019d5cf526e72376bd5;p=otter.git geometry: Relax Ord to PartialOrd Signed-off-by: Ian Jackson --- diff --git a/base/geometry.rs b/base/geometry.rs index 4a4e2dd4..2e1708ce 100644 --- a/base/geometry.rs +++ b/base/geometry.rs @@ -198,14 +198,14 @@ impl PosC { // ---------- Area ---------- impl AreaC { - pub fn contains(&self, p: PosC) -> bool where T: Ord { + pub fn contains(&self, p: PosC) -> bool where T: PartialOrd { (0..2).all(|i| { p.0[i] >= self.0[0].0[i] && p.0[i] <= self.0[1].0[i] }) } - pub fn overlaps(&self, other: &AreaC) -> bool where T: Ord { + pub fn overlaps(&self, other: &AreaC) -> bool where T: PartialOrd { ! (0..2).any(|i| ( other.0[1].0[i] < self .0[0].0[i] || self .0[1].0[i] < other.0[0].0[i] @@ -245,7 +245,7 @@ pub enum Region { } impl Region { - pub fn contains(&self, pos: PosC) -> bool where T: Ord { + pub fn contains(&self, pos: PosC) -> bool where T: PartialOrd { use Region::*; match &self { Rectangle(a) => a.contains(pos),