Skip to content

Commit cc1d51c

Browse files
authored
Merge pull request #1761 from kpreid/patch-2
Mention that “every address” ≠ “every pointer”
2 parents 9e24743 + 7fbcb20 commit cc1d51c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/types/numeric.md

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ r[type.numeric.int.size.usize]
4040
The `usize` type is an unsigned integer type with the same number of bits as the
4141
platform's pointer type. It can represent every memory address in the process.
4242

43+
> [!NOTE]
44+
> While a `usize` can represent every *address*, converting a *pointer* to a `usize` is not necessarily a reversible operation.
45+
> For more information, see the documentation for [type cast expressions], [`std::ptr`], and [provenance][std::ptr#provenance] in particular.
46+
4347
r[type.numeric.int.size.isize]
4448
The `isize` type is a signed integer type with the same number of bits as the
4549
platform's pointer type. The theoretical upper bound on object and array size
@@ -58,3 +62,5 @@ r[type.numeric.validity]
5862

5963
For every numeric type, `T`, the bit validity of `T` is equivalent to the bit
6064
validity of `[u8; size_of::<T>()]`. An uninitialized byte is not a valid `u8`.
65+
66+
[type cast expressions]: ../expressions/operator-expr.md#type-cast-expressions

0 commit comments

Comments
 (0)