@@ -77,20 +77,26 @@ pub struct ParseIntError {
7777/// # Example
7878///
7979/// ```
80+ /// #![feature(int_error_matching)]
81+ ///
8082/// # fn main() {
8183/// if let Err(e) = i32::from_str_radix("a12", 10) {
8284/// println!("Failed conversion to i32: {:?}", e.kind());
8385/// }
8486/// # }
8587/// ```
86- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
88+ #[ unstable(
89+ feature = "int_error_matching" ,
90+ reason = "it can be useful to match errors when making error messages \
91+ for integer parsing",
92+ issue = "22639"
93+ ) ]
8794#[ derive( Debug , Clone , PartialEq , Eq ) ]
8895#[ non_exhaustive]
8996pub enum IntErrorKind {
9097 /// Value being parsed is empty.
9198 ///
9299 /// Among other causes, this variant will be constructed when parsing an empty string.
93- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
94100 Empty ,
95101 /// Contains an invalid digit in its context.
96102 ///
@@ -99,25 +105,26 @@ pub enum IntErrorKind {
99105 ///
100106 /// This variant is also constructed when a `+` or `-` is misplaced within a string
101107 /// either on its own or in the middle of a number.
102- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
103- InvalidDigit ( #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ] char ) ,
108+ InvalidDigit ,
104109 /// Integer is too large to store in target integer type.
105- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
106110 PosOverflow ,
107111 /// Integer is too small to store in target integer type.
108- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
109112 NegOverflow ,
110113 /// Value was Zero
111114 ///
112115 /// This variant will be emitted when the parsing string has a value of zero, which
113116 /// would be illegal for non-zero types.
114- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
115117 Zero ,
116118}
117119
118120impl ParseIntError {
119121 /// Outputs the detailed cause of parsing an integer failing.
120- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
122+ #[ unstable(
123+ feature = "int_error_matching" ,
124+ reason = "it can be useful to match errors when making error messages \
125+ for integer parsing",
126+ issue = "22639"
127+ ) ]
121128 pub fn kind ( & self ) -> & IntErrorKind {
122129 & self . kind
123130 }
@@ -131,7 +138,7 @@ impl ParseIntError {
131138 pub fn __description ( & self ) -> & str {
132139 match self . kind {
133140 IntErrorKind :: Empty => "cannot parse integer from empty string" ,
134- IntErrorKind :: InvalidDigit ( _ ) => "invalid digit found in string" ,
141+ IntErrorKind :: InvalidDigit => "invalid digit found in string" ,
135142 IntErrorKind :: PosOverflow => "number too large to fit in target type" ,
136143 IntErrorKind :: NegOverflow => "number too small to fit in target type" ,
137144 IntErrorKind :: Zero => "number would be zero for non-zero type" ,
0 commit comments