add ObserverExt with notify_each()

This commit is contained in:
Michael Sippel 2020-12-14 19:21:03 +01:00
parent 49f189f3db
commit eebabdda2d
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -14,6 +14,18 @@ pub trait Observer : Send + Sync {
fn notify(&self, key: Self::Msg); fn notify(&self, key: Self::Msg);
} }
pub trait ObserverExt : Observer {
fn notify_each(&self, it: impl IntoIterator<Item = Self::Msg>);
}
impl<T: Observer> ObserverExt for T {
fn notify_each(&self, it: impl IntoIterator<Item = Self::Msg>) {
for msg in it {
self.notify(msg);
}
}
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
use cgmath::Vector2; use cgmath::Vector2;