Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary Boxed values #111

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove unnecessary Boxed values
Signed-off-by: Taiki Ono <taiki@finatext.com>
taiki45 committed Sep 10, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
taiki45 Taiki Ono
commit 1ad768ff61d290975dc0d9b9e5cf3974214ce7e4
6 changes: 3 additions & 3 deletions src/cli/apply.rs
Original file line number Diff line number Diff line change
@@ -58,9 +58,9 @@ pub fn apply(args: ApplyArgs) -> CliResult {

// Bind for later use.
let confirmed_count = result.confirmed.len();
let mut out: Box<dyn Write> = match &args.output {
Some(path) => Box::new(File::create(path)?),
None => Box::new(stdout()),
let mut out: &mut dyn Write = match &args.output {
Some(path) => &mut File::create(path)?,
None => &mut stdout(),
};
let msg_f = || {
let out_description = args
6 changes: 3 additions & 3 deletions src/cli/cleanup_allowlist.rs
Original file line number Diff line number Diff line change
@@ -35,9 +35,9 @@ pub fn cleanup_allowlist(args: CleanupAllowlistArgs) -> CliResult {
.for_each(|rule| {
rule.remove("allowlist");
});
let mut out: Box<dyn Write> = match args.output {
Some(path) => Box::new(File::create(path)?),
None => Box::new(stdout()),
let mut out: &mut dyn Write = match args.output {
Some(path) => &mut File::create(path)?,
None => &mut stdout(),
};
write!(&mut out, "{doc}")?;
SUCCESS
6 changes: 3 additions & 3 deletions src/cli/cleanup_rule.rs
Original file line number Diff line number Diff line change
@@ -73,9 +73,9 @@ pub fn cleanup_rule(args: CleanupRuleArgs) -> CliResult {
!contain
});

let mut out: Box<dyn Write> = match args.output {
Some(path) => Box::new(File::create(path)?),
None => Box::new(stdout()),
let mut out: &mut dyn Write = match args.output {
Some(path) => &mut File::create(path)?,
None => &mut stdout(),
};
write!(&mut out, "{doc}")?;
SUCCESS
6 changes: 3 additions & 3 deletions src/cli/diff.rs
Original file line number Diff line number Diff line change
@@ -62,9 +62,9 @@ pub fn diff(args: DiffArgs) -> CliResult {
.with_context(|| format!("Failed to parse JSON: {}", after_path.display()))?;

let diffs = compute_diff(befores, afters);
let mut out: Box<dyn Write> = match args.output.clone() {
Some(path) => Box::new(File::create(path)?),
None => Box::new(stdout()),
let mut out: &mut dyn Write = match args.output.clone() {
Some(path) => &mut File::create(path)?,
None => &mut stdout(),
};

match args.format {
8 changes: 4 additions & 4 deletions src/cli/extract_allowlist.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
fs::{self, read_to_string},
io,
io::{self, Write},
path::PathBuf,
};

@@ -51,9 +51,9 @@ pub fn extract_allowlist(args: ExtractAllowlistArgs) -> CliResult {
.collect::<Vec<_>>();
let config = ConfigRoot::new(allowlists);

let mut out: Box<dyn io::Write> = match args.output {
Some(path) => Box::new(fs::File::create(path)?),
None => Box::new(io::stdout()),
let mut out: &mut dyn Write = match args.output {
Some(path) => &mut fs::File::create(path)?,
None => &mut io::stdout(),
};
write!(&mut out, "{}", toml::to_string(&config)?)?;
SUCCESS
6 changes: 3 additions & 3 deletions src/cli/format.rs
Original file line number Diff line number Diff line change
@@ -22,9 +22,9 @@ pub struct FormatArgs {
pub fn format(args: FormatArgs) -> CliResult {
let contents = read_to_string(args.source)?;
let config: ConfigRoot = toml::from_str(&contents)?;
let mut out: Box<dyn Write> = match args.output {
Some(path) => Box::new(File::create(path)?),
None => Box::new(stdout()),
let mut out: &mut dyn Write = match args.output {
Some(path) => &mut File::create(path)?,
None => &mut stdout(),
};
write!(&mut out, "{}", toml::to_string(&config)?)?;
writeln!(out)?;
6 changes: 3 additions & 3 deletions src/cli/review.rs
Original file line number Diff line number Diff line change
@@ -91,9 +91,9 @@ pub fn review(args: ReviewArgs) -> CliResult {
.map(|report| filter.apply_report(report))
.collect::<Vec<FilterResult>>();

let mut out: Box<dyn Write> = match args.output.as_ref() {
Some(path) => Box::new(File::create(path)?),
None => Box::new(stdout()),
let mut out: &mut dyn Write = match args.output.as_ref() {
Some(path) => &mut File::create(path)?,
None => &mut stdout(),
};
match args.mode {
Mode::Summary => print_summary(&results, &filter, &mut out)?,