File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,30 @@ impl Interest {
70
70
Interest ( unsafe { NonZeroU8 :: new_unchecked ( self . 0 . get ( ) | other. 0 . get ( ) ) } )
71
71
}
72
72
73
+ /// Removes `other` `Interest` from `self`.
74
+ ///
75
+ /// Returns `None` if the set would be empty after removing `other`.
76
+ ///
77
+ /// ```
78
+ /// use mio::Interest;
79
+ ///
80
+ /// const RW_INTERESTS: Interest = Interest::READABLE.add(Interest::WRITABLE);
81
+ ///
82
+ /// // As long a one interest remain this will return `Some`.
83
+ /// let w_interest = RW_INTERESTS.remove(Interest::READABLE).unwrap();
84
+ /// assert!(!w_interest.is_readable());
85
+ /// assert!(w_interest.is_writable());
86
+ ///
87
+ /// // Removing all interests from the set will return `None`.
88
+ /// assert_eq!(w_interest.remove(Interest::WRITABLE), None);
89
+ ///
90
+ /// // Its also possible to remove multiple interests at once.
91
+ /// assert_eq!(RW_INTERESTS.remove(RW_INTERESTS), None);
92
+ /// ```
93
+ pub fn remove ( self , other : Interest ) -> Option < Interest > {
94
+ NonZeroU8 :: new ( self . 0 . get ( ) & !other. 0 . get ( ) ) . map ( Interest )
95
+ }
96
+
73
97
/// Returns true if the value includes readable readiness.
74
98
pub const fn is_readable ( self ) -> bool {
75
99
( self . 0 . get ( ) & READABLE ) != 0
You can’t perform that action at this time.
0 commit comments