[]Struct near_sdk::collections::Set

pub struct Set<T> { /* fields omitted */ }

An iterable implementation of a set that stores its content directly on the trie.

Methods

impl<T> Set<T>[src]

pub fn len(&self) -> u64[src]

Returns the number of elements in the set, also referred to as its size.

pub fn new(id: Vec<u8>) -> Self[src]

Create new map with zero elements. Use id as a unique identifier.

pub fn insert_raw(&mut self, element_raw: &[u8]) -> bool[src]

Adds a value to the set. If the set did not have this value present, true is returned. If the set did have this value present, false is returned. Note, the elements that have the same hash value are undistinguished by the implementation.

pub fn remove_raw(&mut self, element_raw: &[u8]) -> bool[src]

Removes a value from the set. Returns whether the value was present in the set.

impl<T> Set<T> where
    T: BorshSerialize + BorshDeserialize
[src]

pub fn contains(&self, element: &T) -> bool[src]

Returns true if the set contains an element.

pub fn remove(&mut self, element: &T) -> bool[src]

Removes a value from the set. Returns whether the value was present in the set.

pub fn insert(&mut self, element: &T) -> bool[src]

Adds a value to the set. If the set did not have this value present, true is returned. If the set did have this value present, false is returned. Note, the elements that have the same hash value are undistinguished by the implementation.

pub fn clear(&mut self)[src]

Clears the map, removing all elements.

pub fn to_vec(&self) -> Vec<T>[src]

Copies elements into an std::vec::Vec.

pub fn iter<'a>(&'a self) -> impl Iterator<Item = T> + 'a[src]

Iterate over deserialized elements.

pub fn extend<IT: IntoIterator<Item = T>>(&mut self, iter: IT)[src]

pub fn as_vector(&self) -> &Vector<T>[src]

Returns a view of elements as a vector. It's sometimes useful to have random access to the elements.

Trait Implementations

impl<T> BorshDeserialize for Set<T> where
    Vec<u8>: BorshDeserialize,
    Vector<T>: BorshDeserialize
[src]

impl<T> BorshSerialize for Set<T> where
    Vec<u8>: BorshSerialize,
    Vector<T>: BorshSerialize
[src]

impl<T> Default for Set<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Set<T> where
    T: RefUnwindSafe

impl<T> Send for Set<T> where
    T: Send

impl<T> Sync for Set<T> where
    T: Sync

impl<T> Unpin for Set<T> where
    T: Unpin

impl<T> UnwindSafe for Set<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.