(output: &str)
| 2117 | } |
| 2118 | |
| 2119 | fn parse_android_rounded_corners(output: &str) -> Option<AndroidCornerRadii> { |
| 2120 | let mut radii = AndroidCornerRadii::ZERO; |
| 2121 | let mut found = false; |
| 2122 | |
| 2123 | for chunk in output.split("RoundedCorner{").skip(1) { |
| 2124 | let section = chunk.split('}').next().unwrap_or(chunk); |
| 2125 | let Some(position) = parse_named_value(section, "position=") else { |
| 2126 | continue; |
| 2127 | }; |
| 2128 | let Some(radius) = |
| 2129 | parse_named_value(section, "radius=").and_then(|value| value.parse::<f64>().ok()) |
| 2130 | else { |
| 2131 | continue; |
| 2132 | }; |
| 2133 | match position { |
| 2134 | "TopLeft" => radii.top_left = radius, |
| 2135 | "TopRight" => radii.top_right = radius, |
| 2136 | "BottomRight" => radii.bottom_right = radius, |
| 2137 | "BottomLeft" => radii.bottom_left = radius, |
| 2138 | _ => continue, |
| 2139 | } |
| 2140 | found = true; |
| 2141 | } |
| 2142 | |
| 2143 | found.then_some(radii) |
| 2144 | } |
| 2145 | |
| 2146 | fn parse_named_value<'a>(input: &'a str, key: &str) -> Option<&'a str> { |
| 2147 | let (_, value) = input.split_once(key)?; |
no test coverage detected