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

Implement serialization of tuple variants of flatten enums #2448

Merged
merged 10 commits into from
Jul 30, 2023

Commits on Jul 11, 2023

  1. Move flatten enum tests to a dedicated module

    (review with "ignore whitespace" option on and editor that shows line moves,
    for example, TortoiseGitMerge)
    Mingun committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    348bc6b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    52a7d40 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f7c5d93 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    ab21d4d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f3d50e5 View commit details
    Browse the repository at this point in the history
  6. Use traditional order for enum variants (Unit, Newtype, Tuple, Struct…

    …) and names for tag and content fields
    Mingun committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    5b96cf1 View commit details
    Browse the repository at this point in the history
  7. Implement tests for crate::private::de::content::VariantDeserializer

    failures (1):
        flatten::enum_::externally_tagged::tuple
    Mingun committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    9939666 View commit details
    Browse the repository at this point in the history
  8. Implement serialization of flattened tuple variants of externally tag…

    …ged enums
    
    The Container struct
    
      struct Container {
        #[serde(flatten)]
        enum_field: Enum,
      }
      enum Enum {
        Tuple(u32, u32),
      }
    
    now can be serialized to JSON as
    
      { "enum_field": [1, 2] }
    
    Deserialization already works
    
    Fixes (1):
        flatten::enum_::externally_tagged::tuple
    Mingun committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    4f922e4 View commit details
    Browse the repository at this point in the history
  9. Move test_flatten_enum_newtype into new group of flatten tests - flat…

    …ten::enum_::externally_tagged::newtype
    Mingun committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    4513a9e View commit details
    Browse the repository at this point in the history
  10. Remove custom implementations of SeqDeserializer and MapDeserializer …

    …for enums
    
    Those deserializers are used to deserialize tuple or struct variants from Content
    which is used by internally tagged enums and by flatten
    
    FlatMapDeserializer is reached in the following tests:
        flatten::enum_::externally_tagged::newtype
        flatten::enum_::externally_tagged::struct_from_map
        flatten::enum_::externally_tagged::struct_from_seq
        flatten::enum_::externally_tagged::tuple
    
    ContentDeserializer is reached in the following tests:
        test_enum_in_internally_tagged_enum
        test_internally_tagged_struct_variant_containing_unit_variant
    Mingun committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    4e5e55b View commit details
    Browse the repository at this point in the history