I have a struct NotificationOption
and another struct NotificationOption2
as well as an implementation for From<NotificationOption>
for NotificationOption2
.
I'm would like to convert Vec<NotificationOption>
to a Vec<NotificationOption2>
:
struct NotificationOption {
key: String,
}
struct NotificationOption2 {
key: String,
}
impl From<NotificationOption> for NotificationOption2 {
fn from(n: NotificationOption) -> Self {
Self {
key: n.key,
}
}
}
let options: Vec<NotificationOption> = ...;
let options2: Vec<NotificationOption2> = options.into();
But I get a compiler error:
error[E0277]: the trait bound `Vec<NotificationOption2>: From<Vec<NotificationOption>>` is not satisfied
--> src/main.rs:22:46
|
22 | let options2: Vec<NotificationOption2> = options.into();
| ^^^^^^^ ---- required by a bound introduced by this call
| |
| the trait `From<Vec<NotificationOption>>` is not implemented for `Vec<NotificationOption2>`