linux-drm 0.6.0

Client for the Linux Direct Rendering Manager and Kernel Modesetting APIs.
Documentation
pub(crate) struct Cleanup<F>
where
    F: FnOnce(),
{
    f: Option<F>,
}

impl<F> Cleanup<F>
where
    F: FnOnce(),
{
    pub(crate) fn new(f: F) -> Self {
        Self { f: Some(f) }
    }

    pub(crate) fn cancel(&mut self) {
        self.f = None;
    }
}

impl<F> Drop for Cleanup<F>
where
    F: FnOnce(),
{
    fn drop(&mut self) {
        if let Some(f) = self.f.take() {
            f()
        };
    }
}