The Default impl on the Command struct has the following bounds, autogenerated by derivative:
impl<U, E> Default for Command<U, E>
where U: Default,
E: Default
However, U and E don't actually need to have a Default implementation, since none of the fields in Command require construction of either to have a Default impl, and there isn't any reason why they ever would in the future - user data isn't stored in Command and E is only returned as the Err variant of Result, where constructing the Ok variant is always possible to get a default value. It would also be silly in most cases for the error to have a Default impl, and most error types don't, making this impl useless for nearly all cases.
My usecase for this is to have a command for which the subcommands are determined from a const variable in a different module - something like this:
The
Default
impl on theCommand
struct has the following bounds, autogenerated byderivative
:However,
U
andE
don't actually need to have aDefault
implementation, since none of the fields inCommand
require construction of either to have aDefault
impl, and there isn't any reason why they ever would in the future - user data isn't stored inCommand
andE
is only returned as theErr
variant ofResult
, where constructing theOk
variant is always possible to get a default value. It would also be silly in most cases for the error to have aDefault
impl, and most error types don't, making this impl useless for nearly all cases.My usecase for this is to have a command for which the subcommands are determined from a const variable in a different module - something like this:
whereas now I have to do something like this:
I suppose in this case this isn't that big of a deal though (though it might matter more in other cases).