Skip to content

Commit 920440e

Browse files
committed
containers: enrich CloseMethodSet APIs
1 parent 3ba6ad3 commit 920440e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/containers/partials.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,30 @@ pub enum CloseMethodSet {
4848
Both = 0x03,
4949
}
5050

51+
impl BitOr<Option<CloseMethodSet>> for CloseMethodSet {
52+
type Output = Self;
53+
fn bitor(mut self, rhs: Option<CloseMethodSet>) -> Self::Output {
54+
rhs.map(|m| self |= m);
55+
self
56+
}
57+
}
58+
59+
impl BitOrAssign<Option<CloseMethodSet>> for CloseMethodSet {
60+
fn bitor_assign(&mut self, rhs: Option<CloseMethodSet>) { rhs.map(|m| *self |= m); }
61+
}
62+
63+
impl BitOr<CloseMethodSet> for Option<CloseMethodSet> {
64+
type Output = CloseMethodSet;
65+
fn bitor(self, mut rhs: CloseMethodSet) -> Self::Output {
66+
self.map(|m| rhs |= m);
67+
rhs
68+
}
69+
}
70+
71+
impl BitOrAssign<CloseMethodSet> for Option<CloseMethodSet> {
72+
fn bitor_assign(&mut self, rhs: CloseMethodSet) { *self = Some(rhs | *self) }
73+
}
74+
5175
impl BitOr for CloseMethodSet {
5276
type Output = Self;
5377
fn bitor(self, rhs: Self) -> Self::Output { if self == rhs { self } else { Self::Both } }
@@ -70,6 +94,11 @@ impl From<CloseMethod> for CloseMethodSet {
7094
}
7195
}
7296

97+
impl CloseMethodSet {
98+
pub fn has_tapret_first(self) -> bool { matches!(self, Self::TapretFirst | Self::Both) }
99+
pub fn has_opret_first(self) -> bool { matches!(self, Self::OpretFirst | Self::Both) }
100+
}
101+
73102
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
74103
#[derive(StrictType, StrictEncode, StrictDecode)]
75104
#[strict_type(lib = LIB_NAME_RGB_STD)]

0 commit comments

Comments
 (0)