arrayvec icon indicating copy to clipboard operation
arrayvec copied to clipboard

Return a proper error for `into_inner`

Open patrickariel opened this issue 1 year ago • 2 comments

This PR adds a new error type representing an under-filled state for ArrayVec::into_inner. Previously, it would return self which is rather unconventional and prevents ergonomic error propagation (e.g. with ?).

patrickariel avatar Dec 20 '24 16:12 patrickariel

This change is a breaking change and would need a new major version.

After the change, one could no longer recover the original array.

Workaround for your use case: You can use .map_err(|_| YourError::Underfilled)? to use it with the question mark operator.

tbu- avatar Dec 20 '24 16:12 tbu-

Thanks for the feedback, I changed it so that the error stores the original vec, allowing the user to recover it using take_vec.

Workaround for your use case: You can use .map_err(|_| YourError::Underfilled)? to use it with the question mark operator.

This is what I'm currently doing, but it'd more convenient to have a canonical error type :slightly_smiling_face:

patrickariel avatar Dec 20 '24 17:12 patrickariel