@@ -77,20 +77,26 @@ pub struct ParseIntError {
77
77
/// # Example
78
78
///
79
79
/// ```
80
+ /// #![feature(int_error_matching)]
81
+ ///
80
82
/// # fn main() {
81
83
/// if let Err(e) = i32::from_str_radix("a12", 10) {
82
84
/// println!("Failed conversion to i32: {:?}", e.kind());
83
85
/// }
84
86
/// # }
85
87
/// ```
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
+ ) ]
87
94
#[ derive( Debug , Clone , PartialEq , Eq ) ]
88
95
#[ non_exhaustive]
89
96
pub enum IntErrorKind {
90
97
/// Value being parsed is empty.
91
98
///
92
99
/// Among other causes, this variant will be constructed when parsing an empty string.
93
- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
94
100
Empty ,
95
101
/// Contains an invalid digit in its context.
96
102
///
@@ -99,25 +105,26 @@ pub enum IntErrorKind {
99
105
///
100
106
/// This variant is also constructed when a `+` or `-` is misplaced within a string
101
107
/// 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 ,
104
109
/// Integer is too large to store in target integer type.
105
- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
106
110
PosOverflow ,
107
111
/// Integer is too small to store in target integer type.
108
- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
109
112
NegOverflow ,
110
113
/// Value was Zero
111
114
///
112
115
/// This variant will be emitted when the parsing string has a value of zero, which
113
116
/// would be illegal for non-zero types.
114
- #[ stable( feature = "int_error_matching" , since = "1.47.0" ) ]
115
117
Zero ,
116
118
}
117
119
118
120
impl ParseIntError {
119
121
/// 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
+ ) ]
121
128
pub fn kind ( & self ) -> & IntErrorKind {
122
129
& self . kind
123
130
}
@@ -131,7 +138,7 @@ impl ParseIntError {
131
138
pub fn __description ( & self ) -> & str {
132
139
match self . kind {
133
140
IntErrorKind :: Empty => "cannot parse integer from empty string" ,
134
- IntErrorKind :: InvalidDigit ( _ ) => "invalid digit found in string" ,
141
+ IntErrorKind :: InvalidDigit => "invalid digit found in string" ,
135
142
IntErrorKind :: PosOverflow => "number too large to fit in target type" ,
136
143
IntErrorKind :: NegOverflow => "number too small to fit in target type" ,
137
144
IntErrorKind :: Zero => "number would be zero for non-zero type" ,
0 commit comments