stabilize int_error_matching
This commit is contained in:
@@ -74,26 +74,20 @@ pub struct ParseIntError {
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(int_error_matching)]
|
||||
///
|
||||
/// # fn main() {
|
||||
/// if let Err(e) = i32::from_str_radix("a12", 10) {
|
||||
/// println!("Failed conversion to i32: {:?}", e.kind());
|
||||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
#[unstable(
|
||||
feature = "int_error_matching",
|
||||
reason = "it can be useful to match errors when making error messages \
|
||||
for integer parsing",
|
||||
issue = "22639"
|
||||
)]
|
||||
#[stable(feature = "int_error_matching", since = "1.54.0")]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum IntErrorKind {
|
||||
/// Value being parsed is empty.
|
||||
///
|
||||
/// Among other causes, this variant will be constructed when parsing an empty string.
|
||||
/// This variant will be constructed when parsing an empty string.
|
||||
#[stable(feature = "int_error_matching", since = "1.54.0")]
|
||||
Empty,
|
||||
/// Contains an invalid digit in its context.
|
||||
///
|
||||
@@ -102,26 +96,25 @@ pub enum IntErrorKind {
|
||||
///
|
||||
/// This variant is also constructed when a `+` or `-` is misplaced within a string
|
||||
/// either on its own or in the middle of a number.
|
||||
#[stable(feature = "int_error_matching", since = "1.54.0")]
|
||||
InvalidDigit,
|
||||
/// Integer is too large to store in target integer type.
|
||||
#[stable(feature = "int_error_matching", since = "1.54.0")]
|
||||
PosOverflow,
|
||||
/// Integer is too small to store in target integer type.
|
||||
#[stable(feature = "int_error_matching", since = "1.54.0")]
|
||||
NegOverflow,
|
||||
/// Value was Zero
|
||||
///
|
||||
/// This variant will be emitted when the parsing string has a value of zero, which
|
||||
/// would be illegal for non-zero types.
|
||||
#[stable(feature = "int_error_matching", since = "1.54.0")]
|
||||
Zero,
|
||||
}
|
||||
|
||||
impl ParseIntError {
|
||||
/// Outputs the detailed cause of parsing an integer failing.
|
||||
#[unstable(
|
||||
feature = "int_error_matching",
|
||||
reason = "it can be useful to match errors when making error messages \
|
||||
for integer parsing",
|
||||
issue = "22639"
|
||||
)]
|
||||
#[stable(feature = "int_error_matching", since = "1.54.0")]
|
||||
pub fn kind(&self) -> &IntErrorKind {
|
||||
&self.kind
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user