try_drop/drop_strategies/
exit.rs1use crate::TryDropStrategy;
2use std::process;
3
4#[cfg_attr(
6 feature = "derives",
7 derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)
8)]
9pub struct ExitDropStrategy {
10 pub exit_code: i32,
12}
13
14impl ExitDropStrategy {
15 pub const DEFAULT: Self = Self::new(1);
17
18 pub const fn new(exit_code: i32) -> Self {
20 Self { exit_code }
21 }
22}
23
24impl Default for ExitDropStrategy {
25 fn default() -> Self {
26 Self::DEFAULT
27 }
28}
29
30impl TryDropStrategy for ExitDropStrategy {
31 fn handle_error(&self, _error: crate::Error) {
32 process::exit(self.exit_code)
33 }
34}
35
36