crux_cli/codegen/
indexed.rs1use std::cmp::Ordering;
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6pub struct Indexed<T> {
7 pub index: u32,
8 pub value: T,
9}
10
11impl<T: Clone> Indexed<T> {
12 pub(crate) fn inner(&self) -> T {
13 self.value.clone()
14 }
15}
16
17impl<T: Eq> Ord for Indexed<T> {
18 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
19 self.index.cmp(&other.index)
20 }
21}
22
23impl<T: Eq> PartialOrd for Indexed<T> {
24 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
25 Some(self.cmp(other))
26 }
27}