Function orx_pinned_vec::test_pinned_vec
source · pub fn test_pinned_vec<P: PinnedVec<usize>>(pinned_vec: P, test_vec_len: usize)
Expand description
Tests the pinned vector guarantees of the specific PinnedVec
implementation P
. Assertions fail if any of the guarantees are not satisfied.
To be specific on the required guarantees, let’s assume that a pinned vector pinned
currently has n
elements:
pinned.push(new_element)
: does not change the memory locations of the firstn
elements;pinned.extend_from_slice(slice)
: does not change the memory locations of the firstn
elements;pinned.insert(a, new_element)
: does not change the memory locations of the firsta
elements, wherea <= n
; elements to the right of the inserted element might be changed (commonly shifted to right).pinned.pop()
: does not change the memory locations of the firstn-1
elements (the n-th element will be removed);pinned.remove(a)
: does not change the memory locations of the firsta
elements, wherea < n
; elements to the right of the removed element might be changed (commonly shifted to left).pinned.truncate(a)
: does not change the memory locations of the firsta
elements, wherea < n
.