Skip to content

Commit b8de0d2

Browse files
committed
Impl EncodeLabelValue for Option<T>
Signed-off-by: Evan Schwartz <[email protected]>
1 parent 85033bf commit b8de0d2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/encoding.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,18 @@ impl EncodeLabelValue for f64 {
404404
}
405405
}
406406

407+
impl<T> EncodeLabelValue for Option<T>
408+
where
409+
T: EncodeLabelValue,
410+
{
411+
fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), std::fmt::Error> {
412+
match self {
413+
Some(v) => EncodeLabelValue::encode(v, encoder),
414+
None => EncodeLabelValue::encode(&"", encoder),
415+
}
416+
}
417+
}
418+
407419
macro_rules! impl_encode_label_value_for_integer {
408420
($($t:ident),*) => {$(
409421
impl EncodeLabelValue for $t {

0 commit comments

Comments
 (0)