Skip to content

Releases: chuck-flowers/attribution

v0.5.0

26 Jun 14:32

Choose a tag to compare

Features

Change #[attr_args] to #[derive(AttrArgs)]

This changes the type of procedural macro that is used to generate the parsing logic. Since the only code that was being generated was a single impl syn::parse::Parse for Foo, it made more sense that it should be a derive macro. This should help create more readable code when other derive macros are used on the same struct.

Adds Support for Short-Form Boolean Values

Previously when specifying a boolean parameter value within the attribute, the following syntax had to be used: #[my_attr(flag = true)]. Now the following syntax can be used when providing a true value for a boolean parameter: #[my_attr(flag)].

Bug Fixes

Panicking on Parse Failure

Previously the generated parsing logic for the attribute parameters would panic if there was an error converting from the raw parameter value to the field type of the Rust struct. This caused issues when parsing enums that were tagged with procedural macro. The code no longer panics and will instead return an error and attempt subsequent parsing logic.

v0.4.0

09 Jun 11:10

Choose a tag to compare

Features

Array Parameter Values

Attribution now supports parameters which accept a collection of parameter values. These are expressed as array literals in the attribute.

Example

#[attr_args]
struct AttrArgs {
    array: Vec<i64>
}

#[my_attr(array = [1, 2, 3])]
fn foo() {
    // ...
}

Bug Fixes

  • Fixes an issue where tagging an enum with the #[attr_args] attribute would cause warnings to be generated on all variants.

v0.3.0

26 May 11:43
eebe299

Choose a tag to compare

Features

Tagged Tuple Structs

Tuple structs can now be tagged with #[attr_args] which allows for attributes using unnamed parameters.

Example

#[attr_args]
struct Foo (String);

#[foo("Value")]
fn bar() {
    //...
}

Tagged Enums

Now users can use the #[attr_args] attribute on enums to allow for custom attributes that have multiple forms.

Example

#[attr_args]
enum Foo {
    Both { first: String, second: String },
    FirstOnly { first: String },
    UnnamedFirstOnly(String),
    SecondOnly { second: String }
}

#[foo(first = "First", second = "Second")] // Valid
#[foo(first = "First")] // Valid
#[foo("First")] // Valid
#[foo(second = "Second")] // Valid
#[foo()] // Invalid
fn bar() {
    //...
}

Second Release

10 Aug 01:20
96ccb81

Choose a tag to compare

Second Release Pre-release
Pre-release

This release adds the ability to parse custom types by converting from ParamVals and includes a custom type DynamicParameters that can be used to parse all otherwise unspecified parameters into a mapping of parameter name to ParamVal

First release

24 Jul 01:43

Choose a tag to compare

First release Pre-release
Pre-release

This is the initial release of attribution. It contains support for parsing attribute that have a static form (all parameters of the attribute are required).