mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-31 20:21:59 -07:00
style: simplify string formatting
Most of this code was written before this was supported by Rust. Closes #2912
This commit is contained in:
committed by
Andrew Gallant
parent
e169881a36
commit
f1b4b182f2
4
build.rs
4
build.rs
@@ -22,7 +22,7 @@ fn set_windows_exe_options() {
|
|||||||
manifest.push(MANIFEST);
|
manifest.push(MANIFEST);
|
||||||
let Some(manifest) = manifest.to_str() else { return };
|
let Some(manifest) = manifest.to_str() else { return };
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed={}", MANIFEST);
|
println!("cargo:rerun-if-changed={MANIFEST}");
|
||||||
// Embed the Windows application manifest file.
|
// Embed the Windows application manifest file.
|
||||||
println!("cargo:rustc-link-arg-bin=rg=/MANIFEST:EMBED");
|
println!("cargo:rustc-link-arg-bin=rg=/MANIFEST:EMBED");
|
||||||
println!("cargo:rustc-link-arg-bin=rg=/MANIFESTINPUT:{manifest}");
|
println!("cargo:rustc-link-arg-bin=rg=/MANIFESTINPUT:{manifest}");
|
||||||
@@ -42,5 +42,5 @@ fn set_git_revision_hash() {
|
|||||||
if rev.is_empty() {
|
if rev.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
println!("cargo:rustc-env=RIPGREP_BUILD_GIT_HASH={}", rev);
|
println!("cargo:rustc-env=RIPGREP_BUILD_GIT_HASH={rev}");
|
||||||
}
|
}
|
||||||
|
@@ -72,7 +72,7 @@ pub(crate) fn generate() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(negated) = flag.name_negated() {
|
if let Some(negated) = flag.name_negated() {
|
||||||
let dash_name = format!("--{}", negated);
|
let dash_name = format!("--{negated}");
|
||||||
flags.push_str("\n ");
|
flags.push_str("\n ");
|
||||||
flags.push_str(
|
flags.push_str(
|
||||||
&TEMPLATE_FLAG
|
&TEMPLATE_FLAG
|
||||||
|
@@ -307,15 +307,14 @@ impl<W: WriteColor> SearchWorker<W> {
|
|||||||
io::Error::new(
|
io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
format!(
|
format!(
|
||||||
"preprocessor command could not start: '{:?}': {}",
|
"preprocessor command could not start: '{cmd:?}': {err}",
|
||||||
cmd, err,
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
let result = self.search_reader(path, &mut rdr).map_err(|err| {
|
let result = self.search_reader(path, &mut rdr).map_err(|err| {
|
||||||
io::Error::new(
|
io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
format!("preprocessor command failed: '{:?}': {}", cmd, err),
|
format!("preprocessor command failed: '{cmd:?}': {err}"),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let close_result = rdr.close();
|
let close_result = rdr.close();
|
||||||
|
@@ -21,35 +21,35 @@ impl Message {
|
|||||||
fn unwrap_begin(&self) -> Begin {
|
fn unwrap_begin(&self) -> Begin {
|
||||||
match *self {
|
match *self {
|
||||||
Message::Begin(ref x) => x.clone(),
|
Message::Begin(ref x) => x.clone(),
|
||||||
ref x => panic!("expected Message::Begin but got {:?}", x),
|
ref x => panic!("expected Message::Begin but got {x:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unwrap_end(&self) -> End {
|
fn unwrap_end(&self) -> End {
|
||||||
match *self {
|
match *self {
|
||||||
Message::End(ref x) => x.clone(),
|
Message::End(ref x) => x.clone(),
|
||||||
ref x => panic!("expected Message::End but got {:?}", x),
|
ref x => panic!("expected Message::End but got {x:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unwrap_match(&self) -> Match {
|
fn unwrap_match(&self) -> Match {
|
||||||
match *self {
|
match *self {
|
||||||
Message::Match(ref x) => x.clone(),
|
Message::Match(ref x) => x.clone(),
|
||||||
ref x => panic!("expected Message::Match but got {:?}", x),
|
ref x => panic!("expected Message::Match but got {x:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unwrap_context(&self) -> Context {
|
fn unwrap_context(&self) -> Context {
|
||||||
match *self {
|
match *self {
|
||||||
Message::Context(ref x) => x.clone(),
|
Message::Context(ref x) => x.clone(),
|
||||||
ref x => panic!("expected Message::Context but got {:?}", x),
|
ref x => panic!("expected Message::Context but got {x:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unwrap_summary(&self) -> Summary {
|
fn unwrap_summary(&self) -> Summary {
|
||||||
match *self {
|
match *self {
|
||||||
Message::Summary(ref x) => x.clone(),
|
Message::Summary(ref x) => x.clone(),
|
||||||
ref x => panic!("expected Message::Summary but got {:?}", x),
|
ref x => panic!("expected Message::Summary but got {x:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,7 @@ impl Dir {
|
|||||||
.expect("executable's directory")
|
.expect("executable's directory")
|
||||||
.to_path_buf();
|
.to_path_buf();
|
||||||
let dir =
|
let dir =
|
||||||
env::temp_dir().join(TEST_DIR).join(name).join(&format!("{}", id));
|
env::temp_dir().join(TEST_DIR).join(name).join(&format!("{id}"));
|
||||||
if dir.exists() {
|
if dir.exists() {
|
||||||
nice_err(&dir, fs::remove_dir_all(&dir));
|
nice_err(&dir, fs::remove_dir_all(&dir));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user