All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
#[builder(setter(strip_option))]
for making zero arguments setters for bool
fields that just set them to true
(the default
automatically becomes false
)extern crate proc_macro;
to solve some weird problem (https://github.com/idanarye/rust-typed-builder/issues/57)::
prefixed absolute paths in generated code.Clone
when all set fields support clone.#[builder(setter(transform = ...))]
attribute for running a transform on a setter‘s argument to convert them to the field’s type.#[field_defaults(...)]
attribute for settings default attributes for all the fields.default_code
, because it needed to resolve conflict with other custom derive proc-macro crates that try to parse [#builder(default = ...)]
attribute in order to decide if they are relevant to them - and fail because the expect them to be simple literals.into
and strip_option
simultaneously for a field.skip
twice in the same builder(setter(...))
is no longer supported. Then again, if you were doing that you probably deserve having your code broken.panic!()
in the faux build method.doc
and skip
into a subsetting named setter(...)
. This means that #[builder(doc = "...")]
, for example, should now be written as #[builder(setter(doc = "..."))]
.into()
. If you want to automatically convert them, use #[builder(setter(into))]
. This new default enables rustc inference for generic types and proper integer literal type detection..build()
and repeated setters, by creating faux methods with deprecation warnings.#[builder(setter(strip_option))]
for making setters for Option
fields automatically wrap the argument with Some(...)
. Note that this is a weaker conversion than #[builder(setter(into))]
, and thus can still support type inference and integer literal type detection.default_code
setting (#[builder(default_code = "...")]
) because it is no longer required now that Rust and syn
support arbitrary expressions in attributes.Foo<'a, X, Y>
yields FooBuilder<'a, X, Y, ((), ())>
previously, and now it becomes FooBuilder<'a, ((), ()), X, Y, >.
. This change fix compiler error for struct with default type like Foo<'a, X, Y=Bar>
. Rust only allow type parameters with a default to be trailing.#![no_std]
is now supported out of the box. (You don't need to opt into any features, it just works.)default_code
expression can now refer to the values of earlier fields by name (This is extremely unlikely to break your code, but could in theory due to shadowing)#[builder(skip)]
on fields, to not provide a method to set that field.#[builder(doc = "…")]
on fields, to document the field‘s method on the builder. Unlike #[doc]
, you can currently only have one value rather than one attribute per line; but that’s not a big deal since you don't get to use the ///
sugar anyway. Just use a multiline string.#[builder(doc, builder_method_doc = "…", builder_type_doc = "…", build_method_doc = "…")]
on structs:doc
unhides the builder type from the documentation.builder_method_doc = "…"
replaces the default documentation that will be generated for the builder() method of the type for which the builder is being generated.builder_type_doc = "…"
replaces the default documentation that will be generated for the builder type. Implies doc
.build_method_doc = "…"
replaces the default documentation that will be generated for the build() method of the builder type. Implies doc
.TypedBuilder_BuilderFor_Foo
to FooBuilder
, for improved ergonomics, especially when you enable documentation of the builder type.TypedBuilder_genericType_x
to __x
. This is still expected to avoid all name collisions, but is easier to read in the builder type docs if you enable them.TypedBuilder_conversionHelperTrait_Foo
to FooBuilder_Optional
), and its method name for simpler code.default_code
is now lazily evaluated instead of eagerly; any side-effects that there might have been will no longer occur. As is usual in this release, this is very unlikely to affect you.#[builder]
attribute per field has been lifted. You can now write #[builder(skip)] #[builder(default)]
instead of #[builder(skip, default)]
if you want to. As was already the case, latest definition wins.#[builder(default_code = "...")]
syntax for defaults that cannot be parsed as attributes no matter what.syn
version to support Rust 2018.#[builder(...)]
:#[default]
-> #[builder(default)]
#[default=...]
-> #[builder(default=...)]
default
no longer needs to be a string.TypedBuilder
.Into
values..build()
.#[default]
to make them optional and specify a default value when the user does not set them..builder()
method.