-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Have System::run_unsafe
return Result
.
#19145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
8ba30ec
a9c6c84
f4960bd
c2b009b
8c8c67e
809514c
632e3d6
d3e72ca
ba48caa
80546b2
26c723f
f0db7b4
ad6be24
b006848
202efa1
f03e910
1de29ca
cdbd498
a30cc18
e78e0cd
9c591d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ use alloc::{borrow::Cow, boxed::Box, format}; | |
use core::ops::Not; | ||
|
||
use crate::system::{ | ||
Adapt, AdapterSystem, CombinatorSystem, Combine, IntoSystem, ReadOnlySystem, System, SystemIn, | ||
SystemInput, | ||
Adapt, AdapterSystem, CombinatorSystem, Combine, IntoSystem, ReadOnlySystem, RunSystemError, | ||
System, SystemIn, SystemInput, | ||
}; | ||
|
||
/// A type-erased run condition stored in a [`Box`]. | ||
|
@@ -59,7 +59,7 @@ pub type BoxedCondition<In = ()> = Box<dyn ReadOnlySystem<In = In, Out = bool>>; | |
/// ``` | ||
/// # use bevy_ecs::prelude::*; | ||
/// fn identity() -> impl Condition<(), In<bool>> { | ||
/// IntoSystem::into_system(|In(x)| x) | ||
/// IntoSystem::into_system(|In(x): In<bool>| x) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is another type inference failure. It has something to do with the fact that the output type is tied to the input type, as changing it to return |
||
/// } | ||
/// | ||
/// # fn always_true() -> bool { true } | ||
|
@@ -1110,9 +1110,9 @@ impl<S: System<Out: Not>> Adapt<S> for NotMarker { | |
fn adapt( | ||
&mut self, | ||
input: <Self::In as SystemInput>::Inner<'_>, | ||
run_system: impl FnOnce(SystemIn<'_, S>) -> S::Out, | ||
) -> Self::Out { | ||
!run_system(input) | ||
run_system: impl FnOnce(SystemIn<'_, S>) -> Result<S::Out, RunSystemError>, | ||
) -> Result<Self::Out, RunSystemError> { | ||
run_system(input).map(Not::not) | ||
} | ||
} | ||
|
||
|
@@ -1148,10 +1148,10 @@ where | |
|
||
fn combine( | ||
input: <Self::In as SystemInput>::Inner<'_>, | ||
a: impl FnOnce(SystemIn<'_, A>) -> A::Out, | ||
b: impl FnOnce(SystemIn<'_, A>) -> B::Out, | ||
) -> Self::Out { | ||
a(input) && b(input) | ||
a: impl FnOnce(SystemIn<'_, A>) -> Result<A::Out, RunSystemError>, | ||
b: impl FnOnce(SystemIn<'_, A>) -> Result<B::Out, RunSystemError>, | ||
) -> Result<Self::Out, RunSystemError> { | ||
Ok(a(input)? && b(input)?) | ||
} | ||
} | ||
|
||
|
@@ -1169,10 +1169,10 @@ where | |
|
||
fn combine( | ||
input: <Self::In as SystemInput>::Inner<'_>, | ||
a: impl FnOnce(SystemIn<'_, A>) -> A::Out, | ||
b: impl FnOnce(SystemIn<'_, B>) -> B::Out, | ||
) -> Self::Out { | ||
!(a(input) && b(input)) | ||
a: impl FnOnce(SystemIn<'_, A>) -> Result<A::Out, RunSystemError>, | ||
b: impl FnOnce(SystemIn<'_, A>) -> Result<B::Out, RunSystemError>, | ||
) -> Result<Self::Out, RunSystemError> { | ||
Ok(!(a(input)? && b(input)?)) | ||
} | ||
} | ||
|
||
|
@@ -1190,10 +1190,10 @@ where | |
|
||
fn combine( | ||
input: <Self::In as SystemInput>::Inner<'_>, | ||
a: impl FnOnce(SystemIn<'_, A>) -> A::Out, | ||
b: impl FnOnce(SystemIn<'_, B>) -> B::Out, | ||
) -> Self::Out { | ||
!(a(input) || b(input)) | ||
a: impl FnOnce(SystemIn<'_, A>) -> Result<A::Out, RunSystemError>, | ||
b: impl FnOnce(SystemIn<'_, A>) -> Result<B::Out, RunSystemError>, | ||
) -> Result<Self::Out, RunSystemError> { | ||
Ok(!(a(input)? || b(input)?)) | ||
} | ||
} | ||
|
||
|
@@ -1211,10 +1211,10 @@ where | |
|
||
fn combine( | ||
input: <Self::In as SystemInput>::Inner<'_>, | ||
a: impl FnOnce(SystemIn<'_, A>) -> A::Out, | ||
b: impl FnOnce(SystemIn<'_, B>) -> B::Out, | ||
) -> Self::Out { | ||
a(input) || b(input) | ||
a: impl FnOnce(SystemIn<'_, A>) -> Result<A::Out, RunSystemError>, | ||
b: impl FnOnce(SystemIn<'_, A>) -> Result<B::Out, RunSystemError>, | ||
) -> Result<Self::Out, RunSystemError> { | ||
Ok(a(input)? || b(input)?) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wrote it this way for consistency, but the short-circuiting behavior of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was told this short-circuiting was preferable in review to avoid breaking existing code and reduce pointless failures. I'm not sure I agree still, but it's best to split that change out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't quite follow. What would you like me to split out? The core change here is making I think the only behavior change to existing code is that a failing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My preference was to leave the behavior completely unchanged in this PR. That said, I prefer this behavior and won't block on it. |
||
} | ||
} | ||
|
||
|
@@ -1232,10 +1232,10 @@ where | |
|
||
fn combine( | ||
input: <Self::In as SystemInput>::Inner<'_>, | ||
a: impl FnOnce(SystemIn<'_, A>) -> A::Out, | ||
b: impl FnOnce(SystemIn<'_, B>) -> B::Out, | ||
) -> Self::Out { | ||
!(a(input) ^ b(input)) | ||
a: impl FnOnce(SystemIn<'_, A>) -> Result<A::Out, RunSystemError>, | ||
b: impl FnOnce(SystemIn<'_, A>) -> Result<B::Out, RunSystemError>, | ||
) -> Result<Self::Out, RunSystemError> { | ||
Ok(!(a(input)? ^ b(input)?)) | ||
} | ||
} | ||
|
||
|
@@ -1253,10 +1253,10 @@ where | |
|
||
fn combine( | ||
input: <Self::In as SystemInput>::Inner<'_>, | ||
a: impl FnOnce(SystemIn<'_, A>) -> A::Out, | ||
b: impl FnOnce(SystemIn<'_, B>) -> B::Out, | ||
) -> Self::Out { | ||
a(input) ^ b(input) | ||
a: impl FnOnce(SystemIn<'_, A>) -> Result<A::Out, RunSystemError>, | ||
b: impl FnOnce(SystemIn<'_, A>) -> Result<B::Out, RunSystemError>, | ||
) -> Result<Self::Out, RunSystemError> { | ||
Ok(a(input)? ^ b(input)?) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idly interested in benchmarks of this. Removing the branch here should be net positive.