equals implementation for literal.
This commit is contained in:
		
							parent
							
								
									6519add838
								
							
						
					
					
						commit
						bf35fd0ae4
					
				| @ -179,8 +179,28 @@ impl Walkable for OwnedLiteral { | ||||
| 
 | ||||
| impl CompareContextElement for OwnedLiteral { | ||||
|     fn equals(&self, other: &dyn ContextElement) -> bool { | ||||
|         // TODO
 | ||||
|         false | ||||
|         // If its an OwnedLiteral then compare them directly,
 | ||||
|         // otherwise defer to the other type's implementation of
 | ||||
|         // CompareContextElement since the end user could add any
 | ||||
|         // type.
 | ||||
|         match other.to_any().downcast_ref::<Self>() { | ||||
|             None => other.equals(self), | ||||
|             Some(other_literal) => match (self, other_literal) { | ||||
|                 (OwnedLiteral::LString(self_text), OwnedLiteral::LString(other_text)) => { | ||||
|                     self_text == other_text | ||||
|                 } | ||||
|                 (OwnedLiteral::LPositiveInteger(self_num), OwnedLiteral::LString(other_text)) => { | ||||
|                     &self_num.to_string() == other_text | ||||
|                 } | ||||
|                 (OwnedLiteral::LString(self_text), OwnedLiteral::LPositiveInteger(other_num)) => { | ||||
|                     self_text == &other_num.to_string() | ||||
|                 } | ||||
|                 ( | ||||
|                     OwnedLiteral::LPositiveInteger(self_num), | ||||
|                     OwnedLiteral::LPositiveInteger(other_num), | ||||
|                 ) => self_num == other_num, | ||||
|             }, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     fn partial_compare(&self, other: &dyn ContextElement) -> Option<Ordering> { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander