Skip to content

Add type NonEmptySlice #17

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

Merged
merged 8 commits into from
Jul 13, 2022
Merged

Conversation

joseph-gio
Copy link
Contributor

@joseph-gio joseph-gio commented Jun 28, 2022

  • Added the DST NonEmptySlice
    • Wrapper around a slice that guarantees it has at least one element.
    • Defines many helper methods that benefit from the non-empty restriction, such as first, split_last_mut, etc.
    • impl Deref<Target = [T]>, for the rest of the methods we expect.
  • Change NonEmpty to impl Deref<Target = NonEmptySlice>.
    • This means the majority of NonEmpty's methods are now unnecessary, since we get them through the Deref impl.
  • Added a significant amount of documentation.

@joseph-gio joseph-gio marked this pull request as ready for review June 28, 2022 03:57
@joseph-gio
Copy link
Contributor Author

This may seem unnecessary, but I noticed the majority of the methods in this crate actually don't have anything to do with a non-empty vector, but a slice. So, I factored it out into a separate type which can hopefully be useful on its own.

@yihuang yihuang mentioned this pull request Jun 29, 2022
@joseph-gio joseph-gio requested a review from yihuang June 29, 2022 15:17
@joseph-gio
Copy link
Contributor Author

Okay, that's the last of the changes I want to make for this PR.

Copy link
Owner

@yihuang yihuang left a comment

Choose a reason for hiding this comment

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

LGTM, awesome.

@yihuang yihuang merged commit c6362f9 into yihuang:master Jul 13, 2022
@joseph-gio joseph-gio deleted the non-empty-slice branch July 13, 2022 22:56
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.

3 participants