1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
pub mod state {
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("A state member could not be borrowed")]
Borrow(#[from] std::cell::BorrowError),
#[error("A state member could not be mutably borrowed")]
BorrowMut(#[from] std::cell::BorrowMutError),
}
pub type Result<T> = std::result::Result<T, Error>;
}
pub mod repo {
use std::{
cell::{BorrowError, BorrowMutError},
fmt::{Display, Formatter},
};
#[derive(Debug)]
pub struct Error;
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
"Could not borrow the repository as it's already borrowed mutably".fmt(f)
}
}
impl std::error::Error for Error {}
impl From<BorrowError> for Error {
fn from(_: BorrowError) -> Self {
Error
}
}
impl From<BorrowMutError> for Error {
fn from(_: BorrowMutError) -> Self {
Error
}
}
pub type Result<T> = std::result::Result<T, Error>;
}