-
Notifications
You must be signed in to change notification settings - Fork 120
feat(toml_edit): Implement IntoDeserializer
for Item
#846
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
base: main
Are you sure you want to change the base?
Conversation
From https://github.com/toml-rs/toml/blob/main/CONTRIBUTING.md
For example, its not clear why you specifically want |
Sorry, I should have created an issue first, or at least explained clearly what I wanted to do in the PR. I want to parse the toml: # ...
[editor]
mouse = true
theme = "onedark"
# ... into a struct: #[derive(serde::Deserialize)]
struct Editor {
mouse: bool,
theme: String,
} Config parsing is part of the system, and elsewhere in the system there is already a |
Pull Request Test Coverage Report for Build 14008023700Details
💛 - Coveralls |
After refreshing myself on this code and the motivations for its design, my concerns are
Also, is there a reason you are using |
In my case, I don't need them since I don't need to know the specific type of the content, and I just need to know it's an
Makes sense, I will try to refactor it - I will set the PR as draft until I complete the refactoring (expected in the next day or two).
|
I'm trying to look for the principles of what the API should be, not handle one off cases. |
My knowledge of API design is very limited, so I might not be the right person to answer this. Before finding such principles, is there any chance of accepting this one-off PR? If not, I can close it - or I can create a separate issue for discussion if that would help. It's all up to you :) |
Hey @epage, I have separated Let me know if there are any other changes needed. |
@@ -35,20 +36,18 @@ use crate::de::Error; | |||
/// # } | |||
/// ``` | |||
pub struct ValueDeserializer { | |||
input: crate::Item, | |||
validate_struct_keys: bool, | |||
inner: ItemDeserializer, | |||
} | |||
|
|||
impl ValueDeserializer { | |||
pub(crate) fn new(input: crate::Item) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it would be better to change crate::Item
to crate::Value
here, but I'm not sure if we should introduce more unrelated changes, as it might make the review more difficult.
If you prefer, I can make this change in a new commit or a separate refactor PR.
I'm working on a config parser based on
toml_edit
that requires the implementation ofIntoDeserializer
for interoperability withserde
.I noticed that
toml_edit::Item
already has aninto_deserializer()
method, but it's not public. So, this PR exposes it by implementing theIntoDeserializer
trait.