Skip to content

Commit 493ceb9

Browse files
committed
Use more elegant get_or_insert_default
Signed-off-by: Colin Walters <[email protected]>
1 parent 691bb45 commit 493ceb9

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

examples/ocidir-import-tar.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ fn import(oci_dir: &OciDir, name: &str, src: File) -> anyhow::Result<()> {
4242
.created_by(name.to_string())
4343
.build()
4444
.unwrap();
45-
match config.history_mut() {
46-
Some(v) => v.push(h),
47-
None => {
48-
config.set_history(Some(vec![h]));
49-
}
50-
}
45+
config.history_mut().get_or_insert_default().push(h);
5146

5247
println!(
5348
"Created image with manifest: {}",

src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,7 @@ impl OciDir {
429429
} else {
430430
oci_image::HistoryBuilder::default().build().unwrap()
431431
};
432-
match config.history_mut() {
433-
Some(h) => h.push(history),
434-
None => {
435-
config.set_history(Some(vec![history]));
436-
}
437-
}
432+
config.history_mut().get_or_insert_default().push(history);
438433
}
439434

440435
/// Add a layer to the top of the image stack with desired history entry.

0 commit comments

Comments
 (0)