Guest User

Untitled

a guest
Dec 15th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. use std::mem;
  2. use std::ptr;
  3.  
  4. fn main() {
  5. let data_len: usize = 0;
  6. let mut data: [String; 1000];
  7.  
  8. unsafe {
  9. data = mem::uninitialized();
  10.  
  11. for elem in &mut data[0..500] {
  12. ptr::write(elem, String::from("hello"));
  13. }
  14. }
  15.  
  16. // For each thing, drop
  17. for i in 0..data_len {
  18. mem::drop(data[i]);
  19. }
  20. // then memforget the slice?
  21. mem::forget(data);
  22. }
Add Comment
Please, Sign In to add comment