MCPcopy Create free account
hub / github.com/Axect/Peroxide / swap_vec_ptr

Function swap_vec_ptr

src/util/low_level.rs:27–35  ·  view source on GitHub ↗

Pairwise-swap the values pointed to by `lhs` and `rhs`. # Safety `lhs` and `rhs` must have equal length (enforced by debug assert). Each `(lhs[i], rhs[i])` pair must point to valid, properly-aligned `T` locations and must not alias another live reference. `lhs` and `rhs` themselves must point to disjoint memory.

(lhs: &mut [*mut T], rhs: &mut [*mut T])

Source from the content-addressed store, hash-verified

25/// `T` locations and must not alias another live reference.
26/// * `lhs` and `rhs` themselves must point to disjoint memory.
27pub unsafe fn swap_vec_ptr<T>(lhs: &mut [*mut T], rhs: &mut [*mut T])
28where
29 T: Copy,
30{
31 assert_eq!(lhs.len(), rhs.len(), "Should use same length vectors");
32 for (&mut l, &mut r) in lhs.iter_mut().zip(rhs.iter_mut()) {
33 std::ptr::swap(l, r);
34 }
35}
36
37/// Dereference every pointer in `pv` and collect the values into a `Vec`.
38///

Callers 2

swapMethod · 0.85
swapMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected