Skip to content

Feature Request: strip custom attributes on items #18

@colin-kiegel

Description

@colin-kiegel

@killercup have a use case, were we could use some custom attribute-annotations of struct fields (like #[customDefault(42i32)]. In our case only our own custom-derive extension would be able to make sense of it.

As illustration imagine the following macro invocation to implement the Default trait - but with special_info : i32 = 42i32 instead of 0 for Channel. This is actually quite close to our use case.

custom_derive! {
    #[derive(CustomDefault)]
    struct Channel {
        id: Uuid,
        token: Authentication,
        #[customDefault(42i32)]
        special_info: i32,
    }
}

Now the question is, is there a feasible way of extending rust-custom-derive to filter out those custom attributes on items when writing the rust code?

  • one spontaneous idea would be an explicit blacklist, e.g. #[strip_attributes(customDefault)] in front of the struct itself
  • another spontaneous idea would be an implicit whitelist in rust-custom-derive itself (probably not so good?)

@DanielKeep: How do you feel about the idea in general?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions