E4090#
Tuples are not mutable. You cannot change the value of a field in a tuple using assignment.
错误示例#
fn main {
let a = (1, 2, 3)
a.2 = 4 // Error: tuples are not mutable
println(a.2)
}
建议#
If you need to change the value of a field in a tuple, you should use a struct instead.
pub struct MyStruct {
a: Int
b: Int
mut c: Int
}
fn main {
let a : MyStruct = { a : 1, b : 2, c : 3 }
a.c = 4
println(a.c)
}