Re: Audio Games with Rust?

Update: So looking at Bevy, or the rustdocs at least, it looks like a lot of magic and very little explanation. For example, the example has this line:

   App::build()
       .add_system(hello_world_system.system())
       .run();

That hello_world_system thing is defined as:

fn hello_world_system() {
   println!("hello world");
}

Yet the .add_system() function looks like:

pub fn add_system(&mut self, system: Box<dyn System>) -> &mut Self

This makes no sense to me. The hello_world_system() function returns unit. Therefore, what magic is exactly going on? Because according to the example, the function has no annotations, proc-macros, derivations... nothing. Its just an ordinary rust function, indistinguishable from main(). To add to that, the .system() function is called on the function as though it were an initialized structure. And rust syntax does not allow you to do calls like that on functions -- you have to do that on their return values (I don't know a language that treats functions as objects like this seems to do). So, I'm utterly baffled.... what exactly is going on?



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ty via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Gaki_shonen via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector

Reply via email to