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

Allow bytes for adjacently tagged enums #2377

Merged
merged 1 commit into from May 5, 2023
Merged

Conversation

mfro
Copy link
Contributor

@mfro mfro commented Feb 18, 2023

This pull request will add support for Bytes as the tag and content field name in adjacently tagged enums. This addresses the issue raised here: BurntSushi/rust-csv#278

Code changes are in TagContentOtherFieldVisitor as suggested by the investigation in the above issue, and a unit test is added to cover this case. The unit test currently fails on serde/master.

@mfro mfro changed the title Allow bytes for adjantly tagged enums Allow bytes for adjacently tagged enums Feb 18, 2023
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks!

@dtolnay
Copy link
Member

dtolnay commented May 5, 2023

Published in serde 1.0.162.

crapStone added a commit to Calciumdibromid/CaBr2 that referenced this pull request May 9, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [serde](https://serde.rs) ([source](https://github.com/serde-rs/serde)) | dependencies | patch | `1.0.160` -> `1.0.162` |

---

### Release Notes

<details>
<summary>serde-rs/serde</summary>

### [`v1.0.162`](https://github.com/serde-rs/serde/releases/tag/1.0.162)

[Compare Source](serde-rs/serde@v1.0.161...1.0.162)

-   Support deserializing flattened adjacently tagged enums from data formats which represent fields as bytes, such as the `csv` crate ([#&#8203;2377](serde-rs/serde#2377), thanks [@&#8203;mfro](https://github.com/mfro))

    ```rust
    #[derive(Deserialize)]
    pub struct Record {
        common: u64,
        #[serde(flatten)]
        kind: Kind,
    }

    #[derive(Deserialize)]
    #[serde(tag = "kind", content = "parameter", rename_all = "lowercase")]
    enum Kind {
        Foo(u64),
        Bar(bool),
    }
    ```

    ```csv
    common,kind,parameter
    1,foo,42
    2,bar,true
    ```

### [`v1.0.161`](https://github.com/serde-rs/serde/releases/tag/v1.0.161)

[Compare Source](serde-rs/serde@v1.0.160...v1.0.161)

-   Improve error messages produced by serde_test on test failure ([#&#8203;2435](serde-rs/serde#2435), thanks [@&#8203;Mingun](https://github.com/Mingun))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43Mi4xIiwidXBkYXRlZEluVmVyIjoiMzUuNzIuMSIsInRhcmdldEJyYW5jaCI6ImRldmVsb3AifQ==-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Co-authored-by: crapStone <crapstone01@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1891
Reviewed-by: crapStone <crapstone@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants