https://github.com/sof3/derive-trait
Derive a trait and a delegating impl from an inherent impl block.
https://github.com/sof3/derive-trait
Last synced: 10 months ago
JSON representation
Derive a trait and a delegating impl from an inherent impl block.
- Host: GitHub
- URL: https://github.com/sof3/derive-trait
- Owner: SOF3
- License: apache-2.0
- Created: 2023-10-07T09:53:41.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-10-08T07:03:32.000Z (over 2 years ago)
- Last Synced: 2025-02-28T10:49:06.270Z (11 months ago)
- Language: Rust
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# derive-trait
Derive a trait and a delegating impl from an inherent impl block.
## Why go the opposite way?
This macro is designated for single generic types with many small impl blocks
and complex type bounds in each impl block.
- Without a trait, the function user needs to repeat all the type bounds in the impl block
in every function that requests a type supporting the associated functions.
- Without a macro, the function author needs to write each function signature four times
(the trait, the inherent impl, the trait impl and delegation)
and the type bounds twice.
- With the `#[inherent]` macro, the function author would still need to write twice
(the trait and the trait impl).
Note that use of thsi crate is only advisable for impl blocks with complicated type bounds.
It is not advisable to create single-implementor traits blindly.