I expected to be able to write:
struct Foo<T = String> {
x: T = String::new(),
}
but I got this error:
error[E0308]: mismatched types
--> src/lib.rs:4:12
|
3 | struct Foo<T = String> {
| ---------- expected this type parameter
4 | x: T = String::new(),
| ^^^^^^^^^^^^^ expected type parameter `T`, found `String`
|
= note: expected type parameter `T`
found struct `String`
It seems like this ought to work. But if not, we should at least improve the error.
I expected to be able to write:
but I got this error:
It seems like this ought to work. But if not, we should at least improve the error.