Hi All
I just started programming Rust this week. I've been reading through the book and creating a small CLI tool to try things out. So far I love it
I've got a struct which is generated from a JSON file. I would like to update a value (end
) in this struct but the value is optional. Here's what I've got so far.
fn update_end(state: &mut TrackingItem) {
let end = Utc::now().format("%Y-%m-%d %H:%M:%S").to_string();
state.end = Some(end);
}
fn stop_current_tracking(config: &mut TurboTrackConfig) -> bool{
match &config.current {
None => false,
Some(item) => {
update_end(&mut item);
true
}
}
}
I get the following error:
cannot borrow `item` as mutable, as it is not declared as mutable
But now I am stuck. If someone could tell me how to fix this as well as a resource where I can learn more about this problem? I've been reading the book but I am only at chapter 7 ATM
Thanks in advance!