#[repr(transparent)]pub struct Guarded<T> {
pub borrow: T,
/* private fields */
}Expand description
A borrow guarded by an invariant.
This is used to define GuardedBorrow.
This can also be used to define the equivalent of GuardedBorrow with
smart pointers, like RefMut.
Fields§
§borrow: TBorrow contained in this guard.
The T type parameter is meant to be a mutable borrow type (like
&mut T, or RefMut<T>).
Implementations§
Source§impl<'a, T: ?Sized> Guarded<&'a mut T>
impl<'a, T: ?Sized> Guarded<&'a mut T>
Sourcepub fn new(borrow: &'a mut T, guard: Snapshot<Mapping<T, bool>>) -> Self
pub fn new(borrow: &'a mut T, guard: Snapshot<Mapping<T, bool>>) -> Self
Create a new guarded borrow.
The borrow contained in the result is guaranteed to satisfy the
guard at the end of its lifetime.
Note that the borrow field cannot have its final value changed,
ensuring that it will not get swapped for another borrow.
ensures
result.borrow == borrowensures
forall<bor: &mut T> result.guard()[bor] == (guard[*bor] && ^bor == ^borrow)
ensures
guard[^borrow]ghost
Get a shared borrow out of this guarded borrow.
It is not possible to break the guard anymore, since the returned borrow is immutable.
ensures
*result == *self.borrowensures
*self.borrow == ^self.borrowghost
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Guarded<T>where
T: Freeze,
impl<T> Objective for Guarded<T>where
T: Objective,
impl<T> RefUnwindSafe for Guarded<T>where
T: RefUnwindSafe,
impl<T> Send for Guarded<T>where
T: Send,
impl<T> Sync for Guarded<T>where
T: Sync,
impl<T> Unpin for Guarded<T>where
T: Unpin,
impl<T> UnsafeUnpin for Guarded<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Guarded<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