Skip to content

Consider implementing From<T> where T: Into<#inner_type>? #124

Closed
@schneiderfelipe

Description

@schneiderfelipe

Currently derive(From) produces

pub fn gen_impl_trait_from(type_name: &TypeName, inner_type: impl ToTokens) -> TokenStream {
quote! {
impl ::core::convert::From<#inner_type> for #type_name {
#[inline]
fn from(raw_value: #inner_type) -> Self {
Self::new(raw_value)
}
}
}
}

Is there anything holding back the production of something like the following?

quote! {
    impl<T: Into<#inner_type>> ::core::convert::From<T> for #type_name {
        #[inline]
        fn from(raw_value: T) -> Self {
            Self::new(raw_value.into())
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions