pub struct ParseIntError { /* private fields */ }
Expand description
An error which can be returned when parsing an integer.
This error is used as the error type for the from_str_radix()
functions
on the primitive integer types, such as i8::from_str_radix
.
§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§
source§impl ParseIntError
impl ParseIntError
1.55.0 (const: 1.82.0) · sourcepub const fn kind(&self) -> &IntErrorKind
pub const fn kind(&self) -> &IntErrorKind
Outputs the detailed cause of parsing an integer failing.
Trait Implementations§
1.0.0 · source§impl Clone for ParseIntError
impl Clone for ParseIntError
source§fn clone(&self) -> ParseIntError
fn clone(&self) -> ParseIntError
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more1.0.0 · source§impl Debug for ParseIntError
impl Debug for ParseIntError
1.0.0 · source§impl Display for ParseIntError
impl Display for ParseIntError
1.0.0 · source§impl Error for ParseIntError
impl Error for ParseIntError
source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · source§impl PartialEq for ParseIntError
impl PartialEq for ParseIntError
impl Eq for ParseIntError
impl StructuralPartialEq for ParseIntError
Auto Trait Implementations§
impl Freeze for ParseIntError
impl RefUnwindSafe for ParseIntError
impl Send for ParseIntError
impl Sync for ParseIntError
impl Unpin for ParseIntError
impl UnwindSafe for ParseIntError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> IntoAnyhow for T
impl<T> IntoAnyhow for T
source§fn into_anyhow(self) -> Error
fn into_anyhow(self) -> Error
Converts
self
into an anyhow::Error
.