You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letmut range = range(0,10);loop{match range.next(){Some(x) => {println!("{}", x);},None => {break}}}
so if I add the following(in the same main.rs):
let nums = vec![1,2,3];for x inrange(0,10){println!("{}", x);}
the error is:
src/main.rs:19:14: 19:26 error: expected function, found `core::iter::Range<_>`
src/main.rs:19 for x in range(0, 10) {
Is there a way to turn on a warning when such overrides happen? Something that says that this line "overwrites" previous definition of "range"(and maybe point to previous definition too), even though it's true only for a limited(local) scope. (tried to look at rustc -W help)
To avoid confusion, I suggest using a different binding name in that example.
Thoughts?
here: http://doc.rust-lang.org/book/iterators.html
this example will redefine the function range:
so if I add the following(in the same main.rs):
the error is:
Is there a way to turn on a warning when such overrides happen? Something that says that this line "overwrites" previous definition of "range"(and maybe point to previous definition too), even though it's true only for a limited(local) scope. (tried to look at
rustc -W help
)To avoid confusion, I suggest using a different binding name in that example.
Thoughts?
Thanks.
EDIT:
12 places where
range
is a binding thus overriding the function with the same name:https://github.com/rust-lang/rust/search?utf8=%E2%9C%93&q=%22let+mut+range%22&type=Code
https://github.com/rust-lang/rust/search?utf8=%E2%9C%93&q=%22let+range%22&type=Code
The text was updated successfully, but these errors were encountered: