inter-struct

Experimental autogenerated traits for operations between arbitrary structs (in the same crate).

MIT License

Downloads
27.9K
Stars
19
Committers
2
inter-struct - Latest Release

Published by Nukesor 10 months ago

[0.2.1] - 16-12-2023

Misc

  • Bump syn dependency to v2.
inter-struct - v0.2.0

Published by Nukesor 10 months ago

[0.2.0] - 31-05-2022

Changed

  • Refactor structure of public API and rename derive macros.
inter-struct -

Published by Nukesor over 2 years ago

[0.1.0] - 30-12-2021

This is the first MVP release of the inter-struct library.

It's purpose is to implement traits between various structs.

Added

Traits:

  • StructMerge trait which implements functions to merge a given struct into Self.
  • StructMergeInto trait.
    The counterpart of StructMerge which merges Self into a target struct.
    StructMerge is automatically implemented.
  • StructMergeRef trait which implements functions to merge a reference of given struct into Self.
    The fields to be merged then need to implement Clone.
  • StructMergeIntoRef trait.
    The counterpart of StructMergeRef, which merges &Self into a target struct.
    StructMergeRef is automatically implemented.

Derive Macro:

  • InterStruct The main derive macro for this crate.

Derive Macro Attributes:

  • merge attribute for generating StructMergeInto and the auto-implemented StructMerge implementations.
  • merge_ref attribute for generating the StructMergeRefInto and the auto-implemented StructMergeRef implementations.
  • into attribute for generating std::convert::From and the auto-implemented std::convert::Into implementations.
  • into_default attribute for generating std::convert::From and the auto-implemented std::convert::Into implementations.
    This populates all non-matching fields by calling Default::default for the target struct.