Skip to content

Commit 8b5da13

Browse files
committed
feat(chain): impl Append for Option<T>
1 parent f741122 commit 8b5da13

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/chain/src/tx_data_traits.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ impl<T> Append for Vec<T> {
128128
}
129129
}
130130

131+
impl<T> Append for Option<T> {
132+
// If other is Some then replace self's value with other's value, if other is None do nothing.
133+
fn append(&mut self, other: Self) {
134+
other.and_then(|v| self.replace(v));
135+
}
136+
137+
fn is_empty(&self) -> bool {
138+
self.is_none()
139+
}
140+
}
141+
131142
macro_rules! impl_append_for_tuple {
132143
($($a:ident $b:tt)*) => {
133144
impl<$($a),*> Append for ($($a,)*) where $($a: Append),* {

0 commit comments

Comments
 (0)