1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27: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 {
fn display(&self) -> String {
let mut output = String::new();
for name in [
[
self.kernel_name.as_ref(),
self.nodename.as_ref(),
self.kernel_release.as_ref(),
@ -51,11 +50,9 @@ impl UNameOutput {
]
.into_iter()
.flatten()
{
output.push_str(name);
output.push(' ');
}
output
.map(|name| name.as_str())
.collect::<Vec<_>>()
.join(" ")
}
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),
};
let output = UNameOutput::new(&options)?;
println!("{}", output.display().trim_end());
println!("{}", output.display());
Ok(())
}