Auto merge of #23333 - oli-obk:slice_from_raw_parts, r=alexcrichton

at least that's what the docs say: http://doc.rust-lang.org/std/slice/fn.from_raw_parts.html

A few situations got prettier. In some situations the mutability of the resulting and source pointers differed (and was cast away by transmute), the mutability matches now.
This commit is contained in:
bors
2015-03-14 08:55:31 +00:00
11 changed files with 72 additions and 80 deletions

View File

@@ -931,15 +931,15 @@ impl<'a> Reader for &'a mut (Reader+'a) {
// Private function here because we aren't sure if we want to expose this as
// API yet. If so, it should be a method on Vec.
unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -> &'a mut [T] {
use raw::Slice;
use slice;
use ptr::PtrExt;
assert!(start <= end);
assert!(end <= v.capacity());
transmute(Slice {
data: v.as_ptr().offset(start as int),
len: end - start
})
slice::from_raw_parts_mut(
v.as_mut_ptr().offset(start as int),
end - start
)
}
/// A `RefReader` is a struct implementing `Reader` which contains a reference