[proposed feature] Allow AutoElements to store an owned local reference #508
+50
−31
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.
Overview
Currently, AutoElements borrows a local reference to a JPrimitiveArray. However, this makes it harder to pass the AutoElements around and make collections of them, since they depend not only on the context but on the local variable that held the array they were borrowed from. This PR changes AutoElements to depend on anything that can AsRef to a JPrimitiveArray, which in practice means either a reference or an owned local reference, or even an AutoLocal.
Another option would be for AutoElements to always create a new local reference, but that could break programs that aren't expecting to allocate more local references just by using AutoElements.
This is a breaking change, since it changes the generic signature of AutoElements.
Is this useful enough to take?
Definition of Done