orx_split_vec/fragment/
into_fragments.rs1use crate::{Fragment, Growth, SplitVec};
2use alloc::vec::Vec;
3
4pub trait IntoFragments<T> {
6 fn into_fragments(self) -> impl Iterator<Item = Fragment<T>>;
8}
9
10impl<T> IntoFragments<T> for Vec<T> {
11 fn into_fragments(self) -> impl Iterator<Item = Fragment<T>> {
12 [Fragment::from(self)].into_iter()
13 }
14}
15
16impl<T, const N: usize> IntoFragments<T> for [Vec<T>; N] {
17 fn into_fragments(self) -> impl Iterator<Item = Fragment<T>> {
18 self.into_iter().map(Fragment::from)
19 }
20}
21
22impl<T> IntoFragments<T> for Vec<Vec<T>> {
23 fn into_fragments(self) -> impl Iterator<Item = Fragment<T>> {
24 self.into_iter().map(Fragment::from)
25 }
26}
27
28impl<T, G: Growth> IntoFragments<T> for SplitVec<T, G> {
29 fn into_fragments(self) -> impl Iterator<Item = Fragment<T>> {
30 self.fragments.into_iter()
31 }
32}