Skip to content

Commit 60c1066

Browse files
pietroalbiniJoshua Nelson
authored andcommitted
bin: remove duplication setting up rustwide
1 parent 967d5af commit 60c1066

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/bin/cratesfyi.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,17 @@ enum BuildSubcommand {
303303

304304
impl BuildSubcommand {
305305
pub fn handle_args(self, ctx: BinContext, mut docbuilder: DocBuilder) -> Result<(), Error> {
306+
let rustwide_builder = || -> Result<RustwideBuilder, Error> {
307+
Ok(RustwideBuilder::init(
308+
ctx.pool()?,
309+
ctx.metrics()?,
310+
ctx.storage()?,
311+
)?)
312+
};
313+
306314
match self {
307315
Self::World => {
308-
let mut builder =
309-
RustwideBuilder::init(ctx.pool()?, ctx.metrics()?, ctx.storage()?)?;
310-
builder
316+
rustwide_builder()?
311317
.build_world(&mut docbuilder)
312318
.context("Failed to build world")?;
313319
}
@@ -317,9 +323,7 @@ impl BuildSubcommand {
317323
crate_version,
318324
local,
319325
} => {
320-
let mut builder =
321-
RustwideBuilder::init(ctx.pool()?, ctx.metrics()?, ctx.storage()?)
322-
.context("failed to initialize rustwide")?;
326+
let mut builder = rustwide_builder()?;
323327

324328
if let Some(path) = local {
325329
builder
@@ -353,17 +357,13 @@ impl BuildSubcommand {
353357
}
354358
}
355359

356-
let mut builder =
357-
RustwideBuilder::init(ctx.pool()?, ctx.metrics()?, ctx.storage()?)?;
358-
builder
360+
rustwide_builder()?
359361
.update_toolchain()
360362
.context("failed to update toolchain")?;
361363
}
362364

363365
Self::AddEssentialFiles => {
364-
let mut builder =
365-
RustwideBuilder::init(ctx.pool()?, ctx.metrics()?, ctx.storage()?)?;
366-
builder
366+
rustwide_builder()?
367367
.add_essential_files()
368368
.context("failed to add essential files")?;
369369
}

0 commit comments

Comments
 (0)