3 ms·
Still different. Yours only increments once. Doesn't pass basic QA. And declaring a static variable inside a function, even if in main, smells.
by hu3 11mo ago
Still different. Yours only increments once. Doesn't pass basic QA.
And declaring a static variable inside a function, even if in main, smells.
- raggi 11mo agoOP you keep comparing to doesn't even declare the variable. I'm done with you.
- School-Cotton 11mo agoOP here, not showing how to declare the variable was an oversight on my part. static mut COUNTER: u32 = 0; (at top-level) If on 2024 edition, you will additionally need #![allow(static_mut_refs)]
- raggi 11mo agoYup, your example was fine, as I said I just wanted to show a safe method too :-)