pub struct GhostMapAuth<K, V> { /* private fields */ }Expand description
A resource that has the authoritative ownership on the entire map
Implementations§
Source§impl<K, V> GhostMapAuth<K, V>
impl<K, V> GhostMapAuth<K, V>
Sourcepub open spec fn dom(self) -> Set<K>
pub open spec fn dom(self) -> Set<K>
{ self@.dom() }Domain of the GhostMapAuth
Sourcepub open spec fn spec_index(self, key: K) -> V
pub open spec fn spec_index(self, key: K) -> V
recommends
self.dom().contains(key),{ self@[key] }Indexing operation auth[key]
Sourcepub proof fn dummy() -> tracked result : GhostMapAuth<K, V>
pub proof fn dummy() -> tracked result : GhostMapAuth<K, V>
Instantiate a dummy GhostMapAuth
Sourcepub proof fn take(tracked &mut self) -> tracked result : GhostMapAuth<K, V>
pub proof fn take(tracked &mut self) -> tracked result : GhostMapAuth<K, V>
ensures
result == *old(self),Extract the GhostMapAuth from a mutable reference
Sourcepub proof fn empty(tracked &self) -> tracked result : GhostSubmap<K, V>
pub proof fn empty(tracked &self) -> tracked result : GhostSubmap<K, V>
ensures
result.id() == self.id(),result@ == Map::<K, V>::empty(),Create an empty GhostSubmap
Sourcepub proof fn insert_map(tracked &mut self, m: Map<K, V>) -> tracked result : GhostSubmap<K, V>
pub proof fn insert_map(tracked &mut self, m: Map<K, V>) -> tracked result : GhostSubmap<K, V>
requires
old(self)@.dom().disjoint(m.dom()),ensuresself.id() == old(self).id(),self@ == old(self)@.union_prefer_right(m),result.id() == self.id(),result@ == m,Insert a Map of values, receiving the GhostSubmap that asserts ownership over the key
domain inserted.
proof fn insert_map_example(tracked mut m: GhostMapAuth<int, int>) -> (tracked r: GhostSubmap<int, int>)
requires
!m.dom().contains(1int),
!m.dom().contains(2int),
{
let tracked submap = m.insert_map(map![1int => 1int, 2int => 4int]);
// do something with the submap
submap
}Sourcepub proof fn insert(tracked &mut self, k: K, v: V) -> tracked result : GhostPointsTo<K, V>
pub proof fn insert(tracked &mut self, k: K, v: V) -> tracked result : GhostPointsTo<K, V>
requires
!old(self)@.contains_key(k),ensuresself.id() == old(self).id(),self@ == old(self)@.insert(k, v),result.id() == self.id(),result@ == (k, v),Insert a key-value pair, receiving the GhostPointsTo that asserts ownerships over the key.
proof fn insert_example(tracked mut m: GhostMapAuth<int, int>) -> (tracked r: GhostPointsTo<int, int>)
requires
!m.dom().contains(1int),
{
let tracked points_to = m.insert(1, 1);
// do something with the points_to
points_to
}Sourcepub proof fn delete(tracked &mut self, tracked submap: GhostSubmap<K, V>)
pub proof fn delete(tracked &mut self, tracked submap: GhostSubmap<K, V>)
requires
submap.id() == old(self).id(),ensuresself.id() == old(self).id(),self@ == old(self)@.remove_keys(submap@.dom()),Delete a set of keys
proof fn delete(tracked mut auth: GhostMapAuth<int, int>)
requires
auth.dom().contains(1int),
auth.dom().contains(2int),
ensures
old(auth)@ == auth@
{
let tracked submap = auth.insert_map(map![1int => 1int, 2int => 4int]);
// do something with the submap
auth.delete(submap)
}Sourcepub proof fn delete_points_to(tracked &mut self, tracked p: GhostPointsTo<K, V>)
pub proof fn delete_points_to(tracked &mut self, tracked p: GhostPointsTo<K, V>)
requires
p.id() == old(self).id(),ensuresself.id() == old(self).id(),self@ == old(self)@.remove(p.key()),Delete a single key from the map
proof fn delete_key(tracked mut auth: GhostMapAuth<int, int>)
requires
auth.dom().contains(1int),
ensures
old(auth)@ == auth@
{
let tracked points_to = auth.insert(1, 1);
// do something with the submap
auth.delete_points_to(points_to)
}Sourcepub proof fn new(m: Map<K, V>) -> tracked result : (GhostMapAuth<K, V>, GhostSubmap<K, V>)
pub proof fn new(m: Map<K, V>) -> tracked result : (GhostMapAuth<K, V>, GhostSubmap<K, V>)
ensures
result.0.id() == result.1.id(),result.0@ == m,result.1@ == m,Create a new GhostMapAuth from a Map.
Gives the other half of ownership in the form of a GhostSubmap.
fn example() {
let m = map![1int => 1int, 2int => 4int, 3int => 9int];
let tracked (auth, sub) = GhostMapAuth::new(m);
assert(auth@ == m);
assert(sub.dom() == m.dom());
}Auto Trait Implementations§
impl<K, V> Freeze for GhostMapAuth<K, V>
impl<K, V> RefUnwindSafe for GhostMapAuth<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for GhostMapAuth<K, V>
impl<K, V> Sync for GhostMapAuth<K, V>
impl<K, V> Unpin for GhostMapAuth<K, V>
impl<K, V> UnwindSafe for GhostMapAuth<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more