-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Implement the basics of built-in vector types #71
Conversation
4c28670
to
f743d3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, this looks very clean as a foundation for future expansion!
Commented inline.
// vector += vector | ||
impl std::ops::$operator for $vector { | ||
fn $func(&mut self, rhs: $vector) { | ||
$( | ||
self.$components.$func(rhs.$components); | ||
)* | ||
} | ||
} | ||
|
||
// vector += scalar | ||
impl std::ops::$operator<$scalar> for $vector { | ||
fn $func(&mut self, rhs: $scalar) { | ||
$( | ||
self.$components.$func(rhs); | ||
)* | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
In general, the operation a @= b
should be provided if and only if a = a @ b
is provided.
(for any operator @
)
d1e6e61
to
1930877
Compare
I think I addressed all your comments, PTAL. |
For Vector{2,3,4}{,i} this implements: - public fields - constructors - constants - operators - indexing by axis - (private) conversions to/from glam types - Display - a couple of functions like `abs()` and `length()` for demonstration See also godot-rust#6.
1930877
to
66a487a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the update! Only minor things left, I can also apply them myself as there might be some more breaks introduced by my recent clippy addition. Let's see...
bors try
tryBuild failed: |
bors r+ |
Build succeeded: |
This is a great foundation for vector types, thank you very much for this PR! 🚀 I added some minor amendments in a 2nd commit. |
Oh, now I noticed that it's already merged. Still getting used to GitHub's code review workflow... Tiny additional PR coming up... |
For Vector{2,3,4}{,i} this implements:
abs()
andlength()
for demonstrationSee also #6.
This PR supersedes #66.