Skip to content

Commit

Permalink
Remove use of reduce crate
Browse files Browse the repository at this point in the history
  • Loading branch information
kpcyrd committed Sep 6, 2024
1 parent c21a9c1 commit 32bc786
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dns-parser = "0.8"
tls-parser = "0.12"
dhcp4r = "0.2.0"
ansi_term = "0.12"
reduce = "0.1.1"
env_logger = "0.11"
log = "0.4"
toml = "0.8"
Expand Down
21 changes: 12 additions & 9 deletions src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::sync::Arc;

use ansi_term::Color;
use bstr::ByteSlice;
use reduce::Reduce;
use sha2::{Sha512, Digest};
use std::cmp;
use std::fmt::Debug;
Expand Down Expand Up @@ -364,8 +363,9 @@ impl Format {
Request(req) => {
out.push_str("[dns] req, ");

match Reduce::reduce(req.questions.iter()
.map(|x| format!("{:?}", x)), |a, b| a + &align(out.len(), &b))
match req.questions.iter()
.map(|x| format!("{:?}", x))
.reduce(|a, b| a + &align(out.len(), &b))
{
Some(dns) => out.push_str(&dns),
None => out.push_str("[]"),
Expand All @@ -374,8 +374,9 @@ impl Format {
Response(resp) => {
out.push_str("[dns] resp, ");

match Reduce::reduce(resp.answers.iter()
.map(|x| format!("{:?}", x)), |a, b| a + &align(out.len(), &b))
match resp.answers.iter()
.map(|x| format!("{:?}", x))
.reduce(|a, b| a + &align(out.len(), &b))
{
Some(dns) => out.push_str(&dns),
None => out.push_str("[]"),
Expand Down Expand Up @@ -619,12 +620,13 @@ fn display_macadr_buf(mac: [u8; 6]) -> String {

#[inline]
fn display_kv_list(list: &[(&str, Option<&str>)]) -> String {
Reduce::reduce(list.iter()
list.iter()
.filter_map(|&(key, ref value)| {
value.as_ref().map(|value| {
format!("{}: {:?}", key, value)
})
}), |a, b| a + ", " + &b)
})
.reduce(|a, b| a + ", " + &b)
.map_or_else(String::new, |extra| format!(" ({})", extra))
}

Expand All @@ -650,10 +652,11 @@ impl<'a> DhcpKvListWriter<'a> {
}

fn finalize(self) -> String {
Reduce::reduce(self.elements.iter()
self.elements.iter()
.map(|&(key, ref value)| {
format!("{}: {}", key, value)
}), |a, b| a + ", " + &b)
})
.reduce(|a, b| a + ", " + &b)
.map_or_else(String::new, |extra| format!(" ({})", extra))
}
}

0 comments on commit 32bc786

Please sign in to comment.