Simplify creating BoundedSeparated

Along with this comes the decision to no longer track whitespace and
comments across desugarings in most cases. The main reason for this
decision is that not having to track whitespace simplifies the code and
reasoning necessary.

While implementing desugarings, I also realized that the current comment
model doesn't let me accurately track whitespace across desugarings. I'm
fairly sure I haven't yet found a good model for whitespace and
comments. Once I find one, adding pretty printing support for those
should hopefully be easy though.
This commit is contained in:
Joscha 2022-11-22 14:44:15 +01:00
parent d6a0bbf2af
commit c769d9e16f
7 changed files with 110 additions and 205 deletions

View file

@ -89,3 +89,19 @@ impl<E> HasSpan for BoundedSeparated<E> {
self.span
}
}
impl<E> BoundedSeparated<E> {
pub fn new(span: Span) -> Self {
Self {
elems: vec![],
trailing: None,
span,
}
}
pub fn then(mut self, elem: E) -> Self {
self.elems
.push((Space::empty(self.span), elem, Space::empty(self.span)));
self
}
}