Crates.io | adrop |
lib.rs | adrop |
version | 0.2.1 |
source | src |
created_at | 2021-02-23 10:46:51.387754 |
updated_at | 2021-02-25 10:03:26.794887 |
description | Simple and fast dedicated thread drop. |
homepage | |
repository | https://github.com/CedarHuang/adrop |
max_upload_size | |
id | 359423 |
size | 18,607 |
Simple and fast dedicated thread drop.
Add the following dependency to your Cargo manifest...
[dependencies]
adrop = "0.2"
extern crate adrop;
use adrop::*;
struct Test {}
impl Drop for Test {
fn drop(&mut self) {
println!(
"Dropping HasDrop! ThreadId: {:?}",
std::thread::current().id()
);
}
}
fn main() {
println!("Main ThreadId: {:?}", std::thread::current().id());
adrop(Test {});
// Output:
// Main ThreadId: ThreadId(1)
// Dropping HasDrop! ThreadId: ThreadId(2)
}
Or you can use Adrop
wrapper to realize automatic adrop
:
let _ = Adrop::new(Test {});