E4056#
方法已被定义。
错误示例#
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() + ">"
}
建议#
请删除重复的方法,只保留一个:
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