duplicate icon indicating copy to clipboard operation
duplicate copied to clipboard

Add `substitute` macro(s)

Open Emoun opened this issue 2 years ago • 2 comments

Short Description:

Provide substitute and substitute_item which only provide the global substitution feature of the main macros.

Motivation:

Sometimes, duplicate may be used only to avoid repeating something within the code, but not to duplicate the whole thing. Providing these macro would make the intent more clear for readers of the code that no duplication is happening.

Design

Misc:

Provide substitute! and substitute_item as synonyms for duplicate! and duplicate_item respectively, where only global substitutions are allowed.

Emoun avatar Oct 10 '22 13:10 Emoun

For clarity: Currently this is fully supported by duplicate! and duplicate_item. The new macros would just be a more clear way of showing that we are not actually duplicating anything

Emoun avatar Mar 04 '23 18:03 Emoun

Initial implementation done.

Missing work:

  • [ ] Update root level documentation.
  • [x] Since we are bumping major versions anyway (increased base MSRV), we could change duplicate! and duplicate_item to not allow no duplications.
  • [x] Update changelog
  • [ ] Allow nested substitute! calls, like you can with duplicate!

Emoun avatar Apr 23 '24 10:04 Emoun