Reword explanation of 'size' types.#32906
Conversation
Do not reference machine 'pointers' in explanation of 'size' types.
src/doc/book/primitive-types.md
Outdated
| and unsigned varieties. This makes for two types: `isize` and `usize`. | ||
| Rust also provides types whose particular size depends on the underlying machine | ||
| architecture. Their range is sufficient to express sizes of collections and they | ||
| are used to address items in a vector, for example. These types have ‘size’ as |
There was a problem hiding this comment.
I find the "for example" part misplaced or too much.
Simplify explanation and rephrase as per @GuillaumeGomez's suggestion.
src/doc/book/primitive-types.md
Outdated
| Rust also provides types whose particular size depends on the underlying machine | ||
| architecture. Their range is sufficient to express the size of any collection, so | ||
| these types have ‘size’ as the category. They come in signed and unsigned varieties | ||
| which makes for two types: `isize` and `usize`. |
|
|
|
@petrochenkov: I didn't understand that he said it was an implementation detail, on the contrary. |
|
@petrochenkov I think the reason I picked up on this when first reading the Rust book is that the introduction of integral types mentions pointers while pointers themselves have been moved (appropriately) towards the end of the chapter. I feel that for an introductory text, the notion of the »largest size you'd want to express« (ignoring special purposes such as file-system interfaces) succinctly describes the purpose of these types, while the reference should of course state that they are defined to be pointer-sized. |
Replace "make for" by the slightly more accurate "account for".
|
@bors: r+ rollup thanks! |
|
📌 Commit a548d4d has been approved by |
…labnik Reword explanation of 'size' types. Do not reference machine 'pointers' in explanation of 'size' types. I think the number of elements that can be directly addressed is a fundamental feature of a machine architecture in its own right. The fact that it coincides with the ‘size’ of a pointer should be viewed as an ‘implementation detail’ ;)
Do not reference machine 'pointers' in explanation of 'size' types.
I think the number of elements that can be directly addressed is a fundamental feature of a machine architecture in its own right. The fact that it coincides with the ‘size’ of a pointer should be viewed as an ‘implementation detail’ ;)