identified_vec 0.1.11

Like HashSet but retaining INSERTION order and without `Hash` requirement on the Element type.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fmt::Debug;
use std::hash::Hash;

/// The `Identifiable` trait allows you to use the
/// `IdentifiedVecOf<User> instead of the more verbose
/// `IdentifiedVec<SomeUserID, User>` but also allows you to
/// skip the `id_of_element: fn(&Element) -> ID` closure when
/// initializing a new identified vec.
pub trait Identifiable {
    /// The type that your `Element` will use as its globally unique and stable ID,
    /// must impl `Hash` since it is used as a key in `IdentifiedVecOf`'s internal
    /// `HashMap`. Must impl `Clone` since we need to be able to clone it as a key
    type ID: Eq + Hash + Clone + Debug;

    /// Return `Element`'s globally unique and stable ID, used to uniquely identify
    /// the `Element` in the `IdentifiedVecOf` collection of elements.
    fn id(&self) -> Self::ID;
}