pub trait ParseInt: Sized {
type FromStrRadixErr: Into<ParseIntError>;
// Required method
fn from_str_radix(
src: &str,
radix: u32,
) -> Result<Self, Self::FromStrRadixErr>;
// Provided method
fn from_str(src: &str) -> Result<Self, ParseIntError> { ... }
}
Expand description
Trait for parsing integers.
Strings beginning with the common and classic prefixes 0x
, 0o
, 0b
or 0
are parsed
as hex, octal, binary, and octal (classic). Anything else is parsed as decimal.
A leading +
or -
is permitted. Any string parsed by strtol(3)
or strtoul(3)
will be parsed successfully.
Required Associated Types§
Required Methods§
fn from_str_radix(src: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
Provided Methods§
fn from_str(src: &str) -> Result<Self, ParseIntError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.