
[英]How `impl From<AsRef<A>> for B` correctly: "the size for values of type `(dyn AsRef<address2::A> + 'static)` cannot be known at compilation time"
[英]How to use this impl<T> From<T> for B where T: AsRef<A> twice: conflicting implementations of trait `std::convert::From<_>` for type `B`
struct A {}
struct B {}
struct C {}
impl<T> From<T> for B
where
T: AsRef<A>,
{
fn from(_: T) -> Self {
todo!()
}
}
impl<T> From<T> for B
where
T: AsRef<C>,
{
fn from(_: T) -> Self {
todo!()
}
}
它给我的错误是
error[E0119]: conflicting implementations of trait `std::convert::From<_>` for type `B`
--> src/main.rs:59:1
|
50 | impl<T> From<T> for B
| --------------------- first implementation here
...
59 | impl<T> From<T> for B
| ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `B`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.