Canonicalize deriving

This commit is contained in:
Ayaz Hafiz 2022-05-19 18:15:05 -04:00
parent 09acc5458b
commit 9712cfe342
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
6 changed files with 397 additions and 171 deletions

View file

@ -401,17 +401,21 @@ pub enum Derived<'a> {
}
impl Derived<'_> {
pub fn is_empty(&self) -> bool {
pub fn collection(&self) -> &Collection<AbilityName> {
let mut it = self;
loop {
match it {
Self::SpaceBefore(inner, _) | Self::SpaceAfter(inner, _) => {
it = inner;
}
Self::Has(collection) => return collection.is_empty(),
Self::Has(collection) => return collection,
}
}
}
pub fn is_empty(&self) -> bool {
self.collection().is_empty()
}
}
#[derive(Debug, Copy, Clone, PartialEq)]