pub struct LookupSet<T, H = Identity> where
T: BorshSerialize + Ord,
H: ToKey, { /* private fields */ }
Implementations
sourceimpl<T> LookupSet<T, Identity> where
T: BorshSerialize + Ord,
impl<T> LookupSet<T, Identity> where
T: BorshSerialize + Ord,
sourcepub fn new<S>(prefix: S) -> Self where
S: IntoStorageKey,
pub fn new<S>(prefix: S) -> Self where
S: IntoStorageKey,
Initialize new LookupSet
with the prefix provided.
This prefix can be anything that implements IntoStorageKey
. The prefix is used when
storing and looking up values in storage to ensure no collisions with other collections.
sourceimpl<T, H> LookupSet<T, H> where
T: BorshSerialize + Ord,
H: ToKey,
impl<T, H> LookupSet<T, H> where
T: BorshSerialize + Ord,
H: ToKey,
sourcepub fn with_hasher<S>(prefix: S) -> Self where
S: IntoStorageKey,
pub fn with_hasher<S>(prefix: S) -> Self where
S: IntoStorageKey,
sourcepub fn contains<Q: ?Sized>(&self, value: &Q) -> bool where
T: Borrow<Q>,
Q: BorshSerialize + ToOwned<Owned = T> + Ord,
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool where
T: Borrow<Q>,
Q: BorshSerialize + ToOwned<Owned = T> + Ord,
Returns true
if the set contains the specified value.
The value may be any borrowed form of the set’s value type, but
BorshSerialize
, ToOwned<Owned = T>
and Ord
on the borrowed form must
match those for the value type.
sourcepub fn insert(&mut self, value: T) -> bool where
T: Clone,
pub fn insert(&mut self, value: T) -> bool where
T: Clone,
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.
sourcepub fn put(&mut self, value: T)
pub fn put(&mut self, value: T)
Puts the given value into the set.
This function will not return whether the passed value was already in the set.
Use LookupSet::insert
if you need that.
sourcepub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool where
T: Borrow<Q>,
Q: BorshSerialize + ToOwned<Owned = T> + Ord,
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool where
T: Borrow<Q>,
Q: BorshSerialize + ToOwned<Owned = T> + Ord,
Removes a value from the set. Returns whether the value was present in the set.
The value may be any borrowed form of the set’s value type, but
BorshSerialize
, ToOwned<Owned = K>
and Ord
on the borrowed form must
match those for the value type.
Trait Implementations
sourceimpl<T, H> BorshDeserialize for LookupSet<T, H> where
T: BorshSerialize + Ord,
H: ToKey,
Box<[u8]>: BorshDeserialize,
impl<T, H> BorshDeserialize for LookupSet<T, H> where
T: BorshSerialize + Ord,
H: ToKey,
Box<[u8]>: BorshDeserialize,
sourceimpl<T, H> BorshSerialize for LookupSet<T, H> where
T: BorshSerialize + Ord,
H: ToKey,
Box<[u8]>: BorshSerialize,
impl<T, H> BorshSerialize for LookupSet<T, H> where
T: BorshSerialize + Ord,
H: ToKey,
Box<[u8]>: BorshSerialize,
sourceimpl<T, H> Extend<T> for LookupSet<T, H> where
T: BorshSerialize + Ord,
H: ToKey,
impl<T, H> Extend<T> for LookupSet<T, H> where
T: BorshSerialize + Ord,
H: ToKey,
sourcefn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations
impl<T, H = Identity> !RefUnwindSafe for LookupSet<T, H>
impl<T, H> Send for LookupSet<T, H> where
H: Send,
T: Send,
impl<T, H = Identity> !Sync for LookupSet<T, H>
impl<T, H> Unpin for LookupSet<T, H> where
H: Unpin,
impl<T, H> UnwindSafe for LookupSet<T, H> where
H: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more