Skip to content

Commit

Permalink
refactor: Replace format! with other macros/methods when unnecessary (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral-Tech authored Dec 2, 2024
1 parent 90b30cb commit 4206db3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn build_shell_completions(out_dir: &Path) -> Result<(), IoError> {
fn build_manpage(out_dir: &Path) -> Result<(), IoError> {
fs::create_dir_all(out_dir)?;
let app = args::get_args();
let file = out_dir.join(format!("{}.8", env!("CARGO_PKG_NAME")));
let file = out_dir.join(concat!(env!("CARGO_PKG_NAME"), ".8"));
let mut file = File::create(file)?;
Man::new(app).render(&mut file)?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl App {
for module in &mut kernel_module_list {
if module[2].len() > dependent_width {
module[2].truncate(dependent_width);
module[2] = format!("{}...", module[2]);
module[2].push_str("...");
}
}
kernel_modules.list = kernel_module_list;
Expand Down
7 changes: 5 additions & 2 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ pub fn get_args() -> App {
App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.author(env!("CARGO_PKG_AUTHORS"))
.about(format!(
"{} {}\n{}\n{}\n\n{}",
.about(concat!(
env!("CARGO_PKG_NAME"),
" ",
env!("CARGO_PKG_VERSION"),
"\n",
env!("CARGO_PKG_AUTHORS"),
"\n",
env!("CARGO_PKG_DESCRIPTION"),
"\n\n",
"Press '?' while running the terminal UI to see key bindings."
))
.before_help(ASCII_LOGO)
Expand Down
3 changes: 2 additions & 1 deletion src/kernel/lkm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ impl KernelModules<'_> {
let columns: Vec<&str> = line.split_whitespace().collect();
let mut module_name = format!(" {}", columns[0]);
if columns.len() >= 7 {
module_name = format!("{} {}", module_name, columns[6]);
module_name.push(' ');
module_name.push_str(columns[6]);
}
let mut used_modules = format!("{} {}", columns[2], columns[3]);
if used_modules.ends_with(',') {
Expand Down

0 comments on commit 4206db3

Please sign in to comment.