From 1269d4b34ddcd68efacf7b1f5b12023013252b8d Mon Sep 17 00:00:00 2001 From: ltabis Date: Wed, 24 Aug 2022 13:17:43 +0200 Subject: [PATCH] feat(ranges): add `is_empty` function to inclusive/exclusive ranges. --- src/packages/iter_basic.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/packages/iter_basic.rs b/src/packages/iter_basic.rs index 3ec29366..02089952 100644 --- a/src/packages/iter_basic.rs +++ b/src/packages/iter_basic.rs @@ -666,6 +666,11 @@ mod range_functions { let _ = range; true } + /// Returns true if the range contains no items. + #[rhai_fn(get = "is_empty", name = "is_empty", pure)] + pub fn is_empty_exclusive(range: &mut ExclusiveRange) -> bool { + range.is_empty() + } /// Return the start of the inclusive range. #[rhai_fn(get = "start", name = "start", pure)] pub fn start_inclusive(range: &mut InclusiveRange) -> INT { @@ -688,4 +693,9 @@ mod range_functions { let _ = range; false } + /// Returns true if the range contains no items. + #[rhai_fn(get = "is_empty", name = "is_empty", pure)] + pub fn is_empty_inclusive(range: &mut InclusiveRange) -> bool { + range.is_empty() + } }