Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hex-literal: allow use | to start comment? #813

Closed
hismito opened this issue Oct 19, 2022 · 5 comments
Closed

hex-literal: allow use | to start comment? #813

hismito opened this issue Oct 19, 2022 · 5 comments

Comments

@hismito
Copy link

hismito commented Oct 19, 2022

hex!(
    "
    31 0a 32 0a 33 0a 34 0a  35 0a 36 0a 37 0a 38 0a  |1.2.3.4.5.6.7.8.
    39 0a 31 30 0a                                    |9.10.
    "
);

It's pretty common to separates hex and ascii by |, this would enable copy-paste without any modification.

@tarcieri
Copy link
Member

Personally I'd prefer to keep the number of comment syntaxes to a minimum for the sake of not overcomplicating the implementation

@newpavlov
Copy link
Member

I agree. IIRC we declined request to support # for comments, so I don't think we should accept |l. Honestly, it may be worth to even completely forbid comments inside literals and instead recommend to use standard Rust comments with multi-literal hex!. Your example would look like this:

hex!(
    "31 0a 32 0a 33 0a 34 0a  35 0a 36 0a 37 0a 38 0a"  // 1.2.3.4.5.6.7.8.
    "39 0a 31 30 0a"                                    // 9.10.
);

@tarcieri
Copy link
Member

FWIW there are several things that use the existing comment syntax. I would prefer not adding churn to remove it.

@newpavlov
Copy link
Member

newpavlov commented Oct 20, 2022

Well, hex-literal v0.3 will continue to work without any changes, so people who don't want to edit comments can simply continue to use it as-is.

Advantages of forbidding comments inside literals:

  • Comments will be properly highlighted in code editors and snippets
  • Significant simplification of the hex-literal code

hex-literal is quite stable, so it may be worth to consider releasing v1.0 sometime next year (though, ideally, I would like to get MSRV-dependent dependency version resolution before that).

@newpavlov
Copy link
Member

Since we both agree regarding the OP's proposal, I will close this issue and will open a separate one for discussing potential v1.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants