More enum work (#3212)

This commit is contained in:
Jeong YunWon 2023-02-26 01:40:16 +09:00 committed by GitHub
parent 248590224a
commit 84e96cdcd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 93 additions and 224 deletions

View file

@ -7,7 +7,6 @@ use crate::context::ASTFormatContext;
use crate::cst::{Excepthandler, ExcepthandlerKind};
use crate::format::builders::block;
use crate::shared_traits::AsFormat;
use crate::trivia::{Relationship, TriviaKind};
pub struct FormatExcepthandler<'a> {
item: &'a Excepthandler,
@ -46,12 +45,8 @@ impl Format<ASTFormatContext<'_>> for FormatExcepthandler<'_> {
// Format any end-of-line comments.
let mut first = true;
for range in excepthandler.trivia.iter().filter_map(|trivia| {
if matches!(trivia.relationship, Relationship::Trailing) {
if let TriviaKind::EndOfLineComment(range) = trivia.kind {
Some(range)
} else {
None
}
if trivia.relationship.is_trailing() {
trivia.kind.end_of_line_comment()
} else {
None
}