@@ -984,8 +984,17 @@ impl<T: ?Sized> *const T {
984
984
/// operation because the returned value could be pointing to invalid
985
985
/// memory.
986
986
///
987
+ /// When calling this method, you have to ensure that if the pointer is
988
+ /// non-NULL, then it is properly aligned, dereferencable (for the whole
989
+ /// size of `T`) and points to an initialized instance of `T`. This applies
990
+ /// even if the result of this method is unused!
991
+ /// (The part about being initialized is not yet fully decided, but until
992
+ /// it is, the only safe approach is to ensure that they are indeed initialized.)
993
+ ///
987
994
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
988
- /// not necessarily reflect the actual lifetime of the data.
995
+ /// not necessarily reflect the actual lifetime of the data. It is up to the
996
+ /// caller to ensure that for the duration of this lifetime, the memory this
997
+ /// pointer points to does not get written to outside of `UnsafeCell<U>`.
989
998
///
990
999
/// # Examples
991
1000
///
@@ -1610,8 +1619,17 @@ impl<T: ?Sized> *mut T {
1610
1619
/// operation because the returned value could be pointing to invalid
1611
1620
/// memory.
1612
1621
///
1622
+ /// When calling this method, you have to ensure that if the pointer is
1623
+ /// non-NULL, then it is properly aligned, dereferencable (for the whole
1624
+ /// size of `T`) and points to an initialized instance of `T`. This applies
1625
+ /// even if the result of this method is unused!
1626
+ /// (The part about being initialized is not yet fully decided, but until
1627
+ /// it is, the only safe approach is to ensure that they are indeed initialized.)
1628
+ ///
1613
1629
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
1614
- /// not necessarily reflect the actual lifetime of the data.
1630
+ /// not necessarily reflect the actual lifetime of the data. It is up to the
1631
+ /// caller to ensure that for the duration of this lifetime, the memory this
1632
+ /// pointer points to does not get written to outside of `UnsafeCell<U>`.
1615
1633
///
1616
1634
/// # Examples
1617
1635
///
@@ -1755,10 +1773,24 @@ impl<T: ?Sized> *mut T {
1755
1773
///
1756
1774
/// # Safety
1757
1775
///
1758
- /// As with `as_ref`, this is unsafe because it cannot verify the validity
1776
+ /// As with [ `as_ref`] , this is unsafe because it cannot verify the validity
1759
1777
/// of the returned pointer, nor can it ensure that the lifetime `'a`
1760
1778
/// returned is indeed a valid lifetime for the contained data.
1761
1779
///
1780
+ /// When calling this method, you have to ensure that if the pointer is
1781
+ /// non-NULL, then it is properly aligned, dereferencable (for the whole
1782
+ /// size of `T`) and points to an initialized instance of `T`. This applies
1783
+ /// even if the result of this method is unused!
1784
+ /// (The part about being initialized is not yet fully decided, but until
1785
+ /// it is the only safe approach is to ensure that they are indeed initialized.)
1786
+ ///
1787
+ /// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
1788
+ /// not necessarily reflect the actual lifetime of the data. It is up to the
1789
+ /// caller to ensure that for the duration of this lifetime, the memory this
1790
+ /// pointer points to does not get accessed through any other pointer.
1791
+ ///
1792
+ /// [`as_ref`]: #method.as_ref
1793
+ ///
1762
1794
/// # Examples
1763
1795
///
1764
1796
/// Basic usage:
0 commit comments