Skip to content

Commit 075f22d

Browse files
committed
Take FileDataSource by reference in create_fat_filesystem
1 parent c4714ce commit 075f22d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/fat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{collections::BTreeMap, fs, path::Path};
77
use crate::KERNEL_FILE_NAME;
88

99
pub fn create_fat_filesystem(
10-
files: BTreeMap<&str, FileDataSource>,
10+
files: BTreeMap<&str, &FileDataSource>,
1111
out_fat_path: &Path,
1212
) -> anyhow::Result<()> {
1313
const MB: u64 = 1024 * 1024;
@@ -58,7 +58,7 @@ pub fn create_fat_filesystem(
5858

5959
pub fn add_files_to_image(
6060
root_dir: &Dir<&File>,
61-
files: BTreeMap<&str, FileDataSource>,
61+
files: BTreeMap<&str, &FileDataSource>,
6262
) -> anyhow::Result<()> {
6363
for (target_path_raw, source) in files {
6464
let target_path = Path::new(target_path_raw);

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ impl DiskImageBuilder {
199199
&self,
200200
internal_files: BTreeMap<&str, FileDataSource>,
201201
) -> anyhow::Result<NamedTempFile> {
202-
let mut local_map = BTreeMap::new();
202+
let mut local_map: BTreeMap<&str, _> = BTreeMap::new();
203203

204-
for f in &self.files {
205-
local_map.insert(f.0.as_str(), f.1.clone());
204+
for (name, source) in &self.files {
205+
local_map.insert(&name, source);
206206
}
207207

208208
for k in internal_files {
209-
if local_map.insert(k.0, k.1).is_some() {
209+
if local_map.insert(k.0, &k.1).is_some() {
210210
return Err(anyhow::Error::msg(format!(
211211
"Attempted to overwrite internal file: {}",
212212
k.0

0 commit comments

Comments
 (0)