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 CoalesceOrEmptySlice for slices #513

Open
takanuva15 opened this issue Aug 13, 2024 · 1 comment
Open

Add CoalesceOrEmptySlice for slices #513

takanuva15 opened this issue Aug 13, 2024 · 1 comment

Comments

@takanuva15
Copy link

Hi, the CoalesceOrEmpty function is awesome, but it doesn't work for slices. Can we add a counterpart for CoalesceOrEmpty that works for nil/empty slices?

We could call it CoalesceOrEmptySlice and define it with standard generic types like the existing Coalesce:

func CoalesceOrEmptySlice[T ~[]E, E any](v ...T) (result T, ok bool) {

(Alternatively we could try removing the comparable limitation on the existing Coalesce, but I haven't tested whether that would work for nil slices)

@chg1f
Copy link

chg1f commented Oct 16, 2024

#542

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

No branches or pull requests

2 participants