mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Format has-derived clauses
This commit is contained in:
parent
fcf464e9da
commit
e78b345ee0
5 changed files with 179 additions and 15 deletions
|
@ -400,6 +400,20 @@ pub enum Derived<'a> {
|
|||
SpaceAfter(&'a Derived<'a>, &'a [CommentOrNewline<'a>]),
|
||||
}
|
||||
|
||||
impl Derived<'_> {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
let mut it = self;
|
||||
loop {
|
||||
match it {
|
||||
Self::SpaceBefore(inner, _) | Self::SpaceAfter(inner, _) => {
|
||||
it = inner;
|
||||
}
|
||||
Self::Has(collection) => return collection.is_empty(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum TypeAnnotation<'a> {
|
||||
/// A function. The types of its arguments, then the type of its return value.
|
||||
|
@ -1005,6 +1019,7 @@ impl_extract_spaces!(Expr);
|
|||
impl_extract_spaces!(Pattern);
|
||||
impl_extract_spaces!(Tag);
|
||||
impl_extract_spaces!(AssignedField<T>);
|
||||
impl_extract_spaces!(TypeAnnotation);
|
||||
|
||||
impl<'a, T: Copy> ExtractSpaces<'a> for Spaced<'a, T> {
|
||||
type Item = T;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue