From eebabdda2d31689de6f1d66909c3c28667b17fe7 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Mon, 14 Dec 2020 19:21:03 +0100 Subject: [PATCH] add ObserverExt with notify_each() --- src/view.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/view.rs b/src/view.rs index 6b804c8..8c0c915 100644 --- a/src/view.rs +++ b/src/view.rs @@ -14,6 +14,18 @@ pub trait Observer : Send + Sync { fn notify(&self, key: Self::Msg); } +pub trait ObserverExt : Observer { + fn notify_each(&self, it: impl IntoIterator); +} + +impl ObserverExt for T { + fn notify_each(&self, it: impl IntoIterator) { + for msg in it { + self.notify(msg); + } + } +} + //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> use cgmath::Vector2;