-
Notifications
You must be signed in to change notification settings - Fork 123
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
Extracting struct name from Value? #264
Comments
So I spent some time playing around with adding:
But the problem I'm running into is that serde's data model seems to force losing struct names when combined with the lack of a parser separate from serde. What I see:
I think in order for this to work there has to be a parser independent of any use of serde that can translate text streams into RON Values. |
If that's something Serde lacks, but is needed, would there be an upstream issue about this? |
I found serde-rs/serde#1345 which suggests wrapping in a struct with one field that is the name of the actual struct. They link to a helper crate that a later commenter says is broken though. |
Issue has had no activity in the last 180 days and is going to be closed in 7 days if no further activity occurs |
Looking at the docs for Value:
I don't see how to get the name of a struct out, e.g. if I were to call
from_str
on the contents ofexample.ron
, how would I get the string "Nested" out of it? My use case is the following: I want to have a field that could be one of many different structs. I'd like to parse into a ron Value, check the parsed struct name, then based on that name choose which actualT
to pass tointo_rust
. I couldn't find this in the examples/docs.The text was updated successfully, but these errors were encountered: