You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the TryFrom section, is it worth mentioning that you cannot implement both From and TryFrom since if From is implemented for a given type T, an infallible TryFrom is also auto-implemented for you. Therefore you end up with conflicting trait implementations for the same type. For example, let's say you implement both From and TryFrom for Point, you get the following error:
error[E0119]: conflicting implementations of trait `TryFrom<(i32, i32)>` for type `Point`
--> src/main.rs:22:1
|
22 | impl TryFrom<(i32, i32)> for Point {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T, U> TryFrom<U> for T
where U: Into<T>;
For more information about this error, try `rustc --explain E0119`.
error: could not compile `foo` due to previous error
The text was updated successfully, but these errors were encountered:
In the
TryFrom
section, is it worth mentioning that you cannot implement bothFrom
andTryFrom
since ifFrom
is implemented for a given type T, an infallibleTryFrom
is also auto-implemented for you. Therefore you end up with conflicting trait implementations for the same type. For example, let's say you implement bothFrom
andTryFrom
forPoint
, you get the following error:The text was updated successfully, but these errors were encountered: