1
Fork 0

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:
Nicholas Nethercote 2023-11-28 09:11:03 +11:00
parent 1bcbb7c93b
commit 0efd2a9d8f
9 changed files with 20 additions and 20 deletions

View file

@ -858,9 +858,9 @@ pub enum BinOpKind {
}
impl BinOpKind {
pub fn to_string(&self) -> &'static str {
pub fn as_str(&self) -> &'static str {
use BinOpKind::*;
match *self {
match self {
Add => "+",
Sub => "-",
Mul => "*",
@ -912,8 +912,8 @@ pub enum UnOp {
}
impl UnOp {
pub fn to_string(op: UnOp) -> &'static str {
match op {
pub fn as_str(&self) -> &'static str {
match self {
UnOp::Deref => "*",
UnOp::Not => "!",
UnOp::Neg => "-",