use crate::disposable::Disposable;
use educe::Educe;
#[derive(Educe)]
#[educe(Debug)]
pub struct BoundDropDisposal<T>(Option<T>)
where
T: Disposable;
impl<T> BoundDropDisposal<T>
where
T: Disposable,
{
pub fn new(disposal: T) -> Self {
Self(Some(disposal))
}
}
impl<T> Disposable for BoundDropDisposal<T>
where
T: Disposable,
{
fn dispose(self) {
}
}
impl<T> Drop for BoundDropDisposal<T>
where
T: Disposable,
{
fn drop(&mut self) {
if let Some(disposal) = self.0.take() {
disposal.dispose();
}
}
}