Struct adrop::Adrop[][src]

pub struct Adrop<T: Send + 'static> { /* fields omitted */ }

Adrop wrapper can realize automatic adrop.

Examples

use adrop::Adrop;

struct Test {}

impl Drop for Test {
    fn drop(&mut self) {
        println!(
            "Dropping HasDrop! ThreadId: {:?}",
            std::thread::current().id()
        );
    }
}

println!("Main ThreadId: {:?}", std::thread::current().id());
let _ = Adrop::new(Test {});

Output:

Main ThreadId: ThreadId(1)
Dropping HasDrop! ThreadId: ThreadId(2)

Implementations

impl<T: Send> Adrop<T>[src]

pub fn new(content: T) -> Adrop<T>[src]

Wrap a value to be realize automatic adrop.

Examples

use adrop::Adrop;
Adrop::new(String::from("Hello World!"));

pub fn into_inner(self) -> T[src]

Extracts the value from the Adrop container.
This allows the value to be dropped again.

Examples

use adrop::Adrop;
let s = Adrop::new(String::from("Hello World!"));
let _ = s.into_inner();

Trait Implementations

impl<T: Clone + Send + 'static> Clone for Adrop<T>[src]

impl<T: Debug + Send + 'static> Debug for Adrop<T>[src]

impl<T: Default + Send + 'static> Default for Adrop<T>[src]

impl<T: Send> Deref for Adrop<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: Send> DerefMut for Adrop<T>[src]

impl<T: Send> Drop for Adrop<T>[src]

impl<T: Eq + Send + 'static> Eq for Adrop<T>[src]

impl<T: Hash + Send + 'static> Hash for Adrop<T>[src]

impl<T: Ord + Send + 'static> Ord for Adrop<T>[src]

impl<T: PartialEq + Send + 'static> PartialEq<Adrop<T>> for Adrop<T>[src]

impl<T: PartialOrd + Send + 'static> PartialOrd<Adrop<T>> for Adrop<T>[src]

impl<T: Send + 'static> StructuralEq for Adrop<T>[src]

impl<T: Send + 'static> StructuralPartialEq for Adrop<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Adrop<T> where
    T: RefUnwindSafe

impl<T> Send for Adrop<T>

impl<T> Sync for Adrop<T> where
    T: Sync

impl<T> Unpin for Adrop<T> where
    T: Unpin

impl<T> UnwindSafe for Adrop<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.