feat(tazjin/rlox): Implement PartialEq for interpreter::Value
Values have equality, unless they're functions. Change-Id: Ie5c623081a1fa556e6b7a5251b0ce85af68dd31a Reviewed-on: https://cl.tvl.fyi/c/depot/+/2385 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									9b477975d4
								
							
						
					
					
						commit
						0c1c4584cb
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -38,6 +38,16 @@ pub enum Value {
 | 
			
		|||
    Callable(Callable),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl PartialEq for Value {
 | 
			
		||||
    fn eq(&self, other: &Self) -> bool {
 | 
			
		||||
        match (self, other) {
 | 
			
		||||
            (Value::Literal(lhs), Value::Literal(rhs)) => lhs == rhs,
 | 
			
		||||
            // functions do not have equality
 | 
			
		||||
            _ => false,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl From<Literal> for Value {
 | 
			
		||||
    fn from(lit: Literal) -> Value {
 | 
			
		||||
        Value::Literal(lit)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue