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:
parent
f84d53ca0a
commit
5441ad6b9d
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]) {
|
||||
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))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue