We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a56ec4 commit 645f685Copy full SHA for 645f685
src/liballoc/slice.rs
@@ -137,17 +137,16 @@ pub use hack::to_vec;
137
// `core::slice::SliceExt` - we need to supply these functions for the
138
// `test_permutations` test
139
mod hack {
140
- use core::mem;
141
-
142
use crate::boxed::Box;
143
use crate::vec::Vec;
144
#[cfg(test)]
145
use crate::string::ToString;
146
147
- pub fn into_vec<T>(mut b: Box<[T]>) -> Vec<T> {
+ pub fn into_vec<T>(b: Box<[T]>) -> Vec<T> {
148
unsafe {
149
- let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len());
150
- 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);
151
xs
152
}
153
0 commit comments