3 ms·
Thanks for this example. I wasn't aware if that. But still no idea why I need to write: fn poly(a: impl Display) { println!("{a}"); } instead
by scotty79 4y ago
Thanks for this example. I wasn't aware if that. But still no idea why I need to write:
fn poly(a: impl Display) {
println!("{a}");
}
instead of just
fn poly(a: Display) {
println!("{a}");
}
Can I use same identifier for type and trait at the same time?
- GolDDranks 4y agoYeah, it could be that the compiler just referred back to the definition of the name to see if it is a type or a trait. Actually, there was a plan to implement that behaviour, but it was given up in favor of the current "explicit" style. There was some fears of confusing traits and types being more confusing in the long run.