Expand description
The methods and macros provided directly in this index_set
module (new
, with_capacity
) work in both std and no-std modes - unlike the
corresponding methods on IndexSet
itself.
Unfortunately IndexSet
is very hard to use from no-std (see docs
and relevant github issue). It uses a weird build.rs script to detect if no-std is present, which
is hard to force unless you explicitly do eg a WASM build and see that it’s missing.
You can use these methods as follows:
use sbor::rust::collections::*;
let index_set: IndexSet<K> = index_set_new();
let index_set: IndexSet<K> = index_set_with_capacity(n);
let index_set = indexset!(1u32, 2u32);
Macros§
Functions§
- This is safe for std and no-std use cases (unlike
IndexSet::new
which disappears when std is not in the toolchain - see this article for deep technical reasons) - This is safe for std and no-std use cases (unlike
IndexSet::with_capacity
which disappears when std is not in the toolchain - see this article for deep technical reasons)