diff --git a/engine/src/types.rs b/engine/src/types.rs index cc217b60..d9592db9 100644 --- a/engine/src/types.rs +++ b/engine/src/types.rs @@ -365,6 +365,16 @@ impl<'a> Array<'a> { pub fn value_type(&self) -> &Type { &self.val_type } + + /// Returns the number of elements in the array + pub fn len(&self) -> usize { + self.data.len() + } + + /// Returns true if the array contains no elements. + pub fn is_empty(&self) -> bool { + self.data.is_empty() + } } impl<'a> GetType for Array<'a> { @@ -476,6 +486,16 @@ impl<'a> Map<'a> { pub fn value_type(&self) -> &Type { &self.val_type } + + /// Returns the number of elements in the map + pub fn len(&self) -> usize { + self.data.len() + } + + /// Returns true if the map contains no elements. + pub fn is_empty(&self) -> bool { + self.data.is_empty() + } } impl<'a> GetType for Map<'a> {