@@ -7,7 +7,7 @@ struct NoDigitError<'a>(#[allow(dead_code)] &'a str);
77
88const DIGITS : & str = r"([0-9]|one|two|three|four|five|six|seven|eight|nine)" ;
99
10- fn from_digit ( s : & str ) -> Result < u64 , NoDigitError > {
10+ fn from_digit ( s : & ' _ str ) -> Result < u64 , NoDigitError < ' _ > > {
1111 Ok ( match s {
1212 "0" => 0 ,
1313 "1" | "one" => 1 ,
@@ -23,23 +23,23 @@ fn from_digit(s: &str) -> Result<u64, NoDigitError> {
2323 } )
2424}
2525
26- fn first_digit ( s : & str ) -> Result < u64 , NoDigitError > {
26+ fn first_digit ( s : & ' _ str ) -> Result < u64 , NoDigitError < ' _ > > {
2727 static RE : LazyLock < Regex > =
2828 LazyLock :: new ( || Regex :: new ( & [ r"^.*?" , DIGITS , r".*$" ] . join ( "" ) ) . unwrap ( ) ) ;
2929 let captures = RE . captures ( s) . ok_or ( NoDigitError ( s) ) ?;
3030 let m = captures. get ( 1 ) . unwrap ( ) ;
3131 from_digit ( m. as_str ( ) )
3232}
3333
34- fn last_digit ( s : & str ) -> Result < u64 , NoDigitError > {
34+ fn last_digit ( s : & ' _ str ) -> Result < u64 , NoDigitError < ' _ > > {
3535 static RE : LazyLock < Regex > =
3636 LazyLock :: new ( || Regex :: new ( & [ r"^.*" , DIGITS , r".*?$" ] . join ( "" ) ) . unwrap ( ) ) ;
3737 let captures = RE . captures ( s) . ok_or ( NoDigitError ( s) ) ?;
3838 let m = captures. get ( 1 ) . unwrap ( ) ;
3939 from_digit ( m. as_str ( ) )
4040}
4141
42- fn calibration_value ( s : & str ) -> Result < u64 , NoDigitError > {
42+ fn calibration_value ( s : & ' _ str ) -> Result < u64 , NoDigitError < ' _ > > {
4343 Ok ( first_digit ( s) ? * 10 + last_digit ( s) ?)
4444}
4545
0 commit comments