Skip to content

Implicit relationship between FromStr and TryFrom #53167

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
npmccallum opened this issue Aug 7, 2018 · 4 comments
Closed

Implicit relationship between FromStr and TryFrom #53167

npmccallum opened this issue Aug 7, 2018 · 4 comments
Labels
A-specialization Area: Trait impl specialization C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@npmccallum
Copy link
Contributor

npmccallum commented Aug 7, 2018

When TryFrom is stabilized, it would be really nice if there were an implicit relationship between TryFrom and FromStr. For example:

impl<'a, T: TryFrom<&'a str>> FromStr for T {
    type Err = T::Error;

    fn from_str(value: &'a str) -> Result<T, Self::Err> {
        T::try_from(value)
    }
}

I think, for stability reasons, that this can only be done before TryFrom is stabilized.

@sfackler
Copy link
Member

sfackler commented Aug 7, 2018

That implementation can't be added without specialization.

@memoryruins memoryruins added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-specialization Area: Trait impl specialization C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Sep 15, 2018
@czipperz
Copy link
Contributor

What's the status of this?

@sfackler
Copy link
Member

That implementation can't be added without specialization.

@Mark-Simulacrum
Copy link
Member

Since it's true that we can't add this without specialization, and we've stabilized TryFrom already, I believe that we can basically conclude that this is not something that we can add today. I also believe that this is a sort of unnecessary blanket impl to add so would not want to see it personally too. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-specialization Area: Trait impl specialization C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants