pub struct Ghost<T: ?Sized>(/* private fields */);Expand description
A type that can be used in ghost! context.
This type may be used to make more complicated proofs possible. In particular, some proof may need a notion of non-duplicable token to carry around.
Conceptually, a Ghost<T> is an object of type T that resides in a special “ghost”
heap. This heap is inaccessible from normal code, and Ghost values cannot be used
to influence the behavior of normal code.
This box can be accessed in a ghost! block:
let b: Ghost<i32> = Ghost::new(1);
ghost! {
let value: i32 = b.into_inner();
// use value here
}
let value: i32 = b.into_inner(); // compile error !Implementations§
Source§impl<T: ?Sized> Ghost<T>
impl<T: ?Sized> Ghost<T>
Sourcepub fn borrow(&self) -> Ghost<&T>
pub fn borrow(&self) -> Ghost<&T>
Transforms a &Ghost<T> into Ghost<&T>
erasure
_ghost
ensures
**result == **selfSourcepub fn borrow_mut(&mut self) -> Ghost<&mut T>
pub fn borrow_mut(&mut self) -> Ghost<&mut T>
Transforms a &mut Ghost<T> into a Ghost<&mut T>.
erasure
_ghost
ensures
*result == &mut **selfSourcepub fn conjure() -> Self
pub fn conjure() -> Self
Conjures a Ghost<T> out of thin air.
This would be unsound in verified code, hence the false precondition.
This function is nevertheless useful to create a Ghost in “trusted”
contexts, when axiomatizing an API that is believed to be sound for
external reasons.
erasure
_ghost
requires
falseSource§impl<T: ?Sized> Ghost<T>
impl<T: ?Sized> Ghost<T>
Sourcepub fn new(x: T) -> Selfwhere
T: Sized,
pub fn new(x: T) -> Selfwhere
T: Sized,
Creates a new ghost variable.
This function can only be called in ghost! code.
ghost
ensures
#[logic_alias(Self::new_logic)]Sourcepub fn into_inner(self) -> Twhere
T: Sized,
pub fn into_inner(self) -> Twhere
T: Sized,
Returns the inner value of the Ghost.
This function can only be called in ghost! context.
ghost
ensures
#[logic_alias(Self::inner_logic)]Sourcepub fn inner_logic(self) -> Twhere
T: Sized,
pub fn inner_logic(self) -> Twhere
T: Sized,
Returns the inner value of the Ghost.
You should prefer the dereference operator * instead.
logic ⚠
Source§impl<T1, T2, T3> Ghost<(T1, T2, T3)>
impl<T1, T2, T3> Ghost<(T1, T2, T3)>
Source§impl<T1, T2, T3, T4> Ghost<(T1, T2, T3, T4)>
impl<T1, T2, T3, T4> Ghost<(T1, T2, T3, T4)>
Source§impl<T1, T2, T3, T4, T5> Ghost<(T1, T2, T3, T4, T5)>
impl<T1, T2, T3, T4, T5> Ghost<(T1, T2, T3, T4, T5)>
Sourcepub fn split(self) -> (Ghost<T1>, Ghost<T2>, Ghost<T3>, Ghost<T4>, Ghost<T5>)
pub fn split(self) -> (Ghost<T1>, Ghost<T2>, Ghost<T3>, Ghost<T4>, Ghost<T5>)
Transform a Ghost of tuple into a tuple of Ghosts.
ghost
ensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nSource§impl<T1, T2, T3, T4, T5, T6> Ghost<(T1, T2, T3, T4, T5, T6)>
impl<T1, T2, T3, T4, T5, T6> Ghost<(T1, T2, T3, T4, T5, T6)>
Sourcepub fn split(
self,
) -> (Ghost<T1>, Ghost<T2>, Ghost<T3>, Ghost<T4>, Ghost<T5>, Ghost<T6>)
pub fn split( self, ) -> (Ghost<T1>, Ghost<T2>, Ghost<T3>, Ghost<T4>, Ghost<T5>, Ghost<T6>)
Transform a Ghost of tuple into a tuple of Ghosts.
ghost
ensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nSource§impl<T1, T2, T3, T4, T5, T6, T7> Ghost<(T1, T2, T3, T4, T5, T6, T7)>
impl<T1, T2, T3, T4, T5, T6, T7> Ghost<(T1, T2, T3, T4, T5, T6, T7)>
Sourcepub fn split(
self,
) -> (Ghost<T1>, Ghost<T2>, Ghost<T3>, Ghost<T4>, Ghost<T5>, Ghost<T6>, Ghost<T7>)
pub fn split( self, ) -> (Ghost<T1>, Ghost<T2>, Ghost<T3>, Ghost<T4>, Ghost<T5>, Ghost<T6>, Ghost<T7>)
Transform a Ghost of tuple into a tuple of Ghosts.
ghost
ensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nSource§impl<T1, T2, T3, T4, T5, T6, T7, T8> Ghost<(T1, T2, T3, T4, T5, T6, T7, T8)>
impl<T1, T2, T3, T4, T5, T6, T7, T8> Ghost<(T1, T2, T3, T4, T5, T6, T7, T8)>
Sourcepub fn split(
self,
) -> (Ghost<T1>, Ghost<T2>, Ghost<T3>, Ghost<T4>, Ghost<T5>, Ghost<T6>, Ghost<T7>, Ghost<T8>)
pub fn split( self, ) -> (Ghost<T1>, Ghost<T2>, Ghost<T3>, Ghost<T4>, Ghost<T5>, Ghost<T6>, Ghost<T7>, Ghost<T8>)
Transform a Ghost of tuple into a tuple of Ghosts.
ghost
ensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nensures
(*self).$n == *result.$nTrait Implementations§
impl<T: Copy> Copy for Ghost<T>
Source§impl<T: ?Sized> DerefLogic for Ghost<T>
impl<T: ?Sized> DerefLogic for Ghost<T>
Source§fn deref_logic(&self) -> &T
fn deref_logic(&self) -> &T
logic ⚠
Source§impl<T: ?Sized> DerefMutLogic for Ghost<T>
impl<T: ?Sized> DerefMutLogic for Ghost<T>
Source§fn deref_mut_logic(&mut self) -> &mut T
fn deref_mut_logic(&mut self) -> &mut T
logic ⚠