Skip to content

Commit 5441ad6

Browse files
committed
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.
1 parent f84d53c commit 5441ad6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libcore/slice.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,10 @@ impl<T> SliceExt for [T] {
303303
fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
304304
let len = self.len();
305305
let ptr = self.as_mut_ptr();
306-
assert!(mid <= len);
306+
307307
unsafe {
308+
assert!(mid <= len);
309+
308310
(from_raw_parts_mut(ptr, mid),
309311
from_raw_parts_mut(ptr.offset(mid as isize), len - mid))
310312
}

0 commit comments

Comments
 (0)