about summary refs log tree commit diff
path: root/tvix/castore
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-01-15T12·24+0200
committerclbot <clbot@tvl.fyi>2024-01-15T18·19+0000
commitc5e2832cbd22354ce46a9ffefce4dc6f3afd4243 (patch)
tree773df00a129d44fe84cb2781aaedc7f5333ff83e /tvix/castore
parent2750e1e640f5228afe1efcdb4deb4922887d0121 (diff)
feat(tvix/castore): implement Ord for node::Node r/7380
This allows assembling BTreeSets of node::Node.

Change-Id: I97b83be5ffc3e891307a8ef2b5fc31e38b747a62
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10625
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/castore')
-rw-r--r--tvix/castore/src/proto/mod.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tvix/castore/src/proto/mod.rs b/tvix/castore/src/proto/mod.rs
index 9c4df4df53c2..edf042e3dfa6 100644
--- a/tvix/castore/src/proto/mod.rs
+++ b/tvix/castore/src/proto/mod.rs
@@ -159,6 +159,20 @@ impl node::Node {
     }
 }
 
+impl Eq for node::Node {}
+
+impl PartialOrd for node::Node {
+    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
+        Some(self.cmp(other))
+    }
+}
+
+impl Ord for node::Node {
+    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+        self.get_name().cmp(other.get_name())
+    }
+}
+
 /// Accepts a name, and a mutable reference to the previous name.
 /// If the passed name is larger than the previous one, the reference is updated.
 /// If it's not, an error is returned.