SHARE
TWEET

Untitled

a guest Jul 11th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. trait Y {}
  2.  
  3. struct X;
  4.  
  5. impl Drop for X {
  6.     fn drop(&mut self) {
  7.         println!("Dropping!");
  8.     }
  9. }
  10.  
  11. impl Y for X {}
  12.  
  13. fn take_ownership(x: Box<dyn Y>) {
  14.     println!("About to drop!");
  15.     std::mem::drop(x);
  16. }
  17.  
  18. fn main() {
  19.     let x: Box<dyn Y> = Box::new(X);
  20.     take_ownership(x);
  21.     println!("Should be dropped now");
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top