method.selected_delivery_option.and_then(|x| x.title) == Some("Test".to_string())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------------- `method.selected_delivery_option` moved due to this method call
| |
| help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
| move occurs because `method.selected_delivery_option` has type `std::option::Option<InputCartDeliveryGroupsSelectedDeliveryOption>`, which does not implement the `Copy` trait
--> src/main.rs:44:67
|
44 | method.selected_delivery_option.as_ref().and_then(|x| x.title) == Some("Test".to_string())
| ^^^^^^^ move occurs because `x.title` has type `std::option::Option<std::string::String>`, which does not implement the `Copy` trait
Generally the compiler give you the solution.
Here you can take the field by ref.
Are you new to rust ? Those issues are pretty trivial to solve. I can only suggest you to read the book. It will help you to understand the issues and how to solve them.
Using unwrap is a bad practice because it will make your code panic if the value is None.
Use and_then instead. Or alternatively you may use if-let but the code will be more verbose.