zaxis 0.0.5

An event-driven immediate mode GUI for desktop tools
Documentation
//! Stable widget identities and scoped hashing.

use std::hash::{Hash, Hasher};

/// Stable widget identity. Scope child IDs to their parent using [`Id::with`].
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Id(u64);

impl Id {
    pub fn new(value: impl Hash) -> Self {
        let mut hasher = std::collections::hash_map::DefaultHasher::new();
        value.hash(&mut hasher);
        Self(hasher.finish())
    }

    pub fn with(self, value: impl Hash) -> Self {
        Self::new((self, value))
    }
    /// The id with this exact value, for a number that came from `value()`.
    pub(crate) fn from_raw(value: u64) -> Self {
        Self(value)
    }
    pub fn value(self) -> u64 {
        self.0
    }
}