Take Box instead of reference in State::operate

This commit is contained in:
Héctor Ramón Jiménez 2023-06-29 08:14:44 +02:00
parent 4b831a917d
commit ae2709f2c4
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -176,10 +176,10 @@ where
}
/// Applies [`widget::Operation`]s to the [`State`]
pub fn operate<'a>(
pub fn operate(
&mut self,
renderer: &mut P::Renderer,
operations: impl Iterator<Item = &'a mut dyn Operation<P::Message>>,
operations: impl Iterator<Item = Box<dyn Operation<P::Message>>>,
bounds: Size,
debug: &mut Debug,
) {
@ -192,18 +192,18 @@ where
);
for operation in operations {
let mut owned_op;
let mut current_operation = Some(operation);
while let Some(operation) = current_operation.take() {
user_interface.operate(renderer, operation);
while let Some(mut operation) = current_operation.take() {
user_interface.operate(renderer, operation.as_mut());
match operation.finish() {
Outcome::None => {}
Outcome::Some(message) => {
self.queued_messages.push(message)
}
Outcome::Chain(op) => {
owned_op = op;
current_operation = Some(owned_op.as_mut());
Outcome::Chain(next) => {
current_operation = Some(next);
}
};
}