1
Fork 0

Auto merge of #28285 - steveklabnik:split_at_idiom, r=arielb1

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 is of course, a little style thing, so no worries if we don't want this patch.
This commit is contained in:
bors 2015-09-07 19:25:21 +00:00
commit 7bf626a680

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))
}