Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a proper error for into_inner #284

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

patrickariel
Copy link

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 ?).

@tbu-
Copy link
Collaborator

tbu- commented Dec 20, 2024

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.

@patrickariel
Copy link
Author

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 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants