Skip to main content

orx_concurrent_option/common_traits/
eq.rs

1use crate::concurrent_option::ConcurrentOption;
2
3impl<T: PartialEq> PartialEq for ConcurrentOption<T> {
4    /// Returns whether or not self is equal to the `other` with the default ordering.
5    ///
6    /// You may call [`eq_with_order`] to use the desired ordering.
7    ///
8    /// [`eq_with_order`]: ConcurrentOption::eq_with_order
9    ///
10    /// ```rust
11    /// use orx_concurrent_option::*;
12    ///
13    /// let x = ConcurrentOption::some(3);
14    /// let y = ConcurrentOption::some(7);
15    /// let z = ConcurrentOption::<i32>::none();
16    ///
17    /// assert!(x.eq(&x));
18    /// assert!(!x.eq(&y));
19    /// assert!(!x.eq(&z));
20    ///
21    /// assert!(!z.eq(&x));
22    /// assert!(!z.eq(&y));
23    /// assert!(z.eq(&z));
24    /// ```
25    fn eq(&self, other: &Self) -> bool {
26        self.locked_compare(other, true, false, false, |l, r| l.eq(r))
27    }
28}
29
30impl<T: Eq> Eq for ConcurrentOption<T> {}