I'm getting a Unsupported Argument Type error when using #[enum_dispatch]. My code below very closely follows the example from the docs, so I'm not really sure what the issue could be as this error message is very opaque. Any thoughts on what the cause could be or how I could get a more detailed error report? I can run the example fine, so I don't think it's an issue with the compiler.
enum_dispatch = "0.3.5"
undo = {version = "0.46.0", features = ["colored"]}
use undo::{Action, History, Merged};
use enum_dispatch::enum_dispatch;
pub struct AppState{
names: Vec<String>
}
#[enum_dispatch(AppActionTest)]
pub trait AppAction{
fn apply(&mut self, target: &mut AppState) -> Result<(), String>;
fn undo(&mut self, target: &mut AppState) -> Result<(), String>;
fn redo(&mut self, target: &mut AppState) -> Result<(), String> {
self.apply(target)
}
fn merge(&mut self, _: &mut AppActionTest) -> Merged {
Merged::No
}
}
pub struct AddMask;
impl Action for AddMask{
type Target = AppState;
type Output = ();
type Error = String;
fn apply(&mut self, target: &mut AppState) -> Result<(), String>{
dbg!("APPLYING ADD MASK");
Ok(())
}
fn undo(&mut self, target: &mut AppState) -> Result<(), String>{
Ok(())
}
fn redo(&mut self, target: &mut AppState) -> Result<(), String> {
self.apply(target)
}
}
#[enum_dispatch]
pub enum AppActionTest {
AM(AddMask)
}
fn main(){
dbg!("running");
}
gives error statement:
error: custom attribute panicked
--> src\main.rs:41:1
|
41 | #[enum_dispatch]
| ^^^^^^^^^^^^^^^^
|
= help: message: Unsupported argument type
error[E0412]: cannot find type `AppActionTest` in this scope
--> src\main.rs:19:33
|
19 | fn merge(&mut self, _: &mut AppActionTest) -> Merged {
| ^^^^^^^^^^^^^ not found in this scope
I created a repo with this code if you'd like to run it.