From 216456d702b0d1158bdf57e70f59bd43cfcbe70f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 3 Jan 2017 22:29:15 -0800 Subject: [PATCH] Add more docs for CoerceUnsized and Unsize --- coercions.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coercions.md b/coercions.md index 6a9ebd6..b699946 100644 --- a/coercions.md +++ b/coercions.md @@ -17,6 +17,7 @@ Coercion is allowed between the following types: * `&T` to `*const T` * `&mut T` to `*mut T` * Unsizing: `T` to `U` if `T` implements `CoerceUnsized` +* Deref coercion: Expression `&x` of type `&T` to `&*x` of type `&U` if `T` derefs to `U` (i.e. `T: Deref`) `CoerceUnsized> for Pointer where T: Unsize` is implemented for all pointer types (including smart pointers like Box and Rc). Unsize is @@ -27,8 +28,9 @@ only implemented automatically, and enables the following transformations: * `Foo<..., T, ...>` => `Foo<..., U, ...>` where: * `T: Unsize` * `Foo` is a struct - * Only the last field of `Foo` has type `T` + * Only the last field of `Foo` has type involving `T` * `T` is not part of the type of any other fields + * `Bar: Unsize>`, if the last field of `Foo` has type `Bar` 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