PackageTrack
Sign in Get early access

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 2025
2021 2022 2023 2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 24
  1. 2.0.1 03 Nov 2025
    Release notes

    Module disambiguation now errors if cannot disambiguate.

    Open source →
    Release notes

    Changed

    • Documentaion on nested invocations now clarifies that inner calls to duplicate are expanded before outer calls.

    Fixed

    • Hints no longer print unusual Unicode characters. This was caused by an issue with the proc-macro2-diagnostics crate.
    • 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
    Open source →
  2. 2.0.0 16 Sep 2024
    Release notes

    [CI] Removed beta channel from testing temporarily

    Open source →
    Release notes

    Added

    • substitute! and substitute_item allow the use of global substitutions without duplication. See #49.

    Changed

    • [BREAKING] Increased base MSRV to 1.65.
    • [BREAKING] duplicate! and duplicate_item no longer allow using exclusively global substitutions.
    • Edition increased to 2021.
    • Replaced proc-macro-error dependency with proc-macro2-diagnostics for printing nice error messages and hints. See #61.
    • Updated heck dependency to version 0.5.
    Open source →
  3. 1.0.0 10 Mar 2023
    Release notes

    Additional error reporting improvements.

    Open source →
    Release notes

    Changed

    • Overhauled the pretty_errors feature to more consistently provide useful hints and code highlights. See #19.

    Fixed

    • duplicate now also substitutes the invocations of nested duplicate'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.
    Open source →
  4. 0.4.1 17 Jul 2022
    Release notes

    proc_macro::Span tracks the edition of the code.
    Previously, duplicate's edition was inserted into the expanded
    code by not setting the span of created proc_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 test ensure_no_group_new was added to try and catch
    any wrong creation of groups in the future.

    Open source →
    Release notes

    Fixed

    • Fixed an issue where duplicate's edition would leak into the user's code. See #47.
    Open source →
  5. 0.4.0 20 Feb 2022
    Release notes

    Also added correct name to copyright files.

    Open source →
    Release notes

    Added

    • Nested invocations can now be used everywhere.

    Changed

    • [BREAKING] Renamed duplicate::duplicate to duplicate::duplicate_item. See #40.
    • [BREAKING] Renamed duplicate::duplicate_inline to duplicate::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 heck dependency to version 0.4.
    Open source →
  6. 0.3.0 08 Jun 2021
    Release notes

    Removed Travis CI configuration.

    Open source →
    Release notes

    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_case dependency for heck. See #22.

    Fixed

    • Now also substitutes code inside substitution arguments. See #24.
    • Module_disambiguation: Now only substitutes the module name and not any matching identifier in the body of the module. See #27.
    Open source →
  7. 0.2.9 28 Sep 2020
    Release notes

    Updated the changelog and documentation to reflect this.

    Open source →
    Release notes

    Added

    • New Minimum Supported Rust Version (MSRV) Policy. Briefly, MSRV is 1.34 but may be increased by enabling features. See #18.
    • The crate's readme now contains section on MSRV policy.
    • Parameterized substitution is now also available for the verbose syntax. See #8.
    Open source →
  8. 0.2.8 24 Sep 2020
    Release notes

    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.

    Open source →
  9. 0.2.7 10 Aug 2020
    Release notes

    CI: Updated crates.io API key used by Travis.

    Open source →
    Release notes

    Added

    • duplicate_inline: Function-like procedural macro version of duplicate. 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_error dependency to version 1.0.4.
    Open source →
  10. 0.2.6 13 Jul 2020
    Release notes

    Renamed 'auto_mods' feature to 'module_disambiguation'

    Open source →
    Release notes

    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 the pretty_errors feature.
    Open source →
  11. 0.2.5 29 Jun 2020
    Release notes

    Fixed

    • Fixed a build issue when using version 1.0.3 of proc_macro_error. See #11.

    Changed

    • The proc_macro_error dependency is fixed to version 1.0.3 to avoid potential breaking changes with future updates to that crate.
    Open source →
  12. 0.2.4 23 Jun 2020
    Release notes

    Fixed

    • Fixed issue with the short syntax where substitutions that included any bracket type would be expanded wrong. See #9.
    Open source →
  13. 0.2.3 21 Jun 2020 withdrawn
    Release notes

    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.
    Open source →
  14. 0.2.2 17 May 2020
    Release notes

    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, which duplicate couldn't handle.
    Open source →
  15. 0.2.1 26 Apr 2020
    Release notes

    Changed

    • Updated crate readme to new short syntax.
    Open source →
  16. 0.2.0 26 Apr 2020
    Release notes

    Added

    Changed

    • New short syntax with row-based substitution groups instead of the old column-based syntax. See github issue.
    Open source →
  17. 0.1.5 12 Apr 2020
    Release notes

    Changed

    • Crate readme format titles are now bigger than changelog entries.
    Open source →
  18. 0.1.4 12 Apr 2020
    Release notes

    Added

    • Crate readme now includes list of changes when published to crates.io.
    Open source →
  19. 0.1.3 12 Apr 2020

    Nothing published for this version

  20. 0.1.2 09 Apr 2020
    Release notes

    Added

    • duplicate attribute macro for code duplication and substitution.
    • Short invocation syntax for duplicate.
    • Verbose invocation syntax for duplicate.
    Open source →
  21. 0.1.1 09 Apr 2020

    Nothing published for this version

  22. 0.1.0 08 Apr 2020

    Nothing published for this version

  23. 0.0.1 04 Apr 2020

    Nothing published for this version

  24. 0.0.0 04 Apr 2020

    Nothing published for this version

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive