• Lucy :3@feddit.org
      link
      fedilink
      arrow-up
      15
      arrow-down
      14
      ·
      12 hours ago

      Average Rust code:

      macro_rules! sum {
          ( $initial:expr $(, $expr:expr )* $(,)? ) => {
              $initial $(+ $expr)*
          }
      }
      
      fn remove_prefix<'a>(mut original: &'a str, prefix: &str) -> &'a str
      
      let mut up = 1;
          'outer: loop {
      

      Hell I don’t want to know what you define as ugly then.

        • wewbull@feddit.uk
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          3
          ·
          7 hours ago

          What language are they then? They’re not Python, JS, <insert any other language here>

          • calcopiritus@lemmy.world
            link
            fedilink
            arrow-up
            3
            ·
            60 minutes ago

            You used macro_rules, which is not common at all. Most rust files don’t contain any macro definition.

            This code doesn’t even compile. There is a random function definition, and then there are loose statements not inside any code block.

            The loop is also annotated, which is not common at all, and when loops are annotated it’s a blessing for readability. Additionally, the loop (+annotation) is indented for some reason.

            And the loop doesn’t contain any codeblock. Just an opening bracket.

            Also, the function definition contains a lifetime annotation. While they are not uncommon, I wouldn’t say the average rust function contains them. Of course their frequency changes a lot depending on context, but in my experience most functions I write/read don’t have lifetime annotations at all.

            Yes, what you wrote somewhat resembles rust. But it is in no way average rust code.

      • flamingo_pinyata@sopuli.xyzOP
        link
        fedilink
        arrow-up
        15
        ·
        10 hours ago

        I don’t know if anyone would argue Rust macros are beautiful. If someone does they should be checked out by a doctor.
        Speaking as a fan of Rust.