15
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 26 Sep 2024
15 points (100.0% liked)
Rust Programming
9142 readers
2 users here now
founded 6 years ago
MODERATORS
I think you already used a pretty nice way, which is using shadowing. If one variable is only used for the creation of another, simply shadowing it keeps your namespace clean.
Sometimes it doesn't make sense to give the shadowed variable the same name, because that name doesn't describe its content very well. But in this case it seems like that is not a concern.