Skip to content

Instantly share code, notes, and snippets.

@nmrshll
Last active September 19, 2022 15:32
Show Gist options
  • Save nmrshll/6489693e102fbc53a0650c32106bf796 to your computer and use it in GitHub Desktop.
Save nmrshll/6489693e102fbc53a0650c32106bf796 to your computer and use it in GitHub Desktop.
Async Drop with tokio
impl Drop for MyStruct {
fn drop(&mut self) {
tokio::task::block_in_place(move || {
tokio::runtime::Handle::current().block_on(async move {
// self.client.cleanup(&mut *self.db.conn().await).await;
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment