From 5441ad6b9d944d0e625bed87e1e3ff169a268390 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 7 Sep 2015 10:16:57 -0400 Subject: [PATCH] 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. --- src/libcore/slice.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index cf605f507bca6..b5d3129d2683e 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -303,8 +303,10 @@ impl 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)) }