Skip to content

Commit

Permalink
feat(chain): impl Append for Option<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
notmandatory committed Dec 6, 2023
1 parent f741122 commit 8b5da13
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/chain/src/tx_data_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ impl<T> Append for Vec<T> {
}
}

impl<T> Append for Option<T> {
// If other is Some then replace self's value with other's value, if other is None do nothing.
fn append(&mut self, other: Self) {
other.and_then(|v| self.replace(v));
}

fn is_empty(&self) -> bool {
self.is_none()
}
}

macro_rules! impl_append_for_tuple {
($($a:ident $b:tt)*) => {
impl<$($a),*> Append for ($($a,)*) where $($a: Append),* {
Expand Down

0 comments on commit 8b5da13

Please sign in to comment.