diff options
| author | Ralf Jung <post@ralfj.de> | 2019-05-27 22:40:13 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-05-27 22:40:28 +0200 |
| commit | 645f685e1b05f3f62de26ea1579861e83cbd0d74 (patch) | |
| tree | a1ac8315a89309c3ef7d75c95fe5fe337ecdfc63 /src/liballoc | |
| parent | 1a56ec4dae92538ab6e0ecf993c61f3b50ed77cf (diff) | |
| download | rust-645f685e1b05f3f62de26ea1579861e83cbd0d74.tar.gz rust-645f685e1b05f3f62de26ea1579861e83cbd0d74.zip | |
Box::into_vec: use Box::into_raw instead of mem::forget
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/slice.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 8768f1ff081..aeb7f90d3e6 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -137,17 +137,16 @@ pub use hack::to_vec; // `core::slice::SliceExt` - we need to supply these functions for the // `test_permutations` test mod hack { - use core::mem; - use crate::boxed::Box; use crate::vec::Vec; #[cfg(test)] use crate::string::ToString; - pub fn into_vec<T>(mut b: Box<[T]>) -> Vec<T> { + pub fn into_vec<T>(b: Box<[T]>) -> Vec<T> { unsafe { - let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len()); - mem::forget(b); + let len = b.len(); + let b = Box::into_raw(b); + let xs = Vec::from_raw_parts(b as *mut T, len, len); xs } } |
