Auto infer namespaces on struct and enum instantiations

let _ { field, .. } = struct_value feels totally adequate. However _::Variant is, imho, way to syntax heavy. .Variant is much better but at the same time it doesn't look like regular Rust. I don't have a good solution unfortunately.

Do you mean "syntax heavy"? I guess it is on the heavier end. But it follows rust's conventions if you consider that the _ is replacing a type name which should be able to be inferred from context.

6 Likes

Yes, looks like I cannot spell that word!

I was thinking about the syntax and I found that the meaning is different. For example:

In the expression _::Something the _ means auto-complete the rest of the namespaces. So it would be evident to use it like this something::_::Something or this _::something::Something.

While . is a tiny black hole that sucks every namespace into itself. It lefts no confusion. It doesn't exist in rust, but it doesn't mean it cannot fit well.

I'm not saying the one is better than the other, but this may help to accept the black hole operator better.

At the end of the day, we can keep this choice to the core language team.

It wouldn't be to infer the rest of the path, it would be to infer the enum/struct name which may or may not be in scope. That's a significant difference.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.