• 0 Posts
  • 64 Comments
Joined 7 months ago
cake
Cake day: November 24th, 2023

help-circle










  • RustyNova@lemmy.worldtoProgrammer Humor@lemmy.mllocal warzone
    link
    fedilink
    arrow-up
    20
    arrow-down
    1
    ·
    edit-2
    1 month ago

    Apart from the search engines being both shitty, here there’s nothing wrong

    If you installed an extension to use bing search, what you want is to use bing search, not Google. So of course the extension has to say “don’t switch”

    There’s also a good point on chrome’s side. There’s extensions that will switch your default search engine without your consent, so having the possibility to undo directly is nice.

    Another way to see it, would be to switch chrome for firefox, Google search for duck duck go, and bing to qwant. Same story, but no shitty companies clouding judgements




  • Oh, then you use and_then() or something similar.

    There’s also the possibility to use the guard clauses patern and do let <...> = <...> else {}.

    And finally, you can always split into another function.

    It’s not straight rules. It depends on what makes it more readable for your case.





  • RustyNova@lemmy.worldtoProgrammer Humor@lemmy.mlgot him
    link
    fedilink
    arrow-up
    27
    arrow-down
    2
    ·
    edit-2
    2 months ago

    While I totally agree with that philosophy, it heavily depends on the language.

    For Rust, my philosophy is more like this:

    • Impl + fn body don’t count, as well as async blocks if they span the whole function
    • do not nest more than one if statement. You probably better using guard clauses or matches
    • do not put loops into an if statement.
    • do not nest loops unless clearly shown to be (X, Y) indexing
    • method chaining is free
    • do not nest closures, unless the nested closure doesn’t have a {} block
    • do not use mod unless it’s test for the current module. No I don’t want to Star Wars scroll your 1000 line file. Split it.