nannou-org / nannou

A Creative Coding Framework for Rust.
https://nannou.cc/
6.04k stars 305 forks source link

mismatched types when referencing the app from an instance of a struct. #978

Open pixmusix opened 2 months ago

pixmusix commented 2 months ago

I want to include a reference to the app inside my structure. This will allow my instance to refer to the window and time of the application. This will require me to assign a lifetime of the reference. I think that lifetime should be static based on my reading of the lib.rs file.

struct ParticleSystem {
    app : &'static App,
    particles: Vec<Particle>,
}

However

error[E0308]: mismatched types --> src/main.rs:256:17 256 nannou::app(model).update(update).run(); ----------- ^^^^^ one type is more general than the other
arguments to this function are incorrect

= note: expected fn pointer for<'a> fn(&'a nannou::App) -> _ found fn item fn(&'static nannou::App) -> Model {model}

I've actually not encounter this error before but I get the gist. It feels like I'm either one sprinkle of syntactic sugar away from compiling or my approach is simply wrong.

May I have some guidance? Thanks 👍 Pix ❣️