duplicate
Attribute macro for code duplication with substitution.
Motivation
If you find yourself in need of copying a block of code and then making some small changes to fit the new use case, this crate is for you.
The duplicate
attribute macro will duplicate an item any number of times while inserting custom code in the designated places in each duplicate.
For an in-depth explanation of the syntax and features, see the documentation.
Example
use duplicate;
/// Trait we want to implement for u8, u16, and u32
assert!;
assert!;
assert!;
Expands to:
use duplicate;
/// Trait we want to implement for u8, u16, and u32
assert!;
assert!;
assert!;
Changelog
This project adheres to Semantic Versioning. During initial development (with versions 0.y.z), bumps to the minor version (y) signify breaking changes.
Added
- New feature named
pretty_errors
(enabled by default). When enabled, errors are more detailed and helpful. - New feature named
module_disambiguation
(enabled by default). When enabled, automatically uses a suitable substitution identifier to disambiguate the name of a module being duplicated. See the documentation for more details. See also #7.
Changed
- Errors are now less detailed and helpful unless the
pretty_errors
feature is enabled. - The dependence on the
proc_macro_error
crate is now optional and used by thepretty_errors
feature.
This changelog format is based on Keep a Changelog and shows only the changes since the previous version. See the full changelog for changes to all released versions.