fn _handlerchain_construct_window_chain(handler_chain: &mut HandlerChain)
Expand description
Helper method to construct a list of windows. Messages will be passed to these windows via the HandlerChain object.
The HandlerChain object takes ownership of the windows due to a limitation in Rust. I would have preferred a separate list own the MessageWindow instances and the HandlerChain would be given a mutable reference to the IMessageHandler trait on each MessageWindow. But that requires taking a mutable borrow through the list of windows, one for each window, and Rust does not allow multiple mutable borrows (even though technically the mutable borrow should be on the MessageWindow instance, Rust sees the borrow on the list of windows. If I take the mutable borrow on the MessageWindow instance before adding it to the list of windows and then add the MessageWindow instance to the list of windows, Rust will not allow the window instance to be added (it’s an immutable borrow on a reference that is mutable).
Parameters
-
handler_chain
A reference to a HandlerChain instance that the messages will be passed to. This HandlerChain instance also takes ownership of the MessageWindow instances.