|
|
|
|
|
by masklinn
1177 days ago
|
|
Definitely super useful, especially in a language where such conversions are rather common. Also useful because you can’t have abstracted local types, so let’s say you’re building an iterator in a language with interfaces you could do something like let it: Iterator = some().thing();
// intermediate stuff
it = it.some().transform();
// more intermediate stuff
it = it.final().transform();
But in Rust that won’t work, every adapter yields a different concrete type, you’d have to box every layer to make them compatible. Intra-scope shadowing solves that issue.The biggest downside is that it’s possible to reuse names for completely unrelated purposes, which can make code much harder to understand. Clippy has a shadow_unrelated lint but it’s allowed by default because it’s a bit limited. |
|