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:
commit
7bf626a680
1 changed files with 3 additions and 1 deletions
|
@ -303,8 +303,10 @@ impl<T> SliceExt for [T] {
|
||||||
fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
|
fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
|
||||||
let len = self.len();
|
let len = self.len();
|
||||||
let ptr = self.as_mut_ptr();
|
let ptr = self.as_mut_ptr();
|
||||||
assert!(mid <= len);
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
assert!(mid <= len);
|
||||||
|
|
||||||
(from_raw_parts_mut(ptr, mid),
|
(from_raw_parts_mut(ptr, mid),
|
||||||
from_raw_parts_mut(ptr.offset(mid as isize), len - mid))
|
from_raw_parts_mut(ptr.offset(mid as isize), len - mid))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue