Well I'm starting over with rust again, using a basic book (Carlo Milanesi, Beginning Rust) and encountered a confusing error.
Basically when writing following source code.
fn main() {
for n in 1..10 {
print!("{} ", n);
}
}
it does compile on my computer, however when running the exe it throws a syntax error.
Now the troublesome part is this does work on playground, so I am tad confused.
Using the 1.62.0 build of the compiler. Win10 and so far everything has compiled and worked fine.
A syntax error should not be thrown at runtime. What is the error exactly? Maybe you can share a (partial) screen shot of the actual message or paste it here?
I assume that "for" is a special name in the Windows shell. The error is from the shell, not from Rust. Try to rename the program from "for" to "somename".
actually such code does not even compiles, ... is not a operator now.
--> test.rs:2:11
|
2 | for n in 1...10{
| ^^^
|
help: use `..` for an exclusive range
|
2 | for n in 1..10{
| ~~
help: or `..=` for an inclusive range
|
2 | for n in 1..=10{
|
don't know what's wrong with your rustc, but such code should not compile.
the syntax error is another problem:
when you enter for in cmd and press enter, it almost always return syntax error.
$ LC_ALL=C wine cmd
Microsoft Windows 6.1.7601
Z:\me>for
Syntax error
Z:\me>
I think the "..." was a typo when copying the code here to the forum (or a typo that has been fixed meanwhile). The main error was naming the program "for", which can't be called by typing "for" in the Windows shell.