Skip to content

Implicit relationship between FromStr and TryFrom #53167

Closed
@npmccallum

Description

@npmccallum

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-specializationArea: Trait impl specializationC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions