#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct ScopeDecl {
pub anchor: String,
pub label: String,
}
impl ScopeDecl {
pub fn new(anchor: impl Into<String>, label: impl Into<String>) -> Self {
Self {
anchor: anchor.into(),
label: label.into(),
}
}
#[must_use]
pub fn contains(&self, anchor: &str) -> bool {
scope_contains(&self.anchor, anchor)
}
}
#[must_use]
pub fn scope_contains(scope: &str, anchor: &str) -> bool {
anchor
.strip_prefix(scope)
.is_some_and(|rest| rest.is_empty() || rest.starts_with('/'))
}