From eed7f643446fc4713d6b428e1e46866a67d08288 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 7 Mar 2024 13:49:28 -0600 Subject: [PATCH] refactor(shell): Switch away from 'ref mut' patterns --- src/cargo/core/shell.rs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 1bfdb586964b..4a180cba4f9b 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -232,11 +232,11 @@ impl Shell { /// Updates the color choice (always, never, or auto) from a string.. pub fn set_color_choice(&mut self, color: Option<&str>) -> CargoResult<()> { if let ShellOut::Stream { - ref mut stdout, - ref mut stderr, - ref mut color_choice, + stdout, + stderr, + color_choice, .. - } = self.output + } = &mut self.output { let cfg = color .map(|c| c.parse()) @@ -253,10 +253,10 @@ impl Shell { pub fn set_unicode(&mut self, yes: bool) -> CargoResult<()> { if let ShellOut::Stream { - ref mut stdout_unicode, - ref mut stderr_unicode, + stdout_unicode, + stderr_unicode, .. - } = self.output + } = &mut self.output { *stdout_unicode = yes; *stderr_unicode = yes; @@ -265,10 +265,7 @@ impl Shell { } pub fn set_hyperlinks(&mut self, yes: bool) -> CargoResult<()> { - if let ShellOut::Stream { - ref mut hyperlinks, .. - } = self.output - { + if let ShellOut::Stream { hyperlinks, .. } = &mut self.output { *hyperlinks = yes; } Ok(()) @@ -447,17 +444,17 @@ impl ShellOut { /// Gets stdout as a `io::Write`. fn stdout(&mut self) -> &mut dyn Write { - match *self { - ShellOut::Stream { ref mut stdout, .. } => stdout, - ShellOut::Write(ref mut w) => w, + match self { + ShellOut::Stream { stdout, .. } => stdout, + ShellOut::Write(w) => w, } } /// Gets stderr as a `io::Write`. fn stderr(&mut self) -> &mut dyn Write { - match *self { - ShellOut::Stream { ref mut stderr, .. } => stderr, - ShellOut::Write(ref mut w) => w, + match self { + ShellOut::Stream { stderr, .. } => stderr, + ShellOut::Write(w) => w, } } }