Improve debuggability of place_comment (#5209)

## Summary

I found it hard to figure out which function decides placement for a
specific comment. An explicit loop makes this easier to debug

## Test Plan

There should be no functional changes, no changes to the formatting of
the fixtures.
This commit is contained in:
konstin 2023-06-21 11:52:13 +02:00 committed by GitHub
parent f551c9aad2
commit 44156f6962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 31 deletions

View file

@ -615,18 +615,6 @@ impl<'a> CommentPlacement<'a> {
comment: comment.into(),
}
}
/// Returns the placement if it isn't [`CommentPlacement::Default`], otherwise calls `f` and returns the result.
#[inline]
pub(super) fn or_else<F>(self, f: F) -> Self
where
F: FnOnce(DecoratedComment<'a>) -> CommentPlacement<'a>,
{
match self {
CommentPlacement::Default(comment) => f(comment),
placement => placement,
}
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]