mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +00:00
![]() ## Summary This PR adds an API for chaining comment placement methods based on the [`then_with`](https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.then_with) from `Ordering` in the standard library. For example, you can now do: ```rust try_some_case(comment).then_with(|comment| try_some_other_case_if_still_default(comment)) ``` This lets us avoid this kind of pattern, which I've seen in `placement.rs` and used myself before: ```rust let comment = match handle_own_line_comment_between_branches(comment, preceding, locator) { CommentPlacement::Default(comment) => comment, placement => return placement, }; ``` |
||
---|---|---|
.. | ||
snapshots | ||
debug.rs | ||
format.rs | ||
map.rs | ||
mod.rs | ||
node_key.rs | ||
placement.rs | ||
visitor.rs |