bevy_ecs/schedule/graph/
node.rs1use core::fmt::Debug;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
7pub enum NodeId {
8 System(usize),
10 Set(usize),
12}
13
14impl NodeId {
15 pub const fn index(&self) -> usize {
17 match self {
18 NodeId::System(index) | NodeId::Set(index) => *index,
19 }
20 }
21
22 pub const fn is_system(&self) -> bool {
24 matches!(self, NodeId::System(_))
25 }
26
27 pub const fn is_set(&self) -> bool {
29 matches!(self, NodeId::Set(_))
30 }
31
32 pub const fn cmp(&self, other: &Self) -> core::cmp::Ordering {
34 use core::cmp::Ordering::{Equal, Greater, Less};
35 use NodeId::{Set, System};
36
37 match (self, other) {
38 (System(a), System(b)) | (Set(a), Set(b)) => match a.checked_sub(*b) {
39 None => Less,
40 Some(0) => Equal,
41 Some(_) => Greater,
42 },
43 (System(_), Set(_)) => Less,
44 (Set(_), System(_)) => Greater,
45 }
46 }
47}