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

Event loop being interpreted as a global variable #3969

Closed
code-Cells opened this issue Oct 24, 2024 · 2 comments
Closed

Event loop being interpreted as a global variable #3969

code-Cells opened this issue Oct 24, 2024 · 2 comments
Labels
B - bug Dang, that shouldn't have happened DS - x11

Comments

@code-Cells
Copy link

code-Cells commented Oct 24, 2024

Description

I tried running the https://docs.rs/winit/latest/winit/index.html example as is and keep getting the error message

  --> src/main.rs:43:1
   |
43 | let event_loop = EventLoop::new().unwrap();
   | ^^^ consider using `const` or `static` instead of `let` for global variables

Because of the lines below, it makes no sense for it to be a global variable.

event_loop.set_control_flow(ControlFlow::Poll);
event_loop.set_control_flow(ControlFlow::Wait);

Took some time researching, but didn't manage to fiend an issue about this. Is this a known one?

Also tried 0.30.1, and got the same problem.

OS and window mananger

Linux Mint 21.3
x11 cinnamon

Winit version

0.30.5

@code-Cells code-Cells added B - bug Dang, that shouldn't have happened DS - x11 labels Oct 24, 2024
@kchibisov
Copy link
Member

kchibisov commented Oct 24, 2024

put them inside fn main() { /* your code here */ }.

@madsmtm
Copy link
Member

madsmtm commented Oct 25, 2024

To expand a little bit, the example is using the common rustdoc convention of eliding the main function in examples which Rust otherwise requires.

I have been thinking though, perhaps it would make sense to not do that here? Opened #3971 for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened DS - x11
Development

No branches or pull requests

3 participants