Skip to main content

vstd_extra/external/
vec.rs

1//! Trusted specifications for standard-library `Vec` operations missing from `vstd`.
2use alloc::vec::Vec;
3use core::{
4    alloc::Allocator,
5    ops::{Index, IndexMut},
6    slice::SliceIndex,
7};
8use vstd::prelude::*;
9
10verus! {
11
12/// `Vec` delegates mutable indexing to its element slice. Reuse the slice
13/// index's contract, including its bounds and updates to the borrowed elements.
14pub assume_specification<T, I: SliceIndex<[T]>, A: Allocator>[ <Vec<T, A> as IndexMut<
15    I,
16>>::index_mut ](vec: &mut Vec<T, A>, index: I) -> (output: &mut <Vec<T, A> as Index<I>>::Output)
17    ensures
18        exists|slice: &mut [T]| #[trigger]
19            slice@ == old(vec)@ && final(slice)@ == final(vec)@ && call_ensures(
20                <I as SliceIndex<[T]>>::index_mut,
21                (index, slice),
22                output,
23            ),
24;
25
26} // verus!