-
I am reading https://bevyengine.org/learn/book/getting-started/ecs/#your-first-system which contains the following code. use bevy::prelude::*;
fn hello_world() {
println!("hello world!");
}
fn main() {
App::build()
.add_system(hello_world.system())
.run();
} I don't get where the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 15 replies
-
It's an implementation of the bevy/crates/bevy_ecs/src/system/into_system.rs Lines 193 to 195 in 61ce3f7 The implementation specifically for And the actual implementation is generated here, because that function does not have an |
Beta Was this translation helpful? Give feedback.
-
@DJMcNab does that mean that all functions in the file get the |
Beta Was this translation helpful? Give feedback.
-
Obviously I'm simplifying things a bit (and I'm a Rust newbie myself), but hopefully it makes things more understandable. |
Beta Was this translation helpful? Give feedback.
-
Simplifying things a bit. In Bevy there is a code like this: impl IntoSystem for FnMut()
{
fn system(mut self) -> FuncSystem {
...
}
} Which implements When compiler sees
This way That's basically it on the simplest level. |
Beta Was this translation helpful? Give feedback.
Simplifying things a bit.
In Bevy there is a code like this:
Which implements
IntoSystem
for a function without parameters (FnMut()
).When compiler sees
hello_world.system()
it does something like this:hello_world
)? It isFnMut()
.system()
method) onFnMut()
? Yes - theIntoSystem
trait.T…