Given some list of options of big structs:
struct big_struct {
a:i32 // Imagine this is some big datatype
}
let mut tester:Vec<Option<(big_struct,big_struct)>> = vec![
None,
Some((big_struct{a:1},big_struct{a:2})),
None,
];
I'm iterating over this list, by another check I know which elements have Some
, on these elements I want to call a function which edits their values
Example function:
fn tester_method(pos:&mut (big_struct,big_struct)) {
pos.0 = big_struct {a:8};
pos.1 = big_struct {a:9};
}
Function call which doesn't work: tester_method(&mut tester[1].unwrap());
How can I do this?
On the function call I get the error:
cannot move out of index of `std::vec::Vec<std::option::Option<(big_struct, big_struct)>>`
move occurs because value has type `std::option::Option<(big_struct, big_struct)>`, which does not implement the `Copy` traitrustc(E0507)
main.rs(132, 24): consider borrowing the `Option`'s content