How to update or add to a u64 value in a sui::Table?
let v = table::borrow_mut(&mut table_with_u64_values, k); v = v + i;
Gives an error.
let v = table::borrow_mut(&mut table_with_u64_values, k); *v = *v + i;
value: &mut u64
The example updates a mutable borrowed value.
docs: “Both mutable and immutable references can be read to produce a copy of the referenced value.
Only mutable references can be written. A write
*x = v discards the value previously stored in
x and updates it with
Hence the first *v is a write to the table value and the second *v is a dereference and a read of the previously stored value in v.