Debian Codegraph @

src/error.rs

raw symbols SCIP
1 //! Error types.
2
3 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::{selfrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#};
4
5 /// Number out of bounds.
6 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
7 pub enum ConversionErrorrust-analyzer cargo dashu-base 0.4.1 error/ConversionError# {
8 /// The number is not in the representation range
9 OutOfBoundsrust-analyzer cargo dashu-base 0.4.1 error/ConversionError#OutOfBounds#,
10 /// The conversion will cause a loss of precision
11 LossOfPrecisionrust-analyzer cargo dashu-base 0.4.1 error/ConversionError#LossOfPrecision#,
12 }
13
14 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for ConversionErrorrust-analyzer cargo dashu-base 0.4.1 error/ConversionError# {
15 fn fmtrust-analyzer cargo dashu-base 0.4.1 error/impl#[ConversionError][Display]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
16 match self {
17 ConversionErrorrust-analyzer cargo dashu-base 0.4.1 error/ConversionError#::OutOfBoundsrust-analyzer cargo dashu-base 0.4.1 error/ConversionError#OutOfBounds# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("number out of bounds"),
18 ConversionErrorrust-analyzer cargo dashu-base 0.4.1 error/ConversionError#::LossOfPrecisionrust-analyzer cargo dashu-base 0.4.1 error/ConversionError#LossOfPrecision# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("number can't be converted losslessly"),
19 }
20 }
21 }
22
23 #[cfg(feature = "std")]
24 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for ConversionErrorrust-analyzer cargo dashu-base 0.4.1 error/ConversionError# {}
25
26 /// Error parsing a number.
27 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
28 pub enum ParseErrorrust-analyzer cargo dashu-base 0.4.1 error/ParseError# {
29 /// No digits in the string.
30 NoDigitsrust-analyzer cargo dashu-base 0.4.1 error/ParseError#NoDigits#,
31 /// Invalid digit for a given radix.
32 InvalidDigitrust-analyzer cargo dashu-base 0.4.1 error/ParseError#InvalidDigit#,
33 /// The radix is not supported.
34 UnsupportedRadixrust-analyzer cargo dashu-base 0.4.1 error/ParseError#UnsupportedRadix#,
35 /// The radices of different components of the number are different
36 InconsistentRadixrust-analyzer cargo dashu-base 0.4.1 error/ParseError#InconsistentRadix#,
37 }
38
39 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for ParseErrorrust-analyzer cargo dashu-base 0.4.1 error/ParseError# {
40 fn fmtrust-analyzer cargo dashu-base 0.4.1 error/impl#[ParseError][Display]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
41 match self {
42 ParseErrorrust-analyzer cargo dashu-base 0.4.1 error/ParseError#::NoDigitsrust-analyzer cargo dashu-base 0.4.1 error/ParseError#NoDigits# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("no digits"),
43 ParseErrorrust-analyzer cargo dashu-base 0.4.1 error/ParseError#::InvalidDigitrust-analyzer cargo dashu-base 0.4.1 error/ParseError#InvalidDigit# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("invalid digit"),
44 ParseErrorrust-analyzer cargo dashu-base 0.4.1 error/ParseError#::UnsupportedRadixrust-analyzer cargo dashu-base 0.4.1 error/ParseError#UnsupportedRadix# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("unsupported radix"),
45 ParseErrorrust-analyzer cargo dashu-base 0.4.1 error/ParseError#::InconsistentRadixrust-analyzer cargo dashu-base 0.4.1 error/ParseError#InconsistentRadix# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("inconsistent radix"),
46 }
47 }
48 }
49
50 #[cfg(feature = "std")]
51 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for ParseErrorrust-analyzer cargo dashu-base 0.4.1 error/ParseError# {}