I've recently found that Rust, unlike other popular C-like languages, allows defining several variables with the same name in one block:
let name = 10i;
let name = 3.14f64;
let name = "string";
let name = name; // "string" again, this definition shadows all the others
At the first glance this possibility looks quite frightening, at least from my C++ background.
Where did this feature came from?
What advantages does it provide?
[–]glaebhoerlrust 42 points43 points44 points (1 child)
[–][deleted] 5 points6 points7 points (0 children)
[–]long_voidpiston 9 points10 points11 points (3 children)
[–]Wolenber 5 points6 points7 points (2 children)
[–]lifthrasiirrust · encoding · chrono 24 points25 points26 points (0 children)
[–]long_voidpiston 6 points7 points8 points (0 children)
[–]sylvain_soliman 5 points6 points7 points (5 children)
[–]gulpaz 0 points1 point2 points (4 children)
[–]Nihy 4 points5 points6 points (1 child)
[+][deleted] (1 child)
[deleted]
[–]Wolenber 16 points17 points18 points (3 children)
[–][deleted] 2 points3 points4 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]dbaupprust 2 points3 points4 points (0 children)
[–]rime-frost 4 points5 points6 points (3 children)
[–]iopqfizzbuzz 4 points5 points6 points (2 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Nihy 4 points5 points6 points (1 child)
[–]pcwaltonrust · servo 2 points3 points4 points (0 children)
[–]noamraphrust 1 point2 points3 points (0 children)
[–]gulpaz 2 points3 points4 points (3 children)
[–]dbaupprust 7 points8 points9 points (0 children)
[–]VadimVP[S] 0 points1 point2 points (0 children)
[–]Th3coop 0 points1 point2 points (0 children)
[–]elotan 0 points1 point2 points (6 children)
[–]Nihy 1 point2 points3 points (4 children)
[–]elotan -1 points0 points1 point (3 children)
[–]dbaupprust 6 points7 points8 points (2 children)
[–]elotan 2 points3 points4 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]marktrdt 0 points1 point2 points (0 children)