Use wide pointers consistenly across the compiler
This commit is contained in:
parent
f7c8928f03
commit
018ba0528f
41 changed files with 120 additions and 120 deletions
|
@ -1,4 +1,4 @@
|
|||
A cast between a thin and a fat pointer was attempted.
|
||||
A cast between a thin and a wide pointer was attempted.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
|
@ -7,18 +7,18 @@ let v = core::ptr::null::<u8>();
|
|||
v as *const [u8];
|
||||
```
|
||||
|
||||
First: what are thin and fat pointers?
|
||||
First: what are thin and wide pointers?
|
||||
|
||||
Thin pointers are "simple" pointers: they are purely a reference to a memory
|
||||
address.
|
||||
|
||||
Fat pointers are pointers referencing Dynamically Sized Types (also called
|
||||
Wide pointers are pointers referencing Dynamically Sized Types (also called
|
||||
DSTs). DSTs don't have a statically known size, therefore they can only exist
|
||||
behind some kind of pointer that contains additional information. For example,
|
||||
slices and trait objects are DSTs. In the case of slices, the additional
|
||||
information the fat pointer holds is their size.
|
||||
information the wide pointer holds is their size.
|
||||
|
||||
To fix this error, don't try to cast directly between thin and fat pointers.
|
||||
To fix this error, don't try to cast directly between thin and wide pointers.
|
||||
|
||||
For more information about type casts, take a look at the section of the
|
||||
[The Rust Reference][1] on type cast expressions.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue