-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Labels
Description
It is currently not possible for downstreams to create a CapacityError due to it being #[non_exhaustive].
This can be a problem when wrapping heapless APIs.
For example, a function that extends a buffer:
fn add_data(vec: &mut VecView<u8>) -> Result<(), CapacityError> {
vec.push(0u8)?;
vec.extend_from_slice(&b"some slice")?;
Ok(())
}does not compile because the push method does not return a CapacityError and it's not possible to simply use .map_err to change the error type.
I think adding a implementation of Default would be fine, and have not much maintenance risk (if this error is improved we can always just keep a default value that does not contain any precise information). It doesn't look like the #[non_exhaustive] was motivated a plan to increase the information in this error type anyway: #533 (comment).