Skip to content

Commit 64546c4

Browse files
committed
condense impls
1 parent 1cf6ebd commit 64546c4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

crates/bevy_ecs/src/system/commands/config.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,7 @@ macro_rules! impl_fallible_commands {
141141
#[inline]
142142
#[allow(dead_code)]
143143
fn return_unit(&self) {}
144-
}
145144

146-
impl<'a, C, T> $name<'a, C, T>
147-
where
148-
C: FallibleCommand,
149-
C::Error: Debug,
150-
T: AddCommand,
151-
{
152145
/// If the command failed, run the provided `error_handler`.
153146
///
154147
/// ## Note
@@ -167,6 +160,7 @@ macro_rules! impl_fallible_commands {
167160
/// commands.spawn().insert(42).on_err(|error, ctx| {});
168161
/// }
169162
/// ```
163+
#[inline]
170164
pub fn on_err(
171165
&mut self,
172166
error_handler: impl FnOnce(C::Error, CommandContext) + Send + Sync + 'static,
@@ -188,9 +182,13 @@ macro_rules! impl_fallible_commands {
188182
C: FallibleCommand,
189183
T: AddCommand,
190184
{
185+
#[inline]
191186
fn drop(&mut self) {
192-
if self.command.is_some() {
193-
self.on_err(CommandErrorHandler::log);
187+
if let Some(command) = self.command.take() {
188+
self.inner.add_command(HandledErrorCommand {
189+
command,
190+
error_handler: CommandErrorHandler::log,
191+
});
194192
}
195193
}
196194
}

0 commit comments

Comments
 (0)