Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing operators for Vector2<T> #106

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

henriquecolini
Copy link

I have noticed that there are a couple of very common operator implementations missing for Vector2.

Namely, Neg (-vec) and left scalar Mul (scalar * vec). The latter is interesting, because it seems to be just a Rust limitation, as it would require implementing a foreign trait for a completely foreign type.

That said, putting a scalar on the left side of the multiplication is so common (standard in textbooks) that I implemented that for the concrete Vector2s in dimen.rs.

Additionally, I included a rotate_180_degrees() method to Vector2 that simply negates it, for completeness sake.

@QuantumBadger
Copy link
Owner

Thank you, this looks good! Would you mind adding some unit tests for this please?

The Clippy failures look like issues with main, I'll fix these now.

@QuantumBadger
Copy link
Owner

Clippy is now fixed on main, if you rebase the CI should pass :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants