-
Notifications
You must be signed in to change notification settings - Fork 13k
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
FromStr is not implemented for char #24939
Comments
Strings aren't indexable and .len() doesn't count the number of chars. 😄 What comes to mind first is an iterator inspecting the two first chars: let mut chars = s.chars();
match (chars.next(), chars.next()) {
(None, None) => // empty
(Some(c), None) => Ok(c),
_ => // Too many
} |
xD I didn't test my code, but you get the gist. |
cc @aturon |
Triage: this has not been added.
|
PRs welcome! |
I can take this. I was also thinking of adding a |
wait, that wouldn't work bc of lifetime issues regardless, right? :( |
add `FromStr` Impl for `char` fixes rust-lang#24939. is it possible to use pub(restricted) instead of using a stability attribute for the internal error representation? is it needed at all?
I'm not sure if this is an oversight. But the implementation should be trivial. I'll add tests and implement it, if it is fine.
The text was updated successfully, but these errors were encountered: