pelf 0.1.5

A library for parsing/generating/analyzing ELF
Documentation
#[derive(Clone, Default)]
pub struct FlagSet<T: std::ops::BitOr + Default + PartialEq + Ord + PartialEq + Eq> {
    pub(crate) inner: T,
}

impl<T: std::ops::BitOr + Default + PartialEq + Ord + PartialEq + Eq> FlagSet<T> {
    /// initializes a flag set that all flags are off.
    pub fn empty() -> Self {
        Self {
            inner: T::default(),
        }
    }

    pub fn contains<F: Into<T>>(&self, f: F) -> bool {
        self.inner == f.into()
    }
}

impl<T: std::ops::BitOr + std::fmt::Binary + Default + PartialEq + Ord + PartialEq + Eq>
    std::fmt::Binary for FlagSet<T>
{
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{:b}", self.inner)
    }
}