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

Add const representation for standard header names #946

Merged
merged 2 commits into from
May 29, 2023

Conversation

caspervonb
Copy link
Collaborator

@caspervonb caspervonb commented May 1, 2023

Add const representation (an enum) for standard known header names.

Closes #945

@caspervonb caspervonb force-pushed the introduce-standard-header-repr branch 2 times, most recently from acf34e8 to 8540f61 Compare May 1, 2023 16:45
@caspervonb caspervonb requested a review from Jarema May 1, 2023 21:17
@caspervonb caspervonb marked this pull request as ready for review May 1, 2023 21:17
@caspervonb caspervonb force-pushed the introduce-standard-header-repr branch 3 times, most recently from 8238589 to 56d6e04 Compare May 8, 2023 14:36
@caspervonb caspervonb force-pushed the introduce-standard-header-repr branch 2 times, most recently from 3d1de1a to 787ff29 Compare May 17, 2023 03:18
@caspervonb caspervonb force-pushed the introduce-standard-header-repr branch from 787ff29 to 23248a3 Compare May 17, 2023 03:19
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks ok, but I'm not happy about reintroducing unsafe block.
Wondering if we can get rid of it.

@caspervonb
Copy link
Collaborator Author

caspervonb commented May 20, 2023

It looks ok, but I'm not happy about reintroducing unsafe block.
Wondering if we can get rid of it.

Can't really get rid of it. It is safe tho, as the data is valid utf-8.

@Jarema
Copy link
Member

Jarema commented May 21, 2023

Can't really get rid of it. It is safe tho, as the data is valid utf-8.

@caspervonb I agree it's safe, but as some of our contributors mentioned, people run checks and disallow libraries with unsafe blocks. That's my concern.

@caspervonb
Copy link
Collaborator Author

@caspervonb I agree it's safe, but as some of our contributors mentioned, people run checks and disallow libraries with unsafe blocks. That's my concern.

I'm not particularly worried about invariants that are known to be safe.
Even basic std string operations contain unsafe blocks.

Difference between just having to call an unsafe function to achieve an operation that is safe for a certain condition and being clever with unsafe hacks are quite different imo.

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@caspervonb caspervonb merged commit f30b3ec into nats-io:main May 29, 2023
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

Successfully merging this pull request may close these issues.

Allow HeaderName to be const-initialized
2 participants