Skip to main content

hash_map_get_ensures

Function hash_map_get_ensures 

Source
pub open spec fn hash_map_get_ensures<Key: Borrow<Q> + Hash + Eq, Value, S: BuildHasher, A: Allocator, Q: Hash + Eq + ?Sized>(
    m: &HashMap<Key, Value, S, A>,
    k: &Q,
    result: Option<&Value>,
) -> bool
Expand description
{
    ({
        &&& obeys_key_model::<Key>()
        &&& obeys_key_model::<Q>()
        &&& builds_valid_hashers::<S>()
        &&& <Key as BorrowSpec<Q>>::obeys_borrow_spec()
        &&& hash_map_inv(m)

    })
        ==> {
            match result {
                Some(v) => {
                    exists |key: Key| {
                        &&& #[trigger] m@.contains_key(key)
                        &&& k.eq_spec(<Key as BorrowSpec<Q>>::borrow_spec(&key))
                        &&& m@[key] == *v

                    }
                }
                None => {
                    forall |key: Key| (
                        #[trigger] m@.contains_key(key)
                            ==> !k.eq_spec(<Key as BorrowSpec<Q>>::borrow_spec(&key))
                    )
                }
            }
        }
}