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

Method from_string

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

Source from the content-addressed store, hash-verified

7
8impl BrowserVersion {
9 pub fn from_string(version: &str) -> Result<Self, ParseIntError> {
10 let parts: Vec<&str> = version.split('.').collect();
11 if parts.is_empty() {
12 return Ok(BrowserVersion(version.parse()?, 0));
13 }
14 let major: u16 = parts[0].parse()?;
15 let minor: u16 = if parts.len() > 1 { parts[1].parse()? } else { 0 };
16 Ok(Self(major, minor))
17 }
18
19 pub fn from_string_as_range(version: &str) -> Result<(Self, Self), ParseIntError> {
20 if version == "all" {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected