E4056

E4056#

Method has already been defined.

错误示例#

struct Point {
  x: Int
  y: Int
}

fn Point::to_string(self : Point) -> String {
  "(" + self.x.to_string() + "," + self.y.to_string() + ")"
}

fn Point::to_string(self : Point) -> String {
  "<" + self.x.to_string() + "," + self.y.to_string() + ">"
}

建议#

Remove the duplicate method and keep only one method:

struct Point {
  x: Int
  y: Int
}

fn Point::to_string(self : Point) -> String {
  "(" + self.x.to_string() + "," + self.y.to_string() + ")"
}

// Remove the second Point::to_string method