#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Blocking {
May,
MayNot,
}
impl Blocking {
#[must_use]
pub const fn as_arg(self) -> &'static str {
match self {
Self::May => "1",
Self::MayNot => "0",
}
}
}
impl From<bool> for Blocking {
fn from(may_block: bool) -> Self {
if may_block { Self::May } else { Self::MayNot }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn blocking_args() {
assert_eq!(Blocking::May.as_arg(), "1");
assert_eq!(Blocking::MayNot.as_arg(), "0");
assert_eq!(Blocking::from(true), Blocking::May);
assert_eq!(Blocking::from(false), Blocking::MayNot);
}
}