pub(crate) unsafe fn retain_raw<const SINGLE_REGION: bool, T, F>(
front: *mut T,
front_len: usize,
back: *mut T,
total_len: &mut usize,
f: F,
)Expand description
Retains elements in two contiguous regions according to f.
The *total_len initialized elements are treated as one logical sequence:
the first front_len elements start at front, and the remaining elements
start at back.
Each element is passed to f in logical order. Elements for which f
returns true are compacted toward the beginning of the logical sequence,
preserving their relative order. Rejected elements are dropped.
On return, *total_len is updated to the number of retained elements.
On panic, retained and unchecked elements, including the element whose
predicate panicked, are compacted and *total_len is updated accordingly.
Uses the specialized SINGLE_REGION in PanicGuard to
eliminate unnecessary stack usage and move unchecked elements
with a single bulk copy for Vec.
§Safety
front_lenmust equal*total_lenifSINGLE_REGIONistrue.frontmust point tofront_leninitialized, valid instances ofT.backmust point to*total_len - front_leninitialized, valid instances ofT.front_len <= *total_len.- The two regions must not overlap.
- All elements in both regions must be exclusively accessible for the duration of this call.
total_lenmust not point into either region.