standard_lib/util/
error.rs

1use std::error::Error;
2use std::fmt::{self, Display, Formatter};
3
4#[derive(#[automatically_derived]
impl ::core::fmt::Debug for IndexOutOfBounds {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "IndexOutOfBounds", "index", &self.index, "len", &&self.len)
    }
}Debug)]
5pub struct IndexOutOfBounds {
6    pub index: usize,
7    pub len: usize,
8}
9
10impl Display for IndexOutOfBounds {
11    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
12        f.write_fmt(format_args!("Index {0} out of bounds for collection with {1} elements!",
        self.index, self.len))write!(f, "Index {} out of bounds for collection with {} elements!", self.index, self.len)
13    }
14}
15
16impl Error for IndexOutOfBounds {}
17
18/// TODO
19///
20/// Note: This error is no longer returned by any public part of the API, but it is thrown during
21/// panics. This is because a capacity overflow has such a small chance of occurring that it isn't
22/// worth handling in most placed. Most machines wouldn't have enough memory to overflow a non-ZST
23/// collection with a u64 length.
24#[derive(#[automatically_derived]
impl ::core::fmt::Debug for CapacityOverflow {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "CapacityOverflow")
    }
}Debug)]
25pub struct CapacityOverflow;
26
27impl Display for CapacityOverflow {
28    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
29        f.write_fmt(format_args!("Capacity overflow!"))write!(f, "Capacity overflow!")
30    }
31}
32
33impl Error for CapacityOverflow {}
34
35#[derive(#[automatically_derived]
impl ::core::fmt::Debug for NoValueForKey {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "NoValueForKey")
    }
}Debug)]
36pub struct NoValueForKey;
37
38impl Display for NoValueForKey {
39    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
40        f.write_fmt(format_args!("No values is associated with the provided key."))write!(f, "No values is associated with the provided key.")
41    }
42}
43
44impl Error for NoValueForKey {}