From: Ian Jackson Date: Sun, 14 Mar 2021 23:39:09 +0000 (+0000) Subject: spec: Provide Area::empty X-Git-Tag: otter-0.4.0~41 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=4e6101a211053b996d5b2854095ebbd09f825d8e;p=otter.git spec: Provide Area::empty Signed-off-by: Ian Jackson --- 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 {