Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/stdx/src/lib.rs')
| -rw-r--r-- | crates/stdx/src/lib.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index ee23f57934..e33b45cc8e 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -193,6 +193,11 @@ where } } +/// Returns all final segments of the argument, longest first. +pub fn slice_tails<T>(this: &[T]) -> impl Iterator<Item = &[T]> { + (0..this.len()).map(|i| &this[i..]) +} + #[cfg(test)] mod tests { use super::*; |