| 76 | } |
| 77 | |
| 78 | fn div_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 79 | if let Some(other_int) = other.as_any().downcast_ref::<IntValue>() { |
| 80 | if other_int.value == 0 { |
| 81 | return Err("Can't perform `/` operator with 0 value".to_string()); |
| 82 | } |
| 83 | let value = self.value / other_int.value; |
| 84 | return Ok(Box::new(IntValue::new(value))); |
| 85 | } |
| 86 | Err("Unexpected type to perform `/` with".to_string()) |
| 87 | } |
| 88 | |
| 89 | fn rem_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 90 | if let Some(other_int) = other.as_any().downcast_ref::<IntValue>() { |