use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CardEdgeType {
Blocks,
RelatesTo,
ParentOf,
}
impl CardEdgeType {
pub fn requires_dag(&self) -> bool {
matches!(self, CardEdgeType::Blocks | CardEdgeType::ParentOf)
}
pub fn allows_cycles(&self) -> bool {
!self.requires_dag()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_blocks_requires_dag() {
assert!(CardEdgeType::Blocks.requires_dag());
assert!(!CardEdgeType::Blocks.allows_cycles());
}
#[test]
fn test_relates_to_allows_cycles() {
assert!(!CardEdgeType::RelatesTo.requires_dag());
assert!(CardEdgeType::RelatesTo.allows_cycles());
}
#[test]
fn test_parent_of_requires_dag() {
assert!(CardEdgeType::ParentOf.requires_dag());
assert!(!CardEdgeType::ParentOf.allows_cycles());
}
}