-
Notifications
You must be signed in to change notification settings - Fork 11
Substitution in strings #55
Copy link
Copy link
Open
Labels
D-discussionA decision (D) has not been made yet and is open to discussionA decision (D) has not been made yet and is open to discussionI-featureThis issue (I) regards a (potential) feature in the projectThis issue (I) regards a (potential) feature in the projectT-acceptedTriage (T): Initial review accepted issue/PR as validTriage (T): Initial review accepted issue/PR as valid
Metadata
Metadata
Assignees
Labels
D-discussionA decision (D) has not been made yet and is open to discussionA decision (D) has not been made yet and is open to discussionI-featureThis issue (I) regards a (potential) feature in the projectThis issue (I) regards a (potential) feature in the projectT-acceptedTriage (T): Initial review accepted issue/PR as validTriage (T): Initial review accepted issue/PR as valid
Short Description:
Enable substitution within string literals.
Motivation:
Substitution within the contents of string literals fits well with the overall functionality of
duplicate.E.g. it could be used to change the wording on some strings depending on the duplicate.
Additionally, it enables the substitution of documentation comments. Currently, to do so can only be done using the doc attribute and substituting the whole string. Not being able to substitute in docs means our examples of generating different versions of functions for e.g. mutability or async don't work well if you need the documentation to be changed too. See #54. Enabling substitution within strings should (hopefully, needs more investigation) enable substitution within
///comments directly.Lastly, it's not immediately intuitive that substitution wouldn't work within string literals, making it a pain point for users.
Design
During substition, if a string literal is encountered, run the substitutions within it too.
To parse the contents of strings, the litrs crate can be used. See also this stackoverflow answer.
Misc:
Open questions:
&strand notTokenStream(if usinglittrs), meaning the normal method of identifying substitution identifiers wouldn't work. This is especially difficult with parametric substitution.