1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

uname: remove unnecessary mut & trim_end() call

This commit is contained in:
Daniel Hofstetter 2025-06-07 17:42:28 +02:00 committed by Sylvestre Ledru
parent 0835fc61eb
commit 05bcb65b26

View file

@ -38,8 +38,7 @@ pub struct UNameOutput {
impl UNameOutput { impl UNameOutput {
fn display(&self) -> String { fn display(&self) -> String {
let mut output = String::new(); [
for name in [
self.kernel_name.as_ref(), self.kernel_name.as_ref(),
self.nodename.as_ref(), self.nodename.as_ref(),
self.kernel_release.as_ref(), self.kernel_release.as_ref(),
@ -51,11 +50,9 @@ impl UNameOutput {
] ]
.into_iter() .into_iter()
.flatten() .flatten()
{ .map(|name| name.as_str())
output.push_str(name); .collect::<Vec<_>>()
output.push(' '); .join(" ")
}
output
} }
pub fn new(opts: &Options) -> UResult<Self> { pub fn new(opts: &Options) -> UResult<Self> {
@ -138,7 +135,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
os: matches.get_flag(options::OS), os: matches.get_flag(options::OS),
}; };
let output = UNameOutput::new(&options)?; let output = UNameOutput::new(&options)?;
println!("{}", output.display().trim_end()); println!("{}", output.display());
Ok(()) Ok(())
} }