pub struct PCell<V>(/* private fields */);Expand description
Variant of pcell::PCell<V> for potentially uninitialized data.
See the pcell::PCell<V> docs for a high-level overview.
§Example
ⓘ
use vstd::prelude::*;
use vstd::cell::pcell_maybe_uninit as un;
use vstd::raw_ptr::MemContents;
verus! {
fn example_pcell_maybe_uninit() {
let (cell, Tracked(mut points_to)) = un::PCell::new(5);
assert(points_to.id() == cell.id());
assert(points_to.mem_contents() === MemContents::Init(5));
let x = cell.take(Tracked(&mut points_to));
assert(x == 5);
assert(points_to.id() == cell.id());
assert(points_to.mem_contents() === MemContents::Uninit);
cell.put(Tracked(&mut points_to), 17);
assert(points_to.id() == cell.id());
assert(points_to.mem_contents() === MemContents::Init(17));
}
} // verus!Implementations§
Source§impl<V> PCell<V>
impl<V> PCell<V>
Sourcepub const exec fn empty() -> pt : (PCell<V>, Tracked<PointsTo<V>>)
pub const exec fn empty() -> pt : (PCell<V>, Tracked<PointsTo<V>>)
ensures
pt.1@.id() == pt.0.id(),pt.1@.mem_contents() === MemContents::Uninit,Return an empty (“uninitialized”) cell.
Sourcepub const exec fn new(v: V) -> pt : (PCell<V>, Tracked<PointsTo<V>>)
pub const exec fn new(v: V) -> pt : (PCell<V>, Tracked<PointsTo<V>>)
ensures
pt.1@.id() == pt.0.id(),pt.1@.mem_contents() == MemContents::Init(v),Sourcepub exec fn put(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, in_v: V)
pub exec fn put(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, in_v: V)
requires
old(perm).id() == self.id(),old(perm).mem_contents() === MemContents::Uninit,ensuresperm.id() == self.id(),perm.mem_contents() === MemContents::Init(in_v),Sourcepub exec fn take(&self, Tracked(perm): Tracked<&mut PointsTo<V>>) -> out_v : V
pub exec fn take(&self, Tracked(perm): Tracked<&mut PointsTo<V>>) -> out_v : V
requires
self.id() === old(perm).id(),old(perm).is_init(),ensuresperm.id() === old(perm).id(),perm.mem_contents() === MemContents::Uninit,out_v === old(perm).value(),Sourcepub exec fn replace(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, in_v: V) -> out_v : V
pub exec fn replace(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, in_v: V) -> out_v : V
requires
self.id() === old(perm).id(),old(perm).is_init(),ensuresperm.id() === old(perm).id(),perm.mem_contents() === MemContents::Init(in_v),out_v === old(perm).value(),Sourcepub exec fn borrow<'a>(&'a self, Tracked(perm): Tracked<&'a PointsTo<V>>) -> v : &'a V
pub exec fn borrow<'a>(&'a self, Tracked(perm): Tracked<&'a PointsTo<V>>) -> v : &'a V
requires
self.id() === perm.id(),perm.is_init(),ensures*v === perm.value(),Sourcepub exec fn into_inner(self, Tracked(perm): Tracked<PointsTo<V>>) -> v : V
pub exec fn into_inner(self, Tracked(perm): Tracked<PointsTo<V>>) -> v : V
requires
self.id() === perm.id(),perm.is_init(),ensuresv === perm.value(),Auto Trait Implementations§
impl<V> !Freeze for PCell<V>
impl<V> !RefUnwindSafe for PCell<V>
impl<V> Send for PCell<V>
impl<V> Sync for PCell<V>
impl<V> Unpin for PCell<V>where
V: Unpin,
impl<V> UnwindSafe for PCell<V>where
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
Source§impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
Source§impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryFrom<T>,
impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryFrom<T>,
Source§exec fn obeys_try_from_spec() -> bool
exec fn obeys_try_from_spec() -> bool
Source§impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryInto<T>,
impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryInto<T>,
Source§exec fn obeys_try_into_spec() -> bool
exec fn obeys_try_into_spec() -> bool
Source§impl<T, U> TryIntoSpecImpl<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryIntoSpecImpl<U> for Twhere
U: TryFrom<T>,
Source§open spec fn obeys_try_into_spec() -> bool
open spec fn obeys_try_into_spec() -> bool
{ <U as TryFromSpec<Self>>::obeys_try_from_spec() }