futures_rx/stream/
notification.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#[derive(Debug)]
pub enum Notification<T> {
    Next(T),
    Complete,
}

impl<T> Notification<T> {
    pub fn inner_value(self) -> Option<T> {
        match self {
            Notification::Next(it) => Some(it),
            Notification::Complete => None,
        }
    }
}

impl<T: PartialEq> PartialEq for Notification<T> {
    fn eq(&self, other: &Self) -> bool {
        match (self, other) {
            (Self::Next(l0), Self::Next(r0)) => l0 == r0,
            _ => core::mem::discriminant(self) == core::mem::discriminant(other),
        }
    }
}

impl<T: Clone> Clone for Notification<T> {
    fn clone(&self) -> Self {
        match self {
            Self::Next(arg0) => Self::Next(arg0.clone()),
            Self::Complete => Self::Complete,
        }
    }
}