Skip to content

Commit 062d1b8

Browse files
committed
Remove duplicate docs
Currently the `translate_pk` functions on `semantic::Policy` and `concrete::Policy` have exactly the same docs in the `# Examples` section, down to the usage of "abstract" in both. Direct docs readers from one function to the other to see the example.
1 parent 0e4fa34 commit 062d1b8

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

src/policy/concrete.rs

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -689,49 +689,9 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
689689
}
690690
}
691691

692-
/// Convert a policy using one kind of public key to another
693-
/// type of public key
692+
/// Convert a policy using one kind of public key to another type of public key.
694693
///
695-
/// # Example
696-
///
697-
/// ```
698-
/// use miniscript::{bitcoin::PublicKey, policy::concrete::Policy, Translator, hash256};
699-
/// use std::str::FromStr;
700-
/// use miniscript::translate_hash_fail;
701-
/// use std::collections::HashMap;
702-
/// use miniscript::bitcoin::hashes::{sha256, hash160, ripemd160};
703-
/// let alice_key = "0270cf3c71f65a3d93d285d9149fddeeb638f87a2d4d8cf16c525f71c417439777";
704-
/// let bob_key = "02f43b15c50a436f5335dbea8a64dd3b4e63e34c3b50c42598acb5f4f336b5d2fb";
705-
/// let placeholder_policy = Policy::<String>::from_str("and(pk(alice_key),pk(bob_key))").unwrap();
706-
///
707-
/// // Information to translator abstract String type keys to concrete bitcoin::PublicKey.
708-
/// // In practice, wallets would map from String key names to BIP32 keys
709-
/// struct StrPkTranslator {
710-
/// pk_map: HashMap<String, bitcoin::PublicKey>
711-
/// }
712-
///
713-
/// // If we also wanted to provide mapping of other associated types(sha256, older etc),
714-
/// // we would use the general Translator Trait.
715-
/// impl Translator<String, bitcoin::PublicKey, ()> for StrPkTranslator {
716-
/// // Provides the translation public keys P -> Q
717-
/// fn pk(&mut self, pk: &String) -> Result<bitcoin::PublicKey, ()> {
718-
/// self.pk_map.get(pk).copied().ok_or(()) // Dummy Err
719-
/// }
720-
///
721-
/// // Fail for hash types
722-
/// translate_hash_fail!(String, bitcoin::PublicKey, ());
723-
/// }
724-
///
725-
/// let mut pk_map = HashMap::new();
726-
/// pk_map.insert(String::from("alice_key"), bitcoin::PublicKey::from_str(alice_key).unwrap());
727-
/// pk_map.insert(String::from("bob_key"), bitcoin::PublicKey::from_str(bob_key).unwrap());
728-
/// let mut t = StrPkTranslator { pk_map: pk_map };
729-
///
730-
/// let real_policy = placeholder_policy.translate_pk(&mut t).unwrap();
731-
///
732-
/// let expected_policy = Policy::from_str(&format!("and(pk({}),pk({}))", alice_key, bob_key)).unwrap();
733-
/// assert_eq!(real_policy, expected_policy);
734-
/// ```
694+
/// For example usage please see [`crate::policy::semantic::Policy::translate_pk`].
735695
pub fn translate_pk<Q, E, T>(&self, t: &mut T) -> Result<Policy<Q>, E>
736696
where
737697
T: Translator<Pk, Q, E>,

0 commit comments

Comments
 (0)