如何从方法中改变结构的字段?
我想做这个: struct Point { x: i32, y: i32, } impl Point { fn up(&self) { self.y += 1; } } fn main() { let p = Point { x: 0, y: 0 }; p.up(); } 但是这段代码会引发编译器错误: error[E0594]: cannot assign to field `self.y` of immutable binding --> src/main.rs:8:9 | 7 | …