Use unsafe more idiomatically

Generally, including everything that makes an unsafe block safe in the
block is good style. Since the assert! is what makes this safe, it
should go inside the block. I also added a few bits of whitespace.
This commit is contained in:
Steve Klabnik 2015-09-07 10:16:57 -04:00
parent f84d53ca0a
commit 5441ad6b9d

View file

@ -303,8 +303,10 @@ impl<T> SliceExt for [T] {
fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
let len = self.len();
let ptr = self.as_mut_ptr();
assert!(mid <= len);
unsafe {
assert!(mid <= len);
(from_raw_parts_mut(ptr, mid),
from_raw_parts_mut(ptr.offset(mid as isize), len - mid))
}