1use core::fmt;
4
5#[derive(Debug)]
7pub struct BorrowError;
8
9impl BorrowError {
10 pub(crate) fn panic(self) -> ! {
12 panic!("{self}")
13 }
14}
15
16impl fmt::Display for BorrowError {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 write!(f, "wrong token")
19 }
20}
21
22#[cfg(feature = "std")]
23impl std::error::Error for BorrowError {}
24
25#[allow(missing_docs)]
26#[derive(Debug)]
28pub enum BorrowMutError {
29 WrongToken,
30 NotUniqueToken,
31}
32
33impl BorrowMutError {
34 pub(crate) fn panic(self) -> ! {
36 panic!("{self}")
37 }
38}
39
40impl fmt::Display for BorrowMutError {
41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42 match self {
43 Self::WrongToken => write!(f, "wrong token"),
44 Self::NotUniqueToken => write!(f, "not unique token"),
45 }
46 }
47}
48
49#[cfg(feature = "std")]
50impl std::error::Error for BorrowMutError {}
51
52#[derive(Debug)]
54pub struct AlreadyInitialized;
55
56impl fmt::Display for AlreadyInitialized {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 write!(f, "already initialized")
59 }
60}
61
62#[cfg(feature = "std")]
63impl std::error::Error for AlreadyInitialized {}