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

Strings chapter: &String doesn't actually coerce to &str #21850

Closed
FreeFull opened this issue Feb 1, 2015 · 4 comments
Closed

Strings chapter: &String doesn't actually coerce to &str #21850

FreeFull opened this issue Feb 1, 2015 · 4 comments

Comments

@FreeFull
Copy link
Contributor

FreeFull commented Feb 1, 2015

"Strings will coerece into &str with an &:

fn takes_slice(slice: &str) {
    println!("Got: {}", slice);
}

fn main() {
    let s = "Hello".to_string();
    takes_slice(&s);
}

"
This example should have &*s rather than &s, and the line above it should be reworded, since this isn't a coercion. (Note coerce is misspelled as coerece)

@retep998
Copy link
Member

retep998 commented Feb 2, 2015

&s is actually valid now due to #21351.

@FreeFull
Copy link
Contributor Author

FreeFull commented Feb 2, 2015

Ah, I've missed that. The spelling mistake is the only bug, then.

@FreeFull
Copy link
Contributor Author

FreeFull commented Feb 2, 2015

#21852 Fix for the spelling mistake.

@alexcrichton
Copy link
Member

Fixed in #21852

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

No branches or pull requests

5 participants