[~OT] Go generics

While I like the idea of anonymous enums (my proposal), I would strongly prefer to be explicit about type conversions. Your last example could look like this instead:

fn foo(cond: bool) -> impl Debug {
    if cond {
        become 42 as i32
    } else {
        become "foo"
    }
}

Why not enum impl Trait + implicit conversion? I think anonymous enum is just an implementation detail, so it should not be expressed in function signatures.

3 Likes