diff --git a/moz-webgpu-cts/src/wpt/path.rs b/moz-webgpu-cts/src/wpt/path.rs index 7186949..7a36c78 100644 --- a/moz-webgpu-cts/src/wpt/path.rs +++ b/moz-webgpu-cts/src/wpt/path.rs @@ -78,9 +78,7 @@ impl SpecType { pub fn from_base_name(base_name: &str) -> Option<(Self, &str)> { Self::iter().find_map(|variant| { - base_name - .strip_suffix(variant.file_extension()) - .map(|some| (variant, some)) + strip_suffix_with_value(base_name, variant.file_extension(), variant) }) } @@ -432,6 +430,10 @@ impl From for RootDir { } } +fn strip_suffix_with_value<'a, T>(s: &'a str, suffix: &str, t: T) -> Option<(T, &'a str)> { + s.strip_suffix(suffix).map(|some| (t, some)) +} + #[test] fn parse_test_entry_path() { assert_eq!(