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

toml: implement decode method for Doc #19318

Merged
merged 1 commit into from
Sep 11, 2023
Merged

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Sep 9, 2023

I.e. toml.parse_file returns a Doc. So it probably makes sense to implement a decode method for it to simplify the decoding process.

It's includes #19317, which is a separate change, I would rebase it after it is resolved.

🤖 Generated by Copilot at dacfe18

This pull request adds a new feature and tests to the toml module. The feature allows decoding TOML documents into custom structs with compile-time type checking. The tests cover the new feature and the error handling of the decode function.

🤖 Generated by Copilot at dacfe18

  • Add a compile-time check to decode function of toml module to ensure struct type argument (link)
  • Add a decode method to Doc struct to allow decoding a parsed TOML document into a custom struct type (link)
  • Add two test functions to vlib/toml/tests/encode_and_decode_test.v to test the new decode method of Doc struct and the error handling of decode function of toml module (link)
  • Add an enum type Title and a struct type Employee to vlib/toml/tests/encode_and_decode_test.v to use as target types for decoding (link)

@ttytm ttytm changed the title toml: check if supported type was passed when it has no method toml: implement decode method for Doc Sep 9, 2023
@ttytm
Copy link
Member Author

ttytm commented Sep 10, 2023

Rebased and included stronger tests as suggested.

@ttytm ttytm marked this pull request as ready for review September 10, 2023 19:49
@spytheman spytheman merged commit 140b5a3 into vlang:master Sep 11, 2023
35 checks passed
Wertzui123 pushed a commit to Wertzui123/v that referenced this pull request Oct 8, 2023
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.

2 participants