Skip to content

Support for value types #1

@Drizin

Description

@Drizin

If you have a type OneOf<T0, T1> where T0 (for example) is non-null value type (like int, or enum) and you deconstruct it then T1 will always get a non-null value.

To achieve the right semantic (where only one of the types should return a non-null value, like the discriminated-union type) you would need to convert T0 to a Nullable<T0>. Unfortunately this can only work value types (where T0: struct), so there's no easy solution that works with all cases.

If you're interested please check my solution here: https://github.com/Drizin/OneOf.DeconstructorExtensions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions