Skip to content

Commit 7bf626a

Browse files
committed
Auto merge of rust-lang#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.
2 parents a7f4a8e + 5441ad6 commit 7bf626a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libcore/slice.rs

+3-1
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)