|
24 | 24 | /// (`u8`, `bool`, `str`, pointers, ...) whereas `From` and `Into` also works with types like
|
25 | 25 | /// `String` or `Vec`.
|
26 | 26 | ///
|
| 27 | +/// You'll also find with `From` and `Into`, and indeed all traits, that `as` is used for the |
| 28 | +/// _fully qualified syntax_, a means of clarifying ambiguous method calls. If you have a type which |
| 29 | +/// implements two traits with identical method names (e.g. `Into<u32>` and `Into<u64>`), you can |
| 30 | +/// clarify which method you use with `<MyThing as Into<u32>>::into(my_thing)`. This is quite |
| 31 | +/// verbose, but fortunately, Rust's type inference usually saves you from needing this, although it |
| 32 | +/// is occasionally necessary. |
| 33 | +/// |
27 | 34 | /// `as` can also be used with the `_` placeholder when the destination type can be inferred. Note
|
28 | 35 | /// that this can cause inference breakage and usually such code should use an explicit type for
|
29 | 36 | /// both clarity and stability. This is most useful when converting pointers using `as *const _` or
|
|
0 commit comments