pub(crate) fn insert(&mut self, new_alert: Alert, new_alert_level: AlertLevel) {
        let mut already_present = false;

        for (existing_alert, ref mut existing_alert_level) in
            self.all_alerts.iter_mut().filter_map(|e| *e)
        {
            // check if alert is already present
            if existing_alert == new_alert {
                // promote alerts of lower priority to higher priority
                if new_alert_level < *existing_alert_level {
                    *existing_alert_level = new_alert_level;
                }
                already_present = true;
            }
        }

        // lets find a free spot
        if !already_present {
            if let Some(option) = self.all_alerts.iter_mut().find(|e| e.is_none()) {
                *option = Some((new_alert, new_alert_level));
            }
        }
    }
/// updates internal alerts with new alerts, removing all old alerts. Prioritizes as well.
updates internal alerts with new alerts, removing all old alerts. Prioritizes as well.
updates internal alerts with new alerts removing all old alerts . Prioritizes as well .
pub(crate) fn insert(&mut self, new_alert: Alert, new_alert_level: AlertLevel) {
        let mut already_present = false;
        for (existing_alert, ref mut existing_alert_level) in
            self.all_alerts.iter_mut().filter_map(|e| *e)
        {
            // check if alert is already present
            if existing_alert == new_alert {
                // promote alerts of lower priority to higher priority
                if new_alert_level < *existing_alert_level {
                    *existing_alert_level = new_alert_level;
                }
                already_present = true;
            }
        }
        // lets find a free spot
        if !already_present {
            if let Some(option) = self.all_alerts.iter_mut().find(|e| e.is_none()) {
                *option = Some((new_alert, new_alert_level));
            }
        }
    }
pub ( crate ) fn insert ( & mut self , new_alert : Alert , new_alert_level : AlertLevel ) { let mut already_present = false ; for ( existing_alert , ref mut existing_alert_level ) in self . all_alerts . iter_mut ( ) . filter_map ( | e | * e ) { // check if alert is already present if existing_alert == new_alert { // promote alerts of lower priority to higher priority if new_alert_level < * existing_alert_level { * existing_alert_level = new_alert_level ; } already_present = true ; } } // lets find a free spot if ! already_present { if let Some ( option ) = self . all_alerts . iter_mut ( ) . find ( | e | e . is_none ( ) ) { * option = Some ( ( new_alert , new_alert_level ) ) ; } } }
updates internal alerts with new alerts, removing all old alerts.
updates internal alerts with new alerts removing all old alerts .
&mut self
new_alert
Alert
new_alert_level
AlertLevel
&mut self
new_alert
Alert
new_alert_level
AlertLevel