bitfielder 0.1.1

Yet another bitfield library
Documentation
//! Result and error types.

/// Convenience alias for the library result type.
pub type Result<T> = core::result::Result<T, Error>;

/// Represents the error variants for the library.
#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Error {
    InvalidFieldVariant { field: &'static str, value: usize },
}

impl Error {
    /// Creates a new invalid field variant [Error].
    pub const fn invalid_field_variant(field: &'static str, value: usize) -> Self {
        Self::InvalidFieldVariant { field, value }
    }
}

impl core::fmt::Display for Error {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::InvalidFieldVariant { field, value } => {
                write!(f, "invalid {field} value: {value}")
            }
        }
    }
}

impl core::error::Error for Error {}