*_operand.rs: Directly delegate when possible in Display
This commit is contained in:
parent
7901c24d80
commit
2f867a67ad
@ -126,20 +126,21 @@ impl From<SecondaryOperand> for PrimaryOperand {
|
||||
}
|
||||
|
||||
impl Display for PrimaryOperand {
|
||||
// Turn the operand back into a form which parses into the same type
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Direct(r) => write!(f, "{r}"),
|
||||
Self::Direct(r) => Display::fmt(r, f),
|
||||
Self::Indirect(r) => write!(f, "@{r}"),
|
||||
Self::PostInc(r) => write!(f, "@{r}+"),
|
||||
Self::Indexed(r, idx) => write!(f, "{idx}({r})"),
|
||||
Self::Absolute(n) => write!(f, "&{n}"),
|
||||
Self::Immediate(n) => write!(f, "#{n}"),
|
||||
Self::Four => write!(f, "#4"),
|
||||
Self::Eight => write!(f, "#8"),
|
||||
Self::Zero => write!(f, "#0"),
|
||||
Self::One => write!(f, "#1"),
|
||||
Self::Two => write!(f, "#2"),
|
||||
Self::MinusOne => write!(f, "#-1"),
|
||||
Self::Four => Display::fmt("#4", f),
|
||||
Self::Eight => Display::fmt("#8", f),
|
||||
Self::Zero => Display::fmt("#0", f),
|
||||
Self::One => Display::fmt("#1", f),
|
||||
Self::Two => Display::fmt("#2", f),
|
||||
Self::MinusOne => Display::fmt("#-1", f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,11 +85,11 @@ impl Parsable for SecondaryOperand {
|
||||
impl Display for SecondaryOperand {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Direct(r) => write!(f, "{r}"),
|
||||
Self::Direct(r) => Display::fmt(r, f),
|
||||
Self::Indexed(r, idx) => write!(f, "{idx}({r})"),
|
||||
Self::Absolute(n) => write!(f, "&{n}"),
|
||||
Self::Zero => write!(f, "#0"),
|
||||
Self::One => write!(f, "#1"),
|
||||
Self::Zero => Display::fmt("#0", f),
|
||||
Self::One => Display::fmt("#1", f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user