Skip to content

Commit

Permalink
Auto merge of rust-lang#28285 - steveklabnik:split_at_idiom, r=arielb1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Sep 7, 2015
2 parents a7f4a8e + 5441ad6 commit 7bf626a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 7bf626a

Please sign in to comment.