duplicate
Provides macros for duplication of code with variable substitution.
2.0.1
21M downloads/mo
#2043 most downloaded on crates.io
Emoun/duplicate
What this package is like to depend on
Last release 9 months ago
03 Nov 2025
Release timing varies
gaps range from 3 weeks to 1.5 years
Most releases are documented
notes for 18 of 23 stable releases
1 version withdrawn
withdrawn after publishing
6 years old
24 releases · first in 2020
1 release in the last 12 months
see the full history below
Release timeline
24 releases · Apr 2020 to Nov 2025Releases
latest 24-
2.0.103 Nov 2025Release notes
Open source →Changed
- Documentaion on nested invocations now clarifies that inner calls to
duplicateare expanded before outer calls.
Fixed
- Hints no longer print unusual Unicode characters. This was caused by an issue with the
proc-macro2-diagnosticscrate. - Fixed an issue where nested calls would result in outer calls only using substitutes from the first substitution group in all duplicates.
- Module disambiguation now produces an error if no substitution identifier is suitable for disambiguating the module name. See #64
- Documentaion on nested invocations now clarifies that inner calls to
-
2.0.016 Sep 2024Release notes
Open source →Added
substitute!andsubstitute_itemallow the use of global substitutions without duplication. See #49.
Changed
- [BREAKING] Increased base MSRV to 1.65.
- [BREAKING]
duplicate!andduplicate_itemno longer allow using exclusively global substitutions. - Edition increased to 2021.
- Replaced
proc-macro-errordependency withproc-macro2-diagnosticsfor printing nice error messages and hints. See #61. - Updated
heckdependency to version 0.5.
-
1.0.010 Mar 2023Release notes
Open source →Changed
- Overhauled the
pretty_errorsfeature to more consistently provide useful hints and code highlights. See #19.
Fixed
duplicatenow also substitutes the invocations of nestedduplicate's. See #48.- Forgetting to enclose subtitution parameters in brackets now reports sensible error. See #30.
- Short syntax no longer accepts providing no substitution groups after the identifier list. See #29.
- Fixed several issues where code was accepted which shouldn't have been.
- Overhauled the
-
0.4.117 Jul 2022Release notes
Open source →proc_macro::Spantracks the edition of the code.
Previously, duplicate's edition was inserted into the expanded
code by not setting the span of createdproc_macro::Groups.Added one specific test (in tests/no_features/edition_2021)
that exhibits the problem, however, it is difficult to know
if there are other cases.
The testensure_no_group_newwas added to try and catch
any wrong creation of groups in the future.Release notes
Open source →Fixed
- Fixed an issue where
duplicate's edition would leak into the user's code. See #47.
- Fixed an issue where
-
0.4.020 Feb 2022Release notes
Open source →Added
- Nested invocations can now be used everywhere.
Changed
- [BREAKING] Renamed
duplicate::duplicatetoduplicate::duplicate_item. See #40. - [BREAKING] Renamed
duplicate::duplicate_inlinetoduplicate::duplicate. See #40. - [BREAKING] Nested invocation now uses
duplicate!{[<invocation>] <body>}syntax instead of#[<invocation>][<body>]. See #28. - [BREAKING] Increased base MSRV to 1.42. See #45
- [BREAKING] Relaxed MSRV policy. Only the minimal versions of direct and transitive dependencies are guaranteed to work for the MSRV. See #44
- No longer pinning dependencies following new MSRV policy.
- Updated
heckdependency to version 0.4.
-
0.3.008 Jun 2021Release notes
Open source →Added
- Global Substitution: Allows substitutions that are applied to all duplicates equally. See #23.
Changed
- [BREAKING] Limited which group delimiters are allowed in various syntactic positions. The specific delimiters required now follow the use of delimiters in previous documentation examples. See #25.
- Substituted the
convert_casedependency forheck. See #22.
Fixed
-
0.2.928 Sep 2020 -
0.2.824 Sep 2020Release notes
Open source →This ensures that the duplicate_inline invocation is not
regarded as a statement (in the previously automatically
added main) which is unsupported for rust <1.45. -
0.2.710 Aug 2020Release notes
Open source →Added
duplicate_inline: Function-like procedural macro version ofduplicate. Has the same functionality, but can be used in other contexts and can duplicate any number of items. See also #6.
Changed
- Updated
proc_macro_errordependency to version 1.0.4.
-
0.2.613 Jul 2020Release notes
Open source →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_errorsfeature is enabled. - The dependence on the
proc_macro_errorcrate is now optional and used by thepretty_errorsfeature.
- New feature named
-
0.2.529 Jun 2020Release notes
Open source →Fixed
- Fixed a build issue when using version 1.0.3 of
proc_macro_error. See #11.
Changed
- The
proc_macro_errordependency is fixed to version 1.0.3 to avoid potential breaking changes with future updates to that crate.
- Fixed a build issue when using version 1.0.3 of
-
0.2.423 Jun 2020Release notes
Open source →Fixed
- Fixed issue with the short syntax where substitutions that included any bracket type would be expanded wrong. See #9.
-
0.2.321 Jun 2020 withdrawnRelease notes
Open source →Added
- Short syntax now supports parameterized substitution. This allows identifiers to take arguments that can be used to customize the substitution for each use. See #5.
-
0.2.217 May 2020Release notes
Open source →Added
- Short syntax now supports nested macro invocations. Can only be used after the initial list of substitution identifiers. See #2.
Changed
- Updated documentation. The short syntax is now used for the primary examples.
- Crate readme license section no longer includes paragraph on the licensing of contibutions.
Fixed
- Fixed an issue where
#[duplicate(..)]would throw an error if it was generated by a macro expansion. It would fail if a substitution identifier originated from a macro variable. This is caused by the variable's expansion sometimes being wrapped in a group with no delimiters, whichduplicatecouldn't handle.
-
0.2.126 Apr 2020 -
0.2.026 Apr 2020Release notes
Open source →Added
- Crate readme changelog section now asserts the use of Semantic Versioning and Keep a Changelog.
Changed
- New short syntax with row-based substitution groups instead of the old column-based syntax. See github issue.
-
0.1.512 Apr 2020Release notes
Open source →Changed
- Crate readme format titles are now bigger than changelog entries.
-
0.1.412 Apr 2020Release notes
Open source →Added
- Crate readme now includes list of changes when published to
crates.io.
- Crate readme now includes list of changes when published to
-
0.1.312 Apr 2020Nothing published for this version
-
0.1.209 Apr 2020Release notes
Open source →Added
duplicateattribute macro for code duplication and substitution.- Short invocation syntax for
duplicate. - Verbose invocation syntax for
duplicate.
-
0.1.109 Apr 2020Nothing published for this version
-
0.1.008 Apr 2020Nothing published for this version
-
0.0.104 Apr 2020Nothing published for this version
-
0.0.004 Apr 2020Nothing published for this version