There might be something there, but I'd need to revert my code back to confirm - but for what it's worth, I did experiment with a method on
RequestData
like the following:
impl<T> RequestData<T> {
pub fn info(&mut self, message: impl Into<String>) {
self.messages = self.messages.info(message);
}
}
...which created the following error:
error[E0507]: cannot move out of `self.messages` which is behind a mutable reference
--> libs/apex-utils/src/request.rs:37:25
|
37 | self.messages = self.messages.info(message);
| ^^^^^^^^^^^^^ ------------- `self.messages` moved due to this method call
| |
| move occurs because `self.messages` has type `Messages`, which does not implement the `Copy` trait
|
note: `Messages::info` takes ownership of the receiver `self`, which moves `self.messages`
It could be worked around by the following, which I alluded to in my last comment regarding Clone
:
impl<T> RequestData<T> {
pub fn info(&mut self, message: impl Into<String>) {
self.messages = self.messages.clone().info(message);
}
}
Personally speaking, I also am just not a fan of needing to pepper request.messages =
throughout handlers, the assignment aspect just isn't relevant to what's usually going on - but that's more subjective so I defer to you. on Support extracting messages in one pass?
3 weeks ago