For the implementation of Write for Vec<u8>, use Vec::try_reserve
to try and allocate memory before copying a slice into the Vec. If a
TryReserveError is returned, bubble that up to the caller instead of
letting alloc do a process abort.
If an allocation fails, return Error::OutOfMemory.
This commit removes derive(Copy) from the error type in this crate
because the inner TryReserveError in the OutOfMemory variant is not
Copy.
Sorry to merge this change without pinging you @x-hgg-x. I wasn't sure you had accepted the invite yet. If you'd like to do a post-merge code review, I'm open to feedback on this PR.
For the implementation of
Write
forVec<u8>
, useVec::try_reserve
to try and allocate memory before copying a slice into theVec
. If aTryReserveError
is returned, bubble that up to the caller instead of lettingalloc
do a process abort.If an allocation fails, return
Error::OutOfMemory
.This commit removes
derive(Copy)
from the error type in this crate because the innerTryReserveError
in theOutOfMemory
variant is notCopy
.