Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::mem;
- use std::ptr;
- fn main() {
- let data_len: usize = 0;
- let mut data: [String; 1000];
- unsafe {
- data = mem::uninitialized();
- for elem in &mut data[0..500] {
- ptr::write(elem, String::from("hello"));
- }
- }
- // For each thing, drop
- for i in 0..data_len {
- mem::drop(data[i]);
- }
- // then memforget the slice?
- mem::forget(data);
- }
Add Comment
Please, Sign In to add comment