pub fn matches_prefix(channel: &str, prefix: &str) -> bool {
channel == prefix
|| channel
.strip_prefix(prefix)
.is_some_and(|rest| rest.starts_with('.'))
}
pub fn family_head(channel: &str) -> &str {
channel.split('.').next().unwrap_or(channel)
}
#[cfg(test)]
mod tests {
use super::{family_head, matches_prefix};
#[test]
fn family_naming_rules() {
assert_eq!(family_head("goals.148e0e02"), "goals");
assert_eq!(family_head("goals"), "goals");
assert!(matches_prefix("goals", "goals"));
assert!(matches_prefix("goals.148e0e02", "goals"));
assert!(matches_prefix("goals.a.b", "goals.a"));
assert!(!matches_prefix("goals.ab", "goals.a"));
assert!(!matches_prefix("goalsmith", "goals"));
assert!(!matches_prefix("concerto", "goals"));
}
}