615
The easiest problem (discuss.tchncs.de)
you are viewing a single comment's thread
view the rest of the comments
[-] PoolloverNathan@programming.dev 3 points 2 weeks ago

I present to you quality variable names. (and a Mount Rustmore)

(Reconfigure(f), 'c') => {
    let mut p: Vec<&str> = vec![];
    loop {
        match args.next() {
            Some(k) => {
                if k == "=" {
                    match args.next() {
                        None => q("need value for Rc"),
                        Some(v) => u(
                            f,
                            |f| Box::new(
                                |c| {
                                    f(c);
                                    c.set(p.iter().copied(), v);
                                    for e in p {
                                        unsafe {
                                            Box::<str>::from_raw(
                                                std::mem::transmute(e)
                                            );
                                        }
                                    }
                                }
                            )
                        )
                    };
                    break
                } else {
                    p.push(Box::leak(k.into()));
                }
            }
            None => error("need path element or = for Rc"),
        }
    }
},
[-] lseif@sopuli.xyz 1 points 2 weeks ago
[-] PoolloverNathan@programming.dev 2 points 2 weeks ago

Argument parsing; turning Rc foo = bar into Reconfigure(|c| c.foo = "bar").

this post was submitted on 07 May 2024
615 points (97.5% liked)

Programmer Humor

17735 readers
26 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 11 months ago
MODERATORS