I am literally just getting started with RUST, and the best way for me is to get myhands dirty so I am trying to experiment by building random stuff, reading, copying code, and just messing around, but I have hit a snag that I dont seem to really understand whats going on.
take this:
struct context<'a> {
custom: &'a mut custom,
}
struct custom<'a> {
search: &'a String,
}
Somewhere else I have this:
fn process(
data: &mut custom,
){
// How can I change the search string value inside custom?
data.search = "bananas"
}
Another question do I actually need to make custom mut inside context struct, if I what I want to change is just the string and not the actual custom reference?
Am I using lifecycles correctly? I followed that pattern from some other piece of code I saw online, but tbh I still havent fully grasped the concept.
Any pointers/help would be apreciated 🙂