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
24ce52a199
commit
d84d8d2604
@ -1933,7 +1933,7 @@ fn rewrite_unary_op(
|
|||||||
shape: Shape,
|
shape: Shape,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
// For some reason, an UnOp is not spanned like BinOp!
|
// For some reason, an UnOp is not spanned like BinOp!
|
||||||
rewrite_unary_prefix(context, ast::UnOp::to_string(op), expr, shape)
|
rewrite_unary_prefix(context, op.as_str(), expr, shape)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum RhsAssignKind<'ast> {
|
pub(crate) enum RhsAssignKind<'ast> {
|
||||||
|
@ -339,7 +339,7 @@ fn flatten(
|
|||||||
if let Some(pop) = stack.pop() {
|
if let Some(pop) = stack.pop() {
|
||||||
match pop.kind {
|
match pop.kind {
|
||||||
ast::ExprKind::Binary(op, _, ref rhs) => {
|
ast::ExprKind::Binary(op, _, ref rhs) => {
|
||||||
separators.push(op.node.to_string());
|
separators.push(op.node.as_str());
|
||||||
node = rhs;
|
node = rhs;
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
Loading…
Reference in New Issue
Block a user