-
Notifications
You must be signed in to change notification settings - Fork 20
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
split
method is ambiguous on its own
#60
Comments
That makes sense 👍 I'll add a patch to change it to return |
FintanH
added a commit
that referenced
this issue
Nov 14, 2024
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
FintanH
added a commit
that referenced
this issue
Nov 14, 2024
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
FintanH
added a commit
that referenced
this issue
Nov 15, 2024
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
Calling
split
on a single-elementNonEmpty
returns the same thing as a two-elementNonEmpty
when all the elements are the same.Although this situation can be disambiguated, e.g. by checking the length, it's a potential source of confusion and bugs.
Changing the return type to
(&T, &[T], Option<&T>)
and returning(0, &[], None)
for the one-element case and(0, &[], Some(0))
for the two-element case would resolve the ambiguity.The text was updated successfully, but these errors were encountered: