From 8ecafe2750caab592d130199d25a490f9dc0ca2a Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 13 Feb 2025 07:54:32 -0700 Subject: [PATCH] refactor: use `match`, instead of `if`, for `Features::from_name` --- wgpu-types/src/features.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/wgpu-types/src/features.rs b/wgpu-types/src/features.rs index c25c5a32e..5648ae36d 100644 --- a/wgpu-types/src/features.rs +++ b/wgpu-types/src/features.rs @@ -399,16 +399,14 @@ macro_rules! bitflags_array { /// Takes in a name and returns Self if it matches or none if the name does not match /// the name of any of the flags. Name is capitalisation dependent. pub fn from_name(name: &str) -> Option { - $( + match name { $( - { - if name == stringify!($Flag) { - return Some(Self::$Flag); - } - } + $( + stringify!($Flag) => Some(Self::$Flag), + )* )* - )* - None + _ => None, + } } /// Combines the features from the internal flags into the entire features struct