Skip to content

Commit 336bb45

Browse files
authored
Merge pull request #13 from jarrodsfarrell/option-vec
Add `Serialize` for `Option<Vec<Regex>>`
2 parents e9e9ead + 0c6bbbd commit 336bb45

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,18 @@ impl<'a> Serialize for Serde<&'a Vec<Regex>> {
494494
}
495495
}
496496

497+
impl<'a> Serialize for Serde<&'a Option<Vec<Regex>>> {
498+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
499+
where
500+
S: Serializer,
501+
{
502+
match self.0 {
503+
&Some(ref value) => serializer.serialize_some(&Serde(value)),
504+
&None => serializer.serialize_none(),
505+
}
506+
}
507+
}
508+
497509
impl<'a, K, S> Serialize for Serde<&'a HashMap<K, Regex, S>>
498510
where
499511
K: Hash + Eq + Serialize,
@@ -568,6 +580,18 @@ impl Serialize for Serde<Vec<bytes::Regex>> {
568580
}
569581
}
570582

583+
impl<'a> Serialize for Serde<&'a Option<Vec<bytes::Regex>>> {
584+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
585+
where
586+
S: Serializer,
587+
{
588+
match self.0 {
589+
&Some(ref value) => serializer.serialize_some(&Serde(value)),
590+
&None => serializer.serialize_none(),
591+
}
592+
}
593+
}
594+
571595
impl<K, S> Serialize for Serde<HashMap<K, bytes::Regex, S>>
572596
where
573597
K: Hash + Eq + Serialize,

0 commit comments

Comments
 (0)