Skip to content

Commit 1f33c92

Browse files
committed
Add a comment for covariant Ref
1 parent 1e53fab commit 1f33c92

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/core/src/cell.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,7 @@ impl Clone for BorrowRef<'_> {
13181318
pub struct Ref<'b, T: ?Sized + 'b> {
13191319
// NB: we use a pointer instead of `&'b T` to avoid `noalias` violations, because a
13201320
// `Ref` argument doesn't hold immutability for its whole scope, only until it drops.
1321+
// `NonNull` is also covariant over `T`, just like we would have with `&T`.
13211322
value: NonNull<T>,
13221323
borrow: BorrowRef<'b>,
13231324
}
@@ -1704,7 +1705,7 @@ pub struct RefMut<'b, T: ?Sized + 'b> {
17041705
// `RefMut` argument doesn't hold exclusivity for its whole scope, only until it drops.
17051706
value: NonNull<T>,
17061707
borrow: BorrowRefMut<'b>,
1707-
// NonNull is covariant over T, so we need to reintroduce invariance.
1708+
// `NonNull` is covariant over `T`, so we need to reintroduce invariance.
17081709
marker: PhantomData<&'b mut T>,
17091710
}
17101711

0 commit comments

Comments
 (0)