News for hackers. Stuff that matters.
Re:Thoughts on Go vs. Rust vs. Zig by raggi on Friday December 05, 2025 @09:18PM (#46169945)

    use std::sync::Mutex;
    fn main() -> Result<(), Box<dyn std::error::Error>> {
        static PEDANTRY: Mutex<u64> = Mutex::new(0);
        *PEDANTRY.lock()? += 1;
        println!("{}", PEDANTRY.lock()?);
        Ok(())
    }
Re:Thoughts on Go vs. Rust vs. Zig by hu3 on Saturday December 06, 2025 @04:36PM (#46176790)
Still different. Yours only increments once. Doesn't pass basic QA.

And declaring a static variable inside a function, even if in main, smells.

Re:Thoughts on Go vs. Rust vs. Zig by raggi on Saturday December 06, 2025 @05:23PM (#46177107)
OP you keep comparing to doesn't even declare the variable. I'm done with you.
Re:Thoughts on Go vs. Rust vs. Zig by umanwizard on Sunday December 07, 2025 @12:31PM (#46183395)
OP 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)]
Re:Thoughts on Go vs. Rust vs. Zig by raggi on Sunday December 07, 2025 @01:07PM (#46183658)
Yup, your example was fine, as I said I just wanted to show a safe method too :-)