archunit/layers/assertion/
layer_dependency_rule.rsuse std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
pub enum LayerDependencyRule {
MayOnlyDependOnLayers,
MayNotDependOnLayers,
}
impl LayerDependencyRule {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::MayOnlyDependOnLayers => "may-only-depend-on-layers",
Self::MayNotDependOnLayers => "may-not-depend-on-layers",
}
}
}
impl fmt::Display for LayerDependencyRule {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(self.as_str())
}
}
#[cfg(test)]
mod tests {
use super::LayerDependencyRule;
#[test]
fn exposes_stable_rule_names() {
assert_eq!(
LayerDependencyRule::MayOnlyDependOnLayers.as_str(),
"may-only-depend-on-layers"
);
assert_eq!(
LayerDependencyRule::MayNotDependOnLayers.to_string(),
"may-not-depend-on-layers"
);
}
}