mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
style: simplify string formatting for readability (#231763)
* style: simplify string formatting for readability * fix: formatting in `.rs` files in `src/`
This commit is contained in:
@@ -146,7 +146,7 @@ pub async fn kill_tree(process_id: u32) -> Result<(), CodeError> {
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|e| CodeError::CommandFailed {
|
||||
command: format!("pgrep -P {}", parent_id),
|
||||
command: format!("pgrep -P {parent_id}"),
|
||||
code: -1,
|
||||
output: e.to_string(),
|
||||
})?;
|
||||
|
||||
@@ -41,7 +41,7 @@ impl From<reqwest::Error> for WrappedError {
|
||||
"error requesting {}",
|
||||
e.url().map_or("<unknown>", |u| u.as_str())
|
||||
),
|
||||
original: format!("{}", e),
|
||||
original: format!("{e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ where
|
||||
{
|
||||
WrappedError {
|
||||
message: message.into(),
|
||||
original: format!("{:?}", original),
|
||||
original: format!("{original:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ where
|
||||
{
|
||||
WrappedError {
|
||||
message: message.into(),
|
||||
original: format!("{}", original),
|
||||
original: format!("{original}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,10 +93,7 @@ impl StatusError {
|
||||
let body = res.text().await.map_err(|e| {
|
||||
wrap(
|
||||
e,
|
||||
format!(
|
||||
"failed to read response body on {} code from {}",
|
||||
status_code, url
|
||||
),
|
||||
format!("failed to read response body on {status_code} code from {url}"),
|
||||
)
|
||||
})?;
|
||||
|
||||
@@ -290,7 +287,7 @@ pub struct CannotForwardControlPort();
|
||||
|
||||
impl std::fmt::Display for CannotForwardControlPort {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "Cannot forward or unforward port {}.", CONTROL_PORT)
|
||||
write!(f, "Cannot forward or unforward port {CONTROL_PORT}.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +305,7 @@ pub struct ServiceAlreadyRegistered();
|
||||
|
||||
impl std::fmt::Display for ServiceAlreadyRegistered {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "Already registered the service. Run `{} tunnel service uninstall` to unregister it first", APPLICATION_NAME)
|
||||
write!(f, "Already registered the service. Run `{APPLICATION_NAME} tunnel service uninstall` to unregister it first")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +431,7 @@ impl Display for DbusConnectFailedError {
|
||||
str.push_str(&self.0);
|
||||
str.push('\n');
|
||||
|
||||
write!(f, "{}", str)
|
||||
write!(f, "{str}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ mod tests {
|
||||
let base_line = "Elit ipsum cillum ex cillum. Adipisicing consequat cupidatat do proident ut in sunt Lorem ipsum tempor. Eiusmod ipsum Lorem labore exercitation sunt pariatur excepteur fugiat cillum velit cillum enim. Nisi Lorem cupidatat ad enim velit officia eiusmod esse tempor aliquip. Deserunt pariatur tempor in duis culpa esse sit nulla irure ullamco ipsum voluptate non laboris. Occaecat officia nulla officia mollit do aliquip reprehenderit ad incididunt.";
|
||||
for i in 0..100 {
|
||||
let line = format!("{}: {}", i, &base_line[..rng.gen_range(0..base_line.len())]);
|
||||
writeln!(&mut read_file, "{}", line).unwrap();
|
||||
writeln!(&mut read_file, "{line}").unwrap();
|
||||
written.push(line);
|
||||
}
|
||||
write!(&mut read_file, "partial line").unwrap();
|
||||
|
||||
@@ -121,7 +121,7 @@ impl PreReqChecker {
|
||||
|
||||
let bullets = errors
|
||||
.iter()
|
||||
.map(|e| format!(" - {}", e))
|
||||
.map(|e| format!(" - {e}"))
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
|
||||
@@ -142,8 +142,7 @@ async fn check_musl_interpreter() -> Result<(), String> {
|
||||
|
||||
if fs::metadata(MUSL_PATH).await.is_err() {
|
||||
return Err(format!(
|
||||
"find {}, which is required to run the {} in musl environments",
|
||||
MUSL_PATH, QUALITYLESS_SERVER_NAME
|
||||
"find {MUSL_PATH}, which is required to run the {QUALITYLESS_SERVER_NAME} in musl environments"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -231,8 +230,7 @@ async fn check_glibcxx_version() -> Result<bool, String> {
|
||||
Some(path) => match fs::read(&path).await {
|
||||
Ok(contents) => check_for_sufficient_glibcxx_versions(contents),
|
||||
Err(e) => Err(format!(
|
||||
"validate GLIBCXX version for GNU environments, but could not: {}",
|
||||
e
|
||||
"validate GLIBCXX version for GNU environments, but could not: {e}"
|
||||
)),
|
||||
},
|
||||
None => Err("find libstdc++.so or ldconfig for GNU environments".to_owned()),
|
||||
|
||||
@@ -60,7 +60,7 @@ where
|
||||
}
|
||||
let mut file = archive
|
||||
.by_index(i)
|
||||
.map_err(|e| wrap(e, format!("could not open zip entry {}", i)))?;
|
||||
.map_err(|e| wrap(e, format!("could not open zip entry {i}")))?;
|
||||
|
||||
let outpath: PathBuf = match file.enclosed_name() {
|
||||
Some(path) => {
|
||||
|
||||
Reference in New Issue
Block a user