(
value: &str,
cast_options: &CastOptions,
)
| 411 | |
| 412 | #[inline] |
| 413 | fn cast_single_string_to_boolean( |
| 414 | value: &str, |
| 415 | cast_options: &CastOptions, |
| 416 | ) -> Result<Option<bool>, ArrowError> { |
| 417 | match value.to_ascii_lowercase().trim() { |
| 418 | "t" | "tr" | "tru" | "true" | "y" | "ye" | "yes" | "on" | "1" => Ok(Some(true)), |
| 419 | "f" | "fa" | "fal" | "fals" | "false" | "n" | "no" | "of" | "off" | "0" => Ok(Some(false)), |
| 420 | invalid_value => match cast_options.safe { |
| 421 | true => Ok(None), |
| 422 | false => Err(ArrowError::CastError(format!( |
| 423 | "Cannot cast value '{invalid_value}' to value of Boolean type", |
| 424 | ))), |
| 425 | }, |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | /// Cast a single string to boolean with default cast option(safe=true). |
| 430 | pub fn cast_single_string_to_boolean_default(value: &str) -> Option<bool> { |
no test coverage detected