Skip to content

Commit 05bcb65

Browse files
cakebakersylvestre
authored andcommitted
uname: remove unnecessary mut & trim_end() call
1 parent 0835fc6 commit 05bcb65

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/uu/uname/src/uname.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ pub struct UNameOutput {
3838

3939
impl UNameOutput {
4040
fn display(&self) -> String {
41-
let mut output = String::new();
42-
for name in [
41+
[
4342
self.kernel_name.as_ref(),
4443
self.nodename.as_ref(),
4544
self.kernel_release.as_ref(),
@@ -51,11 +50,9 @@ impl UNameOutput {
5150
]
5251
.into_iter()
5352
.flatten()
54-
{
55-
output.push_str(name);
56-
output.push(' ');
57-
}
58-
output
53+
.map(|name| name.as_str())
54+
.collect::<Vec<_>>()
55+
.join(" ")
5956
}
6057

6158
pub fn new(opts: &Options) -> UResult<Self> {
@@ -138,7 +135,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
138135
os: matches.get_flag(options::OS),
139136
};
140137
let output = UNameOutput::new(&options)?;
141-
println!("{}", output.display().trim_end());
138+
println!("{}", output.display());
142139
Ok(())
143140
}
144141

0 commit comments

Comments
 (0)