use ferroui_system::IDisposable;
use std::any::Any;
use std::rc::Rc;
pub trait ICommand {
fn can_execute(&self, parameter: Option<&dyn Any>) -> bool;
fn execute(&self, parameter: Option<&dyn Any>);
fn can_execute_changed(&self, handler: Rc<dyn Fn()>) -> Rc<dyn IDisposable>;
}
impl PartialEq for dyn ICommand {
#[inline]
fn eq(&self, other: &Self) -> bool {
std::ptr::addr_eq(self as *const Self, other as *const Self)
}
}
impl<C: ICommand + ?Sized> ICommand for Rc<C> {
fn can_execute(&self, parameter: Option<&dyn Any>) -> bool {
(**self).can_execute(parameter)
}
fn execute(&self, parameter: Option<&dyn Any>) {
(**self).execute(parameter)
}
fn can_execute_changed(&self, handler: Rc<dyn Fn()>) -> Rc<dyn IDisposable> {
(**self).can_execute_changed(handler)
}
}