pub struct Snapshot<T: ?Sized>(/* private fields */);Expand description
A copyable snapshot, usable in pearlite.
The Snapshot type contains the logical value of some data, in a purely immutable way.
It is zero sized.
Creating a snapshot does not move the ownership of a value.
§Pearlite syntax
In executable code, you may create a snapshot with the snapshot! macro. Inside
this macro, you may write pearlite code; this code will not run during the normal
execution of the program.
§Example
let x: Snapshot<Int> = snapshot!(1);
let m: Snapshot<Mapping<Int, Int>> = snapshot!(|x| x + 1);Implementations§
Source§impl<T> Snapshot<T>
impl<T> Snapshot<T>
Sourcepub fn inner(self) -> T
pub fn inner(self) -> T
Get the value of the snapshot.
When possible, you should instead use the dereference operator.
§Example
let x = snapshot!(1);
proof_assert!(x.inner() == 1);
proof_assert!(*x == 1); // prefer this⚠
Sourcepub fn into_ghost(self) -> Ghost<T>where
T: Plain,
pub fn into_ghost(self) -> Ghost<T>where
T: Plain,
Extract a plain value from a snapshot in ghost code.
ensures
*result == *selfterminates
ghost
Trait Implementations§
Source§impl<R: RA> LocalUpdate<R> for Snapshot<(R, R)>
impl<R: RA> LocalUpdate<R> for Snapshot<(R, R)>
Source§fn premise(self, from_auth: R, from_frag: R) -> bool
fn premise(self, from_auth: R, from_frag: R) -> bool
(open)
pearlite! { forall<f: Option<R>> Some(from_frag).op(f) == Some(Some(from_auth)) ==> Some(self.1).op(f) == Some(Some(self.0)) }
Source§fn frame_preserving(self, from_auth: R, from_frag: R, frame: Option<R>)
fn frame_preserving(self, from_auth: R, from_frag: R, frame: Option<R>)
⚠
requires
LocalUpdate::premise(self, from_auth, from_frag)requires
Some(from_frag).op(frame) == Some(Some(from_auth))ensures
let (to_auth, to_frag) = LocalUpdate::update(self, from_auth, from_frag); Some(to_frag).op(frame) == Some(Some(to_auth))
Source§impl<R: RA, Choice> Update<R> for Snapshot<Mapping<Choice, R>>
impl<R: RA, Choice> Update<R> for Snapshot<Mapping<Choice, R>>
Source§fn premise(self, from: R) -> bool
fn premise(self, from: R) -> bool
(open)
pearlite! { forall<y: R> from.op(y) != None ==> exists<ch: Choice> self[ch].op(y) != None }
Source§fn frame_preserving(self, from: R, frame: R) -> Choice
fn frame_preserving(self, from: R, frame: R) -> Choice
⚠
requires
self.premise(from)requires
from.op(frame) != Noneensures
self.update(from, result).op(frame) != Nonetype Choice = Choice
Source§impl<R: RA> Update<R> for Snapshot<R>
impl<R: RA> Update<R> for Snapshot<R>
Source§fn premise(self, from: R) -> bool
fn premise(self, from: R) -> bool
(open)
pearlite! { forall<y: R> from.op(y) != None ==> self.op(y) != None }
Source§fn frame_preserving(self, from: R, frame: R)
fn frame_preserving(self, from: R, frame: R)
⚠
requires
self.premise(from)requires
from.op(frame) != Noneensures
self.update(from, result).op(frame) != Nonetype Choice = ()
impl<T: ?Sized> Copy for Snapshot<T>
Auto Trait Implementations§
impl<T> Freeze for Snapshot<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Snapshot<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Snapshot<T>
impl<T> Sync for Snapshot<T>
impl<T> Unpin for Snapshot<T>
impl<T> UnwindSafe for Snapshot<T>where
T: UnwindSafe + ?Sized,
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