Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Ciber94 committed Sep 22, 2024
1 parent 3a9056e commit aab14f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
21 changes: 0 additions & 21 deletions src/http/headers/entry.rs

This file was deleted.

18 changes: 12 additions & 6 deletions src/http/headers/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ use core::str;

use private::Sealed;

use super::{entry::HeaderEntry, non_empty_list::NonEmptyList, value::HeaderValue, HeaderName};
use super::{non_empty_list::NonEmptyList, value::HeaderValue, HeaderName};

#[derive(Debug, Clone)]
struct HeaderEntry {
pub(crate) key: HeaderName,
pub(crate) value: NonEmptyList<HeaderValue>,
}

#[derive(Default, Debug, Clone)]
pub struct Headers {
Expand All @@ -28,7 +34,7 @@ impl Headers {
match key.find(&self) {
Some(idx) => {
let entry = self.entries.get(idx)?;
entry.iter().next()
entry.value.iter().next()
}
None => None,
}
Expand All @@ -38,7 +44,7 @@ impl Headers {
let iter = key
.find(&self)
.map(|idx| &self.entries[idx])
.map(|x| x.iter());
.map(|x| x.value.iter());

GetAll { iter }
}
Expand Down Expand Up @@ -95,7 +101,7 @@ impl Headers {
match key.find(&self) {
Some(idx) => {
let entry = self.entries.remove(idx);
Some(entry.take())
Some(entry.value.take_first())
}
None => None,
}
Expand Down Expand Up @@ -213,7 +219,7 @@ impl<'a> Iterator for Iter<'a> {

let entry = self.entries.get(self.index)?;
self.index += 1;
Some((&entry.key, entry.iter()))
Some((&entry.key, entry.value.iter()))
}
}

Expand All @@ -240,7 +246,7 @@ impl Iterator for IntoIter {

let entry = self.entries.remove(0);
let key = entry.key.clone();
Some((key, entry.into_iter()))
Some((key, entry.value.into_iter()))
}
}

Expand Down
1 change: 0 additions & 1 deletion src/http/headers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod entry;
mod headers;
mod name;
pub(crate) mod non_empty_list;
Expand Down

0 comments on commit aab14f8

Please sign in to comment.