-
Notifications
You must be signed in to change notification settings - Fork 153
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 std::ops traits on references #335
Labels
Comments
This would be very much appreciated. I'm often working with references to vectors throughout my codebase, and this is a common point of friction. I don't want to have to dereference my vectors just to include them in operations. |
Closed
Arithmetic ops added for vector types, reopened to look at other core::ops impls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
It's good practice for both
T
and&T
to implement e.g.Add<T>
andAdd<&T>
, even ifT: Copy
. Primitive types already do this, butVec2
etc. currently don't.This is important in generic contexts such as
struct Foo<T> { x: T }
.T
might not beCopy
, so to avoid unnecessary cloning, you canimpl<T> Add<&Foo<T>> for Foo<T> where T: Add<&T>
. However, this excludesFoo<Vec2>
becauseVec2: !Add<&Vec2>
.The following paragraph from the
std::ops
documentation is relevant:The text was updated successfully, but these errors were encountered: