]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Don't require import of internal macros
authorElias Rohrer <dev@tnull.de>
Thu, 17 Aug 2023 08:50:23 +0000 (10:50 +0200)
committerElias Rohrer <dev@tnull.de>
Thu, 17 Aug 2023 08:50:23 +0000 (10:50 +0200)
Commit f560320b introduced changes that require users of
`impl_writeable_tlv_based`/`impl_writeable_tlv_based_enum` to import
`_encode_varint_length_prefixed_tlv` and `alloc` separately.

Here, we take care of the necessary imports in
`_encode_varint_length_prefixed_tlv` itself, allowing users to just
import the `impl_writeable_tlv_based` variant they need.

lightning/src/util/ser_macros.rs

index a68dae39cdc65319b910f1f2af6b5fb905511e96..2626509f34e6a48cacab50013451a6e454a1a9fe 100644 (file)
@@ -231,9 +231,10 @@ macro_rules! _get_varint_length_prefixed_tlv_length {
 #[macro_export]
 macro_rules! _encode_varint_length_prefixed_tlv {
        ($stream: expr, {$(($type: expr, $field: expr, $fieldty: tt)),*}) => { {
-               _encode_varint_length_prefixed_tlv!($stream, {$(($type, $field, $fieldty)),*}, &[])
+               $crate::_encode_varint_length_prefixed_tlv!($stream, {$(($type, $field, $fieldty)),*}, &[])
        } };
        ($stream: expr, {$(($type: expr, $field: expr, $fieldty: tt)),*}, $extra_tlvs: expr) => { {
+               extern crate alloc;
                use $crate::util::ser::BigSize;
                use alloc::vec::Vec;
                let len = {
@@ -814,8 +815,7 @@ macro_rules! _init_and_read_tlv_fields {
 ///
 /// For example,
 /// ```
-/// # use lightning::{impl_writeable_tlv_based, _encode_varint_length_prefixed_tlv};
-/// # extern crate alloc;
+/// # use lightning::impl_writeable_tlv_based;
 /// struct LightningMessage {
 ///    tlv_integer: u32,
 ///    tlv_default_integer: u32,