An implementation of a mathematical 2D vector type with tests

Hello there!

I would love it if you could drop in a comment about this code. What can I change to make a better API and/or more accurate implementation of the mathematical type? I uploaded it as a gist.

Thank you for your time!

scalar / vector division doesn’t make much sense in terms of (standard) mathematical notation. Maybe just skip that part, of if you need the functionality of element-wise multiplicative inversion for some other use, consider using a descriptively named method instead.

To be clear, the other division, vector / scalar, is reasonable in my opinion.


Thank you for your input! I made a revision to my code to fix that.

Given that this is a small Copy type, it would seem reasonable to me to make the non-self argument of fn dot a by-value argument – instead of by-reference – too. I see you already changed the &self itself to self, anyways.


I have clippy to thank for that one! :smiley:

In your opinion, would it make sense to continue passing self by value when I make types with more dimensions? Would it impact the performance in any significant way?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.