pub struct PCell<V> { /* private fields */ }vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadExpand description
Now deprecated See pcell::PCell or pcell_maybe_uninit::PCell instead
PCell<V> (which stands for “permissioned call”) is the primitive Verus Cell type.
Technically, it is a wrapper around
core::cell::UnsafeCell<core::mem::MaybeUninit<V>>, and thus has the same runtime
properties: there are no runtime checks (as there would be for Rust’s traditional
core::cell::RefCell).
Its data may be uninitialized.
Furthermore (and unlike both
core::cell::Cell and
core::cell::RefCell),
a PCell<V> may be Sync (depending on V).
Thanks to verification, Verus ensures that access to the cell is data-race-free.
PCell uses a ghost permission token similar to simple_pptr::PPtr – see the simple_pptr::PPtr
documentation for the basics.
For PCell, the associated type of the permission token is cell::PointsTo.
§Differences from PPtr.
The key difference is that, whereas simple_pptr::PPtr represents a fixed address in memory,
a PCell has no fixed address because a PCell might be moved.
As such, the pcell.id() does not correspond to a memory address; rather,
it is a unique identifier that is fixed for a given cell, even when it is moved.
The arbitrary ID given by pcell.id() is of type CellId.
Despite the fact that it is, in some ways, “like a pointer”, note that
CellId does not support any meangingful arithmetic,
has no concept of a “null ID”,
and has no runtime representation.
Also note that the PCell might be dropped before the PointsTo token is dropped,
although in that case it will no longer be possible to use the PointsTo in exec code
to extract data from the cell.
Implementations§
Source§impl<V> PCell<V>
impl<V> PCell<V>
Sourcepub uninterp fn id(&self) -> CellId
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub uninterp fn id(&self) -> CellId
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadA unique ID for the cell.
Sourcepub const exec fn empty() -> pt : (PCell<V>, Tracked<PointsTo<V>>)
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub const exec fn empty() -> pt : (PCell<V>, Tracked<PointsTo<V>>)
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadpt.1@@ === pcell_points![pt.0.id() => MemContents::Uninit],Return an empty (“uninitialized”) cell.
Sourcepub const exec fn new(v: V) -> pt : (PCell<V>, Tracked<PointsTo<V>>)
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub const exec fn new(v: V) -> pt : (PCell<V>, Tracked<PointsTo<V>>)
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadpt.1@@ === pcell_points![pt.0.id() => MemContents::Init(v)],Sourcepub exec fn put(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, v: V)
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub exec fn put(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, v: V)
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadold(perm)@ === pcell_points![self.id() => MemContents::Uninit],ensuresperm@ === pcell_points![self.id() => MemContents::Init(v)],Sourcepub exec fn take(&self, Tracked(perm): Tracked<&mut PointsTo<V>>) -> v : V
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub exec fn take(&self, Tracked(perm): Tracked<&mut PointsTo<V>>) -> v : V
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadself.id() === old(perm)@.pcell,old(perm).is_init(),ensuresperm.id() === old(perm)@.pcell,perm.mem_contents() === MemContents::Uninit,v === old(perm).value(),Sourcepub exec fn replace(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, in_v: V) -> out_v : V
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub exec fn replace(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, in_v: V) -> out_v : V
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadself.id() === old(perm)@.pcell,old(perm).is_init(),ensuresperm.id() === old(perm)@.pcell,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
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub exec fn borrow<'a>(&'a self, Tracked(perm): Tracked<&'a PointsTo<V>>) -> v : &'a V
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadself.id() === perm@.pcell,perm.is_init(),ensures*v === perm.value(),Sourcepub exec fn into_inner(self, Tracked(perm): Tracked<PointsTo<V>>) -> v : V
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub exec fn into_inner(self, Tracked(perm): Tracked<PointsTo<V>>) -> v : V
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadself.id() === perm@.pcell,perm.is_init(),ensuresv === perm.value(),Source§impl<V: Copy> PCell<V>
impl<V: Copy> PCell<V>
Sourcepub exec fn write(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, in_v: V)
👎Deprecated: use vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell instead
pub exec fn write(&self, Tracked(perm): Tracked<&mut PointsTo<V>>, in_v: V)
vstd::cell::pcell::PCell or vstd::cell::pcell_maybe_uninit::PCell insteadself.id() === old(perm)@.pcell,old(perm).is_init(),ensuresperm.id() === old(perm)@.pcell,perm.mem_contents() === MemContents::Init(in_v),Trait Implementations§
impl<T> Send for PCell<T>
impl<T> Sync for PCell<T>
PCell is always safe to Send or Sync. Rather, it is the PointsTo object where Send and Sync matter.
(It doesn’t matter if you move the bytes to another thread if you can’t access them.)
Auto Trait Implementations§
impl<V> !Freeze for PCell<V>
impl<V> !RefUnwindSafe 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
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() }