Skip to content

Comments

flatten_enum.rs added serialize #866

Merged
Mingun merged 1 commit intotafia:masterfrom
dizzyi:master
Jun 7, 2025
Merged

flatten_enum.rs added serialize #866
Mingun merged 1 commit intotafia:masterfrom
dizzyi:master

Conversation

@dizzyi
Copy link
Contributor

@dizzyi dizzyi commented Jun 6, 2025

Added enum serializing to example/flattened_enum.rs

  • added implementation of Serialize to Elem
  • updated comment
  • added comment of expected output under println! statement

note

still trying to familiarize myself with this crate.
I am not sure if @type key should count toward len of map here, it does in this example, not sure if that matter.

run

cargo run --example flattened_enum --features="serialize"

output

Model { elem: [Foo(Foo { a: "1", subfoo: SubFoo { a1: "2", a2: "42", a3: "1337" } }), Bar(Bar { b: "22" })] }
<model><elem type="foo"><a>1</a><subfoo><a1>2</a1><a2>42</a2><a3>1337</a3></subfoo></elem><elem type="bar"><b>22</b></elem></model>

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.

Project coverage is 60.56%. Comparing base (254fbd2) to head (60e1d2c).
Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
examples/flattened_enum.rs 0.00% 22 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #866      +/-   ##
==========================================
- Coverage   60.74%   60.56%   -0.18%     
==========================================
  Files          41       42       +1     
  Lines       16044    16492     +448     
==========================================
+ Hits         9746     9989     +243     
- Misses       6298     6503     +205     
Flag Coverage Δ
unittests 60.56% <0.00%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Mingun
Copy link
Collaborator

Mingun commented Jun 7, 2025

I am not sure if @type key should count toward len of map here, it does in this example, not sure if that matter.

Yes, it should. Usually serialization part with serde are straightforward and not needs additional explanation in addition to official serde guidem, but I'm not against it.

@Mingun Mingun merged commit 2b91987 into tafia:master Jun 7, 2025
7 checks passed
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.

3 participants