Skip to content

Generic type for an incomplete builder? #21

@rollo-b2c2

Description

@rollo-b2c2

Appreciate this might be quite difficult to do:

If you want to pass around a builder you have to specify the state of the builder:

#[bon::builder]
pub struct T {
    a: usize,
    b: usize
}

fn a() -> TBuilder<(bon::private::Set<usize>, bon::private::Set<usize>)> {
    T::builder()
        .a(1)
        .b(2)
}

let var = a1();
var.build();

let var = a2().b(2);
var.build();

For complete structs it would make sense to type alias completeness to

type TBuilderValid = (bon::private::Set<usize>, bon::private::Set<usize>);

However what would be really useful would be some generic way of passing incomplete builders around.

A note for the community from the maintainers

Please vote on this issue by adding a 👍 reaction to help the maintainers with prioritizing it. You may add a comment describing your real use case related to this issue for us to better understand the problem domain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions