Enum IntErrorKind

#[non_exhaustive]
pub enum IntErrorKind

Enum to store the various types of errors that can cause parsing or converting an integer to fail.

Example

# fn main() {
if let Err(e) = i32::from_str_radix("a12", 10) {
    println!("Failed conversion to i32: {:?}", e.kind());
}
# }

Variants

Empty

Value being parsed is empty.

This variant will be constructed when parsing an empty string.

InvalidDigit

Contains an invalid digit in its context.

Among other causes, this variant will be constructed when parsing a string that contains a non-ASCII char.

This variant is also constructed when a + or - is misplaced within a string either on its own or in the middle of a number.

PosOverflow

Integer is too large to store in target integer type.

NegOverflow

Integer is too small to store in target integer type.

Zero

Value was Zero

This variant will be emitted when the parsing string or the converting integer has a value of zero, which would be illegal for non-zero types.

NotAPowerOfTwo

Value is not a power of two.

This variant will be emitted when converting an integer that is not a power of two. This is required in some cases such as constructing an Alignment.

Trait Implementations

impl Clone for IntErrorKind

fn clone(&self) -> IntErrorKind

impl Copy for IntErrorKind

impl Debug for IntErrorKind

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

impl Eq for IntErrorKind

fn assert_fields_are_eq(&self)

impl Hash for IntErrorKind

fn hash<__H: Hasher>(&self, state: &mut __H)

impl PartialEq for IntErrorKind

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

impl StructuralPartialEq for IntErrorKind

impl TrivialClone for IntErrorKind

Auto Trait Implementations

impl Freeze for IntErrorKind

impl RefUnwindSafe for IntErrorKind

impl Send for IntErrorKind

impl Sync for IntErrorKind

impl Unpin for IntErrorKind

impl UnsafeUnpin for IntErrorKind

impl UnwindSafe for IntErrorKind

Blanket Implementations

impl<T> Any for IntErrorKind where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for IntErrorKind where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for IntErrorKind where T: ?Sized,

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

impl<T> CloneToUninit for IntErrorKind where T: Clone,

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

impl<T> From<T> for IntErrorKind

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Printable for IntErrorKind where T: Copy + Debug,

impl<T> SizeHint for IntErrorKind where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for IntErrorKind

impl<T, U> Into<U> for IntErrorKind where U: From<T>,

fn into(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<U> for IntErrorKind where U: Into<T>,

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

impl<T, U> TryInto<U> for IntErrorKind where U: TryFrom<T>,

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