Skip to content

Guide: option<int> doesn't implement ToStr #17486

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
steveklabnik opened this issue Sep 23, 2014 · 4 comments
Closed

Guide: option<int> doesn't implement ToStr #17486

steveklabnik opened this issue Sep 23, 2014 · 4 comments

Comments

@steveklabnik
Copy link
Member

the part of the guide that shows ::<> doesn't work now, or so I hear. Making an issue to investigate later

@crumblingstatue
Copy link
Contributor

Here is the relevant section:

In a similar fashion, both of these work:

let input_num = from_str::<Option<uint>>("5");
let input_num: Option<uint> = from_str("5");

According to my understanding, the guide is saying here that both of these work, and do the same thing, which is take a string slice, and return an Option<T>.

The first line however, doesn't return an Option<T>.

from_str parameterizes over T, and returns an Option<T>. from_str::<Option<uint>> would actually return Option<Option<uint>>, if it was implemented.

If we change the first line to, let input_num = from_str::<uint>("5");, it works, and seems to be the intended thing.

@steveklabnik
Copy link
Member Author

Yup! #17366 is a PR fixing it in exactly that way. 😄

@aochagavia
Copy link
Contributor

The PR has been merged, so this is no loger an issue

@alexcrichton
Copy link
Member

Thanks!

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

4 participants