-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attributes for Param, SelfParam, and StructField types #521
Comments
How would disabling a struct field work? Renaming, sure, but I can't see how disabling would work. But yes, we should support this. Figuring out the inheritance might be tricky. |
Disable was something of a random example, for a more specific use case for #500, the current attribute syntax looks something like this: impl ICU4XLocale {
/// Construct an [`ICU4XLocale`] from a locale identifier represented as a string.
#[diplomat::attr(supports = constructors, constructor)]
#[diplomat::demo(input(name(label = "Locale Name")))]
pub fn new(name: &DiplomatStr) -> Box<ICU4XLocale> {
Box::new(ICU4XLocale(Locale::try_from_bytes(name).unwrap()))
}
} Could avoid a lot more boilerplate with this: impl ICU4XLocale {
/// Construct an [`ICU4XLocale`] from a locale identifier represented as a string.
#[diplomat::attr(supports = constructors, constructor)]
pub fn new(
#[diplomat::demo(label = "Locale Name")]
name: &DiplomatStr) -> Box<ICU4XLocale> {
Box::new(ICU4XLocale(Locale::try_from_bytes(name).unwrap()))
}
} |
Ah, yes, that would be fine. Some thought needs to be given to inheritance, I'd assume that most attributes do not inherit past this boundary |
Shouldn't be hard to add support for if you're thinking of doing it! |
Per rust-lang/rust#60406 and https://doc.rust-lang.org/reference/attributes.html, attributes can be positioned in struct fields or parameters positions. Diplomat currently does not have an
attrs
field for theParam
,ParamSelf
, orStructField
types.This is something that would be especially nice to have for #500.
So for instance, you'd be able to write something like
Or
The text was updated successfully, but these errors were encountered: