Skip to content

Commit

Permalink
Impl EncodeLabelValue for Option<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
emschwartz committed Apr 21, 2023
1 parent 85033bf commit 6e93d2a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,18 @@ impl EncodeLabelValue for f64 {
}
}

impl<T> EncodeLabelValue for Option<T>
where
T: EncodeLabelValue,
{
fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), std::fmt::Error> {
match self {
Some(v) => EncodeLabelValue::encode(v, encoder),
None => EncodeLabelValue::encode(&"", encoder),
}
}
}

macro_rules! impl_encode_label_value_for_integer {
($($t:ident),*) => {$(
impl EncodeLabelValue for $t {
Expand Down

0 comments on commit 6e93d2a

Please sign in to comment.