@@ -40,9 +40,6 @@ pub enum DecodeError {
4040 /// The decoded number cannot fit into a [`u128`].
4141 ArithmeticOverflow ,
4242
43- /// The encoded input is an empty string.
44- EmptyInput ,
45-
4643 /// The encoded input contains the given invalid byte at the given index.
4744 InvalidBase62Byte ( u8 , usize ) ,
4845}
@@ -53,7 +50,6 @@ impl core::fmt::Display for DecodeError {
5350 DecodeError :: ArithmeticOverflow => {
5451 f. write_str ( "Decoded number cannot fit into a `u128`" )
5552 }
56- DecodeError :: EmptyInput => f. write_str ( "Encoded input is an empty string" ) ,
5753 DecodeError :: InvalidBase62Byte ( ch, idx) => {
5854 use core:: fmt:: Write ;
5955
@@ -346,7 +342,7 @@ macro_rules! internal_decoder_fn {
346342 ( $fn_name: ident, $numeric_start_value: literal, $uppercase_start_value: literal, $lowercase_start_value: literal) => {
347343 fn $fn_name( mut input: & [ u8 ] ) -> Result <u128 , DecodeError > {
348344 if input. is_empty( ) {
349- return Err ( DecodeError :: EmptyInput ) ;
345+ return Ok ( 0 ) ;
350346 }
351347
352348 // Remove leading zeroes
@@ -825,7 +821,7 @@ mod tests {
825821
826822 quickcheck ! {
827823 fn decode_bad( input: Vec <u8 >) -> TestResult {
828- if !input . is_empty ( ) && input. iter( ) . all( |ch| ch. is_ascii_alphanumeric( ) ) {
824+ if input. iter( ) . all( |ch| ch. is_ascii_alphanumeric( ) ) {
829825 TestResult :: discard( )
830826 } else {
831827 TestResult :: from_bool( decode( & input) . is_err( ) )
@@ -835,7 +831,7 @@ mod tests {
835831
836832 quickcheck ! {
837833 fn decode_good( input: Vec <u8 >) -> TestResult {
838- if !input . is_empty ( ) && input. iter( ) . all( |ch| ch. is_ascii_alphanumeric( ) ) {
834+ if input. iter( ) . all( |ch| ch. is_ascii_alphanumeric( ) ) {
839835 TestResult :: from_bool( decode( & input) . is_ok( ) )
840836 } else {
841837 TestResult :: discard( )
@@ -882,7 +878,7 @@ mod tests {
882878
883879 #[ test]
884880 fn test_decode_empty_input ( ) {
885- assert_eq ! ( decode( "" ) , Err ( DecodeError :: EmptyInput ) ) ;
881+ assert_eq ! ( decode( "" ) , Ok ( 0 ) ) ;
886882 }
887883
888884 #[ test]
@@ -967,7 +963,7 @@ mod tests {
967963
968964 #[ test]
969965 fn test_decode_alternative_empty_input ( ) {
970- assert_eq ! ( decode_alternative( "" ) , Err ( DecodeError :: EmptyInput ) ) ;
966+ assert_eq ! ( decode_alternative( "" ) , Ok ( 0 ) ) ;
971967 }
972968
973969 #[ test]
0 commit comments