Lines Matching full:split

15 /// Types that can be split in two.
98 unsafe fn split_at_unchecked(&self, l_len: usize) -> Split<&Self> { in split_at_unchecked()
100 unsafe { Split::<&Self>::new(self, l_len) } in split_at_unchecked()
103 /// Attempts to split `self` in two.
129 /// // Attempt to split `packet` at `length`.
130 /// let split = packet.split_at(packet.length as usize).unwrap();
134 /// let (packet, rest) = split.via_immutable();
160 fn split_at(&self, l_len: usize) -> Option<Split<&Self>> { in split_at()
166 unsafe { Split::new(self, l_len.get()) } in split_at()
183 unsafe fn split_at_mut_unchecked(&mut self, l_len: usize) -> Split<&mut Self> { in split_at_mut_unchecked()
185 unsafe { Split::<&mut Self>::new(self, l_len) } in split_at_mut_unchecked()
188 /// Attempts to split `self` in two.
218 /// // Attempt to split `packet` at `length`.
219 /// let split = packet.split_at_mut(packet.length as usize).unwrap();
223 /// let (packet, rest) = split.via_into_bytes();
240 fn split_at_mut(&mut self, l_len: usize) -> Option<Split<&mut Self>> { in split_at_mut()
246 unsafe { Split::new(self, l_len.get()) } in split_at_mut()
265 /// A `T` that has been split into two possibly-overlapping parts.
269 /// length](KnownLayout#slice-dst-layout). If `T` is split at a length that
271 /// split `T` will overlap the right part. If `T` is a mutable reference or
278 pub struct Split<T> { struct
290 impl<T> Split<T> { implementation
291 /// Produces a `Split` of `source` with `l_len`.
302 impl<'a, T> Split<&'a T> impl
307 fn into_ptr(self) -> Split<Ptr<'a, T, (Shared, Aligned, Valid)>> { in into_ptr()
311 unsafe { Split::new(source, self.l_len) } in into_ptr()
314 /// Produces the split parts of `self`, using [`Immutable`] to ensure that
338 /// // Attempt to split `packet` at `length`.
339 /// let split = packet.split_at(packet.length as usize).unwrap();
343 /// let (packet, rest) = split.via_immutable();
377 /// Produces the split parts of `self`, using [`IntoBytes`] to ensure that
401 /// // Attempt to split `packet` at `length`.
402 /// let split = packet.split_at(packet.length as usize).unwrap();
406 /// let (packet, rest) = split.via_into_bytes();
415 /// See [`Split::via_immutable`](#method.split_via_immutable.codegen).
426 /// Produces the split parts of `self`, using [`Unaligned`] to ensure that
450 /// // Attempt to split `packet` at `length`.
451 /// let split = packet.split_at(packet.length as usize).unwrap();
455 /// let (packet, rest) = split.via_unaligned();
464 /// See [`Split::via_immutable`](#method.split_via_immutable.codegen).
475 /// Produces the split parts of `self`, using a dynamic check to ensure that
511 /// // Attempt to split `packet` at `length`.
512 /// let split = packet.split_at(packet.length.into()).unwrap();
516 /// let (packet, rest) = split.via_runtime_check().unwrap();
522 /// // Attempt to split `packet` at `length - 1`.
524 /// let split = packet.split_at(idx as usize).unwrap();
532 /// assert!(split.via_runtime_check().is_err());
561 /// Unsafely produces the split parts of `self`.
594 // left and right portions of `self` split at `l_len` do not overlap. in via_unchecked()
600 impl<'a, T> Split<&'a mut T> impl
605 fn into_ptr(self) -> Split<Ptr<'a, T, (Exclusive, Aligned, Valid)>> { in into_ptr()
609 unsafe { Split::new(source, self.l_len) } in into_ptr()
612 /// Produces the split parts of `self`, using [`IntoBytes`] to ensure that
637 /// // Attempt to split `packet` at `length`.
638 /// let split = packet.split_at_mut(packet.length as usize).unwrap();
642 /// let (packet, rest) = split.via_into_bytes();
657 /// See [`Split::via_immutable`](#method.split_via_immutable.codegen).
668 /// Produces the split parts of `self`, using [`Unaligned`] to ensure that
693 /// // Attempt to split `packet` at `length`.
694 /// let split = packet.split_at_mut(packet.length as usize).unwrap();
698 /// let (packet, rest) = split.via_unaligned();
713 /// See [`Split::via_immutable`](#method.split_via_immutable.codegen).
724 /// Produces the split parts of `self`, using a dynamic check to ensure that
751 /// // Attempt to split `packet` at `length`.
752 /// let split = packet.split_at_mut(packet.length as usize).unwrap();
756 /// let (packet, rest) = split.via_runtime_check().unwrap();
771 /// See [`Split::via_runtime_check`](#method.split_via_runtime_check.codegen).
781 /// Unsafely produces the split parts of `self`.
793 /// See [`Split::via_unchecked`](#method.split_via_unchecked.codegen).
798 // caller has promised that the left and right portions of `self` split in via_unchecked()
805 impl<'a, T, I> Split<Ptr<'a, T, I>> implementation
810 fn into_ref(self) -> Split<&'a T> in into_ref()
817 unsafe { Split::new(self.source.as_ref(), self.l_len) } in into_ref()
820 fn into_mut(self) -> Split<&'a mut T> in into_mut()
827 unsafe { Split::new(self.source.unify_invariants().as_mut(), self.l_len) } in into_mut()
833 // SAFETY: By invariant on `Split`, `self.l_len` is not greater than the in l_len()
838 /// Produces the split parts of `self`, using [`Immutable`] to ensure that
850 /// Produces the split parts of `self`, using [`IntoBytes`] to ensure that
858 // Consequently, `T` can be split into non-overlapping parts at any in via_into_bytes()
863 /// Produces the split parts of `self`, using [`Unaligned`] to ensure that
875 // be split into strictly non-overlapping parts any any index. in via_unaligned()
879 /// Produces the split parts of `self`, using a dynamic check to ensure that
901 /// Unsafely produces the split parts of `self`.
1020 let split = dst.split_at(i).unwrap().via_runtime_check(); in test_split_at_overlapping() localVariable
1022 assert!(split.is_ok()); in test_split_at_overlapping()
1024 assert!(split.is_err()); in test_split_at_overlapping()
1034 let split = unsafe { SplitAt::split_at_unchecked(slice, 2) }; in test_split_at_unchecked() localVariable
1035 // SAFETY: SplitAt::split_at_unchecked guarantees that the split is valid. in test_split_at_unchecked()
1036 let (l, r) = unsafe { split.via_unchecked() }; in test_split_at_unchecked()
1042 let split = unsafe { SplitAt::split_at_mut_unchecked(slice_mut, 2) }; in test_split_at_unchecked() localVariable
1043 // SAFETY: SplitAt::split_at_mut_unchecked guarantees that the split is valid. in test_split_at_unchecked()
1044 let (l, r) = unsafe { split.via_unchecked() }; in test_split_at_unchecked()
1085 let split = packet.split_at(2).unwrap(); in test_split_at_via_unaligned() localVariable
1086 let (l, r) = split.via_unaligned(); in test_split_at_via_unaligned()