about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2022-05-16 17:24:53 -0700
committerJosh Stone <jistone@redhat.com>2022-05-16 17:24:53 -0700
commit1f33c921d1e030c1d293b774df079996bcfb2f68 (patch)
treeb9f8cf97d741d960e1c63fe28cd9e25818e44061
parent1e53fab55a0435be8bf4bf3ff9810ce2c73d5977 (diff)
downloadrust-1f33c921d1e030c1d293b774df079996bcfb2f68.tar.gz
rust-1f33c921d1e030c1d293b774df079996bcfb2f68.zip
Add a comment for covariant `Ref`
-rw-r--r--library/core/src/cell.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index d43be569c5b..5448ced803a 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -1318,6 +1318,7 @@ impl Clone for BorrowRef<'_> {
 pub struct Ref<'b, T: ?Sized + 'b> {
     // NB: we use a pointer instead of `&'b T` to avoid `noalias` violations, because a
     // `Ref` argument doesn't hold immutability for its whole scope, only until it drops.
+    // `NonNull` is also covariant over `T`, just like we would have with `&T`.
     value: NonNull<T>,
     borrow: BorrowRef<'b>,
 }
@@ -1704,7 +1705,7 @@ pub struct RefMut<'b, T: ?Sized + 'b> {
     // `RefMut` argument doesn't hold exclusivity for its whole scope, only until it drops.
     value: NonNull<T>,
     borrow: BorrowRefMut<'b>,
-    // NonNull is covariant over T, so we need to reintroduce invariance.
+    // `NonNull` is covariant over `T`, so we need to reintroduce invariance.
     marker: PhantomData<&'b mut T>,
 }