Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert a HeaderValue into a rust String
/// Additional conversion methods for `HeaderValue`.
pub trait HeaderValueExt {
fn to_string(&self) -> String;
impl HeaderValueExt for HeaderValue {
fn to_string(&self) -> String {
// Usage:
let ok: Option<String> = request.headers().get("ok").map(|x| x.to_string());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment