Skip to content

Commit

Permalink
feat(nutype_macros): impl From<T> where T: Into<#inner_type>
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiderfelipe committed Feb 14, 2024
1 parent c8e3f72 commit cca7047
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nutype_macros/src/common/gen/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ pub fn gen_impl_trait_borrow(type_name: &TypeName, borrowed_type: impl ToTokens)

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

0 comments on commit cca7047

Please sign in to comment.