• 1 Post
  • 58 Comments
Joined 1 year ago
cake
Cake day: July 2nd, 2023

help-circle

  • Doods@infosec.pubtoProgrammer Humor@lemmy.mlgot him
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    1 month ago

    I just got some idea yesterday regarding impl blocks, ready to be my respondent?

    I had a big impl block with 4 levels of indentation, so I cut the block, and replaced

    impl InputList {
        //snip
    }
    

    with mod impl_inputlist; and moved the impl block to a new file, and did not indent anything inside that block.

    The advantage this has over just not indenting the impl block in place, is that people will have difficulty distinguishing between what’s in the block and what’s outside, and that’s why the impl was moved to its own exclusive file, impl_inputlist.rs

    Maybe I am overstressing indentation. Ss there something wrong with my setup that prevents me from accepting 4-space indentation?

    I use:

    Editor: Neovide

    Font: “FiraCode Nerd Font Mono:h16” (16px fonts are addicintg)

    Monitor: 1366x768, 18.5 inch, 10+ years old, frankenstein-ly repaired Samsung monitor.

    Distance: I sit at about 40-60 Cm from my monitor.

    That leaves me with a 32x99 view of code excluding line numbers and such.


  • Doods@infosec.pubtoProgrammer Humor@lemmy.mlgot him
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    2 months ago

    Formatters are off-topic for this, styles come first, formatters are developed later.

    My other reply:

    How about this one? it more closely mirrors the switch example:

    match suffix {
    'G' | 'g' => mem -= 30,
    'M' | 'm' => mem -= 20,
    'K' | 'k' => mem -= 10,
    _ => {},
    }
    

    How about this other one? it goes as far as cloning the switch example’s indentation:

    match suffix {
    'G' | 'g' => {
    	mem -= 30;
           }
    'M' | 'm' => {
    	mem -= 20;
           }
    'K' | 'k' => {
    	mem -= 10;
           }
    _ => {},
    }
    

  • Doods@infosec.pubtoProgrammer Humor@lemmy.mlgot him
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    2 months ago

    How about this one? it more closely mirrors the switch example:

    match suffix {
    'G' | 'g' => mem -= 30,
    'M' | 'm' => mem -= 20,
    'K' | 'k' => mem -= 10,
    _ => {},
    }
    

    How about this other one? it goes as far as cloning the switch example’s indentation:

    match suffix {
    'G' | 'g' => {
    	mem -= 30;
            }
    'M' | 'm' => {
    	mem -= 20;
            }
    'K' | 'k' => {
    	mem -= 10;
            }
    _ => {},
    }
    

  • Doods@infosec.pubtoProgrammer Humor@lemmy.mlgot him
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    2 months ago

    A single match statement inside a function inside an impl is already 4 levels of indentation.

    How about this?

    The preferred way to ease multiple indentation levels in a switch statement is to align the switch and its subordinate case labels in the same column instead of double-indenting the case labels. E.g.:

    switch (suffix) {
    case 'G':
    case 'g':
            mem <<= 30;
            break;
    case 'M':
    case 'm':
            mem <<= 20;
            break;
    case 'K':
    case 'k':
            mem <<= 10;
            /* fall through */
    default:
            break;
    }
    

    I had some luck applying this to match statements. My example:

    
    let x = 5;
    
    match x {
    5 => foo(),
    3 => bar(),
    1 => match baz(x) {
    	Ok(_) => foo2(),
    	Err(e) => match maybe(e) {
    		Ok(_) => bar2(),
    		_ => panic!(),
    		}
    	}
    _ => panic!(),
    }
    
    

    Is this acceptable, at least compared to the original switch statement idea?



  • Doods@infosec.pubOPtoProgrammer Humor@lemmy.mlI pulled this from a shop.
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    edit-2
    3 months ago

    After searching your comment history for the string: “Doods” (all case) I have something to tell you: git off social media, it took me minutes of flipping pages to reach 5 month old comments before surrendering; I do feel like I know you as well.

    Regarding the general feeling, I experience a similar thing with someone else:

    @PanArab@lemmy.ml, who is noticeable for having one of the few Arabic names on Lemmy, تحريرها كلها ممكن (freeing it all is possible) and for being the moderator of !israelicrimes@lemmy.ml, and for being from Saudi Arabia, we could tell that because:

    a) He has its flag on his account.

    b) He put a picture of an expensive car on top of it, further proving he is from Saudi Arabia (لا مؤاخذة) (Sorry for teasing you)

    Edit: he apparently moderates many other things as well.











  • hmmm…things that don’t require much physical strength and endurance? ( Any answer that is more complex will result in a messy ideological argument, which I don’t want to engage in.

    Actually, you know what? I don’t think I want to continue this argument. I am sorry for provoking your replies and then abandoning the conversion, I really am )

    Edit: I usually don’t do such a thing but I’m not feeling well today.



  • And just as a note for anyone reading, when an Arab says something bad about Jews, like curse the Jews, they are referring to real Jews, as in the ones who actually follow their book*, i.e. the Zionists, not your average self-proclaimed Jew, which is the reason the word ‘Jew’ is sometimes used as a swear word, even if mostly ironically. (kind of like redditors and the French)

    *: I am unqualified to talk about what’s in it, the only things I heard are horrible - mainly war rules - and I made this comment only to prevent misunderstandings by revealing different points of view.