Struct StringHashSet

Source
pub struct StringHashSet { /* private fields */ }
Expand description

StringHashSet is a trusted wrapper around std::collections::HashSet<String> with View implemented for the type vstd::map::Set<Seq<char>>.

This type was created for ease of use with String as it uses &str instead of &String for methods that require shared references. Also, it assumes that obeys_key_model::<String>() holds.

See the Rust documentation for HashSet for details about its implementation.

If you are using std::collections::HashSet directly, see ExHashSet for information on the Verus specifications for this type.

Implementations§

Source§

impl StringHashSet

Source

pub exec fn new() -> result : Self

ensures
result@ == Set::<Seq<char>>::empty(),

Creates an empty StringHashSet with capacity 0.

See Rust’s HashSet::new() for implementation details.

Source

pub exec fn with_capacity(capacity: usize) -> result : Self

ensures
result@ == Set::<Seq<char>>::empty(),

Creates an empty StringHashSet with at least capacity for the specified number of elements.

See Rust’s HashSet::with_capacity() for implementation details.

Source

pub exec fn reserve(&mut self, additional: usize)

ensures
self@ == old(self)@,

Reserves capacity for at least additional number of elements in the set.

See Rust’s HashSet::reserve() for implementation details.

Source

pub exec fn is_empty(&self) -> result : bool

ensures
result == self@.is_empty(),

Returns true if the set is empty.

Source

pub uninterp fn spec_len(&self) -> usize

Returns the number of elements in the set.

Source

pub exec fn len(&self) -> result : usize

ensures
result == self@.len(),

Returns the number of elements in the set.

Source

pub exec fn insert(&mut self, k: String) -> result : bool

ensures
self@ == old(self)@.insert(k@) && result == !old(self)@.contains(k@),

Inserts the given value into the set. Returns true if the value was not previously in the set, false otherwise.

See Rust’s HashSet::insert() for implementation details.

Source

pub exec fn remove(&mut self, k: &str) -> result : bool

ensures
self@ == old(self)@.remove(k@) && result == old(self)@.contains(k@),

Removes the given value from the set. Returns true if the value was previously in the set, false otherwise.

See Rust’s HashSet::remove() for implementation details.

Source

pub exec fn contains(&self, k: &str) -> result : bool

ensures
result == self@.contains(k@),

Returns true if the set contains the given value.

See Rust’s HashSet::contains() for implementation details.

Source

pub exec fn get<'a>(&'a self, k: &str) -> result : Option<&'a String>

ensures
match result {
    Some(v) => self@.contains(k@) && v@ == k@,
    None => !self@.contains(k@),
},

Returns a reference to the value in the set that is equal to the given value. If the value is not present in the set, returns None.

See Rust’s HashSet::get() for implementation details.

Source

pub exec fn clear(&mut self)

ensures
self@ == Set::<Seq<char>>::empty(),

Clears all values from the set.

See Rust’s HashSet::clear() for implementation details.

Trait Implementations§

Source§

impl View for StringHashSet

Source§

uninterp fn view(&self) -> Self::V

Source§

type V = Set<Seq<char>>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.