diff --git a/conversions.md b/conversions.md index ad5d240..55b7b20 100644 --- a/conversions.md +++ b/conversions.md @@ -53,7 +53,7 @@ Coercion is allowed between the following types: * `&mut T` to `*mut T` * Unsizing: `T` to `U` if `T` implements `CoerceUnsized` -`CoerceUnsized> for Pointer` where T: Unsize is implemented +`CoerceUnsized> for Pointer where T: Unsize` is implemented for all pointer types (including smart pointers like Box and Rc). Unsize is only implemented automatically, and enables the following transformations: @@ -65,7 +65,6 @@ only implemented automatically, and enables the following transformations: * `Foo` is a struct * Only the last field has type `T` * `T` is not part of the type of any other fields - (note that this also applies to to tuples as an anonymous struct `Tuple3`) 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 @@ -106,6 +105,9 @@ fn main() { ^~~ ``` + + + # The Dot Operator 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 + + + # Casts 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 TODO?