share dangling comment logic

This commit is contained in:
Brent Westbrook 2025-12-12 09:53:47 -05:00
parent 4a66edf5f8
commit 93a958a734
No known key found for this signature in database
1 changed files with 9 additions and 17 deletions

View File

@ -123,28 +123,20 @@ impl FormatNodeRule<ExprLambda> for FormatExprLambda {
)?;
}
write!(f, [token(":")])?;
if dangling_after_parameters.is_empty() {
write!(f, [space()])?;
} else if !preview {
write!(f, [dangling_comments(dangling_after_parameters)])?;
}
dangling_after_parameters
} else {
write!(f, [token(":")])?;
// In this context, a dangling comment is a comment between the `lambda` and the body.
if dangling.is_empty() {
write!(f, [space()])?;
} else if !preview {
write!(f, [dangling_comments(dangling)])?;
}
dangling
};
write!(f, [token(":")])?;
// In this context, a dangling comment is a comment between the `lambda` and the body.
if dangling.is_empty() {
write!(f, [space()])?;
} else if !preview {
write!(f, [dangling_comments(dangling)])?;
}
FormatBody {
body,
dangling,