MCPcopy Create free account
hub / github.com/csskit/csskit / from_string_as_range

Method from_string_as_range

crates/css_feature_data/src/browser_version.rs:19–34  ·  view source on GitHub ↗
(version: &str)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

BrowserVersionClass · 0.85
collectMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected