(version: &str)
| 17 | } |
| 18 | |
| 19 | pub fn from_string_as_range(version: &str) -> Result<(Self, Self), ParseIntError> { |
| 20 | if version == "all" { |
| 21 | return Ok((BrowserVersion(0, 0), BrowserVersion(u16::MAX, u16::MAX))); |
| 22 | } |
| 23 | let parts: Vec<&str> = version.split('-').collect(); |
| 24 | if parts.is_empty() || parts.len() < 2 { |
| 25 | let res = Self::from_string(version)?; |
| 26 | return Ok((res, res)); |
| 27 | } |
| 28 | let first = Self::from_string(parts[0])?; |
| 29 | let second = Self::from_string(parts[1])?; |
| 30 | if first > second { |
| 31 | return Ok((second, first)); |
| 32 | } |
| 33 | Ok((first, second)) |
| 34 | } |
| 35 | |
| 36 | pub fn in_range(self, range: (Self, Self)) -> bool { |
| 37 | range.0 < self && self < range.1 |
nothing calls this directly
no test coverage detected