Set of non-duplicate items for CosmWasm smart contract store.
```rust use cosmwasmstd::{DepsMut, Order, StdResult}; use cwitem_set::Set;
const VALIDATORS: Set<&str> = Set::new("validators", "validators__counter");
fn example(deps: DepsMut) -> StdResult<()> { // add a new item to the set VALIDATORS.insert(deps.storage, "larry")?;
// remove an existing item from the set
VALIDATORS.remove(deps.storage, "jake")?;
// check whether an item is in the set
let is_whitelisted = VALIDATORS.contains(deps.as_ref().storage, "pumpkin");
// check the total number of of items in the set
let num_validators = VALIDATORS.count(deps.as_ref().storage)?;
// enumerate items in the set
VALIDATORS
.items(deps.as_ref().storage, None, None, Order::Ascending)
.for_each(|validator| {
println!("{} is whitelisted!", validator);
});
// delete all items in the set
VALIDATORS.clear(deps.storage);
Ok(())
} ```
Contents of this crate are open source under GNU Affero General Public License v3 or later.