rust-typed-builder
rust-typed-builder copied to clipboard
`setter(transform)` requires the type to be public
Minimal example reproducing the error:
mod foo {
use typed_builder::TypedBuilder;
struct Bar;
#[derive(TypedBuilder)]
pub struct Foo {
#[builder(setter(transform = |x: u32| Bar))]
foo: Bar,
}
}
use foo::Foo;
fn main() {
Foo::builder()
.foo(5)
.build();
}
That gives the following undesired error:
error: type `Bar` is private
--> src/lib.rs:18:10
|
18 | .build();
| ^^^^^ private type
The foo method accepts a u32, not a Bar, so the Bar type shouldn't be exposed, so there shouldn't be any error.
But there is an error. This makes it impossible to use private types with transform.