-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Direct cast to a polymorphic trait type is not supported directly #3635
Comments
This is more-or-less working as intended, although there are further changes coming to trait types. Previously, traits as types were implicitly boxed, but not written with The current functionality is still very limited, and not often used. |
Oh, it isn't possible to directly cast to a value-type trait because they don't have a fixed size (similar to how it isn't possible to use a plain |
Hmm, I still believe that section "15.6 Casting to an interface type" on the tutorial should be revised to reflect this (in the future, when it is working anyways). |
Here's the tutorial text for 0.4: https://github.com/mozilla/rust/blob/incoming/doc/tutorial.md#casting-to-a-trait-type-and-dynamic-method-dispatch |
It seems that one is not able to cast to a polymorphic type directly e.g.
does not work, but
does.
It might be a documentation bug if one is only allowed to cast to a trait pointer type (as it is shown in the tutorial that one can cast to Drawable trait directly), or it might be an implementation bug regarding traits with type parameters.
The text was updated successfully, but these errors were encountered: