-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add ?Sized
bound to SourceCode to allow casting
&str` into it.
#414
Comments
I think this is happening because you’re trying to turn try casting |
Well, it is implemented for I couldn't do it with |
actually afaik that is currently a restriction of the rust compiler, you can't actually use CoerceUnsized for !Sized objects. I don't know why the error message is so confusing, that could certainly use some improvement. See the section here, it mentiones https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html |
Well, in any case, it seems like this is a rust bug. That trait is clearly implemented for It is a bit of a paradox that you can implement a trait for an unsized type but can't actually use it. |
well you can use it, you just can't perform the unsizing coercion on |
Well, that certainly went over my head :) In any case, I gathered from your explanation that making |
I'm trying to cast a borrowed
&str
to adyn SourceCode
but I'm receiving the error:error[E0277]: the size for values of type
strcannot be known at compilation time
and
help: the trait `Sized` is not implemented for `str`
note: required for the cast from `&str` to `&dyn SourceCode`
Which leads me to
Source Code
's definition, where it is said to be implemented bystr
and&str
(as expected), but it is not marked as?Sized
which I suspect is the reason why this cast can't be made.The text was updated successfully, but these errors were encountered: