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.
This commit is contained in:
parent
bf86fe130c
commit
684c4bfef1
4 changed files with 10 additions and 10 deletions
|
|
@ -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}"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue