mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Implement [more] app header formatting
Also, refactor out a utility method to format a Collection. This method can currently replace some of the formatting done in module headers - but the goal is eventually to be able to replace the code in fmt_list as well, such that there is 'one true way' to format collections.
This commit is contained in:
parent
f02ed47f31
commit
24f7692a73
9 changed files with 322 additions and 137 deletions
|
@ -16,9 +16,22 @@ pub fn add_spaces(buf: &mut String<'_>, spaces: u16) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fmt_spaces<'a, I>(buf: &mut String<'a>, spaces: I, indent: u16)
|
||||
pub fn fmt_default_spaces<'a>(
|
||||
buf: &mut String<'a>,
|
||||
spaces: &[CommentOrNewline<'a>],
|
||||
default: &str,
|
||||
indent: u16,
|
||||
) {
|
||||
if spaces.is_empty() {
|
||||
buf.push_str(default);
|
||||
} else {
|
||||
fmt_spaces(buf, spaces.iter(), indent);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fmt_spaces<'b, 'a: 'b, I>(buf: &mut String<'a>, spaces: I, indent: u16)
|
||||
where
|
||||
I: Iterator<Item = &'a CommentOrNewline<'a>>,
|
||||
I: Iterator<Item = &'b CommentOrNewline<'a>>,
|
||||
{
|
||||
use self::CommentOrNewline::*;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue