Skip to content

doc: fix code for hello world example - #2987

Closed
fsouza wants to merge 1 commit into
rust-lang:masterfrom
fsouza:master
Closed

doc: fix code for hello world example#2987
fsouza wants to merge 1 commit into
rust-lang:masterfrom
fsouza:master

Conversation

@fsouza

@fsouza fsouza commented Jul 22, 2012

Copy link
Copy Markdown
Contributor

This change closes #2986.

@z0w0

z0w0 commented Jul 22, 2012

Copy link
Copy Markdown
Contributor

You seem to be using the stable 0.3.1 release which has the old style of strings. Recently Rust was changed so that all plain str values should be ~str. So the current documentation is correct for the version of Rust I'm using (the latest HEAD from here) however it's not for your version. The documentation for your version is at http://dl.rust-lang.org/doc/0.3/tutorial.html. e.g. this patch fails to build for me:

a.rs:1:16: 1:19 error: bare `str` is not a type
a.rs:1 fn main(args: ~[str]) {
                       ^~~
a.rs:2:16: 2:45 error: binary operation + cannot be applied to type `str/18`
a.rs:2     io::println("hello world from '" + args[0] + "'!");
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.rs:2:16: 2:53 error: binary operation + cannot be applied to type `str/18`
a.rs:2     io::println("hello world from '" + args[0] + "'!");
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

However the current version does. It is kind of awkward for the documentation links to lead to the latest documentation rather than the latest stable, so maybe that should be changed.

@fsouza

fsouza commented Jul 22, 2012

Copy link
Copy Markdown
Contributor Author

Hi @z0w0. Sorry about that, I should checked this at master.

I think the problem with the tutorial is that in Installation it teaches how to install rust 0.3, and then teaches code that works only with the latest code (master).

May I open an issue for this?

@fsouza fsouza closed this Jul 22, 2012
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Jul 23, 2023
celinval pushed a commit to celinval/rust-dev that referenced this pull request Jun 4, 2024
This is currently marked "Beta". Switching is an attempt to address the
memory allocation failures.
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
2987: vscode refactoring: use more laconic export snytax, split huge string literal r=matklad a=Veetaha



Co-authored-by: Veetaha <gerzoh1@gmail.com>
tshepang pushed a commit to tshepang/rust that referenced this pull request Sep 4, 2026
touch-ups to "query system" chapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tutorial: hello world sample program won't compile

2 participants