Skip to content

doc: fix code for hello world example #2987

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

Closed
wants to merge 1 commit into from
Closed

doc: fix code for hello world example #2987

wants to merge 1 commit into from

Conversation

fsouza
Copy link
Contributor

@fsouza fsouza commented Jul 22, 2012

This change closes #2986.

@z0w0
Copy link
Contributor

z0w0 commented Jul 22, 2012

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
Copy link
Contributor Author

fsouza commented Jul 22, 2012

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.
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