From 4e6101a211053b996d5b2854095ebbd09f825d8e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 14 Mar 2021 23:39:09 +0000 Subject: [PATCH] spec: Provide Area::empty Signed-off-by: Ian Jackson --- src/spec.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/spec.rs b/src/spec.rs index bb83d99b..9d31a824 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -375,6 +375,23 @@ pub mod implementation { self .0[1].0[i] < other.0[0].0[i] )) } + + pub fn empty() -> Self where T: Copy + num_traits::Zero + num_traits::One { + let zero = ::zero(); + let one = ::one(); + AreaC([ + PosC([ one, one ]), + PosC([ zero, zero ]), + ]) + } + } + + #[test] + fn empty_area() { + let empty = Area::empty(); + for x in -3..3 { for y in -3..3 { + assert!(! empty.contains(PosC([x,y]))); + } } } impl Default for PieceAngle { -- 2.30.2