mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Canonicalize deriving
This commit is contained in:
parent
09acc5458b
commit
9712cfe342
6 changed files with 397 additions and 171 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue