Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ndc_lib/src/stdlib/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ mod inner {
map.insert(key, Value::unit());
}

/// Returns true if the map or set contains no elements.
pub fn is_empty(map: &HashMap<Value, Value>) -> bool {
map.is_empty()
}

#[function(name = "&=")]
pub fn intersect_assign(lhs: &mut MapRepr, rhs: &mut MapRepr) {
let left_map: &mut HashMap<Value, Value> = &mut lhs
Expand Down
6 changes: 6 additions & 0 deletions tests/programs/007_map_and_set/023_map_is_empty.ndct
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--PROGRAM--
assert_eq(%{}.is_empty(), true);
assert_eq(%{1,2,3}.is_empty(), false);
print("ok");
--EXPECT--
ok