1 comments

  • pducks32 1862 days ago
    This is super fantastic. Well written and just the right amount of approachfulness and wit. Sometimes articles about things like this go too far into metaphor and lose the reader. I'd recommment going over

        fn mv_mutable(mut a : MyThing) {}
    
    a little bit as in when you might want to do this and especially

        fn mutable_ref_mutable(mut a : &mut MyThing) {}
    
    as I write a lot fo rust and still never understand how this works or why its useful. Lastly maybe an explainer of conforming to `Copy` and if you should do this because I believe currently the recommendation is conform to it for any type you can and I still have to stop and think how that's more performant. But again really great article, I bookmarked it for reference ;)
    • saghm 1862 days ago
      > fn mv_mutable(mut a : MyThing) {}

      Compared to simply `a: MyThing`, there are two main reasons when you'd want to do this, namely a) when you want to reassign a different value to `a` or b) when you want to make a mutable reference to `a` (i.e. `&mut a`).

      > fn mutable_ref_mutable(mut a : &mut MyThing) {}

      Since you already have an `&mut MyThing`, reason "b" from above doesn't apply here, generally the only reason you'd need to do this is if you wanted to reassign a different value to `a`. Technically you would also need it if for some reason you needed an `&mut &mut MyThing`, but that isn't likely to be something you need very often.