o3/alloc/error.rs
1use std::mem;
2
3use crate::alloc::{Exhausted, Overflow};
4
5/// Failure to validate or satisfy an allocation layout.
6#[repr(u8)]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Error {
9 /// The allocator could not satisfy a valid layout.
10 Exhausted,
11 /// Capacity or layout arithmetic exceeded a representable bound.
12 Overflow,
13}
14
15impl From<Exhausted> for Error {
16 fn from(_: Exhausted) -> Self {
17 Self::Exhausted
18 }
19}
20
21impl From<Overflow> for Error {
22 fn from(_: Overflow) -> Self {
23 Self::Overflow
24 }
25}
26
27const _: () = assert!(mem::size_of::<Error>() == 1);
28const _: () = assert!(mem::size_of::<Result<(), Error>>() == 1);