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.
This commit is contained in:
Martin Habovstiak 2025-03-24 14:30:56 +01:00
parent 7a115e3cf1
commit d42364bd9d
1 changed files with 4 additions and 4 deletions

View File

@ -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<V = NetworkChecked>(AddressInner, PhantomData<V>)
pub struct Address<V = NetworkChecked>(PhantomData<V>, AddressInner)
where
V: NetworkValidation;
@ -455,15 +455,15 @@ impl<V: NetworkValidation> serde::Serialize for Address<V> {
/// `Address<NetworkUnchecked>`.
impl<V: NetworkValidation> Address<V> {
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.