1use std::{error::Error, fmt::Display};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub struct ArenaFull;
9
10impl Display for ArenaFull {
11 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12 f.write_str("Cannot reserve an key because the arena is full")
13 }
14}
15
16impl Error for ArenaFull {}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
19pub enum InsertWithKeyError {
23 KeyNotReserved,
25 InvalidKey,
28}
29
30impl Display for InsertWithKeyError {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 match self {
33 InsertWithKeyError::KeyNotReserved => f.write_str("Cannot insert with this key because it is not reserved"),
34 InsertWithKeyError::InvalidKey => f.write_str("Cannot insert with this key because the slot index or generation is invalid for this arena."),
35 }
36 }
37}
38
39impl Error for InsertWithKeyError {}