Skip to content

Latest commit

 

History

History
233 lines (177 loc) · 7.43 KB

CHANGELOG.md

File metadata and controls

233 lines (177 loc) · 7.43 KB

Changelog

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.

0.5.4 - 2023-08-29

#167 Remove tild from dependencies

0.5.3 - 2023-06-21

#147 Remove .toolversions

0.5.2 - 2023-03-19

#103 Add docs to generated new when using #[derive(Builder].

0.5.1 - 2022-11-03

#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 }
    }
}

0.5.0 - 2022-08-05

#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].

0.4.0 - 2022-07-31

#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!

0.3.2 - 2022-06-09

#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.

0.3.1 - 2022-06-09

#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.

0.3.0 - 2022-05-23

#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:

  1. the docs look nice
  2. the builder can be passed to a function (although this is of limited real world use).

#4 Use #[inline(always)] on generated code.

0.2.0 - 2022-05-10

#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]

  1. Annotate the impl with: #[buildstructor::buildstructor]
  2. 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 around new/*_new are used.
  • exit => The terminal method for the generated builder. Defaults to builder for constructors and call for 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.

0.1.12 - 2022-05-06

#39 Visibility of builder now matches the visibility of each constructor.

0.1.11 - 2022-05-06

#39 Visibility of builder now matches the visibility of each constructor.

#28 Generalize replacing of self in return type.

0.1.10 - 2022-05-04

#30 The original token stream is output if there are compile errors. This allows IDEs to auto complete during periods of invalid code.

0.1.9 - 2022-04-26

#24 Simple types are now given Into treatment globally.

0.1.8 - 2022-04-25

#5 Simple types are now given Into treatment when inserting to collection via singular form.

0.1.7 - 2022-04-23

#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(_)

0.1.6 - 2022-04-23

#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.

0.1.5 - 2022-04-11

Added

#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.

Fixed

#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.

0.1.4 - 2022-03-30

Fixed

#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.

0.1.3 - 2022-03-30

Fixed

#1 Fix generics on collections

0.1.2 - 2022-03-30

Changed

Improve readme

Add rust doc to [builder]

0.1.1 - 2022-03-29

Changed

Improve readme

0.1.0 - 2022-003-29

Added

Initial release