summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-09-17 15:46:37 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-09-17 15:46:37 +0200
commitf6abd405d8387692168820cc4feed6e49468260a (patch)
tree519e564a474b0f2c0dbae2ea3c5b6624286bffdc
parent00d389f47c66f14740b89a62944a5169b0f4b9a7 (diff)
openpgp: Make UserID::assemble use concrete types.
- This prevents monomorphization.
-rw-r--r--openpgp/src/packet/userid.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs
index 17267a5b..c6acab51 100644
--- a/openpgp/src/packet/userid.rs
+++ b/openpgp/src/packet/userid.rs
@@ -548,16 +548,14 @@ impl Clone for UserID {
}
impl UserID {
- fn assemble<S>(name: Option<S>, comment: Option<S>,
- address: S, check_address: bool)
+ fn assemble(name: Option<&str>, comment: Option<&str>,
+ address: &str, check_address: bool)
-> Result<Self>
- where S: AsRef<str>,
{
let mut value = String::with_capacity(64);
// Make sure the individual components are valid.
if let Some(ref name) = name {
- let name = name.as_ref();
match ConventionallyParsedUserID::new(name.to_string()) {
Err(err) =>
return Err(err.context(format!(
@@ -578,7 +576,6 @@ impl UserID {
}
if let Some(ref comment) = comment {
- let comment = comment.as_ref();
match ConventionallyParsedUserID::new(
format!("x ({})", comment))
{
@@ -606,7 +603,6 @@ impl UserID {
}
if check_address {
- let address = address.as_ref();
match ConventionallyParsedUserID::new(
format!("<{}>", address))
{
@@ -630,7 +626,7 @@ impl UserID {
if something {
value.push_str(" <");
}
- value.push_str(address.as_ref());
+ value.push_str(address);
if something {
value.push_str(">");
}
@@ -682,7 +678,10 @@ impl UserID {
where S: AsRef<str>,
O: Into<Option<S>>
{
- Self::assemble(name.into(), comment.into(), email, true)
+ Self::assemble(name.into().as_ref().map(|s| s.as_ref()),
+ comment.into().as_ref().map(|s| s.as_ref()),
+ email.as_ref(),
+ true)
}
/// Constructs a User ID.
@@ -709,7 +708,10 @@ impl UserID {
where S: AsRef<str>,
O: Into<Option<S>>
{
- Self::assemble(name.into(), comment.into(), address, false)
+ Self::assemble(name.into().as_ref().map(|s| s.as_ref()),
+ comment.into().as_ref().map(|s| s.as_ref()),
+ address.as_ref(),
+ false)
}
/// Gets the user ID packet's value.