diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-11-28 09:11:03 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-11-28 09:42:07 +1100 |
| commit | 684c4bfef156e5c0243ca70906db5cc9179fc0ca (patch) | |
| tree | 90ad89984b875fc22576508d45a3b8f8647a3d1f /clippy_utils/src/sugg.rs | |
| parent | bf86fe130c41c0506c703b551b22f955277d8e4b (diff) | |
| download | rust-684c4bfef156e5c0243ca70906db5cc9179fc0ca.tar.gz rust-684c4bfef156e5c0243ca70906db5cc9179fc0ca.zip | |
Rework `ast::BinOpKind::to_string` and `ast::UnOp::to_string`.
- Rename them both `as_str`, which is the typical name for a function that returns a `&str`. (`to_string` is appropriate for functions returning `String` or maybe `Cow<'a, str>`.) - Change `UnOp::as_str` from an associated function (weird!) to a method. - Avoid needless `self` dereferences.
Diffstat (limited to 'clippy_utils/src/sugg.rs')
| -rw-r--r-- | clippy_utils/src/sugg.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clippy_utils/src/sugg.rs b/clippy_utils/src/sugg.rs index db79dd78801..f143163152e 100644 --- a/clippy_utils/src/sugg.rs +++ b/clippy_utils/src/sugg.rs @@ -382,7 +382,7 @@ fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String { | AssocOp::GreaterEqual => { format!( "{lhs} {} {rhs}", - op.to_ast_binop().expect("Those are AST ops").to_string() + op.to_ast_binop().expect("Those are AST ops").as_str() ) }, AssocOp::Assign => format!("{lhs} = {rhs}"), |
