adrop

Crates.ioadrop
lib.rsadrop
version0.2.1
sourcesrc
created_at2021-02-23 10:46:51.387754
updated_at2021-02-25 10:03:26.794887
descriptionSimple and fast dedicated thread drop.
homepage
repositoryhttps://github.com/CedarHuang/adrop
max_upload_size
id359423
size18,607
(CedarHuang)

documentation

https://docs.rs/adrop

README

adrop

Simple and fast dedicated thread drop.

Latest version Documentation License

Getting Started

Add the following dependency to your Cargo manifest...

[dependencies]
adrop = "0.2"

Example

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 {});

License

Commit count: 8

cargo fmt