https://issues.dlang.org/show_bug.cgi?id=17015

          Issue ID: 17015
           Summary: support final switch in std.variant
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: [email protected]
          Reporter: [email protected]

As e.g. in https://github.com/s-ludwig/taggedalgebraic:


final switch (taggedAny.kind) {
    case Tagged.Kind.i:
        // It's "int i"
        break;

    case Tagged.Kind.str:
        // It's "string str"
        break;

    case Tagged.Kind.foo:
        // It's "Foo foo"
        break;
}

this has the advantage over visit that the compiler can enforce that all types
are covered.

--

Reply via email to