♻️ Implement From<&str> and From<String> traits to MachineError, and simplified opiw_instruction
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
use std::fmt;
|
||||
use std::fmt::{self, Error};
|
||||
|
||||
/// Machine Error
|
||||
/// This error serves as a specific exception handler for the Machine struct
|
||||
@ -41,4 +41,16 @@ impl fmt::Display for MachineError {
|
||||
write!(f, "Machine error: {}", &self.message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl From<&str> for MachineError {
|
||||
fn from(value: &str) -> Self {
|
||||
MachineError { message: value.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for MachineError {
|
||||
fn from(value: String) -> Self {
|
||||
MachineError { message: value }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user