Skip to content

Visibility of inner struct depends on visibility of field #11

Open
@huuff

Description

@huuff

I was writing this small snippet

nestify::nest! {
    #[derive(Debug, Clone)]*
    pub struct Purchase(Vec<pub struct TripPurchase {
        pub price: SupplierTripPrice,
        pub booking_references: References,
        pub ticket_numbers: References,
    }>);
}

And found that I can't access the TripPurchase struct externally, it's private. However if I make the field pub, I can:

nestify::nest! {
    #[derive(Debug, Clone)]*
    pub struct Purchase(pub Vec<pub struct TripPurchase {
        pub price: SupplierTripPrice,
        pub booking_references: References,
        pub ticket_numbers: References,
    }>);
}

Is this expected? It feels weird to me since it means the inner pub is mostly useless. Also, I'd say my first snippet is desirable for many patterns, for example if I want to hide the structure to force the use of a constructor to ensure invariants are held.

If this is not actually expected and a bug, I may be able to lend a hand to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions