Skip to content

Commit

Permalink
clippy: Fix manual_pattern_char_comparison lint (#625)
Browse files Browse the repository at this point in the history
Using this pattern of code allows for more efficient code and is more
concise.

This is a lint that slated to be added in 1.80.
  • Loading branch information
waywardmonkeys authored Jul 15, 2024
1 parent ccec1a4 commit d2c1195
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions examples/scenes/src/pico_svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn parse_transform(transform: &str) -> Affine {
for ts in transform.split(')').map(str::trim) {
nt *= if let Some(s) = ts.strip_prefix("matrix(") {
let vals = s
.split(|c| matches!(c, ',' | ' '))
.split([',', ' '])
.map(str::parse)
.collect::<Result<Vec<f64>, _>>()
.expect("Could parse all values of 'matrix' as floats");
Expand All @@ -209,7 +209,7 @@ fn parse_transform(transform: &str) -> Affine {
)
} else if let Some(s) = ts.strip_prefix("translate(") {
if let Ok(vals) = s
.split(|c| matches!(c, ',' | ' '))
.split([',', ' '])
.map(str::trim)
.map(str::parse)
.collect::<Result<Vec<f64>, _>>()
Expand All @@ -223,7 +223,7 @@ fn parse_transform(transform: &str) -> Affine {
}
} else if let Some(s) = ts.strip_prefix("scale(") {
if let Ok(vals) = s
.split(|c| matches!(c, ',' | ' '))
.split([',', ' '])
.map(str::trim)
.map(str::parse)
.collect::<Result<Vec<f64>, _>>()
Expand Down Expand Up @@ -263,10 +263,7 @@ fn parse_color(color: &str) -> Color {
if let Some(c) = Color::parse(color) {
c
} else if let Some(s) = color.strip_prefix("rgb(").and_then(|s| s.strip_suffix(')')) {
let mut iter = s
.split(|c| matches!(c, ',' | ' '))
.map(str::trim)
.map(u8::from_str);
let mut iter = s.split([',', ' ']).map(str::trim).map(u8::from_str);

let r = iter.next().unwrap().unwrap();
let g = iter.next().unwrap().unwrap();
Expand Down

0 comments on commit d2c1195

Please sign in to comment.