vcombey / fallible_collections

impl fallible collections in rust, quite as describe in RFC 2116
Apache License 2.0
31 stars 14 forks source link

Add fallible alternative to slice sort methods #7

Open baumanj opened 3 years ago

baumanj commented 3 years ago

Since slice::sort and related functions like slice::sort_by_key may allocate "temporary storage half the size of self", it's possible to end up with a panic on allocation failure even when using TryVec.

Though sort_unstable and the unstable variants of the other sorting methods don't allocate, sometimes a stable sort is required. Perhaps adding a TrySort trait that provides fallible alternatives to these methods would be worthwhile.