Skip to content
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

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

Open
pixmusix opened this issue Sep 10, 2024 · 0 comments
Open

Comments

@pixmusix
Copy link

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 ❣️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant