1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#[derive(Debug, Default, Clone)]
pub struct Headers(Vec<(&'static str, String)>);
impl Headers {
pub fn none() -> Option<Headers> {
None
}
pub fn add<V>(&mut self, key: &'static str, val: V)
where
V: Into<String>,
{
self.0.push((key, val.into()))
}
pub fn single<V>(key: &'static str, val: V) -> Self
where
V: Into<String>,
{
let mut h = Self::default();
h.add(key, val);
h
}
}
impl IntoIterator for Headers {
type Item = (&'static str, String);
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}