compare_and_set

Function compare_and_set 

Source
pub fn compare_and_set<T>(
    value: &mut T,
    new_value: &T,
    message: &UiMessage,
    ui: &UserInterface,
) -> bool
where T: PartialEq + Clone,
Expand description

Compares the new value with the existing one, and if they do not match, sets the new value to it and sends the given message back to the message queue with the opposite direction. This function is useful to reduce boilerplate code when reacting to widget messages.