From c5e2832cbd22354ce46a9ffefce4dc6f3afd4243 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 15 Jan 2024 14:24:20 +0200 Subject: feat(tvix/castore): implement Ord for node::Node 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 Autosubmit: flokli --- tvix/castore/src/proto/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tvix/castore') 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 { + 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. -- cgit 1.4.1