Parses a string `s` as a boolean.
(s: &str)
| 37 | |
| 38 | /// Parses a string `s` as a boolean. |
| 39 | pub fn parse_boolean(s: &str) -> Result<bool, String> { |
| 40 | let raw = s.to_uppercase(); |
| 41 | if raw == "TRUE" || raw == "YES" || raw == "Y" { |
| 42 | Ok(true) |
| 43 | } else if raw == "FALSE" || raw == "NO" || raw == "N" { |
| 44 | Ok(false) |
| 45 | } else { |
| 46 | Err(format!("Invalid boolean literal {}", s)) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// Formats a double `d` for display. |
| 51 | pub fn format_double(d: f64) -> String { |
no outgoing calls
no test coverage detected