Add helper function for adding command to Commands

This commit is contained in:
Joscha 2024-12-29 16:10:58 +01:00
parent b62afb32e6
commit ea53af739a
2 changed files with 43 additions and 28 deletions

View file

@ -153,6 +153,13 @@ pub trait CommandExt: Sized {
fn clap(self) -> clap::Clap<Self> {
clap::Clap(self)
}
fn add_to<E>(self, commands: &mut Commands<E>)
where
Self: Command<E> + Send + Sync + 'static,
{
commands.add(self);
}
}
// Sadly this doesn't work: `impl<E, C: Command<E>> CommandExt for C {}`