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

Allow HeaderName to be const-initialized #945

Closed
caspervonb opened this issue May 1, 2023 · 0 comments · Fixed by #946
Closed

Allow HeaderName to be const-initialized #945

caspervonb opened this issue May 1, 2023 · 0 comments · Fixed by #946
Assignees
Labels
enhancement Enhancement to existing functionality

Comments

@caspervonb
Copy link
Collaborator

caspervonb commented May 1, 2023

Use case

Provide constants of known header names in the header module without introducing any allocations.

use async_nats::header::{self, HeaderMap};

fn main() -> Result<(), String> {
  let headers = HeaderMap::new();
  headers.insert(header::NATS_STREAM, "foo".parse()?);
}

Proposed change

  • Add representation that can be initialized with const for known headers.
  • Change constants in in the header module to be const HeaderNames.

Who benefits from the change(s)?

Everyone

Alternative Approaches

No response

@caspervonb caspervonb added the enhancement Enhancement to existing functionality label May 1, 2023
@caspervonb caspervonb self-assigned this May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant