Skip to content

Commit f0328e6

Browse files
committed
Follow-up fixes for by-value arguments
1 parent bd5047c commit f0328e6

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

src/bios/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ impl BiosBoot {
1313
/// Start creating a disk image for the given bootloader ELF executable.
1414
pub fn new(kernel_path: &Path) -> Self {
1515
Self {
16-
image_builder: DiskImageBuilder::new(kernel_path),
16+
image_builder: DiskImageBuilder::new(kernel_path.to_owned()),
1717
}
1818
}
1919

2020
/// Add a ramdisk file to the image.
2121
pub fn set_ramdisk(&mut self, ramdisk_path: &Path) -> &mut Self {
22-
self.image_builder.set_ramdisk(ramdisk_path);
22+
self.image_builder.set_ramdisk(ramdisk_path.to_owned());
2323
self
2424
}
2525

src/lib.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,12 @@ impl DiskImageBuilder {
6666

6767
/// Add or replace a kernel to be included in the final image.
6868
pub fn set_kernel(&mut self, path: PathBuf) -> &mut Self {
69-
self.set_file_source(
70-
KERNEL_FILE_NAME.into(),
71-
FileDataSource::File(path.to_path_buf()),
72-
)
69+
self.set_file_source(KERNEL_FILE_NAME.into(), FileDataSource::File(path))
7370
}
7471

7572
/// Add or replace a ramdisk to be included in the final image.
7673
pub fn set_ramdisk(&mut self, path: PathBuf) -> &mut Self {
77-
self.set_file_source(
78-
RAMDISK_FILE_NAME.into(),
79-
FileDataSource::File(path.to_path_buf()),
80-
)
74+
self.set_file_source(RAMDISK_FILE_NAME.into(), FileDataSource::File(path))
8175
}
8276

8377
/// Configures the runtime behavior of the bootloader.
@@ -98,7 +92,7 @@ impl DiskImageBuilder {
9892
///
9993
/// Note that the bootloader only loads the kernel and ramdisk files into memory on boot.
10094
/// Other files need to be loaded manually by the kernel.
101-
pub fn set_file(&mut self, destination: &str, file_path: PathBuf) -> &mut Self {
95+
pub fn set_file(&mut self, destination: String, file_path: PathBuf) -> &mut Self {
10296
self.set_file_source(destination.into(), FileDataSource::File(file_path))
10397
}
10498

@@ -212,11 +206,11 @@ impl DiskImageBuilder {
212206
let mut local_map: BTreeMap<&str, _> = BTreeMap::new();
213207

214208
for (name, source) in &self.files {
215-
local_map.insert(&name, source);
209+
local_map.insert(name, source);
216210
}
217211

218-
for k in internal_files {
219-
if local_map.insert(k.0, &k.1).is_some() {
212+
for k in &internal_files {
213+
if local_map.insert(k.0, k.1).is_some() {
220214
return Err(anyhow::Error::msg(format!(
221215
"Attempted to overwrite internal file: {}",
222216
k.0

src/uefi/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ impl UefiBoot {
1313
/// Start creating a disk image for the given bootloader ELF executable.
1414
pub fn new(kernel_path: &Path) -> Self {
1515
Self {
16-
image_builder: DiskImageBuilder::new(kernel_path),
16+
image_builder: DiskImageBuilder::new(kernel_path.to_owned()),
1717
}
1818
}
1919

2020
/// Add a ramdisk file to the image
2121
pub fn set_ramdisk(&mut self, ramdisk_path: &Path) -> &mut Self {
22-
self.image_builder.set_ramdisk(ramdisk_path);
22+
self.image_builder.set_ramdisk(ramdisk_path.to_owned());
2323
self
2424
}
2525

0 commit comments

Comments
 (0)