pub enum ParseError {
Empty,
InvalidLiteral,
PosOverflow,
NegOverflow,
ExponentOverflow,
Signed,
InvalidRadix,
Unknown,
}Expand description
Enum to store the various types of errors that can cause parsing decimal to fail.
§Example
use fastnum::decimal::Context;
use fastnum::UD256;
if let Err(e) = UD256::from_str("e12", Context::default()) {
println!("Failed conversion to Decimal: {e}");
}Variants§
Empty
Value being parsed is empty.
This variant will be constructed when parsing an empty string.
InvalidLiteral
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
The number is too large to store in target decimal type.
NegOverflow
The number is too small to store in target decimal type.
ExponentOverflow
Exponent is too large to store in decimal type.
Signed
Value was Signed
This variant will be emitted when the parsing string has a sign literal, which would be illegal for unsigned types.
InvalidRadix
Invalid radix.
Unknown
Unknown error
Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseError
impl Debug for ParseError
Source§impl Display for ParseError
impl Display for ParseError
Source§impl Error for ParseError
impl Error for ParseError
Source§fn description(&self) -> &str
fn description(&self) -> &str
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)>
Source§impl From<ParseIntError> for ParseError
impl From<ParseIntError> for ParseError
Source§fn from(e: ParseIntError) -> ParseError
fn from(e: ParseIntError) -> ParseError
Source§impl PartialEq for ParseError
impl PartialEq for ParseError
Source§fn eq(&self, other: &ParseError) -> bool
fn eq(&self, other: &ParseError) -> bool
self and other values to be equal, and is used by ==.