Skip to content

Commit 0a72c68

Browse files
committed
refactor: simplify is_proxyable_tools
1 parent 10d093f commit 0a72c68

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/lib.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub use crate::errors::*;
1616
pub(crate) use crate::notifications::*;
1717
pub(crate) use crate::utils::toml_utils;
1818
use anyhow::{anyhow, Result};
19+
use itertools::{chain, Itertools};
1920

2021
#[macro_use]
2122
extern crate rs_tracing;
@@ -41,23 +42,15 @@ pub static DUP_TOOLS: &[&str] = &["rust-analyzer", "rustfmt", "cargo-fmt"];
4142

4243
// If the given name is one of the tools we proxy.
4344
pub fn is_proxyable_tools(tool: &str) -> Result<()> {
44-
if TOOLS
45-
.iter()
46-
.chain(DUP_TOOLS.iter())
47-
.any(|&name| name == tool)
48-
{
45+
if chain!(TOOLS, DUP_TOOLS).contains(&tool) {
4946
Ok(())
5047
} else {
51-
Err(anyhow!(format!(
52-
"unknown proxy name: '{}'; valid proxy names are {}",
53-
tool,
54-
TOOLS
55-
.iter()
56-
.chain(DUP_TOOLS.iter())
48+
Err(anyhow!(
49+
"unknown proxy name: '{tool}'; valid proxy names are {}",
50+
chain!(TOOLS, DUP_TOOLS)
5751
.map(|s| format!("'{s}'"))
58-
.collect::<Vec<_>>()
59-
.join(", ")
60-
)))
52+
.join(", "),
53+
))
6154
}
6255
}
6356

0 commit comments

Comments
 (0)