I have the following code:
match arg {
Num(x) => Ok(forth.stack.push(*x)),
Dup => Arg::dup(forth.stack),
Drop => Arg::drop(forth.stack),
Swap => Arg::swap(forth.stack),
Over => Arg::over(forth.stack),
Oper(operator) => match operator {
Plus => Arg::plus(forth.stack),
Subt => Arg::subt(forth.stack),
Mult => Arg::mult(forth.stack),
Divd => Arg::divd(forth.stack),
},
SemiColon => Ok(()),
Cmd(strng) => Ok(()),
Colon => {
let mut v = vec![];
while let Some(nxt) = iter.next() {
if nxt != &SemiColon {
v.push(*nxt);
} else {
break;
}
}
forth.new_cmd(v);
Ok(())
}
}
This gives me the error mismatched types: expected (), found enum
std::result::Result``. If I remove the Ok(())
near the end, I get match arms have incompatible types: expected enum
std::result::Result, found ()
for the last match. It's a catch-22. How do I fix this?
Not sure if related, but clippy also is weird about this match because I can't have the Colon
arm anywhere but the final position as clippy (or I guess ALE using clippy) removes the comma after the braces.