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

Improve return type of NonEmpty::split #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

FintanH
Copy link
Collaborator

@FintanH FintanH commented Nov 14, 2024

Fixes #601.

As pointed out in #60, splitting a NonEmpty that contains a single element can be ambiguous to a NonEmpty equivalent to (x, [x]). A better representation for this return type is (&T, &[T], Option<&T>).

Footnotes

  1. https://github.com/cloudhead/nonempty/issues/60

Copy link

@mx00s mx00s left a comment

Choose a reason for hiding this comment

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

This doc comment is now stale:

/// If there is only one element then first == last.

Potential alternative:

/// If there is only one element then last is `None`.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Fixes #60[^issue-60].

As pointed out in #60, splitting a `NonEmpty` that contains a single
element can be ambiguous to a `NonEmpty` equivalent to `(x, [x])`. A
better representation for this return type is `(&T, &[T],
Option<&T>)`.

[^issue-60]: #60
Signed-off-by: Fintan Halpenny <[email protected]>
X-Clacks-Overhead: GNU Terry Pratchett
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.

split method is ambiguous on its own
2 participants