@@ -812,6 +812,13 @@ public struct ${Self}<Pointee>
812
812
/// With pointers `p` and `q`, the result of `p.distance(to: q)` is
813
813
/// equivalent to `q - p`.
814
814
///
815
+ /// Typed pointers are required to be properly aligned for their `Pointee`
816
+ /// type. Proper alignment ensures that the result of `distance(to:)`
817
+ /// accurately measures the distance between the two pointers, counted in
818
+ /// strides of `Pointee`. To find the distance in bytes between two
819
+ /// pointers, convert them to `UnsafeRawPointer` instances before calling
820
+ /// `distance(to:)`.
821
+ ///
815
822
/// - Parameter end: The pointer to calculate the distance to.
816
823
/// - Returns: The distance from this pointer to `end`, in strides of the
817
824
/// pointer's `Pointee` type. To access the stride, use
@@ -970,6 +977,13 @@ extension ${Self} {
970
977
/// Returns the distance between two pointers, counted as instances of the
971
978
/// pointers' `Pointee` type.
972
979
///
980
+ /// Typed pointers are required to be properly aligned for their `Pointee`
981
+ /// type. Proper alignment ensures that the result of the subtraction
982
+ /// operator (`-`) accurately measures the distance between the two
983
+ /// pointers, counted in strides of `Pointee`. To find the distance in bytes
984
+ /// between two pointers, convert them to `UnsafeRawPointer` instances
985
+ /// before subtracting.
986
+ ///
973
987
/// - Parameters:
974
988
/// - lhs: A pointer.
975
989
/// - rhs: Another pointer.
0 commit comments