conversion corrections

pull/10/head
Alexis Beingessner 10 years ago committed by Manish Goregaokar
parent c3384dde9f
commit 49c9be6c9d

@ -53,7 +53,7 @@ Coercion is allowed between the following types:
* `&mut T` to `*mut T` * `&mut T` to `*mut T`
* Unsizing: `T` to `U` if `T` implements `CoerceUnsized<U>` * Unsizing: `T` to `U` if `T` implements `CoerceUnsized<U>`
`CoerceUnsized<Pointer<U>> for Pointer<T>` where T: Unsize<U> is implemented `CoerceUnsized<Pointer<U>> for Pointer<T> where T: Unsize<U>` is implemented
for all pointer types (including smart pointers like Box and Rc). Unsize is for all pointer types (including smart pointers like Box and Rc). Unsize is
only implemented automatically, and enables the following transformations: only implemented automatically, and enables the following transformations:
@ -65,7 +65,6 @@ only implemented automatically, and enables the following transformations:
* `Foo` is a struct * `Foo` is a struct
* Only the last field has type `T` * Only the last field has type `T`
* `T` is not part of the type of any other fields * `T` is not part of the type of any other fields
(note that this also applies to to tuples as an anonymous struct `Tuple3<T, U, V>`)
Coercions occur at a *coercion site*. Any location that is explicitly typed Coercions occur at a *coercion site*. Any location that is explicitly typed
will cause a coercion to its type. If inference is necessary, the coercion will will cause a coercion to its type. If inference is necessary, the coercion will
@ -106,6 +105,9 @@ fn main() {
^~~ ^~~
``` ```
# The Dot Operator # The Dot Operator
The dot operator will perform a lot of magic to convert types. It will perform The dot operator will perform a lot of magic to convert types. It will perform
@ -113,6 +115,9 @@ auto-referencing, auto-dereferencing, and coercion until types match.
TODO: steal information from http://stackoverflow.com/questions/28519997/what-are-rusts-exact-auto-dereferencing-rules/28552082#28552082 TODO: steal information from http://stackoverflow.com/questions/28519997/what-are-rusts-exact-auto-dereferencing-rules/28552082#28552082
# Casts # Casts
Casts are a superset of coercions: every coercion can be explicitly invoked via a Casts are a superset of coercions: every coercion can be explicitly invoked via a
@ -171,6 +176,8 @@ For numeric casts, there are quite a few cases to consider:
# Conversion Traits # Conversion Traits
TODO? TODO?

Loading…
Cancel
Save