mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00
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:
parent
f551c9aad2
commit
44156f6962
2 changed files with 30 additions and 31 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue