From 698f12a7b4cf403a53e98d5bd3f7318e107079f9 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 27 Aug 2026 07:20:54 +0200 Subject: Change the first argument of Machine::from() into a &Path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes for a saner API, and some users (e.g. vnf-tests) don't have to go over backwards to provide a parameter they already had as a PathBuf. Signed-off-by: Miquel Sabaté Solà --- lib/vnf/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/vnf/src') diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs index e9c7539..b4e2399 100644 --- a/lib/vnf/src/lib.rs +++ b/lib/vnf/src/lib.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use std::fs::File; use std::io::{ErrorKind, Read}; use std::ops::Range; +use std::path::Path; use xixanta::opcodes::AddressingMode; use xixanta::opcodes::{Instruction, InstructionIdentifier, OPCODES}; @@ -337,9 +338,12 @@ impl Machine { /// Initialize a Machine object by reading the ROM file located at /// 'file'. The machine should be initialized to start from the 'start' /// address, and the memory should be initialized with the given 'policy'. - pub fn from(file: &String, start: u16, policy: MemoryPolicy) -> Result { + pub fn from(file: &Path, start: u16, policy: MemoryPolicy) -> Result { let Ok(mut input) = File::open(file) else { - return Err(format!("failed to open the given file '{}'", file)); + return Err(format!( + "failed to open the given file '{}'", + file.display() + )); }; // Read the header in order to detect the PRG ROM size. -- cgit v1.2.3