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

hybrid-array: add FromIterator impl #1039

Merged
merged 1 commit into from
Jan 10, 2024
Merged

Conversation

tarcieri
Copy link
Member

For feature parity with GenericArray.

It would be nice to have a fallible version of this which returns an error instead of panicking on length mismatch, but we'd first need to add FromFn::try_from_fn or thereabouts.

This is enough to cover the immediate use cases in the meantime.

For feature parity with `GenericArray`.

It would be nice to have a fallible version of this which returns an
error instead of panicking on length mismatch, but we'd first need to
add `FromFn::try_from_fn` or thereabouts.

This is enough to cover the immediate use cases in the meantime.

assert!(
iter.next().is_none(),
"too many items in iterator to fit in array"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these should both say "iterator should have exactly as many items as can fit in array"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be useful to know whether you have more than needed or not enough elements in iterator to fill array. The other expect message can be "not enough items in iterator to fill array".

@tarcieri tarcieri merged commit 62ec49c into master Jan 10, 2024
11 checks passed
@tarcieri tarcieri deleted the hybrid-array/from-iterator branch January 10, 2024 16:27
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