tree: remove unsafe with ouroboros
for self-referential iterators
#2547
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.
Closes #2127. This is fairly clumsy right now using
with_mut
, so I'm open to alternative ways of writing those cases. Basically, we use it to destructure the struct in question and get immutable/mutable references to all the fields at once.Feel free to commandeer this PR if you are waiting impatiently, as I'm not sure when I'll get time to respond to feedback.
After this, these are the remaining
unsafe
sites:https://github.com/martinvonz/jj/blob/084b99e1e2c42c40f2d52038cdc97687b76fed89/cli/src/cleanup_guard.rs#L60
https://github.com/martinvonz/jj/blob/084b99e1e2c42c40f2d52038cdc97687b76fed89/lib/testutils/src/lib.rs#L56
https://github.com/martinvonz/jj/blob/084b99e1e2c42c40f2d52038cdc97687b76fed89/lib/src/repo.rs#L275
The first two look like unavoidable instances of
unsafe
to me.Checklist
If applicable:
CHANGELOG.md