(
&mut self, range: R, replacement: I,
)
| 1019 | /// ``` |
| 1020 | #[inline] |
| 1021 | pub fn splice<R, I>( |
| 1022 | &mut self, range: R, replacement: I, |
| 1023 | ) -> ArrayVecSplice<'_, A, core::iter::Fuse<I::IntoIter>> |
| 1024 | where |
| 1025 | R: RangeBounds<usize>, |
| 1026 | I: IntoIterator<Item = A::Item>, |
| 1027 | { |
| 1028 | use core::ops::Bound; |
| 1029 | let start = match range.start_bound() { |
| 1030 | Bound::Included(x) => *x, |
| 1031 | Bound::Excluded(x) => x.saturating_add(1), |
| 1032 | Bound::Unbounded => 0, |
| 1033 | }; |
| 1034 | let end = match range.end_bound() { |
| 1035 | Bound::Included(x) => x.saturating_add(1), |
| 1036 | Bound::Excluded(x) => *x, |
| 1037 | Bound::Unbounded => self.len(), |
| 1038 | }; |
| 1039 | assert!( |
| 1040 | start <= end, |
| 1041 | "ArrayVec::splice> Illegal range, {} to {}", |
| 1042 | start, |
| 1043 | end |
| 1044 | ); |
| 1045 | assert!( |
| 1046 | end <= self.len(), |
| 1047 | "ArrayVec::splice> Range ends at {} but length is only {}!", |
| 1048 | end, |
| 1049 | self.len() |
| 1050 | ); |
| 1051 | |
| 1052 | ArrayVecSplice { |
| 1053 | removal_start: start, |
| 1054 | removal_end: end, |
| 1055 | parent: self, |
| 1056 | replacement: replacement.into_iter().fuse(), |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | /// Remove an element, swapping the end of the vec into its place. |
| 1061 | /// |
nothing calls this directly
no test coverage detected