Skip to content

Commit 2923ad8

Browse files
committed
Take arguments as owned values in set_file and set_file_contents
1 parent 5cabc0c commit 2923ad8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ pub use bios::BiosBoot;
2424
mod fat;
2525
mod file_data_source;
2626

27-
use std::{collections::BTreeMap, fs, path::Path};
27+
use std::{
28+
collections::BTreeMap,
29+
fs,
30+
path::{Path, PathBuf},
31+
};
2832

2933
use anyhow::Context;
3034

@@ -85,13 +89,13 @@ impl DiskImageBuilder {
8589
}
8690

8791
/// Add a file with the specified bytes to the disk image
88-
pub fn set_file_contents(&mut self, destination: &str, data: &[u8]) -> &mut Self {
89-
self.set_file_source(destination, FileDataSource::Data(data.to_vec()))
92+
pub fn set_file_contents(&mut self, destination: &str, data: Vec<u8>) -> &mut Self {
93+
self.set_file_source(destination, FileDataSource::Data(data))
9094
}
9195

9296
/// Add a file with the specified source file to the disk image
93-
pub fn set_file(&mut self, destination: &str, file_path: &Path) -> &mut Self {
94-
self.set_file_source(destination, FileDataSource::File(file_path.to_path_buf()))
97+
pub fn set_file(&mut self, destination: &str, file_path: PathBuf) -> &mut Self {
98+
self.set_file_source(destination, FileDataSource::File(file_path))
9599
}
96100

97101
fn create_fat_filesystem_image(

0 commit comments

Comments
 (0)