Skip to content

Commit 7a7bfc7

Browse files
committed
dist: simpify casting to trait object
1 parent afb6c64 commit 7a7bfc7

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/dist/manifestation.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,22 +274,12 @@ impl Manifestation {
274274
process: download_cfg.process,
275275
};
276276

277-
let (gz, xz, zst);
278277
let reader =
279278
utils::FileReaderWithProgress::new_file(&installer_file, &notification_converter)?;
280-
let package: &dyn Package = match format {
281-
CompressionKind::GZip => {
282-
gz = TarGzPackage::new(reader, &cx)?;
283-
&gz
284-
}
285-
CompressionKind::XZ => {
286-
xz = TarXzPackage::new(reader, &cx)?;
287-
&xz
288-
}
289-
CompressionKind::ZStd => {
290-
zst = TarZStdPackage::new(reader, &cx)?;
291-
&zst
292-
}
279+
let package = match format {
280+
CompressionKind::GZip => &TarGzPackage::new(reader, &cx)? as &dyn Package,
281+
CompressionKind::XZ => &TarXzPackage::new(reader, &cx)?,
282+
CompressionKind::ZStd => &TarZStdPackage::new(reader, &cx)?,
293283
};
294284

295285
// If the package doesn't contain the component that the

0 commit comments

Comments
 (0)