From 558cbd0195d3c308f73bdef8e5f46a0f9974e1fb Mon Sep 17 00:00:00 2001 From: Wiktor Kwapisiewicz Date: Wed, 3 Aug 2022 13:34:53 +0200 Subject: [PATCH] Fix documentation example for `Rsa::from_private_components` The existing documentation probably went out of sync when refactoring `Rsa` into `RsaPrivateKeyBuilder`. This change fixes the example by using code similar to the actual implementation. Additionally the example has been converted to a doctest so that any future refactorings should be captured by the test. --- openssl/src/rsa.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openssl/src/rsa.rs b/openssl/src/rsa.rs index c96e21d8d..1ccce2508 100644 --- a/openssl/src/rsa.rs +++ b/openssl/src/rsa.rs @@ -490,8 +490,18 @@ impl RsaPrivateKeyBuilder { impl Rsa { /// Creates a new RSA key with private components (public components are assumed). /// - /// This a convenience method over - /// `Rsa::build(n, e, d)?.set_factors(p, q)?.set_crt_params(dmp1, dmq1, iqmp)?.build()` + /// This a convenience method over: + /// ``` + /// # use openssl::rsa::RsaPrivateKeyBuilder; + /// # fn main() -> Result<(), Box> { + /// # let bn = || openssl::bn::BigNum::new().unwrap(); + /// # let (n, e, d, p, q, dmp1, dmq1, iqmp) = (bn(), bn(), bn(), bn(), bn(), bn(), bn(), bn()); + /// RsaPrivateKeyBuilder::new(n, e, d)? + /// .set_factors(p, q)? + /// .set_crt_params(dmp1, dmq1, iqmp)? + /// .build(); + /// # Ok(()) } + /// ``` #[allow(clippy::too_many_arguments, clippy::many_single_char_names)] pub fn from_private_components( n: BigNum, -- GitLab