fn split_at_mut(slice: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
    let len: usize = slice.len();
    let ptr: *mut i32 = slice.as_mut_ptr();

    assert!(mid <= len);

    // Borrowing different parts of a slice is fundamentally okay because the two slices
    // aren't overlapping, but Rust isn't smart enough to know this.
    // (&mut slice[..mid], &mut slice[mid..])

    unsafe {
        (
            slice::from_raw_parts_mut(ptr, mid),
            slice::from_raw_parts_mut(ptr.add(mid), len - mid),
        )
    }
}
// Safe abstraction over an unsafe block.
Safe abstraction over an unsafe block.
Safe abstraction over an unsafe block .
fn split_at_mut(slice: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
    let len: usize = slice.len();
    let ptr: *mut i32 = slice.as_mut_ptr();
    assert!(mid <= len);
    // Borrowing different parts of a slice is fundamentally okay because the two slices
    // aren't overlapping, but Rust isn't smart enough to know this.
    // (&mut slice[..mid], &mut slice[mid..])
    unsafe {
        (
            slice::from_raw_parts_mut(ptr, mid),
            slice::from_raw_parts_mut(ptr.add(mid), len - mid),
        )
    }
}
fn split_at_mut ( slice : & mut [ i32 ] , mid : usize ) -> ( & mut [ i32 ] , & mut [ i32 ] ) { let len : usize = slice . len ( ) ; let ptr : * mut i32 = slice . as_mut_ptr ( ) ; assert ! ( mid len ) ; // Borrowing different parts of a slice is fundamentally okay because the two slices // aren't overlapping, but Rust isn't smart enough to know this. // (&mut slice[..mid], &mut slice[mid..]) unsafe { ( slice :: from_raw_parts_mut ( ptr , mid ) , slice :: from_raw_parts_mut ( ptr . add ( mid ) , len - mid ) , ) } }
Safe abstraction over an unsafe block.
Safe abstraction over an unsafe block .
slice
&mut [i32]
mid
usize
slice
&mut [i32]
mid
usize