From dbd6134fd66ef5947013c185f3fa44d8ee8e288e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Tue, 3 Jan 2017 15:33:45 -0800 Subject: [PATCH] Clean up EcKey example a bit --- openssl/src/ec.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/openssl/src/ec.rs b/openssl/src/ec.rs index 94b11e932..592c40269 100644 --- a/openssl/src/ec.rs +++ b/openssl/src/ec.rs @@ -295,7 +295,7 @@ impl EcKey { /// /// # Example /// - /// ``` + /// ```no_run /// use openssl::bn::BigNumContext; /// use openssl::ec::*; /// use openssl::nid; @@ -304,13 +304,11 @@ impl EcKey { /// // get bytes from somewhere, i.e. this will not produce a valid key /// let public_key: Vec = vec![]; /// - /// // create a PKey from the binary form of a EcPoint - /// EcGroup::from_curve_name(nid::SECP256K1) - /// .and_then(|group| BigNumContext::new().map(|ctx| (group, ctx))) - /// .and_then(|(group, mut ctx)| EcPoint::from_bytes(&group, &public_key, &mut ctx) - /// .map(|point| (group, point) )) - /// .and_then(|(group, point)| EcKey::from_public_key(&group, &point)) - /// .and_then(|ec_key| PKey::from_ec_key(ec_key)); + /// // create an EcKey from the binary form of a EcPoint + /// let group = EcGroup::from_curve_name(nid::SECP256K1).unwrap(); + /// let mut ctx = BigNumContext::new().unwrap(); + /// let point = EcPoint::from_bytes(&group, &public_key, &mut ctx).unwrap(); + /// let key = EcKey::from_public_key(&group, &point); /// ``` pub fn from_public_key(group: &EcGroupRef, public_key: &EcPointRef) -> Result { unsafe { -- GitLab