fix(tvix/value): explicitly delegate Ord to &str representation
				
					
				
			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>
This commit is contained in:
		
							parent
							
								
									58db7e3a65
								
							
						
					
					
						commit
						fa2d250d1a
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		|  | @ -4,7 +4,7 @@ use std::{borrow::Cow, fmt::Display}; | ||||||
| /// This module implements Nix language strings and their different
 | /// This module implements Nix language strings and their different
 | ||||||
| /// backing implementations.
 | /// backing implementations.
 | ||||||
| 
 | 
 | ||||||
| #[derive(Clone, Debug, Eq, Ord)] | #[derive(Clone, Debug)] | ||||||
| pub enum NixString { | pub enum NixString { | ||||||
|     Static(&'static str), |     Static(&'static str), | ||||||
|     Heap(String), |     Heap(String), | ||||||
|  | @ -16,12 +16,20 @@ impl PartialEq for NixString { | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl Eq for NixString {} | ||||||
|  | 
 | ||||||
| impl PartialOrd for NixString { | impl PartialOrd for NixString { | ||||||
|     fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { |     fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | ||||||
|         self.as_str().partial_cmp(other.as_str()) |         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 { | impl From<&'static str> for NixString { | ||||||
|     fn from(s: &'static str) -> Self { |     fn from(s: &'static str) -> Self { | ||||||
|         NixString::Static(s) |         NixString::Static(s) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue