-
Notifications
You must be signed in to change notification settings - Fork 5
Consider taking self
instead of &self
#1
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
Comments
Thank you for your interest! I like the idea of being able to compare Is it possible to implement the existing trait for |
I've thought about it a little more, and I understand where you're coming from, here are my thoughts:
That said, I don't think returning an iterator is possible unless it is I do want to point out that without changing the traits it would be possible to implement over slices, however due to the limitation I mentioned about lifetimes, the output would need to be allocated and wouldn't work in |
Oh! I must admit, I haven't thought that deeply about why I think that my main potential worry is to do with the API becoming harder to use if different levels of borrowing start to conflict with one another at compile time (as this thread seems to suggest), but it's easy enough to write tests to cover those cases to check. The other thing is that I don't understand how these kinds of trait definitions might interact when they overlap yet, so that's also as much a learning exercise on my part too. If you wished to investigate this yourself, I'd be happy to look at a PR, with the caveat that I'm new to using git/github so it might take me longer than you're used to! Otherwise, I can have a go at implementing it when I get the chance :) |
Right, I've done some more thinking/research and I have some further thoughts, my last reply may have been a bit hasty. I've not thought about the implications for
Makes sense, thank you for explaining. If I understand the implications correctly, binary operations using a non-borrowed
This also makes sense - I agree that In terms of The Hopefully that makes sense? |
I completely agree that You may be right about the implications in asserts (though shared references are |
I've created an issue for making the change to FloatDiff. I'm going to leave FloatEq in terms of references, since I think that's more idiomatic. |
I wanted to look into implementing these traits for
Iterator
s, but taking&self
makes that a little difficult. With the current traits there isn't a convenient way to implement the following blanket impl:My proposed changes:
self
f32
,f64
,Complex
remain unchanged since they are allCopy
.IntoIterator
, returning iterators overAbsDiff
, etc.[T; N]
to&[T; N]
(if they are even still necessary, arrays implementIntoIterator
)Let me know what you think and if you'd like a little help implementing it, I didn't want to go change everything and just drop a PR without bringing it up :)
The text was updated successfully, but these errors were encountered: