Skip to content
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

fix: partial support flatten enum in struct #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

greenhat616
Copy link

Close #14

The coding approach is according to ron-rs/ron#451.

The serde_yaml_ng::from_str::<Outer>(yaml).is_err() should always failed with invalid type: unit value, expected a string, which is blocked by serde-rs/serde#1183

src/de.rs Outdated Show resolved Hide resolved
Copy link
Owner

@acatton acatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put some comments on the code. But I have some overall notes.

First of all, I'm a little uneasy with the change. There are at least 3 comments about hacks in this change, which kinda makes me uncomfortable. But I'm a lenient person, so I'm okay giving all of them a pass. I'm just uncomfortable because I'm not fully mastering this topic, or even the bug it's trying to fix.

However, this doesn't break backward compatibility. So I'm strongly considering approving this change.

Even though I don't know yet, there are some things that need to be addressed if you want me be able to merge it.

  1. Please make only one commit. I don't mind multiple commits on changes. But I hate clean up commits. I know this repo has many from me, but as the owner of the repo, I have the right to break my own rules 😄 . I just don't like it when other don't follow my rules 😛 . For this change, I would like to ask you to make only one commit please, because I think it fits nicely into one.
  2. Please rebase onto the master branch, as I've said in one of the comments, the tests were failing when you forked it, and I fixed them ~1h ago. I want the CI to be green before merging this change. It is currently green on master, if it becomes red again, no need to fix it, I'll fix it again. We're regularly running master against the latest clippy, so when clippy adds new checks, it breaks once in a while.
  3. Please use git commit -s as mentionned in the README. This means that you signed off the Developer Certificate of Origin. See more information in my comment about it

Thank you for your patch, with a nice test 🙂 .

tests/test_de.rs Outdated Show resolved Hide resolved
src/de.rs Outdated Show resolved Hide resolved
src/de.rs Outdated Show resolved Hide resolved
src/de.rs Show resolved Hide resolved
src/de.rs Outdated Show resolved Hide resolved
src/de.rs Outdated Show resolved Hide resolved
src/de.rs Outdated Show resolved Hide resolved
src/de.rs Outdated Show resolved Hide resolved
tests/test_de.rs Outdated Show resolved Hide resolved
src/value/tagged.rs Outdated Show resolved Hide resolved
@greenhat616 greenhat616 force-pushed the master branch 2 times, most recently from 4037163 to 35bb238 Compare October 21, 2024 06:44
@greenhat616
Copy link
Author

I have revised the comments and squashed the commits into a single signed commit.

@greenhat616 greenhat616 requested a review from acatton October 21, 2024 06:47
src/de.rs Outdated Show resolved Hide resolved
Copy link
Owner

@acatton acatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at it. I'm not gonna lie, it's not my favorite change, but I think it's fine.

I would like to ask you to fix the comment from Mingun (I commented on it). Other than that I think we're good to go. 👍

Thanks for your contribution 🙂

@greenhat616 greenhat616 force-pushed the master branch 2 times, most recently from ec3a7c0 to 39cfdee Compare November 4, 2024 08:51
@greenhat616
Copy link
Author

Hi. I have updated the adviced lines.

@greenhat616 greenhat616 requested review from acatton and Mingun November 5, 2024 12:08
src/de.rs Show resolved Hide resolved
src/de.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Mingun Mingun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accidentally send two comments without starting review.

My main concern here that this changes is not described in the code, how they are worked and why in that way.

I understood that you've represent tagged YAML values as maps and use visit_map when deserializing value is serde's Content, but it is not quite clear why it is needed to call visit_map for that? Why visit_enum does not work or why we cannot use visit_map in all cases?

src/de.rs Outdated Show resolved Hide resolved
tests/test_de.rs Outdated Show resolved Hide resolved
src/value/tagged.rs Outdated Show resolved Hide resolved
src/value/tagged.rs Outdated Show resolved Hide resolved
src/value/tagged.rs Outdated Show resolved Hide resolved
src/value/de.rs Outdated Show resolved Hide resolved
@greenhat616
Copy link
Author

Hi, I’ve got a bit of a breather from my busy work, and over the next few days, I’ll start addressing these reviews.

Close acatton#14.

I adapted the implementation from [ron-rs/ron#451](ron-rs/ron#451).

This is a workaround for Serde's internal buffer type used when deserializing via `visit_enum`.

Signed-off-by: Jonson Petard <41122242+greenhat616@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Newtype enum variant deserialization failure when used with #[serde(flatten)]
3 participants