scsys_core/id/
mod.rs

1/*
2    Appellation: ids <module>
3    Contrib: FL03 <jo3mccain@icloud.com>
4*/
5//! # Identity
6//!
7//! The identity module provides a set of traits and types for generating unique identifiers.
8#[doc(inline)]
9pub use self::{kinds::*, traits::*};
10
11pub(crate) mod traits;
12
13mod kinds {
14    pub use self::{atomic::AtomicId, indexed::IndexId};
15
16    pub mod atomic;
17    pub mod indexed;
18
19    pub(crate) mod prelude {
20        pub use super::atomic::AtomicId;
21        pub use super::indexed::IndexId;
22    }
23}
24
25pub(crate) mod prelude {
26    pub use super::kinds::prelude::*;
27    pub use super::traits::*;
28}
29
30#[cfg(test)]
31mod tests {
32    use super::traits::*;
33    use super::AtomicId;
34
35    #[test]
36    fn test_id() {
37        let id = 0usize.get();
38        assert_eq!(id, &0);
39        let atomic = AtomicId::new();
40        let aid = Id::<usize>::get(&atomic);
41        assert_ne!(*aid, *id);
42    }
43}