Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[allow(unused_imports)]
- use std::io;
- use std::mem;
- fn leak( s : &String) -> String {
- println!("{}", s);
- std::mem::drop(s);
- String::from("haha gone")
- }
- fn main() {
- let x = "hello";
- let y = String::from(x);
- let y = leak(&y);
- println!("Hello, {}! {}", y, mem::size_of::<String>());
- }
Add Comment
Please, Sign In to add comment