Skip to content

Commit eae90a8

Browse files
committed
refactor: renamed function prefix "pos" to "position"
1 parent 0b644af commit eae90a8

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

header-plz/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ pub mod error;
77
pub mod message_head;
88
pub mod methods;
99

10-
pub use message_head::header_map::HeaderMap;
1110
pub use message_head::header_map::header::Header;
12-
pub use message_head::info_line::{InfoLine, request::Request, response::Response};
11+
pub use message_head::header_map::HeaderMap;
12+
pub use message_head::info_line::{request::Request, response::Response, InfoLine};

header-plz/src/message_head/header_map/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl HeaderMap {
4747
}
4848

4949
// Finders
50-
pub fn find_pos_all<F>(&self, mut f: F) -> Option<Vec<usize>>
50+
pub fn find_position_all<F>(&self, mut f: F) -> Option<Vec<usize>>
5151
where
5252
F: FnMut(&Header) -> bool,
5353
{
@@ -60,7 +60,7 @@ impl HeaderMap {
6060
Some(pos).filter(|v| !v.is_empty())
6161
}
6262

63-
pub fn find_pos<F>(&self, f: F) -> Option<usize>
63+
pub fn find_position<F>(&self, f: F) -> Option<usize>
6464
where
6565
F: FnMut(&Header) -> bool,
6666
{
@@ -71,14 +71,14 @@ impl HeaderMap {
7171
// ----- find
7272
pub fn header_position_all(&self, to_find_hdr: &str) -> Option<Vec<usize>> {
7373
let (key, val) = Header::split_header(to_find_hdr);
74-
self.find_pos_all(|h| {
74+
self.find_position_all(|h| {
7575
h.key_as_str().eq_ignore_ascii_case(key) && h.value_as_str().eq_ignore_ascii_case(val)
7676
})
7777
}
7878

7979
pub fn header_position(&self, to_find_hdr: &str) -> Option<usize> {
8080
let (key, val) = Header::split_header(to_find_hdr);
81-
self.find_pos(|h| {
81+
self.find_position(|h| {
8282
h.key_as_str().eq_ignore_ascii_case(key) && h.value_as_str().eq_ignore_ascii_case(val)
8383
})
8484
}
@@ -111,7 +111,7 @@ impl HeaderMap {
111111
}
112112

113113
// ----- remove
114-
pub fn remove_header_all_pos(&mut self, positions: Vec<usize>) {
114+
pub fn remove_header_all_positions(&mut self, positions: Vec<usize>) {
115115
for index in positions.into_iter().rev() {
116116
self.headers.remove(index);
117117
}
@@ -122,7 +122,7 @@ impl HeaderMap {
122122
let mut result = false;
123123
if let Some(positions) = self.header_position_all(to_remove) {
124124
result = true;
125-
self.remove_header_all_pos(positions);
125+
self.remove_header_all_positions(positions);
126126
}
127127
result
128128
}
@@ -143,16 +143,16 @@ impl HeaderMap {
143143
// ---------- Key
144144
// ----- find
145145
pub fn header_key_position_all(&self, key: &str) -> Option<Vec<usize>> {
146-
self.find_pos_all(|h| h.key_as_str().eq_ignore_ascii_case(key))
146+
self.find_position_all(|h| h.key_as_str().eq_ignore_ascii_case(key))
147147
}
148148

149149
pub fn header_key_position(&self, key: &str) -> Option<usize> {
150-
self.find_pos(|h| h.key_as_str().eq_ignore_ascii_case(key))
150+
self.find_position(|h| h.key_as_str().eq_ignore_ascii_case(key))
151151
}
152152

153153
// ----- key -> value
154154
pub fn value_of_key(&self, key: &str) -> Option<&str> {
155-
self.find_pos(|h| h.key_as_str().eq_ignore_ascii_case(key))
155+
self.find_position(|h| h.key_as_str().eq_ignore_ascii_case(key))
156156
.map(|pos| self.headers[pos].value_as_str())
157157
}
158158

@@ -232,7 +232,7 @@ impl HeaderMap {
232232
let mut result = false;
233233
if let Some(positions) = self.header_key_position_all(key) {
234234
result = true;
235-
self.remove_header_all_pos(positions);
235+
self.remove_header_all_positions(positions);
236236
}
237237
result
238238
}
@@ -248,7 +248,7 @@ impl HeaderMap {
248248

249249
// ---------- value
250250
// ------ update
251-
pub fn update_header_value_on_pos(&mut self, pos: usize, value: &str) {
251+
pub fn update_header_value_on_position(&mut self, pos: usize, value: &str) {
252252
self.headers[pos].change_value(value);
253253
}
254254

@@ -573,7 +573,7 @@ mod tests {
573573
let mut map = build_header_map();
574574
let pos = 1;
575575
let val = "30";
576-
map.update_header_value_on_pos(pos, val);
576+
map.update_header_value_on_position(pos, val);
577577
let result = map.into_bytes();
578578
let verify = "Host: localhost\r\n\
579579
Content-Length: 30\r\n\

0 commit comments

Comments
 (0)