-
Notifications
You must be signed in to change notification settings - Fork 321
Add raw array pointer types #496
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
355b153
Make do_collapse_axis return offset instead of performing it
jturner314 ebf864f
Add DataRaw and DataRawMut traits
jturner314 2a98148
Add RawArrayView and RawArrayViewMut
jturner314 0a7fafd
Add conversions to/from RawArrayView(Mut)
jturner314 8baa1cc
Relax constraints on ArrayBase methods
jturner314 4b91c6b
Remove duplication in from_shape_ptr and split_at
jturner314 e2fcf22
Add DataRawClone and relax Clone implementation
jturner314 6ef3b48
Remove deref_view and deref_view_mut
jturner314 c81ccdd
Deprecate the DataClone trait
jturner314 218bb88
Rename DataRaw* traits to RawData*
jturner314 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we can be without this trait, and just use DataClone?
Clone
is the only consumer of the traitThere 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.
In current
ndarray
,DataClone
has aData
bound. If we want to be able to cloneArrayPtr
/ArrayPtrMut
, this is too restrictive given only the current implementation ofClone
forArrayBase
. Possible alternatives to the approach in this PR:Don't add a
DataRawClone
trait; instead, implementClone
individually forArrayPtr
andArrayPtrMut
. That would be inconsistent and would prevent code with just aDataClone
bound from being able to cloneArrayPtr
andArrayPtrMut
.With a breaking change, though, we could get rid of
DataClone
entirely and just implementClone
individually forArcArray
,Array
,ArrayView
,ArrayPtr
, andArrayPtrMut
. This actually seems pretty nice, but it does make writing generic code more difficult. (In user code, the bound to allowarray.clone()
would have to beArrayBase<S, D>: Clone
instead ofS: DataRawClone
.)Add the
DataRawClone
trait and remove theDataClone
trait. That would work but would be a breaking change.Fwiw,
DataClone
does have a small amount of utility as the combination ofData
andDataRawClone
, but I agree it does seem like unnecessary complication.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.
(2) I think a breaking change is ok. We have lots of them queued? We should get on to merging them as soon as 0.12.1 is released (and I can do the releasing if you want).
I'd hope it has very little impact on users, but maybe I underestimate how much these representation traits are used?
I'd use the name
DataClone
for the new trait.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.
The only thing that I don't like about this is consistency of naming with the other data traits, especially
DataMut
vs.DataRawMut
. I was naming traits without aData
boundDataRaw*
and traits with aData
boundData*
.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.
Good point. We still should use only one trait if we don't need 2, we could use the name DataRawClone and let DataClone be a deprecated reexport of it.
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.
DataClone could be a trait alias of DataRawClone + Data? That's a new Rust feature we can transition to.
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.
Woah, I had no idea trait aliases were a thing. They look very convenient.
I've added a commit deprecating
DataClone
. We can switchDataClone
to a trait alias once they're available on stable.