Názor k článku Rust: programovací jazyk do aut, vlaků a letadel od alex6bbc - found this :-) //Hello. I want my own local...

  • Článek je starý, nové názory již nelze přidávat.
  • 1. 11. 2023 21:47

    alex6bbc

    found this :-)

    //Hello. I want my own local copy of your Widget that I will manipulate,
    //but I don't want my changes to affect the one you have. I may or may not
    //hold onto it for later, but that's none of your business.
    void foo(Widget w);

    //Hello. I want to take your Widget and play with it. It may be in a
    //different state than when you gave it to me, but it'll still be yours
    //when I'm finished. Trust me!
    void foo(Widget& w);

    //Hello. Can I see that Widget of yours? I don't want to mess with it;
    //I just want to check something out on it. Read that one value from it,
    //or observe what state it's in. I won't touch it and I won't keep it.
    void foo(const Widget& w);

    //Hello. Ooh, I like that Widget you have. You're not going to use it
    //anymore, are you? Please just give it to me. Thank you! It's my
    //responsibility now, so don't worry about it anymore, m'kay?
    void foo(Widget&& w);