diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-10T17·59+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-08-25T11·11+0000 |
commit | fa2d250d1a65ba3bf8522fdbbe72dca21fa7ee66 (patch) | |
tree | 411a62e6428bf9baaca21223af90976f18f27efb | |
parent | 58db7e3a65ac96664ebd8c73bdff7185e59b8cff (diff) |
fix(tvix/value): explicitly delegate `Ord` to &str representation r/4474
I assumed that `Ord` is a marker trait like `Eq`, but it actually has a member. Without this ordering was incoherent. Change-Id: Id37cbdf333daf748d29b85243046c7e061b1ce29 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6139 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
-rw-r--r-- | tvix/eval/src/value/string.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs index f9178ca7f4bb..3816e89cd1b1 100644 --- a/tvix/eval/src/value/string.rs +++ b/tvix/eval/src/value/string.rs @@ -4,7 +4,7 @@ use std::{borrow::Cow, fmt::Display}; /// This module implements Nix language strings and their different /// backing implementations. -#[derive(Clone, Debug, Eq, Ord)] +#[derive(Clone, Debug)] pub enum NixString { Static(&'static str), Heap(String), @@ -16,12 +16,20 @@ impl PartialEq for NixString { } } +impl Eq for NixString {} + impl PartialOrd for NixString { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { self.as_str().partial_cmp(other.as_str()) } } +impl Ord for NixString { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.as_str().cmp(other.as_str()) + } +} + impl From<&'static str> for NixString { fn from(s: &'static str) -> Self { NixString::Static(s) |