Skip to content

fn DisjointImmutGuard::get_unchecked: add unsafe fn to bypass DisjointMut#1479

Merged
kkysen merged 1 commit intomainfrom
kkysen/fn-unchecked_disjoint_mut
Mar 31, 2026
Merged

fn DisjointImmutGuard::get_unchecked: add unsafe fn to bypass DisjointMut#1479
kkysen merged 1 commit intomainfrom
kkysen/fn-unchecked_disjoint_mut

Conversation

@kkysen
Copy link
Copy Markdown
Collaborator

@kkysen kkysen commented Mar 18, 2026

For use in #1439 (comment).

Comment thread src/disjoint_mut.rs Outdated
@randomPoison
Copy link
Copy Markdown
Collaborator

I'm not sure I understand what the point of this change is. DisjointImmutGuard already implements Deref, which gives us a safe way to get the full slice out, and I can't tell what is different about this new unsafe function. Why does the existing Deref impl not work for our purposes here?

@kkysen
Copy link
Copy Markdown
Collaborator Author

kkysen commented Mar 24, 2026

I'm not sure I understand what the point of this change is. DisjointImmutGuard already implements Deref, which gives us a safe way to get the full slice out, and I can't tell what is different about this new unsafe function. Why does the existing Deref impl not work for our purposes here?

The existing deref impl returns a slice that can't outlive the guard. This method does.

@randomPoison
Copy link
Copy Markdown
Collaborator

Ah, I see now, the returned reference isn't tied to the guard, it's tied to the borrow the guard represents, i.e. the original DisjointMut. In that case, I think that should be called out in the documentation for the function and spelled out as part of the safety invariants.

@kkysen kkysen force-pushed the kkysen/fn-unchecked_disjoint_mut branch from cceab5a to 0266fff Compare March 31, 2026 03:10
@kkysen kkysen force-pushed the kkysen/fn-unchecked_disjoint_mut branch from 0266fff to 9fc3603 Compare March 31, 2026 03:22
@kkysen kkysen requested a review from randomPoison March 31, 2026 03:23
@kkysen kkysen changed the title fn DisjointImmutGuard::unchecked_disjoint_mut: add unsafe fn to bypass DisjointMut fn DisjointImmutGuard::get_unchecked: add unsafe fn to bypass DisjointMut Mar 31, 2026
@kkysen kkysen merged commit 17d7897 into main Mar 31, 2026
28 checks passed
@kkysen kkysen deleted the kkysen/fn-unchecked_disjoint_mut branch March 31, 2026 19:25
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.

2 participants