From 46f74ede0177dda0f9e15856b97c581381fe90f7 Mon Sep 17 00:00:00 2001 From: Integral Date: Sun, 8 Dec 2024 21:01:12 +0800 Subject: [PATCH] refactor: replace format! with concat! for string literals (#83) --- src/bin/mangen.rs | 2 +- src/tui.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bin/mangen.rs b/src/bin/mangen.rs index 5adc935..f0c6589 100644 --- a/src/bin/mangen.rs +++ b/src/bin/mangen.rs @@ -19,7 +19,7 @@ const OUT_DIR_ENV: &str = "OUT_DIR"; /// See fn main() -> Result<()> { let out_dir = env::var(OUT_DIR_ENV).unwrap_or_else(|_| panic!("{OUT_DIR_ENV} is not set")); - let out_path = PathBuf::from(out_dir).join(format!("{}.1", env!("CARGO_PKG_NAME"))); + let out_path = PathBuf::from(out_dir).join(concat!(env!("CARGO_PKG_NAME"), ".1")); let app = Args::command(); let man = Man::new(app); let mut buffer = Vec::::new(); diff --git a/src/tui.rs b/src/tui.rs index cb3c034..796915a 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -155,10 +155,12 @@ fn highlight_search_result(value: String, app: &App) -> Line { fn render_header(app: &mut App, frame: &mut Frame<'_>, area: Rect) { let title = Paragraph::new( - format!( - " {} - {} ", + concat!( + " ", env!("CARGO_PKG_NAME"), - env!("CARGO_PKG_DESCRIPTION") + " - ", + env!("CARGO_PKG_DESCRIPTION"), + " ", ) .bold(), ) @@ -166,7 +168,7 @@ fn render_header(app: &mut App, frame: &mut Frame<'_>, area: Rect) { .alignment(Alignment::Left); frame.render_widget(title, area); - let text = format!("v{} with ♥ by @orhun ", env!("CARGO_PKG_VERSION")); + let text = concat!("v", env!("CARGO_PKG_VERSION"), " with ♥ by @orhun "); let meta = Paragraph::new(text) .block(Block::default().style(app.theme.header)) .alignment(Alignment::Right);