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

Implement ToHeaderValues for more string types #279

Merged
merged 3 commits into from
Nov 13, 2020

Conversation

yoshuawuyts
Copy link
Member

Implements ToHeaderValues for more string types. Noticed that passing &format!("{}", "value") as the header value didn't work, but format!("{}", "value").as_str() does. This fixes that. Thanks!

Copy link
Member

@jbr jbr left a comment

Choose a reason for hiding this comment

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

Could these be defined in terms of the ToHeaderValues for &'a str impl to reduce duplicated code? Similarly, the String one probably could also be defined as

impl ToHeaderValues for String {
    type Iter = option::IntoIter<HeaderValue>;

    fn to_header_values(&self) -> crate::Result<Self::Iter> {
        self.as_str().to_header_values()
    }
}

That way if changes were needed to the &str impl, it wouldn't have to be repeated in four places

@yoshuawuyts yoshuawuyts merged commit 72d8827 into main Nov 13, 2020
@delete-merged-branch delete-merged-branch bot deleted the to-header-values-for-more-string-types branch November 13, 2020 14:19
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.

3 participants