#fields #convert #macro #serde-json #sharing #structs #i32

macro impl-from-into-similar

Implement Into to any struct to convert between structs sharing similar fields. Uses serde_json.

4 releases

0.2.1 Feb 19, 2023
0.2.0 Feb 19, 2023
0.1.1 Feb 19, 2023
0.1.0 Feb 19, 2023

#1975 in Procedural macros

23 downloads per month

MIT license

3KB

Readme generated by Bing AI

impl-from-into-similar

A Rust crate that provides a macro to implement From and Into traits for similar types.

Installation

Add this to your Cargo.toml:

[dependencies] impl-from-into-similar = “0.1.0” 

Usage

Import the crate and use the impl_from_into_similar! macro with two or more types that have similar fields:

use impl_from_into_similar::impl_from_into_similar;

struct Foo { x: i32, y: i32, }

struct Bar { x: i32, y: i32, }

impl_from_into_similar!(Foo, Bar); 

License

This project is licensed under the MIT license.

Dependencies

~3.5–4.5MB
~90K SLoC