about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-09-07 19:25:21 +0000
committerbors <bors@rust-lang.org>2015-09-07 19:25:21 +0000
commit7bf626a68045be1d1a4fac9a635113bb7775b6bb (patch)
tree76fd18e4a7f16f497dda4071a7a6aed9614b5b05 /src/libcore
parenta7f4a8e50da5525ff44fd61fb2c8f67e92eb072d (diff)
parent5441ad6b9d944d0e625bed87e1e3ff169a268390 (diff)
downloadrust-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.rs4
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))
         }