Skip Navigation

InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)DO
Posts
11
Comments
146
Joined
2 yr. 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;
            }
    _ => {},
    }
    
      
  • 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?

  • Well, what I meant was just rustfmt's default with:

    • 80 character line
    • 8-space hard tabs

    In addition to naming local variables short names, and soft-limiting functions to 48 lines long & their local variables to 5-10 (you know, normal reasonable things)

    The part about switch statements doesn't apply as Rust replaced them with match.*

    The part about function brackets on new lines doesn't apply because Rust does have nested functions.

    The bad part about bracket-less if statements doesn't apply as Rust doesn't support such anti-features.

    The part about editor cruft is probably solved in this day & age.

    The rest are either forced by the borrow checker, made obsolete by the great type system, or are just C exclusive issues that are unique to C.

    I left out some parts of the standard that I do not understand.

    I just skimmed through the Rust style guide, and realized the only real difference between the 2 standards is indentation, and line length. Embarrassing.

    *: I experimented with not-indenting the arms of the root match expression, it's surprisingly very good for simple match expressions, and feels very much like a switch, though I am not confident in recommending to people.

    Edit: How did I forget?! Indentation is limited to 3, increasing code readability.

  • So, why don't people just restrict tabs to pre-text, strictly-sized indentation?

    On a side note: I think (not sure) that indenting with 8 or more spaces just to align 2 similar but differently sized lines of code is a bit too much.

  • I am on Pop!_OS, I ran sudo apt install cosmic*.

    Don't worry, you're not missing out on much, running video games, or any OpenGL thing including 2D games and GPU-accelerated terminal emulators is a bad experience, and alt+f4 isn't implemented, and f11 to fullscreen is janky, and theming for buttons and such is clearly alpha.

    The promise of an Arabic-supporting, Rust based, GPU-accelerated terminal is too attractive, however, as I was teared between multilingual terminal, Wezterm, Alacritty and Kitty for a while.

    The first is horrible at everything but supporting languages, the second is really janky, the third doesn't support tabs, the fourth has bad theming and customization.

  • wasting 10% of that space for each indentation? What are you smoking?

    As I said before, this standard is older than C itself, and the kernel's been using it for decades, I shouldn't have to explain it. Long tabs and short lines boost readability, and restricting indentation to 3 solves the problem. Read my reply to 1rre@discuss.tchncs.de for more context.

    Also rustfmt didn't move the string in

    println!("a very long string slice with a static lifetime"); to a new line even when it exceeded a 100 columns, I should seek a solution.

    Note: The actual string I used was way longer than that.

  • A semi-rolling distribution, with access to Ubuntu's many PPA's, and easily removable extensions that reveal the lovely vanilla Gnome experience, it's great!

    Also they are making a Rust desktop, which I am currently running, though not daily driving.

  • It has a long-lasting C coding standard, they call it the standard since it was the only language anyway. Then, they made a newly conceived Rust standards, which ignore everything the original standard stood for. (Note the strong language in the post's first quote, it's from the original standard)

  • My emotions just stopped, so I can now think straight.

    There are really only 2 changes that - in my eyes - should be made:

    • 8 space-long, hard tabs.
    • 80 character limit instead of 100.

    I don't think a tool like rustfmt can affect most of the original guidelines, and it's generally compatible with the OG style by default.

    Edit: I - surprisingly - never actually used rustfmt, so I will go now and test before I say something stupid.

    Edit II: I just found this on their repo:

    Rustfmt is designed to be very configurable.

    Edit III: I tested rustfmt with:

    hard_tabs = true

    max_width = 80

    It's great!

  • Flatpaks never worked for me though, last I tried was 38.

    Also didn't something happen in relation to some encoding?

    Pop!_OS would be my recommendation, semi-rolling for sweet driver updates, Ubuntu based for easy searching (how to do x on Ubuntu) and Large software support.

    I just remembered that Pop!_OS doesn't ship with vanilla gnome, sadly, which degrades its position as a recommendation.

  • US defaultism detected on Lemmic soil, lethal force engaged.

    I find diplomacy hard when one side has been going for complete annihilation of Palestinians, which is only a logical continuation of a 3/4 century long conflict.

    And that one side includes almost every governemnt, including the Palestinian "governemnt".

    But sure, diplomacy's great, if they stopped attacking tommorow, retreated, and said they want to negotiate, and somehow had sufficient evidence to prove that it isn't a trick, and that they reflected and regretted half a century of genocide in 1 day, I would advocate for their diplomatic attempt.

    Random rant of the day: A few months ago I read an article that said: "after Hamas killed thousands of civilians on the 6th of October"; at the time Israel was doing its thing for at least a week and their 'reported' kill count wasn't even a thousand yet, I hate these liars.

  • Ok, I see your point.

    How about sending trained soldiers and cooperating with Hamas?

    Or more easily, stopping trade with Israel?

    Or more easily and more profitably, stopping weapon donations to Israel at the very least?

    I am not speaking to you personally, but if people stop talking about things they become forgotten, so here I am speaking.