Derive Macro fundamental_data_type::FromInner
source · #[derive(FromInner)]
Expand description
Alias for derive From
. Provides an automatic From
implementation for struct wrapping a single value.
This macro simplifies the conversion of an inner type to an outer struct type when the outer type is a simple wrapper around the inner type.
§Example Usage
Instead of manually implementing From< bool >
for IsTransparent
:
pub struct IsTransparent( bool );
impl From< bool > for IsTransparent
{
#[ inline( always ) ]
fn from( src : bool ) -> Self
{
Self( src )
}
}
Use #[ derive( FromInner ) ]
to automatically generate the implementation:
#[ derive( FromInner ) ]
pub struct IsTransparent( bool );
The macro facilitates the conversion without additional boilerplate code.