diff options
author | Azul <azul@riseup.net> | 2020-12-11 14:41:57 +0100 |
---|---|---|
committer | Azul <azul@riseup.net> | 2020-12-11 18:09:09 +0100 |
commit | e3d65e26e284b7a77af9f3b713790f8a98bc417f (patch) | |
tree | fc7c363c357f1ce7bd80f5646f4b054f2c468b9b /openpgp/src/packet | |
parent | 90105c50559da50d7e601dca6a27040e03e430a1 (diff) |
openpgp: Replace `.unwrap()` in doctests with `?`
- See #480.
Diffstat (limited to 'openpgp/src/packet')
-rw-r--r-- | openpgp/src/packet/key.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 10 | ||||
-rw-r--r-- | openpgp/src/packet/userid.rs | 8 |
3 files changed, 13 insertions, 9 deletions
diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index 87745997..348a9396 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -202,7 +202,7 @@ pub trait KeyParts: fmt::Debug + seal::Sealed { /// # let (cert, _) = /// # CertBuilder::general_purpose(None, Some("alice@example.org")) /// # .generate()?; - /// # f(&cert, cert.primary_key().key().clone().role_into_unspecified()).unwrap(); + /// # f(&cert, cert.primary_key().key().clone().role_into_unspecified())?; /// # Ok(()) /// # } /// ``` @@ -384,7 +384,7 @@ pub trait KeyRole: fmt::Debug + seal::Sealed { /// # let (cert, _) = /// # CertBuilder::general_purpose(None, Some("alice@example.org")) /// # .generate()?; - /// # f(&cert, cert.primary_key().key().clone().parts_into_unspecified()).unwrap(); + /// # f(&cert, cert.primary_key().key().clone().parts_into_unspecified())?; /// # Ok(()) /// # } /// ``` diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 0bfac9b5..35c37b09 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -3673,7 +3673,7 @@ impl signature::SignatureBuilder { /// true)?)?; /// let sig = builder.sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` /// @@ -3713,7 +3713,7 @@ impl signature::SignatureBuilder { /// })? /// .sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` /// @@ -3764,7 +3764,7 @@ impl signature::SignatureBuilder { /// })? /// .sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` pub fn modify_unhashed_area<F>(mut self, f: F) @@ -3819,7 +3819,7 @@ impl signature::SignatureBuilder { /// true)?)?; /// let sig = builder.sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` /// @@ -3859,7 +3859,7 @@ impl signature::SignatureBuilder { /// })? /// .sign_message(&mut signer, msg)?; /// # let mut sig = sig; - /// # sig.verify_message(signer.public(), msg).unwrap(); + /// # sig.verify_message(signer.public(), msg)?; /// # Ok(()) } /// ``` /// diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs index 49d189bf..93d6875c 100644 --- a/openpgp/src/packet/userid.rs +++ b/openpgp/src/packet/userid.rs @@ -775,12 +775,14 @@ impl UserID { /// [conventional User ID]: #conventional-user-ids /// /// ``` + /// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { /// # use sequoia_openpgp as openpgp; /// # use openpgp::packet::UserID; /// assert_eq!(UserID::from_address( /// "John Smith".into(), - /// None, "boat@example.org").unwrap().value(), + /// None, "boat@example.org")?.value(), /// &b"John Smith <boat@example.org>"[..]); + /// # Ok(()) } /// ``` pub fn from_address<O, S>(name: O, comment: O, email: S) -> Result<Self> @@ -808,12 +810,14 @@ impl UserID { /// [conventional User ID]: #conventional-user-ids /// /// ``` + /// # f().unwrap(); fn f() -> sequoia_openpgp::Result<()> { /// # use sequoia_openpgp as openpgp; /// # use openpgp::packet::UserID; /// assert_eq!(UserID::from_unchecked_address( /// "NAS".into(), - /// None, "ssh://host.example.org").unwrap().value(), + /// None, "ssh://host.example.org")?.value(), /// &b"NAS <ssh://host.example.org>"[..]); + /// # Ok(()) } /// ``` pub fn from_unchecked_address<O, S>(name: O, comment: O, address: S) -> Result<Self> |