(&self, target_type: &Box<dyn DataType>)
| 364 | } |
| 365 | |
| 366 | fn cast_op(&self, target_type: &Box<dyn DataType>) -> Result<Box<dyn Value>, String> { |
| 367 | // Cast to Boolean |
| 368 | if target_type.is_bool() { |
| 369 | let value = self.value != 0; |
| 370 | return Ok(Box::new(BoolValue::new(value))); |
| 371 | } |
| 372 | |
| 373 | // Cast to Float |
| 374 | if target_type.is_float() { |
| 375 | let value = self.value as f64; |
| 376 | return Ok(Box::new(FloatValue { value })); |
| 377 | } |
| 378 | |
| 379 | Err("Unexpected value to perform `CAST` with".to_string()) |
| 380 | } |
| 381 | } |