Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Y {}
- struct X;
- impl Drop for X {
- fn drop(&mut self) {
- println!("Dropping!");
- }
- }
- impl Y for X {}
- fn take_ownership(x: Box<dyn Y>) {
- println!("About to drop!");
- std::mem::drop(x);
- }
- fn main() {
- let x: Box<dyn Y> = Box::new(X);
- take_ownership(x);
- println!("Should be dropped now");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement