From 684c4bfef156e5c0243ca70906db5cc9179fc0ca Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 28 Nov 2023 09:11:03 +1100 Subject: 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. --- clippy_utils/src/sugg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clippy_utils/src') 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}"), -- cgit 1.4.1-3-g733a5