pub struct ArrayPtr<V, const N: usize> {
pub addr: usize,
pub index: usize,
pub _type: PhantomData<[V; N]>,
}Expand description
Concrete representation of a pointer to an array The length of the array is not stored in the pointer
Fields§
§addr: usize§index: usize§_type: PhantomData<[V; N]>Implementations§
Source§impl<V, const N: usize> ArrayPtr<V, N>
impl<V, const N: usize> ArrayPtr<V, N>
Sourcepub exec fn empty() -> res : (ArrayPtr<V, N>, Tracked<PointsTo<V, N>>)
pub exec fn empty() -> res : (ArrayPtr<V, N>, Tracked<PointsTo<V, N>>)
layout::size_of::<[V; N]>() > 0,ensuresres.1@.wf(),res.1@.is_pptr(res.0),res.1@.is_uninit_all(),Sourcepub exec fn make_as(&self, Tracked(perm): Tracked<&mut PointsTo<V, N>>, value: V)where
V: Copy,
pub exec fn make_as(&self, Tracked(perm): Tracked<&mut PointsTo<V, N>>, value: V)where
V: Copy,
old(perm).wf(),old(perm).is_pptr(*self),old(perm).is_uninit_all(),ensuresperm.wf(),perm.is_pptr(*self),perm.is_init_all(),forall |i: int| 0 <= i < N ==> perm.opt_value()[i] == raw_ptr::MemContents::Init(value),Sourcepub exec fn new(dft: V) -> res : (ArrayPtr<V, N>, Tracked<PointsTo<V, N>>)where
V: Copy,
pub exec fn new(dft: V) -> res : (ArrayPtr<V, N>, Tracked<PointsTo<V, N>>)where
V: Copy,
layout::size_of::<[V; N]>() > 0,ensuresres.1@.wf(),res.1@.is_pptr(res.0),forall |i: int| {
0 <= i < N ==> #[trigger] res.1@.opt_value()[i] == raw_ptr::MemContents::Init(dft)
},Sourcepub exec fn free(self, Tracked(perm): Tracked<PointsTo<V, N>>)
pub exec fn free(self, Tracked(perm): Tracked<PointsTo<V, N>>)
perm.wf(),perm.is_pptr(self),perm.is_uninit_all(),Sourcepub exec fn insert(&self, Tracked(perm): Tracked<&mut PointsTo<V, N>>, value: V)
pub exec fn insert(&self, Tracked(perm): Tracked<&mut PointsTo<V, N>>, value: V)
old(perm).wf(),old(perm).is_pptr(*self),old(perm).is_uninit(self.index as int),self.index < N,ensuresperm.wf(),perm.is_pptr(*self),perm.is_init(self.index as int),forall |i: int| {
0 <= i < N && i != self.index ==> perm.opt_value()[i] == old(perm).opt_value()[i]
},perm.opt_value()[self.index as int] == raw_ptr::MemContents::Init(value),Insert value at index
The value is moved into the array.
Requires the slot at index to be uninitialized.
Sourcepub exec fn take_at(&self, Tracked(perm): Tracked<&mut PointsTo<V, N>>) -> res : Vwhere
V: Copy,
pub exec fn take_at(&self, Tracked(perm): Tracked<&mut PointsTo<V, N>>) -> res : Vwhere
V: Copy,
old(perm).wf(),old(perm).is_pptr(*self),old(perm).is_init(self.index as int),self.index < N,ensuresperm.wf(),perm.is_pptr(*self),perm.is_uninit(self.index as int),forall |i: int| {
0 <= i < N && i != self.index ==> perm.opt_value()[i] == old(perm).opt_value()[i]
},res == old(perm).opt_value()[self.index as int].value(),Take the value at index
The value is moved out of the array.
Requires the slot at index to be initialized.
Afterwards, the slot is uninitialized.
Sourcepub exec fn take_all(&self, Tracked(perm): Tracked<&mut PointsTo<V, N>>) -> res : [V; N]
pub exec fn take_all(&self, Tracked(perm): Tracked<&mut PointsTo<V, N>>) -> res : [V; N]
old(perm).wf(),old(perm).is_pptr(*self),old(perm).is_init_all(),ensuresperm.wf(),perm.is_pptr(*self),perm.is_uninit_all(),res@ == old(perm).value(),Take all the values of the array The values are moved out of the array. Requires all slots to be initialized. Afterwards, all slots are uninitialized.
Sourcepub exec fn into_inner(self, Tracked(perm): Tracked<PointsTo<V, N>>) -> res : [V; N]
pub exec fn into_inner(self, Tracked(perm): Tracked<PointsTo<V, N>>) -> res : [V; N]
perm.wf(),perm.is_pptr(self),perm.is_init_all(),ensuresres@ == perm.value(),Free the memory of the entire array and return the value that was previously stored in the array. Requires all slots to be initialized. Afterwards, all slots are uninitialized.
Sourcepub exec fn update(
&self,
verus_tmp_perm: Tracked<&mut PointsTo<V, N>>,
index: usize,
value: V,
) -> res : Vwhere
V: Copy,
pub exec fn update(
&self,
verus_tmp_perm: Tracked<&mut PointsTo<V, N>>,
index: usize,
value: V,
) -> res : Vwhere
V: Copy,
old(perm).wf(),old(perm).is_pptr(*self),old(perm).is_init(index as int),index < N,ensuresperm.wf(),perm.is_pptr(*self),perm.is_init(index as int),forall |i: int| {
0 <= i < N && i != index ==> perm.opt_value()[i] == old(perm).opt_value()[i]
},perm.opt_value()[index as int] == raw_ptr::MemContents::Init(value),res == old(perm).opt_value()[index as int].value(),Update the value at index with value and return the previous value
Requires the slot at index to be initialized.
Afterwards, the slot is initialized with value.
Returns the previous value.
Sourcepub exec fn borrow_at<'a>(
&self,
verus_tmp_perm: Tracked<&'a PointsTo<V, N>>,
index: usize,
) -> res : &'a V
pub exec fn borrow_at<'a>( &self, verus_tmp_perm: Tracked<&'a PointsTo<V, N>>, index: usize, ) -> res : &'a V
perm.wf(),perm.is_pptr(*self),perm.is_init(index as int),index < N,ensuresres == perm.opt_value()[index as int].value(),Get the reference of the value at index
Borrow the immutable reference of the value at index
Requires the slot at index to be initialized.
Afterwards, the slot is still initialized.
Returns the immutable reference of the value.
The reference is valid as long as the permission is alive.
The reference is not allowed to be stored.
Sourcepub exec fn borrow<'a>(
&self,
verus_tmp_perm: Tracked<&'a PointsTo<V, N>>,
) -> res : &'a [V; N]
pub exec fn borrow<'a>( &self, verus_tmp_perm: Tracked<&'a PointsTo<V, N>>, ) -> res : &'a [V; N]
perm.wf(),perm.is_pptr(*self),perm.is_init_all(),ensuresforall |i: int| 0 <= i < N ==> #[trigger] res[i] == perm.opt_value()[i].value(),Get the reference of the entire array Borrow the immutable reference of the entire array Requires all slots to be initialized. Afterwards, all slots are still initialized. Returns the immutable reference of the entire array. The reference is valid as long as the permission is alive. The reference is not allowed to be stored.
Sourcepub exec fn overwrite(
&self,
verus_tmp_perm: Tracked<&mut PointsTo<V, N>>,
index: usize,
value: V,
)
pub exec fn overwrite( &self, verus_tmp_perm: Tracked<&mut PointsTo<V, N>>, index: usize, value: V, )
old(perm).wf(),old(perm).is_pptr(*self),index < N,ensuresperm.wf(),perm.is_pptr(*self),perm.is_init(index as int),forall |i: int| {
0 <= i < N && i != index ==> perm.opt_value()[i] == old(perm).opt_value()[i]
},perm.opt_value()[index as int] == raw_ptr::MemContents::Init(value),Overwrite the entry at index with value
The pervious value will be leaked if it was initialized.
Sourcepub proof fn tracked_overwrite(tracked
&self,
tracked perm: &mut PointsTo<V, N>,
tracked index: usize,
tracked value: V,
)
pub proof fn tracked_overwrite(tracked &self, tracked perm: &mut PointsTo<V, N>, tracked index: usize, tracked value: V, )
old(perm).wf(),old(perm).is_pptr(*self),index < N,ensuresperm.wf(),perm.is_pptr(*self),perm.is_init(index as int),forall |i: int| {
0 <= i < N && i != index ==> perm.opt_value()[i] == old(perm).opt_value()[i]
},perm.opt_value()[index as int] == raw_ptr::MemContents::Init(value),Sourcepub exec fn get(&self, Tracked(perm): Tracked<&PointsTo<V, N>>, index: usize) -> res : Vwhere
V: Copy,
pub exec fn get(&self, Tracked(perm): Tracked<&PointsTo<V, N>>, index: usize) -> res : Vwhere
V: Copy,
perm.wf(),perm.is_pptr(*self),perm.is_init(index as int),index < N,ensuresres == perm.opt_value()[index as int].value(),Get the value at index and return it
The value is copied from the array
Requires the slot at index to be initialized.
Afterwards, the slot is still initialized.