Struct ParseIntError

struct ParseIntError { ... }

An error which can be returned when parsing an integer.

For example, this error is returned by the from_str_radix() functions on the primitive integer types (such as i8::from_str_radix) and is used as the error type in their FromStr implementations.

Potential causes

Among other causes, ParseIntError can be thrown because of leading or trailing whitespace in the string e.g., when it is obtained from the standard input. Using the [str::trim()] method ensures that no whitespace remains before parsing.

Example

if let Err(e) = i32::from_str_radix("a12", 10) {
    println!("Failed conversion to i32: {e}");
}

Implementations

impl ParseIntError

const fn kind(self: &Self) -> &IntErrorKind

Outputs the detailed cause of parsing an integer failing.

impl Clone for ParseIntError

fn clone(self: &Self) -> ParseIntError

impl Debug for ParseIntError

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Display for ParseIntError

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Eq for ParseIntError

impl Error for ParseIntError

impl Freeze for ParseIntError

impl PartialEq for ParseIntError

fn eq(self: &Self, other: &ParseIntError) -> bool

impl RefUnwindSafe for ParseIntError

impl Send for ParseIntError

impl StructuralPartialEq for ParseIntError

impl Sync for ParseIntError

impl Unpin for ParseIntError

impl UnsafeUnpin for ParseIntError

impl UnwindSafe for ParseIntError

impl<T> Any for ParseIntError

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ParseIntError

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ParseIntError

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for ParseIntError

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for ParseIntError

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for ParseIntError

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for ParseIntError

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for ParseIntError

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>