Skip to content
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

Should static variables be annotated &'static or not? #2689

Closed
wpd opened this issue Apr 8, 2021 · 2 comments
Closed

Should static variables be annotated &'static or not? #2689

wpd opened this issue Apr 8, 2021 · 2 comments
Labels

Comments

@wpd
Copy link
Contributor

wpd commented Apr 8, 2021

According to the text in src/ch19-01-unsafe-rust.md, "we must annotate the variable’s type, which is &'static str", but the example shown in listings/ch19-advanced-features/listing-19-09/src/main.rs is:

static HELLO_WORLD: &str = "Hello, world!";

fn main() {
    println!("name is: {}", HELLO_WORLD);
}

which does not declare HELLO_WORLD as &'static str. This could be confusing to other newbies (besides myself :-) ).

@steveklabnik
Copy link
Member

This is basically a bug in the book, you used to have to, but don't any more. We should update the text for sure :)

@carols10cents
Copy link
Member

Fixed in #2692.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants