@@ -142,13 +142,13 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> core::ops::DispatchFromDyn<Arc<U>> for Ar
142
142
143
143
// SAFETY: It is safe to send `Arc<T>` to another thread when the underlying `T` is `Sync` because
144
144
// it effectively means sharing `&T` (which is safe because `T` is `Sync`); additionally, it needs
145
- // `T` to be `Send` because any thread that has a `Arc<T>` may ultimately access `T` directly, for
145
+ // `T` to be `Send` because any thread that has an `Arc<T>` may ultimately access `T` directly, for
146
146
// example, when the reference count reaches zero and `T` is dropped.
147
147
unsafe impl < T : ?Sized + Sync + Send > Send for Arc < T > { }
148
148
149
- // SAFETY: It is safe to send `&Arc<T>` to another thread when the underlying `T` is `Sync` for
150
- // the same reason as above. `T` needs to be `Send` as well because a thread can clone a `&Arc<T>`
151
- // into a `Arc<T>`, which may lead to `T` being accessed by the same reasoning as above.
149
+ // SAFETY: It is safe to send `&Arc<T>` to another thread when the underlying `T` is `Sync` for the
150
+ // same reason as above. `T` needs to be `Send` as well because a thread can clone an `&Arc<T>`
151
+ // into an `Arc<T>`, which may lead to `T` being accessed by the same reasoning as above.
152
152
unsafe impl < T : ?Sized + Sync + Send > Sync for Arc < T > { }
153
153
154
154
impl < T > Arc < T > {
@@ -237,8 +237,9 @@ impl<T: ?Sized> Arc<T> {
237
237
/// receiver), but we have a [`Arc`] instead. Getting a [`ArcBorrow`] is free when optimised.
238
238
#[ inline]
239
239
pub fn as_arc_borrow ( & self ) -> ArcBorrow < ' _ , T > {
240
- // SAFETY: The constraint that lifetime of the shared reference must outlive that of
241
- // the returned `ArcBorrow` ensures that the object remains alive.
240
+ // SAFETY: The constraint that the lifetime of the shared reference must outlive that of
241
+ // the returned `ArcBorrow` ensures that the object remains alive and that no mutable
242
+ // reference can be created.
242
243
unsafe { ArcBorrow :: new ( self . ptr ) }
243
244
}
244
245
}
@@ -402,8 +403,8 @@ impl<T: ?Sized> ArcBorrow<'_, T> {
402
403
/// # Safety
403
404
///
404
405
/// Callers must ensure the following for the lifetime of the returned [`ArcBorrow`] instance:
405
- /// 1. That `obj ` remains valid;
406
- /// 2. That no mutable references to `obj ` are created.
406
+ /// 1. That `inner ` remains valid;
407
+ /// 2. That no mutable references to `inner ` are created.
407
408
unsafe fn new ( inner : NonNull < ArcInner < T > > ) -> Self {
408
409
// INVARIANT: The safety requirements guarantee the invariants.
409
410
Self {
@@ -436,15 +437,15 @@ impl<T: ?Sized> Deref for ArcBorrow<'_, T> {
436
437
437
438
/// A refcounted object that is known to have a refcount of 1.
438
439
///
439
- /// It is mutable and can be converted to a [`Arc`] so that it can be shared.
440
+ /// It is mutable and can be converted to an [`Arc`] so that it can be shared.
440
441
///
441
442
/// # Invariants
442
443
///
443
444
/// `inner` always has a reference count of 1.
444
445
///
445
446
/// # Examples
446
447
///
447
- /// In the following example, we make changes to the inner object before turning it into a
448
+ /// In the following example, we make changes to the inner object before turning it into an
448
449
/// `Arc<Test>` object (after which point, it cannot be mutated directly). Note that `x.into()`
449
450
/// cannot fail.
450
451
///
0 commit comments