4
jestdotty
54d

can option pls override or operator

this is stupid

say no to

let branch = branch.unwrap_or(config.branch.unwrap_or("something".to_string()));

say yes to

let branch = branch || config.branch || "something".to_string();

Comments
  • 0
    let branch = branch

    Is this a typo?
  • 1
    @jestdotty When I first read that, I thought yes, the second one with the or operators is much nicer.

    But now I've thought about it for a few minutes, I prefer the first one. The act of trying to unwrap and moving to the next thing if you can't is made explicit, you can see what's going on. Now the second one looks confusing.

    I find this happens a lot with rust.

    Wtf is that -> actually that's ok -> ooh that's a good idea -> that's better than C#.
  • 1
    Honestly, I just map over those monads and let it fail fast and hard otherwise
  • 3
    @kobenz Some years ago, I googled "what the fuck is a monad", and discovered to my delight that someone had written an article with that exact title.

    I read it then, and I've just re-read it now, and I still don't know what the fuck a monad is.
  • 0
    I think I've read that one, @donkulator. This one's shorter, faster and easier
    https://adit.io/posts/...
Add Comment