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

Add into_inner method #124

Merged
merged 4 commits into from
Oct 13, 2020
Merged

Add into_inner method #124

merged 4 commits into from
Oct 13, 2020

Conversation

notgull
Copy link
Contributor

@notgull notgull commented Oct 12, 2020

This method adds the into_inner method to both ArrayVec and TinyVec and resolves #122. It also adds documentation and doc-tests for both of these functions.

Implementation questions:

  • If the length of an ArrayVec is less than its capacity, should it return an error value or should it return the array with its default values? I have taken the latter option for the time being.

@Shnatsel
Copy link
Collaborator

Why not return the inner Vec instead of erroring out in TinyVec?

@notgull
Copy link
Contributor Author

notgull commented Oct 13, 2020

I was mostly just copying smallvec's way of doing it. However, it would certainly be possible to return an enum containing either an array or a vector. I'd like to hear Lokathor's thoughts on what the API should look like.

@Lokathor
Copy link
Owner

Lokathor commented Oct 13, 2020

yeouch, lots of diff noise, guess we haven't formatted the repo in a little while.

For TinyVec, the inner fields are already public since it's just an enum, I don't think we need to have an into_inner method at all. People can already do a match and then handle the error non-array however they want.

@Lokathor
Copy link
Owner

great! though also the example doesn't need to be a whole page :3 just a few lines showing that you can get the array out should be enough. I can fix that before publishing if you don't want to.

not sure why CI stopped, i'll restart it

@Lokathor Lokathor merged commit c570a11 into Lokathor:main Oct 13, 2020
@notgull notgull deleted the into_inner branch October 13, 2020 18:07
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.

Add some kind of "into_inner" function to ArrayVec and TinyVec
3 participants