Skip to content

refactor header helpers #837

Closed
Closed
@cataggar

Description

@cataggar
 pub fn get_as_str<T: Into<HeaderName>>(&self, key: T) -> Option<&str> {
        self.get(key).map(|v| v.as_str())
    }

I think we should just get rid of the variants of this methods and only have the variants which return a crate::Result. If you need an option, you can just call .ok() on the Result.
And of course, then we just use the simpler naming convention and not the or_err names.
#833 (review)

    pub fn get_as_enum<T: Into<HeaderName>, V: FromStr<Err = E>, E>(

This is a bit more general than for enums. Can we call this get_as_parsed or something like that? I think get_as_u64_or_err can be implemented using this function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions