Skip to content

Commit

Permalink
Merge pull request #15 in EGS/wirefilter from elie/FW-2077-len to clo…
Browse files Browse the repository at this point in the history
…udflare

* commit 'c45cbd4215c0504d7e78ec8e81eba8517cb7b99c':
  FW-2077: add len and is_empty methods to Array and Map data types
  • Loading branch information
marmeladema committed Nov 1, 2019
2 parents d5b37fa + c45cbd4 commit 5ee29a7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions engine/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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> {
Expand Down

0 comments on commit 5ee29a7

Please sign in to comment.