Why can't you disambiguate via cast on a variable

⚓ Rust    📅 2026-01-10    👤 surdeus    👁️ 2      

surdeus

Why can't you do (bar as Foo<4>).foo() for a trait Foo<const F:u8> much the same way you can do <Bar as Foo<4>>::foo() if bar were a type instead?
Foo::<4>::foo(bar) is not nearly as clear as (bar as Foo<4>).foo() in terms of communicating that foo is a trait instance method and not a function of some class Foo. Also I don't believe this causes any new ambiguity that wasn't something that would've errored anyway before, but I could be wrong.

Example of what I think it could look like and more on why I have issues with the current system:

1 post - 1 participant

Read full topic

🏷️ Rust_feed