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
From is typically implemented for lossless, value-preservingobvious conversions. For example, String::from(&str) would give you a String which has the same content of the &str, and you can even build a &str back from the String.
This works in your example, because you simply copy the field. On the other hand, I think StructB should not implement From<StructA> in the following case:
What it does
Checks for functions and methods that could be a
From
impl (we could even do this forTryFrom
)Advantage
Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: