Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not OP, async drop isn't a thing, but you can still have a drop guard in an async function. It's not as nice as having async drop obviously, because you can't run any await-able code inside Drop, but it still works for some situations:

   async fn foo() {
      let guard = Guard;
      // async stuff
   }

   impl Drop for Guard {
      fn drop(&mut self) {
         // do cleanup
      }
   }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: