Skip to content

Commit

Permalink
refactor(shell): Switch away from 'ref mut' patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 7, 2024
1 parent b033ed2 commit eed7f64
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/cargo/core/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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;
Expand All @@ -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(())
Expand Down Expand Up @@ -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,
}
}
}
Expand Down

0 comments on commit eed7f64

Please sign in to comment.