Non-empty collections in std

The idea is that some functions can only return non-empty collections, which means that methods that take first element, last element or a sum of elements and maybe some others can return non-option-wrapped elements which improves ergonomics.

There is already a couple of implementations for some specific cases
crates: non-empty, non-empty-collections, vec1

Is it possible/desirable to design a more generalized version in today's rust?

There are many proposals like this that get shot down simply because std is not a place to put things just because they are useful. And even if it did belong in standard, there would need to be implementations in crates and users with significant experience with those crates to effectively argue that these things just won't function correctly unless they are in std.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.