osom_arrays/errors.rs
1use osom_alloc::AllocationError;
2
3/// Represents a general issue that can occure when dealing
4/// with arrays.
5#[repr(C)]
6#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
7#[must_use]
8pub enum ArrayError {
9 /// The underlying allocator returned an error,
10 /// likely due to out of memory.
11 AllocationError = 0,
12
13 /// Tried to push to array beyond its length limit.
14 LengthLimitExceeded = 1,
15}
16
17impl From<AllocationError> for ArrayError {
18 fn from(_: AllocationError) -> Self {
19 Self::AllocationError
20 }
21}
22
23/// Represents an error that occures when the array is empty.
24#[repr(C)]
25#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Default)]
26#[must_use]
27pub struct ArrayIsEmptyError;