• onlinepersona
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    9 months ago

    Do you mean this for loop?

    for shape in &shapes {
      accum += shape.area();
    }
    

    That does use an iterator

    for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common practice within Rust, which is to loop over anything that implements IntoIterator until the iterator returned by .into_iter() returns None (or the loop body uses break).

    Anti Commercial AI thingy

    CC BY-NC-SA 4.0

    • arendjr
      link
      fedilink
      arrow-up
      9
      ·
      9 months ago

      I think they meant using for accumulating, like this:

      shapes.iter().map(Shape::area).sum()
      
      • Turun@feddit.de
        link
        fedilink
        arrow-up
        4
        ·
        9 months ago

        Yes. That’s what I meant.

        Though I heavily expect the rust compiler to produce identical assembly for both types of iteration.

        • sugar_in_your_tea@sh.itjust.works
          link
          fedilink
          arrow-up
          3
          arrow-down
          1
          ·
          9 months ago

          Anti Commercial AI thingy

          Off-topic, but does that actually work? I would assume OpenAI would just ignore it and you’d have to prove that they did so.

          • onlinepersona
            link
            fedilink
            English
            arrow-up
            5
            ·
            9 months ago

            Dunno if it works. AI has been tricked into revealing it’s training data, so it’s possible that it happens and they are sued for using copyrighted material.

            This is my drop in the ocean.

            Anti Commercial AI thingy

            CC BY-NC-SA 4.0

              • onlinepersona
                link
                fedilink
                English
                arrow-up
                3
                ·
                9 months ago

                Welcome 🙂 A drop more.

                Btw, if you’re using linux and X11, you can bind a keyboard shortcut to the following shell-script (probably will need to install xte).

                #!/usr/bin/env bash
                sleep 0.5
                xte "str ::: spoiler Anti Commercial AI thingy"
                xte "key Return"
                xte "str [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)"
                xte "key Return"
                xte "str :::"
                
                Anti Commercial AI thingy

                CC BY-NC-SA 4.0

                • sugar_in_your_tea@sh.itjust.works
                  link
                  fedilink
                  arrow-up
                  3
                  ·
                  9 months ago

                  I’m on Wayland, but I’m sure I can figure something out.

                  I do most of my lemmy-ing on mobile, so I’ll probably make a bot to auto-edit my posts or something.

                  • onlinepersona
                    link
                    fedilink
                    English
                    arrow-up
                    3
                    ·
                    9 months ago

                    Have fun! I’m curious how you’ll do it. If you figure out a way on Wayland, it would be great to read about it!

                    Anti Commercial AI thingy

                    CC BY-NC-SA 4.0