-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
@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
Labels
No labels