We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Header for (&str, &str)
1 parent 463f3c2 commit 338508dCopy full SHA for 338508d
1 file changed
src/headers/header.rs
@@ -16,3 +16,26 @@ pub trait Header {
16
headers.as_mut().insert(name, value);
17
}
18
19
+
20
+impl<'a, 'b> Header for (&'a str, &'b str) {
21
+ fn header_name(&self) -> HeaderName {
22
+ HeaderName::from(self.0)
23
+ }
24
25
+ fn header_value(&self) -> HeaderValue {
26
+ HeaderValue::from_bytes(self.1.to_owned().into_bytes())
27
+ .expect("String slice should be valid ASCII")
28
29
+}
30
31
+#[cfg(test)]
32
+mod test {
33
+ use super::*;
34
35
+ #[test]
36
+ fn header_from_strings() {
37
+ let strings = ("Content-Length", "12");
38
+ assert_eq!(strings.header_name(), "Content-Length");
39
+ assert_eq!(strings.header_value(), "12");
40
41
0 commit comments