core::sync: rename Exclusive to SyncView and make improvements#153038
core::sync: rename Exclusive to SyncView and make improvements#153038pthariensflame wants to merge 8 commits intorust-lang:mainfrom
Exclusive to SyncView and make improvements#153038Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This moves the inherent `get_mut` method to be `AsMut::as_mut`, and renames `get_pin_mut` to `as_pin_mut` accordingly. It also constifies the `AsRef` (and `AsMut`) implementations, preserving the `const` status of the original `get_mut`, albeit only unstably.
This completes the existing suite of `as_ref`, `as_mut`, and `as_pin_mut` methods.
0967996 to
b5f2783
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| #[rustc_const_unstable(feature = "const_iter", issue = "92476")] | ||
| impl<T> const Iterator for SyncView<T> | ||
| where | ||
| T: [const] Iterator + ?Sized, |
There was a problem hiding this comment.
This needs to be bounded on Sync – size_hint takes &self.
There was a problem hiding this comment.
We figured this was similar to the case with Debug, which doesn’t need Sync despite taking &self because it doesn’t inspect self in any way. The default definition for size_hint is used here (so giving no information about the underlying iterator) instead of delegating through (which would require T: Sync).
This PR implements the renaming of
core::sync::ExclusivetoSyncViewas decided in #98407. To preserve the ability to search for the old name, it addsExclusiveas adoc_alias.It also makes the following additional changes:
get_mutmethod to being an instance ofAsMut::as_mut. In the process, it makes both the newimpl AsMutand the existingimpl AsRefconst, and it also renamesget_pin_muttoas_pin_mutfor consistency. This direction follows a suggestion from Tracking Issue forExclusive#98407.as_pinmethod that can only be used when the wrapped type implementsSync, to complete the square of access methods.implsconstas possible; this involved making the existingimpl Defaultno longer derived.implfor (const)Iterator, which felt in line with the existingimpls forFutureandCoroutine.impls forAsyncFnOnce,AsyncFnMut, andAsyncFn, akin to the existingimplsforFnOnce,FnMut, andFn.It does not yet do the following, which may be desirable:
std::sync::Exclusiveis dubious #146245.