prototype having the errors as separate structs that are instantiated instead of an enum
current model:
#[derive(Debug)]
pub enum CollectionAllocErr {
/// Overflow `usize::MAX` or other error during size computation
CapacityOverflow,
/// The allocator return an error
AllocErr {
/// The layout that was passed to the allocator
layout: Layout
}
}
the current model is a simple enum with two variants, which means that neither variant can exist independently but as an instance of the enum
then, the infallible function is used to either panic on an error result or call handle_alloc_error
the proposal is for something like
pub struct CapacityOverflow;
pub struct AllocationError(Layout);
// if necessary an enum encompassing both
pub trait Handle { // handle the error, implemented for both errors
// one function that either panics or handles alloc error
// depending on the implementation for that type
}
which will allow us to have precise error signatures and avoid the infallible helper
prototype having the errors as separate structs that are instantiated instead of an enum
current model:
the current model is a simple enum with two variants, which means that neither variant can exist independently but as an instance of the enum
then, the
infalliblefunction is used to either panic on an error result or callhandle_alloc_errorthe proposal is for something like
which will allow us to have precise error signatures and avoid the
infalliblehelper