general_stable_vec/
error.rs1use std::slice::GetDisjointMutError;
4
5use thiserror::Error;
6
7#[derive(Debug, Error)]
9pub enum Error {
10 #[error("the given index {index} is not mapped to any element")]
12 UnmappedIndex {
13 index: usize,
15 },
16
17 #[error("the given indices contain an overlapping pair of indices")]
19 OverlappingIndices,
20
21 #[error("the given index {index} is already mapped to an element")]
23 IndexAlreadyInUse {
24 index: usize,
26 },
27
28 #[error(
30 "The given index {actual_index} is not the next available insertion index {expected_index}"
31 )]
32 NotTheNextAvailableInsertionIndex {
33 expected_index: usize,
35 actual_index: usize,
37 },
38}
39
40impl From<GetDisjointMutError> for Error {
41 fn from(value: GetDisjointMutError) -> Self {
42 match value {
43 GetDisjointMutError::IndexOutOfBounds => {
44 unreachable!("We always want to report the index")
45 }
46 GetDisjointMutError::OverlappingIndices => Self::OverlappingIndices,
47 }
48 }
49}
50
51pub type Result<T> = std::result::Result<T, Error>;