Skip to content

Commit cca7047

Browse files
feat(nutype_macros): impl From<T> where T: Into<#inner_type>
Fix greyblake#124
1 parent c8e3f72 commit cca7047

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

nutype_macros/src/common/gen/traits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ pub fn gen_impl_trait_borrow(type_name: &TypeName, borrowed_type: impl ToTokens)
124124

125125
pub fn gen_impl_trait_from(type_name: &TypeName, inner_type: impl ToTokens) -> TokenStream {
126126
quote! {
127-
impl ::core::convert::From<#inner_type> for #type_name {
127+
impl<T: Into<#inner_type>> ::core::convert::From<T> for #type_name {
128128
#[inline]
129-
fn from(raw_value: #inner_type) -> Self {
130-
Self::new(raw_value)
129+
fn from(raw_value: T) -> Self {
130+
Self::new(raw_value.into())
131131
}
132132
}
133133
}

0 commit comments

Comments
 (0)