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.
#195 Update clippy lint allow too many args:
#[allow(clippy::too_many_arguments)]
#197
Builders methods have #[must_use]. This will prevent accidentally unfinished builders.
#167 Remove tild from dependencies
#147 Remove .toolversions
#103
Add docs to generated new when using #[derive(Builder].
#96 Fix associated type parameters:
#[buildstructor]
impl<T: MyTrait> Foo<T> {
#[builder]
pub fn new(foo: T, bar: T::Bar) -> Foo<T> {
Foo { foo, bar }
}
}#81 Fix derive builder when used with module level visibility.
#77 Remove validation of visibility specifier.
#74
Automatically add #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] to functions annotated with #[builder].
#69 Add the ability to override the visibility of generated builder.
#[derive(buildstructor::Builder)]
pub struct MyStruct {
simple: usize,
}The generated constructor will have private visibility and the builder will be public.
#70 Add the ability to override the visibility of generated builder.
#3 Changed the storage of required but not yet supplied values to use MaybeUninit. The tuple that represents the builder state stays the same memory layout regardless of if a field has been initialized or not.
This does not require any unsafe code!
#60 Fix impl with concrete types in generics where self is used in the return type.
#[buildstructor]
impl Foo<usize> {
#[builder]
fn bound_new(simple: usize) -> Self {
Self { simple }
}
}Previously the generated builder method was not including concrete generic type. In this case usize.
#60 Fix impl with concrete types in generics.
#[buildstructor]
impl Foo<usize> {
#[builder]
fn bound_new(simple: usize) -> Foo<usize> {
Self { simple }
}
}Previously the generated builder method was not including concrete generic type. In this case usize.
#55 Lifetimes are supported now.
#52 Add docs to generated builder. In addition, a type alias is introduced for the initial builder type so that:
- the docs look nice
- the builder can be passed to a function (although this is of limited real world use).
#4
Use #[inline(always)] on generated code.
#45 Major refactor to expand the scope of buildstructor.
To provide more control over generated builders and allow builders for methods with receivers the top level annotation has changed:
#[buildstructor::builder] => #[buildstructor::buildstructor]
- Annotate the impl with:
#[buildstructor::buildstructor] - Annotate methods to create a builders for with:
#[builder]
#[buildstructor::buildstructor]
impl Foo {
#[builder]
fn new(simple: String) -> Foo {
Self { simple }
}
}You can configure your builder using the #[builder] annotation, which has the following attributes:
entry=> The entry point for your builder. If not specified then the pre-existing rules aroundnew/*_neware used.exit=> The terminal method for the generated builder. Defaults tobuilderfor constructors andcallfor methods.
In addition, you can now specify builders on methods that take self:
#[derive(Default)]
pub struct Client;
#[buildstructor::buildstructor]
impl Client {
#[builder(entry = "phone", exit = "call")]
fn phone_call(self, _simple: String) {}
}
fn main() {
Client::default().phone().simple("3").call();
}Note, if method parameters begin with _ then this is stripped for the builder method names.
#39 Visibility of builder now matches the visibility of each constructor.
#39 Visibility of builder now matches the visibility of each constructor.
#28 Generalize replacing of self in return type.
#30 The original token stream is output if there are compile errors. This allows IDEs to auto complete during periods of invalid code.
#24 Simple types are now given Into treatment globally.
#5 Simple types are now given Into treatment when inserting to collection via singular form.
#18 Relaxed collection support. Collections type matching is relaxed to the following:
| Type Name | Method used to insert |
|---|---|
| ...Buffer | push(_) |
| ...Deque | push(_) |
| ...Heap | push(_) |
| ...Set | insert(_) |
| ...Stack | push(_) |
| ...Map | insert(_, _) |
| Vec | push(_) |
#14 Generics ordering bug. Generics were not being consistently ordered, which caused issues if there were generics on the impl type and also in a where clause.
#9 Add *_new support.
Any method named new or has a suffix _new will create a builder.
Builders methods are named appropriately. e.g. try_new -> try_build.
#11 Fix multiple builders in the same module. Removes the use of wildcard imports to builder modules to fix name clashes.
#8 Fix constructors that return Self
Self on builders needed to be converted to the target type.
#6 Fix generics on collections. This mostly rolls back the changes in #1. THe examples have been updated to show the correct way to use into with a collection.
#1 Fix generics on collections
Improve readme
Add rust doc to [builder]
Improve readme
Initial release