Unwrap Struct Once And Modify Multiple Values

275 Views Asked by At

I have the following code:

((&self.items).get(&self.lastIndex)).unwrap().val1 = "hello";
((&self.items).get(&self.lastIndex)).unwrap().val2 = "world";

Map of ink storage. How can I unwrap the struct from KV once and modify all values at once? Like so:

/// not rust syntax
((&self.items).get(&self.lastIndex))
.unwrap()->{
  this.val1 = "";
  this.val2 = "";
}
0

There are 0 best solutions below