Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    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(())
    }




Still different. Yours only increments once. Doesn't pass basic QA.

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


OP you keep comparing to doesn't even declare the variable. I'm done with you.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: