Trait Object Auto Implementation That Passes Itself to a Function?

That, or, on nightly,

#![feature(specialization)]

default impl<T /* : Sized */> CliCommand for T {
    fn to_cli_command (self: &'_ Self) -> &'_ dyn CliCommand
    {
        self
    }
}

See this post for a more detailed answer: Explanation on fn(self: Box<Self>) for trait objects - #5 by Yandros

1 Like