-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guide: section on for loops shows C code which can be mistaken for Rust code #17228
Comments
👍 |
I called it a "C for loop" because even in JavaScript, Ruby, and Python, they also tend to call this notation a "C-style for loop." That said, the playpen link is certainly bad. |
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Sep 13, 2014
Without 'notrust,' we were getting a playpen link. Fixes rust-lang#17228.
Being a C++ developer, it is easier for me understand what happens when the C version is presented first and then compared to how Rust does it... |
lnicola
pushed a commit
to lnicola/rust
that referenced
this issue
May 19, 2024
…kril internal: Sort computed runnables Fixes rust-lang/rust-analyzer#17223
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Section 11.1 on for loops unusually begins by showing C syntax, saying "Rust's for loop doesn't look like this C for loop:"
In my opinion that is a strange way to introduce Rust's for loops.
Furthermore the C code is not clearly indicated to be in another language, so someone casually perusing the documentation may not notice that it is from another language.
Lastly, the C code has a link to the rust play pen, which obviously results in a syntax error if you try to run it:
:2:12: 2:13 error: expected
,
, found=
:2 for (x = 0; x < 10; x++) {
I think it would be better to introduce Rust's notation first, and then perhaps make a passing remark that this is different to some languages (such as C) - though it is also similar to other languages, such as Python.
The text was updated successfully, but these errors were encountered: