Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempt number two/three? Too many in any case.
Previously I proposed a design that followed a
struct
like syntax:However it turns out that this does not work well with named arguments
as reported in issues #369 and #372. The implementation was eventually
reverted in pr #374.
This new design takes inspiration from the
tracing
crate which alreadysupports key-value pairs in logging events. The basic idea is to put the
key-value pairs before the message and arguments. Applying the same
structure like syntax as above we would get something like the
following.
But personally I'm not a big fan of this formatting, let's try putting
everything on a single line instead.
A little better, but at this point the structure like syntax is really
more annoying then helpful. So, instead I've done away it, opting
instead use the following syntax.
Two major differences:
:
) are replaced with equal/assignment signs (=
).This gives us syntax similar to variable assignment.
But then we run in some limitations of the macro syntax, specifically
that
expr
fragments aren't allowed afterexpr
fragments. To fix thisI went with the easiest option of changing the last comma (
,
) afterthe key-value pairs to a semicolon (
;
). Making the final syntax looklike the following.
Which, in my opinion and all things considered, it's too bad looking.
/cc @KodrAus @yoshuawuyts