try-drop 0.2.0

Batteries included error handling mechanisms for drops which can fail
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::TryDropStrategy;
use std::process;

/// A drop strategy that aborts the program if the drop fails.
#[cfg_attr(
    feature = "derives",
    derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Default)
)]
pub struct AbortDropStrategy;

impl TryDropStrategy for AbortDropStrategy {
    fn handle_error(&self, _error: crate::Error) {
        process::abort()
    }
}

// it is not possible to create tests for this strategy because this aborts the program, which
// can't be caught.