1#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
4pub struct ScopeDecl {
5 pub anchor: String,
6 pub label: String,
7}
8
9impl ScopeDecl {
10 pub fn new(anchor: impl Into<String>, label: impl Into<String>) -> Self {
11 Self {
12 anchor: anchor.into(),
13 label: label.into(),
14 }
15 }
16
17 #[must_use]
19 pub fn contains(&self, anchor: &str) -> bool {
20 scope_contains(&self.anchor, anchor)
21 }
22}
23
24#[must_use]
26pub fn scope_contains(scope: &str, anchor: &str) -> bool {
27 anchor
28 .strip_prefix(scope)
29 .is_some_and(|rest| rest.is_empty() || rest.starts_with('/'))
30}