Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//! ```

use std::fmt;
use std::fmt::{Display, Formatter};

/// Represents a version of the HTTP spec.
#[derive(PartialEq, PartialOrd, Copy, Clone, Eq, Ord, Hash)]
Expand All @@ -42,6 +43,12 @@ impl Version {
pub const HTTP_3: Version = Version(Http::H3);
}

impl Display for Version {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}

#[derive(PartialEq, PartialOrd, Copy, Clone, Eq, Ord, Hash)]
enum Http {
Http09,
Expand Down Expand Up @@ -73,3 +80,13 @@ impl fmt::Debug for Version {
})
}
}

#[cfg(test)]
mod tests {
use crate::Version;

#[test]
fn test_display_for_version() {
assert_eq!("HTTP/1.1", format!("{}", Version::HTTP_11));
}
}