zone_alloc/
borrow_error.rs

1use core::{
2    error::Error,
3    fmt::Display,
4};
5
6/// A borrow error.
7#[derive(Debug, PartialEq, Eq)]
8pub enum BorrowError {
9    /// The element is out of bounds.
10    OutOfBounds,
11    /// The element is already borrowed mutably.
12    AlreadyBorrowedMutably,
13    /// The element is already borrowed immutably.
14    AlreadyBorrowed,
15}
16
17impl Display for BorrowError {
18    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
19        match self {
20            Self::OutOfBounds => write!(f, "element is out of bounds"),
21            Self::AlreadyBorrowedMutably => write!(f, "element is already borrowed mutably"),
22            Self::AlreadyBorrowed => write!(f, "element is already borrowed"),
23        }
24    }
25}
26
27impl Error for BorrowError {}