Dup-Indexer

CI build crates.io version docs.rs docs

Create a non-duplicated vector of values without extra memory allocations, even for ref values like String, Vec, and Box. The resulting vector is guaranteed to be in the same order as the original insertion order.

This approach is useful for creating a vector of unique values, such as a list of unique strings, or a list of unique objects, and then using the index of the value in the vector as a unique identifier, e.g. in a protobuf message.

Example

```rust use dup_indexer::DupIndexer;

fn main() { let mut di = DupIndexer::new(); asserteq!(0, di.insertstring("hello".tostring())); asserteq!(1, di.insertstring("world".tostring())); asserteq!(0, di.insertstring("hello".tostring())); // try inserting "hello" again asserteq!(di.intovec(), vec!["hello".tostring(), "world".to_string()]); } ```