Skip to content

Commit 266b60d

Browse files
committed
Change out SingleNotify for GenericNotify
1 parent 5f67dd0 commit 266b60d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/notify.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,22 +221,29 @@ where
221221
}
222222
}
223223

224-
/// A single notification.
225-
pub(crate) struct SingleNotify<T> {
224+
/// A generic notification.
225+
pub(crate) struct GenericNotify<F> {
226+
/// Number of listeners to notify.
227+
count: usize,
228+
229+
/// Whether this notification is additional.
226230
additional: bool,
227-
tag: Option<T>,
231+
232+
/// Generate tags.
233+
tags: F,
228234
}
229235

230-
impl<T> SingleNotify<T> {
231-
pub(crate) fn new(additional: bool, tag: T) -> Self {
236+
impl<T, F: FnMut() -> T> GenericNotify<F> {
237+
pub(crate) fn new(count: usize, additional: bool, tags: F) -> Self {
232238
Self {
239+
count,
233240
additional,
234-
tag: Some(tag),
241+
tags,
235242
}
236243
}
237244
}
238245

239-
impl<T> Notification for SingleNotify<T> {
246+
impl<T, F: FnMut() -> T> Notification for GenericNotify<F> {
240247
type Tag = T;
241248

242249
fn is_additional(&self) -> bool {
@@ -248,11 +255,11 @@ impl<T> Notification for SingleNotify<T> {
248255
}
249256

250257
fn count(&self) -> usize {
251-
1
258+
self.count
252259
}
253260

254261
fn next_tag(&mut self) -> Self::Tag {
255-
self.tag.take().unwrap()
262+
(self.tags)()
256263
}
257264
}
258265

0 commit comments

Comments
 (0)