Skip to content

Commit db334d5

Browse files
authored
📭 Added is_empty function for maps (#76)
1 parent c4aff70 commit db334d5

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎ndc_lib/src/stdlib/hash_map.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ mod inner {
4848
map.insert(key, Value::unit());
4949
}
5050

51+
/// Returns true if the map or set contains no elements.
52+
pub fn is_empty(map: &HashMap<Value, Value>) -> bool {
53+
map.is_empty()
54+
}
55+
5156
#[function(name = "&=")]
5257
pub fn intersect_assign(lhs: &mut MapRepr, rhs: &mut MapRepr) {
5358
let left_map: &mut HashMap<Value, Value> = &mut lhs
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--PROGRAM--
2+
assert_eq(%{}.is_empty(), true);
3+
assert_eq(%{1,2,3}.is_empty(), false);
4+
print("ok");
5+
--EXPECT--
6+
ok

0 commit comments

Comments
 (0)