triomphe/alloc_error.rs
1use core::fmt;
2
3/// The error type returned by the fallible (`try_*`) allocation methods of
4/// `triomphe` when the underlying allocator fails to allocate or the requested
5/// layout overflows.
6///
7/// This mirrors [`core::alloc::AllocError`].
8#[derive(Copy, Clone, PartialEq, Eq, Debug)]
9pub struct AllocError;
10
11impl fmt::Display for AllocError {
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 f.write_str("memory allocation failed")
14 }
15}
16
17impl core::error::Error for AllocError {}