Click here to Skip to main content
15,887,746 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
JokeThis one seems appropriate on a leap day... PinPopular
Sander Rossel29-Feb-24 0:54
professionalSander Rossel29-Feb-24 0:54 
GeneralRe: This one seems appropriate on a leap day... Pin
BernardIE531729-Feb-24 1:45
BernardIE531729-Feb-24 1:45 
GeneralRe: This one seems appropriate on a leap day... Pin
snorkie29-Feb-24 2:16
professionalsnorkie29-Feb-24 2:16 
GeneralRe: This one seems appropriate on a leap day... Pin
PIEBALDconsult29-Feb-24 2:57
mvePIEBALDconsult29-Feb-24 2:57 
GeneralRe: This one seems appropriate on a leap day... Pin
obermd29-Feb-24 3:37
obermd29-Feb-24 3:37 
GeneralRe: This one seems appropriate on a leap day... Pin
StarNamer@work29-Feb-24 8:02
professionalStarNamer@work29-Feb-24 8:02 
GeneralRe: This one seems appropriate on a leap day... Pin
jmaida29-Feb-24 17:20
jmaida29-Feb-24 17:20 
GeneralRust and its ways Pin
Rob Philpott28-Feb-24 21:57
Rob Philpott28-Feb-24 21:57 
Good morning CodeProject!

I’ve decided to teach myself something new - apparently it’s important for older people to do that to stop them going mental. So behind the back of my loving, dependable and reliable C# I’ve been having a risqué affair with Rust. Turns out that developing in Rust is about 30% expressing your intention in code and 70% arguing with a bad-tempered bureaucratic compiler for who simply nothing seems good enough.

I decided my first project would be a Suduko solver, which is done and it works, but there was an interesting point in the development where different runs would dish out differing results. I was using a HashSet internally, and like in .NET you shouldn’t make any assumptions about the order of the items if you iterate over it. Fair enough, but I would expect it to be consistent in that ordering between say releases of the .NET framework.

Not so in Rust. Here’s a Rust program:
use std::collections::HashSet;

fn main() {

    let mut set = HashSet::new();

    for n in 0..5 {
        set.insert(n);
    }

    for n in set {
        println!("{}", n);
    }
}

And here’s the output from running it twice:

0
3
2
1
4

and

0
2
1
3
4

Interesting huh? Something non-deterministic is going on. I haven’t debugged the HashSet yet to find out, but I’m presuming it’s using some random number or aspect of time somehow. I spoke with 'Gemini' about it yesterday and it agreed it's interesting, so thought I'd share it. Smile | :)
Regards,
Rob Philpott.

GeneralRe: Rust and its ways Pin
Peter_in_278028-Feb-24 22:43
professionalPeter_in_278028-Feb-24 22:43 
GeneralRe: Rust and its ways Pin
Rob Philpott28-Feb-24 23:07
Rob Philpott28-Feb-24 23:07 
GeneralRe: Rust and its ways Pin
Amarnath S29-Feb-24 1:58
professionalAmarnath S29-Feb-24 1:58 
GeneralRe: Rust and its ways Pin
markkuk1-Mar-24 0:30
markkuk1-Mar-24 0:30 
GeneralRe: Rust and its ways Pin
Rob Philpott5-Mar-24 21:03
Rob Philpott5-Mar-24 21:03 
JokeGot pulled over by a police officer... PinPopular
Sander Rossel28-Feb-24 21:35
professionalSander Rossel28-Feb-24 21:35 
GeneralRe: Got pulled over by a police officer... Pin
Mike Hankey28-Feb-24 21:56
mveMike Hankey28-Feb-24 21:56 
GeneralRe: Got pulled over by a police officer... Pin
jmaida29-Feb-24 12:39
jmaida29-Feb-24 12:39 
GeneralRe: Got pulled over by a police officer... Pin
Mike Hankey29-Feb-24 12:59
mveMike Hankey29-Feb-24 12:59 
GeneralRe: Got pulled over by a police officer... Pin
dandy721-Mar-24 4:09
dandy721-Mar-24 4:09 
GeneralRe: Got pulled over by a police officer... Pin
jmaida1-Mar-24 14:58
jmaida1-Mar-24 14:58 
GeneralRe: Got pulled over by a police officer... Pin
jmaida29-Feb-24 14:40
jmaida29-Feb-24 14:40 
RantThanks, Outlook! Pin
Richard Deeming28-Feb-24 21:16
mveRichard Deeming28-Feb-24 21:16 
GeneralRe: Thanks, Outlook! Pin
Cp-Coder29-Feb-24 0:49
Cp-Coder29-Feb-24 0:49 
GeneralRe: Thanks, Outlook! Pin
Richard Deeming29-Feb-24 2:54
mveRichard Deeming29-Feb-24 2:54 
GeneralRe: Thanks, Outlook! Pin
GKP199229-Feb-24 3:06
professionalGKP199229-Feb-24 3:06 
GeneralRe: Thanks, Outlook! Pin
abmv29-Feb-24 4:06
professionalabmv29-Feb-24 4:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.