diff options
| author | bors <bors@rust-lang.org> | 2015-09-07 19:25:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-09-07 19:25:21 +0000 |
| commit | 7bf626a68045be1d1a4fac9a635113bb7775b6bb (patch) | |
| tree | 76fd18e4a7f16f497dda4071a7a6aed9614b5b05 /src/libcore | |
| parent | a7f4a8e50da5525ff44fd61fb2c8f67e92eb072d (diff) | |
| parent | 5441ad6b9d944d0e625bed87e1e3ff169a268390 (diff) | |
| download | rust-7bf626a68045be1d1a4fac9a635113bb7775b6bb.tar.gz rust-7bf626a68045be1d1a4fac9a635113bb7775b6bb.zip | |
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.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/slice.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index cf605f507bc..b5d3129d268 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -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)) } |
