@@ -251,8 +251,11 @@ impl TryFrom<String> for MmcLifeTime {
251251 return Err ( eyre ! ( "Invalid number of lifetime values" ) ) ;
252252 }
253253
254- let raw_lifetime_a = u8:: from_str_radix ( tokens[ 0 ] , 16 ) ?;
255- let raw_lifetime_b = u8:: from_str_radix ( tokens[ 1 ] , 16 ) ?;
254+ let stripped_lifetime_a = tokens[ 0 ] . strip_prefix ( "0x" ) . unwrap_or ( tokens[ 0 ] ) ;
255+ let stripped_lifetime_b = tokens[ 1 ] . strip_prefix ( "0x" ) . unwrap_or ( tokens[ 1 ] ) ;
256+
257+ let raw_lifetime_a = u8:: from_str_radix ( stripped_lifetime_a, 16 ) ?;
258+ let raw_lifetime_b = u8:: from_str_radix ( stripped_lifetime_b, 16 ) ?;
256259
257260 let lifetime_a_pct = raw_lifetime_to_pct ( raw_lifetime_a) ;
258261 let lifetime_b_pct = raw_lifetime_to_pct ( raw_lifetime_b) ;
@@ -407,6 +410,7 @@ mod test {
407410 #[ case( String :: from( "4 5\n " ) , Ok ( MmcLifeTime :: new( Some ( 30 ) , Some ( 40 ) ) ) ) ]
408411 #[ case( String :: from( "\t 4 5" ) , Ok ( MmcLifeTime :: new( Some ( 30 ) , Some ( 40 ) ) ) ) ]
409412 #[ case( String :: from( "4 5" ) , Ok ( MmcLifeTime :: new( Some ( 30 ) , Some ( 40 ) ) ) ) ]
413+ #[ case( String :: from( "0x4 0x5" ) , Ok ( MmcLifeTime :: new( Some ( 30 ) , Some ( 40 ) ) ) ) ]
410414 fn test_lifetime_from_sysfs_string (
411415 #[ case] input_string : String ,
412416 #[ case] expected : Result < MmcLifeTime > ,
0 commit comments