Эта функция компилирует:
fn edit<S: AsRef<str>>(w: S) {}
Если я наберу общие параметры:
type Word = dyn AsRef<str>;
fn edit(w: Word) {}
Я получаю сообщение об ошибке:
error[E0277]: the size for values of type `(dyn std::convert::AsRef<str> + 'static)` cannot be known at compilation time
--> src/lib.rs:3:9
|
3 | fn edit(w: Word) {}
| ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `(dyn std::convert::AsRef<str> + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
Почему это происходит?