-
Notifications
You must be signed in to change notification settings - Fork 68
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
Missed documentation about how to use derives #165
Comments
This isn't something
This is much too dependent on the struct/enum in question. I'd suggest using If you can't get the enum to do what you want, then I'd suggest using I'm closing this issue - while more examples would be useful, this issue is asking a lot of questions that are specific for a particular use-case. I would be open to PRs with added examples that showcase specific functionality, or one that uses |
I don't see how this helps -- I need to distinquish this situations: // #[xml(...)] present
#[xml(attribute)]
field: (), and // #[xml(...)] does not present
field: (), I think it's darling responsibility
Generally, this issue about missing documentation. My use-case just an illustration, so you can understand what problems I faced -- I even don't know which derive I should use, because their purpose isn't described and there are missing examples of their usage (BOTH the complete compilable code and the input). That is what I'm asking to add. Because I don't see any similar open issue, I've opened this and I think it should stay open until that documentation will be written |
I expect to find an example of an user struct with
From*
trait derived and example of the rust code that it will parse.I want to create a simple filter for
#[derive(serde::Deserialize)]
and convert this:to this:
(i.e. generate a serde rename for all fields with an
#[xml(attribute)]
by prepending to their names an@
symbol)My current code is:
but
props
is obviously does not contain what I want because I even do not specify that I want to processxml
attributes. Where I should do this?I want to get answer to all that questions from the documentation without any third-party support. Can you please add such a documentation.
Then I found #156, it answer on some questions, for example, how to tell what attribute is interested:
But problem in that that
props
alwaysOk()
, even when no attributes are present on the field. How I can check that at leastxml
attribute is present?Ideally, I also want to have a mutually exclusive attributes:
attribute
andcontent
,attribute
andflatten
are mutually exclusive, I want to emit an error if both are present. Could I changeFieldProps
toenum
for this? If yes, what the additional steps I should perform to parse such attributes?It also would be useful, if documentation for each trait will show what code is generated by derives (with cuts if required).
I found that examples in the
examples
folder definitely missing an examples of input which struct could handle, for example, here:darling/examples/consume_fields.rs
Lines 12 to 20 in da38efe
If I understand correctly, that enum could be parsed from
... = "Normal"
,... = "Whisper"
, or... = "Shout"
.If so, this will be useful addition to the documentation.
The similar examples needed for all other structs that derives darling
From*
traits.The text was updated successfully, but these errors were encountered: