-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables GATs iteration in the Element API (#442)
This PR replaces all uses of `Box<dyn Iterator<Item=_> + 'a>` in the `Element` and `ElementRef` APIs with generic associated types. This means that heap allocations are no longer required to iterate over annotations, sequence elements, or struct fields. Because this change uses generic associated types, it also configures the CI tests to use the beta channel of cargo. GATs will be available in the next release of Rust (v1.65, out in November); once that happens, we can and should switch back to stable. (#443) This change also removes the recently added dependency on the `linkhash` crate. That dependency was originally pulled in so structs could remember the order in which their fields were inserted for later iteration. However, it only worked if the struct did not contain duplicate field names. This PR changes the field storage for `Struct` and `StructRef` to store their fields in a `Vec` and also maintain a `HashMap<Symbol, IndexVec>` that remembers all of the indexes at which values for a given field can be found. Further, it moves `Sequence` elements and `Struct` fields into an `Rc` to make clone() operations cheaper. A future PR will modify iterators over collection types to clone the `Rc` and thus remove one of their lifetime constraints, making it much easier to write a recursive iterator over an element tree without constant cloning.
- Loading branch information
Showing
15 changed files
with
531 additions
and
222 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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.