Skip to content
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
22 changes: 10 additions & 12 deletions lib/benches/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ fn build_small_spec() -> Spec {
.build();
cmd.subcommands.insert("install".to_string(), install_cmd);

Spec {
name: "test".to_string(),
bin: "test".to_string(),
cmd,
..Default::default()
}
let mut spec = Spec::default();
spec.name = "test".to_string();
spec.bin = "test".to_string();
spec.cmd = cmd;
spec
Comment on lines +19 to +23

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This pattern for creating a Spec instance is also used in the build_large_spec function (lines 87-91). To improve maintainability and reduce code duplication, you could extract this logic into a helper function. For example:

fn build_spec_with_cmd(name: &str, bin: &str, cmd: SpecCommand) -> Spec {
    let mut spec = Spec::default();
    spec.name = name.to_string();
    spec.bin = bin.to_string();
    spec.cmd = cmd;
    spec
}

This helper could then be called from both build_small_spec and build_large_spec.

}

fn build_large_spec() -> Spec {
Expand Down Expand Up @@ -85,12 +84,11 @@ fn build_large_spec() -> Spec {
.build();
cmd.subcommands = subcommands;

Spec {
name: "bench".to_string(),
bin: "bench".to_string(),
cmd,
..Default::default()
}
let mut spec = Spec::default();
spec.name = "bench".to_string();
spec.bin = "bench".to_string();
spec.cmd = cmd;
spec
}

fn bench_parse_small_spec(c: &mut Criterion) {
Expand Down
Loading