diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-04-25 17:17:01 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-04-25 17:17:59 +0200 |
commit | c0f833dcdcdc3459056281833e77bc33f028869c (patch) | |
tree | 2894a8b48a0e2918ab3d1c478081e05b60554683 /openpgp/src | |
parent | fceece17cf21fcffc4dbf020c60f64352e8f34a5 (diff) |
openpgp: Implement From<Cow<'a, str>> for UserID.
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/packet/userid.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs index 4a1ecec4..64f76b13 100644 --- a/openpgp/src/packet/userid.rs +++ b/openpgp/src/packet/userid.rs @@ -50,6 +50,15 @@ impl<'a> From<&'a str> for UserID { } } +impl<'a> From<::std::borrow::Cow<'a, str>> for UserID { + fn from(u: ::std::borrow::Cow<'a, str>) -> Self { + let b = u.as_bytes(); + let mut v = Vec::with_capacity(b.len()); + v.extend_from_slice(b); + v.into() + } +} + impl fmt::Display for UserID { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let userid = String::from_utf8_lossy(&self.value[..]); |