Remove some allocations

This commit is contained in:
Lukas Wirth 2021-12-10 20:01:24 +01:00
parent c81aa68afe
commit 1bbc255ec5
13 changed files with 78 additions and 58 deletions

View file

@ -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::*;