Use vec! instead of mut and push

As suggested by Clippy, use the `vec!` macro directly instead of
declaring a mutable vector and pushing elements onto it.
This commit is contained in:
Tobin Harding 2021-02-10 10:25:46 +11:00
parent 24df438607
commit e35601bb19
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
2 changed files with 15 additions and 13 deletions

View File

@ -228,10 +228,11 @@ macro_rules! impl_sortedmulti {
use $crate::keys::IntoDescriptorKey; use $crate::keys::IntoDescriptorKey;
let secp = $crate::bitcoin::secp256k1::Secp256k1::new(); let secp = $crate::bitcoin::secp256k1::Secp256k1::new();
let mut keys = vec![]; let keys = vec![
$( $(
keys.push($key.into_descriptor_key()); $key.into_descriptor_key(),
)* )*
];
keys.into_iter().collect::<Result<Vec<_>, _>>() keys.into_iter().collect::<Result<Vec<_>, _>>()
.map_err($crate::descriptor::DescriptorError::Key) .map_err($crate::descriptor::DescriptorError::Key)
@ -656,10 +657,11 @@ macro_rules! fragment {
use $crate::keys::IntoDescriptorKey; use $crate::keys::IntoDescriptorKey;
let secp = $crate::bitcoin::secp256k1::Secp256k1::new(); let secp = $crate::bitcoin::secp256k1::Secp256k1::new();
let mut keys = vec![]; let keys = vec![
$( $(
keys.push($key.into_descriptor_key()); $key.into_descriptor_key(),
)* )*
];
keys.into_iter().collect::<Result<Vec<_>, _>>() keys.into_iter().collect::<Result<Vec<_>, _>>()
.map_err($crate::descriptor::DescriptorError::Key) .map_err($crate::descriptor::DescriptorError::Key)

View File

@ -440,11 +440,11 @@ macro_rules! expand_make_bipxx {
KeychainKind::Internal => vec![bip32::ChildNumber::from_normal_idx(1)?].into(), KeychainKind::Internal => vec![bip32::ChildNumber::from_normal_idx(1)?].into(),
}; };
let mut source_path = Vec::with_capacity(3); let source_path = bip32::DerivationPath::from(vec![
source_path.push(bip32::ChildNumber::from_hardened_idx(bip)?); bip32::ChildNumber::from_hardened_idx(bip)?,
source_path.push(bip32::ChildNumber::from_hardened_idx(0)?); bip32::ChildNumber::from_hardened_idx(0)?,
source_path.push(bip32::ChildNumber::from_hardened_idx(0)?); bip32::ChildNumber::from_hardened_idx(0)?,
let source_path: bip32::DerivationPath = source_path.into(); ]);
Ok((key, (parent_fingerprint, source_path), derivation_path)) Ok((key, (parent_fingerprint, source_path), derivation_path))
} }