Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extend to HashMap and StringHashMap #1295

Merged
merged 4 commits into from
Oct 17, 2024
Merged
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
16 changes: 16 additions & 0 deletions source/vstd/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ impl<Key, Value> HashMapWithView<Key, Value> where Key: View + Eq + Hash {
{
self.m.clear()
}

#[verifier::external_body]
pub fn union_prefer_right(&mut self, other: Self)
ensures
self@ == old(self)@.union_prefer_right(other@),
{
self.m.extend(other.m)
marshtompsxd marked this conversation as resolved.
Show resolved Hide resolved
}
}

pub broadcast proof fn axiom_hash_map_with_view_spec_len<Key, Value>(
Expand Down Expand Up @@ -211,6 +219,14 @@ impl<Value> StringHashMap<Value> {
{
self.m.clear()
}

#[verifier::external_body]
pub fn union_prefer_right(&mut self, other: Self)
ensures
self@ == old(self)@.union_prefer_right(other@),
{
self.m.extend(other.m)
}
}

pub broadcast proof fn axiom_string_hash_map_spec_len<Value>(m: &StringHashMap<Value>)
Expand Down