From: Ian Jackson Date: Thu, 25 Mar 2021 00:36:02 +0000 (+0000) Subject: provide otter_base::Region X-Git-Tag: otter-0.5.0~434 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=facb03275e0e7021d552917c3e28019fdc75dec5;p=otter.git provide otter_base::Region Signed-off-by: Ian Jackson --- diff --git a/base/geometry.rs b/base/geometry.rs index a18a03db..4a4e2dd4 100644 --- a/base/geometry.rs +++ b/base/geometry.rs @@ -236,3 +236,19 @@ fn empty_area() { assert!(! empty.contains(PosC([x,y]))); } } } + +// ---------- Region ---------- + +#[derive(Clone,Debug,Serialize,Deserialize)] +pub enum Region { + Rectangle(AreaC), +} + +impl Region { + pub fn contains(&self, pos: PosC) -> bool where T: Ord { + use Region::*; + match &self { + Rectangle(a) => a.contains(pos), + } + } +}