From facb03275e0e7021d552917c3e28019fdc75dec5 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 25 Mar 2021 00:36:02 +0000 Subject: [PATCH] provide otter_base::Region Signed-off-by: Ian Jackson --- base/geometry.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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), + } + } +} -- 2.30.2