From ca7090ebf45e915d4eff300bb45a9c127ed0bda7 Mon Sep 17 00:00:00 2001 From: Quinn Painter Date: Fri, 17 Feb 2023 20:37:34 +0000 Subject: [PATCH] Use str.strip_prefix instead of str.starts_with + slice --- src/internal.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/internal.rs b/src/internal.rs index 272b08eb..fdda1fd9 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -134,8 +134,7 @@ macro_rules! __impl_internal_bitflags { // If the flag starts with `0x` then it's a hex number // Parse it directly to the underlying bits type - let parsed_flag = if flag.starts_with("0x") { - let flag = &flag[2..]; + let parsed_flag = if let $crate::__private::core::option::Option::Some(flag) = flag.strip_prefix("0x") { let bits = <$T>::from_str_radix(flag, 16).map_err(|_| $crate::parser::ParseError::invalid_hex_flag(flag))?; Self::from_bits_retain(bits)