[-] [email protected] 1 points 1 day ago* (last edited 1 day ago)

Even if you were using the builder pattern, this maintains the immutable variable in the parent scope while you use the mutable variable's builder pattern methods (basically exactly as my example demonstrates) in the inner scope.

edit: Oh, I think you mean you would chain the builder pattern calls and assign it to an immutable variable. Sure, that makes sense if you own the struct.

[-] [email protected] 2 points 1 day ago* (last edited 1 day ago)

I prefer to encapsulate a mutable reference to the instance in a scope.

let post_form = {
    let mut post_form = PostInsertForm::new(
        // your constructor arguments
    );
    post_form.some_mutating_method(
        // mutation arguments
    );
    post_form
};

This way you're left with an immutable instance and you encapsulate all of the logic needed to setup the instance in one place.

[-] [email protected] 10 points 4 days ago
[-] [email protected] 16 points 4 days ago

Eternal Sunshine of the Spotless Mind

[-] [email protected] 3 points 4 days ago

For those looking for more of the same great fun, please do yourself a favor and check out RiffTrax (link below). Done by the same guy.

https://www.rifftrax.com/

[-] [email protected] 3 points 6 days ago

I've literally sat down in city centers surrounded by buildings. It's an amazing feeling.

[-] [email protected] 19 points 6 days ago

I wish I could experience that. I wish our sci-fi fairytales of space travel were happening now. Alas, I must simply exist in a life lived better than a king of old, living longer than our ancestors, with food untasted by the billions before us, and all while I fly around in space within Eve Online while watching Star Trek. Life is great, but it's so easy to want it to be just that much better.

[-] [email protected] 21 points 2 months ago

Neovim. I tried to use it a year ago, but I felt like I was fighting it every time I just wanted to make progress on my project. VSCode doesn't get in my way. I'm going to give it another shot in a few years.

[-] [email protected] 70 points 2 months ago

You can just pinch the end of a banana to start peeling it. The effort required is far less than trying to overcome the ripping force of the stem.

[-] [email protected] 36 points 4 months ago

Your team needs to have a coding standards meeting where you can describe the pros and cons of each approach. You guys shouldn't be wasting time during PR reviews on the same argument. When that happens to me, it just feels like such a waste of time.

[-] [email protected] 19 points 5 months ago

It's surprising how useful ChatGpt is in these situations. Honestly, it's a great general purpose search engine.

[-] [email protected] 57 points 1 year ago

As someone who learned a lot from C++ and that now loves Rust, this annoys me.

view more: next ›

livingcoder

joined 1 year ago