How to stop ( loop forever )

⚓ Rust    📅 2026-05-26    👤 surdeus    👁️ 1      

surdeus

Clippy is warning about my code here:

    while stop {
        // Program is terminating, loop forever.
        std::thread::sleep(std::time::Duration::from_millis(100));
    }

the message:

    |
145 |         while stop {
    |               ^^^^
    |
    = note: this may lead to an infinite or to a never running loop
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.96.0/index.html#while_immutable_condition
    = note: `#[deny(clippy::while_immutable_condition)]` on by default

For now I have just suppressed it with

#[allow(clippy::while_immutable_condition)]

but I was wondering is there is a more elegant solution. Also, is there a simpler way of sleeping forever?

6 posts - 4 participants

Read full topic

🏷️ Rust_feed