@@ -4209,19 +4209,19 @@ println!("{}", v[2]);
4209
4209
"## ,
4210
4210
4211
4211
E0604 : r##"
4212
- A cast to `char` was attempted on another type than `u8`.
4212
+ A cast to `char` was attempted on a type other than `u8`.
4213
4213
4214
4214
Erroneous code example:
4215
4215
4216
4216
```compile_fail,E0604
4217
4217
0u32 as char; // error: only `u8` can be cast as `char`, not `u32`
4218
4218
```
4219
4219
4220
- As the error message indicates, only `u8` can be casted into `char`. Example:
4220
+ As the error message indicates, only `u8` can be cast into `char`. Example:
4221
4221
4222
4222
```
4223
4223
let c = 86u8 as char; // ok!
4224
- assert !(c, 'V');
4224
+ assert_eq !(c, 'V');
4225
4225
```
4226
4226
"## ,
4227
4227
@@ -4232,15 +4232,15 @@ Erroneous code examples:
4232
4232
4233
4233
```compile_fail,E0605
4234
4234
let x = 0u8;
4235
- x as Vec<u8>; // error: non-scalar cast: `u8` as `std::vec::Vec<u8>`
4235
+ x as Vec<u8>; // error: non-primitive cast: `u8` as `std::vec::Vec<u8>`
4236
4236
4237
4237
// Another example
4238
4238
4239
4239
let v = 0 as *const u8; // So here, `v` is a `*const u8`.
4240
- v as &u8; // error: non-scalar cast: `*const u8` as `&u8`
4240
+ v as &u8; // error: non-primitive cast: `*const u8` as `&u8`
4241
4241
```
4242
4242
4243
- Only primitive types cast be casted into each others . Examples:
4243
+ Only primitive types can be cast into each other . Examples:
4244
4244
4245
4245
```
4246
4246
let x = 0u8;
@@ -4261,8 +4261,8 @@ let x = &0u8; // Here, `x` is a `&u8`.
4261
4261
let y: u32 = x as u32; // error: casting `&u8` as `u32` is invalid
4262
4262
```
4263
4263
4264
- When casting, keep in mind that only primitive types cast be casted into each
4265
- others . Example:
4264
+ When casting, keep in mind that only primitive types can be cast into each
4265
+ other . Example:
4266
4266
4267
4267
```
4268
4268
let x = &0u8;
@@ -4282,15 +4282,16 @@ v as *const [u8];
4282
4282
4283
4283
First: what are thin and fat pointers?
4284
4284
4285
- Thin pointers are "simple" pointers that simply reference a memory address.
4285
+ Thin pointers are "simple" pointers: they are purely a reference to a memory
4286
+ address.
4286
4287
4287
4288
Fat pointers are pointers referencing Dynamically Sized Types (also called DST).
4288
- They don't have a statically known size, therefore they can only exist behind
4289
+ DST don't have a statically known size, therefore they can only exist behind
4289
4290
some kind of pointers that contain additional information. Slices and trait
4290
- objects are DSTs.
4291
+ objects are DSTs. In the case of slices, the additional information the fat
4292
+ pointer holds is their size.
4291
4293
4292
- So in order to fix this error, don't try to cast directly between thin and fat
4293
- pointers.
4294
+ To fix this error, don't try to cast directly between thin and fat pointers.
4294
4295
"## ,
4295
4296
4296
4297
E0609 : r##"
0 commit comments