From d42364bd9d39ce4d509cf2d13336bc3bc619e3f1 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Mon, 24 Mar 2025 14:30:56 +0100 Subject: [PATCH] Swap around the fields in `Address` There's a restriction that for structs containing unsized types the unsized type has to be the last field. `Address` is not an unsize type but we are going to introduce a macro that will assume this order to work equally well with both sized and unsized types. Thus we swap it upfront here. --- bitcoin/src/address/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs index 0200b108b..48cf871fd 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -395,7 +395,7 @@ pub enum AddressData { // The `#[repr(transparent)]` attribute is used to guarantee the layout of the `Address` struct. It // is an implementation detail and users should not rely on it in their code. #[repr(transparent)] -pub struct Address(AddressInner, PhantomData) +pub struct Address(PhantomData, AddressInner) where V: NetworkValidation; @@ -455,15 +455,15 @@ impl serde::Serialize for Address { /// `Address`. impl Address { fn from_inner(inner: AddressInner) -> Self { - Address(inner, PhantomData) + Address(PhantomData, inner) } fn into_inner(self) -> AddressInner { - self.0 + self.1 } fn inner(&self) -> &AddressInner { - &self.0 + &self.1 } /// Returns a reference to the address as if it was unchecked.