add ObserverExt with notify_each()
This commit is contained in:
parent
49f189f3db
commit
eebabdda2d
1 changed files with 12 additions and 0 deletions
12
src/view.rs
12
src/view.rs
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue