Skip to main content

euv_core/scene/id/
impl.rs

1use super::*;
2
3/// Indexing utilities for `NodeId`.
4impl NodeId {
5    /// Converts the node slot index to `usize`.
6    ///
7    /// # Arguments
8    ///
9    /// - `&Self` - Node handle.
10    ///
11    /// # Returns
12    ///
13    /// - `usize` - Zero-based arena vector index.
14    #[must_use]
15    pub fn as_usize(&self) -> usize {
16        self.get_index() as usize
17    }
18
19    /// Returns true when the handle carries a non-zero generation tag.
20    ///
21    /// # Arguments
22    ///
23    /// - `&Self` - Node handle.
24    ///
25    /// # Returns
26    ///
27    /// - `bool` - True when non-null.
28    #[must_use]
29    pub fn is_valid(&self) -> bool {
30        self.get_generation() != 0
31    }
32}