Skip to content
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

Remove GuestMemoryIterator, replace with GAT #278

Merged
merged 3 commits into from
Oct 8, 2024

Conversation

roypat
Copy link
Collaborator

@roypat roypat commented Jan 4, 2024

Use an implicit generic associated type to realize GuestMemory::iter(). This removes the pre-GAT workaround used here to get an iterator that borrows values with the same lifetime as the &self parameter to .iter().

This is a follow up from a discussion between @Ablu and me on Slack. I was cleaning up my workspace and decided to just put it out here to get some comments. Note that this requires rustc 1.75.0 to compile.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR are signed (with git commit -s), and the commit
    message has max 60 characters for the summary and max 75 characters for each
    description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@roypat roypat changed the title [RFC] Remove GuestMemoryIterator, replace with GAT Remove GuestMemoryIterator, replace with GAT Oct 2, 2024
Use an implicit generic associated type to realize GuestMemory::iter().
This removes the pre-GAT workaround used here to get an iterator that
borrows values with the same lifetime as the `&self` parameter to
`.iter()`.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
@roypat
Copy link
Collaborator Author

roypat commented Oct 2, 2024

@stefano-garzarella what do you think about this? I compiled both vm-virto and vhost workspaces against this without issues, and now that Rust 1.75.0 and impl-trait-in-trait have been out for a while, I think it's a nice simplification we can make

@stefano-garzarella
Copy link
Member

@roypat I'm not a vm-memory expert, but I like this simplification, especially if it does not require changes from crate users!

@roypat roypat requested a review from rbradford October 7, 2024 06:47
@roypat roypat mentioned this pull request Oct 7, 2024
4 tasks
@roypat roypat merged commit 805a232 into rust-vmm:main Oct 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants