pub struct GhostSetAuth<T> { /* private fields */ }Expand description
A resource that has the authoritative ownership on the entire set
For ownership of only a subset of values, see GhostSubset.
For ownership of a single value, see GhostSingleton.
Implementations§
Source§impl<T> GhostSetAuth<T>
impl<T> GhostSetAuth<T>
Sourcepub proof fn new(s: Set<T>) -> tracked result : (GhostSetAuth<T>, GhostSubset<T>)
pub proof fn new(s: Set<T>) -> tracked result : (GhostSetAuth<T>, GhostSubset<T>)
ensures
result.0.id() == result.1.id(),result.0@ == s,result.1@ == s,Create a new GhostSetAuth from a Set.
Gives the other half of ownership in the form of a GhostSubset
fn example() {
let s = set![1int, 2int];
let tracked (auth, sub) = GhostSetAuth::new(s);
assert(auth@ == s);
assert(sub@ == auth@);
}Sourcepub proof fn dummy() -> tracked result : GhostSetAuth<T>
pub proof fn dummy() -> tracked result : GhostSetAuth<T>
Instantiate a dummy GhostSetAuth
Sourcepub proof fn take(tracked &mut self) -> tracked result : GhostSetAuth<T>
pub proof fn take(tracked &mut self) -> tracked result : GhostSetAuth<T>
ensures
result == *old(self),Extract the GhostSetAuth from a mutable reference
Sourcepub proof fn empty(tracked &self) -> tracked result : GhostSubset<T>
pub proof fn empty(tracked &self) -> tracked result : GhostSubset<T>
ensures
result.id() == self.id(),result@ == Set::<T>::empty(),Create an empty GhostSubset
Sourcepub proof fn insert_set(tracked &mut self, s: Set<T>) -> tracked result : GhostSubset<T>
pub proof fn insert_set(tracked &mut self, s: Set<T>) -> tracked result : GhostSubset<T>
requires
old(self)@.disjoint(s),ensuresself.id() == old(self).id(),self@ == old(self)@.union(s),result.id() == self.id(),result@ == s,Insert a Set of values, receiving the GhostSubset that asserts ownership over the set inserted.
proof fn insert_set_example(tracked mut m: GhostSetAuth<int>) -> (tracked r: GhostSubset<int>)
requires
m@.contains(1int),
m@.contains(2int),
{
let tracked subset = m.insert_set(set![1int, 2int]);
// do something with the subset
subset
}Sourcepub proof fn insert(tracked &mut self, v: T) -> tracked result : GhostSingleton<T>
pub proof fn insert(tracked &mut self, v: T) -> tracked result : GhostSingleton<T>
requires
!old(self)@.contains(v),ensuresself.id() == old(self).id(),self@ == old(self)@.insert(v),result.id() == self.id(),result@ == v,Insert a value, receiving the GhostSingleton that asserts ownerships over the value.
proof fn insert_example(tracked mut s: GhostSetAuth<int>) -> (tracked r: GhostSingleton<int>)
requires
!m@.contains(1int),
{
let tracked singleton = m.insert(1);
// do something with the singleton
singleton
}Sourcepub proof fn delete(tracked &mut self, tracked f: GhostSubset<T>)
pub proof fn delete(tracked &mut self, tracked f: GhostSubset<T>)
requires
f.id() == old(self).id(),ensuresself.id() == old(self).id(),self@ == old(self)@.difference(f@),Delete a set of values
proof fn delete(tracked mut auth: GhostSetAuth<int>)
requires
auth@.contains(1int),
auth@.contains(2int),
ensures
old(auth)@ == auth@
{
let tracked submap = auth.insert_set(set![1int, 2int]);
// do something with the submap
auth.delete(submap)
}Sourcepub proof fn delete_singleton(tracked &mut self, tracked p: GhostSingleton<T>)
pub proof fn delete_singleton(tracked &mut self, tracked p: GhostSingleton<T>)
requires
p.id() == old(self).id(),ensuresself.id() == old(self).id(),self@ == old(self)@.remove(p@),Delete a single key from the map
proof fn delete_key(tracked mut auth: GhostSetAuth<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)
}Auto Trait Implementations§
impl<T> Freeze for GhostSetAuth<T>
impl<T> RefUnwindSafe for GhostSetAuth<T>where
T: RefUnwindSafe,
impl<T> Send for GhostSetAuth<T>where
T: Send,
impl<T> Sync for GhostSetAuth<T>where
T: Sync,
impl<T> Unpin for GhostSetAuth<T>where
T: Unpin,
impl<T> UnwindSafe for GhostSetAuth<T>where
T: 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