ruff
d3aa8b4e - Add API to chain comment placement operations (#6319)

Commit
2 years ago
Add API to chain comment placement operations (#6319) ## 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, }; ```
Author
Parents
Loading