Skip to content

Returning a lifetime-less reference is confusing #45

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
huonw opened this issue May 1, 2014 · 0 comments
Closed

Returning a lifetime-less reference is confusing #45

huonw opened this issue May 1, 2014 · 0 comments

Comments

@huonw
Copy link
Member

huonw commented May 1, 2014

E.g. http://rustbyexample.com/examples/tuples/README.html

fn chimpanzees() -> (int, &str) {

should really be &'static str. It's actually a bug (rust-lang/rust#2478) that not having the lifetime is even possible. (The compiler inserts anonymous lifetimes where they are missing, but 'static is the super-lifetime of everything, including these anonymous ones, so the &'static str string literals satisfy the return type.)

@japaric japaric closed this as completed in 28aa4ee May 3, 2014
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

1 participant